runtime-dom.esm-bundler.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035
  1. /**
  2. * @vue/runtime-dom v3.5.41
  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. const value = next[key];
  530. if (value != null) {
  531. if (!shouldPreserveTextareaResizeStyle(
  532. el,
  533. key,
  534. !isString(prev) && prev ? prev[key] : void 0,
  535. value
  536. )) {
  537. setStyle(style, key, value);
  538. }
  539. } else {
  540. setStyle(style, key, "");
  541. }
  542. }
  543. } else {
  544. if (isCssString) {
  545. if (prev !== next) {
  546. const cssVarText = style[CSS_VAR_TEXT];
  547. if (cssVarText) {
  548. next += ";" + cssVarText;
  549. }
  550. style.cssText = next;
  551. hasControlledDisplay = displayRE.test(next);
  552. }
  553. } else if (prev) {
  554. el.removeAttribute("style");
  555. }
  556. }
  557. if (vShowOriginalDisplay in el) {
  558. el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
  559. if (el[vShowHidden]) {
  560. style.display = "none";
  561. }
  562. }
  563. }
  564. const semicolonRE = /[^\\];\s*$/;
  565. const importantRE = /\s*!important$/;
  566. function setStyle(style, name, val) {
  567. if (isArray(val)) {
  568. val.forEach((v) => setStyle(style, name, v));
  569. } else {
  570. if (val == null) val = "";
  571. if (!!(process.env.NODE_ENV !== "production")) {
  572. if (semicolonRE.test(val)) {
  573. warn(
  574. `Unexpected semicolon at the end of '${name}' style value: '${val}'`
  575. );
  576. }
  577. }
  578. if (name.startsWith("--")) {
  579. style.setProperty(name, val);
  580. } else {
  581. const prefixed = autoPrefix(style, name);
  582. if (importantRE.test(val)) {
  583. style.setProperty(
  584. hyphenate(prefixed),
  585. val.replace(importantRE, ""),
  586. "important"
  587. );
  588. } else {
  589. style[prefixed] = val;
  590. }
  591. }
  592. }
  593. }
  594. const prefixes = ["Webkit", "Moz", "ms"];
  595. const prefixCache = {};
  596. function autoPrefix(style, rawName) {
  597. const cached = prefixCache[rawName];
  598. if (cached) {
  599. return cached;
  600. }
  601. let name = camelize(rawName);
  602. if (name !== "filter" && name in style) {
  603. return prefixCache[rawName] = name;
  604. }
  605. name = capitalize(name);
  606. for (let i = 0; i < prefixes.length; i++) {
  607. const prefixed = prefixes[i] + name;
  608. if (prefixed in style) {
  609. return prefixCache[rawName] = prefixed;
  610. }
  611. }
  612. return rawName;
  613. }
  614. function shouldPreserveTextareaResizeStyle(el, key, prev, next) {
  615. return el.tagName === "TEXTAREA" && (key === "width" || key === "height") && isString(next) && prev === next;
  616. }
  617. const xlinkNS = "http://www.w3.org/1999/xlink";
  618. function patchAttr(el, key, value, isSVG, instance, isBoolean = isSpecialBooleanAttr(key)) {
  619. if (isSVG && key.startsWith("xlink:")) {
  620. if (value == null) {
  621. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  622. } else {
  623. el.setAttributeNS(xlinkNS, key, value);
  624. }
  625. } else {
  626. if (value == null || isBoolean && !includeBooleanAttr(value)) {
  627. el.removeAttribute(key);
  628. } else {
  629. el.setAttribute(
  630. key,
  631. isBoolean ? "" : isSymbol(value) ? String(value) : value
  632. );
  633. }
  634. }
  635. }
  636. function patchDOMProp(el, key, value, parentComponent, attrName) {
  637. if (key === "innerHTML" || key === "textContent") {
  638. if (value != null) {
  639. el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
  640. }
  641. return;
  642. }
  643. const tag = el.tagName;
  644. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  645. !tag.includes("-")) {
  646. const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
  647. const newValue = value == null ? (
  648. // #11647: value should be set as empty string for null and undefined,
  649. // but <input type="checkbox"> should be set as 'on'.
  650. el.type === "checkbox" ? "on" : ""
  651. ) : String(value);
  652. if (oldValue !== newValue || !("_value" in el)) {
  653. el.value = newValue;
  654. }
  655. if (value == null) {
  656. el.removeAttribute(key);
  657. }
  658. el._value = value;
  659. return;
  660. }
  661. let needRemove = false;
  662. if (value === "" || value == null) {
  663. const type = typeof el[key];
  664. if (type === "boolean") {
  665. value = includeBooleanAttr(value);
  666. } else if (value == null && type === "string") {
  667. value = "";
  668. needRemove = true;
  669. } else if (type === "number") {
  670. value = 0;
  671. needRemove = true;
  672. }
  673. }
  674. try {
  675. el[key] = value;
  676. } catch (e) {
  677. if (!!(process.env.NODE_ENV !== "production") && !needRemove) {
  678. warn(
  679. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  680. e
  681. );
  682. }
  683. }
  684. needRemove && el.removeAttribute(attrName || key);
  685. }
  686. function addEventListener(el, event, handler, options) {
  687. el.addEventListener(event, handler, options);
  688. }
  689. function removeEventListener(el, event, handler, options) {
  690. el.removeEventListener(event, handler, options);
  691. }
  692. const veiKey = /* @__PURE__ */ Symbol("_vei");
  693. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  694. const invokers = el[veiKey] || (el[veiKey] = {});
  695. const existingInvoker = invokers[rawName];
  696. if (nextValue && existingInvoker) {
  697. existingInvoker.value = !!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue;
  698. } else {
  699. const [name, options] = parseName(rawName);
  700. if (nextValue) {
  701. const invoker = invokers[rawName] = createInvoker(
  702. !!(process.env.NODE_ENV !== "production") ? sanitizeEventValue(nextValue, rawName) : nextValue,
  703. instance
  704. );
  705. addEventListener(el, name, invoker, options);
  706. } else if (existingInvoker) {
  707. removeEventListener(el, name, existingInvoker, options);
  708. invokers[rawName] = void 0;
  709. }
  710. }
  711. }
  712. const optionsModifierRE = /(Once|Passive|Capture)$/;
  713. const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
  714. function parseName(name) {
  715. let options;
  716. let m;
  717. while ((m = name.match(optionsModifierRE)) && !optionsModifierEventRE.test(name)) {
  718. if (!options) options = {};
  719. name = name.slice(0, name.length - m[1].length);
  720. options[m[1].toLowerCase()] = true;
  721. }
  722. const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
  723. return [event, options];
  724. }
  725. let cachedNow = 0;
  726. const p = /* @__PURE__ */ Promise.resolve();
  727. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  728. function createInvoker(initialValue, instance) {
  729. const invoker = (e) => {
  730. if (!e._vts) {
  731. e._vts = Date.now();
  732. } else if (e._vts <= invoker.attached) {
  733. return;
  734. }
  735. const value = invoker.value;
  736. if (isArray(value)) {
  737. const originalStop = e.stopImmediatePropagation;
  738. e.stopImmediatePropagation = () => {
  739. originalStop.call(e);
  740. e._stopped = true;
  741. };
  742. const handlers = value.slice();
  743. const args = [e];
  744. for (let i = 0; i < handlers.length; i++) {
  745. if (e._stopped) {
  746. break;
  747. }
  748. const handler = handlers[i];
  749. if (handler) {
  750. callWithAsyncErrorHandling(
  751. handler,
  752. instance,
  753. 5,
  754. args
  755. );
  756. }
  757. }
  758. } else {
  759. callWithAsyncErrorHandling(
  760. value,
  761. instance,
  762. 5,
  763. [e]
  764. );
  765. }
  766. };
  767. invoker.value = initialValue;
  768. invoker.attached = getNow();
  769. return invoker;
  770. }
  771. function sanitizeEventValue(value, propName) {
  772. if (isFunction(value) || isArray(value)) {
  773. return value;
  774. }
  775. warn(
  776. `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
  777. Expected function or array of functions, received type ${typeof value}.`
  778. );
  779. return NOOP;
  780. }
  781. const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
  782. key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
  783. const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
  784. const isSVG = namespace === "svg";
  785. if (key === "class") {
  786. patchClass(el, nextValue, isSVG);
  787. } else if (key === "style") {
  788. patchStyle(el, prevValue, nextValue);
  789. } else if (isOn(key)) {
  790. if (!isModelListener(key)) {
  791. patchEvent(el, key, prevValue, nextValue, parentComponent);
  792. }
  793. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  794. patchDOMProp(el, key, nextValue);
  795. if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
  796. patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
  797. }
  798. } else if (
  799. // #11081 force set props for possible async custom element
  800. el._isVueCE && // #12408 check if it's declared prop or it's async custom element
  801. (shouldSetAsPropForVueCE(el, key) || // @ts-expect-error _def is private
  802. el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))
  803. ) {
  804. patchDOMProp(el, camelize$1(key), nextValue, parentComponent, key);
  805. } else {
  806. if (key === "true-value") {
  807. el._trueValue = nextValue;
  808. } else if (key === "false-value") {
  809. el._falseValue = nextValue;
  810. }
  811. patchAttr(el, key, nextValue, isSVG);
  812. }
  813. };
  814. function shouldSetAsProp(el, key, value, isSVG) {
  815. if (isSVG) {
  816. if (key === "innerHTML" || key === "textContent") {
  817. return true;
  818. }
  819. if (key in el && isNativeOn(key) && isFunction(value)) {
  820. return true;
  821. }
  822. return false;
  823. }
  824. if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") {
  825. return false;
  826. }
  827. if (key === "sandbox" && el.tagName === "IFRAME") {
  828. return false;
  829. }
  830. if (key === "form") {
  831. return false;
  832. }
  833. if (key === "list" && el.tagName === "INPUT") {
  834. return false;
  835. }
  836. if (key === "type" && el.tagName === "TEXTAREA") {
  837. return false;
  838. }
  839. if (key === "width" || key === "height") {
  840. const tag = el.tagName;
  841. if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
  842. return false;
  843. }
  844. }
  845. if (isNativeOn(key) && isString(value)) {
  846. return false;
  847. }
  848. return key in el;
  849. }
  850. function shouldSetAsPropForVueCE(el, key) {
  851. const props = (
  852. // @ts-expect-error _def is private
  853. el._def.props
  854. );
  855. if (!props) {
  856. return false;
  857. }
  858. const camelKey = camelize$1(key);
  859. return Array.isArray(props) ? props.some((prop) => camelize$1(prop) === camelKey) : Object.keys(props).some((prop) => camelize$1(prop) === camelKey);
  860. }
  861. const REMOVAL = {};
  862. // @__NO_SIDE_EFFECTS__
  863. function defineCustomElement(options, extraOptions, _createApp) {
  864. let Comp = defineComponent(options, extraOptions);
  865. if (isPlainObject(Comp)) Comp = extend({}, Comp, extraOptions);
  866. class VueCustomElement extends VueElement {
  867. constructor(initialProps) {
  868. super(Comp, initialProps, _createApp);
  869. }
  870. }
  871. VueCustomElement.def = Comp;
  872. return VueCustomElement;
  873. }
  874. const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
  875. return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
  876. });
  877. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  878. };
  879. class VueElement extends BaseClass {
  880. constructor(_def, _props = {}, _createApp = createApp) {
  881. super();
  882. this._def = _def;
  883. this._props = _props;
  884. this._createApp = _createApp;
  885. this._isVueCE = true;
  886. /**
  887. * @internal
  888. */
  889. this._instance = null;
  890. /**
  891. * @internal
  892. */
  893. this._app = null;
  894. /**
  895. * @internal
  896. */
  897. this._nonce = this._def.nonce;
  898. this._connected = false;
  899. this._resolved = false;
  900. this._patching = false;
  901. this._dirty = false;
  902. this._numberProps = null;
  903. this._styleChildren = /* @__PURE__ */ new WeakSet();
  904. this._styleAnchors = /* @__PURE__ */ new WeakMap();
  905. this._ob = null;
  906. if (this.shadowRoot && _createApp !== createApp) {
  907. this._root = this.shadowRoot;
  908. } else {
  909. if (!!(process.env.NODE_ENV !== "production") && this.shadowRoot) {
  910. warn(
  911. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
  912. );
  913. }
  914. if (_def.shadowRoot !== false) {
  915. this.attachShadow(
  916. extend({}, _def.shadowRootOptions, {
  917. mode: "open"
  918. })
  919. );
  920. this._root = this.shadowRoot;
  921. } else {
  922. this._root = this;
  923. }
  924. }
  925. }
  926. connectedCallback() {
  927. if (!this.isConnected) return;
  928. if (!this.shadowRoot && !this._resolved) {
  929. this._parseSlots();
  930. }
  931. this._connected = true;
  932. let parent = this;
  933. while (parent = parent && // #12479 should check assignedSlot first to get correct parent
  934. (parent.assignedSlot || parent.parentNode || parent.host)) {
  935. if (parent instanceof VueElement) {
  936. this._parent = parent;
  937. break;
  938. }
  939. }
  940. if (!this._instance) {
  941. if (this._resolved) {
  942. this._mount(this._def);
  943. } else {
  944. if (parent && parent._pendingResolve) {
  945. this._pendingResolve = parent._pendingResolve.then(() => {
  946. this._pendingResolve = void 0;
  947. if (this.isConnected) {
  948. return this._resolveDef();
  949. }
  950. });
  951. } else {
  952. this._resolveDef();
  953. }
  954. }
  955. }
  956. }
  957. _setParent(parent = this._parent) {
  958. if (parent) {
  959. this._instance.parent = parent._instance;
  960. this._inheritParentContext(parent);
  961. }
  962. }
  963. _inheritParentContext(parent = this._parent) {
  964. if (parent && this._app) {
  965. Object.setPrototypeOf(
  966. this._app._context.provides,
  967. parent._instance.provides
  968. );
  969. }
  970. }
  971. disconnectedCallback() {
  972. this._connected = false;
  973. nextTick(() => {
  974. if (!this._connected) {
  975. if (this._ob) {
  976. this._ob.disconnect();
  977. this._ob = null;
  978. }
  979. this._app && this._app.unmount();
  980. if (this._instance) this._instance.ce = void 0;
  981. this._app = this._instance = null;
  982. if (this._teleportTargets) {
  983. this._teleportTargets.clear();
  984. this._teleportTargets = void 0;
  985. }
  986. }
  987. });
  988. }
  989. _processMutations(mutations) {
  990. for (const m of mutations) {
  991. this._setAttr(m.attributeName);
  992. }
  993. }
  994. /**
  995. * resolve inner component definition (handle possible async component)
  996. */
  997. _resolveDef() {
  998. if (this._pendingResolve) {
  999. return this._pendingResolve;
  1000. }
  1001. for (let i = 0; i < this.attributes.length; i++) {
  1002. this._setAttr(this.attributes[i].name);
  1003. }
  1004. this._ob = new MutationObserver(this._processMutations.bind(this));
  1005. this._ob.observe(this, { attributes: true });
  1006. const resolve = (def, isAsync = false) => {
  1007. this._resolved = true;
  1008. this._pendingResolve = void 0;
  1009. const { props, styles } = def;
  1010. let numberProps;
  1011. if (props && !isArray(props)) {
  1012. for (const key in props) {
  1013. const opt = props[key];
  1014. if (opt === Number || opt && opt.type === Number) {
  1015. if (key in this._props) {
  1016. this._props[key] = toNumber(this._props[key]);
  1017. }
  1018. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize$1(key)] = true;
  1019. }
  1020. }
  1021. }
  1022. this._numberProps = numberProps;
  1023. this._resolveProps(def);
  1024. if (this.shadowRoot) {
  1025. this._applyStyles(styles);
  1026. } else if (!!(process.env.NODE_ENV !== "production") && styles) {
  1027. warn(
  1028. "Custom element style injection is not supported when using shadowRoot: false"
  1029. );
  1030. }
  1031. this._mount(def);
  1032. };
  1033. const asyncDef = this._def.__asyncLoader;
  1034. if (asyncDef) {
  1035. this._pendingResolve = asyncDef().then((def) => {
  1036. def.configureApp = this._def.configureApp;
  1037. resolve(this._def = def, true);
  1038. });
  1039. return this._pendingResolve;
  1040. } else {
  1041. resolve(this._def);
  1042. }
  1043. }
  1044. _mount(def) {
  1045. if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) && !def.name) {
  1046. def.name = "VueElement";
  1047. }
  1048. this._app = this._createApp(def);
  1049. this._inheritParentContext();
  1050. if (def.configureApp) {
  1051. def.configureApp(this._app);
  1052. }
  1053. this._app._ceVNode = this._createVNode();
  1054. this._app.mount(this._root);
  1055. const exposed = this._instance && this._instance.exposed;
  1056. if (!exposed) return;
  1057. for (const key in exposed) {
  1058. if (!hasOwn(this, key)) {
  1059. Object.defineProperty(this, key, {
  1060. // unwrap ref to be consistent with public instance behavior
  1061. get: () => unref(exposed[key])
  1062. });
  1063. } else if (!!(process.env.NODE_ENV !== "production")) {
  1064. warn(`Exposed property "${key}" already exists on custom element.`);
  1065. }
  1066. }
  1067. }
  1068. _resolveProps(def) {
  1069. const { props } = def;
  1070. const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
  1071. for (const key of Object.keys(this)) {
  1072. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  1073. this._setProp(key, this[key]);
  1074. }
  1075. }
  1076. for (const key of declaredPropKeys.map(camelize$1)) {
  1077. if (!!(process.env.NODE_ENV !== "production") && key in Object.getPrototypeOf(this)) {
  1078. warn(
  1079. `Custom element prop "${key}" conflicts with an existing property on the element and will overwrite it.`
  1080. );
  1081. }
  1082. Object.defineProperty(this, key, {
  1083. get() {
  1084. return this._getProp(key);
  1085. },
  1086. set(val) {
  1087. this._setProp(key, val, true, !this._patching);
  1088. }
  1089. });
  1090. }
  1091. }
  1092. _setAttr(key) {
  1093. if (key.startsWith("data-v-")) return;
  1094. const has = this.hasAttribute(key);
  1095. let value = has ? this.getAttribute(key) : REMOVAL;
  1096. const camelKey = camelize$1(key);
  1097. if (has && this._numberProps && this._numberProps[camelKey]) {
  1098. value = toNumber(value);
  1099. }
  1100. this._setProp(camelKey, value, false, true);
  1101. }
  1102. /**
  1103. * @internal
  1104. */
  1105. _getProp(key) {
  1106. return this._props[key];
  1107. }
  1108. /**
  1109. * @internal
  1110. */
  1111. _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
  1112. if (val !== this._props[key]) {
  1113. this._dirty = true;
  1114. if (val === REMOVAL) {
  1115. delete this._props[key];
  1116. } else {
  1117. this._props[key] = val;
  1118. if (key === "key" && this._app) {
  1119. this._app._ceVNode.key = val;
  1120. }
  1121. }
  1122. if (shouldUpdate && this._instance) {
  1123. this._update();
  1124. }
  1125. if (shouldReflect) {
  1126. const ob = this._ob;
  1127. if (ob) {
  1128. this._processMutations(ob.takeRecords());
  1129. ob.disconnect();
  1130. }
  1131. if (val === true) {
  1132. this.setAttribute(hyphenate(key), "");
  1133. } else if (typeof val === "string" || typeof val === "number") {
  1134. this.setAttribute(hyphenate(key), val + "");
  1135. } else if (!val) {
  1136. this.removeAttribute(hyphenate(key));
  1137. }
  1138. ob && ob.observe(this, { attributes: true });
  1139. }
  1140. }
  1141. }
  1142. _update() {
  1143. const vnode = this._createVNode();
  1144. if (this._app) vnode.appContext = this._app._context;
  1145. render(vnode, this._root);
  1146. }
  1147. _createVNode() {
  1148. const baseProps = {};
  1149. if (!this.shadowRoot) {
  1150. baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
  1151. }
  1152. const vnode = createVNode(this._def, extend(baseProps, this._props));
  1153. if (!this._instance) {
  1154. vnode.ce = (instance) => {
  1155. this._instance = instance;
  1156. instance.ce = this;
  1157. instance.isCE = true;
  1158. if (!!(process.env.NODE_ENV !== "production")) {
  1159. instance.ceReload = (newStyles) => {
  1160. if (this._styles) {
  1161. this._styles.forEach((s) => this._root.removeChild(s));
  1162. this._styles.length = 0;
  1163. }
  1164. this._styleAnchors.delete(this._def);
  1165. this._applyStyles(newStyles);
  1166. this._instance = null;
  1167. this._update();
  1168. };
  1169. }
  1170. const dispatch = (event, args) => {
  1171. this.dispatchEvent(
  1172. new CustomEvent(
  1173. event,
  1174. isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
  1175. )
  1176. );
  1177. };
  1178. instance.emit = (event, ...args) => {
  1179. dispatch(event, args);
  1180. if (hyphenate(event) !== event) {
  1181. dispatch(hyphenate(event), args);
  1182. }
  1183. };
  1184. this._setParent();
  1185. };
  1186. }
  1187. return vnode;
  1188. }
  1189. _applyStyles(styles, owner, parentComp) {
  1190. if (!styles) return;
  1191. if (owner) {
  1192. if (owner === this._def || this._styleChildren.has(owner)) {
  1193. return;
  1194. }
  1195. this._styleChildren.add(owner);
  1196. }
  1197. const nonce = this._nonce;
  1198. const root = this.shadowRoot;
  1199. const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root);
  1200. let last = null;
  1201. for (let i = styles.length - 1; i >= 0; i--) {
  1202. const s = document.createElement("style");
  1203. if (nonce) s.setAttribute("nonce", nonce);
  1204. s.textContent = styles[i];
  1205. root.insertBefore(s, last || insertionAnchor);
  1206. last = s;
  1207. if (i === 0) {
  1208. if (!parentComp) this._styleAnchors.set(this._def, s);
  1209. if (owner) this._styleAnchors.set(owner, s);
  1210. }
  1211. if (!!(process.env.NODE_ENV !== "production")) {
  1212. if (owner) {
  1213. if (owner.__hmrId) {
  1214. if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
  1215. let entry = this._childStyles.get(owner.__hmrId);
  1216. if (!entry) {
  1217. this._childStyles.set(owner.__hmrId, entry = []);
  1218. }
  1219. entry.push(s);
  1220. }
  1221. } else {
  1222. (this._styles || (this._styles = [])).push(s);
  1223. }
  1224. }
  1225. }
  1226. }
  1227. _getStyleAnchor(comp) {
  1228. if (!comp) {
  1229. return null;
  1230. }
  1231. const anchor = this._styleAnchors.get(comp);
  1232. if (anchor && anchor.parentNode === this.shadowRoot) {
  1233. return anchor;
  1234. }
  1235. if (anchor) {
  1236. this._styleAnchors.delete(comp);
  1237. }
  1238. return null;
  1239. }
  1240. _getRootStyleInsertionAnchor(root) {
  1241. for (let i = 0; i < root.childNodes.length; i++) {
  1242. const node = root.childNodes[i];
  1243. if (!(node instanceof HTMLStyleElement)) {
  1244. return node;
  1245. }
  1246. }
  1247. return null;
  1248. }
  1249. /**
  1250. * Only called when shadowRoot is false
  1251. */
  1252. _parseSlots() {
  1253. const slots = this._slots = {};
  1254. let n;
  1255. while (n = this.firstChild) {
  1256. const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
  1257. (slots[slotName] || (slots[slotName] = [])).push(n);
  1258. this.removeChild(n);
  1259. }
  1260. }
  1261. /**
  1262. * Only called when shadowRoot is false
  1263. */
  1264. _renderSlots() {
  1265. const outlets = this._getSlots();
  1266. const scopeId = this._instance.type.__scopeId;
  1267. for (let i = 0; i < outlets.length; i++) {
  1268. const o = outlets[i];
  1269. const slotName = o.getAttribute("name") || "default";
  1270. const content = this._slots[slotName];
  1271. const parent = o.parentNode;
  1272. if (content) {
  1273. for (const n of content) {
  1274. if (scopeId && n.nodeType === 1) {
  1275. const id = scopeId + "-s";
  1276. const walker = document.createTreeWalker(n, 1);
  1277. n.setAttribute(id, "");
  1278. let child;
  1279. while (child = walker.nextNode()) {
  1280. child.setAttribute(id, "");
  1281. }
  1282. }
  1283. parent.insertBefore(n, o);
  1284. }
  1285. } else {
  1286. while (o.firstChild) parent.insertBefore(o.firstChild, o);
  1287. }
  1288. parent.removeChild(o);
  1289. }
  1290. }
  1291. /**
  1292. * @internal
  1293. */
  1294. _getSlots() {
  1295. const roots = [this];
  1296. if (this._teleportTargets) {
  1297. roots.push(...this._teleportTargets);
  1298. }
  1299. const slots = /* @__PURE__ */ new Set();
  1300. for (const root of roots) {
  1301. const found = root.querySelectorAll("slot");
  1302. for (let i = 0; i < found.length; i++) {
  1303. slots.add(found[i]);
  1304. }
  1305. }
  1306. return Array.from(slots);
  1307. }
  1308. /**
  1309. * @internal
  1310. */
  1311. _injectChildStyle(comp, parentComp) {
  1312. this._applyStyles(comp.styles, comp, parentComp);
  1313. }
  1314. /**
  1315. * @internal
  1316. */
  1317. _beginPatch() {
  1318. this._patching = true;
  1319. this._dirty = false;
  1320. }
  1321. /**
  1322. * @internal
  1323. */
  1324. _endPatch() {
  1325. this._patching = false;
  1326. if (this._dirty && this._instance) {
  1327. this._update();
  1328. }
  1329. }
  1330. /**
  1331. * @internal
  1332. */
  1333. _hasShadowRoot() {
  1334. return this._def.shadowRoot !== false;
  1335. }
  1336. /**
  1337. * @internal
  1338. */
  1339. _removeChildStyle(comp) {
  1340. if (!!(process.env.NODE_ENV !== "production")) {
  1341. this._styleChildren.delete(comp);
  1342. this._styleAnchors.delete(comp);
  1343. if (this._childStyles && comp.__hmrId) {
  1344. const oldStyles = this._childStyles.get(comp.__hmrId);
  1345. if (oldStyles) {
  1346. oldStyles.forEach((s) => this._root.removeChild(s));
  1347. oldStyles.length = 0;
  1348. }
  1349. }
  1350. }
  1351. }
  1352. }
  1353. function useHost(caller) {
  1354. const instance = getCurrentInstance();
  1355. const el = instance && instance.ce;
  1356. if (el) {
  1357. return el;
  1358. } else if (!!(process.env.NODE_ENV !== "production")) {
  1359. if (!instance) {
  1360. warn(
  1361. `${caller || "useHost"} called without an active component instance.`
  1362. );
  1363. } else {
  1364. warn(
  1365. `${caller || "useHost"} can only be used in components defined via defineCustomElement.`
  1366. );
  1367. }
  1368. }
  1369. return null;
  1370. }
  1371. function useShadowRoot() {
  1372. const el = !!(process.env.NODE_ENV !== "production") ? useHost("useShadowRoot") : useHost();
  1373. return el && el.shadowRoot;
  1374. }
  1375. function useCssModule(name = "$style") {
  1376. {
  1377. const instance = getCurrentInstance();
  1378. if (!instance) {
  1379. !!(process.env.NODE_ENV !== "production") && warn(`useCssModule must be called inside setup()`);
  1380. return EMPTY_OBJ;
  1381. }
  1382. const modules = instance.type.__cssModules;
  1383. if (!modules) {
  1384. !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS modules injected.`);
  1385. return EMPTY_OBJ;
  1386. }
  1387. const mod = modules[name];
  1388. if (!mod) {
  1389. !!(process.env.NODE_ENV !== "production") && warn(`Current instance does not have CSS module named "${name}".`);
  1390. return EMPTY_OBJ;
  1391. }
  1392. return mod;
  1393. }
  1394. }
  1395. const positionMap = /* @__PURE__ */ new WeakMap();
  1396. const newPositionMap = /* @__PURE__ */ new WeakMap();
  1397. const moveCbKey = /* @__PURE__ */ Symbol("_moveCb");
  1398. const enterCbKey = /* @__PURE__ */ Symbol("_enterCb");
  1399. const decorate = (t) => {
  1400. delete t.props.mode;
  1401. return t;
  1402. };
  1403. const TransitionGroupImpl = /* @__PURE__ */ decorate({
  1404. name: "TransitionGroup",
  1405. props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
  1406. tag: String,
  1407. moveClass: String
  1408. }),
  1409. setup(props, { slots }) {
  1410. const instance = getCurrentInstance();
  1411. const state = useTransitionState();
  1412. let prevChildren;
  1413. let children;
  1414. onUpdated(() => {
  1415. if (!prevChildren.length) {
  1416. return;
  1417. }
  1418. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  1419. if (!hasCSSTransform(
  1420. prevChildren[0].el,
  1421. instance.vnode.el,
  1422. moveClass
  1423. )) {
  1424. prevChildren = [];
  1425. return;
  1426. }
  1427. prevChildren.forEach(callPendingCbs);
  1428. prevChildren.forEach(recordPosition);
  1429. const movedChildren = prevChildren.filter(applyTranslation);
  1430. forceReflow(instance.vnode.el);
  1431. movedChildren.forEach((c) => {
  1432. const el = c.el;
  1433. const style = el.style;
  1434. addTransitionClass(el, moveClass);
  1435. style.transform = style.webkitTransform = style.transitionDuration = "";
  1436. const cb = el[moveCbKey] = (e) => {
  1437. if (e && e.target !== el) {
  1438. return;
  1439. }
  1440. if (!e || e.propertyName.endsWith("transform")) {
  1441. el.removeEventListener("transitionend", cb);
  1442. el[moveCbKey] = null;
  1443. removeTransitionClass(el, moveClass);
  1444. }
  1445. };
  1446. el.addEventListener("transitionend", cb);
  1447. });
  1448. prevChildren = [];
  1449. });
  1450. return () => {
  1451. const rawProps = toRaw(props);
  1452. const cssTransitionProps = resolveTransitionProps(rawProps);
  1453. let tag = rawProps.tag || Fragment;
  1454. prevChildren = [];
  1455. if (children) {
  1456. for (let i = 0; i < children.length; i++) {
  1457. const child = children[i];
  1458. if (child.el && child.el instanceof Element && // Hidden v-show nodes have no previous layout box to animate from.
  1459. !child.el[vShowHidden]) {
  1460. prevChildren.push(child);
  1461. setTransitionHooks(
  1462. child,
  1463. resolveTransitionHooks(
  1464. child,
  1465. cssTransitionProps,
  1466. state,
  1467. instance
  1468. )
  1469. );
  1470. positionMap.set(child, getPosition(child.el));
  1471. }
  1472. }
  1473. }
  1474. children = slots.default ? getTransitionRawChildren(slots.default()) : [];
  1475. for (let i = 0; i < children.length; i++) {
  1476. const child = children[i];
  1477. if (child.key != null) {
  1478. setTransitionHooks(
  1479. child,
  1480. resolveTransitionHooks(child, cssTransitionProps, state, instance)
  1481. );
  1482. } else if (!!(process.env.NODE_ENV !== "production") && child.type !== Text) {
  1483. warn(`<TransitionGroup> children must be keyed.`);
  1484. }
  1485. }
  1486. return createVNode(tag, null, children);
  1487. };
  1488. }
  1489. });
  1490. const TransitionGroup = TransitionGroupImpl;
  1491. function callPendingCbs(c) {
  1492. const el = c.el;
  1493. if (el[moveCbKey]) {
  1494. el[moveCbKey]();
  1495. }
  1496. if (el[enterCbKey]) {
  1497. el[enterCbKey]();
  1498. }
  1499. }
  1500. function recordPosition(c) {
  1501. newPositionMap.set(c, getPosition(c.el));
  1502. }
  1503. function applyTranslation(c) {
  1504. const oldPos = positionMap.get(c);
  1505. const newPos = newPositionMap.get(c);
  1506. const dx = oldPos.left - newPos.left;
  1507. const dy = oldPos.top - newPos.top;
  1508. if (dx || dy) {
  1509. const el = c.el;
  1510. const s = el.style;
  1511. const rect = el.getBoundingClientRect();
  1512. let scaleX = 1;
  1513. let scaleY = 1;
  1514. if (el.offsetWidth) scaleX = rect.width / el.offsetWidth;
  1515. if (el.offsetHeight) scaleY = rect.height / el.offsetHeight;
  1516. if (!Number.isFinite(scaleX) || scaleX === 0) scaleX = 1;
  1517. if (!Number.isFinite(scaleY) || scaleY === 0) scaleY = 1;
  1518. if (Math.abs(scaleX - 1) < 0.01) scaleX = 1;
  1519. if (Math.abs(scaleY - 1) < 0.01) scaleY = 1;
  1520. s.transform = s.webkitTransform = `translate(${dx / scaleX}px,${dy / scaleY}px)`;
  1521. s.transitionDuration = "0s";
  1522. return c;
  1523. }
  1524. }
  1525. function getPosition(el) {
  1526. const rect = el.getBoundingClientRect();
  1527. return {
  1528. left: rect.left,
  1529. top: rect.top
  1530. };
  1531. }
  1532. function hasCSSTransform(el, root, moveClass) {
  1533. const clone = el.cloneNode();
  1534. const _vtc = el[vtcKey];
  1535. if (_vtc) {
  1536. _vtc.forEach((cls) => {
  1537. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  1538. });
  1539. }
  1540. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  1541. clone.style.display = "none";
  1542. const container = root.nodeType === 1 ? root : root.parentNode;
  1543. container.appendChild(clone);
  1544. const { hasTransform } = getTransitionInfo(clone);
  1545. container.removeChild(clone);
  1546. return hasTransform;
  1547. }
  1548. const getModelAssigner = (vnode) => {
  1549. const fn = vnode.props["onUpdate:modelValue"] || false;
  1550. return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn;
  1551. };
  1552. function onCompositionStart(e) {
  1553. e.target.composing = true;
  1554. }
  1555. function onCompositionEnd(e) {
  1556. const target = e.target;
  1557. if (target.composing) {
  1558. target.composing = false;
  1559. target.dispatchEvent(new Event("input"));
  1560. }
  1561. }
  1562. const assignKey = /* @__PURE__ */ Symbol("_assign");
  1563. const initialValueKey = /* @__PURE__ */ Symbol("_initialValue");
  1564. function castValue(value, trim, number) {
  1565. if (trim) value = value.trim();
  1566. if (number) value = looseToNumber(value);
  1567. return value;
  1568. }
  1569. const vModelText = {
  1570. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  1571. if (el.parentNode) {
  1572. if (el.type === "text") {
  1573. el[initialValueKey] = el.defaultValue.replace(/[\r\n]/g, "");
  1574. } else if (el.type === "textarea") {
  1575. el[initialValueKey] = el.defaultValue.replace(/\r\n?/g, "\n");
  1576. }
  1577. }
  1578. el[assignKey] = getModelAssigner(vnode);
  1579. const castToNumber = number || vnode.props && vnode.props.type === "number";
  1580. addEventListener(el, lazy ? "change" : "input", (e) => {
  1581. if (e.target.composing) return;
  1582. el[assignKey](castValue(el.value, trim, castToNumber));
  1583. });
  1584. if (trim || castToNumber) {
  1585. addEventListener(el, "change", () => {
  1586. el.value = castValue(el.value, trim, castToNumber);
  1587. });
  1588. }
  1589. if (!lazy) {
  1590. addEventListener(el, "compositionstart", onCompositionStart);
  1591. addEventListener(el, "compositionend", onCompositionEnd);
  1592. addEventListener(el, "change", onCompositionEnd);
  1593. }
  1594. },
  1595. // set value on mounted so it's after min/max for type="range"
  1596. mounted(el, { value, modifiers: { trim, number } }) {
  1597. const newValue = value == null ? "" : value;
  1598. const initialValue = el[initialValueKey];
  1599. delete el[initialValueKey];
  1600. if (initialValue !== void 0 && (el.type === "text" || el.type === "textarea") && el.value !== initialValue) {
  1601. el[assignKey](castValue(el.value, trim, number));
  1602. } else {
  1603. el.value = newValue;
  1604. }
  1605. },
  1606. beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
  1607. el[assignKey] = getModelAssigner(vnode);
  1608. if (el.composing) return;
  1609. const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
  1610. const newValue = value == null ? "" : value;
  1611. if (elValue === newValue) {
  1612. return;
  1613. }
  1614. const rootNode = el.getRootNode();
  1615. if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") {
  1616. if (lazy && value === oldValue) {
  1617. return;
  1618. }
  1619. if (trim && el.value.trim() === newValue) {
  1620. return;
  1621. }
  1622. }
  1623. el.value = newValue;
  1624. }
  1625. };
  1626. const vModelCheckbox = {
  1627. // #4096 array checkboxes need to be deep traversed
  1628. deep: true,
  1629. created(el, _, vnode) {
  1630. el[assignKey] = getModelAssigner(vnode);
  1631. addEventListener(el, "change", () => {
  1632. const modelValue = el._modelValue;
  1633. const elementValue = getValue(el);
  1634. const checked = el.checked;
  1635. const assign = el[assignKey];
  1636. if (isArray(modelValue)) {
  1637. const index = looseIndexOf(modelValue, elementValue);
  1638. const found = index !== -1;
  1639. if (checked && !found) {
  1640. assign(modelValue.concat(elementValue));
  1641. } else if (!checked && found) {
  1642. const filtered = [...modelValue];
  1643. filtered.splice(index, 1);
  1644. assign(filtered);
  1645. }
  1646. } else if (isSet(modelValue)) {
  1647. const cloned = new Set(modelValue);
  1648. if (checked) {
  1649. cloned.add(elementValue);
  1650. } else {
  1651. cloned.delete(elementValue);
  1652. }
  1653. assign(cloned);
  1654. } else {
  1655. assign(getCheckboxValue(el, checked));
  1656. }
  1657. });
  1658. },
  1659. // set initial checked on mount to wait for true-value/false-value
  1660. mounted: setChecked,
  1661. beforeUpdate(el, binding, vnode) {
  1662. el[assignKey] = getModelAssigner(vnode);
  1663. setChecked(el, binding, vnode);
  1664. }
  1665. };
  1666. function setChecked(el, { value, oldValue }, vnode) {
  1667. el._modelValue = value;
  1668. let checked;
  1669. if (isArray(value)) {
  1670. checked = looseIndexOf(value, vnode.props.value) > -1;
  1671. } else if (isSet(value)) {
  1672. checked = value.has(vnode.props.value);
  1673. } else {
  1674. if (value === oldValue) return;
  1675. checked = looseEqual(value, getCheckboxValue(el, true));
  1676. }
  1677. if (el.checked !== checked) {
  1678. el.checked = checked;
  1679. }
  1680. }
  1681. const vModelRadio = {
  1682. created(el, { value }, vnode) {
  1683. el.checked = looseEqual(value, vnode.props.value);
  1684. el[assignKey] = getModelAssigner(vnode);
  1685. addEventListener(el, "change", () => {
  1686. el[assignKey](getValue(el));
  1687. });
  1688. },
  1689. beforeUpdate(el, { value, oldValue }, vnode) {
  1690. el[assignKey] = getModelAssigner(vnode);
  1691. if (value !== oldValue) {
  1692. el.checked = looseEqual(value, vnode.props.value);
  1693. }
  1694. }
  1695. };
  1696. const vModelSelect = {
  1697. // <select multiple> value need to be deep traversed
  1698. deep: true,
  1699. created(el, { value, modifiers: { number } }, vnode) {
  1700. el._modelValue = value;
  1701. addEventListener(el, "change", () => {
  1702. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  1703. (o) => number ? looseToNumber(getValue(o)) : getValue(o)
  1704. );
  1705. el[assignKey](
  1706. el.multiple ? isSet(el._modelValue) ? new Set(selectedVal) : selectedVal : selectedVal[0]
  1707. );
  1708. el._assigning = true;
  1709. nextTick(() => {
  1710. el._assigning = false;
  1711. });
  1712. });
  1713. el[assignKey] = getModelAssigner(vnode);
  1714. },
  1715. // set value in mounted & updated because <select> relies on its children
  1716. // <option>s.
  1717. mounted(el, { value }) {
  1718. setSelected(el, value);
  1719. },
  1720. beforeUpdate(el, { value }, vnode) {
  1721. el._modelValue = value;
  1722. el[assignKey] = getModelAssigner(vnode);
  1723. },
  1724. updated(el, { value }) {
  1725. if (!el._assigning) {
  1726. setSelected(el, value);
  1727. }
  1728. }
  1729. };
  1730. function setSelected(el, value) {
  1731. const isMultiple = el.multiple;
  1732. const isArrayValue = isArray(value);
  1733. if (isMultiple && !isArrayValue && !isSet(value)) {
  1734. !!(process.env.NODE_ENV !== "production") && warn(
  1735. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  1736. );
  1737. return;
  1738. }
  1739. for (let i = 0, l = el.options.length; i < l; i++) {
  1740. const option = el.options[i];
  1741. const optionValue = getValue(option);
  1742. if (isMultiple) {
  1743. if (isArrayValue) {
  1744. const optionType = typeof optionValue;
  1745. if (optionType === "string" || optionType === "number") {
  1746. option.selected = value.some((v) => String(v) === String(optionValue));
  1747. } else {
  1748. option.selected = looseIndexOf(value, optionValue) > -1;
  1749. }
  1750. } else {
  1751. option.selected = value.has(optionValue);
  1752. }
  1753. } else if (looseEqual(getValue(option), value)) {
  1754. if (el.selectedIndex !== i) el.selectedIndex = i;
  1755. return;
  1756. }
  1757. }
  1758. if (!isMultiple && el.selectedIndex !== -1) {
  1759. el.selectedIndex = -1;
  1760. }
  1761. }
  1762. function getValue(el) {
  1763. return "_value" in el ? el._value : el.value;
  1764. }
  1765. function getCheckboxValue(el, checked) {
  1766. const key = checked ? "_trueValue" : "_falseValue";
  1767. return key in el ? el[key] : checked;
  1768. }
  1769. const vModelDynamic = {
  1770. created(el, binding, vnode) {
  1771. callModelHook(el, binding, vnode, null, "created");
  1772. },
  1773. mounted(el, binding, vnode) {
  1774. callModelHook(el, binding, vnode, null, "mounted");
  1775. },
  1776. beforeUpdate(el, binding, vnode, prevVNode) {
  1777. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  1778. },
  1779. updated(el, binding, vnode, prevVNode) {
  1780. callModelHook(el, binding, vnode, prevVNode, "updated");
  1781. }
  1782. };
  1783. function resolveDynamicModel(tagName, type) {
  1784. switch (tagName) {
  1785. case "SELECT":
  1786. return vModelSelect;
  1787. case "TEXTAREA":
  1788. return vModelText;
  1789. default:
  1790. switch (type) {
  1791. case "checkbox":
  1792. return vModelCheckbox;
  1793. case "radio":
  1794. return vModelRadio;
  1795. default:
  1796. return vModelText;
  1797. }
  1798. }
  1799. }
  1800. function callModelHook(el, binding, vnode, prevVNode, hook) {
  1801. const modelToUse = resolveDynamicModel(
  1802. el.tagName,
  1803. vnode.props && vnode.props.type
  1804. );
  1805. const fn = modelToUse[hook];
  1806. fn && fn(el, binding, vnode, prevVNode);
  1807. }
  1808. function initVModelForSSR() {
  1809. vModelText.getSSRProps = ({ value }) => ({ value });
  1810. vModelRadio.getSSRProps = ({ value }, vnode) => {
  1811. if (vnode.props && looseEqual(vnode.props.value, value)) {
  1812. return { checked: true };
  1813. }
  1814. };
  1815. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  1816. if (isArray(value)) {
  1817. if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
  1818. return { checked: true };
  1819. }
  1820. } else if (isSet(value)) {
  1821. if (vnode.props && value.has(vnode.props.value)) {
  1822. return { checked: true };
  1823. }
  1824. } else if (value) {
  1825. return { checked: true };
  1826. }
  1827. };
  1828. vModelDynamic.getSSRProps = (binding, vnode) => {
  1829. if (typeof vnode.type !== "string") {
  1830. return;
  1831. }
  1832. const modelToUse = resolveDynamicModel(
  1833. // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
  1834. vnode.type.toUpperCase(),
  1835. vnode.props && vnode.props.type
  1836. );
  1837. if (modelToUse.getSSRProps) {
  1838. return modelToUse.getSSRProps(binding, vnode);
  1839. }
  1840. };
  1841. }
  1842. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  1843. const modifierGuards = {
  1844. stop: (e) => e.stopPropagation(),
  1845. prevent: (e) => e.preventDefault(),
  1846. self: (e) => e.target !== e.currentTarget,
  1847. ctrl: (e) => !e.ctrlKey,
  1848. shift: (e) => !e.shiftKey,
  1849. alt: (e) => !e.altKey,
  1850. meta: (e) => !e.metaKey,
  1851. left: (e) => "button" in e && e.button !== 0,
  1852. middle: (e) => "button" in e && e.button !== 1,
  1853. right: (e) => "button" in e && e.button !== 2,
  1854. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  1855. };
  1856. const withModifiers = (fn, modifiers) => {
  1857. if (!fn) return fn;
  1858. const cache = fn._withMods || (fn._withMods = {});
  1859. const cacheKey = modifiers.join(".");
  1860. return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => {
  1861. for (let i = 0; i < modifiers.length; i++) {
  1862. const guard = modifierGuards[modifiers[i]];
  1863. if (guard && guard(event, modifiers)) return;
  1864. }
  1865. return fn(event, ...args);
  1866. }));
  1867. };
  1868. const keyNames = {
  1869. esc: "escape",
  1870. space: " ",
  1871. up: "arrow-up",
  1872. left: "arrow-left",
  1873. right: "arrow-right",
  1874. down: "arrow-down",
  1875. delete: "backspace"
  1876. };
  1877. const withKeys = (fn, modifiers) => {
  1878. const cache = fn._withKeys || (fn._withKeys = {});
  1879. const cacheKey = modifiers.join(".");
  1880. return cache[cacheKey] || (cache[cacheKey] = ((event) => {
  1881. if (!("key" in event)) {
  1882. return;
  1883. }
  1884. const eventKey = hyphenate(event.key);
  1885. if (modifiers.some(
  1886. (k) => k === eventKey || keyNames[k] === eventKey
  1887. )) {
  1888. return fn(event);
  1889. }
  1890. }));
  1891. };
  1892. const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
  1893. let renderer;
  1894. let enabledHydration = false;
  1895. function ensureRenderer() {
  1896. return renderer || (renderer = createRenderer(rendererOptions));
  1897. }
  1898. function ensureHydrationRenderer() {
  1899. renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
  1900. enabledHydration = true;
  1901. return renderer;
  1902. }
  1903. const render = ((...args) => {
  1904. ensureRenderer().render(...args);
  1905. });
  1906. const hydrate = ((...args) => {
  1907. ensureHydrationRenderer().hydrate(...args);
  1908. });
  1909. const createApp = ((...args) => {
  1910. const app = ensureRenderer().createApp(...args);
  1911. if (!!(process.env.NODE_ENV !== "production")) {
  1912. injectNativeTagCheck(app);
  1913. injectCompilerOptionsCheck(app);
  1914. }
  1915. const { mount } = app;
  1916. app.mount = (containerOrSelector) => {
  1917. const container = normalizeContainer(containerOrSelector);
  1918. if (!container) return;
  1919. const component = app._component;
  1920. if (!isFunction(component) && !component.render && !component.template) {
  1921. component.template = container.innerHTML;
  1922. }
  1923. if (container.nodeType === 1) {
  1924. container.textContent = "";
  1925. }
  1926. const proxy = mount(container, false, resolveRootNamespace(container));
  1927. if (container instanceof Element) {
  1928. container.removeAttribute("v-cloak");
  1929. container.setAttribute("data-v-app", "");
  1930. }
  1931. return proxy;
  1932. };
  1933. return app;
  1934. });
  1935. const createSSRApp = ((...args) => {
  1936. const app = ensureHydrationRenderer().createApp(...args);
  1937. if (!!(process.env.NODE_ENV !== "production")) {
  1938. injectNativeTagCheck(app);
  1939. injectCompilerOptionsCheck(app);
  1940. }
  1941. const { mount } = app;
  1942. app.mount = (containerOrSelector) => {
  1943. const container = normalizeContainer(containerOrSelector);
  1944. if (container) {
  1945. return mount(container, true, resolveRootNamespace(container));
  1946. }
  1947. };
  1948. return app;
  1949. });
  1950. function resolveRootNamespace(container) {
  1951. if (container instanceof SVGElement) {
  1952. return "svg";
  1953. }
  1954. if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
  1955. return "mathml";
  1956. }
  1957. }
  1958. function injectNativeTagCheck(app) {
  1959. Object.defineProperty(app.config, "isNativeTag", {
  1960. value: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
  1961. writable: false
  1962. });
  1963. }
  1964. function injectCompilerOptionsCheck(app) {
  1965. if (isRuntimeOnly()) {
  1966. const isCustomElement = app.config.isCustomElement;
  1967. Object.defineProperty(app.config, "isCustomElement", {
  1968. get() {
  1969. return isCustomElement;
  1970. },
  1971. set() {
  1972. warn(
  1973. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  1974. );
  1975. }
  1976. });
  1977. const compilerOptions = app.config.compilerOptions;
  1978. 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.
  1979. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  1980. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  1981. - 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`;
  1982. Object.defineProperty(app.config, "compilerOptions", {
  1983. get() {
  1984. warn(msg);
  1985. return compilerOptions;
  1986. },
  1987. set() {
  1988. warn(msg);
  1989. }
  1990. });
  1991. }
  1992. }
  1993. function normalizeContainer(container) {
  1994. if (isString(container)) {
  1995. const res = document.querySelector(container);
  1996. if (!!(process.env.NODE_ENV !== "production") && !res) {
  1997. warn(
  1998. `Failed to mount app: mount target selector "${container}" returned null.`
  1999. );
  2000. }
  2001. return res;
  2002. }
  2003. if (!!(process.env.NODE_ENV !== "production") && window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  2004. warn(
  2005. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  2006. );
  2007. }
  2008. return container;
  2009. }
  2010. let ssrDirectiveInitialized = false;
  2011. const initDirectivesForSSR = () => {
  2012. if (!ssrDirectiveInitialized) {
  2013. ssrDirectiveInitialized = true;
  2014. initVModelForSSR();
  2015. initVShowForSSR();
  2016. }
  2017. } ;
  2018. 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 };