runtime-dom.cjs.prod.js 40 KB

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