runtime-dom.esm-bundler.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984
  1. /**
  2. * @vue/runtime-dom v3.5.30
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. import { warn, BaseTransitionPropsValidators, h, BaseTransition, assertNumber, getCurrentInstance, onBeforeUpdate, queuePostFlushCb, onMounted, watch, onUnmounted, Fragment, Static, camelize, callWithAsyncErrorHandling, nextTick, unref, createVNode, defineComponent, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, Text, createRenderer, isRuntimeOnly, createHydrationRenderer } from '@vue/runtime-core';
  7. export * from '@vue/runtime-core';
  8. import { extend, isObject, toNumber, isArray, NOOP, normalizeCssVarValue, isString, hyphenate, capitalize, includeBooleanAttr, isSymbol, isSpecialBooleanAttr, isFunction, isOn, isModelListener, camelize as camelize$1, hasOwn, isPlainObject, EMPTY_OBJ, looseIndexOf, isSet, looseEqual, looseToNumber, invokeArrayFns, isHTMLTag, isSVGTag, isMathMLTag } from '@vue/shared';
  9. let policy = void 0;
  10. const tt = typeof window !== "undefined" && window.trustedTypes;
  11. if (tt) {
  12. try {
  13. policy = /* @__PURE__ */ tt.createPolicy("vue", {
  14. createHTML: (val) => val
  15. });
  16. } catch (e) {
  17. !!(process.env.NODE_ENV !== "production") && warn(`Error creating trusted types policy: ${e}`);
  18. }
  19. }
  20. const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
  21. const svgNS = "http://www.w3.org/2000/svg";
  22. const mathmlNS = "http://www.w3.org/1998/Math/MathML";
  23. const doc = typeof document !== "undefined" ? document : null;
  24. const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
  25. const nodeOps = {
  26. insert: (child, parent, anchor) => {
  27. parent.insertBefore(child, anchor || null);
  28. },
  29. remove: (child) => {
  30. const parent = child.parentNode;
  31. if (parent) {
  32. parent.removeChild(child);
  33. }
  34. },
  35. createElement: (tag, namespace, is, props) => {
  36. const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag);
  37. if (tag === "select" && props && props.multiple != null) {
  38. el.setAttribute("multiple", props.multiple);
  39. }
  40. return el;
  41. },
  42. createText: (text) => doc.createTextNode(text),
  43. createComment: (text) => doc.createComment(text),
  44. setText: (node, text) => {
  45. node.nodeValue = text;
  46. },
  47. setElementText: (el, text) => {
  48. el.textContent = text;
  49. },
  50. parentNode: (node) => node.parentNode,
  51. nextSibling: (node) => node.nextSibling,
  52. querySelector: (selector) => doc.querySelector(selector),
  53. setScopeId(el, id) {
  54. el.setAttribute(id, "");
  55. },
  56. // __UNSAFE__
  57. // Reason: innerHTML.
  58. // Static content here can only come from compiled templates.
  59. // As long as the user only uses trusted templates, this is safe.
  60. insertStaticContent(content, parent, anchor, namespace, start, end) {
  61. const before = anchor ? anchor.previousSibling : parent.lastChild;
  62. if (start && (start === end || start.nextSibling)) {
  63. while (true) {
  64. parent.insertBefore(start.cloneNode(true), anchor);
  65. if (start === end || !(start = start.nextSibling)) break;
  66. }
  67. } else {
  68. templateContainer.innerHTML = unsafeToTrustedHTML(
  69. namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content
  70. );
  71. const template = templateContainer.content;
  72. if (namespace === "svg" || namespace === "mathml") {
  73. const wrapper = template.firstChild;
  74. while (wrapper.firstChild) {
  75. template.appendChild(wrapper.firstChild);
  76. }
  77. template.removeChild(wrapper);
  78. }
  79. parent.insertBefore(template, anchor);
  80. }
  81. return [
  82. // first
  83. before ? before.nextSibling : parent.firstChild,
  84. // last
  85. anchor ? anchor.previousSibling : parent.lastChild
  86. ];
  87. }
  88. };
  89. const TRANSITION = "transition";
  90. const ANIMATION = "animation";
  91. const vtcKey = /* @__PURE__ */ Symbol("_vtc");
  92. const DOMTransitionPropsValidators = {
  93. name: String,
  94. type: String,
  95. css: {
  96. type: Boolean,
  97. default: true
  98. },
  99. duration: [String, Number, Object],
  100. enterFromClass: String,
  101. enterActiveClass: String,
  102. enterToClass: String,
  103. appearFromClass: String,
  104. appearActiveClass: String,
  105. appearToClass: String,
  106. leaveFromClass: String,
  107. leaveActiveClass: String,
  108. leaveToClass: String
  109. };
  110. const TransitionPropsValidators = /* @__PURE__ */ extend(
  111. {},
  112. BaseTransitionPropsValidators,
  113. DOMTransitionPropsValidators
  114. );
  115. const decorate$1 = (t) => {
  116. t.displayName = "Transition";
  117. t.props = TransitionPropsValidators;
  118. return t;
  119. };
  120. const Transition = /* @__PURE__ */ decorate$1(
  121. (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots)
  122. );
  123. const callHook = (hook, args = []) => {
  124. if (isArray(hook)) {
  125. hook.forEach((h2) => h2(...args));
  126. } else if (hook) {
  127. hook(...args);
  128. }
  129. };
  130. const hasExplicitCallback = (hook) => {
  131. return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
  132. };
  133. function resolveTransitionProps(rawProps) {
  134. const baseProps = {};
  135. for (const key in rawProps) {
  136. if (!(key in DOMTransitionPropsValidators)) {
  137. baseProps[key] = rawProps[key];
  138. }
  139. }
  140. if (rawProps.css === false) {
  141. return baseProps;
  142. }
  143. const {
  144. name = "v",
  145. type,
  146. duration,
  147. enterFromClass = `${name}-enter-from`,
  148. enterActiveClass = `${name}-enter-active`,
  149. enterToClass = `${name}-enter-to`,
  150. appearFromClass = enterFromClass,
  151. appearActiveClass = enterActiveClass,
  152. appearToClass = enterToClass,
  153. leaveFromClass = `${name}-leave-from`,
  154. leaveActiveClass = `${name}-leave-active`,
  155. leaveToClass = `${name}-leave-to`
  156. } = rawProps;
  157. const durations = normalizeDuration(duration);
  158. const enterDuration = durations && durations[0];
  159. const leaveDuration = durations && durations[1];
  160. const {
  161. onBeforeEnter,
  162. onEnter,
  163. onEnterCancelled,
  164. onLeave,
  165. onLeaveCancelled,
  166. onBeforeAppear = onBeforeEnter,
  167. onAppear = onEnter,
  168. onAppearCancelled = onEnterCancelled
  169. } = baseProps;
  170. const finishEnter = (el, isAppear, done, isCancelled) => {
  171. el._enterCancelled = isCancelled;
  172. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  173. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  174. done && done();
  175. };
  176. const finishLeave = (el, done) => {
  177. el._isLeaving = false;
  178. removeTransitionClass(el, leaveFromClass);
  179. removeTransitionClass(el, leaveToClass);
  180. removeTransitionClass(el, leaveActiveClass);
  181. done && done();
  182. };
  183. const makeEnterHook = (isAppear) => {
  184. return (el, done) => {
  185. const hook = isAppear ? onAppear : onEnter;
  186. const resolve = () => finishEnter(el, isAppear, done);
  187. callHook(hook, [el, resolve]);
  188. nextFrame(() => {
  189. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  190. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  191. if (!hasExplicitCallback(hook)) {
  192. whenTransitionEnds(el, type, enterDuration, resolve);
  193. }
  194. });
  195. };
  196. };
  197. return extend(baseProps, {
  198. onBeforeEnter(el) {
  199. callHook(onBeforeEnter, [el]);
  200. addTransitionClass(el, enterFromClass);
  201. addTransitionClass(el, enterActiveClass);
  202. },
  203. onBeforeAppear(el) {
  204. callHook(onBeforeAppear, [el]);
  205. addTransitionClass(el, appearFromClass);
  206. addTransitionClass(el, appearActiveClass);
  207. },
  208. onEnter: makeEnterHook(false),
  209. onAppear: makeEnterHook(true),
  210. onLeave(el, done) {
  211. el._isLeaving = true;
  212. const resolve = () => finishLeave(el, done);
  213. addTransitionClass(el, leaveFromClass);
  214. if (!el._enterCancelled) {
  215. forceReflow(el);
  216. addTransitionClass(el, leaveActiveClass);
  217. } else {
  218. addTransitionClass(el, leaveActiveClass);
  219. forceReflow(el);
  220. }
  221. nextFrame(() => {
  222. if (!el._isLeaving) {
  223. return;
  224. }
  225. removeTransitionClass(el, leaveFromClass);
  226. addTransitionClass(el, leaveToClass);
  227. if (!hasExplicitCallback(onLeave)) {
  228. whenTransitionEnds(el, type, leaveDuration, resolve);
  229. }
  230. });
  231. callHook(onLeave, [el, resolve]);
  232. },
  233. onEnterCancelled(el) {
  234. finishEnter(el, false, void 0, true);
  235. callHook(onEnterCancelled, [el]);
  236. },
  237. onAppearCancelled(el) {
  238. finishEnter(el, true, void 0, true);
  239. callHook(onAppearCancelled, [el]);
  240. },
  241. onLeaveCancelled(el) {
  242. finishLeave(el);
  243. callHook(onLeaveCancelled, [el]);
  244. }
  245. });
  246. }
  247. function normalizeDuration(duration) {
  248. if (duration == null) {
  249. return null;
  250. } else if (isObject(duration)) {
  251. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  252. } else {
  253. const n = NumberOf(duration);
  254. return [n, n];
  255. }
  256. }
  257. function NumberOf(val) {
  258. const res = toNumber(val);
  259. if (!!(process.env.NODE_ENV !== "production")) {
  260. assertNumber(res, "<transition> explicit duration");
  261. }
  262. return res;
  263. }
  264. function addTransitionClass(el, cls) {
  265. cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
  266. (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
  267. }
  268. function removeTransitionClass(el, cls) {
  269. cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
  270. const _vtc = el[vtcKey];
  271. if (_vtc) {
  272. _vtc.delete(cls);
  273. if (!_vtc.size) {
  274. el[vtcKey] = void 0;
  275. }
  276. }
  277. }
  278. function nextFrame(cb) {
  279. requestAnimationFrame(() => {
  280. requestAnimationFrame(cb);
  281. });
  282. }
  283. let endId = 0;
  284. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  285. const id = el._endId = ++endId;
  286. const resolveIfNotStale = () => {
  287. if (id === el._endId) {
  288. resolve();
  289. }
  290. };
  291. if (explicitTimeout != null) {
  292. return setTimeout(resolveIfNotStale, explicitTimeout);
  293. }
  294. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  295. if (!type) {
  296. return resolve();
  297. }
  298. const endEvent = type + "end";
  299. let ended = 0;
  300. const end = () => {
  301. el.removeEventListener(endEvent, onEnd);
  302. resolveIfNotStale();
  303. };
  304. const onEnd = (e) => {
  305. if (e.target === el && ++ended >= propCount) {
  306. end();
  307. }
  308. };
  309. setTimeout(() => {
  310. if (ended < propCount) {
  311. end();
  312. }
  313. }, timeout + 1);
  314. el.addEventListener(endEvent, onEnd);
  315. }
  316. function getTransitionInfo(el, expectedType) {
  317. const styles = window.getComputedStyle(el);
  318. const getStyleProperties = (key) => (styles[key] || "").split(", ");
  319. const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
  320. const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
  321. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  322. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  323. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  324. const animationTimeout = getTimeout(animationDelays, animationDurations);
  325. let type = null;
  326. let timeout = 0;
  327. let propCount = 0;
  328. if (expectedType === TRANSITION) {
  329. if (transitionTimeout > 0) {
  330. type = TRANSITION;
  331. timeout = transitionTimeout;
  332. propCount = transitionDurations.length;
  333. }
  334. } else if (expectedType === ANIMATION) {
  335. if (animationTimeout > 0) {
  336. type = ANIMATION;
  337. timeout = animationTimeout;
  338. propCount = animationDurations.length;
  339. }
  340. } else {
  341. timeout = Math.max(transitionTimeout, animationTimeout);
  342. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
  343. propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
  344. }
  345. const hasTransform = type === TRANSITION && /\b(?:transform|all)(?:,|$)/.test(
  346. getStyleProperties(`${TRANSITION}Property`).toString()
  347. );
  348. return {
  349. type,
  350. timeout,
  351. propCount,
  352. hasTransform
  353. };
  354. }
  355. function getTimeout(delays, durations) {
  356. while (delays.length < durations.length) {
  357. delays = delays.concat(delays);
  358. }
  359. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  360. }
  361. function toMs(s) {
  362. if (s === "auto") return 0;
  363. return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
  364. }
  365. function forceReflow(el) {
  366. const targetDocument = el ? el.ownerDocument : document;
  367. return targetDocument.body.offsetHeight;
  368. }
  369. function patchClass(el, value, isSVG) {
  370. const transitionClasses = el[vtcKey];
  371. if (transitionClasses) {
  372. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
  373. }
  374. if (value == null) {
  375. el.removeAttribute("class");
  376. } else if (isSVG) {
  377. el.setAttribute("class", value);
  378. } else {
  379. el.className = value;
  380. }
  381. }
  382. const vShowOriginalDisplay = /* @__PURE__ */ Symbol("_vod");
  383. const vShowHidden = /* @__PURE__ */ Symbol("_vsh");
  384. const vShow = {
  385. // used for prop mismatch check during hydration
  386. name: "show",
  387. beforeMount(el, { value }, { transition }) {
  388. el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
  389. if (transition && value) {
  390. transition.beforeEnter(el);
  391. } else {
  392. setDisplay(el, value);
  393. }
  394. },
  395. mounted(el, { value }, { transition }) {
  396. if (transition && value) {
  397. transition.enter(el);
  398. }
  399. },
  400. updated(el, { value, oldValue }, { transition }) {
  401. if (!value === !oldValue) return;
  402. if (transition) {
  403. if (value) {
  404. transition.beforeEnter(el);
  405. setDisplay(el, true);
  406. transition.enter(el);
  407. } else {
  408. transition.leave(el, () => {
  409. setDisplay(el, false);
  410. });
  411. }
  412. } else {
  413. setDisplay(el, value);
  414. }
  415. },
  416. beforeUnmount(el, { value }) {
  417. setDisplay(el, value);
  418. }
  419. };
  420. function setDisplay(el, value) {
  421. el.style.display = value ? el[vShowOriginalDisplay] : "none";
  422. el[vShowHidden] = !value;
  423. }
  424. function initVShowForSSR() {
  425. vShow.getSSRProps = ({ value }) => {
  426. if (!value) {
  427. return { style: { display: "none" } };
  428. }
  429. };
  430. }
  431. const CSS_VAR_TEXT = /* @__PURE__ */ Symbol(!!(process.env.NODE_ENV !== "production") ? "CSS_VAR_TEXT" : "");
  432. function useCssVars(getter) {
  433. const instance = getCurrentInstance();
  434. if (!instance) {
  435. !!(process.env.NODE_ENV !== "production") && warn(`useCssVars is called without current active component instance.`);
  436. return;
  437. }
  438. const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
  439. Array.from(
  440. document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
  441. ).forEach((node) => setVarsOnNode(node, vars));
  442. };
  443. if (!!(process.env.NODE_ENV !== "production")) {
  444. instance.getCssVars = () => getter(instance.proxy);
  445. }
  446. const setVars = () => {
  447. const vars = getter(instance.proxy);
  448. if (instance.ce) {
  449. setVarsOnNode(instance.ce, vars);
  450. } else {
  451. setVarsOnVNode(instance.subTree, vars);
  452. }
  453. updateTeleports(vars);
  454. };
  455. onBeforeUpdate(() => {
  456. queuePostFlushCb(setVars);
  457. });
  458. onMounted(() => {
  459. watch(setVars, NOOP, { flush: "post" });
  460. const ob = new MutationObserver(setVars);
  461. ob.observe(instance.subTree.el.parentNode, { childList: true });
  462. onUnmounted(() => ob.disconnect());
  463. });
  464. }
  465. function setVarsOnVNode(vnode, vars) {
  466. if (vnode.shapeFlag & 128) {
  467. const suspense = vnode.suspense;
  468. vnode = suspense.activeBranch;
  469. if (suspense.pendingBranch && !suspense.isHydrating) {
  470. suspense.effects.push(() => {
  471. setVarsOnVNode(suspense.activeBranch, vars);
  472. });
  473. }
  474. }
  475. while (vnode.component) {
  476. vnode = vnode.component.subTree;
  477. }
  478. if (vnode.shapeFlag & 1 && vnode.el) {
  479. setVarsOnNode(vnode.el, vars);
  480. } else if (vnode.type === Fragment) {
  481. vnode.children.forEach((c) => setVarsOnVNode(c, vars));
  482. } else if (vnode.type === Static) {
  483. let { el, anchor } = vnode;
  484. while (el) {
  485. setVarsOnNode(el, vars);
  486. if (el === anchor) break;
  487. el = el.nextSibling;
  488. }
  489. }
  490. }
  491. function setVarsOnNode(el, vars) {
  492. if (el.nodeType === 1) {
  493. const style = el.style;
  494. let cssText = "";
  495. for (const key in vars) {
  496. const value = normalizeCssVarValue(vars[key]);
  497. style.setProperty(`--${key}`, value);
  498. cssText += `--${key}: ${value};`;
  499. }
  500. style[CSS_VAR_TEXT] = cssText;
  501. }
  502. }
  503. const displayRE = /(?:^|;)\s*display\s*:/;
  504. function patchStyle(el, prev, next) {
  505. const style = el.style;
  506. const isCssString = isString(next);
  507. let hasControlledDisplay = false;
  508. if (next && !isCssString) {
  509. if (prev) {
  510. if (!isString(prev)) {
  511. for (const key in prev) {
  512. if (next[key] == null) {
  513. setStyle(style, key, "");
  514. }
  515. }
  516. } else {
  517. for (const prevStyle of prev.split(";")) {
  518. const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
  519. if (next[key] == null) {
  520. setStyle(style, key, "");
  521. }
  522. }
  523. }
  524. }
  525. for (const key in next) {
  526. if (key === "display") {
  527. hasControlledDisplay = true;
  528. }
  529. setStyle(style, key, next[key]);
  530. }
  531. } else {
  532. if (isCssString) {
  533. if (prev !== next) {
  534. const cssVarText = style[CSS_VAR_TEXT];
  535. if (cssVarText) {
  536. next += ";" + cssVarText;
  537. }
  538. style.cssText = next;
  539. hasControlledDisplay = displayRE.test(next);
  540. }
  541. } else if (prev) {
  542. el.removeAttribute("style");
  543. }
  544. }
  545. if (vShowOriginalDisplay in el) {
  546. el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
  547. if (el[vShowHidden]) {
  548. style.display = "none";
  549. }
  550. }
  551. }
  552. const semicolonRE = /[^\\];\s*$/;
  553. const importantRE = /\s*!important$/;
  554. function setStyle(style, name, val) {
  555. if (isArray(val)) {
  556. val.forEach((v) => setStyle(style, name, v));
  557. } else {
  558. if (val == null) val = "";
  559. if (!!(process.env.NODE_ENV !== "production")) {
  560. if (semicolonRE.test(val)) {
  561. warn(
  562. `Unexpected semicolon at the end of '${name}' style value: '${val}'`
  563. );
  564. }
  565. }
  566. if (name.startsWith("--")) {
  567. style.setProperty(name, val);
  568. } else {
  569. const prefixed = autoPrefix(style, name);
  570. if (importantRE.test(val)) {
  571. style.setProperty(
  572. hyphenate(prefixed),
  573. val.replace(importantRE, ""),
  574. "important"
  575. );
  576. } else {
  577. style[prefixed] = val;
  578. }
  579. }
  580. }
  581. }
  582. const prefixes = ["Webkit", "Moz", "ms"];
  583. const prefixCache = {};
  584. function autoPrefix(style, rawName) {
  585. const cached = prefixCache[rawName];
  586. if (cached) {
  587. return cached;
  588. }
  589. let name = camelize(rawName);
  590. if (name !== "filter" && name in style) {
  591. return prefixCache[rawName] = name;
  592. }
  593. name = capitalize(name);
  594. for (let i = 0; i < prefixes.length; i++) {
  595. const prefixed = prefixes[i] + name;
  596. if (prefixed in style) {
  597. return prefixCache[rawName] = prefixed;
  598. }
  599. }
  600. return rawName;
  601. }
  602. const xlinkNS = "http://www.w3.org/1999/xlink";
  603. function patchAttr(el, key, value, isSVG, instance, isBoolean = isSpecialBooleanAttr(key)) {
  604. if (isSVG && key.startsWith("xlink:")) {
  605. if (value == null) {
  606. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  607. } else {
  608. el.setAttributeNS(xlinkNS, key, value);
  609. }
  610. } else {
  611. if (value == null || isBoolean && !includeBooleanAttr(value)) {
  612. el.removeAttribute(key);
  613. } else {
  614. el.setAttribute(
  615. key,
  616. isBoolean ? "" : isSymbol(value) ? String(value) : value
  617. );
  618. }
  619. }
  620. }
  621. function patchDOMProp(el, key, value, parentComponent, attrName) {
  622. if (key === "innerHTML" || key === "textContent") {
  623. if (value != null) {
  624. el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
  625. }
  626. return;
  627. }
  628. const tag = el.tagName;
  629. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  630. !tag.includes("-")) {
  631. const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
  632. const newValue = value == null ? (
  633. // #11647: value should be set as empty string for null and undefined,
  634. // but <input type="checkbox"> should be set as 'on'.
  635. el.type === "checkbox" ? "on" : ""
  636. ) : String(value);
  637. if (oldValue !== newValue || !("_value" in el)) {
  638. el.value = newValue;
  639. }
  640. if (value == null) {
  641. el.removeAttribute(key);
  642. }
  643. el._value = value;
  644. return;
  645. }
  646. let needRemove = false;
  647. if (value === "" || value == null) {
  648. const type = typeof el[key];
  649. if (type === "boolean") {
  650. value = includeBooleanAttr(value);
  651. } else if (value == null && type === "string") {
  652. value = "";
  653. needRemove = true;
  654. } else if (type === "number") {
  655. value = 0;
  656. needRemove = true;
  657. }
  658. }
  659. try {
  660. el[key] = value;
  661. } catch (e) {
  662. if (!!(process.env.NODE_ENV !== "production") && !needRemove) {
  663. warn(
  664. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  665. e
  666. );
  667. }
  668. }
  669. needRemove && el.removeAttribute(attrName || key);
  670. }
  671. function addEventListener(el, event, handler, options) {
  672. el.addEventListener(event, handler, options);
  673. }
  674. function removeEventListener(el, event, handler, options) {
  675. el.removeEventListener(event, handler, options);
  676. }
  677. const veiKey = /* @__PURE__ */ Symbol("_vei");
  678. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  679. const invokers = el[veiKey] || (el[veiKey] = {});
  680. const existingInvoker = invokers[rawName];
  681. if (nextValue && existingInvoker) {
  682. existingInvoker.value = !!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue;
  683. } else {
  684. const [name, options] = parseName(rawName);
  685. if (nextValue) {
  686. const invoker = invokers[rawName] = createInvoker(
  687. !!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue,
  688. instance
  689. );
  690. addEventListener(el, name, invoker, options);
  691. } else if (existingInvoker) {
  692. removeEventListener(el, name, existingInvoker, options);
  693. invokers[rawName] = void 0;
  694. }
  695. }
  696. }
  697. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  698. function parseName(name) {
  699. let options;
  700. if (optionsModifierRE.test(name)) {
  701. options = {};
  702. let m;
  703. while (m = name.match(optionsModifierRE)) {
  704. name = name.slice(0, name.length - m[0].length);
  705. options[m[0].toLowerCase()] = true;
  706. }
  707. }
  708. const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
  709. return [event, options];
  710. }
  711. let cachedNow = 0;
  712. const p = /* @__PURE__ */ Promise.resolve();
  713. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  714. function createInvoker(initialValue, instance) {
  715. const invoker = (e) => {
  716. if (!e._vts) {
  717. e._vts = Date.now();
  718. } else if (e._vts <= invoker.attached) {
  719. return;
  720. }
  721. callWithAsyncErrorHandling(
  722. patchStopImmediatePropagation(e, invoker.value),
  723. instance,
  724. 5,
  725. [e]
  726. );
  727. };
  728. invoker.value = initialValue;
  729. invoker.attached = getNow();
  730. return invoker;
  731. }
  732. function sanitizeEventValue(value, propName) {
  733. if (isFunction(value) || isArray(value)) {
  734. return value;
  735. }
  736. warn(
  737. `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
  738. Expected function or array of functions, received type ${typeof value}.`
  739. );
  740. return NOOP;
  741. }
  742. function patchStopImmediatePropagation(e, value) {
  743. if (isArray(value)) {
  744. const originalStop = e.stopImmediatePropagation;
  745. e.stopImmediatePropagation = () => {
  746. originalStop.call(e);
  747. e._stopped = true;
  748. };
  749. return value.map(
  750. (fn) => (e2) => !e2._stopped && fn && fn(e2)
  751. );
  752. } else {
  753. return value;
  754. }
  755. }
  756. const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
  757. key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
  758. const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
  759. const isSVG = namespace === "svg";
  760. if (key === "class") {
  761. patchClass(el, nextValue, isSVG);
  762. } else if (key === "style") {
  763. patchStyle(el, prevValue, nextValue);
  764. } else if (isOn(key)) {
  765. if (!isModelListener(key)) {
  766. patchEvent(el, key, prevValue, nextValue, parentComponent);
  767. }
  768. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  769. patchDOMProp(el, key, nextValue);
  770. if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
  771. patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
  772. }
  773. } else if (
  774. // #11081 force set props for possible async custom element
  775. el._isVueCE && // #12408 check if it's declared prop or it's async custom element
  776. (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
  777. el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
  778. ) {
  779. patchDOMProp(el, camelize$1(key), nextValue, parentComponent, key);
  780. } else {
  781. if (key === "true-value") {
  782. el._trueValue = nextValue;
  783. } else if (key === "false-value") {
  784. el._falseValue = nextValue;
  785. }
  786. patchAttr(el, key, nextValue, isSVG);
  787. }
  788. };
  789. function shouldSetAsProp(el, key, value, isSVG) {
  790. if (isSVG) {
  791. if (key === "innerHTML" || key === "textContent") {
  792. return true;
  793. }
  794. if (key in el && isNativeOn(key) && isFunction(value)) {
  795. return true;
  796. }
  797. return false;
  798. }
  799. if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") {
  800. return false;
  801. }
  802. if (key === "sandbox" && el.tagName === "IFRAME") {
  803. return false;
  804. }
  805. if (key === "form") {
  806. return false;
  807. }
  808. if (key === "list" && el.tagName === "INPUT") {
  809. return false;
  810. }
  811. if (key === "type" && el.tagName === "TEXTAREA") {
  812. return false;
  813. }
  814. if (key === "width" || key === "height") {
  815. const tag = el.tagName;
  816. if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
  817. return false;
  818. }
  819. }
  820. if (isNativeOn(key) && isString(value)) {
  821. return false;
  822. }
  823. return key in el;
  824. }
  825. function shouldSetAsPropForVueCE(el, key) {
  826. const props = (
  827. // @ts-expect-error _def is private
  828. el._def.props
  829. );
  830. if (!props) {
  831. return false;
  832. }
  833. const camelKey = camelize$1(key);
  834. return Array.isArray(props) ? props.some((prop) => camelize$1(prop) === camelKey) : Object.keys(props).some((prop) => camelize$1(prop) === camelKey);
  835. }
  836. const REMOVAL = {};
  837. // @__NO_SIDE_EFFECTS__
  838. function defineCustomElement(options, extraOptions, _createApp) {
  839. let Comp = defineComponent(options, extraOptions);
  840. if (isPlainObject(Comp)) Comp = extend({}, Comp, extraOptions);
  841. class VueCustomElement extends VueElement {
  842. constructor(initialProps) {
  843. super(Comp, initialProps, _createApp);
  844. }
  845. }
  846. VueCustomElement.def = Comp;
  847. return VueCustomElement;
  848. }
  849. const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
  850. return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
  851. });
  852. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  853. };
  854. class VueElement extends BaseClass {
  855. constructor(_def, _props = {}, _createApp = createApp) {
  856. super();
  857. this._def = _def;
  858. this._props = _props;
  859. this._createApp = _createApp;
  860. this._isVueCE = true;
  861. /**
  862. * @internal
  863. */
  864. this._instance = null;
  865. /**
  866. * @internal
  867. */
  868. this._app = null;
  869. /**
  870. * @internal
  871. */
  872. this._nonce = this._def.nonce;
  873. this._connected = false;
  874. this._resolved = false;
  875. this._patching = false;
  876. this._dirty = false;
  877. this._numberProps = null;
  878. this._styleChildren = /* @__PURE__ */ new WeakSet();
  879. this._styleAnchors = /* @__PURE__ */ new WeakMap();
  880. this._ob = null;
  881. if (this.shadowRoot && _createApp !== createApp) {
  882. this._root = this.shadowRoot;
  883. } else {
  884. if (!!(process.env.NODE_ENV !== "production") && this.shadowRoot) {
  885. warn(
  886. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
  887. );
  888. }
  889. if (_def.shadowRoot !== false) {
  890. this.attachShadow(
  891. extend({}, _def.shadowRootOptions, {
  892. mode: "open"
  893. })
  894. );
  895. this._root = this.shadowRoot;
  896. } else {
  897. this._root = this;
  898. }
  899. }
  900. }
  901. connectedCallback() {
  902. if (!this.isConnected) return;
  903. if (!this.shadowRoot && !this._resolved) {
  904. this._parseSlots();
  905. }
  906. this._connected = true;
  907. let parent = this;
  908. while (parent = parent && // #12479 should check assignedSlot first to get correct parent
  909. (parent.assignedSlot || parent.parentNode || parent.host)) {
  910. if (parent instanceof VueElement) {
  911. this._parent = parent;
  912. break;
  913. }
  914. }
  915. if (!this._instance) {
  916. if (this._resolved) {
  917. this._mount(this._def);
  918. } else {
  919. if (parent && parent._pendingResolve) {
  920. this._pendingResolve = parent._pendingResolve.then(() => {
  921. this._pendingResolve = void 0;
  922. this._resolveDef();
  923. });
  924. } else {
  925. this._resolveDef();
  926. }
  927. }
  928. }
  929. }
  930. _setParent(parent = this._parent) {
  931. if (parent) {
  932. this._instance.parent = parent._instance;
  933. this._inheritParentContext(parent);
  934. }
  935. }
  936. _inheritParentContext(parent = this._parent) {
  937. if (parent && this._app) {
  938. Object.setPrototypeOf(
  939. this._app._context.provides,
  940. parent._instance.provides
  941. );
  942. }
  943. }
  944. disconnectedCallback() {
  945. this._connected = false;
  946. nextTick(() => {
  947. if (!this._connected) {
  948. if (this._ob) {
  949. this._ob.disconnect();
  950. this._ob = null;
  951. }
  952. this._app && this._app.unmount();
  953. if (this._instance) this._instance.ce = void 0;
  954. this._app = this._instance = null;
  955. if (this._teleportTargets) {
  956. this._teleportTargets.clear();
  957. this._teleportTargets = void 0;
  958. }
  959. }
  960. });
  961. }
  962. _processMutations(mutations) {
  963. for (const m of mutations) {
  964. this._setAttr(m.attributeName);
  965. }
  966. }
  967. /**
  968. * resolve inner component definition (handle possible async component)
  969. */
  970. _resolveDef() {
  971. if (this._pendingResolve) {
  972. return;
  973. }
  974. for (let i = 0; i < this.attributes.length; i++) {
  975. this._setAttr(this.attributes[i].name);
  976. }
  977. this._ob = new MutationObserver(this._processMutations.bind(this));
  978. this._ob.observe(this, { attributes: true });
  979. const resolve = (def, isAsync = false) => {
  980. this._resolved = true;
  981. this._pendingResolve = void 0;
  982. const { props, styles } = def;
  983. let numberProps;
  984. if (props && !isArray(props)) {
  985. for (const key in props) {
  986. const opt = props[key];
  987. if (opt === Number || opt && opt.type === Number) {
  988. if (key in this._props) {
  989. this._props[key] = toNumber(this._props[key]);
  990. }
  991. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize$1(key)] = true;
  992. }
  993. }
  994. }
  995. this._numberProps = numberProps;
  996. this._resolveProps(def);
  997. if (this.shadowRoot) {
  998. this._applyStyles(styles);
  999. } else if (!!(process.env.NODE_ENV !== "production") && styles) {
  1000. warn(
  1001. "Custom element style injection is not supported when using shadowRoot: false"
  1002. );
  1003. }
  1004. this._mount(def);
  1005. };
  1006. const asyncDef = this._def.__asyncLoader;
  1007. if (asyncDef) {
  1008. this._pendingResolve = asyncDef().then((def) => {
  1009. def.configureApp = this._def.configureApp;
  1010. resolve(this._def = def, true);
  1011. });
  1012. } else {
  1013. resolve(this._def);
  1014. }
  1015. }
  1016. _mount(def) {
  1017. if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) && !def.name) {
  1018. def.name = "VueElement";
  1019. }
  1020. this._app = this._createApp(def);
  1021. this._inheritParentContext();
  1022. if (def.configureApp) {
  1023. def.configureApp(this._app);
  1024. }
  1025. this._app._ceVNode = this._createVNode();
  1026. this._app.mount(this._root);
  1027. const exposed = this._instance && this._instance.exposed;
  1028. if (!exposed) return;
  1029. for (const key in exposed) {
  1030. if (!hasOwn(this, key)) {
  1031. Object.defineProperty(this, key, {
  1032. // unwrap ref to be consistent with public instance behavior
  1033. get: () => unref(exposed[key])
  1034. });
  1035. } else if (!!(process.env.NODE_ENV !== "production")) {
  1036. warn(`Exposed property "${key}" already exists on custom element.`);
  1037. }
  1038. }
  1039. }
  1040. _resolveProps(def) {
  1041. const { props } = def;
  1042. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  1043. for (const key of Object.keys(this)) {
  1044. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  1045. this._setProp(key, this[key]);
  1046. }
  1047. }
  1048. for (const key of declaredPropKeys.map(camelize$1)) {
  1049. Object.defineProperty(this, key, {
  1050. get() {
  1051. return this._getProp(key);
  1052. },
  1053. set(val) {
  1054. this._setProp(key, val, true, !this._patching);
  1055. }
  1056. });
  1057. }
  1058. }
  1059. _setAttr(key) {
  1060. if (key.startsWith("data-v-")) return;
  1061. const has = this.hasAttribute(key);
  1062. let value = has ? this.getAttribute(key) : REMOVAL;
  1063. const camelKey = camelize$1(key);
  1064. if (has && this._numberProps && this._numberProps[camelKey]) {
  1065. value = toNumber(value);
  1066. }
  1067. this._setProp(camelKey, value, false, true);
  1068. }
  1069. /**
  1070. * @internal
  1071. */
  1072. _getProp(key) {
  1073. return this._props[key];
  1074. }
  1075. /**
  1076. * @internal
  1077. */
  1078. _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
  1079. if (val !== this._props[key]) {
  1080. this._dirty = true;
  1081. if (val === REMOVAL) {
  1082. delete this._props[key];
  1083. } else {
  1084. this._props[key] = val;
  1085. if (key === "key" && this._app) {
  1086. this._app._ceVNode.key = val;
  1087. }
  1088. }
  1089. if (shouldUpdate && this._instance) {
  1090. this._update();
  1091. }
  1092. if (shouldReflect) {
  1093. const ob = this._ob;
  1094. if (ob) {
  1095. this._processMutations(ob.takeRecords());
  1096. ob.disconnect();
  1097. }
  1098. if (val === true) {
  1099. this.setAttribute(hyphenate(key), "");
  1100. } else if (typeof val === "string" || typeof val === "number") {
  1101. this.setAttribute(hyphenate(key), val + "");
  1102. } else if (!val) {
  1103. this.removeAttribute(hyphenate(key));
  1104. }
  1105. ob && ob.observe(this, { attributes: true });
  1106. }
  1107. }
  1108. }
  1109. _update() {
  1110. const vnode = this._createVNode();
  1111. if (this._app) vnode.appContext = this._app._context;
  1112. render(vnode, this._root);
  1113. }
  1114. _createVNode() {
  1115. const baseProps = {};
  1116. if (!this.shadowRoot) {
  1117. baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
  1118. }
  1119. const vnode = createVNode(this._def, extend(baseProps, this._props));
  1120. if (!this._instance) {
  1121. vnode.ce = (instance) => {
  1122. this._instance = instance;
  1123. instance.ce = this;
  1124. instance.isCE = true;
  1125. if (!!(process.env.NODE_ENV !== "production")) {
  1126. instance.ceReload = (newStyles) => {
  1127. if (this._styles) {
  1128. this._styles.forEach((s) => this._root.removeChild(s));
  1129. this._styles.length = 0;
  1130. }
  1131. this._styleAnchors.delete(this._def);
  1132. this._applyStyles(newStyles);
  1133. this._instance = null;
  1134. this._update();
  1135. };
  1136. }
  1137. const dispatch = (event, args) => {
  1138. this.dispatchEvent(
  1139. new CustomEvent(
  1140. event,
  1141. isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
  1142. )
  1143. );
  1144. };
  1145. instance.emit = (event, ...args) => {
  1146. dispatch(event, args);
  1147. if (hyphenate(event) !== event) {
  1148. dispatch(hyphenate(event), args);
  1149. }
  1150. };
  1151. this._setParent();
  1152. };
  1153. }
  1154. return vnode;
  1155. }
  1156. _applyStyles(styles, owner, parentComp) {
  1157. if (!styles) return;
  1158. if (owner) {
  1159. if (owner === this._def || this._styleChildren.has(owner)) {
  1160. return;
  1161. }
  1162. this._styleChildren.add(owner);
  1163. }
  1164. const nonce = this._nonce;
  1165. const root = this.shadowRoot;
  1166. const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
  1167. let last = null;
  1168. for (let i = styles.length - 1; i >= 0; i--) {
  1169. const s = document.createElement("style");
  1170. if (nonce) s.setAttribute("nonce", nonce);
  1171. s.textContent = styles[i];
  1172. root.insertBefore(s, last || insertionAnchor);
  1173. last = s;
  1174. if (i === 0) {
  1175. if (!parentComp) this._styleAnchors.set(this._def, s);
  1176. if (owner) this._styleAnchors.set(owner, s);
  1177. }
  1178. if (!!(process.env.NODE_ENV !== "production")) {
  1179. if (owner) {
  1180. if (owner.__hmrId) {
  1181. if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
  1182. let entry = this._childStyles.get(owner.__hmrId);
  1183. if (!entry) {
  1184. this._childStyles.set(owner.__hmrId, entry = []);
  1185. }
  1186. entry.push(s);
  1187. }
  1188. } else {
  1189. (this._styles || (this._styles = [])).push(s);
  1190. }
  1191. }
  1192. }
  1193. }
  1194. _getStyleAnchor(comp) {
  1195. if (!comp) {
  1196. return null;
  1197. }
  1198. const anchor = this._styleAnchors.get(comp);
  1199. if (anchor && anchor.parentNode === this.shadowRoot) {
  1200. return anchor;
  1201. }
  1202. if (anchor) {
  1203. this._styleAnchors.delete(comp);
  1204. }
  1205. return null;
  1206. }
  1207. _getRootStyleInsertionAnchor(root) {
  1208. for (let i = 0; i < root.childNodes.length; i++) {
  1209. const node = root.childNodes[i];
  1210. if (!(node instanceof HTMLStyleElement)) {
  1211. return node;
  1212. }
  1213. }
  1214. return null;
  1215. }
  1216. /**
  1217. * Only called when shadowRoot is false
  1218. */
  1219. _parseSlots() {
  1220. const slots = this._slots = {};
  1221. let n;
  1222. while (n = this.firstChild) {
  1223. const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
  1224. (slots[slotName] || (slots[slotName] = [])).push(n);
  1225. this.removeChild(n);
  1226. }
  1227. }
  1228. /**
  1229. * Only called when shadowRoot is false
  1230. */
  1231. _renderSlots() {
  1232. const outlets = this._getSlots();
  1233. const scopeId = this._instance.type.__scopeId;
  1234. for (let i = 0; i < outlets.length; i++) {
  1235. const o = outlets[i];
  1236. const slotName = o.getAttribute("name") || "default";
  1237. const content = this._slots[slotName];
  1238. const parent = o.parentNode;
  1239. if (content) {
  1240. for (const n of content) {
  1241. if (scopeId && n.nodeType === 1) {
  1242. const id = scopeId + "-s";
  1243. const walker = document.createTreeWalker(n, 1);
  1244. n.setAttribute(id, "");
  1245. let child;
  1246. while (child = walker.nextNode()) {
  1247. child.setAttribute(id, "");
  1248. }
  1249. }
  1250. parent.insertBefore(n, o);
  1251. }
  1252. } else {
  1253. while (o.firstChild) parent.insertBefore(o.firstChild, o);
  1254. }
  1255. parent.removeChild(o);
  1256. }
  1257. }
  1258. /**
  1259. * @internal
  1260. */
  1261. _getSlots() {
  1262. const roots = [this];
  1263. if (this._teleportTargets) {
  1264. roots.push(...this._teleportTargets);
  1265. }
  1266. const slots = /* @__PURE__ */ new Set();
  1267. for (const root of roots) {
  1268. const found = root.querySelectorAll("slot");
  1269. for (let i = 0; i < found.length; i++) {
  1270. slots.add(found[i]);
  1271. }
  1272. }
  1273. return Array.from(slots);
  1274. }
  1275. /**
  1276. * @internal
  1277. */
  1278. _injectChildStyle(comp, parentComp) {
  1279. this._applyStyles(comp.styles, comp, parentComp);
  1280. }
  1281. /**
  1282. * @internal
  1283. */
  1284. _beginPatch() {
  1285. this._patching = true;
  1286. this._dirty = false;
  1287. }
  1288. /**
  1289. * @internal
  1290. */
  1291. _endPatch() {
  1292. this._patching = false;
  1293. if (this._dirty && this._instance) {
  1294. this._update();
  1295. }
  1296. }
  1297. /**
  1298. * @internal
  1299. */
  1300. _hasShadowRoot() {
  1301. return this._def.shadowRoot !== false;
  1302. }
  1303. /**
  1304. * @internal
  1305. */
  1306. _removeChildStyle(comp) {
  1307. if (!!(process.env.NODE_ENV !== "production")) {
  1308. this._styleChildren.delete(comp);
  1309. this._styleAnchors.delete(comp);
  1310. if (this._childStyles && comp.__hmrId) {
  1311. const oldStyles = this._childStyles.get(comp.__hmrId);
  1312. if (oldStyles) {
  1313. oldStyles.forEach((s) => this._root.removeChild(s));
  1314. oldStyles.length = 0;
  1315. }
  1316. }
  1317. }
  1318. }
  1319. }
  1320. function useHost(caller) {
  1321. const instance = getCurrentInstance();
  1322. const el = instance && instance.ce;
  1323. if (el) {
  1324. return el;
  1325. } else if (!!(process.env.NODE_ENV !== "production")) {
  1326. if (!instance) {
  1327. warn(
  1328. `${caller || "useHost"} called without an active component instance.`
  1329. );
  1330. } else {
  1331. warn(
  1332. `${caller || "useHost"} can only be used in components defined via defineCustomElement.`
  1333. );
  1334. }
  1335. }
  1336. return null;
  1337. }
  1338. function useShadowRoot() {
  1339. const el = !!(process.env.NODE_ENV !== "production") ? useHost("useShadowRoot") : useHost();
  1340. return el && el.shadowRoot;
  1341. }
  1342. function useCssModule(name = "$style") {
  1343. {
  1344. const instance = getCurrentInstance();
  1345. if (!instance) {
  1346. !!(process.env.NODE_ENV !== "production") && warn(`useCssModule must be called inside setup()`);
  1347. return EMPTY_OBJ;
  1348. }
  1349. const modules = instance.type.__cssModules;
  1350. if (!modules) {
  1351. !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS modules injected.`);
  1352. return EMPTY_OBJ;
  1353. }
  1354. const mod = modules[name];
  1355. if (!mod) {
  1356. !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS module named "${name}".`);
  1357. return EMPTY_OBJ;
  1358. }
  1359. return mod;
  1360. }
  1361. }
  1362. const positionMap = /* @__PURE__ */ new WeakMap();
  1363. const newPositionMap = /* @__PURE__ */ new WeakMap();
  1364. const moveCbKey = /* @__PURE__ */ Symbol("_moveCb");
  1365. const enterCbKey = /* @__PURE__ */ Symbol("_enterCb");
  1366. const decorate = (t) => {
  1367. delete t.props.mode;
  1368. return t;
  1369. };
  1370. const TransitionGroupImpl = /* @__PURE__ */ decorate({
  1371. name: "TransitionGroup",
  1372. props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
  1373. tag: String,
  1374. moveClass: String
  1375. }),
  1376. setup(props, { slots }) {
  1377. const instance = getCurrentInstance();
  1378. const state = useTransitionState();
  1379. let prevChildren;
  1380. let children;
  1381. onUpdated(() => {
  1382. if (!prevChildren.length) {
  1383. return;
  1384. }
  1385. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  1386. if (!hasCSSTransform(
  1387. prevChildren[0].el,
  1388. instance.vnode.el,
  1389. moveClass
  1390. )) {
  1391. prevChildren = [];
  1392. return;
  1393. }
  1394. prevChildren.forEach(callPendingCbs);
  1395. prevChildren.forEach(recordPosition);
  1396. const movedChildren = prevChildren.filter(applyTranslation);
  1397. forceReflow(instance.vnode.el);
  1398. movedChildren.forEach((c) => {
  1399. const el = c.el;
  1400. const style = el.style;
  1401. addTransitionClass(el, moveClass);
  1402. style.transform = style.webkitTransform = style.transitionDuration = "";
  1403. const cb = el[moveCbKey] = (e) => {
  1404. if (e && e.target !== el) {
  1405. return;
  1406. }
  1407. if (!e || e.propertyName.endsWith("transform")) {
  1408. el.removeEventListener("transitionend", cb);
  1409. el[moveCbKey] = null;
  1410. removeTransitionClass(el, moveClass);
  1411. }
  1412. };
  1413. el.addEventListener("transitionend", cb);
  1414. });
  1415. prevChildren = [];
  1416. });
  1417. return () => {
  1418. const rawProps = toRaw(props);
  1419. const cssTransitionProps = resolveTransitionProps(rawProps);
  1420. let tag = rawProps.tag || Fragment;
  1421. prevChildren = [];
  1422. if (children) {
  1423. for (let i = 0; i < children.length; i++) {
  1424. const child = children[i];
  1425. if (child.el && child.el instanceof Element) {
  1426. prevChildren.push(child);
  1427. setTransitionHooks(
  1428. child,
  1429. resolveTransitionHooks(
  1430. child,
  1431. cssTransitionProps,
  1432. state,
  1433. instance
  1434. )
  1435. );
  1436. positionMap.set(child, getPosition(child.el));
  1437. }
  1438. }
  1439. }
  1440. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  1441. for (let i = 0; i < children.length; i++) {
  1442. const child = children[i];
  1443. if (child.key != null) {
  1444. setTransitionHooks(
  1445. child,
  1446. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  1447. );
  1448. } else if (!!(process.env.NODE_ENV !== "production") && child.type !== Text) {
  1449. warn(`<TransitionGroup> children must be keyed.`);
  1450. }
  1451. }
  1452. return createVNode(tag, null, children);
  1453. };
  1454. }
  1455. });
  1456. const TransitionGroup = TransitionGroupImpl;
  1457. function callPendingCbs(c) {
  1458. const el = c.el;
  1459. if (el[moveCbKey]) {
  1460. el[moveCbKey]();
  1461. }
  1462. if (el[enterCbKey]) {
  1463. el[enterCbKey]();
  1464. }
  1465. }
  1466. function recordPosition(c) {
  1467. newPositionMap.set(c, getPosition(c.el));
  1468. }
  1469. function applyTranslation(c) {
  1470. const oldPos = positionMap.get(c);
  1471. const newPos = newPositionMap.get(c);
  1472. const dx = oldPos.left - newPos.left;
  1473. const dy = oldPos.top - newPos.top;
  1474. if (dx || dy) {
  1475. const el = c.el;
  1476. const s = el.style;
  1477. const rect = el.getBoundingClientRect();
  1478. let scaleX = 1;
  1479. let scaleY = 1;
  1480. if (el.offsetWidth) scaleX = rect.width / el.offsetWidth;
  1481. if (el.offsetHeight) scaleY = rect.height / el.offsetHeight;
  1482. if (!Number.isFinite(scaleX) || scaleX === 0) scaleX = 1;
  1483. if (!Number.isFinite(scaleY) || scaleY === 0) scaleY = 1;
  1484. if (Math.abs(scaleX - 1) < 0.01) scaleX = 1;
  1485. if (Math.abs(scaleY - 1) < 0.01) scaleY = 1;
  1486. s.transform = s.webkitTransform = `translate(${dx / scaleX}px,${dy / scaleY}px)`;
  1487. s.transitionDuration = "0s";
  1488. return c;
  1489. }
  1490. }
  1491. function getPosition(el) {
  1492. const rect = el.getBoundingClientRect();
  1493. return {
  1494. left: rect.left,
  1495. top: rect.top
  1496. };
  1497. }
  1498. function hasCSSTransform(el, root, moveClass) {
  1499. const clone = el.cloneNode();
  1500. const _vtc = el[vtcKey];
  1501. if (_vtc) {
  1502. _vtc.forEach((cls) => {
  1503. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  1504. });
  1505. }
  1506. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  1507. clone.style.display = "none";
  1508. const container = root.nodeType === 1 ? root : root.parentNode;
  1509. container.appendChild(clone);
  1510. const { hasTransform } = getTransitionInfo(clone);
  1511. container.removeChild(clone);
  1512. return hasTransform;
  1513. }
  1514. const getModelAssigner = (vnode) => {
  1515. const fn = vnode.props["onUpdate:modelValue"] || false;
  1516. return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
  1517. };
  1518. function onCompositionStart(e) {
  1519. e.target.composing = true;
  1520. }
  1521. function onCompositionEnd(e) {
  1522. const target = e.target;
  1523. if (target.composing) {
  1524. target.composing = false;
  1525. target.dispatchEvent(new Event("input"));
  1526. }
  1527. }
  1528. const assignKey = /* @__PURE__ */ Symbol("_assign");
  1529. function castValue(value, trim, number) {
  1530. if (trim) value = value.trim();
  1531. if (number) value = looseToNumber(value);
  1532. return value;
  1533. }
  1534. const vModelText = {
  1535. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  1536. el[assignKey] = getModelAssigner(vnode);
  1537. const castToNumber = number || vnode.props && vnode.props.type === "number";
  1538. addEventListener(el, lazy ? "change" : "input", (e) => {
  1539. if (e.target.composing) return;
  1540. el[assignKey](castValue(el.value, trim, castToNumber));
  1541. });
  1542. if (trim || castToNumber) {
  1543. addEventListener(el, "change", () => {
  1544. el.value = castValue(el.value, trim, castToNumber);
  1545. });
  1546. }
  1547. if (!lazy) {
  1548. addEventListener(el, "compositionstart", onCompositionStart);
  1549. addEventListener(el, "compositionend", onCompositionEnd);
  1550. addEventListener(el, "change", onCompositionEnd);
  1551. }
  1552. },
  1553. // set value on mounted so it's after min/max for type="range"
  1554. mounted(el, { value }) {
  1555. el.value = value == null ? "" : value;
  1556. },
  1557. beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
  1558. el[assignKey] = getModelAssigner(vnode);
  1559. if (el.composing) return;
  1560. const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
  1561. const newValue = value == null ? "" : value;
  1562. if (elValue === newValue) {
  1563. return;
  1564. }
  1565. if (document.activeElement === el && el.type !== "range") {
  1566. if (lazy && value === oldValue) {
  1567. return;
  1568. }
  1569. if (trim && el.value.trim() === newValue) {
  1570. return;
  1571. }
  1572. }
  1573. el.value = newValue;
  1574. }
  1575. };
  1576. const vModelCheckbox = {
  1577. // #4096 array checkboxes need to be deep traversed
  1578. deep: true,
  1579. created(el, _, vnode) {
  1580. el[assignKey] = getModelAssigner(vnode);
  1581. addEventListener(el, "change", () => {
  1582. const modelValue = el._modelValue;
  1583. const elementValue = getValue(el);
  1584. const checked = el.checked;
  1585. const assign = el[assignKey];
  1586. if (isArray(modelValue)) {
  1587. const index = looseIndexOf(modelValue, elementValue);
  1588. const found = index !== -1;
  1589. if (checked && !found) {
  1590. assign(modelValue.concat(elementValue));
  1591. } else if (!checked && found) {
  1592. const filtered = [...modelValue];
  1593. filtered.splice(index, 1);
  1594. assign(filtered);
  1595. }
  1596. } else if (isSet(modelValue)) {
  1597. const cloned = new Set(modelValue);
  1598. if (checked) {
  1599. cloned.add(elementValue);
  1600. } else {
  1601. cloned.delete(elementValue);
  1602. }
  1603. assign(cloned);
  1604. } else {
  1605. assign(getCheckboxValue(el, checked));
  1606. }
  1607. });
  1608. },
  1609. // set initial checked on mount to wait for true-value/false-value
  1610. mounted: setChecked,
  1611. beforeUpdate(el, binding, vnode) {
  1612. el[assignKey] = getModelAssigner(vnode);
  1613. setChecked(el, binding, vnode);
  1614. }
  1615. };
  1616. function setChecked(el, { value, oldValue }, vnode) {
  1617. el._modelValue = value;
  1618. let checked;
  1619. if (isArray(value)) {
  1620. checked = looseIndexOf(value, vnode.props.value) > -1;
  1621. } else if (isSet(value)) {
  1622. checked = value.has(vnode.props.value);
  1623. } else {
  1624. if (value === oldValue) return;
  1625. checked = looseEqual(value, getCheckboxValue(el, true));
  1626. }
  1627. if (el.checked !== checked) {
  1628. el.checked = checked;
  1629. }
  1630. }
  1631. const vModelRadio = {
  1632. created(el, { value }, vnode) {
  1633. el.checked = looseEqual(value, vnode.props.value);
  1634. el[assignKey] = getModelAssigner(vnode);
  1635. addEventListener(el, "change", () => {
  1636. el[assignKey](getValue(el));
  1637. });
  1638. },
  1639. beforeUpdate(el, { value, oldValue }, vnode) {
  1640. el[assignKey] = getModelAssigner(vnode);
  1641. if (value !== oldValue) {
  1642. el.checked = looseEqual(value, vnode.props.value);
  1643. }
  1644. }
  1645. };
  1646. const vModelSelect = {
  1647. // <select multiple> value need to be deep traversed
  1648. deep: true,
  1649. created(el, { value, modifiers: { number } }, vnode) {
  1650. const isSetModel = isSet(value);
  1651. addEventListener(el, "change", () => {
  1652. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  1653. (o) => number ? looseToNumber(getValue(o)) : getValue(o)
  1654. );
  1655. el[assignKey](
  1656. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  1657. );
  1658. el._assigning = true;
  1659. nextTick(() => {
  1660. el._assigning = false;
  1661. });
  1662. });
  1663. el[assignKey] = getModelAssigner(vnode);
  1664. },
  1665. // set value in mounted & updated because <select> relies on its children
  1666. // <option>s.
  1667. mounted(el, { value }) {
  1668. setSelected(el, value);
  1669. },
  1670. beforeUpdate(el, _binding, vnode) {
  1671. el[assignKey] = getModelAssigner(vnode);
  1672. },
  1673. updated(el, { value }) {
  1674. if (!el._assigning) {
  1675. setSelected(el, value);
  1676. }
  1677. }
  1678. };
  1679. function setSelected(el, value) {
  1680. const isMultiple = el.multiple;
  1681. const isArrayValue = isArray(value);
  1682. if (isMultiple && !isArrayValue && !isSet(value)) {
  1683. !!(process.env.NODE_ENV !== "production") && warn(
  1684. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  1685. );
  1686. return;
  1687. }
  1688. for (let i = 0, l = el.options.length; i < l; i++) {
  1689. const option = el.options[i];
  1690. const optionValue = getValue(option);
  1691. if (isMultiple) {
  1692. if (isArrayValue) {
  1693. const optionType = typeof optionValue;
  1694. if (optionType === "string" || optionType === "number") {
  1695. option.selected = value.some((v) => String(v) === String(optionValue));
  1696. } else {
  1697. option.selected = looseIndexOf(value, optionValue) > -1;
  1698. }
  1699. } else {
  1700. option.selected = value.has(optionValue);
  1701. }
  1702. } else if (looseEqual(getValue(option), value)) {
  1703. if (el.selectedIndex !== i) el.selectedIndex = i;
  1704. return;
  1705. }
  1706. }
  1707. if (!isMultiple && el.selectedIndex !== -1) {
  1708. el.selectedIndex = -1;
  1709. }
  1710. }
  1711. function getValue(el) {
  1712. return "_value" in el ? el._value : el.value;
  1713. }
  1714. function getCheckboxValue(el, checked) {
  1715. const key = checked ? "_trueValue" : "_falseValue";
  1716. return key in el ? el[key] : checked;
  1717. }
  1718. const vModelDynamic = {
  1719. created(el, binding, vnode) {
  1720. callModelHook(el, binding, vnode, null, "created");
  1721. },
  1722. mounted(el, binding, vnode) {
  1723. callModelHook(el, binding, vnode, null, "mounted");
  1724. },
  1725. beforeUpdate(el, binding, vnode, prevVNode) {
  1726. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  1727. },
  1728. updated(el, binding, vnode, prevVNode) {
  1729. callModelHook(el, binding, vnode, prevVNode, "updated");
  1730. }
  1731. };
  1732. function resolveDynamicModel(tagName, type) {
  1733. switch (tagName) {
  1734. case "SELECT":
  1735. return vModelSelect;
  1736. case "TEXTAREA":
  1737. return vModelText;
  1738. default:
  1739. switch (type) {
  1740. case "checkbox":
  1741. return vModelCheckbox;
  1742. case "radio":
  1743. return vModelRadio;
  1744. default:
  1745. return vModelText;
  1746. }
  1747. }
  1748. }
  1749. function callModelHook(el, binding, vnode, prevVNode, hook) {
  1750. const modelToUse = resolveDynamicModel(
  1751. el.tagName,
  1752. vnode.props && vnode.props.type
  1753. );
  1754. const fn = modelToUse[hook];
  1755. fn && fn(el, binding, vnode, prevVNode);
  1756. }
  1757. function initVModelForSSR() {
  1758. vModelText.getSSRProps = ({ value }) => ({ value });
  1759. vModelRadio.getSSRProps = ({ value }, vnode) => {
  1760. if (vnode.props && looseEqual(vnode.props.value, value)) {
  1761. return { checked: true };
  1762. }
  1763. };
  1764. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  1765. if (isArray(value)) {
  1766. if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
  1767. return { checked: true };
  1768. }
  1769. } else if (isSet(value)) {
  1770. if (vnode.props && value.has(vnode.props.value)) {
  1771. return { checked: true };
  1772. }
  1773. } else if (value) {
  1774. return { checked: true };
  1775. }
  1776. };
  1777. vModelDynamic.getSSRProps = (binding, vnode) => {
  1778. if (typeof vnode.type !== "string") {
  1779. return;
  1780. }
  1781. const modelToUse = resolveDynamicModel(
  1782. // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
  1783. vnode.type.toUpperCase(),
  1784. vnode.props && vnode.props.type
  1785. );
  1786. if (modelToUse.getSSRProps) {
  1787. return modelToUse.getSSRProps(binding, vnode);
  1788. }
  1789. };
  1790. }
  1791. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  1792. const modifierGuards = {
  1793. stop: (e) => e.stopPropagation(),
  1794. prevent: (e) => e.preventDefault(),
  1795. self: (e) => e.target !== e.currentTarget,
  1796. ctrl: (e) => !e.ctrlKey,
  1797. shift: (e) => !e.shiftKey,
  1798. alt: (e) => !e.altKey,
  1799. meta: (e) => !e.metaKey,
  1800. left: (e) => "button" in e && e.button !== 0,
  1801. middle: (e) => "button" in e && e.button !== 1,
  1802. right: (e) => "button" in e && e.button !== 2,
  1803. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  1804. };
  1805. const withModifiers = (fn, modifiers) => {
  1806. if (!fn) return fn;
  1807. const cache = fn._withMods || (fn._withMods = {});
  1808. const cacheKey = modifiers.join(".");
  1809. return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => {
  1810. for (let i = 0; i < modifiers.length; i++) {
  1811. const guard = modifierGuards[modifiers[i]];
  1812. if (guard && guard(event, modifiers)) return;
  1813. }
  1814. return fn(event, ...args);
  1815. }));
  1816. };
  1817. const keyNames = {
  1818. esc: "escape",
  1819. space: " ",
  1820. up: "arrow-up",
  1821. left: "arrow-left",
  1822. right: "arrow-right",
  1823. down: "arrow-down",
  1824. delete: "backspace"
  1825. };
  1826. const withKeys = (fn, modifiers) => {
  1827. const cache = fn._withKeys || (fn._withKeys = {});
  1828. const cacheKey = modifiers.join(".");
  1829. return cache[cacheKey] || (cache[cacheKey] = ((event) => {
  1830. if (!("key" in event)) {
  1831. return;
  1832. }
  1833. const eventKey = hyphenate(event.key);
  1834. if (modifiers.some(
  1835. (k) => k === eventKey || keyNames[k] === eventKey
  1836. )) {
  1837. return fn(event);
  1838. }
  1839. }));
  1840. };
  1841. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
  1842. let renderer;
  1843. let enabledHydration = false;
  1844. function ensureRenderer() {
  1845. return renderer || (renderer = createRenderer(rendererOptions));
  1846. }
  1847. function ensureHydrationRenderer() {
  1848. renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
  1849. enabledHydration = true;
  1850. return renderer;
  1851. }
  1852. const render = ((...args) => {
  1853. ensureRenderer().render(...args);
  1854. });
  1855. const hydrate = ((...args) => {
  1856. ensureHydrationRenderer().hydrate(...args);
  1857. });
  1858. const createApp = ((...args) => {
  1859. const app = ensureRenderer().createApp(...args);
  1860. if (!!(process.env.NODE_ENV !== "production")) {
  1861. injectNativeTagCheck(app);
  1862. injectCompilerOptionsCheck(app);
  1863. }
  1864. const { mount } = app;
  1865. app.mount = (containerOrSelector) => {
  1866. const container = normalizeContainer(containerOrSelector);
  1867. if (!container) return;
  1868. const component = app._component;
  1869. if (!isFunction(component) && !component.render && !component.template) {
  1870. component.template = container.innerHTML;
  1871. }
  1872. if (container.nodeType === 1) {
  1873. container.textContent = "";
  1874. }
  1875. const proxy = mount(container, false, resolveRootNamespace(container));
  1876. if (container instanceof Element) {
  1877. container.removeAttribute("v-cloak");
  1878. container.setAttribute("data-v-app", "");
  1879. }
  1880. return proxy;
  1881. };
  1882. return app;
  1883. });
  1884. const createSSRApp = ((...args) => {
  1885. const app = ensureHydrationRenderer().createApp(...args);
  1886. if (!!(process.env.NODE_ENV !== "production")) {
  1887. injectNativeTagCheck(app);
  1888. injectCompilerOptionsCheck(app);
  1889. }
  1890. const { mount } = app;
  1891. app.mount = (containerOrSelector) => {
  1892. const container = normalizeContainer(containerOrSelector);
  1893. if (container) {
  1894. return mount(container, true, resolveRootNamespace(container));
  1895. }
  1896. };
  1897. return app;
  1898. });
  1899. function resolveRootNamespace(container) {
  1900. if (container instanceof SVGElement) {
  1901. return "svg";
  1902. }
  1903. if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
  1904. return "mathml";
  1905. }
  1906. }
  1907. function injectNativeTagCheck(app) {
  1908. Object.defineProperty(app.config, "isNativeTag", {
  1909. value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  1910. writable: false
  1911. });
  1912. }
  1913. function injectCompilerOptionsCheck(app) {
  1914. if (isRuntimeOnly()) {
  1915. const isCustomElement = app.config.isCustomElement;
  1916. Object.defineProperty(app.config, "isCustomElement", {
  1917. get() {
  1918. return isCustomElement;
  1919. },
  1920. set() {
  1921. warn(
  1922. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  1923. );
  1924. }
  1925. });
  1926. const compilerOptions = app.config.compilerOptions;
  1927. 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.
  1928. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  1929. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  1930. - 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`;
  1931. Object.defineProperty(app.config, "compilerOptions", {
  1932. get() {
  1933. warn(msg);
  1934. return compilerOptions;
  1935. },
  1936. set() {
  1937. warn(msg);
  1938. }
  1939. });
  1940. }
  1941. }
  1942. function normalizeContainer(container) {
  1943. if (isString(container)) {
  1944. const res = document.querySelector(container);
  1945. if (!!(process.env.NODE_ENV !== "production") && !res) {
  1946. warn(
  1947. `Failed to mount app: mount target selector "${container}" returned null.`
  1948. );
  1949. }
  1950. return res;
  1951. }
  1952. if (!!(process.env.NODE_ENV !== "production") && window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  1953. warn(
  1954. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  1955. );
  1956. }
  1957. return container;
  1958. }
  1959. let ssrDirectiveInitialized = false;
  1960. const initDirectivesForSSR = () => {
  1961. if (!ssrDirectiveInitialized) {
  1962. ssrDirectiveInitialized = true;
  1963. initVModelForSSR();
  1964. initVShowForSSR();
  1965. }
  1966. } ;
  1967. export { Transition, TransitionGroup, VueElement, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, hydrate, initDirectivesForSSR, nodeOps, patchProp, render, useCssModule, useCssVars, useHost, useShadowRoot, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, withKeys, withModifiers };