runtime-dom.esm-bundler.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540
  1. import { h, BaseTransition, BaseTransitionPropsValidators, assertNumber, warn, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createVNode, getCurrentInstance, watchPostEffect, onMounted, onUnmounted, Fragment, Static, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, isRuntimeOnly, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
  2. export * from '@vue/runtime-core';
  3. import { extend, isObject, toNumber, isArray, isString, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isOn, isModelListener, isFunction, camelize as camelize$1, EMPTY_OBJ, looseToNumber, looseIndexOf, isSet, looseEqual, invokeArrayFns, isHTMLTag, isSVGTag } from '@vue/shared';
  4. const svgNS = "http://www.w3.org/2000/svg";
  5. const doc = typeof document !== "undefined" ? document : null;
  6. const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
  7. const nodeOps = {
  8. insert: (child, parent, anchor) => {
  9. parent.insertBefore(child, anchor || null);
  10. },
  11. remove: (child) => {
  12. const parent = child.parentNode;
  13. if (parent) {
  14. parent.removeChild(child);
  15. }
  16. },
  17. createElement: (tag, isSVG, is, props) => {
  18. const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0);
  19. if (tag === "select" && props && props.multiple != null) {
  20. el.setAttribute("multiple", props.multiple);
  21. }
  22. return el;
  23. },
  24. createText: (text) => doc.createTextNode(text),
  25. createComment: (text) => doc.createComment(text),
  26. setText: (node, text) => {
  27. node.nodeValue = text;
  28. },
  29. setElementText: (el, text) => {
  30. el.textContent = text;
  31. },
  32. parentNode: (node) => node.parentNode,
  33. nextSibling: (node) => node.nextSibling,
  34. querySelector: (selector) => doc.querySelector(selector),
  35. setScopeId(el, id) {
  36. el.setAttribute(id, "");
  37. },
  38. // __UNSAFE__
  39. // Reason: innerHTML.
  40. // Static content here can only come from compiled templates.
  41. // As long as the user only uses trusted templates, this is safe.
  42. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  43. const before = anchor ? anchor.previousSibling : parent.lastChild;
  44. if (start && (start === end || start.nextSibling)) {
  45. while (true) {
  46. parent.insertBefore(start.cloneNode(true), anchor);
  47. if (start === end || !(start = start.nextSibling))
  48. break;
  49. }
  50. } else {
  51. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  52. const template = templateContainer.content;
  53. if (isSVG) {
  54. const wrapper = template.firstChild;
  55. while (wrapper.firstChild) {
  56. template.appendChild(wrapper.firstChild);
  57. }
  58. template.removeChild(wrapper);
  59. }
  60. parent.insertBefore(template, anchor);
  61. }
  62. return [
  63. // first
  64. before ? before.nextSibling : parent.firstChild,
  65. // last
  66. anchor ? anchor.previousSibling : parent.lastChild
  67. ];
  68. }
  69. };
  70. const TRANSITION = "transition";
  71. const ANIMATION = "animation";
  72. const vtcKey = Symbol("_vtc");
  73. const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
  74. Transition.displayName = "Transition";
  75. const DOMTransitionPropsValidators = {
  76. name: String,
  77. type: String,
  78. css: {
  79. type: Boolean,
  80. default: true
  81. },
  82. duration: [String, Number, Object],
  83. enterFromClass: String,
  84. enterActiveClass: String,
  85. enterToClass: String,
  86. appearFromClass: String,
  87. appearActiveClass: String,
  88. appearToClass: String,
  89. leaveFromClass: String,
  90. leaveActiveClass: String,
  91. leaveToClass: String
  92. };
  93. const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend(
  94. {},
  95. BaseTransitionPropsValidators,
  96. DOMTransitionPropsValidators
  97. );
  98. const callHook = (hook, args = []) => {
  99. if (isArray(hook)) {
  100. hook.forEach((h2) => h2(...args));
  101. } else if (hook) {
  102. hook(...args);
  103. }
  104. };
  105. const hasExplicitCallback = (hook) => {
  106. return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
  107. };
  108. function resolveTransitionProps(rawProps) {
  109. const baseProps = {};
  110. for (const key in rawProps) {
  111. if (!(key in DOMTransitionPropsValidators)) {
  112. baseProps[key] = rawProps[key];
  113. }
  114. }
  115. if (rawProps.css === false) {
  116. return baseProps;
  117. }
  118. const {
  119. name = "v",
  120. type,
  121. duration,
  122. enterFromClass = `${name}-enter-from`,
  123. enterActiveClass = `${name}-enter-active`,
  124. enterToClass = `${name}-enter-to`,
  125. appearFromClass = enterFromClass,
  126. appearActiveClass = enterActiveClass,
  127. appearToClass = enterToClass,
  128. leaveFromClass = `${name}-leave-from`,
  129. leaveActiveClass = `${name}-leave-active`,
  130. leaveToClass = `${name}-leave-to`
  131. } = rawProps;
  132. const durations = normalizeDuration(duration);
  133. const enterDuration = durations && durations[0];
  134. const leaveDuration = durations && durations[1];
  135. const {
  136. onBeforeEnter,
  137. onEnter,
  138. onEnterCancelled,
  139. onLeave,
  140. onLeaveCancelled,
  141. onBeforeAppear = onBeforeEnter,
  142. onAppear = onEnter,
  143. onAppearCancelled = onEnterCancelled
  144. } = baseProps;
  145. const finishEnter = (el, isAppear, done) => {
  146. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  147. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  148. done && done();
  149. };
  150. const finishLeave = (el, done) => {
  151. el._isLeaving = false;
  152. removeTransitionClass(el, leaveFromClass);
  153. removeTransitionClass(el, leaveToClass);
  154. removeTransitionClass(el, leaveActiveClass);
  155. done && done();
  156. };
  157. const makeEnterHook = (isAppear) => {
  158. return (el, done) => {
  159. const hook = isAppear ? onAppear : onEnter;
  160. const resolve = () => finishEnter(el, isAppear, done);
  161. callHook(hook, [el, resolve]);
  162. nextFrame(() => {
  163. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  164. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  165. if (!hasExplicitCallback(hook)) {
  166. whenTransitionEnds(el, type, enterDuration, resolve);
  167. }
  168. });
  169. };
  170. };
  171. return extend(baseProps, {
  172. onBeforeEnter(el) {
  173. callHook(onBeforeEnter, [el]);
  174. addTransitionClass(el, enterFromClass);
  175. addTransitionClass(el, enterActiveClass);
  176. },
  177. onBeforeAppear(el) {
  178. callHook(onBeforeAppear, [el]);
  179. addTransitionClass(el, appearFromClass);
  180. addTransitionClass(el, appearActiveClass);
  181. },
  182. onEnter: makeEnterHook(false),
  183. onAppear: makeEnterHook(true),
  184. onLeave(el, done) {
  185. el._isLeaving = true;
  186. const resolve = () => finishLeave(el, done);
  187. addTransitionClass(el, leaveFromClass);
  188. forceReflow();
  189. addTransitionClass(el, leaveActiveClass);
  190. nextFrame(() => {
  191. if (!el._isLeaving) {
  192. return;
  193. }
  194. removeTransitionClass(el, leaveFromClass);
  195. addTransitionClass(el, leaveToClass);
  196. if (!hasExplicitCallback(onLeave)) {
  197. whenTransitionEnds(el, type, leaveDuration, resolve);
  198. }
  199. });
  200. callHook(onLeave, [el, resolve]);
  201. },
  202. onEnterCancelled(el) {
  203. finishEnter(el, false);
  204. callHook(onEnterCancelled, [el]);
  205. },
  206. onAppearCancelled(el) {
  207. finishEnter(el, true);
  208. callHook(onAppearCancelled, [el]);
  209. },
  210. onLeaveCancelled(el) {
  211. finishLeave(el);
  212. callHook(onLeaveCancelled, [el]);
  213. }
  214. });
  215. }
  216. function normalizeDuration(duration) {
  217. if (duration == null) {
  218. return null;
  219. } else if (isObject(duration)) {
  220. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  221. } else {
  222. const n = NumberOf(duration);
  223. return [n, n];
  224. }
  225. }
  226. function NumberOf(val) {
  227. const res = toNumber(val);
  228. if (!!(process.env.NODE_ENV !== "production")) {
  229. assertNumber(res, "<transition> explicit duration");
  230. }
  231. return res;
  232. }
  233. function addTransitionClass(el, cls) {
  234. cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
  235. (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
  236. }
  237. function removeTransitionClass(el, cls) {
  238. cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
  239. const _vtc = el[vtcKey];
  240. if (_vtc) {
  241. _vtc.delete(cls);
  242. if (!_vtc.size) {
  243. el[vtcKey] = void 0;
  244. }
  245. }
  246. }
  247. function nextFrame(cb) {
  248. requestAnimationFrame(() => {
  249. requestAnimationFrame(cb);
  250. });
  251. }
  252. let endId = 0;
  253. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  254. const id = el._endId = ++endId;
  255. const resolveIfNotStale = () => {
  256. if (id === el._endId) {
  257. resolve();
  258. }
  259. };
  260. if (explicitTimeout) {
  261. return setTimeout(resolveIfNotStale, explicitTimeout);
  262. }
  263. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  264. if (!type) {
  265. return resolve();
  266. }
  267. const endEvent = type + "end";
  268. let ended = 0;
  269. const end = () => {
  270. el.removeEventListener(endEvent, onEnd);
  271. resolveIfNotStale();
  272. };
  273. const onEnd = (e) => {
  274. if (e.target === el && ++ended >= propCount) {
  275. end();
  276. }
  277. };
  278. setTimeout(() => {
  279. if (ended < propCount) {
  280. end();
  281. }
  282. }, timeout + 1);
  283. el.addEventListener(endEvent, onEnd);
  284. }
  285. function getTransitionInfo(el, expectedType) {
  286. const styles = window.getComputedStyle(el);
  287. const getStyleProperties = (key) => (styles[key] || "").split(", ");
  288. const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
  289. const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
  290. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  291. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  292. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  293. const animationTimeout = getTimeout(animationDelays, animationDurations);
  294. let type = null;
  295. let timeout = 0;
  296. let propCount = 0;
  297. if (expectedType === TRANSITION) {
  298. if (transitionTimeout > 0) {
  299. type = TRANSITION;
  300. timeout = transitionTimeout;
  301. propCount = transitionDurations.length;
  302. }
  303. } else if (expectedType === ANIMATION) {
  304. if (animationTimeout > 0) {
  305. type = ANIMATION;
  306. timeout = animationTimeout;
  307. propCount = animationDurations.length;
  308. }
  309. } else {
  310. timeout = Math.max(transitionTimeout, animationTimeout);
  311. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
  312. propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
  313. }
  314. const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
  315. getStyleProperties(`${TRANSITION}Property`).toString()
  316. );
  317. return {
  318. type,
  319. timeout,
  320. propCount,
  321. hasTransform
  322. };
  323. }
  324. function getTimeout(delays, durations) {
  325. while (delays.length < durations.length) {
  326. delays = delays.concat(delays);
  327. }
  328. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  329. }
  330. function toMs(s) {
  331. if (s === "auto")
  332. return 0;
  333. return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
  334. }
  335. function forceReflow() {
  336. return document.body.offsetHeight;
  337. }
  338. function patchClass(el, value, isSVG) {
  339. const transitionClasses = el[vtcKey];
  340. if (transitionClasses) {
  341. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
  342. }
  343. if (value == null) {
  344. el.removeAttribute("class");
  345. } else if (isSVG) {
  346. el.setAttribute("class", value);
  347. } else {
  348. el.className = value;
  349. }
  350. }
  351. const vShowOldKey = Symbol("_vod");
  352. const vShow = {
  353. beforeMount(el, { value }, { transition }) {
  354. el[vShowOldKey] = el.style.display === "none" ? "" : el.style.display;
  355. if (transition && value) {
  356. transition.beforeEnter(el);
  357. } else {
  358. setDisplay(el, value);
  359. }
  360. },
  361. mounted(el, { value }, { transition }) {
  362. if (transition && value) {
  363. transition.enter(el);
  364. }
  365. },
  366. updated(el, { value, oldValue }, { transition }) {
  367. if (!value === !oldValue)
  368. return;
  369. if (transition) {
  370. if (value) {
  371. transition.beforeEnter(el);
  372. setDisplay(el, true);
  373. transition.enter(el);
  374. } else {
  375. transition.leave(el, () => {
  376. setDisplay(el, false);
  377. });
  378. }
  379. } else {
  380. setDisplay(el, value);
  381. }
  382. },
  383. beforeUnmount(el, { value }) {
  384. setDisplay(el, value);
  385. }
  386. };
  387. function setDisplay(el, value) {
  388. el.style.display = value ? el[vShowOldKey] : "none";
  389. }
  390. function initVShowForSSR() {
  391. vShow.getSSRProps = ({ value }) => {
  392. if (!value) {
  393. return { style: { display: "none" } };
  394. }
  395. };
  396. }
  397. function patchStyle(el, prev, next) {
  398. const style = el.style;
  399. const isCssString = isString(next);
  400. if (next && !isCssString) {
  401. if (prev && !isString(prev)) {
  402. for (const key in prev) {
  403. if (next[key] == null) {
  404. setStyle(style, key, "");
  405. }
  406. }
  407. }
  408. for (const key in next) {
  409. setStyle(style, key, next[key]);
  410. }
  411. } else {
  412. const currentDisplay = style.display;
  413. if (isCssString) {
  414. if (prev !== next) {
  415. style.cssText = next;
  416. }
  417. } else if (prev) {
  418. el.removeAttribute("style");
  419. }
  420. if (vShowOldKey in el) {
  421. style.display = currentDisplay;
  422. }
  423. }
  424. }
  425. const semicolonRE = /[^\\];\s*$/;
  426. const importantRE = /\s*!important$/;
  427. function setStyle(style, name, val) {
  428. if (isArray(val)) {
  429. val.forEach((v) => setStyle(style, name, v));
  430. } else {
  431. if (val == null)
  432. val = "";
  433. if (!!(process.env.NODE_ENV !== "production")) {
  434. if (semicolonRE.test(val)) {
  435. warn(
  436. `Unexpected semicolon at the end of '${name}' style value: '${val}'`
  437. );
  438. }
  439. }
  440. if (name.startsWith("--")) {
  441. style.setProperty(name, val);
  442. } else {
  443. const prefixed = autoPrefix(style, name);
  444. if (importantRE.test(val)) {
  445. style.setProperty(
  446. hyphenate(prefixed),
  447. val.replace(importantRE, ""),
  448. "important"
  449. );
  450. } else {
  451. style[prefixed] = val;
  452. }
  453. }
  454. }
  455. }
  456. const prefixes = ["Webkit", "Moz", "ms"];
  457. const prefixCache = {};
  458. function autoPrefix(style, rawName) {
  459. const cached = prefixCache[rawName];
  460. if (cached) {
  461. return cached;
  462. }
  463. let name = camelize(rawName);
  464. if (name !== "filter" && name in style) {
  465. return prefixCache[rawName] = name;
  466. }
  467. name = capitalize(name);
  468. for (let i = 0; i < prefixes.length; i++) {
  469. const prefixed = prefixes[i] + name;
  470. if (prefixed in style) {
  471. return prefixCache[rawName] = prefixed;
  472. }
  473. }
  474. return rawName;
  475. }
  476. const xlinkNS = "http://www.w3.org/1999/xlink";
  477. function patchAttr(el, key, value, isSVG, instance) {
  478. if (isSVG && key.startsWith("xlink:")) {
  479. if (value == null) {
  480. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  481. } else {
  482. el.setAttributeNS(xlinkNS, key, value);
  483. }
  484. } else {
  485. const isBoolean = isSpecialBooleanAttr(key);
  486. if (value == null || isBoolean && !includeBooleanAttr(value)) {
  487. el.removeAttribute(key);
  488. } else {
  489. el.setAttribute(key, isBoolean ? "" : value);
  490. }
  491. }
  492. }
  493. function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  494. if (key === "innerHTML" || key === "textContent") {
  495. if (prevChildren) {
  496. unmountChildren(prevChildren, parentComponent, parentSuspense);
  497. }
  498. el[key] = value == null ? "" : value;
  499. return;
  500. }
  501. const tag = el.tagName;
  502. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  503. !tag.includes("-")) {
  504. el._value = value;
  505. const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value;
  506. const newValue = value == null ? "" : value;
  507. if (oldValue !== newValue) {
  508. el.value = newValue;
  509. }
  510. if (value == null) {
  511. el.removeAttribute(key);
  512. }
  513. return;
  514. }
  515. let needRemove = false;
  516. if (value === "" || value == null) {
  517. const type = typeof el[key];
  518. if (type === "boolean") {
  519. value = includeBooleanAttr(value);
  520. } else if (value == null && type === "string") {
  521. value = "";
  522. needRemove = true;
  523. } else if (type === "number") {
  524. value = 0;
  525. needRemove = true;
  526. }
  527. }
  528. try {
  529. el[key] = value;
  530. } catch (e) {
  531. if (!!(process.env.NODE_ENV !== "production") && !needRemove) {
  532. warn(
  533. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  534. e
  535. );
  536. }
  537. }
  538. needRemove && el.removeAttribute(key);
  539. }
  540. function addEventListener(el, event, handler, options) {
  541. el.addEventListener(event, handler, options);
  542. }
  543. function removeEventListener(el, event, handler, options) {
  544. el.removeEventListener(event, handler, options);
  545. }
  546. const veiKey = Symbol("_vei");
  547. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  548. const invokers = el[veiKey] || (el[veiKey] = {});
  549. const existingInvoker = invokers[rawName];
  550. if (nextValue && existingInvoker) {
  551. existingInvoker.value = nextValue;
  552. } else {
  553. const [name, options] = parseName(rawName);
  554. if (nextValue) {
  555. const invoker = invokers[rawName] = createInvoker(nextValue, instance);
  556. addEventListener(el, name, invoker, options);
  557. } else if (existingInvoker) {
  558. removeEventListener(el, name, existingInvoker, options);
  559. invokers[rawName] = void 0;
  560. }
  561. }
  562. }
  563. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  564. function parseName(name) {
  565. let options;
  566. if (optionsModifierRE.test(name)) {
  567. options = {};
  568. let m;
  569. while (m = name.match(optionsModifierRE)) {
  570. name = name.slice(0, name.length - m[0].length);
  571. options[m[0].toLowerCase()] = true;
  572. }
  573. }
  574. const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
  575. return [event, options];
  576. }
  577. let cachedNow = 0;
  578. const p = /* @__PURE__ */ Promise.resolve();
  579. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  580. function createInvoker(initialValue, instance) {
  581. const invoker = (e) => {
  582. if (!e._vts) {
  583. e._vts = Date.now();
  584. } else if (e._vts <= invoker.attached) {
  585. return;
  586. }
  587. callWithAsyncErrorHandling(
  588. patchStopImmediatePropagation(e, invoker.value),
  589. instance,
  590. 5,
  591. [e]
  592. );
  593. };
  594. invoker.value = initialValue;
  595. invoker.attached = getNow();
  596. return invoker;
  597. }
  598. function patchStopImmediatePropagation(e, value) {
  599. if (isArray(value)) {
  600. const originalStop = e.stopImmediatePropagation;
  601. e.stopImmediatePropagation = () => {
  602. originalStop.call(e);
  603. e._stopped = true;
  604. };
  605. return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2));
  606. } else {
  607. return value;
  608. }
  609. }
  610. const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
  611. key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
  612. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  613. if (key === "class") {
  614. patchClass(el, nextValue, isSVG);
  615. } else if (key === "style") {
  616. patchStyle(el, prevValue, nextValue);
  617. } else if (isOn(key)) {
  618. if (!isModelListener(key)) {
  619. patchEvent(el, key, prevValue, nextValue, parentComponent);
  620. }
  621. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  622. patchDOMProp(
  623. el,
  624. key,
  625. nextValue,
  626. prevChildren,
  627. parentComponent,
  628. parentSuspense,
  629. unmountChildren
  630. );
  631. } else {
  632. if (key === "true-value") {
  633. el._trueValue = nextValue;
  634. } else if (key === "false-value") {
  635. el._falseValue = nextValue;
  636. }
  637. patchAttr(el, key, nextValue, isSVG);
  638. }
  639. };
  640. function shouldSetAsProp(el, key, value, isSVG) {
  641. if (isSVG) {
  642. if (key === "innerHTML" || key === "textContent") {
  643. return true;
  644. }
  645. if (key in el && isNativeOn(key) && isFunction(value)) {
  646. return true;
  647. }
  648. return false;
  649. }
  650. if (key === "spellcheck" || key === "draggable" || key === "translate") {
  651. return false;
  652. }
  653. if (key === "form") {
  654. return false;
  655. }
  656. if (key === "list" && el.tagName === "INPUT") {
  657. return false;
  658. }
  659. if (key === "type" && el.tagName === "TEXTAREA") {
  660. return false;
  661. }
  662. if (key === "width" || key === "height") {
  663. const tag = el.tagName;
  664. if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
  665. return false;
  666. }
  667. }
  668. if (isNativeOn(key) && isString(value)) {
  669. return false;
  670. }
  671. return key in el;
  672. }
  673. /*! #__NO_SIDE_EFFECTS__ */
  674. // @__NO_SIDE_EFFECTS__
  675. function defineCustomElement(options, hydrate2) {
  676. const Comp = defineComponent(options);
  677. class VueCustomElement extends VueElement {
  678. constructor(initialProps) {
  679. super(Comp, initialProps, hydrate2);
  680. }
  681. }
  682. VueCustomElement.def = Comp;
  683. return VueCustomElement;
  684. }
  685. /*! #__NO_SIDE_EFFECTS__ */
  686. const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options) => {
  687. return /* @__PURE__ */ defineCustomElement(options, hydrate);
  688. };
  689. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  690. };
  691. class VueElement extends BaseClass {
  692. constructor(_def, _props = {}, hydrate2) {
  693. super();
  694. this._def = _def;
  695. this._props = _props;
  696. /**
  697. * @internal
  698. */
  699. this._instance = null;
  700. this._connected = false;
  701. this._resolved = false;
  702. this._numberProps = null;
  703. this._ob = null;
  704. if (this.shadowRoot && hydrate2) {
  705. hydrate2(this._createVNode(), this.shadowRoot);
  706. } else {
  707. if (!!(process.env.NODE_ENV !== "production") && this.shadowRoot) {
  708. warn(
  709. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
  710. );
  711. }
  712. this.attachShadow({ mode: "open" });
  713. if (!this._def.__asyncLoader) {
  714. this._resolveProps(this._def);
  715. }
  716. }
  717. }
  718. connectedCallback() {
  719. this._connected = true;
  720. if (!this._instance) {
  721. if (this._resolved) {
  722. this._update();
  723. } else {
  724. this._resolveDef();
  725. }
  726. }
  727. }
  728. disconnectedCallback() {
  729. this._connected = false;
  730. if (this._ob) {
  731. this._ob.disconnect();
  732. this._ob = null;
  733. }
  734. nextTick(() => {
  735. if (!this._connected) {
  736. render(null, this.shadowRoot);
  737. this._instance = null;
  738. }
  739. });
  740. }
  741. /**
  742. * resolve inner component definition (handle possible async component)
  743. */
  744. _resolveDef() {
  745. this._resolved = true;
  746. for (let i = 0; i < this.attributes.length; i++) {
  747. this._setAttr(this.attributes[i].name);
  748. }
  749. this._ob = new MutationObserver((mutations) => {
  750. for (const m of mutations) {
  751. this._setAttr(m.attributeName);
  752. }
  753. });
  754. this._ob.observe(this, { attributes: true });
  755. const resolve = (def, isAsync = false) => {
  756. const { props, styles } = def;
  757. let numberProps;
  758. if (props && !isArray(props)) {
  759. for (const key in props) {
  760. const opt = props[key];
  761. if (opt === Number || opt && opt.type === Number) {
  762. if (key in this._props) {
  763. this._props[key] = toNumber(this._props[key]);
  764. }
  765. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize$1(key)] = true;
  766. }
  767. }
  768. }
  769. this._numberProps = numberProps;
  770. if (isAsync) {
  771. this._resolveProps(def);
  772. }
  773. this._applyStyles(styles);
  774. this._update();
  775. };
  776. const asyncDef = this._def.__asyncLoader;
  777. if (asyncDef) {
  778. asyncDef().then((def) => resolve(def, true));
  779. } else {
  780. resolve(this._def);
  781. }
  782. }
  783. _resolveProps(def) {
  784. const { props } = def;
  785. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  786. for (const key of Object.keys(this)) {
  787. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  788. this._setProp(key, this[key], true, false);
  789. }
  790. }
  791. for (const key of declaredPropKeys.map(camelize$1)) {
  792. Object.defineProperty(this, key, {
  793. get() {
  794. return this._getProp(key);
  795. },
  796. set(val) {
  797. this._setProp(key, val);
  798. }
  799. });
  800. }
  801. }
  802. _setAttr(key) {
  803. let value = this.getAttribute(key);
  804. const camelKey = camelize$1(key);
  805. if (this._numberProps && this._numberProps[camelKey]) {
  806. value = toNumber(value);
  807. }
  808. this._setProp(camelKey, value, false);
  809. }
  810. /**
  811. * @internal
  812. */
  813. _getProp(key) {
  814. return this._props[key];
  815. }
  816. /**
  817. * @internal
  818. */
  819. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  820. if (val !== this._props[key]) {
  821. this._props[key] = val;
  822. if (shouldUpdate && this._instance) {
  823. this._update();
  824. }
  825. if (shouldReflect) {
  826. if (val === true) {
  827. this.setAttribute(hyphenate(key), "");
  828. } else if (typeof val === "string" || typeof val === "number") {
  829. this.setAttribute(hyphenate(key), val + "");
  830. } else if (!val) {
  831. this.removeAttribute(hyphenate(key));
  832. }
  833. }
  834. }
  835. }
  836. _update() {
  837. render(this._createVNode(), this.shadowRoot);
  838. }
  839. _createVNode() {
  840. const vnode = createVNode(this._def, extend({}, this._props));
  841. if (!this._instance) {
  842. vnode.ce = (instance) => {
  843. this._instance = instance;
  844. instance.isCE = true;
  845. if (!!(process.env.NODE_ENV !== "production")) {
  846. instance.ceReload = (newStyles) => {
  847. if (this._styles) {
  848. this._styles.forEach((s) => this.shadowRoot.removeChild(s));
  849. this._styles.length = 0;
  850. }
  851. this._applyStyles(newStyles);
  852. this._instance = null;
  853. this._update();
  854. };
  855. }
  856. const dispatch = (event, args) => {
  857. this.dispatchEvent(
  858. new CustomEvent(event, {
  859. detail: args
  860. })
  861. );
  862. };
  863. instance.emit = (event, ...args) => {
  864. dispatch(event, args);
  865. if (hyphenate(event) !== event) {
  866. dispatch(hyphenate(event), args);
  867. }
  868. };
  869. let parent = this;
  870. while (parent = parent && (parent.parentNode || parent.host)) {
  871. if (parent instanceof VueElement) {
  872. instance.parent = parent._instance;
  873. instance.provides = parent._instance.provides;
  874. break;
  875. }
  876. }
  877. };
  878. }
  879. return vnode;
  880. }
  881. _applyStyles(styles) {
  882. if (styles) {
  883. styles.forEach((css) => {
  884. const s = document.createElement("style");
  885. s.textContent = css;
  886. this.shadowRoot.appendChild(s);
  887. if (!!(process.env.NODE_ENV !== "production")) {
  888. (this._styles || (this._styles = [])).push(s);
  889. }
  890. });
  891. }
  892. }
  893. }
  894. function useCssModule(name = "$style") {
  895. {
  896. const instance = getCurrentInstance();
  897. if (!instance) {
  898. !!(process.env.NODE_ENV !== "production") && warn(`useCssModule must be called inside setup()`);
  899. return EMPTY_OBJ;
  900. }
  901. const modules = instance.type.__cssModules;
  902. if (!modules) {
  903. !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS modules injected.`);
  904. return EMPTY_OBJ;
  905. }
  906. const mod = modules[name];
  907. if (!mod) {
  908. !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS module named "${name}".`);
  909. return EMPTY_OBJ;
  910. }
  911. return mod;
  912. }
  913. }
  914. function useCssVars(getter) {
  915. const instance = getCurrentInstance();
  916. if (!instance) {
  917. !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
  918. return;
  919. }
  920. const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
  921. Array.from(
  922. document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
  923. ).forEach((node) => setVarsOnNode(node, vars));
  924. };
  925. const setVars = () => {
  926. const vars = getter(instance.proxy);
  927. setVarsOnVNode(instance.subTree, vars);
  928. updateTeleports(vars);
  929. };
  930. watchPostEffect(setVars);
  931. onMounted(() => {
  932. const ob = new MutationObserver(setVars);
  933. ob.observe(instance.subTree.el.parentNode, { childList: true });
  934. onUnmounted(() => ob.disconnect());
  935. });
  936. }
  937. function setVarsOnVNode(vnode, vars) {
  938. if (vnode.shapeFlag & 128) {
  939. const suspense = vnode.suspense;
  940. vnode = suspense.activeBranch;
  941. if (suspense.pendingBranch && !suspense.isHydrating) {
  942. suspense.effects.push(() => {
  943. setVarsOnVNode(suspense.activeBranch, vars);
  944. });
  945. }
  946. }
  947. while (vnode.component) {
  948. vnode = vnode.component.subTree;
  949. }
  950. if (vnode.shapeFlag & 1 && vnode.el) {
  951. setVarsOnNode(vnode.el, vars);
  952. } else if (vnode.type === Fragment) {
  953. vnode.children.forEach((c) => setVarsOnVNode(c, vars));
  954. } else if (vnode.type === Static) {
  955. let { el, anchor } = vnode;
  956. while (el) {
  957. setVarsOnNode(el, vars);
  958. if (el === anchor)
  959. break;
  960. el = el.nextSibling;
  961. }
  962. }
  963. }
  964. function setVarsOnNode(el, vars) {
  965. if (el.nodeType === 1) {
  966. const style = el.style;
  967. for (const key in vars) {
  968. style.setProperty(`--${key}`, vars[key]);
  969. }
  970. }
  971. }
  972. const positionMap = /* @__PURE__ */ new WeakMap();
  973. const newPositionMap = /* @__PURE__ */ new WeakMap();
  974. const moveCbKey = Symbol("_moveCb");
  975. const enterCbKey = Symbol("_enterCb");
  976. const TransitionGroupImpl = {
  977. name: "TransitionGroup",
  978. props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
  979. tag: String,
  980. moveClass: String
  981. }),
  982. setup(props, { slots }) {
  983. const instance = getCurrentInstance();
  984. const state = useTransitionState();
  985. let prevChildren;
  986. let children;
  987. onUpdated(() => {
  988. if (!prevChildren.length) {
  989. return;
  990. }
  991. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  992. if (!hasCSSTransform(
  993. prevChildren[0].el,
  994. instance.vnode.el,
  995. moveClass
  996. )) {
  997. return;
  998. }
  999. prevChildren.forEach(callPendingCbs);
  1000. prevChildren.forEach(recordPosition);
  1001. const movedChildren = prevChildren.filter(applyTranslation);
  1002. forceReflow();
  1003. movedChildren.forEach((c) => {
  1004. const el = c.el;
  1005. const style = el.style;
  1006. addTransitionClass(el, moveClass);
  1007. style.transform = style.webkitTransform = style.transitionDuration = "";
  1008. const cb = el[moveCbKey] = (e) => {
  1009. if (e && e.target !== el) {
  1010. return;
  1011. }
  1012. if (!e || /transform$/.test(e.propertyName)) {
  1013. el.removeEventListener("transitionend", cb);
  1014. el[moveCbKey] = null;
  1015. removeTransitionClass(el, moveClass);
  1016. }
  1017. };
  1018. el.addEventListener("transitionend", cb);
  1019. });
  1020. });
  1021. return () => {
  1022. const rawProps = toRaw(props);
  1023. const cssTransitionProps = resolveTransitionProps(rawProps);
  1024. let tag = rawProps.tag || Fragment;
  1025. prevChildren = children;
  1026. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  1027. for (let i = 0; i < children.length; i++) {
  1028. const child = children[i];
  1029. if (child.key != null) {
  1030. setTransitionHooks(
  1031. child,
  1032. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  1033. );
  1034. } else if (!!(process.env.NODE_ENV !== "production")) {
  1035. warn(`<TransitionGroup> children must be keyed.`);
  1036. }
  1037. }
  1038. if (prevChildren) {
  1039. for (let i = 0; i < prevChildren.length; i++) {
  1040. const child = prevChildren[i];
  1041. setTransitionHooks(
  1042. child,
  1043. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  1044. );
  1045. positionMap.set(child, child.el.getBoundingClientRect());
  1046. }
  1047. }
  1048. return createVNode(tag, null, children);
  1049. };
  1050. }
  1051. };
  1052. const removeMode = (props) => delete props.mode;
  1053. /* @__PURE__ */ removeMode(TransitionGroupImpl.props);
  1054. const TransitionGroup = TransitionGroupImpl;
  1055. function callPendingCbs(c) {
  1056. const el = c.el;
  1057. if (el[moveCbKey]) {
  1058. el[moveCbKey]();
  1059. }
  1060. if (el[enterCbKey]) {
  1061. el[enterCbKey]();
  1062. }
  1063. }
  1064. function recordPosition(c) {
  1065. newPositionMap.set(c, c.el.getBoundingClientRect());
  1066. }
  1067. function applyTranslation(c) {
  1068. const oldPos = positionMap.get(c);
  1069. const newPos = newPositionMap.get(c);
  1070. const dx = oldPos.left - newPos.left;
  1071. const dy = oldPos.top - newPos.top;
  1072. if (dx || dy) {
  1073. const s = c.el.style;
  1074. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  1075. s.transitionDuration = "0s";
  1076. return c;
  1077. }
  1078. }
  1079. function hasCSSTransform(el, root, moveClass) {
  1080. const clone = el.cloneNode();
  1081. const _vtc = el[vtcKey];
  1082. if (_vtc) {
  1083. _vtc.forEach((cls) => {
  1084. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  1085. });
  1086. }
  1087. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  1088. clone.style.display = "none";
  1089. const container = root.nodeType === 1 ? root : root.parentNode;
  1090. container.appendChild(clone);
  1091. const { hasTransform } = getTransitionInfo(clone);
  1092. container.removeChild(clone);
  1093. return hasTransform;
  1094. }
  1095. const getModelAssigner = (vnode) => {
  1096. const fn = vnode.props["onUpdate:modelValue"] || false;
  1097. return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
  1098. };
  1099. function onCompositionStart(e) {
  1100. e.target.composing = true;
  1101. }
  1102. function onCompositionEnd(e) {
  1103. const target = e.target;
  1104. if (target.composing) {
  1105. target.composing = false;
  1106. target.dispatchEvent(new Event("input"));
  1107. }
  1108. }
  1109. const assignKey = Symbol("_assign");
  1110. const vModelText = {
  1111. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  1112. el[assignKey] = getModelAssigner(vnode);
  1113. const castToNumber = number || vnode.props && vnode.props.type === "number";
  1114. addEventListener(el, lazy ? "change" : "input", (e) => {
  1115. if (e.target.composing)
  1116. return;
  1117. let domValue = el.value;
  1118. if (trim) {
  1119. domValue = domValue.trim();
  1120. }
  1121. if (castToNumber) {
  1122. domValue = looseToNumber(domValue);
  1123. }
  1124. el[assignKey](domValue);
  1125. });
  1126. if (trim) {
  1127. addEventListener(el, "change", () => {
  1128. el.value = el.value.trim();
  1129. });
  1130. }
  1131. if (!lazy) {
  1132. addEventListener(el, "compositionstart", onCompositionStart);
  1133. addEventListener(el, "compositionend", onCompositionEnd);
  1134. addEventListener(el, "change", onCompositionEnd);
  1135. }
  1136. },
  1137. // set value on mounted so it's after min/max for type="range"
  1138. mounted(el, { value }) {
  1139. el.value = value == null ? "" : value;
  1140. },
  1141. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  1142. el[assignKey] = getModelAssigner(vnode);
  1143. if (el.composing)
  1144. return;
  1145. const elValue = number || el.type === "number" ? looseToNumber(el.value) : el.value;
  1146. const newValue = value == null ? "" : value;
  1147. if (elValue === newValue) {
  1148. return;
  1149. }
  1150. if (document.activeElement === el && el.type !== "range") {
  1151. if (lazy) {
  1152. return;
  1153. }
  1154. if (trim && el.value.trim() === newValue) {
  1155. return;
  1156. }
  1157. }
  1158. el.value = newValue;
  1159. }
  1160. };
  1161. const vModelCheckbox = {
  1162. // #4096 array checkboxes need to be deep traversed
  1163. deep: true,
  1164. created(el, _, vnode) {
  1165. el[assignKey] = getModelAssigner(vnode);
  1166. addEventListener(el, "change", () => {
  1167. const modelValue = el._modelValue;
  1168. const elementValue = getValue(el);
  1169. const checked = el.checked;
  1170. const assign = el[assignKey];
  1171. if (isArray(modelValue)) {
  1172. const index = looseIndexOf(modelValue, elementValue);
  1173. const found = index !== -1;
  1174. if (checked && !found) {
  1175. assign(modelValue.concat(elementValue));
  1176. } else if (!checked && found) {
  1177. const filtered = [...modelValue];
  1178. filtered.splice(index, 1);
  1179. assign(filtered);
  1180. }
  1181. } else if (isSet(modelValue)) {
  1182. const cloned = new Set(modelValue);
  1183. if (checked) {
  1184. cloned.add(elementValue);
  1185. } else {
  1186. cloned.delete(elementValue);
  1187. }
  1188. assign(cloned);
  1189. } else {
  1190. assign(getCheckboxValue(el, checked));
  1191. }
  1192. });
  1193. },
  1194. // set initial checked on mount to wait for true-value/false-value
  1195. mounted: setChecked,
  1196. beforeUpdate(el, binding, vnode) {
  1197. el[assignKey] = getModelAssigner(vnode);
  1198. setChecked(el, binding, vnode);
  1199. }
  1200. };
  1201. function setChecked(el, { value, oldValue }, vnode) {
  1202. el._modelValue = value;
  1203. if (isArray(value)) {
  1204. el.checked = looseIndexOf(value, vnode.props.value) > -1;
  1205. } else if (isSet(value)) {
  1206. el.checked = value.has(vnode.props.value);
  1207. } else if (value !== oldValue) {
  1208. el.checked = looseEqual(value, getCheckboxValue(el, true));
  1209. }
  1210. }
  1211. const vModelRadio = {
  1212. created(el, { value }, vnode) {
  1213. el.checked = looseEqual(value, vnode.props.value);
  1214. el[assignKey] = getModelAssigner(vnode);
  1215. addEventListener(el, "change", () => {
  1216. el[assignKey](getValue(el));
  1217. });
  1218. },
  1219. beforeUpdate(el, { value, oldValue }, vnode) {
  1220. el[assignKey] = getModelAssigner(vnode);
  1221. if (value !== oldValue) {
  1222. el.checked = looseEqual(value, vnode.props.value);
  1223. }
  1224. }
  1225. };
  1226. const vModelSelect = {
  1227. // <select multiple> value need to be deep traversed
  1228. deep: true,
  1229. created(el, { value, modifiers: { number } }, vnode) {
  1230. const isSetModel = isSet(value);
  1231. addEventListener(el, "change", () => {
  1232. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  1233. (o) => number ? looseToNumber(getValue(o)) : getValue(o)
  1234. );
  1235. el[assignKey](
  1236. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  1237. );
  1238. });
  1239. el[assignKey] = getModelAssigner(vnode);
  1240. },
  1241. // set value in mounted & updated because <select> relies on its children
  1242. // <option>s.
  1243. mounted(el, { value }) {
  1244. setSelected(el, value);
  1245. },
  1246. beforeUpdate(el, _binding, vnode) {
  1247. el[assignKey] = getModelAssigner(vnode);
  1248. },
  1249. updated(el, { value }) {
  1250. setSelected(el, value);
  1251. }
  1252. };
  1253. function setSelected(el, value) {
  1254. const isMultiple = el.multiple;
  1255. if (isMultiple && !isArray(value) && !isSet(value)) {
  1256. !!(process.env.NODE_ENV !== "production") && warn(
  1257. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  1258. );
  1259. return;
  1260. }
  1261. for (let i = 0, l = el.options.length; i < l; i++) {
  1262. const option = el.options[i];
  1263. const optionValue = getValue(option);
  1264. if (isMultiple) {
  1265. if (isArray(value)) {
  1266. option.selected = looseIndexOf(value, optionValue) > -1;
  1267. } else {
  1268. option.selected = value.has(optionValue);
  1269. }
  1270. } else {
  1271. if (looseEqual(getValue(option), value)) {
  1272. if (el.selectedIndex !== i)
  1273. el.selectedIndex = i;
  1274. return;
  1275. }
  1276. }
  1277. }
  1278. if (!isMultiple && el.selectedIndex !== -1) {
  1279. el.selectedIndex = -1;
  1280. }
  1281. }
  1282. function getValue(el) {
  1283. return "_value" in el ? el._value : el.value;
  1284. }
  1285. function getCheckboxValue(el, checked) {
  1286. const key = checked ? "_trueValue" : "_falseValue";
  1287. return key in el ? el[key] : checked;
  1288. }
  1289. const vModelDynamic = {
  1290. created(el, binding, vnode) {
  1291. callModelHook(el, binding, vnode, null, "created");
  1292. },
  1293. mounted(el, binding, vnode) {
  1294. callModelHook(el, binding, vnode, null, "mounted");
  1295. },
  1296. beforeUpdate(el, binding, vnode, prevVNode) {
  1297. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  1298. },
  1299. updated(el, binding, vnode, prevVNode) {
  1300. callModelHook(el, binding, vnode, prevVNode, "updated");
  1301. }
  1302. };
  1303. function resolveDynamicModel(tagName, type) {
  1304. switch (tagName) {
  1305. case "SELECT":
  1306. return vModelSelect;
  1307. case "TEXTAREA":
  1308. return vModelText;
  1309. default:
  1310. switch (type) {
  1311. case "checkbox":
  1312. return vModelCheckbox;
  1313. case "radio":
  1314. return vModelRadio;
  1315. default:
  1316. return vModelText;
  1317. }
  1318. }
  1319. }
  1320. function callModelHook(el, binding, vnode, prevVNode, hook) {
  1321. const modelToUse = resolveDynamicModel(
  1322. el.tagName,
  1323. vnode.props && vnode.props.type
  1324. );
  1325. const fn = modelToUse[hook];
  1326. fn && fn(el, binding, vnode, prevVNode);
  1327. }
  1328. function initVModelForSSR() {
  1329. vModelText.getSSRProps = ({ value }) => ({ value });
  1330. vModelRadio.getSSRProps = ({ value }, vnode) => {
  1331. if (vnode.props && looseEqual(vnode.props.value, value)) {
  1332. return { checked: true };
  1333. }
  1334. };
  1335. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  1336. if (isArray(value)) {
  1337. if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
  1338. return { checked: true };
  1339. }
  1340. } else if (isSet(value)) {
  1341. if (vnode.props && value.has(vnode.props.value)) {
  1342. return { checked: true };
  1343. }
  1344. } else if (value) {
  1345. return { checked: true };
  1346. }
  1347. };
  1348. vModelDynamic.getSSRProps = (binding, vnode) => {
  1349. if (typeof vnode.type !== "string") {
  1350. return;
  1351. }
  1352. const modelToUse = resolveDynamicModel(
  1353. // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
  1354. vnode.type.toUpperCase(),
  1355. vnode.props && vnode.props.type
  1356. );
  1357. if (modelToUse.getSSRProps) {
  1358. return modelToUse.getSSRProps(binding, vnode);
  1359. }
  1360. };
  1361. }
  1362. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  1363. const modifierGuards = {
  1364. stop: (e) => e.stopPropagation(),
  1365. prevent: (e) => e.preventDefault(),
  1366. self: (e) => e.target !== e.currentTarget,
  1367. ctrl: (e) => !e.ctrlKey,
  1368. shift: (e) => !e.shiftKey,
  1369. alt: (e) => !e.altKey,
  1370. meta: (e) => !e.metaKey,
  1371. left: (e) => "button" in e && e.button !== 0,
  1372. middle: (e) => "button" in e && e.button !== 1,
  1373. right: (e) => "button" in e && e.button !== 2,
  1374. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  1375. };
  1376. const withModifiers = (fn, modifiers) => {
  1377. return fn._withMods || (fn._withMods = (event, ...args) => {
  1378. for (let i = 0; i < modifiers.length; i++) {
  1379. const guard = modifierGuards[modifiers[i]];
  1380. if (guard && guard(event, modifiers))
  1381. return;
  1382. }
  1383. return fn(event, ...args);
  1384. });
  1385. };
  1386. const keyNames = {
  1387. esc: "escape",
  1388. space: " ",
  1389. up: "arrow-up",
  1390. left: "arrow-left",
  1391. right: "arrow-right",
  1392. down: "arrow-down",
  1393. delete: "backspace"
  1394. };
  1395. const withKeys = (fn, modifiers) => {
  1396. return fn._withKeys || (fn._withKeys = (event) => {
  1397. if (!("key" in event)) {
  1398. return;
  1399. }
  1400. const eventKey = hyphenate(event.key);
  1401. if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
  1402. return fn(event);
  1403. }
  1404. });
  1405. };
  1406. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
  1407. let renderer;
  1408. let enabledHydration = false;
  1409. function ensureRenderer() {
  1410. return renderer || (renderer = createRenderer(rendererOptions));
  1411. }
  1412. function ensureHydrationRenderer() {
  1413. renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
  1414. enabledHydration = true;
  1415. return renderer;
  1416. }
  1417. const render = (...args) => {
  1418. ensureRenderer().render(...args);
  1419. };
  1420. const hydrate = (...args) => {
  1421. ensureHydrationRenderer().hydrate(...args);
  1422. };
  1423. const createApp = (...args) => {
  1424. const app = ensureRenderer().createApp(...args);
  1425. if (!!(process.env.NODE_ENV !== "production")) {
  1426. injectNativeTagCheck(app);
  1427. injectCompilerOptionsCheck(app);
  1428. }
  1429. const { mount } = app;
  1430. app.mount = (containerOrSelector) => {
  1431. const container = normalizeContainer(containerOrSelector);
  1432. if (!container)
  1433. return;
  1434. const component = app._component;
  1435. if (!isFunction(component) && !component.render && !component.template) {
  1436. component.template = container.innerHTML;
  1437. }
  1438. container.innerHTML = "";
  1439. const proxy = mount(container, false, container instanceof SVGElement);
  1440. if (container instanceof Element) {
  1441. container.removeAttribute("v-cloak");
  1442. container.setAttribute("data-v-app", "");
  1443. }
  1444. return proxy;
  1445. };
  1446. return app;
  1447. };
  1448. const createSSRApp = (...args) => {
  1449. const app = ensureHydrationRenderer().createApp(...args);
  1450. if (!!(process.env.NODE_ENV !== "production")) {
  1451. injectNativeTagCheck(app);
  1452. injectCompilerOptionsCheck(app);
  1453. }
  1454. const { mount } = app;
  1455. app.mount = (containerOrSelector) => {
  1456. const container = normalizeContainer(containerOrSelector);
  1457. if (container) {
  1458. return mount(container, true, container instanceof SVGElement);
  1459. }
  1460. };
  1461. return app;
  1462. };
  1463. function injectNativeTagCheck(app) {
  1464. Object.defineProperty(app.config, "isNativeTag", {
  1465. value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
  1466. writable: false
  1467. });
  1468. }
  1469. function injectCompilerOptionsCheck(app) {
  1470. if (isRuntimeOnly()) {
  1471. const isCustomElement = app.config.isCustomElement;
  1472. Object.defineProperty(app.config, "isCustomElement", {
  1473. get() {
  1474. return isCustomElement;
  1475. },
  1476. set() {
  1477. warn(
  1478. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  1479. );
  1480. }
  1481. });
  1482. const compilerOptions = app.config.compilerOptions;
  1483. const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
  1484. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  1485. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  1486. - For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
  1487. Object.defineProperty(app.config, "compilerOptions", {
  1488. get() {
  1489. warn(msg);
  1490. return compilerOptions;
  1491. },
  1492. set() {
  1493. warn(msg);
  1494. }
  1495. });
  1496. }
  1497. }
  1498. function normalizeContainer(container) {
  1499. if (isString(container)) {
  1500. const res = document.querySelector(container);
  1501. if (!!(process.env.NODE_ENV !== "production") && !res) {
  1502. warn(
  1503. `Failed to mount app: mount target selector "${container}" returned null.`
  1504. );
  1505. }
  1506. return res;
  1507. }
  1508. if (!!(process.env.NODE_ENV !== "production") && window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  1509. warn(
  1510. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  1511. );
  1512. }
  1513. return container;
  1514. }
  1515. let ssrDirectiveInitialized = false;
  1516. const initDirectivesForSSR = () => {
  1517. if (!ssrDirectiveInitialized) {
  1518. ssrDirectiveInitialized = true;
  1519. initVModelForSSR();
  1520. initVShowForSSR();
  1521. }
  1522. } ;
  1523. export { Transition, TransitionGroup, VueElement, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, hydrate, initDirectivesForSSR, render, useCssModule, useCssVars, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, withKeys, withModifiers };