runtime-dom.esm-bundler.js 49 KB

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