Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runtime-dom.esm-bundler.js 49KB

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