runtime-dom.cjs.prod.js 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676
  1. /**
  2. * @vue/runtime-dom v3.5.16
  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. /*! #__NO_SIDE_EFFECTS__ */
  737. const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
  738. return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
  739. };
  740. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  741. };
  742. class VueElement extends BaseClass {
  743. constructor(_def, _props = {}, _createApp = createApp) {
  744. super();
  745. this._def = _def;
  746. this._props = _props;
  747. this._createApp = _createApp;
  748. this._isVueCE = true;
  749. /**
  750. * @internal
  751. */
  752. this._instance = null;
  753. /**
  754. * @internal
  755. */
  756. this._app = null;
  757. /**
  758. * @internal
  759. */
  760. this._nonce = this._def.nonce;
  761. this._connected = false;
  762. this._resolved = false;
  763. this._numberProps = null;
  764. this._styleChildren = /* @__PURE__ */ new WeakSet();
  765. this._ob = null;
  766. if (this.shadowRoot && _createApp !== createApp) {
  767. this._root = this.shadowRoot;
  768. } else {
  769. if (_def.shadowRoot !== false) {
  770. this.attachShadow({ mode: "open" });
  771. this._root = this.shadowRoot;
  772. } else {
  773. this._root = this;
  774. }
  775. }
  776. }
  777. connectedCallback() {
  778. if (!this.isConnected) return;
  779. if (!this.shadowRoot && !this._resolved) {
  780. this._parseSlots();
  781. }
  782. this._connected = true;
  783. let parent = this;
  784. while (parent = parent && (parent.parentNode || parent.host)) {
  785. if (parent instanceof VueElement) {
  786. this._parent = parent;
  787. break;
  788. }
  789. }
  790. if (!this._instance) {
  791. if (this._resolved) {
  792. this._mount(this._def);
  793. } else {
  794. if (parent && parent._pendingResolve) {
  795. this._pendingResolve = parent._pendingResolve.then(() => {
  796. this._pendingResolve = void 0;
  797. this._resolveDef();
  798. });
  799. } else {
  800. this._resolveDef();
  801. }
  802. }
  803. }
  804. }
  805. _setParent(parent = this._parent) {
  806. if (parent) {
  807. this._instance.parent = parent._instance;
  808. this._inheritParentContext(parent);
  809. }
  810. }
  811. _inheritParentContext(parent = this._parent) {
  812. if (parent && this._app) {
  813. Object.setPrototypeOf(
  814. this._app._context.provides,
  815. parent._instance.provides
  816. );
  817. }
  818. }
  819. disconnectedCallback() {
  820. this._connected = false;
  821. runtimeCore.nextTick(() => {
  822. if (!this._connected) {
  823. if (this._ob) {
  824. this._ob.disconnect();
  825. this._ob = null;
  826. }
  827. this._app && this._app.unmount();
  828. if (this._instance) this._instance.ce = void 0;
  829. this._app = this._instance = null;
  830. }
  831. });
  832. }
  833. /**
  834. * resolve inner component definition (handle possible async component)
  835. */
  836. _resolveDef() {
  837. if (this._pendingResolve) {
  838. return;
  839. }
  840. for (let i = 0; i < this.attributes.length; i++) {
  841. this._setAttr(this.attributes[i].name);
  842. }
  843. this._ob = new MutationObserver((mutations) => {
  844. for (const m of mutations) {
  845. this._setAttr(m.attributeName);
  846. }
  847. });
  848. this._ob.observe(this, { attributes: true });
  849. const resolve = (def, isAsync = false) => {
  850. this._resolved = true;
  851. this._pendingResolve = void 0;
  852. const { props, styles } = def;
  853. let numberProps;
  854. if (props && !shared.isArray(props)) {
  855. for (const key in props) {
  856. const opt = props[key];
  857. if (opt === Number || opt && opt.type === Number) {
  858. if (key in this._props) {
  859. this._props[key] = shared.toNumber(this._props[key]);
  860. }
  861. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[shared.camelize(key)] = true;
  862. }
  863. }
  864. }
  865. this._numberProps = numberProps;
  866. this._resolveProps(def);
  867. if (this.shadowRoot) {
  868. this._applyStyles(styles);
  869. }
  870. this._mount(def);
  871. };
  872. const asyncDef = this._def.__asyncLoader;
  873. if (asyncDef) {
  874. this._pendingResolve = asyncDef().then(
  875. (def) => 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. });