runtime-dom.cjs.js 55 KB

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