runtime-dom.cjs.js 54 KB

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