runtime-dom.cjs.prod.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677
  1. /**
  2. * @vue/runtime-dom v3.5.19
  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. }
  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 = 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__ */ shared.extend(
  111. {},
  112. runtimeCore.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 }) => runtimeCore.h(runtimeCore.BaseTransition, resolveTransitionProps(props), slots)
  122. );
  123. const callHook = (hook, args = []) => {
  124. if (shared.isArray(hook)) {
  125. hook.forEach((h2) => h2(...args));
  126. } else if (hook) {
  127. hook(...args);
  128. }
  129. };
  130. const hasExplicitCallback = (hook) => {
  131. return hook ? shared.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 shared.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();
  216. addTransitionClass(el, leaveActiveClass);
  217. } else {
  218. addTransitionClass(el, leaveActiveClass);
  219. forceReflow();
  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 (shared.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 = shared.toNumber(val);
  259. return res;
  260. }
  261. function addTransitionClass(el, cls) {
  262. cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
  263. (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
  264. }
  265. function removeTransitionClass(el, cls) {
  266. cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
  267. const _vtc = el[vtcKey];
  268. if (_vtc) {
  269. _vtc.delete(cls);
  270. if (!_vtc.size) {
  271. el[vtcKey] = void 0;
  272. }
  273. }
  274. }
  275. function nextFrame(cb) {
  276. requestAnimationFrame(() => {
  277. requestAnimationFrame(cb);
  278. });
  279. }
  280. let endId = 0;
  281. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  282. const id = el._endId = ++endId;
  283. const resolveIfNotStale = () => {
  284. if (id === el._endId) {
  285. resolve();
  286. }
  287. };
  288. if (explicitTimeout != null) {
  289. return setTimeout(resolveIfNotStale, explicitTimeout);
  290. }
  291. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  292. if (!type) {
  293. return resolve();
  294. }
  295. const endEvent = type + "end";
  296. let ended = 0;
  297. const end = () => {
  298. el.removeEventListener(endEvent, onEnd);
  299. resolveIfNotStale();
  300. };
  301. const onEnd = (e) => {
  302. if (e.target === el && ++ended >= propCount) {
  303. end();
  304. }
  305. };
  306. setTimeout(() => {
  307. if (ended < propCount) {
  308. end();
  309. }
  310. }, timeout + 1);
  311. el.addEventListener(endEvent, onEnd);
  312. }
  313. function getTransitionInfo(el, expectedType) {
  314. const styles = window.getComputedStyle(el);
  315. const getStyleProperties = (key) => (styles[key] || "").split(", ");
  316. const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
  317. const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
  318. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  319. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  320. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  321. const animationTimeout = getTimeout(animationDelays, animationDurations);
  322. let type = null;
  323. let timeout = 0;
  324. let propCount = 0;
  325. if (expectedType === TRANSITION) {
  326. if (transitionTimeout > 0) {
  327. type = TRANSITION;
  328. timeout = transitionTimeout;
  329. propCount = transitionDurations.length;
  330. }
  331. } else if (expectedType === ANIMATION) {
  332. if (animationTimeout > 0) {
  333. type = ANIMATION;
  334. timeout = animationTimeout;
  335. propCount = animationDurations.length;
  336. }
  337. } else {
  338. timeout = Math.max(transitionTimeout, animationTimeout);
  339. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
  340. propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
  341. }
  342. const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
  343. getStyleProperties(`${TRANSITION}Property`).toString()
  344. );
  345. return {
  346. type,
  347. timeout,
  348. propCount,
  349. hasTransform
  350. };
  351. }
  352. function getTimeout(delays, durations) {
  353. while (delays.length < durations.length) {
  354. delays = delays.concat(delays);
  355. }
  356. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  357. }
  358. function toMs(s) {
  359. if (s === "auto") return 0;
  360. return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
  361. }
  362. function forceReflow() {
  363. return document.body.offsetHeight;
  364. }
  365. function patchClass(el, value, isSVG) {
  366. const transitionClasses = el[vtcKey];
  367. if (transitionClasses) {
  368. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
  369. }
  370. if (value == null) {
  371. el.removeAttribute("class");
  372. } else if (isSVG) {
  373. el.setAttribute("class", value);
  374. } else {
  375. el.className = value;
  376. }
  377. }
  378. const vShowOriginalDisplay = Symbol("_vod");
  379. const vShowHidden = Symbol("_vsh");
  380. const vShow = {
  381. beforeMount(el, { value }, { transition }) {
  382. el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
  383. if (transition && value) {
  384. transition.beforeEnter(el);
  385. } else {
  386. setDisplay(el, value);
  387. }
  388. },
  389. mounted(el, { value }, { transition }) {
  390. if (transition && value) {
  391. transition.enter(el);
  392. }
  393. },
  394. updated(el, { value, oldValue }, { transition }) {
  395. if (!value === !oldValue) return;
  396. if (transition) {
  397. if (value) {
  398. transition.beforeEnter(el);
  399. setDisplay(el, true);
  400. transition.enter(el);
  401. } else {
  402. transition.leave(el, () => {
  403. setDisplay(el, false);
  404. });
  405. }
  406. } else {
  407. setDisplay(el, value);
  408. }
  409. },
  410. beforeUnmount(el, { value }) {
  411. setDisplay(el, value);
  412. }
  413. };
  414. function setDisplay(el, value) {
  415. el.style.display = value ? el[vShowOriginalDisplay] : "none";
  416. el[vShowHidden] = !value;
  417. }
  418. function initVShowForSSR() {
  419. vShow.getSSRProps = ({ value }) => {
  420. if (!value) {
  421. return { style: { display: "none" } };
  422. }
  423. };
  424. }
  425. const CSS_VAR_TEXT = Symbol("");
  426. function useCssVars(getter) {
  427. return;
  428. }
  429. const displayRE = /(^|;)\s*display\s*:/;
  430. function patchStyle(el, prev, next) {
  431. const style = el.style;
  432. const isCssString = shared.isString(next);
  433. let hasControlledDisplay = false;
  434. if (next && !isCssString) {
  435. if (prev) {
  436. if (!shared.isString(prev)) {
  437. for (const key in prev) {
  438. if (next[key] == null) {
  439. setStyle(style, key, "");
  440. }
  441. }
  442. } else {
  443. for (const prevStyle of prev.split(";")) {
  444. const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
  445. if (next[key] == null) {
  446. setStyle(style, key, "");
  447. }
  448. }
  449. }
  450. }
  451. for (const key in next) {
  452. if (key === "display") {
  453. hasControlledDisplay = true;
  454. }
  455. setStyle(style, key, next[key]);
  456. }
  457. } else {
  458. if (isCssString) {
  459. if (prev !== next) {
  460. const cssVarText = style[CSS_VAR_TEXT];
  461. if (cssVarText) {
  462. next += ";" + cssVarText;
  463. }
  464. style.cssText = next;
  465. hasControlledDisplay = displayRE.test(next);
  466. }
  467. } else if (prev) {
  468. el.removeAttribute("style");
  469. }
  470. }
  471. if (vShowOriginalDisplay in el) {
  472. el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
  473. if (el[vShowHidden]) {
  474. style.display = "none";
  475. }
  476. }
  477. }
  478. const importantRE = /\s*!important$/;
  479. function setStyle(style, name, val) {
  480. if (shared.isArray(val)) {
  481. val.forEach((v) => setStyle(style, name, v));
  482. } else {
  483. if (val == null) val = "";
  484. if (name.startsWith("--")) {
  485. style.setProperty(name, val);
  486. } else {
  487. const prefixed = autoPrefix(style, name);
  488. if (importantRE.test(val)) {
  489. style.setProperty(
  490. shared.hyphenate(prefixed),
  491. val.replace(importantRE, ""),
  492. "important"
  493. );
  494. } else {
  495. style[prefixed] = val;
  496. }
  497. }
  498. }
  499. }
  500. const prefixes = ["Webkit", "Moz", "ms"];
  501. const prefixCache = {};
  502. function autoPrefix(style, rawName) {
  503. const cached = prefixCache[rawName];
  504. if (cached) {
  505. return cached;
  506. }
  507. let name = runtimeCore.camelize(rawName);
  508. if (name !== "filter" && name in style) {
  509. return prefixCache[rawName] = name;
  510. }
  511. name = shared.capitalize(name);
  512. for (let i = 0; i < prefixes.length; i++) {
  513. const prefixed = prefixes[i] + name;
  514. if (prefixed in style) {
  515. return prefixCache[rawName] = prefixed;
  516. }
  517. }
  518. return rawName;
  519. }
  520. const xlinkNS = "http://www.w3.org/1999/xlink";
  521. function patchAttr(el, key, value, isSVG, instance, isBoolean = shared.isSpecialBooleanAttr(key)) {
  522. if (isSVG && key.startsWith("xlink:")) {
  523. if (value == null) {
  524. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  525. } else {
  526. el.setAttributeNS(xlinkNS, key, value);
  527. }
  528. } else {
  529. if (value == null || isBoolean && !shared.includeBooleanAttr(value)) {
  530. el.removeAttribute(key);
  531. } else {
  532. el.setAttribute(
  533. key,
  534. isBoolean ? "" : shared.isSymbol(value) ? String(value) : value
  535. );
  536. }
  537. }
  538. }
  539. function patchDOMProp(el, key, value, parentComponent, attrName) {
  540. if (key === "innerHTML" || key === "textContent") {
  541. if (value != null) {
  542. el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
  543. }
  544. return;
  545. }
  546. const tag = el.tagName;
  547. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  548. !tag.includes("-")) {
  549. const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
  550. const newValue = value == null ? (
  551. // #11647: value should be set as empty string for null and undefined,
  552. // but <input type="checkbox"> should be set as 'on'.
  553. el.type === "checkbox" ? "on" : ""
  554. ) : String(value);
  555. if (oldValue !== newValue || !("_value" in el)) {
  556. el.value = newValue;
  557. }
  558. if (value == null) {
  559. el.removeAttribute(key);
  560. }
  561. el._value = value;
  562. return;
  563. }
  564. let needRemove = false;
  565. if (value === "" || value == null) {
  566. const type = typeof el[key];
  567. if (type === "boolean") {
  568. value = shared.includeBooleanAttr(value);
  569. } else if (value == null && type === "string") {
  570. value = "";
  571. needRemove = true;
  572. } else if (type === "number") {
  573. value = 0;
  574. needRemove = true;
  575. }
  576. }
  577. try {
  578. el[key] = value;
  579. } catch (e) {
  580. }
  581. needRemove && el.removeAttribute(attrName || key);
  582. }
  583. function addEventListener(el, event, handler, options) {
  584. el.addEventListener(event, handler, options);
  585. }
  586. function removeEventListener(el, event, handler, options) {
  587. el.removeEventListener(event, handler, options);
  588. }
  589. const veiKey = Symbol("_vei");
  590. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  591. const invokers = el[veiKey] || (el[veiKey] = {});
  592. const existingInvoker = invokers[rawName];
  593. if (nextValue && existingInvoker) {
  594. existingInvoker.value = nextValue;
  595. } else {
  596. const [name, options] = parseName(rawName);
  597. if (nextValue) {
  598. const invoker = invokers[rawName] = createInvoker(
  599. nextValue,
  600. instance
  601. );
  602. addEventListener(el, name, invoker, options);
  603. } else if (existingInvoker) {
  604. removeEventListener(el, name, existingInvoker, options);
  605. invokers[rawName] = void 0;
  606. }
  607. }
  608. }
  609. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  610. function parseName(name) {
  611. let options;
  612. if (optionsModifierRE.test(name)) {
  613. options = {};
  614. let m;
  615. while (m = name.match(optionsModifierRE)) {
  616. name = name.slice(0, name.length - m[0].length);
  617. options[m[0].toLowerCase()] = true;
  618. }
  619. }
  620. const event = name[2] === ":" ? name.slice(3) : shared.hyphenate(name.slice(2));
  621. return [event, options];
  622. }
  623. let cachedNow = 0;
  624. const p = /* @__PURE__ */ Promise.resolve();
  625. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  626. function createInvoker(initialValue, instance) {
  627. const invoker = (e) => {
  628. if (!e._vts) {
  629. e._vts = Date.now();
  630. } else if (e._vts <= invoker.attached) {
  631. return;
  632. }
  633. runtimeCore.callWithAsyncErrorHandling(
  634. patchStopImmediatePropagation(e, invoker.value),
  635. instance,
  636. 5,
  637. [e]
  638. );
  639. };
  640. invoker.value = initialValue;
  641. invoker.attached = getNow();
  642. return invoker;
  643. }
  644. function patchStopImmediatePropagation(e, value) {
  645. if (shared.isArray(value)) {
  646. const originalStop = e.stopImmediatePropagation;
  647. e.stopImmediatePropagation = () => {
  648. originalStop.call(e);
  649. e._stopped = true;
  650. };
  651. return value.map(
  652. (fn) => (e2) => !e2._stopped && fn && fn(e2)
  653. );
  654. } else {
  655. return value;
  656. }
  657. }
  658. const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
  659. key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
  660. const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
  661. const isSVG = namespace === "svg";
  662. if (key === "class") {
  663. patchClass(el, nextValue, isSVG);
  664. } else if (key === "style") {
  665. patchStyle(el, prevValue, nextValue);
  666. } else if (shared.isOn(key)) {
  667. if (!shared.isModelListener(key)) {
  668. patchEvent(el, key, prevValue, nextValue, parentComponent);
  669. }
  670. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  671. patchDOMProp(el, key, nextValue);
  672. if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
  673. patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
  674. }
  675. } else if (
  676. // #11081 force set props for possible async custom element
  677. el._isVueCE && (/[A-Z]/.test(key) || !shared.isString(nextValue))
  678. ) {
  679. patchDOMProp(el, shared.camelize(key), nextValue, parentComponent, key);
  680. } else {
  681. if (key === "true-value") {
  682. el._trueValue = nextValue;
  683. } else if (key === "false-value") {
  684. el._falseValue = nextValue;
  685. }
  686. patchAttr(el, key, nextValue, isSVG);
  687. }
  688. };
  689. function shouldSetAsProp(el, key, value, isSVG) {
  690. if (isSVG) {
  691. if (key === "innerHTML" || key === "textContent") {
  692. return true;
  693. }
  694. if (key in el && isNativeOn(key) && shared.isFunction(value)) {
  695. return true;
  696. }
  697. return false;
  698. }
  699. if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") {
  700. return false;
  701. }
  702. if (key === "form") {
  703. return false;
  704. }
  705. if (key === "list" && el.tagName === "INPUT") {
  706. return false;
  707. }
  708. if (key === "type" && el.tagName === "TEXTAREA") {
  709. return false;
  710. }
  711. if (key === "width" || key === "height") {
  712. const tag = el.tagName;
  713. if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
  714. return false;
  715. }
  716. }
  717. if (isNativeOn(key) && shared.isString(value)) {
  718. return false;
  719. }
  720. return key in el;
  721. }
  722. const REMOVAL = {};
  723. /*! #__NO_SIDE_EFFECTS__ */
  724. // @__NO_SIDE_EFFECTS__
  725. function defineCustomElement(options, extraOptions, _createApp) {
  726. const Comp = runtimeCore.defineComponent(options, extraOptions);
  727. if (shared.isPlainObject(Comp)) shared.extend(Comp, extraOptions);
  728. class VueCustomElement extends VueElement {
  729. constructor(initialProps) {
  730. super(Comp, initialProps, _createApp);
  731. }
  732. }
  733. VueCustomElement.def = Comp;
  734. return VueCustomElement;
  735. }
  736. const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
  737. return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
  738. });
  739. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  740. };
  741. class VueElement extends BaseClass {
  742. constructor(_def, _props = {}, _createApp = createApp) {
  743. super();
  744. this._def = _def;
  745. this._props = _props;
  746. this._createApp = _createApp;
  747. this._isVueCE = true;
  748. /**
  749. * @internal
  750. */
  751. this._instance = null;
  752. /**
  753. * @internal
  754. */
  755. this._app = null;
  756. /**
  757. * @internal
  758. */
  759. this._nonce = this._def.nonce;
  760. this._connected = false;
  761. this._resolved = false;
  762. this._numberProps = null;
  763. this._styleChildren = /* @__PURE__ */ new WeakSet();
  764. this._ob = null;
  765. if (this.shadowRoot && _createApp !== createApp) {
  766. this._root = this.shadowRoot;
  767. } else {
  768. if (_def.shadowRoot !== false) {
  769. this.attachShadow({ mode: "open" });
  770. this._root = this.shadowRoot;
  771. } else {
  772. this._root = this;
  773. }
  774. }
  775. }
  776. connectedCallback() {
  777. if (!this.isConnected) return;
  778. if (!this.shadowRoot && !this._resolved) {
  779. this._parseSlots();
  780. }
  781. this._connected = true;
  782. let parent = this;
  783. while (parent = parent && (parent.parentNode || parent.host)) {
  784. if (parent instanceof VueElement) {
  785. this._parent = parent;
  786. break;
  787. }
  788. }
  789. if (!this._instance) {
  790. if (this._resolved) {
  791. this._mount(this._def);
  792. } else {
  793. if (parent && parent._pendingResolve) {
  794. this._pendingResolve = parent._pendingResolve.then(() => {
  795. this._pendingResolve = void 0;
  796. this._resolveDef();
  797. });
  798. } else {
  799. this._resolveDef();
  800. }
  801. }
  802. }
  803. }
  804. _setParent(parent = this._parent) {
  805. if (parent) {
  806. this._instance.parent = parent._instance;
  807. this._inheritParentContext(parent);
  808. }
  809. }
  810. _inheritParentContext(parent = this._parent) {
  811. if (parent && this._app) {
  812. Object.setPrototypeOf(
  813. this._app._context.provides,
  814. parent._instance.provides
  815. );
  816. }
  817. }
  818. disconnectedCallback() {
  819. this._connected = false;
  820. runtimeCore.nextTick(() => {
  821. if (!this._connected) {
  822. if (this._ob) {
  823. this._ob.disconnect();
  824. this._ob = null;
  825. }
  826. this._app && this._app.unmount();
  827. if (this._instance) this._instance.ce = void 0;
  828. this._app = this._instance = null;
  829. }
  830. });
  831. }
  832. /**
  833. * resolve inner component definition (handle possible async component)
  834. */
  835. _resolveDef() {
  836. if (this._pendingResolve) {
  837. return;
  838. }
  839. for (let i = 0; i < this.attributes.length; i++) {
  840. this._setAttr(this.attributes[i].name);
  841. }
  842. this._ob = new MutationObserver((mutations) => {
  843. for (const m of mutations) {
  844. this._setAttr(m.attributeName);
  845. }
  846. });
  847. this._ob.observe(this, { attributes: true });
  848. const resolve = (def, isAsync = false) => {
  849. this._resolved = true;
  850. this._pendingResolve = void 0;
  851. const { props, styles } = def;
  852. let numberProps;
  853. if (props && !shared.isArray(props)) {
  854. for (const key in props) {
  855. const opt = props[key];
  856. if (opt === Number || opt && opt.type === Number) {
  857. if (key in this._props) {
  858. this._props[key] = shared.toNumber(this._props[key]);
  859. }
  860. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[shared.camelize(key)] = true;
  861. }
  862. }
  863. }
  864. this._numberProps = numberProps;
  865. this._resolveProps(def);
  866. if (this.shadowRoot) {
  867. this._applyStyles(styles);
  868. }
  869. this._mount(def);
  870. };
  871. const asyncDef = this._def.__asyncLoader;
  872. if (asyncDef) {
  873. this._pendingResolve = asyncDef().then((def) => {
  874. def.configureApp = this._def.configureApp;
  875. resolve(this._def = def, true);
  876. });
  877. } else {
  878. resolve(this._def);
  879. }
  880. }
  881. _mount(def) {
  882. this._app = this._createApp(def);
  883. this._inheritParentContext();
  884. if (def.configureApp) {
  885. def.configureApp(this._app);
  886. }
  887. this._app._ceVNode = this._createVNode();
  888. this._app.mount(this._root);
  889. const exposed = this._instance && this._instance.exposed;
  890. if (!exposed) return;
  891. for (const key in exposed) {
  892. if (!shared.hasOwn(this, key)) {
  893. Object.defineProperty(this, key, {
  894. // unwrap ref to be consistent with public instance behavior
  895. get: () => runtimeCore.unref(exposed[key])
  896. });
  897. }
  898. }
  899. }
  900. _resolveProps(def) {
  901. const { props } = def;
  902. const declaredPropKeys = shared.isArray(props) ? props : Object.keys(props || {});
  903. for (const key of Object.keys(this)) {
  904. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  905. this._setProp(key, this[key]);
  906. }
  907. }
  908. for (const key of declaredPropKeys.map(shared.camelize)) {
  909. Object.defineProperty(this, key, {
  910. get() {
  911. return this._getProp(key);
  912. },
  913. set(val) {
  914. this._setProp(key, val, true, true);
  915. }
  916. });
  917. }
  918. }
  919. _setAttr(key) {
  920. if (key.startsWith("data-v-")) return;
  921. const has = this.hasAttribute(key);
  922. let value = has ? this.getAttribute(key) : REMOVAL;
  923. const camelKey = shared.camelize(key);
  924. if (has && this._numberProps && this._numberProps[camelKey]) {
  925. value = shared.toNumber(value);
  926. }
  927. this._setProp(camelKey, value, false, true);
  928. }
  929. /**
  930. * @internal
  931. */
  932. _getProp(key) {
  933. return this._props[key];
  934. }
  935. /**
  936. * @internal
  937. */
  938. _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
  939. if (val !== this._props[key]) {
  940. if (val === REMOVAL) {
  941. delete this._props[key];
  942. } else {
  943. this._props[key] = val;
  944. if (key === "key" && this._app) {
  945. this._app._ceVNode.key = val;
  946. }
  947. }
  948. if (shouldUpdate && this._instance) {
  949. this._update();
  950. }
  951. if (shouldReflect) {
  952. const ob = this._ob;
  953. ob && ob.disconnect();
  954. if (val === true) {
  955. this.setAttribute(shared.hyphenate(key), "");
  956. } else if (typeof val === "string" || typeof val === "number") {
  957. this.setAttribute(shared.hyphenate(key), val + "");
  958. } else if (!val) {
  959. this.removeAttribute(shared.hyphenate(key));
  960. }
  961. ob && ob.observe(this, { attributes: true });
  962. }
  963. }
  964. }
  965. _update() {
  966. const vnode = this._createVNode();
  967. if (this._app) vnode.appContext = this._app._context;
  968. render(vnode, this._root);
  969. }
  970. _createVNode() {
  971. const baseProps = {};
  972. if (!this.shadowRoot) {
  973. baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
  974. }
  975. const vnode = runtimeCore.createVNode(this._def, shared.extend(baseProps, this._props));
  976. if (!this._instance) {
  977. vnode.ce = (instance) => {
  978. this._instance = instance;
  979. instance.ce = this;
  980. instance.isCE = true;
  981. const dispatch = (event, args) => {
  982. this.dispatchEvent(
  983. new CustomEvent(
  984. event,
  985. shared.isPlainObject(args[0]) ? shared.extend({ detail: args }, args[0]) : { detail: args }
  986. )
  987. );
  988. };
  989. instance.emit = (event, ...args) => {
  990. dispatch(event, args);
  991. if (shared.hyphenate(event) !== event) {
  992. dispatch(shared.hyphenate(event), args);
  993. }
  994. };
  995. this._setParent();
  996. };
  997. }
  998. return vnode;
  999. }
  1000. _applyStyles(styles, owner) {
  1001. if (!styles) return;
  1002. if (owner) {
  1003. if (owner === this._def || this._styleChildren.has(owner)) {
  1004. return;
  1005. }
  1006. this._styleChildren.add(owner);
  1007. }
  1008. const nonce = this._nonce;
  1009. for (let i = styles.length - 1; i >= 0; i--) {
  1010. const s = document.createElement("style");
  1011. if (nonce) s.setAttribute("nonce", nonce);
  1012. s.textContent = styles[i];
  1013. this.shadowRoot.prepend(s);
  1014. }
  1015. }
  1016. /**
  1017. * Only called when shadowRoot is false
  1018. */
  1019. _parseSlots() {
  1020. const slots = this._slots = {};
  1021. let n;
  1022. while (n = this.firstChild) {
  1023. const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
  1024. (slots[slotName] || (slots[slotName] = [])).push(n);
  1025. this.removeChild(n);
  1026. }
  1027. }
  1028. /**
  1029. * Only called when shadowRoot is false
  1030. */
  1031. _renderSlots() {
  1032. const outlets = (this._teleportTarget || this).querySelectorAll("slot");
  1033. const scopeId = this._instance.type.__scopeId;
  1034. for (let i = 0; i < outlets.length; i++) {
  1035. const o = outlets[i];
  1036. const slotName = o.getAttribute("name") || "default";
  1037. const content = this._slots[slotName];
  1038. const parent = o.parentNode;
  1039. if (content) {
  1040. for (const n of content) {
  1041. if (scopeId && n.nodeType === 1) {
  1042. const id = scopeId + "-s";
  1043. const walker = document.createTreeWalker(n, 1);
  1044. n.setAttribute(id, "");
  1045. let child;
  1046. while (child = walker.nextNode()) {
  1047. child.setAttribute(id, "");
  1048. }
  1049. }
  1050. parent.insertBefore(n, o);
  1051. }
  1052. } else {
  1053. while (o.firstChild) parent.insertBefore(o.firstChild, o);
  1054. }
  1055. parent.removeChild(o);
  1056. }
  1057. }
  1058. /**
  1059. * @internal
  1060. */
  1061. _injectChildStyle(comp) {
  1062. this._applyStyles(comp.styles, comp);
  1063. }
  1064. /**
  1065. * @internal
  1066. */
  1067. _removeChildStyle(comp) {
  1068. }
  1069. }
  1070. function useHost(caller) {
  1071. const instance = runtimeCore.getCurrentInstance();
  1072. const el = instance && instance.ce;
  1073. if (el) {
  1074. return el;
  1075. }
  1076. return null;
  1077. }
  1078. function useShadowRoot() {
  1079. const el = useHost();
  1080. return el && el.shadowRoot;
  1081. }
  1082. function useCssModule(name = "$style") {
  1083. {
  1084. const instance = runtimeCore.getCurrentInstance();
  1085. if (!instance) {
  1086. return shared.EMPTY_OBJ;
  1087. }
  1088. const modules = instance.type.__cssModules;
  1089. if (!modules) {
  1090. return shared.EMPTY_OBJ;
  1091. }
  1092. const mod = modules[name];
  1093. if (!mod) {
  1094. return shared.EMPTY_OBJ;
  1095. }
  1096. return mod;
  1097. }
  1098. }
  1099. const positionMap = /* @__PURE__ */ new WeakMap();
  1100. const newPositionMap = /* @__PURE__ */ new WeakMap();
  1101. const moveCbKey = Symbol("_moveCb");
  1102. const enterCbKey = Symbol("_enterCb");
  1103. const decorate = (t) => {
  1104. delete t.props.mode;
  1105. return t;
  1106. };
  1107. const TransitionGroupImpl = /* @__PURE__ */ decorate({
  1108. name: "TransitionGroup",
  1109. props: /* @__PURE__ */ shared.extend({}, TransitionPropsValidators, {
  1110. tag: String,
  1111. moveClass: String
  1112. }),
  1113. setup(props, { slots }) {
  1114. const instance = runtimeCore.getCurrentInstance();
  1115. const state = runtimeCore.useTransitionState();
  1116. let prevChildren;
  1117. let children;
  1118. runtimeCore.onUpdated(() => {
  1119. if (!prevChildren.length) {
  1120. return;
  1121. }
  1122. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  1123. if (!hasCSSTransform(
  1124. prevChildren[0].el,
  1125. instance.vnode.el,
  1126. moveClass
  1127. )) {
  1128. prevChildren = [];
  1129. return;
  1130. }
  1131. prevChildren.forEach(callPendingCbs);
  1132. prevChildren.forEach(recordPosition);
  1133. const movedChildren = prevChildren.filter(applyTranslation);
  1134. forceReflow();
  1135. movedChildren.forEach((c) => {
  1136. const el = c.el;
  1137. const style = el.style;
  1138. addTransitionClass(el, moveClass);
  1139. style.transform = style.webkitTransform = style.transitionDuration = "";
  1140. const cb = el[moveCbKey] = (e) => {
  1141. if (e && e.target !== el) {
  1142. return;
  1143. }
  1144. if (!e || /transform$/.test(e.propertyName)) {
  1145. el.removeEventListener("transitionend", cb);
  1146. el[moveCbKey] = null;
  1147. removeTransitionClass(el, moveClass);
  1148. }
  1149. };
  1150. el.addEventListener("transitionend", cb);
  1151. });
  1152. prevChildren = [];
  1153. });
  1154. return () => {
  1155. const rawProps = runtimeCore.toRaw(props);
  1156. const cssTransitionProps = resolveTransitionProps(rawProps);
  1157. let tag = rawProps.tag || runtimeCore.Fragment;
  1158. prevChildren = [];
  1159. if (children) {
  1160. for (let i = 0; i < children.length; i++) {
  1161. const child = children[i];
  1162. if (child.el && child.el instanceof Element) {
  1163. prevChildren.push(child);
  1164. runtimeCore.setTransitionHooks(
  1165. child,
  1166. runtimeCore.resolveTransitionHooks(
  1167. child,
  1168. cssTransitionProps,
  1169. state,
  1170. instance
  1171. )
  1172. );
  1173. positionMap.set(
  1174. child,
  1175. child.el.getBoundingClientRect()
  1176. );
  1177. }
  1178. }
  1179. }
  1180. children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : [];
  1181. for (let i = 0; i < children.length; i++) {
  1182. const child = children[i];
  1183. if (child.key != null) {
  1184. runtimeCore.setTransitionHooks(
  1185. child,
  1186. runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance)
  1187. );
  1188. }
  1189. }
  1190. return runtimeCore.createVNode(tag, null, children);
  1191. };
  1192. }
  1193. });
  1194. const TransitionGroup = TransitionGroupImpl;
  1195. function callPendingCbs(c) {
  1196. const el = c.el;
  1197. if (el[moveCbKey]) {
  1198. el[moveCbKey]();
  1199. }
  1200. if (el[enterCbKey]) {
  1201. el[enterCbKey]();
  1202. }
  1203. }
  1204. function recordPosition(c) {
  1205. newPositionMap.set(c, c.el.getBoundingClientRect());
  1206. }
  1207. function applyTranslation(c) {
  1208. const oldPos = positionMap.get(c);
  1209. const newPos = newPositionMap.get(c);
  1210. const dx = oldPos.left - newPos.left;
  1211. const dy = oldPos.top - newPos.top;
  1212. if (dx || dy) {
  1213. const s = c.el.style;
  1214. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  1215. s.transitionDuration = "0s";
  1216. return c;
  1217. }
  1218. }
  1219. function hasCSSTransform(el, root, moveClass) {
  1220. const clone = el.cloneNode();
  1221. const _vtc = el[vtcKey];
  1222. if (_vtc) {
  1223. _vtc.forEach((cls) => {
  1224. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  1225. });
  1226. }
  1227. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  1228. clone.style.display = "none";
  1229. const container = root.nodeType === 1 ? root : root.parentNode;
  1230. container.appendChild(clone);
  1231. const { hasTransform } = getTransitionInfo(clone);
  1232. container.removeChild(clone);
  1233. return hasTransform;
  1234. }
  1235. const getModelAssigner = (vnode) => {
  1236. const fn = vnode.props["onUpdate:modelValue"] || false;
  1237. return shared.isArray(fn) ? (value) => shared.invokeArrayFns(fn, value) : fn;
  1238. };
  1239. function onCompositionStart(e) {
  1240. e.target.composing = true;
  1241. }
  1242. function onCompositionEnd(e) {
  1243. const target = e.target;
  1244. if (target.composing) {
  1245. target.composing = false;
  1246. target.dispatchEvent(new Event("input"));
  1247. }
  1248. }
  1249. const assignKey = Symbol("_assign");
  1250. const vModelText = {
  1251. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  1252. el[assignKey] = getModelAssigner(vnode);
  1253. const castToNumber = number || vnode.props && vnode.props.type === "number";
  1254. addEventListener(el, lazy ? "change" : "input", (e) => {
  1255. if (e.target.composing) return;
  1256. let domValue = el.value;
  1257. if (trim) {
  1258. domValue = domValue.trim();
  1259. }
  1260. if (castToNumber) {
  1261. domValue = shared.looseToNumber(domValue);
  1262. }
  1263. el[assignKey](domValue);
  1264. });
  1265. if (trim) {
  1266. addEventListener(el, "change", () => {
  1267. el.value = el.value.trim();
  1268. });
  1269. }
  1270. if (!lazy) {
  1271. addEventListener(el, "compositionstart", onCompositionStart);
  1272. addEventListener(el, "compositionend", onCompositionEnd);
  1273. addEventListener(el, "change", onCompositionEnd);
  1274. }
  1275. },
  1276. // set value on mounted so it's after min/max for type="range"
  1277. mounted(el, { value }) {
  1278. el.value = value == null ? "" : value;
  1279. },
  1280. beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
  1281. el[assignKey] = getModelAssigner(vnode);
  1282. if (el.composing) return;
  1283. const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? shared.looseToNumber(el.value) : el.value;
  1284. const newValue = value == null ? "" : value;
  1285. if (elValue === newValue) {
  1286. return;
  1287. }
  1288. if (document.activeElement === el && el.type !== "range") {
  1289. if (lazy && value === oldValue) {
  1290. return;
  1291. }
  1292. if (trim && el.value.trim() === newValue) {
  1293. return;
  1294. }
  1295. }
  1296. el.value = newValue;
  1297. }
  1298. };
  1299. const vModelCheckbox = {
  1300. // #4096 array checkboxes need to be deep traversed
  1301. deep: true,
  1302. created(el, _, vnode) {
  1303. el[assignKey] = getModelAssigner(vnode);
  1304. addEventListener(el, "change", () => {
  1305. const modelValue = el._modelValue;
  1306. const elementValue = getValue(el);
  1307. const checked = el.checked;
  1308. const assign = el[assignKey];
  1309. if (shared.isArray(modelValue)) {
  1310. const index = shared.looseIndexOf(modelValue, elementValue);
  1311. const found = index !== -1;
  1312. if (checked && !found) {
  1313. assign(modelValue.concat(elementValue));
  1314. } else if (!checked && found) {
  1315. const filtered = [...modelValue];
  1316. filtered.splice(index, 1);
  1317. assign(filtered);
  1318. }
  1319. } else if (shared.isSet(modelValue)) {
  1320. const cloned = new Set(modelValue);
  1321. if (checked) {
  1322. cloned.add(elementValue);
  1323. } else {
  1324. cloned.delete(elementValue);
  1325. }
  1326. assign(cloned);
  1327. } else {
  1328. assign(getCheckboxValue(el, checked));
  1329. }
  1330. });
  1331. },
  1332. // set initial checked on mount to wait for true-value/false-value
  1333. mounted: setChecked,
  1334. beforeUpdate(el, binding, vnode) {
  1335. el[assignKey] = getModelAssigner(vnode);
  1336. setChecked(el, binding, vnode);
  1337. }
  1338. };
  1339. function setChecked(el, { value, oldValue }, vnode) {
  1340. el._modelValue = value;
  1341. let checked;
  1342. if (shared.isArray(value)) {
  1343. checked = shared.looseIndexOf(value, vnode.props.value) > -1;
  1344. } else if (shared.isSet(value)) {
  1345. checked = value.has(vnode.props.value);
  1346. } else {
  1347. if (value === oldValue) return;
  1348. checked = shared.looseEqual(value, getCheckboxValue(el, true));
  1349. }
  1350. if (el.checked !== checked) {
  1351. el.checked = checked;
  1352. }
  1353. }
  1354. const vModelRadio = {
  1355. created(el, { value }, vnode) {
  1356. el.checked = shared.looseEqual(value, vnode.props.value);
  1357. el[assignKey] = getModelAssigner(vnode);
  1358. addEventListener(el, "change", () => {
  1359. el[assignKey](getValue(el));
  1360. });
  1361. },
  1362. beforeUpdate(el, { value, oldValue }, vnode) {
  1363. el[assignKey] = getModelAssigner(vnode);
  1364. if (value !== oldValue) {
  1365. el.checked = shared.looseEqual(value, vnode.props.value);
  1366. }
  1367. }
  1368. };
  1369. const vModelSelect = {
  1370. // <select multiple> value need to be deep traversed
  1371. deep: true,
  1372. created(el, { value, modifiers: { number } }, vnode) {
  1373. const isSetModel = shared.isSet(value);
  1374. addEventListener(el, "change", () => {
  1375. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  1376. (o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
  1377. );
  1378. el[assignKey](
  1379. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  1380. );
  1381. el._assigning = true;
  1382. runtimeCore.nextTick(() => {
  1383. el._assigning = false;
  1384. });
  1385. });
  1386. el[assignKey] = getModelAssigner(vnode);
  1387. },
  1388. // set value in mounted & updated because <select> relies on its children
  1389. // <option>s.
  1390. mounted(el, { value }) {
  1391. setSelected(el, value);
  1392. },
  1393. beforeUpdate(el, _binding, vnode) {
  1394. el[assignKey] = getModelAssigner(vnode);
  1395. },
  1396. updated(el, { value }) {
  1397. if (!el._assigning) {
  1398. setSelected(el, value);
  1399. }
  1400. }
  1401. };
  1402. function setSelected(el, value) {
  1403. const isMultiple = el.multiple;
  1404. const isArrayValue = shared.isArray(value);
  1405. if (isMultiple && !isArrayValue && !shared.isSet(value)) {
  1406. return;
  1407. }
  1408. for (let i = 0, l = el.options.length; i < l; i++) {
  1409. const option = el.options[i];
  1410. const optionValue = getValue(option);
  1411. if (isMultiple) {
  1412. if (isArrayValue) {
  1413. const optionType = typeof optionValue;
  1414. if (optionType === "string" || optionType === "number") {
  1415. option.selected = value.some((v) => String(v) === String(optionValue));
  1416. } else {
  1417. option.selected = shared.looseIndexOf(value, optionValue) > -1;
  1418. }
  1419. } else {
  1420. option.selected = value.has(optionValue);
  1421. }
  1422. } else if (shared.looseEqual(getValue(option), value)) {
  1423. if (el.selectedIndex !== i) el.selectedIndex = i;
  1424. return;
  1425. }
  1426. }
  1427. if (!isMultiple && el.selectedIndex !== -1) {
  1428. el.selectedIndex = -1;
  1429. }
  1430. }
  1431. function getValue(el) {
  1432. return "_value" in el ? el._value : el.value;
  1433. }
  1434. function getCheckboxValue(el, checked) {
  1435. const key = checked ? "_trueValue" : "_falseValue";
  1436. return key in el ? el[key] : checked;
  1437. }
  1438. const vModelDynamic = {
  1439. created(el, binding, vnode) {
  1440. callModelHook(el, binding, vnode, null, "created");
  1441. },
  1442. mounted(el, binding, vnode) {
  1443. callModelHook(el, binding, vnode, null, "mounted");
  1444. },
  1445. beforeUpdate(el, binding, vnode, prevVNode) {
  1446. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  1447. },
  1448. updated(el, binding, vnode, prevVNode) {
  1449. callModelHook(el, binding, vnode, prevVNode, "updated");
  1450. }
  1451. };
  1452. function resolveDynamicModel(tagName, type) {
  1453. switch (tagName) {
  1454. case "SELECT":
  1455. return vModelSelect;
  1456. case "TEXTAREA":
  1457. return vModelText;
  1458. default:
  1459. switch (type) {
  1460. case "checkbox":
  1461. return vModelCheckbox;
  1462. case "radio":
  1463. return vModelRadio;
  1464. default:
  1465. return vModelText;
  1466. }
  1467. }
  1468. }
  1469. function callModelHook(el, binding, vnode, prevVNode, hook) {
  1470. const modelToUse = resolveDynamicModel(
  1471. el.tagName,
  1472. vnode.props && vnode.props.type
  1473. );
  1474. const fn = modelToUse[hook];
  1475. fn && fn(el, binding, vnode, prevVNode);
  1476. }
  1477. function initVModelForSSR() {
  1478. vModelText.getSSRProps = ({ value }) => ({ value });
  1479. vModelRadio.getSSRProps = ({ value }, vnode) => {
  1480. if (vnode.props && shared.looseEqual(vnode.props.value, value)) {
  1481. return { checked: true };
  1482. }
  1483. };
  1484. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  1485. if (shared.isArray(value)) {
  1486. if (vnode.props && shared.looseIndexOf(value, vnode.props.value) > -1) {
  1487. return { checked: true };
  1488. }
  1489. } else if (shared.isSet(value)) {
  1490. if (vnode.props && value.has(vnode.props.value)) {
  1491. return { checked: true };
  1492. }
  1493. } else if (value) {
  1494. return { checked: true };
  1495. }
  1496. };
  1497. vModelDynamic.getSSRProps = (binding, vnode) => {
  1498. if (typeof vnode.type !== "string") {
  1499. return;
  1500. }
  1501. const modelToUse = resolveDynamicModel(
  1502. // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
  1503. vnode.type.toUpperCase(),
  1504. vnode.props && vnode.props.type
  1505. );
  1506. if (modelToUse.getSSRProps) {
  1507. return modelToUse.getSSRProps(binding, vnode);
  1508. }
  1509. };
  1510. }
  1511. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  1512. const modifierGuards = {
  1513. stop: (e) => e.stopPropagation(),
  1514. prevent: (e) => e.preventDefault(),
  1515. self: (e) => e.target !== e.currentTarget,
  1516. ctrl: (e) => !e.ctrlKey,
  1517. shift: (e) => !e.shiftKey,
  1518. alt: (e) => !e.altKey,
  1519. meta: (e) => !e.metaKey,
  1520. left: (e) => "button" in e && e.button !== 0,
  1521. middle: (e) => "button" in e && e.button !== 1,
  1522. right: (e) => "button" in e && e.button !== 2,
  1523. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  1524. };
  1525. const withModifiers = (fn, modifiers) => {
  1526. const cache = fn._withMods || (fn._withMods = {});
  1527. const cacheKey = modifiers.join(".");
  1528. return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => {
  1529. for (let i = 0; i < modifiers.length; i++) {
  1530. const guard = modifierGuards[modifiers[i]];
  1531. if (guard && guard(event, modifiers)) return;
  1532. }
  1533. return fn(event, ...args);
  1534. }));
  1535. };
  1536. const keyNames = {
  1537. esc: "escape",
  1538. space: " ",
  1539. up: "arrow-up",
  1540. left: "arrow-left",
  1541. right: "arrow-right",
  1542. down: "arrow-down",
  1543. delete: "backspace"
  1544. };
  1545. const withKeys = (fn, modifiers) => {
  1546. const cache = fn._withKeys || (fn._withKeys = {});
  1547. const cacheKey = modifiers.join(".");
  1548. return cache[cacheKey] || (cache[cacheKey] = ((event) => {
  1549. if (!("key" in event)) {
  1550. return;
  1551. }
  1552. const eventKey = shared.hyphenate(event.key);
  1553. if (modifiers.some(
  1554. (k) => k === eventKey || keyNames[k] === eventKey
  1555. )) {
  1556. return fn(event);
  1557. }
  1558. }));
  1559. };
  1560. const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
  1561. let renderer;
  1562. let enabledHydration = false;
  1563. function ensureRenderer() {
  1564. return renderer || (renderer = runtimeCore.createRenderer(rendererOptions));
  1565. }
  1566. function ensureHydrationRenderer() {
  1567. renderer = enabledHydration ? renderer : runtimeCore.createHydrationRenderer(rendererOptions);
  1568. enabledHydration = true;
  1569. return renderer;
  1570. }
  1571. const render = ((...args) => {
  1572. ensureRenderer().render(...args);
  1573. });
  1574. const hydrate = ((...args) => {
  1575. ensureHydrationRenderer().hydrate(...args);
  1576. });
  1577. const createApp = ((...args) => {
  1578. const app = ensureRenderer().createApp(...args);
  1579. const { mount } = app;
  1580. app.mount = (containerOrSelector) => {
  1581. const container = normalizeContainer(containerOrSelector);
  1582. if (!container) return;
  1583. const component = app._component;
  1584. if (!shared.isFunction(component) && !component.render && !component.template) {
  1585. component.template = container.innerHTML;
  1586. }
  1587. if (container.nodeType === 1) {
  1588. container.textContent = "";
  1589. }
  1590. const proxy = mount(container, false, resolveRootNamespace(container));
  1591. if (container instanceof Element) {
  1592. container.removeAttribute("v-cloak");
  1593. container.setAttribute("data-v-app", "");
  1594. }
  1595. return proxy;
  1596. };
  1597. return app;
  1598. });
  1599. const createSSRApp = ((...args) => {
  1600. const app = ensureHydrationRenderer().createApp(...args);
  1601. const { mount } = app;
  1602. app.mount = (containerOrSelector) => {
  1603. const container = normalizeContainer(containerOrSelector);
  1604. if (container) {
  1605. return mount(container, true, resolveRootNamespace(container));
  1606. }
  1607. };
  1608. return app;
  1609. });
  1610. function resolveRootNamespace(container) {
  1611. if (container instanceof SVGElement) {
  1612. return "svg";
  1613. }
  1614. if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
  1615. return "mathml";
  1616. }
  1617. }
  1618. function normalizeContainer(container) {
  1619. if (shared.isString(container)) {
  1620. const res = document.querySelector(container);
  1621. return res;
  1622. }
  1623. return container;
  1624. }
  1625. let ssrDirectiveInitialized = false;
  1626. const initDirectivesForSSR = () => {
  1627. if (!ssrDirectiveInitialized) {
  1628. ssrDirectiveInitialized = true;
  1629. initVModelForSSR();
  1630. initVShowForSSR();
  1631. }
  1632. } ;
  1633. exports.Transition = Transition;
  1634. exports.TransitionGroup = TransitionGroup;
  1635. exports.VueElement = VueElement;
  1636. exports.createApp = createApp;
  1637. exports.createSSRApp = createSSRApp;
  1638. exports.defineCustomElement = defineCustomElement;
  1639. exports.defineSSRCustomElement = defineSSRCustomElement;
  1640. exports.hydrate = hydrate;
  1641. exports.initDirectivesForSSR = initDirectivesForSSR;
  1642. exports.render = render;
  1643. exports.useCssModule = useCssModule;
  1644. exports.useCssVars = useCssVars;
  1645. exports.useHost = useHost;
  1646. exports.useShadowRoot = useShadowRoot;
  1647. exports.vModelCheckbox = vModelCheckbox;
  1648. exports.vModelDynamic = vModelDynamic;
  1649. exports.vModelRadio = vModelRadio;
  1650. exports.vModelSelect = vModelSelect;
  1651. exports.vModelText = vModelText;
  1652. exports.vShow = vShow;
  1653. exports.withKeys = withKeys;
  1654. exports.withModifiers = withModifiers;
  1655. Object.keys(runtimeCore).forEach(function (k) {
  1656. if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = runtimeCore[k];
  1657. });