UNPKG

405 kBJavaScriptView Raw
1/**
2 * Make a map and return a function for checking if a key
3 * is in that map.
4 * IMPORTANT: all calls of this function must be prefixed with
5 * \/\*#\_\_PURE\_\_\*\/
6 * So that rollup can tree-shake them if necessary.
7 */
8function makeMap(str, expectsLowerCase) {
9 const map = Object.create(null);
10 const list = str.split(',');
11 for (let i = 0; i < list.length; i++) {
12 map[list[i]] = true;
13 }
14 return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
15}
16
17const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
18 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
19 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
20const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
21
22/**
23 * On the client we only need to offer special cases for boolean attributes that
24 * have different names from their corresponding dom properties:
25 * - itemscope -> N/A
26 * - allowfullscreen -> allowFullscreen
27 * - formnovalidate -> formNoValidate
28 * - ismap -> isMap
29 * - nomodule -> noModule
30 * - novalidate -> noValidate
31 * - readonly -> readOnly
32 */
33const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
34const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
35/**
36 * Boolean attributes should be included if the value is truthy or ''.
37 * e.g. `<select multiple>` compiles to `{ multiple: '' }`
38 */
39function includeBooleanAttr(value) {
40 return !!value || value === '';
41}
42
43function normalizeStyle(value) {
44 if (isArray(value)) {
45 const res = {};
46 for (let i = 0; i < value.length; i++) {
47 const item = value[i];
48 const normalized = isString(item)
49 ? parseStringStyle(item)
50 : normalizeStyle(item);
51 if (normalized) {
52 for (const key in normalized) {
53 res[key] = normalized[key];
54 }
55 }
56 }
57 return res;
58 }
59 else if (isString(value)) {
60 return value;
61 }
62 else if (isObject(value)) {
63 return value;
64 }
65}
66const listDelimiterRE = /;(?![^(]*\))/g;
67const propertyDelimiterRE = /:(.+)/;
68function parseStringStyle(cssText) {
69 const ret = {};
70 cssText.split(listDelimiterRE).forEach(item => {
71 if (item) {
72 const tmp = item.split(propertyDelimiterRE);
73 tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
74 }
75 });
76 return ret;
77}
78function normalizeClass(value) {
79 let res = '';
80 if (isString(value)) {
81 res = value;
82 }
83 else if (isArray(value)) {
84 for (let i = 0; i < value.length; i++) {
85 const normalized = normalizeClass(value[i]);
86 if (normalized) {
87 res += normalized + ' ';
88 }
89 }
90 }
91 else if (isObject(value)) {
92 for (const name in value) {
93 if (value[name]) {
94 res += name + ' ';
95 }
96 }
97 }
98 return res.trim();
99}
100function normalizeProps(props) {
101 if (!props)
102 return null;
103 let { class: klass, style } = props;
104 if (klass && !isString(klass)) {
105 props.class = normalizeClass(klass);
106 }
107 if (style) {
108 props.style = normalizeStyle(style);
109 }
110 return props;
111}
112
113// These tag configs are shared between compiler-dom and runtime-dom, so they
114// https://developer.mozilla.org/en-US/docs/Web/HTML/Element
115const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +
116 'header,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +
117 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +
118 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +
119 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +
120 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +
121 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +
122 'option,output,progress,select,textarea,details,dialog,menu,' +
123 'summary,template,blockquote,iframe,tfoot';
124// https://developer.mozilla.org/en-US/docs/Web/SVG/Element
125const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +
126 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +
127 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +
128 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +
129 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +
130 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +
131 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +
132 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +
133 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
134 'text,textPath,title,tspan,unknown,use,view';
135/**
136 * Compiler only.
137 * Do NOT use in runtime code paths unless behind `true` flag.
138 */
139const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
140/**
141 * Compiler only.
142 * Do NOT use in runtime code paths unless behind `true` flag.
143 */
144const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
145
146function looseCompareArrays(a, b) {
147 if (a.length !== b.length)
148 return false;
149 let equal = true;
150 for (let i = 0; equal && i < a.length; i++) {
151 equal = looseEqual(a[i], b[i]);
152 }
153 return equal;
154}
155function looseEqual(a, b) {
156 if (a === b)
157 return true;
158 let aValidType = isDate(a);
159 let bValidType = isDate(b);
160 if (aValidType || bValidType) {
161 return aValidType && bValidType ? a.getTime() === b.getTime() : false;
162 }
163 aValidType = isArray(a);
164 bValidType = isArray(b);
165 if (aValidType || bValidType) {
166 return aValidType && bValidType ? looseCompareArrays(a, b) : false;
167 }
168 aValidType = isObject(a);
169 bValidType = isObject(b);
170 if (aValidType || bValidType) {
171 /* istanbul ignore if: this if will probably never be called */
172 if (!aValidType || !bValidType) {
173 return false;
174 }
175 const aKeysCount = Object.keys(a).length;
176 const bKeysCount = Object.keys(b).length;
177 if (aKeysCount !== bKeysCount) {
178 return false;
179 }
180 for (const key in a) {
181 const aHasKey = a.hasOwnProperty(key);
182 const bHasKey = b.hasOwnProperty(key);
183 if ((aHasKey && !bHasKey) ||
184 (!aHasKey && bHasKey) ||
185 !looseEqual(a[key], b[key])) {
186 return false;
187 }
188 }
189 }
190 return String(a) === String(b);
191}
192function looseIndexOf(arr, val) {
193 return arr.findIndex(item => looseEqual(item, val));
194}
195
196/**
197 * For converting {{ interpolation }} values to displayed strings.
198 * @private
199 */
200const toDisplayString = (val) => {
201 return isString(val)
202 ? val
203 : val == null
204 ? ''
205 : isArray(val) ||
206 (isObject(val) &&
207 (val.toString === objectToString || !isFunction(val.toString)))
208 ? JSON.stringify(val, replacer, 2)
209 : String(val);
210};
211const replacer = (_key, val) => {
212 // can't use isRef here since @vue/shared has no deps
213 if (val && val.__v_isRef) {
214 return replacer(_key, val.value);
215 }
216 else if (isMap(val)) {
217 return {
218 [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val]) => {
219 entries[`${key} =>`] = val;
220 return entries;
221 }, {})
222 };
223 }
224 else if (isSet(val)) {
225 return {
226 [`Set(${val.size})`]: [...val.values()]
227 };
228 }
229 else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {
230 return String(val);
231 }
232 return val;
233};
234
235const EMPTY_OBJ = Object.freeze({})
236 ;
237const EMPTY_ARR = Object.freeze([]) ;
238const NOOP = () => { };
239/**
240 * Always return false.
241 */
242const NO = () => false;
243const onRE = /^on[^a-z]/;
244const isOn = (key) => onRE.test(key);
245const isModelListener = (key) => key.startsWith('onUpdate:');
246const extend = Object.assign;
247const remove = (arr, el) => {
248 const i = arr.indexOf(el);
249 if (i > -1) {
250 arr.splice(i, 1);
251 }
252};
253const hasOwnProperty = Object.prototype.hasOwnProperty;
254const hasOwn = (val, key) => hasOwnProperty.call(val, key);
255const isArray = Array.isArray;
256const isMap = (val) => toTypeString(val) === '[object Map]';
257const isSet = (val) => toTypeString(val) === '[object Set]';
258const isDate = (val) => val instanceof Date;
259const isFunction = (val) => typeof val === 'function';
260const isString = (val) => typeof val === 'string';
261const isSymbol = (val) => typeof val === 'symbol';
262const isObject = (val) => val !== null && typeof val === 'object';
263const isPromise = (val) => {
264 return isObject(val) && isFunction(val.then) && isFunction(val.catch);
265};
266const objectToString = Object.prototype.toString;
267const toTypeString = (value) => objectToString.call(value);
268const toRawType = (value) => {
269 // extract "RawType" from strings like "[object RawType]"
270 return toTypeString(value).slice(8, -1);
271};
272const isPlainObject = (val) => toTypeString(val) === '[object Object]';
273const isIntegerKey = (key) => isString(key) &&
274 key !== 'NaN' &&
275 key[0] !== '-' &&
276 '' + parseInt(key, 10) === key;
277const isReservedProp = /*#__PURE__*/ makeMap(
278// the leading comma is intentional so empty string "" is also included
279',key,ref,ref_for,ref_key,' +
280 'onVnodeBeforeMount,onVnodeMounted,' +
281 'onVnodeBeforeUpdate,onVnodeUpdated,' +
282 'onVnodeBeforeUnmount,onVnodeUnmounted');
283const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
284const cacheStringFunction = (fn) => {
285 const cache = Object.create(null);
286 return ((str) => {
287 const hit = cache[str];
288 return hit || (cache[str] = fn(str));
289 });
290};
291const camelizeRE = /-(\w)/g;
292/**
293 * @private
294 */
295const camelize = cacheStringFunction((str) => {
296 return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
297});
298const hyphenateRE = /\B([A-Z])/g;
299/**
300 * @private
301 */
302const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase());
303/**
304 * @private
305 */
306const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
307/**
308 * @private
309 */
310const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``);
311// compare whether a value has changed, accounting for NaN.
312const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
313const invokeArrayFns = (fns, arg) => {
314 for (let i = 0; i < fns.length; i++) {
315 fns[i](arg);
316 }
317};
318const def = (obj, key, value) => {
319 Object.defineProperty(obj, key, {
320 configurable: true,
321 enumerable: false,
322 value
323 });
324};
325const toNumber = (val) => {
326 const n = parseFloat(val);
327 return isNaN(n) ? val : n;
328};
329let _globalThis;
330const getGlobalThis = () => {
331 return (_globalThis ||
332 (_globalThis =
333 typeof globalThis !== 'undefined'
334 ? globalThis
335 : typeof self !== 'undefined'
336 ? self
337 : typeof window !== 'undefined'
338 ? window
339 : typeof global !== 'undefined'
340 ? global
341 : {}));
342};
343
344function warn(msg, ...args) {
345 console.warn(`[Vue warn] ${msg}`, ...args);
346}
347
348let activeEffectScope;
349class EffectScope {
350 constructor(detached = false) {
351 this.active = true;
352 this.effects = [];
353 this.cleanups = [];
354 if (!detached && activeEffectScope) {
355 this.parent = activeEffectScope;
356 this.index =
357 (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
358 }
359 }
360 run(fn) {
361 if (this.active) {
362 try {
363 activeEffectScope = this;
364 return fn();
365 }
366 finally {
367 activeEffectScope = this.parent;
368 }
369 }
370 else {
371 warn(`cannot run an inactive effect scope.`);
372 }
373 }
374 on() {
375 activeEffectScope = this;
376 }
377 off() {
378 activeEffectScope = this.parent;
379 }
380 stop(fromParent) {
381 if (this.active) {
382 let i, l;
383 for (i = 0, l = this.effects.length; i < l; i++) {
384 this.effects[i].stop();
385 }
386 for (i = 0, l = this.cleanups.length; i < l; i++) {
387 this.cleanups[i]();
388 }
389 if (this.scopes) {
390 for (i = 0, l = this.scopes.length; i < l; i++) {
391 this.scopes[i].stop(true);
392 }
393 }
394 // nested scope, dereference from parent to avoid memory leaks
395 if (this.parent && !fromParent) {
396 // optimized O(1) removal
397 const last = this.parent.scopes.pop();
398 if (last && last !== this) {
399 this.parent.scopes[this.index] = last;
400 last.index = this.index;
401 }
402 }
403 this.active = false;
404 }
405 }
406}
407function effectScope(detached) {
408 return new EffectScope(detached);
409}
410function recordEffectScope(effect, scope = activeEffectScope) {
411 if (scope && scope.active) {
412 scope.effects.push(effect);
413 }
414}
415function getCurrentScope() {
416 return activeEffectScope;
417}
418function onScopeDispose(fn) {
419 if (activeEffectScope) {
420 activeEffectScope.cleanups.push(fn);
421 }
422 else {
423 warn(`onScopeDispose() is called when there is no active effect scope` +
424 ` to be associated with.`);
425 }
426}
427
428const createDep = (effects) => {
429 const dep = new Set(effects);
430 dep.w = 0;
431 dep.n = 0;
432 return dep;
433};
434const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
435const newTracked = (dep) => (dep.n & trackOpBit) > 0;
436const initDepMarkers = ({ deps }) => {
437 if (deps.length) {
438 for (let i = 0; i < deps.length; i++) {
439 deps[i].w |= trackOpBit; // set was tracked
440 }
441 }
442};
443const finalizeDepMarkers = (effect) => {
444 const { deps } = effect;
445 if (deps.length) {
446 let ptr = 0;
447 for (let i = 0; i < deps.length; i++) {
448 const dep = deps[i];
449 if (wasTracked(dep) && !newTracked(dep)) {
450 dep.delete(effect);
451 }
452 else {
453 deps[ptr++] = dep;
454 }
455 // clear bits
456 dep.w &= ~trackOpBit;
457 dep.n &= ~trackOpBit;
458 }
459 deps.length = ptr;
460 }
461};
462
463const targetMap = new WeakMap();
464// The number of effects currently being tracked recursively.
465let effectTrackDepth = 0;
466let trackOpBit = 1;
467/**
468 * The bitwise track markers support at most 30 levels of recursion.
469 * This value is chosen to enable modern JS engines to use a SMI on all platforms.
470 * When recursion depth is greater, fall back to using a full cleanup.
471 */
472const maxMarkerBits = 30;
473let activeEffect;
474const ITERATE_KEY = Symbol('iterate' );
475const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
476class ReactiveEffect {
477 constructor(fn, scheduler = null, scope) {
478 this.fn = fn;
479 this.scheduler = scheduler;
480 this.active = true;
481 this.deps = [];
482 this.parent = undefined;
483 recordEffectScope(this, scope);
484 }
485 run() {
486 if (!this.active) {
487 return this.fn();
488 }
489 let parent = activeEffect;
490 let lastShouldTrack = shouldTrack;
491 while (parent) {
492 if (parent === this) {
493 return;
494 }
495 parent = parent.parent;
496 }
497 try {
498 this.parent = activeEffect;
499 activeEffect = this;
500 shouldTrack = true;
501 trackOpBit = 1 << ++effectTrackDepth;
502 if (effectTrackDepth <= maxMarkerBits) {
503 initDepMarkers(this);
504 }
505 else {
506 cleanupEffect(this);
507 }
508 return this.fn();
509 }
510 finally {
511 if (effectTrackDepth <= maxMarkerBits) {
512 finalizeDepMarkers(this);
513 }
514 trackOpBit = 1 << --effectTrackDepth;
515 activeEffect = this.parent;
516 shouldTrack = lastShouldTrack;
517 this.parent = undefined;
518 }
519 }
520 stop() {
521 if (this.active) {
522 cleanupEffect(this);
523 if (this.onStop) {
524 this.onStop();
525 }
526 this.active = false;
527 }
528 }
529}
530function cleanupEffect(effect) {
531 const { deps } = effect;
532 if (deps.length) {
533 for (let i = 0; i < deps.length; i++) {
534 deps[i].delete(effect);
535 }
536 deps.length = 0;
537 }
538}
539function effect(fn, options) {
540 if (fn.effect) {
541 fn = fn.effect.fn;
542 }
543 const _effect = new ReactiveEffect(fn);
544 if (options) {
545 extend(_effect, options);
546 if (options.scope)
547 recordEffectScope(_effect, options.scope);
548 }
549 if (!options || !options.lazy) {
550 _effect.run();
551 }
552 const runner = _effect.run.bind(_effect);
553 runner.effect = _effect;
554 return runner;
555}
556function stop(runner) {
557 runner.effect.stop();
558}
559let shouldTrack = true;
560const trackStack = [];
561function pauseTracking() {
562 trackStack.push(shouldTrack);
563 shouldTrack = false;
564}
565function resetTracking() {
566 const last = trackStack.pop();
567 shouldTrack = last === undefined ? true : last;
568}
569function track(target, type, key) {
570 if (shouldTrack && activeEffect) {
571 let depsMap = targetMap.get(target);
572 if (!depsMap) {
573 targetMap.set(target, (depsMap = new Map()));
574 }
575 let dep = depsMap.get(key);
576 if (!dep) {
577 depsMap.set(key, (dep = createDep()));
578 }
579 const eventInfo = { effect: activeEffect, target, type, key }
580 ;
581 trackEffects(dep, eventInfo);
582 }
583}
584function trackEffects(dep, debuggerEventExtraInfo) {
585 let shouldTrack = false;
586 if (effectTrackDepth <= maxMarkerBits) {
587 if (!newTracked(dep)) {
588 dep.n |= trackOpBit; // set newly tracked
589 shouldTrack = !wasTracked(dep);
590 }
591 }
592 else {
593 // Full cleanup mode.
594 shouldTrack = !dep.has(activeEffect);
595 }
596 if (shouldTrack) {
597 dep.add(activeEffect);
598 activeEffect.deps.push(dep);
599 if (activeEffect.onTrack) {
600 activeEffect.onTrack(Object.assign({
601 effect: activeEffect
602 }, debuggerEventExtraInfo));
603 }
604 }
605}
606function trigger(target, type, key, newValue, oldValue, oldTarget) {
607 const depsMap = targetMap.get(target);
608 if (!depsMap) {
609 // never been tracked
610 return;
611 }
612 let deps = [];
613 if (type === "clear" /* CLEAR */) {
614 // collection being cleared
615 // trigger all effects for target
616 deps = [...depsMap.values()];
617 }
618 else if (key === 'length' && isArray(target)) {
619 depsMap.forEach((dep, key) => {
620 if (key === 'length' || key >= newValue) {
621 deps.push(dep);
622 }
623 });
624 }
625 else {
626 // schedule runs for SET | ADD | DELETE
627 if (key !== void 0) {
628 deps.push(depsMap.get(key));
629 }
630 // also run for iteration key on ADD | DELETE | Map.SET
631 switch (type) {
632 case "add" /* ADD */:
633 if (!isArray(target)) {
634 deps.push(depsMap.get(ITERATE_KEY));
635 if (isMap(target)) {
636 deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
637 }
638 }
639 else if (isIntegerKey(key)) {
640 // new index added to array -> length changes
641 deps.push(depsMap.get('length'));
642 }
643 break;
644 case "delete" /* DELETE */:
645 if (!isArray(target)) {
646 deps.push(depsMap.get(ITERATE_KEY));
647 if (isMap(target)) {
648 deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
649 }
650 }
651 break;
652 case "set" /* SET */:
653 if (isMap(target)) {
654 deps.push(depsMap.get(ITERATE_KEY));
655 }
656 break;
657 }
658 }
659 const eventInfo = { target, type, key, newValue, oldValue, oldTarget }
660 ;
661 if (deps.length === 1) {
662 if (deps[0]) {
663 {
664 triggerEffects(deps[0], eventInfo);
665 }
666 }
667 }
668 else {
669 const effects = [];
670 for (const dep of deps) {
671 if (dep) {
672 effects.push(...dep);
673 }
674 }
675 {
676 triggerEffects(createDep(effects), eventInfo);
677 }
678 }
679}
680function triggerEffects(dep, debuggerEventExtraInfo) {
681 // spread into array for stabilization
682 for (const effect of isArray(dep) ? dep : [...dep]) {
683 if (effect !== activeEffect || effect.allowRecurse) {
684 if (effect.onTrigger) {
685 effect.onTrigger(extend({ effect }, debuggerEventExtraInfo));
686 }
687 if (effect.scheduler) {
688 effect.scheduler();
689 }
690 else {
691 effect.run();
692 }
693 }
694 }
695}
696
697const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
698const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
699 .map(key => Symbol[key])
700 .filter(isSymbol));
701const get = /*#__PURE__*/ createGetter();
702const shallowGet = /*#__PURE__*/ createGetter(false, true);
703const readonlyGet = /*#__PURE__*/ createGetter(true);
704const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true);
705const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations();
706function createArrayInstrumentations() {
707 const instrumentations = {};
708 ['includes', 'indexOf', 'lastIndexOf'].forEach(key => {
709 instrumentations[key] = function (...args) {
710 const arr = toRaw(this);
711 for (let i = 0, l = this.length; i < l; i++) {
712 track(arr, "get" /* GET */, i + '');
713 }
714 // we run the method using the original args first (which may be reactive)
715 const res = arr[key](...args);
716 if (res === -1 || res === false) {
717 // if that didn't work, run it again using raw values.
718 return arr[key](...args.map(toRaw));
719 }
720 else {
721 return res;
722 }
723 };
724 });
725 ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => {
726 instrumentations[key] = function (...args) {
727 pauseTracking();
728 const res = toRaw(this)[key].apply(this, args);
729 resetTracking();
730 return res;
731 };
732 });
733 return instrumentations;
734}
735function createGetter(isReadonly = false, shallow = false) {
736 return function get(target, key, receiver) {
737 if (key === "__v_isReactive" /* IS_REACTIVE */) {
738 return !isReadonly;
739 }
740 else if (key === "__v_isReadonly" /* IS_READONLY */) {
741 return isReadonly;
742 }
743 else if (key === "__v_isShallow" /* IS_SHALLOW */) {
744 return shallow;
745 }
746 else if (key === "__v_raw" /* RAW */ &&
747 receiver ===
748 (isReadonly
749 ? shallow
750 ? shallowReadonlyMap
751 : readonlyMap
752 : shallow
753 ? shallowReactiveMap
754 : reactiveMap).get(target)) {
755 return target;
756 }
757 const targetIsArray = isArray(target);
758 if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
759 return Reflect.get(arrayInstrumentations, key, receiver);
760 }
761 const res = Reflect.get(target, key, receiver);
762 if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
763 return res;
764 }
765 if (!isReadonly) {
766 track(target, "get" /* GET */, key);
767 }
768 if (shallow) {
769 return res;
770 }
771 if (isRef(res)) {
772 // ref unwrapping - does not apply for Array + integer key.
773 const shouldUnwrap = !targetIsArray || !isIntegerKey(key);
774 return shouldUnwrap ? res.value : res;
775 }
776 if (isObject(res)) {
777 // Convert returned value into a proxy as well. we do the isObject check
778 // here to avoid invalid value warning. Also need to lazy access readonly
779 // and reactive here to avoid circular dependency.
780 return isReadonly ? readonly(res) : reactive(res);
781 }
782 return res;
783 };
784}
785const set = /*#__PURE__*/ createSetter();
786const shallowSet = /*#__PURE__*/ createSetter(true);
787function createSetter(shallow = false) {
788 return function set(target, key, value, receiver) {
789 let oldValue = target[key];
790 if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
791 return false;
792 }
793 if (!shallow && !isReadonly(value)) {
794 if (!isShallow(value)) {
795 value = toRaw(value);
796 oldValue = toRaw(oldValue);
797 }
798 if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
799 oldValue.value = value;
800 return true;
801 }
802 }
803 const hadKey = isArray(target) && isIntegerKey(key)
804 ? Number(key) < target.length
805 : hasOwn(target, key);
806 const result = Reflect.set(target, key, value, receiver);
807 // don't trigger if target is something up in the prototype chain of original
808 if (target === toRaw(receiver)) {
809 if (!hadKey) {
810 trigger(target, "add" /* ADD */, key, value);
811 }
812 else if (hasChanged(value, oldValue)) {
813 trigger(target, "set" /* SET */, key, value, oldValue);
814 }
815 }
816 return result;
817 };
818}
819function deleteProperty(target, key) {
820 const hadKey = hasOwn(target, key);
821 const oldValue = target[key];
822 const result = Reflect.deleteProperty(target, key);
823 if (result && hadKey) {
824 trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
825 }
826 return result;
827}
828function has(target, key) {
829 const result = Reflect.has(target, key);
830 if (!isSymbol(key) || !builtInSymbols.has(key)) {
831 track(target, "has" /* HAS */, key);
832 }
833 return result;
834}
835function ownKeys(target) {
836 track(target, "iterate" /* ITERATE */, isArray(target) ? 'length' : ITERATE_KEY);
837 return Reflect.ownKeys(target);
838}
839const mutableHandlers = {
840 get,
841 set,
842 deleteProperty,
843 has,
844 ownKeys
845};
846const readonlyHandlers = {
847 get: readonlyGet,
848 set(target, key) {
849 {
850 console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
851 }
852 return true;
853 },
854 deleteProperty(target, key) {
855 {
856 console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
857 }
858 return true;
859 }
860};
861const shallowReactiveHandlers = /*#__PURE__*/ extend({}, mutableHandlers, {
862 get: shallowGet,
863 set: shallowSet
864});
865// Props handlers are special in the sense that it should not unwrap top-level
866// refs (in order to allow refs to be explicitly passed down), but should
867// retain the reactivity of the normal readonly object.
868const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
869 get: shallowReadonlyGet
870});
871
872const toShallow = (value) => value;
873const getProto = (v) => Reflect.getPrototypeOf(v);
874function get$1(target, key, isReadonly = false, isShallow = false) {
875 // #1772: readonly(reactive(Map)) should return readonly + reactive version
876 // of the value
877 target = target["__v_raw" /* RAW */];
878 const rawTarget = toRaw(target);
879 const rawKey = toRaw(key);
880 if (key !== rawKey) {
881 !isReadonly && track(rawTarget, "get" /* GET */, key);
882 }
883 !isReadonly && track(rawTarget, "get" /* GET */, rawKey);
884 const { has } = getProto(rawTarget);
885 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
886 if (has.call(rawTarget, key)) {
887 return wrap(target.get(key));
888 }
889 else if (has.call(rawTarget, rawKey)) {
890 return wrap(target.get(rawKey));
891 }
892 else if (target !== rawTarget) {
893 // #3602 readonly(reactive(Map))
894 // ensure that the nested reactive `Map` can do tracking for itself
895 target.get(key);
896 }
897}
898function has$1(key, isReadonly = false) {
899 const target = this["__v_raw" /* RAW */];
900 const rawTarget = toRaw(target);
901 const rawKey = toRaw(key);
902 if (key !== rawKey) {
903 !isReadonly && track(rawTarget, "has" /* HAS */, key);
904 }
905 !isReadonly && track(rawTarget, "has" /* HAS */, rawKey);
906 return key === rawKey
907 ? target.has(key)
908 : target.has(key) || target.has(rawKey);
909}
910function size(target, isReadonly = false) {
911 target = target["__v_raw" /* RAW */];
912 !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY);
913 return Reflect.get(target, 'size', target);
914}
915function add(value) {
916 value = toRaw(value);
917 const target = toRaw(this);
918 const proto = getProto(target);
919 const hadKey = proto.has.call(target, value);
920 if (!hadKey) {
921 target.add(value);
922 trigger(target, "add" /* ADD */, value, value);
923 }
924 return this;
925}
926function set$1(key, value) {
927 value = toRaw(value);
928 const target = toRaw(this);
929 const { has, get } = getProto(target);
930 let hadKey = has.call(target, key);
931 if (!hadKey) {
932 key = toRaw(key);
933 hadKey = has.call(target, key);
934 }
935 else {
936 checkIdentityKeys(target, has, key);
937 }
938 const oldValue = get.call(target, key);
939 target.set(key, value);
940 if (!hadKey) {
941 trigger(target, "add" /* ADD */, key, value);
942 }
943 else if (hasChanged(value, oldValue)) {
944 trigger(target, "set" /* SET */, key, value, oldValue);
945 }
946 return this;
947}
948function deleteEntry(key) {
949 const target = toRaw(this);
950 const { has, get } = getProto(target);
951 let hadKey = has.call(target, key);
952 if (!hadKey) {
953 key = toRaw(key);
954 hadKey = has.call(target, key);
955 }
956 else {
957 checkIdentityKeys(target, has, key);
958 }
959 const oldValue = get ? get.call(target, key) : undefined;
960 // forward the operation before queueing reactions
961 const result = target.delete(key);
962 if (hadKey) {
963 trigger(target, "delete" /* DELETE */, key, undefined, oldValue);
964 }
965 return result;
966}
967function clear() {
968 const target = toRaw(this);
969 const hadItems = target.size !== 0;
970 const oldTarget = isMap(target)
971 ? new Map(target)
972 : new Set(target)
973 ;
974 // forward the operation before queueing reactions
975 const result = target.clear();
976 if (hadItems) {
977 trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget);
978 }
979 return result;
980}
981function createForEach(isReadonly, isShallow) {
982 return function forEach(callback, thisArg) {
983 const observed = this;
984 const target = observed["__v_raw" /* RAW */];
985 const rawTarget = toRaw(target);
986 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
987 !isReadonly && track(rawTarget, "iterate" /* ITERATE */, ITERATE_KEY);
988 return target.forEach((value, key) => {
989 // important: make sure the callback is
990 // 1. invoked with the reactive map as `this` and 3rd arg
991 // 2. the value received should be a corresponding reactive/readonly.
992 return callback.call(thisArg, wrap(value), wrap(key), observed);
993 });
994 };
995}
996function createIterableMethod(method, isReadonly, isShallow) {
997 return function (...args) {
998 const target = this["__v_raw" /* RAW */];
999 const rawTarget = toRaw(target);
1000 const targetIsMap = isMap(rawTarget);
1001 const isPair = method === 'entries' || (method === Symbol.iterator && targetIsMap);
1002 const isKeyOnly = method === 'keys' && targetIsMap;
1003 const innerIterator = target[method](...args);
1004 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive;
1005 !isReadonly &&
1006 track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
1007 // return a wrapped iterator which returns observed versions of the
1008 // values emitted from the real iterator
1009 return {
1010 // iterator protocol
1011 next() {
1012 const { value, done } = innerIterator.next();
1013 return done
1014 ? { value, done }
1015 : {
1016 value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
1017 done
1018 };
1019 },
1020 // iterable protocol
1021 [Symbol.iterator]() {
1022 return this;
1023 }
1024 };
1025 };
1026}
1027function createReadonlyMethod(type) {
1028 return function (...args) {
1029 {
1030 const key = args[0] ? `on key "${args[0]}" ` : ``;
1031 console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
1032 }
1033 return type === "delete" /* DELETE */ ? false : this;
1034 };
1035}
1036function createInstrumentations() {
1037 const mutableInstrumentations = {
1038 get(key) {
1039 return get$1(this, key);
1040 },
1041 get size() {
1042 return size(this);
1043 },
1044 has: has$1,
1045 add,
1046 set: set$1,
1047 delete: deleteEntry,
1048 clear,
1049 forEach: createForEach(false, false)
1050 };
1051 const shallowInstrumentations = {
1052 get(key) {
1053 return get$1(this, key, false, true);
1054 },
1055 get size() {
1056 return size(this);
1057 },
1058 has: has$1,
1059 add,
1060 set: set$1,
1061 delete: deleteEntry,
1062 clear,
1063 forEach: createForEach(false, true)
1064 };
1065 const readonlyInstrumentations = {
1066 get(key) {
1067 return get$1(this, key, true);
1068 },
1069 get size() {
1070 return size(this, true);
1071 },
1072 has(key) {
1073 return has$1.call(this, key, true);
1074 },
1075 add: createReadonlyMethod("add" /* ADD */),
1076 set: createReadonlyMethod("set" /* SET */),
1077 delete: createReadonlyMethod("delete" /* DELETE */),
1078 clear: createReadonlyMethod("clear" /* CLEAR */),
1079 forEach: createForEach(true, false)
1080 };
1081 const shallowReadonlyInstrumentations = {
1082 get(key) {
1083 return get$1(this, key, true, true);
1084 },
1085 get size() {
1086 return size(this, true);
1087 },
1088 has(key) {
1089 return has$1.call(this, key, true);
1090 },
1091 add: createReadonlyMethod("add" /* ADD */),
1092 set: createReadonlyMethod("set" /* SET */),
1093 delete: createReadonlyMethod("delete" /* DELETE */),
1094 clear: createReadonlyMethod("clear" /* CLEAR */),
1095 forEach: createForEach(true, true)
1096 };
1097 const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator];
1098 iteratorMethods.forEach(method => {
1099 mutableInstrumentations[method] = createIterableMethod(method, false, false);
1100 readonlyInstrumentations[method] = createIterableMethod(method, true, false);
1101 shallowInstrumentations[method] = createIterableMethod(method, false, true);
1102 shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true);
1103 });
1104 return [
1105 mutableInstrumentations,
1106 readonlyInstrumentations,
1107 shallowInstrumentations,
1108 shallowReadonlyInstrumentations
1109 ];
1110}
1111const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/ createInstrumentations();
1112function createInstrumentationGetter(isReadonly, shallow) {
1113 const instrumentations = shallow
1114 ? isReadonly
1115 ? shallowReadonlyInstrumentations
1116 : shallowInstrumentations
1117 : isReadonly
1118 ? readonlyInstrumentations
1119 : mutableInstrumentations;
1120 return (target, key, receiver) => {
1121 if (key === "__v_isReactive" /* IS_REACTIVE */) {
1122 return !isReadonly;
1123 }
1124 else if (key === "__v_isReadonly" /* IS_READONLY */) {
1125 return isReadonly;
1126 }
1127 else if (key === "__v_raw" /* RAW */) {
1128 return target;
1129 }
1130 return Reflect.get(hasOwn(instrumentations, key) && key in target
1131 ? instrumentations
1132 : target, key, receiver);
1133 };
1134}
1135const mutableCollectionHandlers = {
1136 get: /*#__PURE__*/ createInstrumentationGetter(false, false)
1137};
1138const shallowCollectionHandlers = {
1139 get: /*#__PURE__*/ createInstrumentationGetter(false, true)
1140};
1141const readonlyCollectionHandlers = {
1142 get: /*#__PURE__*/ createInstrumentationGetter(true, false)
1143};
1144const shallowReadonlyCollectionHandlers = {
1145 get: /*#__PURE__*/ createInstrumentationGetter(true, true)
1146};
1147function checkIdentityKeys(target, has, key) {
1148 const rawKey = toRaw(key);
1149 if (rawKey !== key && has.call(target, rawKey)) {
1150 const type = toRawType(target);
1151 console.warn(`Reactive ${type} contains both the raw and reactive ` +
1152 `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
1153 `which can lead to inconsistencies. ` +
1154 `Avoid differentiating between the raw and reactive versions ` +
1155 `of an object and only use the reactive version if possible.`);
1156 }
1157}
1158
1159const reactiveMap = new WeakMap();
1160const shallowReactiveMap = new WeakMap();
1161const readonlyMap = new WeakMap();
1162const shallowReadonlyMap = new WeakMap();
1163function targetTypeMap(rawType) {
1164 switch (rawType) {
1165 case 'Object':
1166 case 'Array':
1167 return 1 /* COMMON */;
1168 case 'Map':
1169 case 'Set':
1170 case 'WeakMap':
1171 case 'WeakSet':
1172 return 2 /* COLLECTION */;
1173 default:
1174 return 0 /* INVALID */;
1175 }
1176}
1177function getTargetType(value) {
1178 return value["__v_skip" /* SKIP */] || !Object.isExtensible(value)
1179 ? 0 /* INVALID */
1180 : targetTypeMap(toRawType(value));
1181}
1182function reactive(target) {
1183 // if trying to observe a readonly proxy, return the readonly version.
1184 if (isReadonly(target)) {
1185 return target;
1186 }
1187 return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
1188}
1189/**
1190 * Return a shallowly-reactive copy of the original object, where only the root
1191 * level properties are reactive. It also does not auto-unwrap refs (even at the
1192 * root level).
1193 */
1194function shallowReactive(target) {
1195 return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap);
1196}
1197/**
1198 * Creates a readonly copy of the original object. Note the returned copy is not
1199 * made reactive, but `readonly` can be called on an already reactive object.
1200 */
1201function readonly(target) {
1202 return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
1203}
1204/**
1205 * Returns a reactive-copy of the original object, where only the root level
1206 * properties are readonly, and does NOT unwrap refs nor recursively convert
1207 * returned properties.
1208 * This is used for creating the props proxy object for stateful components.
1209 */
1210function shallowReadonly(target) {
1211 return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap);
1212}
1213function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) {
1214 if (!isObject(target)) {
1215 {
1216 console.warn(`value cannot be made reactive: ${String(target)}`);
1217 }
1218 return target;
1219 }
1220 // target is already a Proxy, return it.
1221 // exception: calling readonly() on a reactive object
1222 if (target["__v_raw" /* RAW */] &&
1223 !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) {
1224 return target;
1225 }
1226 // target already has corresponding Proxy
1227 const existingProxy = proxyMap.get(target);
1228 if (existingProxy) {
1229 return existingProxy;
1230 }
1231 // only a whitelist of value types can be observed.
1232 const targetType = getTargetType(target);
1233 if (targetType === 0 /* INVALID */) {
1234 return target;
1235 }
1236 const proxy = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers);
1237 proxyMap.set(target, proxy);
1238 return proxy;
1239}
1240function isReactive(value) {
1241 if (isReadonly(value)) {
1242 return isReactive(value["__v_raw" /* RAW */]);
1243 }
1244 return !!(value && value["__v_isReactive" /* IS_REACTIVE */]);
1245}
1246function isReadonly(value) {
1247 return !!(value && value["__v_isReadonly" /* IS_READONLY */]);
1248}
1249function isShallow(value) {
1250 return !!(value && value["__v_isShallow" /* IS_SHALLOW */]);
1251}
1252function isProxy(value) {
1253 return isReactive(value) || isReadonly(value);
1254}
1255function toRaw(observed) {
1256 const raw = observed && observed["__v_raw" /* RAW */];
1257 return raw ? toRaw(raw) : observed;
1258}
1259function markRaw(value) {
1260 def(value, "__v_skip" /* SKIP */, true);
1261 return value;
1262}
1263const toReactive = (value) => isObject(value) ? reactive(value) : value;
1264const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1265
1266function trackRefValue(ref) {
1267 if (shouldTrack && activeEffect) {
1268 ref = toRaw(ref);
1269 {
1270 trackEffects(ref.dep || (ref.dep = createDep()), {
1271 target: ref,
1272 type: "get" /* GET */,
1273 key: 'value'
1274 });
1275 }
1276 }
1277}
1278function triggerRefValue(ref, newVal) {
1279 ref = toRaw(ref);
1280 if (ref.dep) {
1281 {
1282 triggerEffects(ref.dep, {
1283 target: ref,
1284 type: "set" /* SET */,
1285 key: 'value',
1286 newValue: newVal
1287 });
1288 }
1289 }
1290}
1291function isRef(r) {
1292 return !!(r && r.__v_isRef === true);
1293}
1294function ref(value) {
1295 return createRef(value, false);
1296}
1297function shallowRef(value) {
1298 return createRef(value, true);
1299}
1300function createRef(rawValue, shallow) {
1301 if (isRef(rawValue)) {
1302 return rawValue;
1303 }
1304 return new RefImpl(rawValue, shallow);
1305}
1306class RefImpl {
1307 constructor(value, __v_isShallow) {
1308 this.__v_isShallow = __v_isShallow;
1309 this.dep = undefined;
1310 this.__v_isRef = true;
1311 this._rawValue = __v_isShallow ? value : toRaw(value);
1312 this._value = __v_isShallow ? value : toReactive(value);
1313 }
1314 get value() {
1315 trackRefValue(this);
1316 return this._value;
1317 }
1318 set value(newVal) {
1319 newVal = this.__v_isShallow ? newVal : toRaw(newVal);
1320 if (hasChanged(newVal, this._rawValue)) {
1321 this._rawValue = newVal;
1322 this._value = this.__v_isShallow ? newVal : toReactive(newVal);
1323 triggerRefValue(this, newVal);
1324 }
1325 }
1326}
1327function triggerRef(ref) {
1328 triggerRefValue(ref, ref.value );
1329}
1330function unref(ref) {
1331 return isRef(ref) ? ref.value : ref;
1332}
1333const shallowUnwrapHandlers = {
1334 get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
1335 set: (target, key, value, receiver) => {
1336 const oldValue = target[key];
1337 if (isRef(oldValue) && !isRef(value)) {
1338 oldValue.value = value;
1339 return true;
1340 }
1341 else {
1342 return Reflect.set(target, key, value, receiver);
1343 }
1344 }
1345};
1346function proxyRefs(objectWithRefs) {
1347 return isReactive(objectWithRefs)
1348 ? objectWithRefs
1349 : new Proxy(objectWithRefs, shallowUnwrapHandlers);
1350}
1351class CustomRefImpl {
1352 constructor(factory) {
1353 this.dep = undefined;
1354 this.__v_isRef = true;
1355 const { get, set } = factory(() => trackRefValue(this), () => triggerRefValue(this));
1356 this._get = get;
1357 this._set = set;
1358 }
1359 get value() {
1360 return this._get();
1361 }
1362 set value(newVal) {
1363 this._set(newVal);
1364 }
1365}
1366function customRef(factory) {
1367 return new CustomRefImpl(factory);
1368}
1369function toRefs(object) {
1370 if (!isProxy(object)) {
1371 console.warn(`toRefs() expects a reactive object but received a plain one.`);
1372 }
1373 const ret = isArray(object) ? new Array(object.length) : {};
1374 for (const key in object) {
1375 ret[key] = toRef(object, key);
1376 }
1377 return ret;
1378}
1379class ObjectRefImpl {
1380 constructor(_object, _key, _defaultValue) {
1381 this._object = _object;
1382 this._key = _key;
1383 this._defaultValue = _defaultValue;
1384 this.__v_isRef = true;
1385 }
1386 get value() {
1387 const val = this._object[this._key];
1388 return val === undefined ? this._defaultValue : val;
1389 }
1390 set value(newVal) {
1391 this._object[this._key] = newVal;
1392 }
1393}
1394function toRef(object, key, defaultValue) {
1395 const val = object[key];
1396 return isRef(val)
1397 ? val
1398 : new ObjectRefImpl(object, key, defaultValue);
1399}
1400
1401class ComputedRefImpl {
1402 constructor(getter, _setter, isReadonly, isSSR) {
1403 this._setter = _setter;
1404 this.dep = undefined;
1405 this.__v_isRef = true;
1406 this._dirty = true;
1407 this.effect = new ReactiveEffect(getter, () => {
1408 if (!this._dirty) {
1409 this._dirty = true;
1410 triggerRefValue(this);
1411 }
1412 });
1413 this.effect.computed = this;
1414 this.effect.active = this._cacheable = !isSSR;
1415 this["__v_isReadonly" /* IS_READONLY */] = isReadonly;
1416 }
1417 get value() {
1418 // the computed ref may get wrapped by other proxies e.g. readonly() #3376
1419 const self = toRaw(this);
1420 trackRefValue(self);
1421 if (self._dirty || !self._cacheable) {
1422 self._dirty = false;
1423 self._value = self.effect.run();
1424 }
1425 return self._value;
1426 }
1427 set value(newValue) {
1428 this._setter(newValue);
1429 }
1430}
1431function computed(getterOrOptions, debugOptions, isSSR = false) {
1432 let getter;
1433 let setter;
1434 const onlyGetter = isFunction(getterOrOptions);
1435 if (onlyGetter) {
1436 getter = getterOrOptions;
1437 setter = () => {
1438 console.warn('Write operation failed: computed value is readonly');
1439 }
1440 ;
1441 }
1442 else {
1443 getter = getterOrOptions.get;
1444 setter = getterOrOptions.set;
1445 }
1446 const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1447 if (debugOptions && !isSSR) {
1448 cRef.effect.onTrack = debugOptions.onTrack;
1449 cRef.effect.onTrigger = debugOptions.onTrigger;
1450 }
1451 return cRef;
1452}
1453
1454const stack = [];
1455function pushWarningContext(vnode) {
1456 stack.push(vnode);
1457}
1458function popWarningContext() {
1459 stack.pop();
1460}
1461function warn$1(msg, ...args) {
1462 // avoid props formatting or warn handler tracking deps that might be mutated
1463 // during patch, leading to infinite recursion.
1464 pauseTracking();
1465 const instance = stack.length ? stack[stack.length - 1].component : null;
1466 const appWarnHandler = instance && instance.appContext.config.warnHandler;
1467 const trace = getComponentTrace();
1468 if (appWarnHandler) {
1469 callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
1470 msg + args.join(''),
1471 instance && instance.proxy,
1472 trace
1473 .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`)
1474 .join('\n'),
1475 trace
1476 ]);
1477 }
1478 else {
1479 const warnArgs = [`[Vue warn]: ${msg}`, ...args];
1480 /* istanbul ignore if */
1481 if (trace.length &&
1482 // avoid spamming console during tests
1483 !false) {
1484 warnArgs.push(`\n`, ...formatTrace(trace));
1485 }
1486 console.warn(...warnArgs);
1487 }
1488 resetTracking();
1489}
1490function getComponentTrace() {
1491 let currentVNode = stack[stack.length - 1];
1492 if (!currentVNode) {
1493 return [];
1494 }
1495 // we can't just use the stack because it will be incomplete during updates
1496 // that did not start from the root. Re-construct the parent chain using
1497 // instance parent pointers.
1498 const normalizedStack = [];
1499 while (currentVNode) {
1500 const last = normalizedStack[0];
1501 if (last && last.vnode === currentVNode) {
1502 last.recurseCount++;
1503 }
1504 else {
1505 normalizedStack.push({
1506 vnode: currentVNode,
1507 recurseCount: 0
1508 });
1509 }
1510 const parentInstance = currentVNode.component && currentVNode.component.parent;
1511 currentVNode = parentInstance && parentInstance.vnode;
1512 }
1513 return normalizedStack;
1514}
1515/* istanbul ignore next */
1516function formatTrace(trace) {
1517 const logs = [];
1518 trace.forEach((entry, i) => {
1519 logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry));
1520 });
1521 return logs;
1522}
1523function formatTraceEntry({ vnode, recurseCount }) {
1524 const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
1525 const isRoot = vnode.component ? vnode.component.parent == null : false;
1526 const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`;
1527 const close = `>` + postfix;
1528 return vnode.props
1529 ? [open, ...formatProps(vnode.props), close]
1530 : [open + close];
1531}
1532/* istanbul ignore next */
1533function formatProps(props) {
1534 const res = [];
1535 const keys = Object.keys(props);
1536 keys.slice(0, 3).forEach(key => {
1537 res.push(...formatProp(key, props[key]));
1538 });
1539 if (keys.length > 3) {
1540 res.push(` ...`);
1541 }
1542 return res;
1543}
1544/* istanbul ignore next */
1545function formatProp(key, value, raw) {
1546 if (isString(value)) {
1547 value = JSON.stringify(value);
1548 return raw ? value : [`${key}=${value}`];
1549 }
1550 else if (typeof value === 'number' ||
1551 typeof value === 'boolean' ||
1552 value == null) {
1553 return raw ? value : [`${key}=${value}`];
1554 }
1555 else if (isRef(value)) {
1556 value = formatProp(key, toRaw(value.value), true);
1557 return raw ? value : [`${key}=Ref<`, value, `>`];
1558 }
1559 else if (isFunction(value)) {
1560 return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
1561 }
1562 else {
1563 value = toRaw(value);
1564 return raw ? value : [`${key}=`, value];
1565 }
1566}
1567
1568const ErrorTypeStrings = {
1569 ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
1570 ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
1571 ["c" /* CREATED */]: 'created hook',
1572 ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
1573 ["m" /* MOUNTED */]: 'mounted hook',
1574 ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
1575 ["u" /* UPDATED */]: 'updated',
1576 ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
1577 ["um" /* UNMOUNTED */]: 'unmounted hook',
1578 ["a" /* ACTIVATED */]: 'activated hook',
1579 ["da" /* DEACTIVATED */]: 'deactivated hook',
1580 ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
1581 ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
1582 ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
1583 [0 /* SETUP_FUNCTION */]: 'setup function',
1584 [1 /* RENDER_FUNCTION */]: 'render function',
1585 [2 /* WATCH_GETTER */]: 'watcher getter',
1586 [3 /* WATCH_CALLBACK */]: 'watcher callback',
1587 [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
1588 [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
1589 [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
1590 [7 /* VNODE_HOOK */]: 'vnode hook',
1591 [8 /* DIRECTIVE_HOOK */]: 'directive hook',
1592 [9 /* TRANSITION_HOOK */]: 'transition hook',
1593 [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
1594 [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
1595 [12 /* FUNCTION_REF */]: 'ref function',
1596 [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
1597 [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
1598 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
1599};
1600function callWithErrorHandling(fn, instance, type, args) {
1601 let res;
1602 try {
1603 res = args ? fn(...args) : fn();
1604 }
1605 catch (err) {
1606 handleError(err, instance, type);
1607 }
1608 return res;
1609}
1610function callWithAsyncErrorHandling(fn, instance, type, args) {
1611 if (isFunction(fn)) {
1612 const res = callWithErrorHandling(fn, instance, type, args);
1613 if (res && isPromise(res)) {
1614 res.catch(err => {
1615 handleError(err, instance, type);
1616 });
1617 }
1618 return res;
1619 }
1620 const values = [];
1621 for (let i = 0; i < fn.length; i++) {
1622 values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
1623 }
1624 return values;
1625}
1626function handleError(err, instance, type, throwInDev = true) {
1627 const contextVNode = instance ? instance.vnode : null;
1628 if (instance) {
1629 let cur = instance.parent;
1630 // the exposed instance is the render proxy to keep it consistent with 2.x
1631 const exposedInstance = instance.proxy;
1632 // in production the hook receives only the error code
1633 const errorInfo = ErrorTypeStrings[type] ;
1634 while (cur) {
1635 const errorCapturedHooks = cur.ec;
1636 if (errorCapturedHooks) {
1637 for (let i = 0; i < errorCapturedHooks.length; i++) {
1638 if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
1639 return;
1640 }
1641 }
1642 }
1643 cur = cur.parent;
1644 }
1645 // app-level handling
1646 const appErrorHandler = instance.appContext.config.errorHandler;
1647 if (appErrorHandler) {
1648 callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
1649 return;
1650 }
1651 }
1652 logError(err, type, contextVNode, throwInDev);
1653}
1654function logError(err, type, contextVNode, throwInDev = true) {
1655 {
1656 const info = ErrorTypeStrings[type];
1657 if (contextVNode) {
1658 pushWarningContext(contextVNode);
1659 }
1660 warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
1661 if (contextVNode) {
1662 popWarningContext();
1663 }
1664 // crash in dev by default so it's more noticeable
1665 if (throwInDev) {
1666 throw err;
1667 }
1668 else {
1669 console.error(err);
1670 }
1671 }
1672}
1673
1674let isFlushing = false;
1675let isFlushPending = false;
1676const queue = [];
1677let flushIndex = 0;
1678const pendingPreFlushCbs = [];
1679let activePreFlushCbs = null;
1680let preFlushIndex = 0;
1681const pendingPostFlushCbs = [];
1682let activePostFlushCbs = null;
1683let postFlushIndex = 0;
1684const resolvedPromise = Promise.resolve();
1685let currentFlushPromise = null;
1686let currentPreFlushParentJob = null;
1687const RECURSION_LIMIT = 100;
1688function nextTick(fn) {
1689 const p = currentFlushPromise || resolvedPromise;
1690 return fn ? p.then(this ? fn.bind(this) : fn) : p;
1691}
1692// #2768
1693// Use binary-search to find a suitable position in the queue,
1694// so that the queue maintains the increasing order of job's id,
1695// which can prevent the job from being skipped and also can avoid repeated patching.
1696function findInsertionIndex(id) {
1697 // the start index should be `flushIndex + 1`
1698 let start = flushIndex + 1;
1699 let end = queue.length;
1700 while (start < end) {
1701 const middle = (start + end) >>> 1;
1702 const middleJobId = getId(queue[middle]);
1703 middleJobId < id ? (start = middle + 1) : (end = middle);
1704 }
1705 return start;
1706}
1707function queueJob(job) {
1708 // the dedupe search uses the startIndex argument of Array.includes()
1709 // by default the search index includes the current job that is being run
1710 // so it cannot recursively trigger itself again.
1711 // if the job is a watch() callback, the search will start with a +1 index to
1712 // allow it recursively trigger itself - it is the user's responsibility to
1713 // ensure it doesn't end up in an infinite loop.
1714 if ((!queue.length ||
1715 !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) &&
1716 job !== currentPreFlushParentJob) {
1717 if (job.id == null) {
1718 queue.push(job);
1719 }
1720 else {
1721 queue.splice(findInsertionIndex(job.id), 0, job);
1722 }
1723 queueFlush();
1724 }
1725}
1726function queueFlush() {
1727 if (!isFlushing && !isFlushPending) {
1728 isFlushPending = true;
1729 currentFlushPromise = resolvedPromise.then(flushJobs);
1730 }
1731}
1732function invalidateJob(job) {
1733 const i = queue.indexOf(job);
1734 if (i > flushIndex) {
1735 queue.splice(i, 1);
1736 }
1737}
1738function queueCb(cb, activeQueue, pendingQueue, index) {
1739 if (!isArray(cb)) {
1740 if (!activeQueue ||
1741 !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) {
1742 pendingQueue.push(cb);
1743 }
1744 }
1745 else {
1746 // if cb is an array, it is a component lifecycle hook which can only be
1747 // triggered by a job, which is already deduped in the main queue, so
1748 // we can skip duplicate check here to improve perf
1749 pendingQueue.push(...cb);
1750 }
1751 queueFlush();
1752}
1753function queuePreFlushCb(cb) {
1754 queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex);
1755}
1756function queuePostFlushCb(cb) {
1757 queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex);
1758}
1759function flushPreFlushCbs(seen, parentJob = null) {
1760 if (pendingPreFlushCbs.length) {
1761 currentPreFlushParentJob = parentJob;
1762 activePreFlushCbs = [...new Set(pendingPreFlushCbs)];
1763 pendingPreFlushCbs.length = 0;
1764 {
1765 seen = seen || new Map();
1766 }
1767 for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) {
1768 if (checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex])) {
1769 continue;
1770 }
1771 activePreFlushCbs[preFlushIndex]();
1772 }
1773 activePreFlushCbs = null;
1774 preFlushIndex = 0;
1775 currentPreFlushParentJob = null;
1776 // recursively flush until it drains
1777 flushPreFlushCbs(seen, parentJob);
1778 }
1779}
1780function flushPostFlushCbs(seen) {
1781 if (pendingPostFlushCbs.length) {
1782 const deduped = [...new Set(pendingPostFlushCbs)];
1783 pendingPostFlushCbs.length = 0;
1784 // #1947 already has active queue, nested flushPostFlushCbs call
1785 if (activePostFlushCbs) {
1786 activePostFlushCbs.push(...deduped);
1787 return;
1788 }
1789 activePostFlushCbs = deduped;
1790 {
1791 seen = seen || new Map();
1792 }
1793 activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
1794 for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
1795 if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
1796 continue;
1797 }
1798 activePostFlushCbs[postFlushIndex]();
1799 }
1800 activePostFlushCbs = null;
1801 postFlushIndex = 0;
1802 }
1803}
1804const getId = (job) => job.id == null ? Infinity : job.id;
1805function flushJobs(seen) {
1806 isFlushPending = false;
1807 isFlushing = true;
1808 {
1809 seen = seen || new Map();
1810 }
1811 flushPreFlushCbs(seen);
1812 // Sort queue before flush.
1813 // This ensures that:
1814 // 1. Components are updated from parent to child. (because parent is always
1815 // created before the child so its render effect will have smaller
1816 // priority number)
1817 // 2. If a component is unmounted during a parent component's update,
1818 // its update can be skipped.
1819 queue.sort((a, b) => getId(a) - getId(b));
1820 // conditional usage of checkRecursiveUpdate must be determined out of
1821 // try ... catch block since Rollup by default de-optimizes treeshaking
1822 // inside try-catch. This can leave all warning code unshaked. Although
1823 // they would get eventually shaken by a minifier like terser, some minifiers
1824 // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
1825 const check = (job) => checkRecursiveUpdates(seen, job)
1826 ;
1827 try {
1828 for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1829 const job = queue[flushIndex];
1830 if (job && job.active !== false) {
1831 if (true && check(job)) {
1832 continue;
1833 }
1834 // console.log(`running:`, job.id)
1835 callWithErrorHandling(job, null, 14 /* SCHEDULER */);
1836 }
1837 }
1838 }
1839 finally {
1840 flushIndex = 0;
1841 queue.length = 0;
1842 flushPostFlushCbs(seen);
1843 isFlushing = false;
1844 currentFlushPromise = null;
1845 // some postFlushCb queued jobs!
1846 // keep flushing until it drains.
1847 if (queue.length ||
1848 pendingPreFlushCbs.length ||
1849 pendingPostFlushCbs.length) {
1850 flushJobs(seen);
1851 }
1852 }
1853}
1854function checkRecursiveUpdates(seen, fn) {
1855 if (!seen.has(fn)) {
1856 seen.set(fn, 1);
1857 }
1858 else {
1859 const count = seen.get(fn);
1860 if (count > RECURSION_LIMIT) {
1861 const instance = fn.ownerInstance;
1862 const componentName = instance && getComponentName(instance.type);
1863 warn$1(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
1864 `This means you have a reactive effect that is mutating its own ` +
1865 `dependencies and thus recursively triggering itself. Possible sources ` +
1866 `include component template, render function, updated hook or ` +
1867 `watcher source function.`);
1868 return true;
1869 }
1870 else {
1871 seen.set(fn, count + 1);
1872 }
1873 }
1874}
1875
1876/* eslint-disable no-restricted-globals */
1877let isHmrUpdating = false;
1878const hmrDirtyComponents = new Set();
1879// Expose the HMR runtime on the global object
1880// This makes it entirely tree-shakable without polluting the exports and makes
1881// it easier to be used in toolings like vue-loader
1882// Note: for a component to be eligible for HMR it also needs the __hmrId option
1883// to be set so that its instances can be registered / removed.
1884{
1885 getGlobalThis().__VUE_HMR_RUNTIME__ = {
1886 createRecord: tryWrap(createRecord),
1887 rerender: tryWrap(rerender),
1888 reload: tryWrap(reload)
1889 };
1890}
1891const map = new Map();
1892function registerHMR(instance) {
1893 const id = instance.type.__hmrId;
1894 let record = map.get(id);
1895 if (!record) {
1896 createRecord(id, instance.type);
1897 record = map.get(id);
1898 }
1899 record.instances.add(instance);
1900}
1901function unregisterHMR(instance) {
1902 map.get(instance.type.__hmrId).instances.delete(instance);
1903}
1904function createRecord(id, initialDef) {
1905 if (map.has(id)) {
1906 return false;
1907 }
1908 map.set(id, {
1909 initialDef: normalizeClassComponent(initialDef),
1910 instances: new Set()
1911 });
1912 return true;
1913}
1914function normalizeClassComponent(component) {
1915 return isClassComponent(component) ? component.__vccOpts : component;
1916}
1917function rerender(id, newRender) {
1918 const record = map.get(id);
1919 if (!record) {
1920 return;
1921 }
1922 // update initial record (for not-yet-rendered component)
1923 record.initialDef.render = newRender;
1924 [...record.instances].forEach(instance => {
1925 if (newRender) {
1926 instance.render = newRender;
1927 normalizeClassComponent(instance.type).render = newRender;
1928 }
1929 instance.renderCache = [];
1930 // this flag forces child components with slot content to update
1931 isHmrUpdating = true;
1932 instance.update();
1933 isHmrUpdating = false;
1934 });
1935}
1936function reload(id, newComp) {
1937 const record = map.get(id);
1938 if (!record)
1939 return;
1940 newComp = normalizeClassComponent(newComp);
1941 // update initial def (for not-yet-rendered components)
1942 updateComponentDef(record.initialDef, newComp);
1943 // create a snapshot which avoids the set being mutated during updates
1944 const instances = [...record.instances];
1945 for (const instance of instances) {
1946 const oldComp = normalizeClassComponent(instance.type);
1947 if (!hmrDirtyComponents.has(oldComp)) {
1948 // 1. Update existing comp definition to match new one
1949 if (oldComp !== record.initialDef) {
1950 updateComponentDef(oldComp, newComp);
1951 }
1952 // 2. mark definition dirty. This forces the renderer to replace the
1953 // component on patch.
1954 hmrDirtyComponents.add(oldComp);
1955 }
1956 // 3. invalidate options resolution cache
1957 instance.appContext.optionsCache.delete(instance.type);
1958 // 4. actually update
1959 if (instance.ceReload) {
1960 // custom element
1961 hmrDirtyComponents.add(oldComp);
1962 instance.ceReload(newComp.styles);
1963 hmrDirtyComponents.delete(oldComp);
1964 }
1965 else if (instance.parent) {
1966 // 4. Force the parent instance to re-render. This will cause all updated
1967 // components to be unmounted and re-mounted. Queue the update so that we
1968 // don't end up forcing the same parent to re-render multiple times.
1969 queueJob(instance.parent.update);
1970 // instance is the inner component of an async custom element
1971 // invoke to reset styles
1972 if (instance.parent.type.__asyncLoader &&
1973 instance.parent.ceReload) {
1974 instance.parent.ceReload(newComp.styles);
1975 }
1976 }
1977 else if (instance.appContext.reload) {
1978 // root instance mounted via createApp() has a reload method
1979 instance.appContext.reload();
1980 }
1981 else if (typeof window !== 'undefined') {
1982 // root instance inside tree created via raw render(). Force reload.
1983 window.location.reload();
1984 }
1985 else {
1986 console.warn('[HMR] Root or manually mounted instance modified. Full reload required.');
1987 }
1988 }
1989 // 5. make sure to cleanup dirty hmr components after update
1990 queuePostFlushCb(() => {
1991 for (const instance of instances) {
1992 hmrDirtyComponents.delete(normalizeClassComponent(instance.type));
1993 }
1994 });
1995}
1996function updateComponentDef(oldComp, newComp) {
1997 extend(oldComp, newComp);
1998 for (const key in oldComp) {
1999 if (key !== '__file' && !(key in newComp)) {
2000 delete oldComp[key];
2001 }
2002 }
2003}
2004function tryWrap(fn) {
2005 return (id, arg) => {
2006 try {
2007 return fn(id, arg);
2008 }
2009 catch (e) {
2010 console.error(e);
2011 console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` +
2012 `Full reload required.`);
2013 }
2014 };
2015}
2016
2017let devtools;
2018let buffer = [];
2019let devtoolsNotInstalled = false;
2020function emit(event, ...args) {
2021 if (devtools) {
2022 devtools.emit(event, ...args);
2023 }
2024 else if (!devtoolsNotInstalled) {
2025 buffer.push({ event, args });
2026 }
2027}
2028function setDevtoolsHook(hook, target) {
2029 var _a, _b;
2030 devtools = hook;
2031 if (devtools) {
2032 devtools.enabled = true;
2033 buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
2034 buffer = [];
2035 }
2036 else if (
2037 // handle late devtools injection - only do this if we are in an actual
2038 // browser environment to avoid the timer handle stalling test runner exit
2039 // (#4815)
2040 // eslint-disable-next-line no-restricted-globals
2041 typeof window !== 'undefined' &&
2042 // some envs mock window but not fully
2043 window.HTMLElement &&
2044 // also exclude jsdom
2045 !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
2046 const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
2047 target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
2048 replay.push((newHook) => {
2049 setDevtoolsHook(newHook, target);
2050 });
2051 // clear buffer after 3s - the user probably doesn't have devtools installed
2052 // at all, and keeping the buffer will cause memory leaks (#4738)
2053 setTimeout(() => {
2054 if (!devtools) {
2055 target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
2056 devtoolsNotInstalled = true;
2057 buffer = [];
2058 }
2059 }, 3000);
2060 }
2061 else {
2062 // non-browser env, assume not installed
2063 devtoolsNotInstalled = true;
2064 buffer = [];
2065 }
2066}
2067function devtoolsInitApp(app, version) {
2068 emit("app:init" /* APP_INIT */, app, version, {
2069 Fragment,
2070 Text,
2071 Comment,
2072 Static
2073 });
2074}
2075function devtoolsUnmountApp(app) {
2076 emit("app:unmount" /* APP_UNMOUNT */, app);
2077}
2078const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
2079const devtoolsComponentUpdated =
2080/*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);
2081const devtoolsComponentRemoved =
2082/*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
2083function createDevtoolsComponentHook(hook) {
2084 return (component) => {
2085 emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
2086 };
2087}
2088const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
2089const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
2090function createDevtoolsPerformanceHook(hook) {
2091 return (component, type, time) => {
2092 emit(hook, component.appContext.app, component.uid, component, type, time);
2093 };
2094}
2095function devtoolsComponentEmit(component, event, params) {
2096 emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
2097}
2098
2099function emit$1(instance, event, ...rawArgs) {
2100 const props = instance.vnode.props || EMPTY_OBJ;
2101 {
2102 const { emitsOptions, propsOptions: [propsOptions] } = instance;
2103 if (emitsOptions) {
2104 if (!(event in emitsOptions) &&
2105 !(false )) {
2106 if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
2107 warn$1(`Component emitted event "${event}" but it is neither declared in ` +
2108 `the emits option nor as an "${toHandlerKey(event)}" prop.`);
2109 }
2110 }
2111 else {
2112 const validator = emitsOptions[event];
2113 if (isFunction(validator)) {
2114 const isValid = validator(...rawArgs);
2115 if (!isValid) {
2116 warn$1(`Invalid event arguments: event validation failed for event "${event}".`);
2117 }
2118 }
2119 }
2120 }
2121 }
2122 let args = rawArgs;
2123 const isModelListener = event.startsWith('update:');
2124 // for v-model update:xxx events, apply modifiers on args
2125 const modelArg = isModelListener && event.slice(7);
2126 if (modelArg && modelArg in props) {
2127 const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
2128 const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
2129 if (trim) {
2130 args = rawArgs.map(a => a.trim());
2131 }
2132 else if (number) {
2133 args = rawArgs.map(toNumber);
2134 }
2135 }
2136 {
2137 devtoolsComponentEmit(instance, event, args);
2138 }
2139 {
2140 const lowerCaseEvent = event.toLowerCase();
2141 if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
2142 warn$1(`Event "${lowerCaseEvent}" is emitted in component ` +
2143 `${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". ` +
2144 `Note that HTML attributes are case-insensitive and you cannot use ` +
2145 `v-on to listen to camelCase events when using in-DOM templates. ` +
2146 `You should probably use "${hyphenate(event)}" instead of "${event}".`);
2147 }
2148 }
2149 let handlerName;
2150 let handler = props[(handlerName = toHandlerKey(event))] ||
2151 // also try camelCase event handler (#2249)
2152 props[(handlerName = toHandlerKey(camelize(event)))];
2153 // for v-model update:xxx events, also trigger kebab-case equivalent
2154 // for props passed via kebab-case
2155 if (!handler && isModelListener) {
2156 handler = props[(handlerName = toHandlerKey(hyphenate(event)))];
2157 }
2158 if (handler) {
2159 callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
2160 }
2161 const onceHandler = props[handlerName + `Once`];
2162 if (onceHandler) {
2163 if (!instance.emitted) {
2164 instance.emitted = {};
2165 }
2166 else if (instance.emitted[handlerName]) {
2167 return;
2168 }
2169 instance.emitted[handlerName] = true;
2170 callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
2171 }
2172}
2173function normalizeEmitsOptions(comp, appContext, asMixin = false) {
2174 const cache = appContext.emitsCache;
2175 const cached = cache.get(comp);
2176 if (cached !== undefined) {
2177 return cached;
2178 }
2179 const raw = comp.emits;
2180 let normalized = {};
2181 // apply mixin/extends props
2182 let hasExtends = false;
2183 if (!isFunction(comp)) {
2184 const extendEmits = (raw) => {
2185 const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);
2186 if (normalizedFromExtend) {
2187 hasExtends = true;
2188 extend(normalized, normalizedFromExtend);
2189 }
2190 };
2191 if (!asMixin && appContext.mixins.length) {
2192 appContext.mixins.forEach(extendEmits);
2193 }
2194 if (comp.extends) {
2195 extendEmits(comp.extends);
2196 }
2197 if (comp.mixins) {
2198 comp.mixins.forEach(extendEmits);
2199 }
2200 }
2201 if (!raw && !hasExtends) {
2202 cache.set(comp, null);
2203 return null;
2204 }
2205 if (isArray(raw)) {
2206 raw.forEach(key => (normalized[key] = null));
2207 }
2208 else {
2209 extend(normalized, raw);
2210 }
2211 cache.set(comp, normalized);
2212 return normalized;
2213}
2214// Check if an incoming prop key is a declared emit event listener.
2215// e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
2216// both considered matched listeners.
2217function isEmitListener(options, key) {
2218 if (!options || !isOn(key)) {
2219 return false;
2220 }
2221 key = key.slice(2).replace(/Once$/, '');
2222 return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||
2223 hasOwn(options, hyphenate(key)) ||
2224 hasOwn(options, key));
2225}
2226
2227/**
2228 * mark the current rendering instance for asset resolution (e.g.
2229 * resolveComponent, resolveDirective) during render
2230 */
2231let currentRenderingInstance = null;
2232let currentScopeId = null;
2233/**
2234 * Note: rendering calls maybe nested. The function returns the parent rendering
2235 * instance if present, which should be restored after the render is done:
2236 *
2237 * ```js
2238 * const prev = setCurrentRenderingInstance(i)
2239 * // ...render
2240 * setCurrentRenderingInstance(prev)
2241 * ```
2242 */
2243function setCurrentRenderingInstance(instance) {
2244 const prev = currentRenderingInstance;
2245 currentRenderingInstance = instance;
2246 currentScopeId = (instance && instance.type.__scopeId) || null;
2247 return prev;
2248}
2249/**
2250 * Set scope id when creating hoisted vnodes.
2251 * @private compiler helper
2252 */
2253function pushScopeId(id) {
2254 currentScopeId = id;
2255}
2256/**
2257 * Technically we no longer need this after 3.0.8 but we need to keep the same
2258 * API for backwards compat w/ code generated by compilers.
2259 * @private
2260 */
2261function popScopeId() {
2262 currentScopeId = null;
2263}
2264/**
2265 * Only for backwards compat
2266 * @private
2267 */
2268const withScopeId = (_id) => withCtx;
2269/**
2270 * Wrap a slot function to memoize current rendering instance
2271 * @private compiler helper
2272 */
2273function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only
2274) {
2275 if (!ctx)
2276 return fn;
2277 // already normalized
2278 if (fn._n) {
2279 return fn;
2280 }
2281 const renderFnWithContext = (...args) => {
2282 // If a user calls a compiled slot inside a template expression (#1745), it
2283 // can mess up block tracking, so by default we disable block tracking and
2284 // force bail out when invoking a compiled slot (indicated by the ._d flag).
2285 // This isn't necessary if rendering a compiled `<slot>`, so we flip the
2286 // ._d flag off when invoking the wrapped fn inside `renderSlot`.
2287 if (renderFnWithContext._d) {
2288 setBlockTracking(-1);
2289 }
2290 const prevInstance = setCurrentRenderingInstance(ctx);
2291 const res = fn(...args);
2292 setCurrentRenderingInstance(prevInstance);
2293 if (renderFnWithContext._d) {
2294 setBlockTracking(1);
2295 }
2296 {
2297 devtoolsComponentUpdated(ctx);
2298 }
2299 return res;
2300 };
2301 // mark normalized to avoid duplicated wrapping
2302 renderFnWithContext._n = true;
2303 // mark this as compiled by default
2304 // this is used in vnode.ts -> normalizeChildren() to set the slot
2305 // rendering flag.
2306 renderFnWithContext._c = true;
2307 // disable block tracking by default
2308 renderFnWithContext._d = true;
2309 return renderFnWithContext;
2310}
2311
2312/**
2313 * dev only flag to track whether $attrs was used during render.
2314 * If $attrs was used during render then the warning for failed attrs
2315 * fallthrough can be suppressed.
2316 */
2317let accessedAttrs = false;
2318function markAttrsAccessed() {
2319 accessedAttrs = true;
2320}
2321function renderComponentRoot(instance) {
2322 const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2323 let result;
2324 let fallthroughAttrs;
2325 const prev = setCurrentRenderingInstance(instance);
2326 {
2327 accessedAttrs = false;
2328 }
2329 try {
2330 if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
2331 // withProxy is a proxy with a different `has` trap only for
2332 // runtime-compiled render functions using `with` block.
2333 const proxyToUse = withProxy || proxy;
2334 result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
2335 fallthroughAttrs = attrs;
2336 }
2337 else {
2338 // functional
2339 const render = Component;
2340 // in dev, mark attrs accessed if optional props (attrs === props)
2341 if (true && attrs === props) {
2342 markAttrsAccessed();
2343 }
2344 result = normalizeVNode(render.length > 1
2345 ? render(props, true
2346 ? {
2347 get attrs() {
2348 markAttrsAccessed();
2349 return attrs;
2350 },
2351 slots,
2352 emit
2353 }
2354 : { attrs, slots, emit })
2355 : render(props, null /* we know it doesn't need it */));
2356 fallthroughAttrs = Component.props
2357 ? attrs
2358 : getFunctionalFallthrough(attrs);
2359 }
2360 }
2361 catch (err) {
2362 blockStack.length = 0;
2363 handleError(err, instance, 1 /* RENDER_FUNCTION */);
2364 result = createVNode(Comment);
2365 }
2366 // attr merging
2367 // in dev mode, comments are preserved, and it's possible for a template
2368 // to have comments along side the root element which makes it a fragment
2369 let root = result;
2370 let setRoot = undefined;
2371 if (result.patchFlag > 0 &&
2372 result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
2373 [root, setRoot] = getChildRoot(result);
2374 }
2375 if (fallthroughAttrs && inheritAttrs !== false) {
2376 const keys = Object.keys(fallthroughAttrs);
2377 const { shapeFlag } = root;
2378 if (keys.length) {
2379 if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
2380 if (propsOptions && keys.some(isModelListener)) {
2381 // If a v-model listener (onUpdate:xxx) has a corresponding declared
2382 // prop, it indicates this component expects to handle v-model and
2383 // it should not fallthrough.
2384 // related: #1543, #1643, #1989
2385 fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
2386 }
2387 root = cloneVNode(root, fallthroughAttrs);
2388 }
2389 else if (!accessedAttrs && root.type !== Comment) {
2390 const allAttrs = Object.keys(attrs);
2391 const eventAttrs = [];
2392 const extraAttrs = [];
2393 for (let i = 0, l = allAttrs.length; i < l; i++) {
2394 const key = allAttrs[i];
2395 if (isOn(key)) {
2396 // ignore v-model handlers when they fail to fallthrough
2397 if (!isModelListener(key)) {
2398 // remove `on`, lowercase first letter to reflect event casing
2399 // accurately
2400 eventAttrs.push(key[2].toLowerCase() + key.slice(3));
2401 }
2402 }
2403 else {
2404 extraAttrs.push(key);
2405 }
2406 }
2407 if (extraAttrs.length) {
2408 warn$1(`Extraneous non-props attributes (` +
2409 `${extraAttrs.join(', ')}) ` +
2410 `were passed to component but could not be automatically inherited ` +
2411 `because component renders fragment or text root nodes.`);
2412 }
2413 if (eventAttrs.length) {
2414 warn$1(`Extraneous non-emits event listeners (` +
2415 `${eventAttrs.join(', ')}) ` +
2416 `were passed to component but could not be automatically inherited ` +
2417 `because component renders fragment or text root nodes. ` +
2418 `If the listener is intended to be a component custom event listener only, ` +
2419 `declare it using the "emits" option.`);
2420 }
2421 }
2422 }
2423 }
2424 // inherit directives
2425 if (vnode.dirs) {
2426 if (!isElementRoot(root)) {
2427 warn$1(`Runtime directive used on component with non-element root node. ` +
2428 `The directives will not function as intended.`);
2429 }
2430 root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
2431 }
2432 // inherit transition data
2433 if (vnode.transition) {
2434 if (!isElementRoot(root)) {
2435 warn$1(`Component inside <Transition> renders non-element root node ` +
2436 `that cannot be animated.`);
2437 }
2438 root.transition = vnode.transition;
2439 }
2440 if (setRoot) {
2441 setRoot(root);
2442 }
2443 else {
2444 result = root;
2445 }
2446 setCurrentRenderingInstance(prev);
2447 return result;
2448}
2449/**
2450 * dev only
2451 * In dev mode, template root level comments are rendered, which turns the
2452 * template into a fragment root, but we need to locate the single element
2453 * root for attrs and scope id processing.
2454 */
2455const getChildRoot = (vnode) => {
2456 const rawChildren = vnode.children;
2457 const dynamicChildren = vnode.dynamicChildren;
2458 const childRoot = filterSingleRoot(rawChildren);
2459 if (!childRoot) {
2460 return [vnode, undefined];
2461 }
2462 const index = rawChildren.indexOf(childRoot);
2463 const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
2464 const setRoot = (updatedRoot) => {
2465 rawChildren[index] = updatedRoot;
2466 if (dynamicChildren) {
2467 if (dynamicIndex > -1) {
2468 dynamicChildren[dynamicIndex] = updatedRoot;
2469 }
2470 else if (updatedRoot.patchFlag > 0) {
2471 vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
2472 }
2473 }
2474 };
2475 return [normalizeVNode(childRoot), setRoot];
2476};
2477function filterSingleRoot(children) {
2478 let singleRoot;
2479 for (let i = 0; i < children.length; i++) {
2480 const child = children[i];
2481 if (isVNode(child)) {
2482 // ignore user comment
2483 if (child.type !== Comment || child.children === 'v-if') {
2484 if (singleRoot) {
2485 // has more than 1 non-comment child, return now
2486 return;
2487 }
2488 else {
2489 singleRoot = child;
2490 }
2491 }
2492 }
2493 else {
2494 return;
2495 }
2496 }
2497 return singleRoot;
2498}
2499const getFunctionalFallthrough = (attrs) => {
2500 let res;
2501 for (const key in attrs) {
2502 if (key === 'class' || key === 'style' || isOn(key)) {
2503 (res || (res = {}))[key] = attrs[key];
2504 }
2505 }
2506 return res;
2507};
2508const filterModelListeners = (attrs, props) => {
2509 const res = {};
2510 for (const key in attrs) {
2511 if (!isModelListener(key) || !(key.slice(9) in props)) {
2512 res[key] = attrs[key];
2513 }
2514 }
2515 return res;
2516};
2517const isElementRoot = (vnode) => {
2518 return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
2519 vnode.type === Comment // potential v-if branch switch
2520 );
2521};
2522function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
2523 const { props: prevProps, children: prevChildren, component } = prevVNode;
2524 const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
2525 const emits = component.emitsOptions;
2526 // Parent component's render function was hot-updated. Since this may have
2527 // caused the child component's slots content to have changed, we need to
2528 // force the child to update as well.
2529 if ((prevChildren || nextChildren) && isHmrUpdating) {
2530 return true;
2531 }
2532 // force child update for runtime directive or transition on component vnode.
2533 if (nextVNode.dirs || nextVNode.transition) {
2534 return true;
2535 }
2536 if (optimized && patchFlag >= 0) {
2537 if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {
2538 // slot content that references values that might have changed,
2539 // e.g. in a v-for
2540 return true;
2541 }
2542 if (patchFlag & 16 /* FULL_PROPS */) {
2543 if (!prevProps) {
2544 return !!nextProps;
2545 }
2546 // presence of this flag indicates props are always non-null
2547 return hasPropsChanged(prevProps, nextProps, emits);
2548 }
2549 else if (patchFlag & 8 /* PROPS */) {
2550 const dynamicProps = nextVNode.dynamicProps;
2551 for (let i = 0; i < dynamicProps.length; i++) {
2552 const key = dynamicProps[i];
2553 if (nextProps[key] !== prevProps[key] &&
2554 !isEmitListener(emits, key)) {
2555 return true;
2556 }
2557 }
2558 }
2559 }
2560 else {
2561 // this path is only taken by manually written render functions
2562 // so presence of any children leads to a forced update
2563 if (prevChildren || nextChildren) {
2564 if (!nextChildren || !nextChildren.$stable) {
2565 return true;
2566 }
2567 }
2568 if (prevProps === nextProps) {
2569 return false;
2570 }
2571 if (!prevProps) {
2572 return !!nextProps;
2573 }
2574 if (!nextProps) {
2575 return true;
2576 }
2577 return hasPropsChanged(prevProps, nextProps, emits);
2578 }
2579 return false;
2580}
2581function hasPropsChanged(prevProps, nextProps, emitsOptions) {
2582 const nextKeys = Object.keys(nextProps);
2583 if (nextKeys.length !== Object.keys(prevProps).length) {
2584 return true;
2585 }
2586 for (let i = 0; i < nextKeys.length; i++) {
2587 const key = nextKeys[i];
2588 if (nextProps[key] !== prevProps[key] &&
2589 !isEmitListener(emitsOptions, key)) {
2590 return true;
2591 }
2592 }
2593 return false;
2594}
2595function updateHOCHostEl({ vnode, parent }, el // HostNode
2596) {
2597 while (parent && parent.subTree === vnode) {
2598 (vnode = parent.vnode).el = el;
2599 parent = parent.parent;
2600 }
2601}
2602
2603const isSuspense = (type) => type.__isSuspense;
2604// Suspense exposes a component-like API, and is treated like a component
2605// in the compiler, but internally it's a special built-in type that hooks
2606// directly into the renderer.
2607const SuspenseImpl = {
2608 name: 'Suspense',
2609 // In order to make Suspense tree-shakable, we need to avoid importing it
2610 // directly in the renderer. The renderer checks for the __isSuspense flag
2611 // on a vnode's type and calls the `process` method, passing in renderer
2612 // internals.
2613 __isSuspense: true,
2614 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized,
2615 // platform-specific impl passed from renderer
2616 rendererInternals) {
2617 if (n1 == null) {
2618 mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals);
2619 }
2620 else {
2621 patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, rendererInternals);
2622 }
2623 },
2624 hydrate: hydrateSuspense,
2625 create: createSuspenseBoundary,
2626 normalize: normalizeSuspenseChildren
2627};
2628// Force-casted public typing for h and TSX props inference
2629const Suspense = (SuspenseImpl );
2630function triggerEvent(vnode, name) {
2631 const eventListener = vnode.props && vnode.props[name];
2632 if (isFunction(eventListener)) {
2633 eventListener();
2634 }
2635}
2636function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
2637 const { p: patch, o: { createElement } } = rendererInternals;
2638 const hiddenContainer = createElement('div');
2639 const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals));
2640 // start mounting the content subtree in an off-dom container
2641 patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds);
2642 // now check if we have encountered any async deps
2643 if (suspense.deps > 0) {
2644 // has async
2645 // invoke @fallback event
2646 triggerEvent(vnode, 'onPending');
2647 triggerEvent(vnode, 'onFallback');
2648 // mount the fallback tree
2649 patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2650 isSVG, slotScopeIds);
2651 setActiveBranch(suspense, vnode.ssFallback);
2652 }
2653 else {
2654 // Suspense has no async deps. Just resolve.
2655 suspense.resolve();
2656 }
2657}
2658function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) {
2659 const suspense = (n2.suspense = n1.suspense);
2660 suspense.vnode = n2;
2661 n2.el = n1.el;
2662 const newBranch = n2.ssContent;
2663 const newFallback = n2.ssFallback;
2664 const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
2665 if (pendingBranch) {
2666 suspense.pendingBranch = newBranch;
2667 if (isSameVNodeType(newBranch, pendingBranch)) {
2668 // same root type but content may have changed.
2669 patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2670 if (suspense.deps <= 0) {
2671 suspense.resolve();
2672 }
2673 else if (isInFallback) {
2674 patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2675 isSVG, slotScopeIds, optimized);
2676 setActiveBranch(suspense, newFallback);
2677 }
2678 }
2679 else {
2680 // toggled before pending tree is resolved
2681 suspense.pendingId++;
2682 if (isHydrating) {
2683 // if toggled before hydration is finished, the current DOM tree is
2684 // no longer valid. set it as the active branch so it will be unmounted
2685 // when resolved
2686 suspense.isHydrating = false;
2687 suspense.activeBranch = pendingBranch;
2688 }
2689 else {
2690 unmount(pendingBranch, parentComponent, suspense);
2691 }
2692 // increment pending ID. this is used to invalidate async callbacks
2693 // reset suspense state
2694 suspense.deps = 0;
2695 // discard effects from pending branch
2696 suspense.effects.length = 0;
2697 // discard previous container
2698 suspense.hiddenContainer = createElement('div');
2699 if (isInFallback) {
2700 // already in fallback state
2701 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2702 if (suspense.deps <= 0) {
2703 suspense.resolve();
2704 }
2705 else {
2706 patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2707 isSVG, slotScopeIds, optimized);
2708 setActiveBranch(suspense, newFallback);
2709 }
2710 }
2711 else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
2712 // toggled "back" to current active branch
2713 patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2714 // force resolve
2715 suspense.resolve(true);
2716 }
2717 else {
2718 // switched to a 3rd branch
2719 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2720 if (suspense.deps <= 0) {
2721 suspense.resolve();
2722 }
2723 }
2724 }
2725 }
2726 else {
2727 if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
2728 // root did not change, just normal patch
2729 patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2730 setActiveBranch(suspense, newBranch);
2731 }
2732 else {
2733 // root node toggled
2734 // invoke @pending event
2735 triggerEvent(n2, 'onPending');
2736 // mount pending branch in off-dom container
2737 suspense.pendingBranch = newBranch;
2738 suspense.pendingId++;
2739 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, slotScopeIds, optimized);
2740 if (suspense.deps <= 0) {
2741 // incoming branch has no async deps, resolve now.
2742 suspense.resolve();
2743 }
2744 else {
2745 const { timeout, pendingId } = suspense;
2746 if (timeout > 0) {
2747 setTimeout(() => {
2748 if (suspense.pendingId === pendingId) {
2749 suspense.fallback(newFallback);
2750 }
2751 }, timeout);
2752 }
2753 else if (timeout === 0) {
2754 suspense.fallback(newFallback);
2755 }
2756 }
2757 }
2758 }
2759}
2760let hasWarned = false;
2761function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
2762 /* istanbul ignore if */
2763 if (!hasWarned) {
2764 hasWarned = true;
2765 // @ts-ignore `console.info` cannot be null error
2766 console[console.info ? 'info' : 'log'](`<Suspense> is an experimental feature and its API will likely change.`);
2767 }
2768 const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;
2769 const timeout = toNumber(vnode.props && vnode.props.timeout);
2770 const suspense = {
2771 vnode,
2772 parent,
2773 parentComponent,
2774 isSVG,
2775 container,
2776 hiddenContainer,
2777 anchor,
2778 deps: 0,
2779 pendingId: 0,
2780 timeout: typeof timeout === 'number' ? timeout : -1,
2781 activeBranch: null,
2782 pendingBranch: null,
2783 isInFallback: true,
2784 isHydrating,
2785 isUnmounted: false,
2786 effects: [],
2787 resolve(resume = false) {
2788 {
2789 if (!resume && !suspense.pendingBranch) {
2790 throw new Error(`suspense.resolve() is called without a pending branch.`);
2791 }
2792 if (suspense.isUnmounted) {
2793 throw new Error(`suspense.resolve() is called on an already unmounted suspense boundary.`);
2794 }
2795 }
2796 const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;
2797 if (suspense.isHydrating) {
2798 suspense.isHydrating = false;
2799 }
2800 else if (!resume) {
2801 const delayEnter = activeBranch &&
2802 pendingBranch.transition &&
2803 pendingBranch.transition.mode === 'out-in';
2804 if (delayEnter) {
2805 activeBranch.transition.afterLeave = () => {
2806 if (pendingId === suspense.pendingId) {
2807 move(pendingBranch, container, anchor, 0 /* ENTER */);
2808 }
2809 };
2810 }
2811 // this is initial anchor on mount
2812 let { anchor } = suspense;
2813 // unmount current active tree
2814 if (activeBranch) {
2815 // if the fallback tree was mounted, it may have been moved
2816 // as part of a parent suspense. get the latest anchor for insertion
2817 anchor = next(activeBranch);
2818 unmount(activeBranch, parentComponent, suspense, true);
2819 }
2820 if (!delayEnter) {
2821 // move content from off-dom container to actual container
2822 move(pendingBranch, container, anchor, 0 /* ENTER */);
2823 }
2824 }
2825 setActiveBranch(suspense, pendingBranch);
2826 suspense.pendingBranch = null;
2827 suspense.isInFallback = false;
2828 // flush buffered effects
2829 // check if there is a pending parent suspense
2830 let parent = suspense.parent;
2831 let hasUnresolvedAncestor = false;
2832 while (parent) {
2833 if (parent.pendingBranch) {
2834 // found a pending parent suspense, merge buffered post jobs
2835 // into that parent
2836 parent.effects.push(...effects);
2837 hasUnresolvedAncestor = true;
2838 break;
2839 }
2840 parent = parent.parent;
2841 }
2842 // no pending parent suspense, flush all jobs
2843 if (!hasUnresolvedAncestor) {
2844 queuePostFlushCb(effects);
2845 }
2846 suspense.effects = [];
2847 // invoke @resolve event
2848 triggerEvent(vnode, 'onResolve');
2849 },
2850 fallback(fallbackVNode) {
2851 if (!suspense.pendingBranch) {
2852 return;
2853 }
2854 const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
2855 // invoke @fallback event
2856 triggerEvent(vnode, 'onFallback');
2857 const anchor = next(activeBranch);
2858 const mountFallback = () => {
2859 if (!suspense.isInFallback) {
2860 return;
2861 }
2862 // mount the fallback tree
2863 patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context
2864 isSVG, slotScopeIds, optimized);
2865 setActiveBranch(suspense, fallbackVNode);
2866 };
2867 const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';
2868 if (delayEnter) {
2869 activeBranch.transition.afterLeave = mountFallback;
2870 }
2871 suspense.isInFallback = true;
2872 // unmount current active branch
2873 unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
2874 true // shouldRemove
2875 );
2876 if (!delayEnter) {
2877 mountFallback();
2878 }
2879 },
2880 move(container, anchor, type) {
2881 suspense.activeBranch &&
2882 move(suspense.activeBranch, container, anchor, type);
2883 suspense.container = container;
2884 },
2885 next() {
2886 return suspense.activeBranch && next(suspense.activeBranch);
2887 },
2888 registerDep(instance, setupRenderEffect) {
2889 const isInPendingSuspense = !!suspense.pendingBranch;
2890 if (isInPendingSuspense) {
2891 suspense.deps++;
2892 }
2893 const hydratedEl = instance.vnode.el;
2894 instance
2895 .asyncDep.catch(err => {
2896 handleError(err, instance, 0 /* SETUP_FUNCTION */);
2897 })
2898 .then(asyncSetupResult => {
2899 // retry when the setup() promise resolves.
2900 // component may have been unmounted before resolve.
2901 if (instance.isUnmounted ||
2902 suspense.isUnmounted ||
2903 suspense.pendingId !== instance.suspenseId) {
2904 return;
2905 }
2906 // retry from this component
2907 instance.asyncResolved = true;
2908 const { vnode } = instance;
2909 {
2910 pushWarningContext(vnode);
2911 }
2912 handleSetupResult(instance, asyncSetupResult, false);
2913 if (hydratedEl) {
2914 // vnode may have been replaced if an update happened before the
2915 // async dep is resolved.
2916 vnode.el = hydratedEl;
2917 }
2918 const placeholder = !hydratedEl && instance.subTree.el;
2919 setupRenderEffect(instance, vnode,
2920 // component may have been moved before resolve.
2921 // if this is not a hydration, instance.subTree will be the comment
2922 // placeholder.
2923 parentNode(hydratedEl || instance.subTree.el),
2924 // anchor will not be used if this is hydration, so only need to
2925 // consider the comment placeholder case.
2926 hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);
2927 if (placeholder) {
2928 remove(placeholder);
2929 }
2930 updateHOCHostEl(instance, vnode.el);
2931 {
2932 popWarningContext();
2933 }
2934 // only decrease deps count if suspense is not already resolved
2935 if (isInPendingSuspense && --suspense.deps === 0) {
2936 suspense.resolve();
2937 }
2938 });
2939 },
2940 unmount(parentSuspense, doRemove) {
2941 suspense.isUnmounted = true;
2942 if (suspense.activeBranch) {
2943 unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);
2944 }
2945 if (suspense.pendingBranch) {
2946 unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);
2947 }
2948 }
2949 };
2950 return suspense;
2951}
2952function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals, hydrateNode) {
2953 /* eslint-disable no-restricted-globals */
2954 const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, slotScopeIds, optimized, rendererInternals, true /* hydrating */));
2955 // there are two possible scenarios for server-rendered suspense:
2956 // - success: ssr content should be fully resolved
2957 // - failure: ssr content should be the fallback branch.
2958 // however, on the client we don't really know if it has failed or not
2959 // attempt to hydrate the DOM assuming it has succeeded, but we still
2960 // need to construct a suspense boundary first
2961 const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, slotScopeIds, optimized);
2962 if (suspense.deps === 0) {
2963 suspense.resolve();
2964 }
2965 return result;
2966 /* eslint-enable no-restricted-globals */
2967}
2968function normalizeSuspenseChildren(vnode) {
2969 const { shapeFlag, children } = vnode;
2970 const isSlotChildren = shapeFlag & 32 /* SLOTS_CHILDREN */;
2971 vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
2972 vnode.ssFallback = isSlotChildren
2973 ? normalizeSuspenseSlot(children.fallback)
2974 : createVNode(Comment);
2975}
2976function normalizeSuspenseSlot(s) {
2977 let block;
2978 if (isFunction(s)) {
2979 const trackBlock = isBlockTreeEnabled && s._c;
2980 if (trackBlock) {
2981 // disableTracking: false
2982 // allow block tracking for compiled slots
2983 // (see ./componentRenderContext.ts)
2984 s._d = false;
2985 openBlock();
2986 }
2987 s = s();
2988 if (trackBlock) {
2989 s._d = true;
2990 block = currentBlock;
2991 closeBlock();
2992 }
2993 }
2994 if (isArray(s)) {
2995 const singleChild = filterSingleRoot(s);
2996 if (!singleChild) {
2997 warn$1(`<Suspense> slots expect a single root node.`);
2998 }
2999 s = singleChild;
3000 }
3001 s = normalizeVNode(s);
3002 if (block && !s.dynamicChildren) {
3003 s.dynamicChildren = block.filter(c => c !== s);
3004 }
3005 return s;
3006}
3007function queueEffectWithSuspense(fn, suspense) {
3008 if (suspense && suspense.pendingBranch) {
3009 if (isArray(fn)) {
3010 suspense.effects.push(...fn);
3011 }
3012 else {
3013 suspense.effects.push(fn);
3014 }
3015 }
3016 else {
3017 queuePostFlushCb(fn);
3018 }
3019}
3020function setActiveBranch(suspense, branch) {
3021 suspense.activeBranch = branch;
3022 const { vnode, parentComponent } = suspense;
3023 const el = (vnode.el = branch.el);
3024 // in case suspense is the root node of a component,
3025 // recursively update the HOC el
3026 if (parentComponent && parentComponent.subTree === vnode) {
3027 parentComponent.vnode.el = el;
3028 updateHOCHostEl(parentComponent, el);
3029 }
3030}
3031
3032function provide(key, value) {
3033 if (!currentInstance) {
3034 {
3035 warn$1(`provide() can only be used inside setup().`);
3036 }
3037 }
3038 else {
3039 let provides = currentInstance.provides;
3040 // by default an instance inherits its parent's provides object
3041 // but when it needs to provide values of its own, it creates its
3042 // own provides object using parent provides object as prototype.
3043 // this way in `inject` we can simply look up injections from direct
3044 // parent and let the prototype chain do the work.
3045 const parentProvides = currentInstance.parent && currentInstance.parent.provides;
3046 if (parentProvides === provides) {
3047 provides = currentInstance.provides = Object.create(parentProvides);
3048 }
3049 // TS doesn't allow symbol as index type
3050 provides[key] = value;
3051 }
3052}
3053function inject(key, defaultValue, treatDefaultAsFactory = false) {
3054 // fallback to `currentRenderingInstance` so that this can be called in
3055 // a functional component
3056 const instance = currentInstance || currentRenderingInstance;
3057 if (instance) {
3058 // #2400
3059 // to support `app.use` plugins,
3060 // fallback to appContext's `provides` if the instance is at root
3061 const provides = instance.parent == null
3062 ? instance.vnode.appContext && instance.vnode.appContext.provides
3063 : instance.parent.provides;
3064 if (provides && key in provides) {
3065 // TS doesn't allow symbol as index type
3066 return provides[key];
3067 }
3068 else if (arguments.length > 1) {
3069 return treatDefaultAsFactory && isFunction(defaultValue)
3070 ? defaultValue.call(instance.proxy)
3071 : defaultValue;
3072 }
3073 else {
3074 warn$1(`injection "${String(key)}" not found.`);
3075 }
3076 }
3077 else {
3078 warn$1(`inject() can only be used inside setup() or functional components.`);
3079 }
3080}
3081
3082// Simple effect.
3083function watchEffect(effect, options) {
3084 return doWatch(effect, null, options);
3085}
3086function watchPostEffect(effect, options) {
3087 return doWatch(effect, null, (Object.assign(options || {}, { flush: 'post' })
3088 ));
3089}
3090function watchSyncEffect(effect, options) {
3091 return doWatch(effect, null, (Object.assign(options || {}, { flush: 'sync' })
3092 ));
3093}
3094// initial value for watchers to trigger on undefined initial values
3095const INITIAL_WATCHER_VALUE = {};
3096// implementation
3097function watch(source, cb, options) {
3098 if (!isFunction(cb)) {
3099 warn$1(`\`watch(fn, options?)\` signature has been moved to a separate API. ` +
3100 `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
3101 `supports \`watch(source, cb, options?) signature.`);
3102 }
3103 return doWatch(source, cb, options);
3104}
3105function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3106 if (!cb) {
3107 if (immediate !== undefined) {
3108 warn$1(`watch() "immediate" option is only respected when using the ` +
3109 `watch(source, callback, options?) signature.`);
3110 }
3111 if (deep !== undefined) {
3112 warn$1(`watch() "deep" option is only respected when using the ` +
3113 `watch(source, callback, options?) signature.`);
3114 }
3115 }
3116 const warnInvalidSource = (s) => {
3117 warn$1(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` +
3118 `a reactive object, or an array of these types.`);
3119 };
3120 const instance = currentInstance;
3121 let getter;
3122 let forceTrigger = false;
3123 let isMultiSource = false;
3124 if (isRef(source)) {
3125 getter = () => source.value;
3126 forceTrigger = isShallow(source);
3127 }
3128 else if (isReactive(source)) {
3129 getter = () => source;
3130 deep = true;
3131 }
3132 else if (isArray(source)) {
3133 isMultiSource = true;
3134 forceTrigger = source.some(isReactive);
3135 getter = () => source.map(s => {
3136 if (isRef(s)) {
3137 return s.value;
3138 }
3139 else if (isReactive(s)) {
3140 return traverse(s);
3141 }
3142 else if (isFunction(s)) {
3143 return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);
3144 }
3145 else {
3146 warnInvalidSource(s);
3147 }
3148 });
3149 }
3150 else if (isFunction(source)) {
3151 if (cb) {
3152 // getter with cb
3153 getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);
3154 }
3155 else {
3156 // no cb -> simple effect
3157 getter = () => {
3158 if (instance && instance.isUnmounted) {
3159 return;
3160 }
3161 if (cleanup) {
3162 cleanup();
3163 }
3164 return callWithAsyncErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onCleanup]);
3165 };
3166 }
3167 }
3168 else {
3169 getter = NOOP;
3170 warnInvalidSource(source);
3171 }
3172 if (cb && deep) {
3173 const baseGetter = getter;
3174 getter = () => traverse(baseGetter());
3175 }
3176 let cleanup;
3177 let onCleanup = (fn) => {
3178 cleanup = effect.onStop = () => {
3179 callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);
3180 };
3181 };
3182 let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
3183 const job = () => {
3184 if (!effect.active) {
3185 return;
3186 }
3187 if (cb) {
3188 // watch(source, cb)
3189 const newValue = effect.run();
3190 if (deep ||
3191 forceTrigger ||
3192 (isMultiSource
3193 ? newValue.some((v, i) => hasChanged(v, oldValue[i]))
3194 : hasChanged(newValue, oldValue)) ||
3195 (false )) {
3196 // cleanup before running cb again
3197 if (cleanup) {
3198 cleanup();
3199 }
3200 callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [
3201 newValue,
3202 // pass undefined as the old value when it's changed for the first time
3203 oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
3204 onCleanup
3205 ]);
3206 oldValue = newValue;
3207 }
3208 }
3209 else {
3210 // watchEffect
3211 effect.run();
3212 }
3213 };
3214 // important: mark the job as a watcher callback so that scheduler knows
3215 // it is allowed to self-trigger (#1727)
3216 job.allowRecurse = !!cb;
3217 let scheduler;
3218 if (flush === 'sync') {
3219 scheduler = job; // the scheduler function gets called directly
3220 }
3221 else if (flush === 'post') {
3222 scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
3223 }
3224 else {
3225 // default: 'pre'
3226 scheduler = () => {
3227 if (!instance || instance.isMounted) {
3228 queuePreFlushCb(job);
3229 }
3230 else {
3231 // with 'pre' option, the first call must happen before
3232 // the component is mounted so it is called synchronously.
3233 job();
3234 }
3235 };
3236 }
3237 const effect = new ReactiveEffect(getter, scheduler);
3238 {
3239 effect.onTrack = onTrack;
3240 effect.onTrigger = onTrigger;
3241 }
3242 // initial run
3243 if (cb) {
3244 if (immediate) {
3245 job();
3246 }
3247 else {
3248 oldValue = effect.run();
3249 }
3250 }
3251 else if (flush === 'post') {
3252 queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);
3253 }
3254 else {
3255 effect.run();
3256 }
3257 return () => {
3258 effect.stop();
3259 if (instance && instance.scope) {
3260 remove(instance.scope.effects, effect);
3261 }
3262 };
3263}
3264// this.$watch
3265function instanceWatch(source, value, options) {
3266 const publicThis = this.proxy;
3267 const getter = isString(source)
3268 ? source.includes('.')
3269 ? createPathGetter(publicThis, source)
3270 : () => publicThis[source]
3271 : source.bind(publicThis, publicThis);
3272 let cb;
3273 if (isFunction(value)) {
3274 cb = value;
3275 }
3276 else {
3277 cb = value.handler;
3278 options = value;
3279 }
3280 const cur = currentInstance;
3281 setCurrentInstance(this);
3282 const res = doWatch(getter, cb.bind(publicThis), options);
3283 if (cur) {
3284 setCurrentInstance(cur);
3285 }
3286 else {
3287 unsetCurrentInstance();
3288 }
3289 return res;
3290}
3291function createPathGetter(ctx, path) {
3292 const segments = path.split('.');
3293 return () => {
3294 let cur = ctx;
3295 for (let i = 0; i < segments.length && cur; i++) {
3296 cur = cur[segments[i]];
3297 }
3298 return cur;
3299 };
3300}
3301function traverse(value, seen) {
3302 if (!isObject(value) || value["__v_skip" /* SKIP */]) {
3303 return value;
3304 }
3305 seen = seen || new Set();
3306 if (seen.has(value)) {
3307 return value;
3308 }
3309 seen.add(value);
3310 if (isRef(value)) {
3311 traverse(value.value, seen);
3312 }
3313 else if (isArray(value)) {
3314 for (let i = 0; i < value.length; i++) {
3315 traverse(value[i], seen);
3316 }
3317 }
3318 else if (isSet(value) || isMap(value)) {
3319 value.forEach((v) => {
3320 traverse(v, seen);
3321 });
3322 }
3323 else if (isPlainObject(value)) {
3324 for (const key in value) {
3325 traverse(value[key], seen);
3326 }
3327 }
3328 return value;
3329}
3330
3331function useTransitionState() {
3332 const state = {
3333 isMounted: false,
3334 isLeaving: false,
3335 isUnmounting: false,
3336 leavingVNodes: new Map()
3337 };
3338 onMounted(() => {
3339 state.isMounted = true;
3340 });
3341 onBeforeUnmount(() => {
3342 state.isUnmounting = true;
3343 });
3344 return state;
3345}
3346const TransitionHookValidator = [Function, Array];
3347const BaseTransitionImpl = {
3348 name: `BaseTransition`,
3349 props: {
3350 mode: String,
3351 appear: Boolean,
3352 persisted: Boolean,
3353 // enter
3354 onBeforeEnter: TransitionHookValidator,
3355 onEnter: TransitionHookValidator,
3356 onAfterEnter: TransitionHookValidator,
3357 onEnterCancelled: TransitionHookValidator,
3358 // leave
3359 onBeforeLeave: TransitionHookValidator,
3360 onLeave: TransitionHookValidator,
3361 onAfterLeave: TransitionHookValidator,
3362 onLeaveCancelled: TransitionHookValidator,
3363 // appear
3364 onBeforeAppear: TransitionHookValidator,
3365 onAppear: TransitionHookValidator,
3366 onAfterAppear: TransitionHookValidator,
3367 onAppearCancelled: TransitionHookValidator
3368 },
3369 setup(props, { slots }) {
3370 const instance = getCurrentInstance();
3371 const state = useTransitionState();
3372 let prevTransitionKey;
3373 return () => {
3374 const children = slots.default && getTransitionRawChildren(slots.default(), true);
3375 if (!children || !children.length) {
3376 return;
3377 }
3378 // warn multiple elements
3379 if (children.length > 1) {
3380 warn$1('<transition> can only be used on a single element or component. Use ' +
3381 '<transition-group> for lists.');
3382 }
3383 // there's no need to track reactivity for these props so use the raw
3384 // props for a bit better perf
3385 const rawProps = toRaw(props);
3386 const { mode } = rawProps;
3387 // check mode
3388 if (mode &&
3389 mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3390 warn$1(`invalid <transition> mode: ${mode}`);
3391 }
3392 // at this point children has a guaranteed length of 1.
3393 const child = children[0];
3394 if (state.isLeaving) {
3395 return emptyPlaceholder(child);
3396 }
3397 // in the case of <transition><keep-alive/></transition>, we need to
3398 // compare the type of the kept-alive children.
3399 const innerChild = getKeepAliveChild(child);
3400 if (!innerChild) {
3401 return emptyPlaceholder(child);
3402 }
3403 const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);
3404 setTransitionHooks(innerChild, enterHooks);
3405 const oldChild = instance.subTree;
3406 const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
3407 let transitionKeyChanged = false;
3408 const { getTransitionKey } = innerChild.type;
3409 if (getTransitionKey) {
3410 const key = getTransitionKey();
3411 if (prevTransitionKey === undefined) {
3412 prevTransitionKey = key;
3413 }
3414 else if (key !== prevTransitionKey) {
3415 prevTransitionKey = key;
3416 transitionKeyChanged = true;
3417 }
3418 }
3419 // handle mode
3420 if (oldInnerChild &&
3421 oldInnerChild.type !== Comment &&
3422 (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
3423 const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
3424 // update old tree's hooks in case of dynamic transition
3425 setTransitionHooks(oldInnerChild, leavingHooks);
3426 // switching between different views
3427 if (mode === 'out-in') {
3428 state.isLeaving = true;
3429 // return placeholder node and queue update when leave finishes
3430 leavingHooks.afterLeave = () => {
3431 state.isLeaving = false;
3432 instance.update();
3433 };
3434 return emptyPlaceholder(child);
3435 }
3436 else if (mode === 'in-out' && innerChild.type !== Comment) {
3437 leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
3438 const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
3439 leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
3440 // early removal callback
3441 el._leaveCb = () => {
3442 earlyRemove();
3443 el._leaveCb = undefined;
3444 delete enterHooks.delayedLeave;
3445 };
3446 enterHooks.delayedLeave = delayedLeave;
3447 };
3448 }
3449 }
3450 return child;
3451 };
3452 }
3453};
3454// export the public type for h/tsx inference
3455// also to avoid inline import() in generated d.ts files
3456const BaseTransition = BaseTransitionImpl;
3457function getLeavingNodesForType(state, vnode) {
3458 const { leavingVNodes } = state;
3459 let leavingVNodesCache = leavingVNodes.get(vnode.type);
3460 if (!leavingVNodesCache) {
3461 leavingVNodesCache = Object.create(null);
3462 leavingVNodes.set(vnode.type, leavingVNodesCache);
3463 }
3464 return leavingVNodesCache;
3465}
3466// The transition hooks are attached to the vnode as vnode.transition
3467// and will be called at appropriate timing in the renderer.
3468function resolveTransitionHooks(vnode, props, state, instance) {
3469 const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;
3470 const key = String(vnode.key);
3471 const leavingVNodesCache = getLeavingNodesForType(state, vnode);
3472 const callHook = (hook, args) => {
3473 hook &&
3474 callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);
3475 };
3476 const hooks = {
3477 mode,
3478 persisted,
3479 beforeEnter(el) {
3480 let hook = onBeforeEnter;
3481 if (!state.isMounted) {
3482 if (appear) {
3483 hook = onBeforeAppear || onBeforeEnter;
3484 }
3485 else {
3486 return;
3487 }
3488 }
3489 // for same element (v-show)
3490 if (el._leaveCb) {
3491 el._leaveCb(true /* cancelled */);
3492 }
3493 // for toggled element with same key (v-if)
3494 const leavingVNode = leavingVNodesCache[key];
3495 if (leavingVNode &&
3496 isSameVNodeType(vnode, leavingVNode) &&
3497 leavingVNode.el._leaveCb) {
3498 // force early removal (not cancelled)
3499 leavingVNode.el._leaveCb();
3500 }
3501 callHook(hook, [el]);
3502 },
3503 enter(el) {
3504 let hook = onEnter;
3505 let afterHook = onAfterEnter;
3506 let cancelHook = onEnterCancelled;
3507 if (!state.isMounted) {
3508 if (appear) {
3509 hook = onAppear || onEnter;
3510 afterHook = onAfterAppear || onAfterEnter;
3511 cancelHook = onAppearCancelled || onEnterCancelled;
3512 }
3513 else {
3514 return;
3515 }
3516 }
3517 let called = false;
3518 const done = (el._enterCb = (cancelled) => {
3519 if (called)
3520 return;
3521 called = true;
3522 if (cancelled) {
3523 callHook(cancelHook, [el]);
3524 }
3525 else {
3526 callHook(afterHook, [el]);
3527 }
3528 if (hooks.delayedLeave) {
3529 hooks.delayedLeave();
3530 }
3531 el._enterCb = undefined;
3532 });
3533 if (hook) {
3534 hook(el, done);
3535 if (hook.length <= 1) {
3536 done();
3537 }
3538 }
3539 else {
3540 done();
3541 }
3542 },
3543 leave(el, remove) {
3544 const key = String(vnode.key);
3545 if (el._enterCb) {
3546 el._enterCb(true /* cancelled */);
3547 }
3548 if (state.isUnmounting) {
3549 return remove();
3550 }
3551 callHook(onBeforeLeave, [el]);
3552 let called = false;
3553 const done = (el._leaveCb = (cancelled) => {
3554 if (called)
3555 return;
3556 called = true;
3557 remove();
3558 if (cancelled) {
3559 callHook(onLeaveCancelled, [el]);
3560 }
3561 else {
3562 callHook(onAfterLeave, [el]);
3563 }
3564 el._leaveCb = undefined;
3565 if (leavingVNodesCache[key] === vnode) {
3566 delete leavingVNodesCache[key];
3567 }
3568 });
3569 leavingVNodesCache[key] = vnode;
3570 if (onLeave) {
3571 onLeave(el, done);
3572 if (onLeave.length <= 1) {
3573 done();
3574 }
3575 }
3576 else {
3577 done();
3578 }
3579 },
3580 clone(vnode) {
3581 return resolveTransitionHooks(vnode, props, state, instance);
3582 }
3583 };
3584 return hooks;
3585}
3586// the placeholder really only handles one special case: KeepAlive
3587// in the case of a KeepAlive in a leave phase we need to return a KeepAlive
3588// placeholder with empty content to avoid the KeepAlive instance from being
3589// unmounted.
3590function emptyPlaceholder(vnode) {
3591 if (isKeepAlive(vnode)) {
3592 vnode = cloneVNode(vnode);
3593 vnode.children = null;
3594 return vnode;
3595 }
3596}
3597function getKeepAliveChild(vnode) {
3598 return isKeepAlive(vnode)
3599 ? vnode.children
3600 ? vnode.children[0]
3601 : undefined
3602 : vnode;
3603}
3604function setTransitionHooks(vnode, hooks) {
3605 if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {
3606 setTransitionHooks(vnode.component.subTree, hooks);
3607 }
3608 else if (vnode.shapeFlag & 128 /* SUSPENSE */) {
3609 vnode.ssContent.transition = hooks.clone(vnode.ssContent);
3610 vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
3611 }
3612 else {
3613 vnode.transition = hooks;
3614 }
3615}
3616function getTransitionRawChildren(children, keepComment = false) {
3617 let ret = [];
3618 let keyedFragmentCount = 0;
3619 for (let i = 0; i < children.length; i++) {
3620 const child = children[i];
3621 // handle fragment children case, e.g. v-for
3622 if (child.type === Fragment) {
3623 if (child.patchFlag & 128 /* KEYED_FRAGMENT */)
3624 keyedFragmentCount++;
3625 ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3626 }
3627 // comment placeholders should be skipped, e.g. v-if
3628 else if (keepComment || child.type !== Comment) {
3629 ret.push(child);
3630 }
3631 }
3632 // #1126 if a transition children list contains multiple sub fragments, these
3633 // fragments will be merged into a flat children array. Since each v-for
3634 // fragment may contain different static bindings inside, we need to de-op
3635 // these children to force full diffs to ensure correct behavior.
3636 if (keyedFragmentCount > 1) {
3637 for (let i = 0; i < ret.length; i++) {
3638 ret[i].patchFlag = -2 /* BAIL */;
3639 }
3640 }
3641 return ret;
3642}
3643
3644// implementation, close to no-op
3645function defineComponent(options) {
3646 return isFunction(options) ? { setup: options, name: options.name } : options;
3647}
3648
3649const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
3650function defineAsyncComponent(source) {
3651 if (isFunction(source)) {
3652 source = { loader: source };
3653 }
3654 const { loader, loadingComponent, errorComponent, delay = 200, timeout, // undefined = never times out
3655 suspensible = true, onError: userOnError } = source;
3656 let pendingRequest = null;
3657 let resolvedComp;
3658 let retries = 0;
3659 const retry = () => {
3660 retries++;
3661 pendingRequest = null;
3662 return load();
3663 };
3664 const load = () => {
3665 let thisRequest;
3666 return (pendingRequest ||
3667 (thisRequest = pendingRequest =
3668 loader()
3669 .catch(err => {
3670 err = err instanceof Error ? err : new Error(String(err));
3671 if (userOnError) {
3672 return new Promise((resolve, reject) => {
3673 const userRetry = () => resolve(retry());
3674 const userFail = () => reject(err);
3675 userOnError(err, userRetry, userFail, retries + 1);
3676 });
3677 }
3678 else {
3679 throw err;
3680 }
3681 })
3682 .then((comp) => {
3683 if (thisRequest !== pendingRequest && pendingRequest) {
3684 return pendingRequest;
3685 }
3686 if (!comp) {
3687 warn$1(`Async component loader resolved to undefined. ` +
3688 `If you are using retry(), make sure to return its return value.`);
3689 }
3690 // interop module default
3691 if (comp &&
3692 (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
3693 comp = comp.default;
3694 }
3695 if (comp && !isObject(comp) && !isFunction(comp)) {
3696 throw new Error(`Invalid async component load result: ${comp}`);
3697 }
3698 resolvedComp = comp;
3699 return comp;
3700 })));
3701 };
3702 return defineComponent({
3703 name: 'AsyncComponentWrapper',
3704 __asyncLoader: load,
3705 get __asyncResolved() {
3706 return resolvedComp;
3707 },
3708 setup() {
3709 const instance = currentInstance;
3710 // already resolved
3711 if (resolvedComp) {
3712 return () => createInnerComp(resolvedComp, instance);
3713 }
3714 const onError = (err) => {
3715 pendingRequest = null;
3716 handleError(err, instance, 13 /* ASYNC_COMPONENT_LOADER */, !errorComponent /* do not throw in dev if user provided error component */);
3717 };
3718 // suspense-controlled or SSR.
3719 if ((suspensible && instance.suspense) ||
3720 (false )) {
3721 return load()
3722 .then(comp => {
3723 return () => createInnerComp(comp, instance);
3724 })
3725 .catch(err => {
3726 onError(err);
3727 return () => errorComponent
3728 ? createVNode(errorComponent, {
3729 error: err
3730 })
3731 : null;
3732 });
3733 }
3734 const loaded = ref(false);
3735 const error = ref();
3736 const delayed = ref(!!delay);
3737 if (delay) {
3738 setTimeout(() => {
3739 delayed.value = false;
3740 }, delay);
3741 }
3742 if (timeout != null) {
3743 setTimeout(() => {
3744 if (!loaded.value && !error.value) {
3745 const err = new Error(`Async component timed out after ${timeout}ms.`);
3746 onError(err);
3747 error.value = err;
3748 }
3749 }, timeout);
3750 }
3751 load()
3752 .then(() => {
3753 loaded.value = true;
3754 if (instance.parent && isKeepAlive(instance.parent.vnode)) {
3755 // parent is keep-alive, force update so the loaded component's
3756 // name is taken into account
3757 queueJob(instance.parent.update);
3758 }
3759 })
3760 .catch(err => {
3761 onError(err);
3762 error.value = err;
3763 });
3764 return () => {
3765 if (loaded.value && resolvedComp) {
3766 return createInnerComp(resolvedComp, instance);
3767 }
3768 else if (error.value && errorComponent) {
3769 return createVNode(errorComponent, {
3770 error: error.value
3771 });
3772 }
3773 else if (loadingComponent && !delayed.value) {
3774 return createVNode(loadingComponent);
3775 }
3776 };
3777 }
3778 });
3779}
3780function createInnerComp(comp, { vnode: { ref, props, children } }) {
3781 const vnode = createVNode(comp, props, children);
3782 // ensure inner component inherits the async wrapper's ref owner
3783 vnode.ref = ref;
3784 return vnode;
3785}
3786
3787const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
3788const KeepAliveImpl = {
3789 name: `KeepAlive`,
3790 // Marker for special handling inside the renderer. We are not using a ===
3791 // check directly on KeepAlive in the renderer, because importing it directly
3792 // would prevent it from being tree-shaken.
3793 __isKeepAlive: true,
3794 props: {
3795 include: [String, RegExp, Array],
3796 exclude: [String, RegExp, Array],
3797 max: [String, Number]
3798 },
3799 setup(props, { slots }) {
3800 const instance = getCurrentInstance();
3801 // KeepAlive communicates with the instantiated renderer via the
3802 // ctx where the renderer passes in its internals,
3803 // and the KeepAlive instance exposes activate/deactivate implementations.
3804 // The whole point of this is to avoid importing KeepAlive directly in the
3805 // renderer to facilitate tree-shaking.
3806 const sharedContext = instance.ctx;
3807 // if the internal renderer is not registered, it indicates that this is server-side rendering,
3808 // for KeepAlive, we just need to render its children
3809 if (!sharedContext.renderer) {
3810 return slots.default;
3811 }
3812 const cache = new Map();
3813 const keys = new Set();
3814 let current = null;
3815 {
3816 instance.__v_cache = cache;
3817 }
3818 const parentSuspense = instance.suspense;
3819 const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;
3820 const storageContainer = createElement('div');
3821 sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {
3822 const instance = vnode.component;
3823 move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);
3824 // in case props have changed
3825 patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, vnode.slotScopeIds, optimized);
3826 queuePostRenderEffect(() => {
3827 instance.isDeactivated = false;
3828 if (instance.a) {
3829 invokeArrayFns(instance.a);
3830 }
3831 const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
3832 if (vnodeHook) {
3833 invokeVNodeHook(vnodeHook, instance.parent, vnode);
3834 }
3835 }, parentSuspense);
3836 {
3837 // Update components tree
3838 devtoolsComponentAdded(instance);
3839 }
3840 };
3841 sharedContext.deactivate = (vnode) => {
3842 const instance = vnode.component;
3843 move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);
3844 queuePostRenderEffect(() => {
3845 if (instance.da) {
3846 invokeArrayFns(instance.da);
3847 }
3848 const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
3849 if (vnodeHook) {
3850 invokeVNodeHook(vnodeHook, instance.parent, vnode);
3851 }
3852 instance.isDeactivated = true;
3853 }, parentSuspense);
3854 {
3855 // Update components tree
3856 devtoolsComponentAdded(instance);
3857 }
3858 };
3859 function unmount(vnode) {
3860 // reset the shapeFlag so it can be properly unmounted
3861 resetShapeFlag(vnode);
3862 _unmount(vnode, instance, parentSuspense, true);
3863 }
3864 function pruneCache(filter) {
3865 cache.forEach((vnode, key) => {
3866 const name = getComponentName(vnode.type);
3867 if (name && (!filter || !filter(name))) {
3868 pruneCacheEntry(key);
3869 }
3870 });
3871 }
3872 function pruneCacheEntry(key) {
3873 const cached = cache.get(key);
3874 if (!current || cached.type !== current.type) {
3875 unmount(cached);
3876 }
3877 else if (current) {
3878 // current active instance should no longer be kept-alive.
3879 // we can't unmount it now but it might be later, so reset its flag now.
3880 resetShapeFlag(current);
3881 }
3882 cache.delete(key);
3883 keys.delete(key);
3884 }
3885 // prune cache on include/exclude prop change
3886 watch(() => [props.include, props.exclude], ([include, exclude]) => {
3887 include && pruneCache(name => matches(include, name));
3888 exclude && pruneCache(name => !matches(exclude, name));
3889 },
3890 // prune post-render after `current` has been updated
3891 { flush: 'post', deep: true });
3892 // cache sub tree after render
3893 let pendingCacheKey = null;
3894 const cacheSubtree = () => {
3895 // fix #1621, the pendingCacheKey could be 0
3896 if (pendingCacheKey != null) {
3897 cache.set(pendingCacheKey, getInnerChild(instance.subTree));
3898 }
3899 };
3900 onMounted(cacheSubtree);
3901 onUpdated(cacheSubtree);
3902 onBeforeUnmount(() => {
3903 cache.forEach(cached => {
3904 const { subTree, suspense } = instance;
3905 const vnode = getInnerChild(subTree);
3906 if (cached.type === vnode.type) {
3907 // current instance will be unmounted as part of keep-alive's unmount
3908 resetShapeFlag(vnode);
3909 // but invoke its deactivated hook here
3910 const da = vnode.component.da;
3911 da && queuePostRenderEffect(da, suspense);
3912 return;
3913 }
3914 unmount(cached);
3915 });
3916 });
3917 return () => {
3918 pendingCacheKey = null;
3919 if (!slots.default) {
3920 return null;
3921 }
3922 const children = slots.default();
3923 const rawVNode = children[0];
3924 if (children.length > 1) {
3925 {
3926 warn$1(`KeepAlive should contain exactly one component child.`);
3927 }
3928 current = null;
3929 return children;
3930 }
3931 else if (!isVNode(rawVNode) ||
3932 (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&
3933 !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {
3934 current = null;
3935 return rawVNode;
3936 }
3937 let vnode = getInnerChild(rawVNode);
3938 const comp = vnode.type;
3939 // for async components, name check should be based in its loaded
3940 // inner component if available
3941 const name = getComponentName(isAsyncWrapper(vnode)
3942 ? vnode.type.__asyncResolved || {}
3943 : comp);
3944 const { include, exclude, max } = props;
3945 if ((include && (!name || !matches(include, name))) ||
3946 (exclude && name && matches(exclude, name))) {
3947 current = vnode;
3948 return rawVNode;
3949 }
3950 const key = vnode.key == null ? comp : vnode.key;
3951 const cachedVNode = cache.get(key);
3952 // clone vnode if it's reused because we are going to mutate it
3953 if (vnode.el) {
3954 vnode = cloneVNode(vnode);
3955 if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {
3956 rawVNode.ssContent = vnode;
3957 }
3958 }
3959 // #1513 it's possible for the returned vnode to be cloned due to attr
3960 // fallthrough or scopeId, so the vnode here may not be the final vnode
3961 // that is mounted. Instead of caching it directly, we store the pending
3962 // key and cache `instance.subTree` (the normalized vnode) in
3963 // beforeMount/beforeUpdate hooks.
3964 pendingCacheKey = key;
3965 if (cachedVNode) {
3966 // copy over mounted state
3967 vnode.el = cachedVNode.el;
3968 vnode.component = cachedVNode.component;
3969 if (vnode.transition) {
3970 // recursively update transition hooks on subTree
3971 setTransitionHooks(vnode, vnode.transition);
3972 }
3973 // avoid vnode being mounted as fresh
3974 vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;
3975 // make this key the freshest
3976 keys.delete(key);
3977 keys.add(key);
3978 }
3979 else {
3980 keys.add(key);
3981 // prune oldest entry
3982 if (max && keys.size > parseInt(max, 10)) {
3983 pruneCacheEntry(keys.values().next().value);
3984 }
3985 }
3986 // avoid vnode being unmounted
3987 vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
3988 current = vnode;
3989 return rawVNode;
3990 };
3991 }
3992};
3993// export the public type for h/tsx inference
3994// also to avoid inline import() in generated d.ts files
3995const KeepAlive = KeepAliveImpl;
3996function matches(pattern, name) {
3997 if (isArray(pattern)) {
3998 return pattern.some((p) => matches(p, name));
3999 }
4000 else if (isString(pattern)) {
4001 return pattern.split(',').includes(name);
4002 }
4003 else if (pattern.test) {
4004 return pattern.test(name);
4005 }
4006 /* istanbul ignore next */
4007 return false;
4008}
4009function onActivated(hook, target) {
4010 registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);
4011}
4012function onDeactivated(hook, target) {
4013 registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);
4014}
4015function registerKeepAliveHook(hook, type, target = currentInstance) {
4016 // cache the deactivate branch check wrapper for injected hooks so the same
4017 // hook can be properly deduped by the scheduler. "__wdc" stands for "with
4018 // deactivation check".
4019 const wrappedHook = hook.__wdc ||
4020 (hook.__wdc = () => {
4021 // only fire the hook if the target instance is NOT in a deactivated branch.
4022 let current = target;
4023 while (current) {
4024 if (current.isDeactivated) {
4025 return;
4026 }
4027 current = current.parent;
4028 }
4029 return hook();
4030 });
4031 injectHook(type, wrappedHook, target);
4032 // In addition to registering it on the target instance, we walk up the parent
4033 // chain and register it on all ancestor instances that are keep-alive roots.
4034 // This avoids the need to walk the entire component tree when invoking these
4035 // hooks, and more importantly, avoids the need to track child components in
4036 // arrays.
4037 if (target) {
4038 let current = target.parent;
4039 while (current && current.parent) {
4040 if (isKeepAlive(current.parent.vnode)) {
4041 injectToKeepAliveRoot(wrappedHook, type, target, current);
4042 }
4043 current = current.parent;
4044 }
4045 }
4046}
4047function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4048 // injectHook wraps the original for error handling, so make sure to remove
4049 // the wrapped version.
4050 const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);
4051 onUnmounted(() => {
4052 remove(keepAliveRoot[type], injected);
4053 }, target);
4054}
4055function resetShapeFlag(vnode) {
4056 let shapeFlag = vnode.shapeFlag;
4057 if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
4058 shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;
4059 }
4060 if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
4061 shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;
4062 }
4063 vnode.shapeFlag = shapeFlag;
4064}
4065function getInnerChild(vnode) {
4066 return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;
4067}
4068
4069function injectHook(type, hook, target = currentInstance, prepend = false) {
4070 if (target) {
4071 const hooks = target[type] || (target[type] = []);
4072 // cache the error handling wrapper for injected hooks so the same hook
4073 // can be properly deduped by the scheduler. "__weh" stands for "with error
4074 // handling".
4075 const wrappedHook = hook.__weh ||
4076 (hook.__weh = (...args) => {
4077 if (target.isUnmounted) {
4078 return;
4079 }
4080 // disable tracking inside all lifecycle hooks
4081 // since they can potentially be called inside effects.
4082 pauseTracking();
4083 // Set currentInstance during hook invocation.
4084 // This assumes the hook does not synchronously trigger other hooks, which
4085 // can only be false when the user does something really funky.
4086 setCurrentInstance(target);
4087 const res = callWithAsyncErrorHandling(hook, target, type, args);
4088 unsetCurrentInstance();
4089 resetTracking();
4090 return res;
4091 });
4092 if (prepend) {
4093 hooks.unshift(wrappedHook);
4094 }
4095 else {
4096 hooks.push(wrappedHook);
4097 }
4098 return wrappedHook;
4099 }
4100 else {
4101 const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ''));
4102 warn$1(`${apiName} is called when there is no active component instance to be ` +
4103 `associated with. ` +
4104 `Lifecycle injection APIs can only be used during execution of setup().` +
4105 (` If you are using async setup(), make sure to register lifecycle ` +
4106 `hooks before the first await statement.`
4107 ));
4108 }
4109}
4110const createHook = (lifecycle) => (hook, target = currentInstance) =>
4111// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
4112(!isInSSRComponentSetup || lifecycle === "sp" /* SERVER_PREFETCH */) &&
4113 injectHook(lifecycle, hook, target);
4114const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);
4115const onMounted = createHook("m" /* MOUNTED */);
4116const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);
4117const onUpdated = createHook("u" /* UPDATED */);
4118const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);
4119const onUnmounted = createHook("um" /* UNMOUNTED */);
4120const onServerPrefetch = createHook("sp" /* SERVER_PREFETCH */);
4121const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);
4122const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);
4123function onErrorCaptured(hook, target = currentInstance) {
4124 injectHook("ec" /* ERROR_CAPTURED */, hook, target);
4125}
4126
4127function createDuplicateChecker() {
4128 const cache = Object.create(null);
4129 return (type, key) => {
4130 if (cache[key]) {
4131 warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`);
4132 }
4133 else {
4134 cache[key] = type;
4135 }
4136 };
4137}
4138let shouldCacheAccess = true;
4139function applyOptions(instance) {
4140 const options = resolveMergedOptions(instance);
4141 const publicThis = instance.proxy;
4142 const ctx = instance.ctx;
4143 // do not cache property access on public proxy during state initialization
4144 shouldCacheAccess = false;
4145 // call beforeCreate first before accessing other options since
4146 // the hook may mutate resolved options (#2791)
4147 if (options.beforeCreate) {
4148 callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
4149 }
4150 const {
4151 // state
4152 data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4153 // lifecycle
4154 created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4155 // public API
4156 expose, inheritAttrs,
4157 // assets
4158 components, directives, filters } = options;
4159 const checkDuplicateProperties = createDuplicateChecker() ;
4160 {
4161 const [propsOptions] = instance.propsOptions;
4162 if (propsOptions) {
4163 for (const key in propsOptions) {
4164 checkDuplicateProperties("Props" /* PROPS */, key);
4165 }
4166 }
4167 }
4168 // options initialization order (to be consistent with Vue 2):
4169 // - props (already done outside of this function)
4170 // - inject
4171 // - methods
4172 // - data (deferred since it relies on `this` access)
4173 // - computed
4174 // - watch (deferred since it relies on `this` access)
4175 if (injectOptions) {
4176 resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);
4177 }
4178 if (methods) {
4179 for (const key in methods) {
4180 const methodHandler = methods[key];
4181 if (isFunction(methodHandler)) {
4182 // In dev mode, we use the `createRenderContext` function to define
4183 // methods to the proxy target, and those are read-only but
4184 // reconfigurable, so it needs to be redefined here
4185 {
4186 Object.defineProperty(ctx, key, {
4187 value: methodHandler.bind(publicThis),
4188 configurable: true,
4189 enumerable: true,
4190 writable: true
4191 });
4192 }
4193 {
4194 checkDuplicateProperties("Methods" /* METHODS */, key);
4195 }
4196 }
4197 else {
4198 warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
4199 `Did you reference the function correctly?`);
4200 }
4201 }
4202 }
4203 if (dataOptions) {
4204 if (!isFunction(dataOptions)) {
4205 warn$1(`The data option must be a function. ` +
4206 `Plain object usage is no longer supported.`);
4207 }
4208 const data = dataOptions.call(publicThis, publicThis);
4209 if (isPromise(data)) {
4210 warn$1(`data() returned a Promise - note data() cannot be async; If you ` +
4211 `intend to perform data fetching before component renders, use ` +
4212 `async setup() + <Suspense>.`);
4213 }
4214 if (!isObject(data)) {
4215 warn$1(`data() should return an object.`);
4216 }
4217 else {
4218 instance.data = reactive(data);
4219 {
4220 for (const key in data) {
4221 checkDuplicateProperties("Data" /* DATA */, key);
4222 // expose data on ctx during dev
4223 if (key[0] !== '$' && key[0] !== '_') {
4224 Object.defineProperty(ctx, key, {
4225 configurable: true,
4226 enumerable: true,
4227 get: () => data[key],
4228 set: NOOP
4229 });
4230 }
4231 }
4232 }
4233 }
4234 }
4235 // state initialization complete at this point - start caching access
4236 shouldCacheAccess = true;
4237 if (computedOptions) {
4238 for (const key in computedOptions) {
4239 const opt = computedOptions[key];
4240 const get = isFunction(opt)
4241 ? opt.bind(publicThis, publicThis)
4242 : isFunction(opt.get)
4243 ? opt.get.bind(publicThis, publicThis)
4244 : NOOP;
4245 if (get === NOOP) {
4246 warn$1(`Computed property "${key}" has no getter.`);
4247 }
4248 const set = !isFunction(opt) && isFunction(opt.set)
4249 ? opt.set.bind(publicThis)
4250 : () => {
4251 warn$1(`Write operation failed: computed property "${key}" is readonly.`);
4252 }
4253 ;
4254 const c = computed$1({
4255 get,
4256 set
4257 });
4258 Object.defineProperty(ctx, key, {
4259 enumerable: true,
4260 configurable: true,
4261 get: () => c.value,
4262 set: v => (c.value = v)
4263 });
4264 {
4265 checkDuplicateProperties("Computed" /* COMPUTED */, key);
4266 }
4267 }
4268 }
4269 if (watchOptions) {
4270 for (const key in watchOptions) {
4271 createWatcher(watchOptions[key], ctx, publicThis, key);
4272 }
4273 }
4274 if (provideOptions) {
4275 const provides = isFunction(provideOptions)
4276 ? provideOptions.call(publicThis)
4277 : provideOptions;
4278 Reflect.ownKeys(provides).forEach(key => {
4279 provide(key, provides[key]);
4280 });
4281 }
4282 if (created) {
4283 callHook(created, instance, "c" /* CREATED */);
4284 }
4285 function registerLifecycleHook(register, hook) {
4286 if (isArray(hook)) {
4287 hook.forEach(_hook => register(_hook.bind(publicThis)));
4288 }
4289 else if (hook) {
4290 register(hook.bind(publicThis));
4291 }
4292 }
4293 registerLifecycleHook(onBeforeMount, beforeMount);
4294 registerLifecycleHook(onMounted, mounted);
4295 registerLifecycleHook(onBeforeUpdate, beforeUpdate);
4296 registerLifecycleHook(onUpdated, updated);
4297 registerLifecycleHook(onActivated, activated);
4298 registerLifecycleHook(onDeactivated, deactivated);
4299 registerLifecycleHook(onErrorCaptured, errorCaptured);
4300 registerLifecycleHook(onRenderTracked, renderTracked);
4301 registerLifecycleHook(onRenderTriggered, renderTriggered);
4302 registerLifecycleHook(onBeforeUnmount, beforeUnmount);
4303 registerLifecycleHook(onUnmounted, unmounted);
4304 registerLifecycleHook(onServerPrefetch, serverPrefetch);
4305 if (isArray(expose)) {
4306 if (expose.length) {
4307 const exposed = instance.exposed || (instance.exposed = {});
4308 expose.forEach(key => {
4309 Object.defineProperty(exposed, key, {
4310 get: () => publicThis[key],
4311 set: val => (publicThis[key] = val)
4312 });
4313 });
4314 }
4315 else if (!instance.exposed) {
4316 instance.exposed = {};
4317 }
4318 }
4319 // options that are handled when creating the instance but also need to be
4320 // applied from mixins
4321 if (render && instance.render === NOOP) {
4322 instance.render = render;
4323 }
4324 if (inheritAttrs != null) {
4325 instance.inheritAttrs = inheritAttrs;
4326 }
4327 // asset options.
4328 if (components)
4329 instance.components = components;
4330 if (directives)
4331 instance.directives = directives;
4332}
4333function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {
4334 if (isArray(injectOptions)) {
4335 injectOptions = normalizeInject(injectOptions);
4336 }
4337 for (const key in injectOptions) {
4338 const opt = injectOptions[key];
4339 let injected;
4340 if (isObject(opt)) {
4341 if ('default' in opt) {
4342 injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4343 }
4344 else {
4345 injected = inject(opt.from || key);
4346 }
4347 }
4348 else {
4349 injected = inject(opt);
4350 }
4351 if (isRef(injected)) {
4352 // TODO remove the check in 3.3
4353 if (unwrapRef) {
4354 Object.defineProperty(ctx, key, {
4355 enumerable: true,
4356 configurable: true,
4357 get: () => injected.value,
4358 set: v => (injected.value = v)
4359 });
4360 }
4361 else {
4362 {
4363 warn$1(`injected property "${key}" is a ref and will be auto-unwrapped ` +
4364 `and no longer needs \`.value\` in the next minor release. ` +
4365 `To opt-in to the new behavior now, ` +
4366 `set \`app.config.unwrapInjectedRef = true\` (this config is ` +
4367 `temporary and will not be needed in the future.)`);
4368 }
4369 ctx[key] = injected;
4370 }
4371 }
4372 else {
4373 ctx[key] = injected;
4374 }
4375 {
4376 checkDuplicateProperties("Inject" /* INJECT */, key);
4377 }
4378 }
4379}
4380function callHook(hook, instance, type) {
4381 callWithAsyncErrorHandling(isArray(hook)
4382 ? hook.map(h => h.bind(instance.proxy))
4383 : hook.bind(instance.proxy), instance, type);
4384}
4385function createWatcher(raw, ctx, publicThis, key) {
4386 const getter = key.includes('.')
4387 ? createPathGetter(publicThis, key)
4388 : () => publicThis[key];
4389 if (isString(raw)) {
4390 const handler = ctx[raw];
4391 if (isFunction(handler)) {
4392 watch(getter, handler);
4393 }
4394 else {
4395 warn$1(`Invalid watch handler specified by key "${raw}"`, handler);
4396 }
4397 }
4398 else if (isFunction(raw)) {
4399 watch(getter, raw.bind(publicThis));
4400 }
4401 else if (isObject(raw)) {
4402 if (isArray(raw)) {
4403 raw.forEach(r => createWatcher(r, ctx, publicThis, key));
4404 }
4405 else {
4406 const handler = isFunction(raw.handler)
4407 ? raw.handler.bind(publicThis)
4408 : ctx[raw.handler];
4409 if (isFunction(handler)) {
4410 watch(getter, handler, raw);
4411 }
4412 else {
4413 warn$1(`Invalid watch handler specified by key "${raw.handler}"`, handler);
4414 }
4415 }
4416 }
4417 else {
4418 warn$1(`Invalid watch option: "${key}"`, raw);
4419 }
4420}
4421/**
4422 * Resolve merged options and cache it on the component.
4423 * This is done only once per-component since the merging does not involve
4424 * instances.
4425 */
4426function resolveMergedOptions(instance) {
4427 const base = instance.type;
4428 const { mixins, extends: extendsOptions } = base;
4429 const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
4430 const cached = cache.get(base);
4431 let resolved;
4432 if (cached) {
4433 resolved = cached;
4434 }
4435 else if (!globalMixins.length && !mixins && !extendsOptions) {
4436 {
4437 resolved = base;
4438 }
4439 }
4440 else {
4441 resolved = {};
4442 if (globalMixins.length) {
4443 globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
4444 }
4445 mergeOptions(resolved, base, optionMergeStrategies);
4446 }
4447 cache.set(base, resolved);
4448 return resolved;
4449}
4450function mergeOptions(to, from, strats, asMixin = false) {
4451 const { mixins, extends: extendsOptions } = from;
4452 if (extendsOptions) {
4453 mergeOptions(to, extendsOptions, strats, true);
4454 }
4455 if (mixins) {
4456 mixins.forEach((m) => mergeOptions(to, m, strats, true));
4457 }
4458 for (const key in from) {
4459 if (asMixin && key === 'expose') {
4460 warn$1(`"expose" option is ignored when declared in mixins or extends. ` +
4461 `It should only be declared in the base component itself.`);
4462 }
4463 else {
4464 const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
4465 to[key] = strat ? strat(to[key], from[key]) : from[key];
4466 }
4467 }
4468 return to;
4469}
4470const internalOptionMergeStrats = {
4471 data: mergeDataFn,
4472 props: mergeObjectOptions,
4473 emits: mergeObjectOptions,
4474 // objects
4475 methods: mergeObjectOptions,
4476 computed: mergeObjectOptions,
4477 // lifecycle
4478 beforeCreate: mergeAsArray,
4479 created: mergeAsArray,
4480 beforeMount: mergeAsArray,
4481 mounted: mergeAsArray,
4482 beforeUpdate: mergeAsArray,
4483 updated: mergeAsArray,
4484 beforeDestroy: mergeAsArray,
4485 beforeUnmount: mergeAsArray,
4486 destroyed: mergeAsArray,
4487 unmounted: mergeAsArray,
4488 activated: mergeAsArray,
4489 deactivated: mergeAsArray,
4490 errorCaptured: mergeAsArray,
4491 serverPrefetch: mergeAsArray,
4492 // assets
4493 components: mergeObjectOptions,
4494 directives: mergeObjectOptions,
4495 // watch
4496 watch: mergeWatchOptions,
4497 // provide / inject
4498 provide: mergeDataFn,
4499 inject: mergeInject
4500};
4501function mergeDataFn(to, from) {
4502 if (!from) {
4503 return to;
4504 }
4505 if (!to) {
4506 return from;
4507 }
4508 return function mergedDataFn() {
4509 return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
4510 };
4511}
4512function mergeInject(to, from) {
4513 return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
4514}
4515function normalizeInject(raw) {
4516 if (isArray(raw)) {
4517 const res = {};
4518 for (let i = 0; i < raw.length; i++) {
4519 res[raw[i]] = raw[i];
4520 }
4521 return res;
4522 }
4523 return raw;
4524}
4525function mergeAsArray(to, from) {
4526 return to ? [...new Set([].concat(to, from))] : from;
4527}
4528function mergeObjectOptions(to, from) {
4529 return to ? extend(extend(Object.create(null), to), from) : from;
4530}
4531function mergeWatchOptions(to, from) {
4532 if (!to)
4533 return from;
4534 if (!from)
4535 return to;
4536 const merged = extend(Object.create(null), to);
4537 for (const key in from) {
4538 merged[key] = mergeAsArray(to[key], from[key]);
4539 }
4540 return merged;
4541}
4542
4543function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
4544isSSR = false) {
4545 const props = {};
4546 const attrs = {};
4547 def(attrs, InternalObjectKey, 1);
4548 instance.propsDefaults = Object.create(null);
4549 setFullProps(instance, rawProps, props, attrs);
4550 // ensure all declared prop keys are present
4551 for (const key in instance.propsOptions[0]) {
4552 if (!(key in props)) {
4553 props[key] = undefined;
4554 }
4555 }
4556 // validation
4557 {
4558 validateProps(rawProps || {}, props, instance);
4559 }
4560 if (isStateful) {
4561 // stateful
4562 instance.props = isSSR ? props : shallowReactive(props);
4563 }
4564 else {
4565 if (!instance.type.props) {
4566 // functional w/ optional props, props === attrs
4567 instance.props = attrs;
4568 }
4569 else {
4570 // functional w/ declared props
4571 instance.props = props;
4572 }
4573 }
4574 instance.attrs = attrs;
4575}
4576function updateProps(instance, rawProps, rawPrevProps, optimized) {
4577 const { props, attrs, vnode: { patchFlag } } = instance;
4578 const rawCurrentProps = toRaw(props);
4579 const [options] = instance.propsOptions;
4580 let hasAttrsChanged = false;
4581 if (
4582 // always force full diff in dev
4583 // - #1942 if hmr is enabled with sfc component
4584 // - vite#872 non-sfc component used by sfc component
4585 !((instance.type.__hmrId ||
4586 (instance.parent && instance.parent.type.__hmrId))) &&
4587 (optimized || patchFlag > 0) &&
4588 !(patchFlag & 16 /* FULL_PROPS */)) {
4589 if (patchFlag & 8 /* PROPS */) {
4590 // Compiler-generated props & no keys change, just set the updated
4591 // the props.
4592 const propsToUpdate = instance.vnode.dynamicProps;
4593 for (let i = 0; i < propsToUpdate.length; i++) {
4594 let key = propsToUpdate[i];
4595 // PROPS flag guarantees rawProps to be non-null
4596 const value = rawProps[key];
4597 if (options) {
4598 // attr / props separation was done on init and will be consistent
4599 // in this code path, so just check if attrs have it.
4600 if (hasOwn(attrs, key)) {
4601 if (value !== attrs[key]) {
4602 attrs[key] = value;
4603 hasAttrsChanged = true;
4604 }
4605 }
4606 else {
4607 const camelizedKey = camelize(key);
4608 props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);
4609 }
4610 }
4611 else {
4612 if (value !== attrs[key]) {
4613 attrs[key] = value;
4614 hasAttrsChanged = true;
4615 }
4616 }
4617 }
4618 }
4619 }
4620 else {
4621 // full props update.
4622 if (setFullProps(instance, rawProps, props, attrs)) {
4623 hasAttrsChanged = true;
4624 }
4625 // in case of dynamic props, check if we need to delete keys from
4626 // the props object
4627 let kebabKey;
4628 for (const key in rawCurrentProps) {
4629 if (!rawProps ||
4630 // for camelCase
4631 (!hasOwn(rawProps, key) &&
4632 // it's possible the original props was passed in as kebab-case
4633 // and converted to camelCase (#955)
4634 ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {
4635 if (options) {
4636 if (rawPrevProps &&
4637 // for camelCase
4638 (rawPrevProps[key] !== undefined ||
4639 // for kebab-case
4640 rawPrevProps[kebabKey] !== undefined)) {
4641 props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);
4642 }
4643 }
4644 else {
4645 delete props[key];
4646 }
4647 }
4648 }
4649 // in the case of functional component w/o props declaration, props and
4650 // attrs point to the same object so it should already have been updated.
4651 if (attrs !== rawCurrentProps) {
4652 for (const key in attrs) {
4653 if (!rawProps ||
4654 (!hasOwn(rawProps, key) &&
4655 (!false ))) {
4656 delete attrs[key];
4657 hasAttrsChanged = true;
4658 }
4659 }
4660 }
4661 }
4662 // trigger updates for $attrs in case it's used in component slots
4663 if (hasAttrsChanged) {
4664 trigger(instance, "set" /* SET */, '$attrs');
4665 }
4666 {
4667 validateProps(rawProps || {}, props, instance);
4668 }
4669}
4670function setFullProps(instance, rawProps, props, attrs) {
4671 const [options, needCastKeys] = instance.propsOptions;
4672 let hasAttrsChanged = false;
4673 let rawCastValues;
4674 if (rawProps) {
4675 for (let key in rawProps) {
4676 // key, ref are reserved and never passed down
4677 if (isReservedProp(key)) {
4678 continue;
4679 }
4680 const value = rawProps[key];
4681 // prop option names are camelized during normalization, so to support
4682 // kebab -> camel conversion here we need to camelize the key.
4683 let camelKey;
4684 if (options && hasOwn(options, (camelKey = camelize(key)))) {
4685 if (!needCastKeys || !needCastKeys.includes(camelKey)) {
4686 props[camelKey] = value;
4687 }
4688 else {
4689 (rawCastValues || (rawCastValues = {}))[camelKey] = value;
4690 }
4691 }
4692 else if (!isEmitListener(instance.emitsOptions, key)) {
4693 if (!(key in attrs) || value !== attrs[key]) {
4694 attrs[key] = value;
4695 hasAttrsChanged = true;
4696 }
4697 }
4698 }
4699 }
4700 if (needCastKeys) {
4701 const rawCurrentProps = toRaw(props);
4702 const castValues = rawCastValues || EMPTY_OBJ;
4703 for (let i = 0; i < needCastKeys.length; i++) {
4704 const key = needCastKeys[i];
4705 props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));
4706 }
4707 }
4708 return hasAttrsChanged;
4709}
4710function resolvePropValue(options, props, key, value, instance, isAbsent) {
4711 const opt = options[key];
4712 if (opt != null) {
4713 const hasDefault = hasOwn(opt, 'default');
4714 // default values
4715 if (hasDefault && value === undefined) {
4716 const defaultValue = opt.default;
4717 if (opt.type !== Function && isFunction(defaultValue)) {
4718 const { propsDefaults } = instance;
4719 if (key in propsDefaults) {
4720 value = propsDefaults[key];
4721 }
4722 else {
4723 setCurrentInstance(instance);
4724 value = propsDefaults[key] = defaultValue.call(null, props);
4725 unsetCurrentInstance();
4726 }
4727 }
4728 else {
4729 value = defaultValue;
4730 }
4731 }
4732 // boolean casting
4733 if (opt[0 /* shouldCast */]) {
4734 if (isAbsent && !hasDefault) {
4735 value = false;
4736 }
4737 else if (opt[1 /* shouldCastTrue */] &&
4738 (value === '' || value === hyphenate(key))) {
4739 value = true;
4740 }
4741 }
4742 }
4743 return value;
4744}
4745function normalizePropsOptions(comp, appContext, asMixin = false) {
4746 const cache = appContext.propsCache;
4747 const cached = cache.get(comp);
4748 if (cached) {
4749 return cached;
4750 }
4751 const raw = comp.props;
4752 const normalized = {};
4753 const needCastKeys = [];
4754 // apply mixin/extends props
4755 let hasExtends = false;
4756 if (!isFunction(comp)) {
4757 const extendProps = (raw) => {
4758 hasExtends = true;
4759 const [props, keys] = normalizePropsOptions(raw, appContext, true);
4760 extend(normalized, props);
4761 if (keys)
4762 needCastKeys.push(...keys);
4763 };
4764 if (!asMixin && appContext.mixins.length) {
4765 appContext.mixins.forEach(extendProps);
4766 }
4767 if (comp.extends) {
4768 extendProps(comp.extends);
4769 }
4770 if (comp.mixins) {
4771 comp.mixins.forEach(extendProps);
4772 }
4773 }
4774 if (!raw && !hasExtends) {
4775 cache.set(comp, EMPTY_ARR);
4776 return EMPTY_ARR;
4777 }
4778 if (isArray(raw)) {
4779 for (let i = 0; i < raw.length; i++) {
4780 if (!isString(raw[i])) {
4781 warn$1(`props must be strings when using array syntax.`, raw[i]);
4782 }
4783 const normalizedKey = camelize(raw[i]);
4784 if (validatePropName(normalizedKey)) {
4785 normalized[normalizedKey] = EMPTY_OBJ;
4786 }
4787 }
4788 }
4789 else if (raw) {
4790 if (!isObject(raw)) {
4791 warn$1(`invalid props options`, raw);
4792 }
4793 for (const key in raw) {
4794 const normalizedKey = camelize(key);
4795 if (validatePropName(normalizedKey)) {
4796 const opt = raw[key];
4797 const prop = (normalized[normalizedKey] =
4798 isArray(opt) || isFunction(opt) ? { type: opt } : opt);
4799 if (prop) {
4800 const booleanIndex = getTypeIndex(Boolean, prop.type);
4801 const stringIndex = getTypeIndex(String, prop.type);
4802 prop[0 /* shouldCast */] = booleanIndex > -1;
4803 prop[1 /* shouldCastTrue */] =
4804 stringIndex < 0 || booleanIndex < stringIndex;
4805 // if the prop needs boolean casting or default value
4806 if (booleanIndex > -1 || hasOwn(prop, 'default')) {
4807 needCastKeys.push(normalizedKey);
4808 }
4809 }
4810 }
4811 }
4812 }
4813 const res = [normalized, needCastKeys];
4814 cache.set(comp, res);
4815 return res;
4816}
4817function validatePropName(key) {
4818 if (key[0] !== '$') {
4819 return true;
4820 }
4821 else {
4822 warn$1(`Invalid prop name: "${key}" is a reserved property.`);
4823 }
4824 return false;
4825}
4826// use function string name to check type constructors
4827// so that it works across vms / iframes.
4828function getType(ctor) {
4829 const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
4830 return match ? match[1] : ctor === null ? 'null' : '';
4831}
4832function isSameType(a, b) {
4833 return getType(a) === getType(b);
4834}
4835function getTypeIndex(type, expectedTypes) {
4836 if (isArray(expectedTypes)) {
4837 return expectedTypes.findIndex(t => isSameType(t, type));
4838 }
4839 else if (isFunction(expectedTypes)) {
4840 return isSameType(expectedTypes, type) ? 0 : -1;
4841 }
4842 return -1;
4843}
4844/**
4845 * dev only
4846 */
4847function validateProps(rawProps, props, instance) {
4848 const resolvedValues = toRaw(props);
4849 const options = instance.propsOptions[0];
4850 for (const key in options) {
4851 let opt = options[key];
4852 if (opt == null)
4853 continue;
4854 validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));
4855 }
4856}
4857/**
4858 * dev only
4859 */
4860function validateProp(name, value, prop, isAbsent) {
4861 const { type, required, validator } = prop;
4862 // required!
4863 if (required && isAbsent) {
4864 warn$1('Missing required prop: "' + name + '"');
4865 return;
4866 }
4867 // missing but optional
4868 if (value == null && !prop.required) {
4869 return;
4870 }
4871 // type check
4872 if (type != null && type !== true) {
4873 let isValid = false;
4874 const types = isArray(type) ? type : [type];
4875 const expectedTypes = [];
4876 // value is valid as long as one of the specified types match
4877 for (let i = 0; i < types.length && !isValid; i++) {
4878 const { valid, expectedType } = assertType(value, types[i]);
4879 expectedTypes.push(expectedType || '');
4880 isValid = valid;
4881 }
4882 if (!isValid) {
4883 warn$1(getInvalidTypeMessage(name, value, expectedTypes));
4884 return;
4885 }
4886 }
4887 // custom validator
4888 if (validator && !validator(value)) {
4889 warn$1('Invalid prop: custom validator check failed for prop "' + name + '".');
4890 }
4891}
4892const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol,BigInt');
4893/**
4894 * dev only
4895 */
4896function assertType(value, type) {
4897 let valid;
4898 const expectedType = getType(type);
4899 if (isSimpleType(expectedType)) {
4900 const t = typeof value;
4901 valid = t === expectedType.toLowerCase();
4902 // for primitive wrapper objects
4903 if (!valid && t === 'object') {
4904 valid = value instanceof type;
4905 }
4906 }
4907 else if (expectedType === 'Object') {
4908 valid = isObject(value);
4909 }
4910 else if (expectedType === 'Array') {
4911 valid = isArray(value);
4912 }
4913 else if (expectedType === 'null') {
4914 valid = value === null;
4915 }
4916 else {
4917 valid = value instanceof type;
4918 }
4919 return {
4920 valid,
4921 expectedType
4922 };
4923}
4924/**
4925 * dev only
4926 */
4927function getInvalidTypeMessage(name, value, expectedTypes) {
4928 let message = `Invalid prop: type check failed for prop "${name}".` +
4929 ` Expected ${expectedTypes.map(capitalize).join(' | ')}`;
4930 const expectedType = expectedTypes[0];
4931 const receivedType = toRawType(value);
4932 const expectedValue = styleValue(value, expectedType);
4933 const receivedValue = styleValue(value, receivedType);
4934 // check if we need to specify expected value
4935 if (expectedTypes.length === 1 &&
4936 isExplicable(expectedType) &&
4937 !isBoolean(expectedType, receivedType)) {
4938 message += ` with value ${expectedValue}`;
4939 }
4940 message += `, got ${receivedType} `;
4941 // check if we need to specify received value
4942 if (isExplicable(receivedType)) {
4943 message += `with value ${receivedValue}.`;
4944 }
4945 return message;
4946}
4947/**
4948 * dev only
4949 */
4950function styleValue(value, type) {
4951 if (type === 'String') {
4952 return `"${value}"`;
4953 }
4954 else if (type === 'Number') {
4955 return `${Number(value)}`;
4956 }
4957 else {
4958 return `${value}`;
4959 }
4960}
4961/**
4962 * dev only
4963 */
4964function isExplicable(type) {
4965 const explicitTypes = ['string', 'number', 'boolean'];
4966 return explicitTypes.some(elem => type.toLowerCase() === elem);
4967}
4968/**
4969 * dev only
4970 */
4971function isBoolean(...args) {
4972 return args.some(elem => elem.toLowerCase() === 'boolean');
4973}
4974
4975const isInternalKey = (key) => key[0] === '_' || key === '$stable';
4976const normalizeSlotValue = (value) => isArray(value)
4977 ? value.map(normalizeVNode)
4978 : [normalizeVNode(value)];
4979const normalizeSlot = (key, rawSlot, ctx) => {
4980 const normalized = withCtx((...args) => {
4981 if (currentInstance) {
4982 warn$1(`Slot "${key}" invoked outside of the render function: ` +
4983 `this will not track dependencies used in the slot. ` +
4984 `Invoke the slot function inside the render function instead.`);
4985 }
4986 return normalizeSlotValue(rawSlot(...args));
4987 }, ctx);
4988 normalized._c = false;
4989 return normalized;
4990};
4991const normalizeObjectSlots = (rawSlots, slots, instance) => {
4992 const ctx = rawSlots._ctx;
4993 for (const key in rawSlots) {
4994 if (isInternalKey(key))
4995 continue;
4996 const value = rawSlots[key];
4997 if (isFunction(value)) {
4998 slots[key] = normalizeSlot(key, value, ctx);
4999 }
5000 else if (value != null) {
5001 {
5002 warn$1(`Non-function value encountered for slot "${key}". ` +
5003 `Prefer function slots for better performance.`);
5004 }
5005 const normalized = normalizeSlotValue(value);
5006 slots[key] = () => normalized;
5007 }
5008 }
5009};
5010const normalizeVNodeSlots = (instance, children) => {
5011 if (!isKeepAlive(instance.vnode) &&
5012 !(false )) {
5013 warn$1(`Non-function value encountered for default slot. ` +
5014 `Prefer function slots for better performance.`);
5015 }
5016 const normalized = normalizeSlotValue(children);
5017 instance.slots.default = () => normalized;
5018};
5019const initSlots = (instance, children) => {
5020 if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5021 const type = children._;
5022 if (type) {
5023 // users can get the shallow readonly version of the slots object through `this.$slots`,
5024 // we should avoid the proxy object polluting the slots of the internal instance
5025 instance.slots = toRaw(children);
5026 // make compiler marker non-enumerable
5027 def(children, '_', type);
5028 }
5029 else {
5030 normalizeObjectSlots(children, (instance.slots = {}));
5031 }
5032 }
5033 else {
5034 instance.slots = {};
5035 if (children) {
5036 normalizeVNodeSlots(instance, children);
5037 }
5038 }
5039 def(instance.slots, InternalObjectKey, 1);
5040};
5041const updateSlots = (instance, children, optimized) => {
5042 const { vnode, slots } = instance;
5043 let needDeletionCheck = true;
5044 let deletionComparisonTarget = EMPTY_OBJ;
5045 if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {
5046 const type = children._;
5047 if (type) {
5048 // compiled slots.
5049 if (isHmrUpdating) {
5050 // Parent was HMR updated so slot content may have changed.
5051 // force update slots and mark instance for hmr as well
5052 extend(slots, children);
5053 }
5054 else if (optimized && type === 1 /* STABLE */) {
5055 // compiled AND stable.
5056 // no need to update, and skip stale slots removal.
5057 needDeletionCheck = false;
5058 }
5059 else {
5060 // compiled but dynamic (v-if/v-for on slots) - update slots, but skip
5061 // normalization.
5062 extend(slots, children);
5063 // #2893
5064 // when rendering the optimized slots by manually written render function,
5065 // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
5066 // i.e. let the `renderSlot` create the bailed Fragment
5067 if (!optimized && type === 1 /* STABLE */) {
5068 delete slots._;
5069 }
5070 }
5071 }
5072 else {
5073 needDeletionCheck = !children.$stable;
5074 normalizeObjectSlots(children, slots);
5075 }
5076 deletionComparisonTarget = children;
5077 }
5078 else if (children) {
5079 // non slot object children (direct value) passed to a component
5080 normalizeVNodeSlots(instance, children);
5081 deletionComparisonTarget = { default: 1 };
5082 }
5083 // delete stale slots
5084 if (needDeletionCheck) {
5085 for (const key in slots) {
5086 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {
5087 delete slots[key];
5088 }
5089 }
5090 }
5091};
5092
5093/**
5094Runtime helper for applying directives to a vnode. Example usage:
5095
5096const comp = resolveComponent('comp')
5097const foo = resolveDirective('foo')
5098const bar = resolveDirective('bar')
5099
5100return withDirectives(h(comp), [
5101 [foo, this.x],
5102 [bar, this.y]
5103])
5104*/
5105function validateDirectiveName(name) {
5106 if (isBuiltInDirective(name)) {
5107 warn$1('Do not use built-in directive ids as custom directive id: ' + name);
5108 }
5109}
5110/**
5111 * Adds directives to a VNode.
5112 */
5113function withDirectives(vnode, directives) {
5114 const internalInstance = currentRenderingInstance;
5115 if (internalInstance === null) {
5116 warn$1(`withDirectives can only be used inside render functions.`);
5117 return vnode;
5118 }
5119 const instance = internalInstance.proxy;
5120 const bindings = vnode.dirs || (vnode.dirs = []);
5121 for (let i = 0; i < directives.length; i++) {
5122 let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
5123 if (isFunction(dir)) {
5124 dir = {
5125 mounted: dir,
5126 updated: dir
5127 };
5128 }
5129 if (dir.deep) {
5130 traverse(value);
5131 }
5132 bindings.push({
5133 dir,
5134 instance,
5135 value,
5136 oldValue: void 0,
5137 arg,
5138 modifiers
5139 });
5140 }
5141 return vnode;
5142}
5143function invokeDirectiveHook(vnode, prevVNode, instance, name) {
5144 const bindings = vnode.dirs;
5145 const oldBindings = prevVNode && prevVNode.dirs;
5146 for (let i = 0; i < bindings.length; i++) {
5147 const binding = bindings[i];
5148 if (oldBindings) {
5149 binding.oldValue = oldBindings[i].value;
5150 }
5151 let hook = binding.dir[name];
5152 if (hook) {
5153 // disable tracking inside all lifecycle hooks
5154 // since they can potentially be called inside effects.
5155 pauseTracking();
5156 callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
5157 vnode.el,
5158 binding,
5159 vnode,
5160 prevVNode
5161 ]);
5162 resetTracking();
5163 }
5164 }
5165}
5166
5167function createAppContext() {
5168 return {
5169 app: null,
5170 config: {
5171 isNativeTag: NO,
5172 performance: false,
5173 globalProperties: {},
5174 optionMergeStrategies: {},
5175 errorHandler: undefined,
5176 warnHandler: undefined,
5177 compilerOptions: {}
5178 },
5179 mixins: [],
5180 components: {},
5181 directives: {},
5182 provides: Object.create(null),
5183 optionsCache: new WeakMap(),
5184 propsCache: new WeakMap(),
5185 emitsCache: new WeakMap()
5186 };
5187}
5188let uid = 0;
5189function createAppAPI(render, hydrate) {
5190 return function createApp(rootComponent, rootProps = null) {
5191 if (rootProps != null && !isObject(rootProps)) {
5192 warn$1(`root props passed to app.mount() must be an object.`);
5193 rootProps = null;
5194 }
5195 const context = createAppContext();
5196 const installedPlugins = new Set();
5197 let isMounted = false;
5198 const app = (context.app = {
5199 _uid: uid++,
5200 _component: rootComponent,
5201 _props: rootProps,
5202 _container: null,
5203 _context: context,
5204 _instance: null,
5205 version,
5206 get config() {
5207 return context.config;
5208 },
5209 set config(v) {
5210 {
5211 warn$1(`app.config cannot be replaced. Modify individual options instead.`);
5212 }
5213 },
5214 use(plugin, ...options) {
5215 if (installedPlugins.has(plugin)) {
5216 warn$1(`Plugin has already been applied to target app.`);
5217 }
5218 else if (plugin && isFunction(plugin.install)) {
5219 installedPlugins.add(plugin);
5220 plugin.install(app, ...options);
5221 }
5222 else if (isFunction(plugin)) {
5223 installedPlugins.add(plugin);
5224 plugin(app, ...options);
5225 }
5226 else {
5227 warn$1(`A plugin must either be a function or an object with an "install" ` +
5228 `function.`);
5229 }
5230 return app;
5231 },
5232 mixin(mixin) {
5233 {
5234 if (!context.mixins.includes(mixin)) {
5235 context.mixins.push(mixin);
5236 }
5237 else {
5238 warn$1('Mixin has already been applied to target app' +
5239 (mixin.name ? `: ${mixin.name}` : ''));
5240 }
5241 }
5242 return app;
5243 },
5244 component(name, component) {
5245 {
5246 validateComponentName(name, context.config);
5247 }
5248 if (!component) {
5249 return context.components[name];
5250 }
5251 if (context.components[name]) {
5252 warn$1(`Component "${name}" has already been registered in target app.`);
5253 }
5254 context.components[name] = component;
5255 return app;
5256 },
5257 directive(name, directive) {
5258 {
5259 validateDirectiveName(name);
5260 }
5261 if (!directive) {
5262 return context.directives[name];
5263 }
5264 if (context.directives[name]) {
5265 warn$1(`Directive "${name}" has already been registered in target app.`);
5266 }
5267 context.directives[name] = directive;
5268 return app;
5269 },
5270 mount(rootContainer, isHydrate, isSVG) {
5271 if (!isMounted) {
5272 const vnode = createVNode(rootComponent, rootProps);
5273 // store app context on the root VNode.
5274 // this will be set on the root instance on initial mount.
5275 vnode.appContext = context;
5276 // HMR root reload
5277 {
5278 context.reload = () => {
5279 render(cloneVNode(vnode), rootContainer, isSVG);
5280 };
5281 }
5282 if (isHydrate && hydrate) {
5283 hydrate(vnode, rootContainer);
5284 }
5285 else {
5286 render(vnode, rootContainer, isSVG);
5287 }
5288 isMounted = true;
5289 app._container = rootContainer;
5290 rootContainer.__vue_app__ = app;
5291 {
5292 app._instance = vnode.component;
5293 devtoolsInitApp(app, version);
5294 }
5295 return getExposeProxy(vnode.component) || vnode.component.proxy;
5296 }
5297 else {
5298 warn$1(`App has already been mounted.\n` +
5299 `If you want to remount the same app, move your app creation logic ` +
5300 `into a factory function and create fresh app instances for each ` +
5301 `mount - e.g. \`const createMyApp = () => createApp(App)\``);
5302 }
5303 },
5304 unmount() {
5305 if (isMounted) {
5306 render(null, app._container);
5307 {
5308 app._instance = null;
5309 devtoolsUnmountApp(app);
5310 }
5311 delete app._container.__vue_app__;
5312 }
5313 else {
5314 warn$1(`Cannot unmount an app that is not mounted.`);
5315 }
5316 },
5317 provide(key, value) {
5318 if (key in context.provides) {
5319 warn$1(`App already provides property with key "${String(key)}". ` +
5320 `It will be overwritten with the new value.`);
5321 }
5322 // TypeScript doesn't allow symbols as index type
5323 // https://github.com/Microsoft/TypeScript/issues/24587
5324 context.provides[key] = value;
5325 return app;
5326 }
5327 });
5328 return app;
5329 };
5330}
5331
5332/**
5333 * Function for handling a template ref
5334 */
5335function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
5336 if (isArray(rawRef)) {
5337 rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount));
5338 return;
5339 }
5340 if (isAsyncWrapper(vnode) && !isUnmount) {
5341 // when mounting async components, nothing needs to be done,
5342 // because the template ref is forwarded to inner component
5343 return;
5344 }
5345 const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
5346 ? getExposeProxy(vnode.component) || vnode.component.proxy
5347 : vnode.el;
5348 const value = isUnmount ? null : refValue;
5349 const { i: owner, r: ref } = rawRef;
5350 if (!owner) {
5351 warn$1(`Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
5352 `A vnode with ref must be created inside the render function.`);
5353 return;
5354 }
5355 const oldRef = oldRawRef && oldRawRef.r;
5356 const refs = owner.refs === EMPTY_OBJ ? (owner.refs = {}) : owner.refs;
5357 const setupState = owner.setupState;
5358 // dynamic ref changed. unset old ref
5359 if (oldRef != null && oldRef !== ref) {
5360 if (isString(oldRef)) {
5361 refs[oldRef] = null;
5362 if (hasOwn(setupState, oldRef)) {
5363 setupState[oldRef] = null;
5364 }
5365 }
5366 else if (isRef(oldRef)) {
5367 oldRef.value = null;
5368 }
5369 }
5370 if (isFunction(ref)) {
5371 callWithErrorHandling(ref, owner, 12 /* FUNCTION_REF */, [value, refs]);
5372 }
5373 else {
5374 const _isString = isString(ref);
5375 const _isRef = isRef(ref);
5376 if (_isString || _isRef) {
5377 const doSet = () => {
5378 if (rawRef.f) {
5379 const existing = _isString ? refs[ref] : ref.value;
5380 if (isUnmount) {
5381 isArray(existing) && remove(existing, refValue);
5382 }
5383 else {
5384 if (!isArray(existing)) {
5385 if (_isString) {
5386 refs[ref] = [refValue];
5387 }
5388 else {
5389 ref.value = [refValue];
5390 if (rawRef.k)
5391 refs[rawRef.k] = ref.value;
5392 }
5393 }
5394 else if (!existing.includes(refValue)) {
5395 existing.push(refValue);
5396 }
5397 }
5398 }
5399 else if (_isString) {
5400 refs[ref] = value;
5401 if (hasOwn(setupState, ref)) {
5402 setupState[ref] = value;
5403 }
5404 }
5405 else if (isRef(ref)) {
5406 ref.value = value;
5407 if (rawRef.k)
5408 refs[rawRef.k] = value;
5409 }
5410 else {
5411 warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
5412 }
5413 };
5414 if (value) {
5415 doSet.id = -1;
5416 queuePostRenderEffect(doSet, parentSuspense);
5417 }
5418 else {
5419 doSet();
5420 }
5421 }
5422 else {
5423 warn$1('Invalid template ref type:', ref, `(${typeof ref})`);
5424 }
5425 }
5426}
5427
5428let hasMismatch = false;
5429const isSVGContainer = (container) => /svg/.test(container.namespaceURI) && container.tagName !== 'foreignObject';
5430const isComment = (node) => node.nodeType === 8 /* COMMENT */;
5431// Note: hydration is DOM-specific
5432// But we have to place it in core due to tight coupling with core - splitting
5433// it out creates a ton of unnecessary complexity.
5434// Hydration also depends on some renderer internal logic which needs to be
5435// passed in via arguments.
5436function createHydrationFunctions(rendererInternals) {
5437 const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
5438 const hydrate = (vnode, container) => {
5439 if (!container.hasChildNodes()) {
5440 warn$1(`Attempting to hydrate existing markup but container is empty. ` +
5441 `Performing full mount instead.`);
5442 patch(null, vnode, container);
5443 flushPostFlushCbs();
5444 return;
5445 }
5446 hasMismatch = false;
5447 hydrateNode(container.firstChild, vnode, null, null, null);
5448 flushPostFlushCbs();
5449 if (hasMismatch && !false) {
5450 // this error should show up in production
5451 console.error(`Hydration completed but contains mismatches.`);
5452 }
5453 };
5454 const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
5455 const isFragmentStart = isComment(node) && node.data === '[';
5456 const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart);
5457 const { type, ref, shapeFlag } = vnode;
5458 const domType = node.nodeType;
5459 vnode.el = node;
5460 let nextNode = null;
5461 switch (type) {
5462 case Text:
5463 if (domType !== 3 /* TEXT */) {
5464 nextNode = onMismatch();
5465 }
5466 else {
5467 if (node.data !== vnode.children) {
5468 hasMismatch = true;
5469 warn$1(`Hydration text mismatch:` +
5470 `\n- Client: ${JSON.stringify(node.data)}` +
5471 `\n- Server: ${JSON.stringify(vnode.children)}`);
5472 node.data = vnode.children;
5473 }
5474 nextNode = nextSibling(node);
5475 }
5476 break;
5477 case Comment:
5478 if (domType !== 8 /* COMMENT */ || isFragmentStart) {
5479 nextNode = onMismatch();
5480 }
5481 else {
5482 nextNode = nextSibling(node);
5483 }
5484 break;
5485 case Static:
5486 if (domType !== 1 /* ELEMENT */) {
5487 nextNode = onMismatch();
5488 }
5489 else {
5490 // determine anchor, adopt content
5491 nextNode = node;
5492 // if the static vnode has its content stripped during build,
5493 // adopt it from the server-rendered HTML.
5494 const needToAdoptContent = !vnode.children.length;
5495 for (let i = 0; i < vnode.staticCount; i++) {
5496 if (needToAdoptContent)
5497 vnode.children += nextNode.outerHTML;
5498 if (i === vnode.staticCount - 1) {
5499 vnode.anchor = nextNode;
5500 }
5501 nextNode = nextSibling(nextNode);
5502 }
5503 return nextNode;
5504 }
5505 break;
5506 case Fragment:
5507 if (!isFragmentStart) {
5508 nextNode = onMismatch();
5509 }
5510 else {
5511 nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
5512 }
5513 break;
5514 default:
5515 if (shapeFlag & 1 /* ELEMENT */) {
5516 if (domType !== 1 /* ELEMENT */ ||
5517 vnode.type.toLowerCase() !==
5518 node.tagName.toLowerCase()) {
5519 nextNode = onMismatch();
5520 }
5521 else {
5522 nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
5523 }
5524 }
5525 else if (shapeFlag & 6 /* COMPONENT */) {
5526 // when setting up the render effect, if the initial vnode already
5527 // has .el set, the component will perform hydration instead of mount
5528 // on its sub-tree.
5529 vnode.slotScopeIds = slotScopeIds;
5530 const container = parentNode(node);
5531 mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized);
5532 // component may be async, so in the case of fragments we cannot rely
5533 // on component's rendered output to determine the end of the fragment
5534 // instead, we do a lookahead to find the end anchor node.
5535 nextNode = isFragmentStart
5536 ? locateClosingAsyncAnchor(node)
5537 : nextSibling(node);
5538 // #3787
5539 // if component is async, it may get moved / unmounted before its
5540 // inner component is loaded, so we need to give it a placeholder
5541 // vnode that matches its adopted DOM.
5542 if (isAsyncWrapper(vnode)) {
5543 let subTree;
5544 if (isFragmentStart) {
5545 subTree = createVNode(Fragment);
5546 subTree.anchor = nextNode
5547 ? nextNode.previousSibling
5548 : container.lastChild;
5549 }
5550 else {
5551 subTree =
5552 node.nodeType === 3 ? createTextVNode('') : createVNode('div');
5553 }
5554 subTree.el = node;
5555 vnode.component.subTree = subTree;
5556 }
5557 }
5558 else if (shapeFlag & 64 /* TELEPORT */) {
5559 if (domType !== 8 /* COMMENT */) {
5560 nextNode = onMismatch();
5561 }
5562 else {
5563 nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
5564 }
5565 }
5566 else if (shapeFlag & 128 /* SUSPENSE */) {
5567 nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
5568 }
5569 else {
5570 warn$1('Invalid HostVNode type:', type, `(${typeof type})`);
5571 }
5572 }
5573 if (ref != null) {
5574 setRef(ref, null, parentSuspense, vnode);
5575 }
5576 return nextNode;
5577 };
5578 const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
5579 optimized = optimized || !!vnode.dynamicChildren;
5580 const { type, props, patchFlag, shapeFlag, dirs } = vnode;
5581 // #4006 for form elements with non-string v-model value bindings
5582 // e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
5583 const forcePatchValue = (type === 'input' && dirs) || type === 'option';
5584 // skip props & children if this is hoisted static nodes
5585 // #5405 in dev, always hydrate children for HMR
5586 {
5587 if (dirs) {
5588 invokeDirectiveHook(vnode, null, parentComponent, 'created');
5589 }
5590 // props
5591 if (props) {
5592 if (forcePatchValue ||
5593 !optimized ||
5594 patchFlag & (16 /* FULL_PROPS */ | 32 /* HYDRATE_EVENTS */)) {
5595 for (const key in props) {
5596 if ((forcePatchValue && key.endsWith('value')) ||
5597 (isOn(key) && !isReservedProp(key))) {
5598 patchProp(el, key, null, props[key], false, undefined, parentComponent);
5599 }
5600 }
5601 }
5602 else if (props.onClick) {
5603 // Fast path for click listeners (which is most often) to avoid
5604 // iterating through props.
5605 patchProp(el, 'onClick', null, props.onClick, false, undefined, parentComponent);
5606 }
5607 }
5608 // vnode / directive hooks
5609 let vnodeHooks;
5610 if ((vnodeHooks = props && props.onVnodeBeforeMount)) {
5611 invokeVNodeHook(vnodeHooks, parentComponent, vnode);
5612 }
5613 if (dirs) {
5614 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
5615 }
5616 if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
5617 queueEffectWithSuspense(() => {
5618 vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
5619 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
5620 }, parentSuspense);
5621 }
5622 // children
5623 if (shapeFlag & 16 /* ARRAY_CHILDREN */ &&
5624 // skip if element has innerHTML / textContent
5625 !(props && (props.innerHTML || props.textContent))) {
5626 let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
5627 let hasWarned = false;
5628 while (next) {
5629 hasMismatch = true;
5630 if (!hasWarned) {
5631 warn$1(`Hydration children mismatch in <${vnode.type}>: ` +
5632 `server rendered element contains more child nodes than client vdom.`);
5633 hasWarned = true;
5634 }
5635 // The SSRed DOM contains more nodes than it should. Remove them.
5636 const cur = next;
5637 next = next.nextSibling;
5638 remove(cur);
5639 }
5640 }
5641 else if (shapeFlag & 8 /* TEXT_CHILDREN */) {
5642 if (el.textContent !== vnode.children) {
5643 hasMismatch = true;
5644 warn$1(`Hydration text content mismatch in <${vnode.type}>:\n` +
5645 `- Client: ${el.textContent}\n` +
5646 `- Server: ${vnode.children}`);
5647 el.textContent = vnode.children;
5648 }
5649 }
5650 }
5651 return el.nextSibling;
5652 };
5653 const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
5654 optimized = optimized || !!parentVNode.dynamicChildren;
5655 const children = parentVNode.children;
5656 const l = children.length;
5657 let hasWarned = false;
5658 for (let i = 0; i < l; i++) {
5659 const vnode = optimized
5660 ? children[i]
5661 : (children[i] = normalizeVNode(children[i]));
5662 if (node) {
5663 node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
5664 }
5665 else if (vnode.type === Text && !vnode.children) {
5666 continue;
5667 }
5668 else {
5669 hasMismatch = true;
5670 if (!hasWarned) {
5671 warn$1(`Hydration children mismatch in <${container.tagName.toLowerCase()}>: ` +
5672 `server rendered element contains fewer child nodes than client vdom.`);
5673 hasWarned = true;
5674 }
5675 // the SSRed DOM didn't contain enough nodes. Mount the missing ones.
5676 patch(null, vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
5677 }
5678 }
5679 return node;
5680 };
5681 const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
5682 const { slotScopeIds: fragmentSlotScopeIds } = vnode;
5683 if (fragmentSlotScopeIds) {
5684 slotScopeIds = slotScopeIds
5685 ? slotScopeIds.concat(fragmentSlotScopeIds)
5686 : fragmentSlotScopeIds;
5687 }
5688 const container = parentNode(node);
5689 const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized);
5690 if (next && isComment(next) && next.data === ']') {
5691 return nextSibling((vnode.anchor = next));
5692 }
5693 else {
5694 // fragment didn't hydrate successfully, since we didn't get a end anchor
5695 // back. This should have led to node/children mismatch warnings.
5696 hasMismatch = true;
5697 // since the anchor is missing, we need to create one and insert it
5698 insert((vnode.anchor = createComment(`]`)), container, next);
5699 return next;
5700 }
5701 };
5702 const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
5703 hasMismatch = true;
5704 warn$1(`Hydration node mismatch:\n- Client vnode:`, vnode.type, `\n- Server rendered DOM:`, node, node.nodeType === 3 /* TEXT */
5705 ? `(text)`
5706 : isComment(node) && node.data === '['
5707 ? `(start of fragment)`
5708 : ``);
5709 vnode.el = null;
5710 if (isFragment) {
5711 // remove excessive fragment nodes
5712 const end = locateClosingAsyncAnchor(node);
5713 while (true) {
5714 const next = nextSibling(node);
5715 if (next && next !== end) {
5716 remove(next);
5717 }
5718 else {
5719 break;
5720 }
5721 }
5722 }
5723 const next = nextSibling(node);
5724 const container = parentNode(node);
5725 remove(node);
5726 patch(null, vnode, container, next, parentComponent, parentSuspense, isSVGContainer(container), slotScopeIds);
5727 return next;
5728 };
5729 const locateClosingAsyncAnchor = (node) => {
5730 let match = 0;
5731 while (node) {
5732 node = nextSibling(node);
5733 if (node && isComment(node)) {
5734 if (node.data === '[')
5735 match++;
5736 if (node.data === ']') {
5737 if (match === 0) {
5738 return nextSibling(node);
5739 }
5740 else {
5741 match--;
5742 }
5743 }
5744 }
5745 }
5746 return node;
5747 };
5748 return [hydrate, hydrateNode];
5749}
5750
5751/* eslint-disable no-restricted-globals */
5752let supported;
5753let perf;
5754function startMeasure(instance, type) {
5755 if (instance.appContext.config.performance && isSupported()) {
5756 perf.mark(`vue-${type}-${instance.uid}`);
5757 }
5758 {
5759 devtoolsPerfStart(instance, type, supported ? perf.now() : Date.now());
5760 }
5761}
5762function endMeasure(instance, type) {
5763 if (instance.appContext.config.performance && isSupported()) {
5764 const startTag = `vue-${type}-${instance.uid}`;
5765 const endTag = startTag + `:end`;
5766 perf.mark(endTag);
5767 perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
5768 perf.clearMarks(startTag);
5769 perf.clearMarks(endTag);
5770 }
5771 {
5772 devtoolsPerfEnd(instance, type, supported ? perf.now() : Date.now());
5773 }
5774}
5775function isSupported() {
5776 if (supported !== undefined) {
5777 return supported;
5778 }
5779 if (typeof window !== 'undefined' && window.performance) {
5780 supported = true;
5781 perf = window.performance;
5782 }
5783 else {
5784 supported = false;
5785 }
5786 return supported;
5787}
5788
5789const queuePostRenderEffect = queueEffectWithSuspense
5790 ;
5791/**
5792 * The createRenderer function accepts two generic arguments:
5793 * HostNode and HostElement, corresponding to Node and Element types in the
5794 * host environment. For example, for runtime-dom, HostNode would be the DOM
5795 * `Node` interface and HostElement would be the DOM `Element` interface.
5796 *
5797 * Custom renderers can pass in the platform specific types like this:
5798 *
5799 * ``` js
5800 * const { render, createApp } = createRenderer<Node, Element>({
5801 * patchProp,
5802 * ...nodeOps
5803 * })
5804 * ```
5805 */
5806function createRenderer(options) {
5807 return baseCreateRenderer(options);
5808}
5809// Separate API for creating hydration-enabled renderer.
5810// Hydration logic is only used when calling this function, making it
5811// tree-shakable.
5812function createHydrationRenderer(options) {
5813 return baseCreateRenderer(options, createHydrationFunctions);
5814}
5815// implementation
5816function baseCreateRenderer(options, createHydrationFns) {
5817 const target = getGlobalThis();
5818 target.__VUE__ = true;
5819 {
5820 setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
5821 }
5822 const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
5823 // Note: functions inside this closure should use `const xxx = () => {}`
5824 // style in order to prevent being inlined by minifiers.
5825 const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
5826 if (n1 === n2) {
5827 return;
5828 }
5829 // patching & not same type, unmount old tree
5830 if (n1 && !isSameVNodeType(n1, n2)) {
5831 anchor = getNextHostNode(n1);
5832 unmount(n1, parentComponent, parentSuspense, true);
5833 n1 = null;
5834 }
5835 if (n2.patchFlag === -2 /* BAIL */) {
5836 optimized = false;
5837 n2.dynamicChildren = null;
5838 }
5839 const { type, ref, shapeFlag } = n2;
5840 switch (type) {
5841 case Text:
5842 processText(n1, n2, container, anchor);
5843 break;
5844 case Comment:
5845 processCommentNode(n1, n2, container, anchor);
5846 break;
5847 case Static:
5848 if (n1 == null) {
5849 mountStaticNode(n2, container, anchor, isSVG);
5850 }
5851 else {
5852 patchStaticNode(n1, n2, container, isSVG);
5853 }
5854 break;
5855 case Fragment:
5856 processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5857 break;
5858 default:
5859 if (shapeFlag & 1 /* ELEMENT */) {
5860 processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5861 }
5862 else if (shapeFlag & 6 /* COMPONENT */) {
5863 processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5864 }
5865 else if (shapeFlag & 64 /* TELEPORT */) {
5866 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
5867 }
5868 else if (shapeFlag & 128 /* SUSPENSE */) {
5869 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
5870 }
5871 else {
5872 warn$1('Invalid VNode type:', type, `(${typeof type})`);
5873 }
5874 }
5875 // set ref
5876 if (ref != null && parentComponent) {
5877 setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
5878 }
5879 };
5880 const processText = (n1, n2, container, anchor) => {
5881 if (n1 == null) {
5882 hostInsert((n2.el = hostCreateText(n2.children)), container, anchor);
5883 }
5884 else {
5885 const el = (n2.el = n1.el);
5886 if (n2.children !== n1.children) {
5887 hostSetText(el, n2.children);
5888 }
5889 }
5890 };
5891 const processCommentNode = (n1, n2, container, anchor) => {
5892 if (n1 == null) {
5893 hostInsert((n2.el = hostCreateComment(n2.children || '')), container, anchor);
5894 }
5895 else {
5896 // there's no support for dynamic comments
5897 n2.el = n1.el;
5898 }
5899 };
5900 const mountStaticNode = (n2, container, anchor, isSVG) => {
5901 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.el, n2.anchor);
5902 };
5903 /**
5904 * Dev / HMR only
5905 */
5906 const patchStaticNode = (n1, n2, container, isSVG) => {
5907 // static nodes are only patched during dev for HMR
5908 if (n2.children !== n1.children) {
5909 const anchor = hostNextSibling(n1.anchor);
5910 // remove existing
5911 removeStaticNode(n1);
5912 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG);
5913 }
5914 else {
5915 n2.el = n1.el;
5916 n2.anchor = n1.anchor;
5917 }
5918 };
5919 const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
5920 let next;
5921 while (el && el !== anchor) {
5922 next = hostNextSibling(el);
5923 hostInsert(el, container, nextSibling);
5924 el = next;
5925 }
5926 hostInsert(anchor, container, nextSibling);
5927 };
5928 const removeStaticNode = ({ el, anchor }) => {
5929 let next;
5930 while (el && el !== anchor) {
5931 next = hostNextSibling(el);
5932 hostRemove(el);
5933 el = next;
5934 }
5935 hostRemove(anchor);
5936 };
5937 const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5938 isSVG = isSVG || n2.type === 'svg';
5939 if (n1 == null) {
5940 mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5941 }
5942 else {
5943 patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
5944 }
5945 };
5946 const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
5947 let el;
5948 let vnodeHook;
5949 const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode;
5950 {
5951 el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props);
5952 // mount children first, since some props may rely on child content
5953 // being already rendered, e.g. `<select value>`
5954 if (shapeFlag & 8 /* TEXT_CHILDREN */) {
5955 hostSetElementText(el, vnode.children);
5956 }
5957 else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
5958 mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
5959 }
5960 if (dirs) {
5961 invokeDirectiveHook(vnode, null, parentComponent, 'created');
5962 }
5963 // props
5964 if (props) {
5965 for (const key in props) {
5966 if (key !== 'value' && !isReservedProp(key)) {
5967 hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
5968 }
5969 }
5970 /**
5971 * Special case for setting value on DOM elements:
5972 * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024)
5973 * - it needs to be forced (#1471)
5974 * #2353 proposes adding another renderer option to configure this, but
5975 * the properties affects are so finite it is worth special casing it
5976 * here to reduce the complexity. (Special casing it also should not
5977 * affect non-DOM renderers)
5978 */
5979 if ('value' in props) {
5980 hostPatchProp(el, 'value', null, props.value);
5981 }
5982 if ((vnodeHook = props.onVnodeBeforeMount)) {
5983 invokeVNodeHook(vnodeHook, parentComponent, vnode);
5984 }
5985 }
5986 // scopeId
5987 setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
5988 }
5989 {
5990 Object.defineProperty(el, '__vnode', {
5991 value: vnode,
5992 enumerable: false
5993 });
5994 Object.defineProperty(el, '__vueParentComponent', {
5995 value: parentComponent,
5996 enumerable: false
5997 });
5998 }
5999 if (dirs) {
6000 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
6001 }
6002 // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved
6003 // #1689 For inside suspense + suspense resolved case, just call it
6004 const needCallTransitionHooks = (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
6005 transition &&
6006 !transition.persisted;
6007 if (needCallTransitionHooks) {
6008 transition.beforeEnter(el);
6009 }
6010 hostInsert(el, container, anchor);
6011 if ((vnodeHook = props && props.onVnodeMounted) ||
6012 needCallTransitionHooks ||
6013 dirs) {
6014 queuePostRenderEffect(() => {
6015 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
6016 needCallTransitionHooks && transition.enter(el);
6017 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
6018 }, parentSuspense);
6019 }
6020 };
6021 const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
6022 if (scopeId) {
6023 hostSetScopeId(el, scopeId);
6024 }
6025 if (slotScopeIds) {
6026 for (let i = 0; i < slotScopeIds.length; i++) {
6027 hostSetScopeId(el, slotScopeIds[i]);
6028 }
6029 }
6030 if (parentComponent) {
6031 let subTree = parentComponent.subTree;
6032 if (subTree.patchFlag > 0 &&
6033 subTree.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) {
6034 subTree =
6035 filterSingleRoot(subTree.children) || subTree;
6036 }
6037 if (vnode === subTree) {
6038 const parentVNode = parentComponent.vnode;
6039 setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent);
6040 }
6041 }
6042 };
6043 const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
6044 for (let i = start; i < children.length; i++) {
6045 const child = (children[i] = optimized
6046 ? cloneIfMounted(children[i])
6047 : normalizeVNode(children[i]));
6048 patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6049 }
6050 };
6051 const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6052 const el = (n2.el = n1.el);
6053 let { patchFlag, dynamicChildren, dirs } = n2;
6054 // #1426 take the old vnode's patch flag into account since user may clone a
6055 // compiler-generated vnode, which de-opts to FULL_PROPS
6056 patchFlag |= n1.patchFlag & 16 /* FULL_PROPS */;
6057 const oldProps = n1.props || EMPTY_OBJ;
6058 const newProps = n2.props || EMPTY_OBJ;
6059 let vnodeHook;
6060 // disable recurse in beforeUpdate hooks
6061 parentComponent && toggleRecurse(parentComponent, false);
6062 if ((vnodeHook = newProps.onVnodeBeforeUpdate)) {
6063 invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
6064 }
6065 if (dirs) {
6066 invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate');
6067 }
6068 parentComponent && toggleRecurse(parentComponent, true);
6069 if (isHmrUpdating) {
6070 // HMR updated, force full diff
6071 patchFlag = 0;
6072 optimized = false;
6073 dynamicChildren = null;
6074 }
6075 const areChildrenSVG = isSVG && n2.type !== 'foreignObject';
6076 if (dynamicChildren) {
6077 patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds);
6078 if (parentComponent && parentComponent.type.__hmrId) {
6079 traverseStaticChildren(n1, n2);
6080 }
6081 }
6082 else if (!optimized) {
6083 // full diff
6084 patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false);
6085 }
6086 if (patchFlag > 0) {
6087 // the presence of a patchFlag means this element's render code was
6088 // generated by the compiler and can take the fast path.
6089 // in this path old node and new node are guaranteed to have the same shape
6090 // (i.e. at the exact same position in the source template)
6091 if (patchFlag & 16 /* FULL_PROPS */) {
6092 // element props contain dynamic keys, full diff needed
6093 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
6094 }
6095 else {
6096 // class
6097 // this flag is matched when the element has dynamic class bindings.
6098 if (patchFlag & 2 /* CLASS */) {
6099 if (oldProps.class !== newProps.class) {
6100 hostPatchProp(el, 'class', null, newProps.class, isSVG);
6101 }
6102 }
6103 // style
6104 // this flag is matched when the element has dynamic style bindings
6105 if (patchFlag & 4 /* STYLE */) {
6106 hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
6107 }
6108 // props
6109 // This flag is matched when the element has dynamic prop/attr bindings
6110 // other than class and style. The keys of dynamic prop/attrs are saved for
6111 // faster iteration.
6112 // Note dynamic keys like :[foo]="bar" will cause this optimization to
6113 // bail out and go through a full diff because we need to unset the old key
6114 if (patchFlag & 8 /* PROPS */) {
6115 // if the flag is present then dynamicProps must be non-null
6116 const propsToUpdate = n2.dynamicProps;
6117 for (let i = 0; i < propsToUpdate.length; i++) {
6118 const key = propsToUpdate[i];
6119 const prev = oldProps[key];
6120 const next = newProps[key];
6121 // #1471 force patch value
6122 if (next !== prev || key === 'value') {
6123 hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
6124 }
6125 }
6126 }
6127 }
6128 // text
6129 // This flag is matched when the element has only dynamic text children.
6130 if (patchFlag & 1 /* TEXT */) {
6131 if (n1.children !== n2.children) {
6132 hostSetElementText(el, n2.children);
6133 }
6134 }
6135 }
6136 else if (!optimized && dynamicChildren == null) {
6137 // unoptimized, full diff
6138 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
6139 }
6140 if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
6141 queuePostRenderEffect(() => {
6142 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
6143 dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated');
6144 }, parentSuspense);
6145 }
6146 };
6147 // The fast path for blocks.
6148 const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
6149 for (let i = 0; i < newChildren.length; i++) {
6150 const oldVNode = oldChildren[i];
6151 const newVNode = newChildren[i];
6152 // Determine the container (parent element) for the patch.
6153 const container =
6154 // oldVNode may be an errored async setup() component inside Suspense
6155 // which will not have a mounted element
6156 oldVNode.el &&
6157 // - In the case of a Fragment, we need to provide the actual parent
6158 // of the Fragment itself so it can move its children.
6159 (oldVNode.type === Fragment ||
6160 // - In the case of different nodes, there is going to be a replacement
6161 // which also requires the correct parent container
6162 !isSameVNodeType(oldVNode, newVNode) ||
6163 // - In the case of a component, it could contain anything.
6164 oldVNode.shapeFlag & (6 /* COMPONENT */ | 64 /* TELEPORT */))
6165 ? hostParentNode(oldVNode.el)
6166 : // In other cases, the parent container is not actually used so we
6167 // just pass the block element here to avoid a DOM parentNode call.
6168 fallbackContainer;
6169 patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true);
6170 }
6171 };
6172 const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
6173 if (oldProps !== newProps) {
6174 for (const key in newProps) {
6175 // empty string is not valid prop
6176 if (isReservedProp(key))
6177 continue;
6178 const next = newProps[key];
6179 const prev = oldProps[key];
6180 // defer patching value
6181 if (next !== prev && key !== 'value') {
6182 hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6183 }
6184 }
6185 if (oldProps !== EMPTY_OBJ) {
6186 for (const key in oldProps) {
6187 if (!isReservedProp(key) && !(key in newProps)) {
6188 hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren);
6189 }
6190 }
6191 }
6192 if ('value' in newProps) {
6193 hostPatchProp(el, 'value', oldProps.value, newProps.value);
6194 }
6195 }
6196 };
6197 const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6198 const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
6199 const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
6200 let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
6201 if (isHmrUpdating) {
6202 // HMR updated, force full diff
6203 patchFlag = 0;
6204 optimized = false;
6205 dynamicChildren = null;
6206 }
6207 // check if this is a slot fragment with :slotted scope ids
6208 if (fragmentSlotScopeIds) {
6209 slotScopeIds = slotScopeIds
6210 ? slotScopeIds.concat(fragmentSlotScopeIds)
6211 : fragmentSlotScopeIds;
6212 }
6213 if (n1 == null) {
6214 hostInsert(fragmentStartAnchor, container, anchor);
6215 hostInsert(fragmentEndAnchor, container, anchor);
6216 // a fragment can only have array children
6217 // since they are either generated by the compiler, or implicitly created
6218 // from arrays.
6219 mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6220 }
6221 else {
6222 if (patchFlag > 0 &&
6223 patchFlag & 64 /* STABLE_FRAGMENT */ &&
6224 dynamicChildren &&
6225 // #2715 the previous fragment could've been a BAILed one as a result
6226 // of renderSlot() with no valid children
6227 n1.dynamicChildren) {
6228 // a stable fragment (template root or <template v-for>) doesn't need to
6229 // patch children order, but it may contain dynamicChildren.
6230 patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds);
6231 if (parentComponent && parentComponent.type.__hmrId) {
6232 traverseStaticChildren(n1, n2);
6233 }
6234 else if (
6235 // #2080 if the stable fragment has a key, it's a <template v-for> that may
6236 // get moved around. Make sure all root level vnodes inherit el.
6237 // #2134 or if it's a component root, it may also get moved around
6238 // as the component is being moved.
6239 n2.key != null ||
6240 (parentComponent && n2 === parentComponent.subTree)) {
6241 traverseStaticChildren(n1, n2, true /* shallow */);
6242 }
6243 }
6244 else {
6245 // keyed / unkeyed, or manual fragments.
6246 // for keyed & unkeyed, since they are compiler generated from v-for,
6247 // each child is guaranteed to be a block so the fragment will never
6248 // have dynamicChildren.
6249 patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6250 }
6251 }
6252 };
6253 const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6254 n2.slotScopeIds = slotScopeIds;
6255 if (n1 == null) {
6256 if (n2.shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {
6257 parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
6258 }
6259 else {
6260 mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
6261 }
6262 }
6263 else {
6264 updateComponent(n1, n2, optimized);
6265 }
6266 };
6267 const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
6268 const instance = (initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense));
6269 if (instance.type.__hmrId) {
6270 registerHMR(instance);
6271 }
6272 {
6273 pushWarningContext(initialVNode);
6274 startMeasure(instance, `mount`);
6275 }
6276 // inject renderer internals for keepAlive
6277 if (isKeepAlive(initialVNode)) {
6278 instance.ctx.renderer = internals;
6279 }
6280 // resolve props and slots for setup context
6281 {
6282 {
6283 startMeasure(instance, `init`);
6284 }
6285 setupComponent(instance);
6286 {
6287 endMeasure(instance, `init`);
6288 }
6289 }
6290 // setup() is async. This component relies on async logic to be resolved
6291 // before proceeding
6292 if (instance.asyncDep) {
6293 parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
6294 // Give it a placeholder if this is not hydration
6295 // TODO handle self-defined fallback
6296 if (!initialVNode.el) {
6297 const placeholder = (instance.subTree = createVNode(Comment));
6298 processCommentNode(null, placeholder, container, anchor);
6299 }
6300 return;
6301 }
6302 setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized);
6303 {
6304 popWarningContext();
6305 endMeasure(instance, `mount`);
6306 }
6307 };
6308 const updateComponent = (n1, n2, optimized) => {
6309 const instance = (n2.component = n1.component);
6310 if (shouldUpdateComponent(n1, n2, optimized)) {
6311 if (instance.asyncDep &&
6312 !instance.asyncResolved) {
6313 // async & still pending - just update props and slots
6314 // since the component's reactive effect for render isn't set-up yet
6315 {
6316 pushWarningContext(n2);
6317 }
6318 updateComponentPreRender(instance, n2, optimized);
6319 {
6320 popWarningContext();
6321 }
6322 return;
6323 }
6324 else {
6325 // normal update
6326 instance.next = n2;
6327 // in case the child component is also queued, remove it to avoid
6328 // double updating the same child component in the same flush.
6329 invalidateJob(instance.update);
6330 // instance.update is the reactive effect.
6331 instance.update();
6332 }
6333 }
6334 else {
6335 // no update needed. just copy over properties
6336 n2.component = n1.component;
6337 n2.el = n1.el;
6338 instance.vnode = n2;
6339 }
6340 };
6341 const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
6342 const componentUpdateFn = () => {
6343 if (!instance.isMounted) {
6344 let vnodeHook;
6345 const { el, props } = initialVNode;
6346 const { bm, m, parent } = instance;
6347 const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
6348 toggleRecurse(instance, false);
6349 // beforeMount hook
6350 if (bm) {
6351 invokeArrayFns(bm);
6352 }
6353 // onVnodeBeforeMount
6354 if (!isAsyncWrapperVNode &&
6355 (vnodeHook = props && props.onVnodeBeforeMount)) {
6356 invokeVNodeHook(vnodeHook, parent, initialVNode);
6357 }
6358 toggleRecurse(instance, true);
6359 if (el && hydrateNode) {
6360 // vnode has adopted host node - perform hydration instead of mount.
6361 const hydrateSubTree = () => {
6362 {
6363 startMeasure(instance, `render`);
6364 }
6365 instance.subTree = renderComponentRoot(instance);
6366 {
6367 endMeasure(instance, `render`);
6368 }
6369 {
6370 startMeasure(instance, `hydrate`);
6371 }
6372 hydrateNode(el, instance.subTree, instance, parentSuspense, null);
6373 {
6374 endMeasure(instance, `hydrate`);
6375 }
6376 };
6377 if (isAsyncWrapperVNode) {
6378 initialVNode.type.__asyncLoader().then(
6379 // note: we are moving the render call into an async callback,
6380 // which means it won't track dependencies - but it's ok because
6381 // a server-rendered async wrapper is already in resolved state
6382 // and it will never need to change.
6383 () => !instance.isUnmounted && hydrateSubTree());
6384 }
6385 else {
6386 hydrateSubTree();
6387 }
6388 }
6389 else {
6390 {
6391 startMeasure(instance, `render`);
6392 }
6393 const subTree = (instance.subTree = renderComponentRoot(instance));
6394 {
6395 endMeasure(instance, `render`);
6396 }
6397 {
6398 startMeasure(instance, `patch`);
6399 }
6400 patch(null, subTree, container, anchor, instance, parentSuspense, isSVG);
6401 {
6402 endMeasure(instance, `patch`);
6403 }
6404 initialVNode.el = subTree.el;
6405 }
6406 // mounted hook
6407 if (m) {
6408 queuePostRenderEffect(m, parentSuspense);
6409 }
6410 // onVnodeMounted
6411 if (!isAsyncWrapperVNode &&
6412 (vnodeHook = props && props.onVnodeMounted)) {
6413 const scopedInitialVNode = initialVNode;
6414 queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense);
6415 }
6416 // activated hook for keep-alive roots.
6417 // #1742 activated hook must be accessed after first render
6418 // since the hook may be injected by a child keep-alive
6419 if (initialVNode.shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
6420 instance.a && queuePostRenderEffect(instance.a, parentSuspense);
6421 }
6422 instance.isMounted = true;
6423 {
6424 devtoolsComponentAdded(instance);
6425 }
6426 // #2458: deference mount-only object parameters to prevent memleaks
6427 initialVNode = container = anchor = null;
6428 }
6429 else {
6430 // updateComponent
6431 // This is triggered by mutation of component's own state (next: null)
6432 // OR parent calling processComponent (next: VNode)
6433 let { next, bu, u, parent, vnode } = instance;
6434 let originNext = next;
6435 let vnodeHook;
6436 {
6437 pushWarningContext(next || instance.vnode);
6438 }
6439 // Disallow component effect recursion during pre-lifecycle hooks.
6440 toggleRecurse(instance, false);
6441 if (next) {
6442 next.el = vnode.el;
6443 updateComponentPreRender(instance, next, optimized);
6444 }
6445 else {
6446 next = vnode;
6447 }
6448 // beforeUpdate hook
6449 if (bu) {
6450 invokeArrayFns(bu);
6451 }
6452 // onVnodeBeforeUpdate
6453 if ((vnodeHook = next.props && next.props.onVnodeBeforeUpdate)) {
6454 invokeVNodeHook(vnodeHook, parent, next, vnode);
6455 }
6456 toggleRecurse(instance, true);
6457 // render
6458 {
6459 startMeasure(instance, `render`);
6460 }
6461 const nextTree = renderComponentRoot(instance);
6462 {
6463 endMeasure(instance, `render`);
6464 }
6465 const prevTree = instance.subTree;
6466 instance.subTree = nextTree;
6467 {
6468 startMeasure(instance, `patch`);
6469 }
6470 patch(prevTree, nextTree,
6471 // parent may have changed if it's in a teleport
6472 hostParentNode(prevTree.el),
6473 // anchor may have changed if it's in a fragment
6474 getNextHostNode(prevTree), instance, parentSuspense, isSVG);
6475 {
6476 endMeasure(instance, `patch`);
6477 }
6478 next.el = nextTree.el;
6479 if (originNext === null) {
6480 // self-triggered update. In case of HOC, update parent component
6481 // vnode el. HOC is indicated by parent instance's subTree pointing
6482 // to child component's vnode
6483 updateHOCHostEl(instance, nextTree.el);
6484 }
6485 // updated hook
6486 if (u) {
6487 queuePostRenderEffect(u, parentSuspense);
6488 }
6489 // onVnodeUpdated
6490 if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
6491 queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense);
6492 }
6493 {
6494 devtoolsComponentUpdated(instance);
6495 }
6496 {
6497 popWarningContext();
6498 }
6499 }
6500 };
6501 // create reactive effect for rendering
6502 const effect = (instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope
6503 ));
6504 const update = (instance.update = effect.run.bind(effect));
6505 update.id = instance.uid;
6506 // allowRecurse
6507 // #1801, #2043 component render effects should allow recursive updates
6508 toggleRecurse(instance, true);
6509 {
6510 effect.onTrack = instance.rtc
6511 ? e => invokeArrayFns(instance.rtc, e)
6512 : void 0;
6513 effect.onTrigger = instance.rtg
6514 ? e => invokeArrayFns(instance.rtg, e)
6515 : void 0;
6516 // @ts-ignore (for scheduler)
6517 update.ownerInstance = instance;
6518 }
6519 update();
6520 };
6521 const updateComponentPreRender = (instance, nextVNode, optimized) => {
6522 nextVNode.component = instance;
6523 const prevProps = instance.vnode.props;
6524 instance.vnode = nextVNode;
6525 instance.next = null;
6526 updateProps(instance, nextVNode.props, prevProps, optimized);
6527 updateSlots(instance, nextVNode.children, optimized);
6528 pauseTracking();
6529 // props update may have triggered pre-flush watchers.
6530 // flush them before the render update.
6531 flushPreFlushCbs(undefined, instance.update);
6532 resetTracking();
6533 };
6534 const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
6535 const c1 = n1 && n1.children;
6536 const prevShapeFlag = n1 ? n1.shapeFlag : 0;
6537 const c2 = n2.children;
6538 const { patchFlag, shapeFlag } = n2;
6539 // fast path
6540 if (patchFlag > 0) {
6541 if (patchFlag & 128 /* KEYED_FRAGMENT */) {
6542 // this could be either fully-keyed or mixed (some keyed some not)
6543 // presence of patchFlag means children are guaranteed to be arrays
6544 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6545 return;
6546 }
6547 else if (patchFlag & 256 /* UNKEYED_FRAGMENT */) {
6548 // unkeyed
6549 patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6550 return;
6551 }
6552 }
6553 // children has 3 possibilities: text, array or no children.
6554 if (shapeFlag & 8 /* TEXT_CHILDREN */) {
6555 // text children fast path
6556 if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
6557 unmountChildren(c1, parentComponent, parentSuspense);
6558 }
6559 if (c2 !== c1) {
6560 hostSetElementText(container, c2);
6561 }
6562 }
6563 else {
6564 if (prevShapeFlag & 16 /* ARRAY_CHILDREN */) {
6565 // prev children was array
6566 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6567 // two arrays, cannot assume anything, do full diff
6568 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6569 }
6570 else {
6571 // no new children, just unmount old
6572 unmountChildren(c1, parentComponent, parentSuspense, true);
6573 }
6574 }
6575 else {
6576 // prev children was text OR null
6577 // new children is array OR null
6578 if (prevShapeFlag & 8 /* TEXT_CHILDREN */) {
6579 hostSetElementText(container, '');
6580 }
6581 // mount new if array
6582 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
6583 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6584 }
6585 }
6586 }
6587 };
6588 const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6589 c1 = c1 || EMPTY_ARR;
6590 c2 = c2 || EMPTY_ARR;
6591 const oldLength = c1.length;
6592 const newLength = c2.length;
6593 const commonLength = Math.min(oldLength, newLength);
6594 let i;
6595 for (i = 0; i < commonLength; i++) {
6596 const nextChild = (c2[i] = optimized
6597 ? cloneIfMounted(c2[i])
6598 : normalizeVNode(c2[i]));
6599 patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6600 }
6601 if (oldLength > newLength) {
6602 // remove old
6603 unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength);
6604 }
6605 else {
6606 // mount new
6607 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength);
6608 }
6609 };
6610 // can be all-keyed or mixed
6611 const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
6612 let i = 0;
6613 const l2 = c2.length;
6614 let e1 = c1.length - 1; // prev ending index
6615 let e2 = l2 - 1; // next ending index
6616 // 1. sync from start
6617 // (a b) c
6618 // (a b) d e
6619 while (i <= e1 && i <= e2) {
6620 const n1 = c1[i];
6621 const n2 = (c2[i] = optimized
6622 ? cloneIfMounted(c2[i])
6623 : normalizeVNode(c2[i]));
6624 if (isSameVNodeType(n1, n2)) {
6625 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6626 }
6627 else {
6628 break;
6629 }
6630 i++;
6631 }
6632 // 2. sync from end
6633 // a (b c)
6634 // d e (b c)
6635 while (i <= e1 && i <= e2) {
6636 const n1 = c1[e1];
6637 const n2 = (c2[e2] = optimized
6638 ? cloneIfMounted(c2[e2])
6639 : normalizeVNode(c2[e2]));
6640 if (isSameVNodeType(n1, n2)) {
6641 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6642 }
6643 else {
6644 break;
6645 }
6646 e1--;
6647 e2--;
6648 }
6649 // 3. common sequence + mount
6650 // (a b)
6651 // (a b) c
6652 // i = 2, e1 = 1, e2 = 2
6653 // (a b)
6654 // c (a b)
6655 // i = 0, e1 = -1, e2 = 0
6656 if (i > e1) {
6657 if (i <= e2) {
6658 const nextPos = e2 + 1;
6659 const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
6660 while (i <= e2) {
6661 patch(null, (c2[i] = optimized
6662 ? cloneIfMounted(c2[i])
6663 : normalizeVNode(c2[i])), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6664 i++;
6665 }
6666 }
6667 }
6668 // 4. common sequence + unmount
6669 // (a b) c
6670 // (a b)
6671 // i = 2, e1 = 2, e2 = 1
6672 // a (b c)
6673 // (b c)
6674 // i = 0, e1 = 0, e2 = -1
6675 else if (i > e2) {
6676 while (i <= e1) {
6677 unmount(c1[i], parentComponent, parentSuspense, true);
6678 i++;
6679 }
6680 }
6681 // 5. unknown sequence
6682 // [i ... e1 + 1]: a b [c d e] f g
6683 // [i ... e2 + 1]: a b [e d c h] f g
6684 // i = 2, e1 = 4, e2 = 5
6685 else {
6686 const s1 = i; // prev starting index
6687 const s2 = i; // next starting index
6688 // 5.1 build key:index map for newChildren
6689 const keyToNewIndexMap = new Map();
6690 for (i = s2; i <= e2; i++) {
6691 const nextChild = (c2[i] = optimized
6692 ? cloneIfMounted(c2[i])
6693 : normalizeVNode(c2[i]));
6694 if (nextChild.key != null) {
6695 if (keyToNewIndexMap.has(nextChild.key)) {
6696 warn$1(`Duplicate keys found during update:`, JSON.stringify(nextChild.key), `Make sure keys are unique.`);
6697 }
6698 keyToNewIndexMap.set(nextChild.key, i);
6699 }
6700 }
6701 // 5.2 loop through old children left to be patched and try to patch
6702 // matching nodes & remove nodes that are no longer present
6703 let j;
6704 let patched = 0;
6705 const toBePatched = e2 - s2 + 1;
6706 let moved = false;
6707 // used to track whether any node has moved
6708 let maxNewIndexSoFar = 0;
6709 // works as Map<newIndex, oldIndex>
6710 // Note that oldIndex is offset by +1
6711 // and oldIndex = 0 is a special value indicating the new node has
6712 // no corresponding old node.
6713 // used for determining longest stable subsequence
6714 const newIndexToOldIndexMap = new Array(toBePatched);
6715 for (i = 0; i < toBePatched; i++)
6716 newIndexToOldIndexMap[i] = 0;
6717 for (i = s1; i <= e1; i++) {
6718 const prevChild = c1[i];
6719 if (patched >= toBePatched) {
6720 // all new children have been patched so this can only be a removal
6721 unmount(prevChild, parentComponent, parentSuspense, true);
6722 continue;
6723 }
6724 let newIndex;
6725 if (prevChild.key != null) {
6726 newIndex = keyToNewIndexMap.get(prevChild.key);
6727 }
6728 else {
6729 // key-less node, try to locate a key-less node of the same type
6730 for (j = s2; j <= e2; j++) {
6731 if (newIndexToOldIndexMap[j - s2] === 0 &&
6732 isSameVNodeType(prevChild, c2[j])) {
6733 newIndex = j;
6734 break;
6735 }
6736 }
6737 }
6738 if (newIndex === undefined) {
6739 unmount(prevChild, parentComponent, parentSuspense, true);
6740 }
6741 else {
6742 newIndexToOldIndexMap[newIndex - s2] = i + 1;
6743 if (newIndex >= maxNewIndexSoFar) {
6744 maxNewIndexSoFar = newIndex;
6745 }
6746 else {
6747 moved = true;
6748 }
6749 patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6750 patched++;
6751 }
6752 }
6753 // 5.3 move and mount
6754 // generate longest stable subsequence only when nodes have moved
6755 const increasingNewIndexSequence = moved
6756 ? getSequence(newIndexToOldIndexMap)
6757 : EMPTY_ARR;
6758 j = increasingNewIndexSequence.length - 1;
6759 // looping backwards so that we can use last patched node as anchor
6760 for (i = toBePatched - 1; i >= 0; i--) {
6761 const nextIndex = s2 + i;
6762 const nextChild = c2[nextIndex];
6763 const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
6764 if (newIndexToOldIndexMap[i] === 0) {
6765 // mount new
6766 patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
6767 }
6768 else if (moved) {
6769 // move if:
6770 // There is no stable subsequence (e.g. a reverse)
6771 // OR current node is not among the stable sequence
6772 if (j < 0 || i !== increasingNewIndexSequence[j]) {
6773 move(nextChild, container, anchor, 2 /* REORDER */);
6774 }
6775 else {
6776 j--;
6777 }
6778 }
6779 }
6780 }
6781 };
6782 const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
6783 const { el, type, transition, children, shapeFlag } = vnode;
6784 if (shapeFlag & 6 /* COMPONENT */) {
6785 move(vnode.component.subTree, container, anchor, moveType);
6786 return;
6787 }
6788 if (shapeFlag & 128 /* SUSPENSE */) {
6789 vnode.suspense.move(container, anchor, moveType);
6790 return;
6791 }
6792 if (shapeFlag & 64 /* TELEPORT */) {
6793 type.move(vnode, container, anchor, internals);
6794 return;
6795 }
6796 if (type === Fragment) {
6797 hostInsert(el, container, anchor);
6798 for (let i = 0; i < children.length; i++) {
6799 move(children[i], container, anchor, moveType);
6800 }
6801 hostInsert(vnode.anchor, container, anchor);
6802 return;
6803 }
6804 if (type === Static) {
6805 moveStaticNode(vnode, container, anchor);
6806 return;
6807 }
6808 // single nodes
6809 const needTransition = moveType !== 2 /* REORDER */ &&
6810 shapeFlag & 1 /* ELEMENT */ &&
6811 transition;
6812 if (needTransition) {
6813 if (moveType === 0 /* ENTER */) {
6814 transition.beforeEnter(el);
6815 hostInsert(el, container, anchor);
6816 queuePostRenderEffect(() => transition.enter(el), parentSuspense);
6817 }
6818 else {
6819 const { leave, delayLeave, afterLeave } = transition;
6820 const remove = () => hostInsert(el, container, anchor);
6821 const performLeave = () => {
6822 leave(el, () => {
6823 remove();
6824 afterLeave && afterLeave();
6825 });
6826 };
6827 if (delayLeave) {
6828 delayLeave(el, remove, performLeave);
6829 }
6830 else {
6831 performLeave();
6832 }
6833 }
6834 }
6835 else {
6836 hostInsert(el, container, anchor);
6837 }
6838 };
6839 const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
6840 const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
6841 // unset ref
6842 if (ref != null) {
6843 setRef(ref, null, parentSuspense, vnode, true);
6844 }
6845 if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {
6846 parentComponent.ctx.deactivate(vnode);
6847 return;
6848 }
6849 const shouldInvokeDirs = shapeFlag & 1 /* ELEMENT */ && dirs;
6850 const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
6851 let vnodeHook;
6852 if (shouldInvokeVnodeHook &&
6853 (vnodeHook = props && props.onVnodeBeforeUnmount)) {
6854 invokeVNodeHook(vnodeHook, parentComponent, vnode);
6855 }
6856 if (shapeFlag & 6 /* COMPONENT */) {
6857 unmountComponent(vnode.component, parentSuspense, doRemove);
6858 }
6859 else {
6860 if (shapeFlag & 128 /* SUSPENSE */) {
6861 vnode.suspense.unmount(parentSuspense, doRemove);
6862 return;
6863 }
6864 if (shouldInvokeDirs) {
6865 invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
6866 }
6867 if (shapeFlag & 64 /* TELEPORT */) {
6868 vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
6869 }
6870 else if (dynamicChildren &&
6871 // #1153: fast path should not be taken for non-stable (v-for) fragments
6872 (type !== Fragment ||
6873 (patchFlag > 0 && patchFlag & 64 /* STABLE_FRAGMENT */))) {
6874 // fast path for block nodes: only need to unmount dynamic children.
6875 unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true);
6876 }
6877 else if ((type === Fragment &&
6878 patchFlag &
6879 (128 /* KEYED_FRAGMENT */ | 256 /* UNKEYED_FRAGMENT */)) ||
6880 (!optimized && shapeFlag & 16 /* ARRAY_CHILDREN */)) {
6881 unmountChildren(children, parentComponent, parentSuspense);
6882 }
6883 if (doRemove) {
6884 remove(vnode);
6885 }
6886 }
6887 if ((shouldInvokeVnodeHook &&
6888 (vnodeHook = props && props.onVnodeUnmounted)) ||
6889 shouldInvokeDirs) {
6890 queuePostRenderEffect(() => {
6891 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
6892 shouldInvokeDirs &&
6893 invokeDirectiveHook(vnode, null, parentComponent, 'unmounted');
6894 }, parentSuspense);
6895 }
6896 };
6897 const remove = vnode => {
6898 const { type, el, anchor, transition } = vnode;
6899 if (type === Fragment) {
6900 removeFragment(el, anchor);
6901 return;
6902 }
6903 if (type === Static) {
6904 removeStaticNode(vnode);
6905 return;
6906 }
6907 const performRemove = () => {
6908 hostRemove(el);
6909 if (transition && !transition.persisted && transition.afterLeave) {
6910 transition.afterLeave();
6911 }
6912 };
6913 if (vnode.shapeFlag & 1 /* ELEMENT */ &&
6914 transition &&
6915 !transition.persisted) {
6916 const { leave, delayLeave } = transition;
6917 const performLeave = () => leave(el, performRemove);
6918 if (delayLeave) {
6919 delayLeave(vnode.el, performRemove, performLeave);
6920 }
6921 else {
6922 performLeave();
6923 }
6924 }
6925 else {
6926 performRemove();
6927 }
6928 };
6929 const removeFragment = (cur, end) => {
6930 // For fragments, directly remove all contained DOM nodes.
6931 // (fragment child nodes cannot have transition)
6932 let next;
6933 while (cur !== end) {
6934 next = hostNextSibling(cur);
6935 hostRemove(cur);
6936 cur = next;
6937 }
6938 hostRemove(end);
6939 };
6940 const unmountComponent = (instance, parentSuspense, doRemove) => {
6941 if (instance.type.__hmrId) {
6942 unregisterHMR(instance);
6943 }
6944 const { bum, scope, update, subTree, um } = instance;
6945 // beforeUnmount hook
6946 if (bum) {
6947 invokeArrayFns(bum);
6948 }
6949 // stop effects in component scope
6950 scope.stop();
6951 // update may be null if a component is unmounted before its async
6952 // setup has resolved.
6953 if (update) {
6954 // so that scheduler will no longer invoke it
6955 update.active = false;
6956 unmount(subTree, instance, parentSuspense, doRemove);
6957 }
6958 // unmounted hook
6959 if (um) {
6960 queuePostRenderEffect(um, parentSuspense);
6961 }
6962 queuePostRenderEffect(() => {
6963 instance.isUnmounted = true;
6964 }, parentSuspense);
6965 // A component with async dep inside a pending suspense is unmounted before
6966 // its async dep resolves. This should remove the dep from the suspense, and
6967 // cause the suspense to resolve immediately if that was the last dep.
6968 if (parentSuspense &&
6969 parentSuspense.pendingBranch &&
6970 !parentSuspense.isUnmounted &&
6971 instance.asyncDep &&
6972 !instance.asyncResolved &&
6973 instance.suspenseId === parentSuspense.pendingId) {
6974 parentSuspense.deps--;
6975 if (parentSuspense.deps === 0) {
6976 parentSuspense.resolve();
6977 }
6978 }
6979 {
6980 devtoolsComponentRemoved(instance);
6981 }
6982 };
6983 const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
6984 for (let i = start; i < children.length; i++) {
6985 unmount(children[i], parentComponent, parentSuspense, doRemove, optimized);
6986 }
6987 };
6988 const getNextHostNode = vnode => {
6989 if (vnode.shapeFlag & 6 /* COMPONENT */) {
6990 return getNextHostNode(vnode.component.subTree);
6991 }
6992 if (vnode.shapeFlag & 128 /* SUSPENSE */) {
6993 return vnode.suspense.next();
6994 }
6995 return hostNextSibling((vnode.anchor || vnode.el));
6996 };
6997 const render = (vnode, container, isSVG) => {
6998 if (vnode == null) {
6999 if (container._vnode) {
7000 unmount(container._vnode, null, null, true);
7001 }
7002 }
7003 else {
7004 patch(container._vnode || null, vnode, container, null, null, null, isSVG);
7005 }
7006 flushPostFlushCbs();
7007 container._vnode = vnode;
7008 };
7009 const internals = {
7010 p: patch,
7011 um: unmount,
7012 m: move,
7013 r: remove,
7014 mt: mountComponent,
7015 mc: mountChildren,
7016 pc: patchChildren,
7017 pbc: patchBlockChildren,
7018 n: getNextHostNode,
7019 o: options
7020 };
7021 let hydrate;
7022 let hydrateNode;
7023 if (createHydrationFns) {
7024 [hydrate, hydrateNode] = createHydrationFns(internals);
7025 }
7026 return {
7027 render,
7028 hydrate,
7029 createApp: createAppAPI(render, hydrate)
7030 };
7031}
7032function toggleRecurse({ effect, update }, allowed) {
7033 effect.allowRecurse = update.allowRecurse = allowed;
7034}
7035/**
7036 * #1156
7037 * When a component is HMR-enabled, we need to make sure that all static nodes
7038 * inside a block also inherit the DOM element from the previous tree so that
7039 * HMR updates (which are full updates) can retrieve the element for patching.
7040 *
7041 * #2080
7042 * Inside keyed `template` fragment static children, if a fragment is moved,
7043 * the children will always be moved. Therefore, in order to ensure correct move
7044 * position, el should be inherited from previous nodes.
7045 */
7046function traverseStaticChildren(n1, n2, shallow = false) {
7047 const ch1 = n1.children;
7048 const ch2 = n2.children;
7049 if (isArray(ch1) && isArray(ch2)) {
7050 for (let i = 0; i < ch1.length; i++) {
7051 // this is only called in the optimized path so array children are
7052 // guaranteed to be vnodes
7053 const c1 = ch1[i];
7054 let c2 = ch2[i];
7055 if (c2.shapeFlag & 1 /* ELEMENT */ && !c2.dynamicChildren) {
7056 if (c2.patchFlag <= 0 || c2.patchFlag === 32 /* HYDRATE_EVENTS */) {
7057 c2 = ch2[i] = cloneIfMounted(ch2[i]);
7058 c2.el = c1.el;
7059 }
7060 if (!shallow)
7061 traverseStaticChildren(c1, c2);
7062 }
7063 // also inherit for comment nodes, but not placeholders (e.g. v-if which
7064 // would have received .el during block patch)
7065 if (c2.type === Comment && !c2.el) {
7066 c2.el = c1.el;
7067 }
7068 }
7069 }
7070}
7071// https://en.wikipedia.org/wiki/Longest_increasing_subsequence
7072function getSequence(arr) {
7073 const p = arr.slice();
7074 const result = [0];
7075 let i, j, u, v, c;
7076 const len = arr.length;
7077 for (i = 0; i < len; i++) {
7078 const arrI = arr[i];
7079 if (arrI !== 0) {
7080 j = result[result.length - 1];
7081 if (arr[j] < arrI) {
7082 p[i] = j;
7083 result.push(i);
7084 continue;
7085 }
7086 u = 0;
7087 v = result.length - 1;
7088 while (u < v) {
7089 c = (u + v) >> 1;
7090 if (arr[result[c]] < arrI) {
7091 u = c + 1;
7092 }
7093 else {
7094 v = c;
7095 }
7096 }
7097 if (arrI < arr[result[u]]) {
7098 if (u > 0) {
7099 p[i] = result[u - 1];
7100 }
7101 result[u] = i;
7102 }
7103 }
7104 }
7105 u = result.length;
7106 v = result[u - 1];
7107 while (u-- > 0) {
7108 result[u] = v;
7109 v = p[v];
7110 }
7111 return result;
7112}
7113
7114const isTeleport = (type) => type.__isTeleport;
7115const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');
7116const isTargetSVG = (target) => typeof SVGElement !== 'undefined' && target instanceof SVGElement;
7117const resolveTarget = (props, select) => {
7118 const targetSelector = props && props.to;
7119 if (isString(targetSelector)) {
7120 if (!select) {
7121 warn$1(`Current renderer does not support string target for Teleports. ` +
7122 `(missing querySelector renderer option)`);
7123 return null;
7124 }
7125 else {
7126 const target = select(targetSelector);
7127 if (!target) {
7128 warn$1(`Failed to locate Teleport target with selector "${targetSelector}". ` +
7129 `Note the target element must exist before the component is mounted - ` +
7130 `i.e. the target cannot be rendered by the component itself, and ` +
7131 `ideally should be outside of the entire Vue component tree.`);
7132 }
7133 return target;
7134 }
7135 }
7136 else {
7137 if (!targetSelector && !isTeleportDisabled(props)) {
7138 warn$1(`Invalid Teleport target: ${targetSelector}`);
7139 }
7140 return targetSelector;
7141 }
7142};
7143const TeleportImpl = {
7144 __isTeleport: true,
7145 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals) {
7146 const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;
7147 const disabled = isTeleportDisabled(n2.props);
7148 let { shapeFlag, children, dynamicChildren } = n2;
7149 // #3302
7150 // HMR updated, force full diff
7151 if (isHmrUpdating) {
7152 optimized = false;
7153 dynamicChildren = null;
7154 }
7155 if (n1 == null) {
7156 // insert anchors in the main view
7157 const placeholder = (n2.el = createComment('teleport start')
7158 );
7159 const mainAnchor = (n2.anchor = createComment('teleport end')
7160 );
7161 insert(placeholder, container, anchor);
7162 insert(mainAnchor, container, anchor);
7163 const target = (n2.target = resolveTarget(n2.props, querySelector));
7164 const targetAnchor = (n2.targetAnchor = createText(''));
7165 if (target) {
7166 insert(targetAnchor, target);
7167 // #2652 we could be teleporting from a non-SVG tree into an SVG tree
7168 isSVG = isSVG || isTargetSVG(target);
7169 }
7170 else if (!disabled) {
7171 warn$1('Invalid Teleport target on mount:', target, `(${typeof target})`);
7172 }
7173 const mount = (container, anchor) => {
7174 // Teleport *always* has Array children. This is enforced in both the
7175 // compiler and vnode children normalization.
7176 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
7177 mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
7178 }
7179 };
7180 if (disabled) {
7181 mount(container, mainAnchor);
7182 }
7183 else if (target) {
7184 mount(target, targetAnchor);
7185 }
7186 }
7187 else {
7188 // update content
7189 n2.el = n1.el;
7190 const mainAnchor = (n2.anchor = n1.anchor);
7191 const target = (n2.target = n1.target);
7192 const targetAnchor = (n2.targetAnchor = n1.targetAnchor);
7193 const wasDisabled = isTeleportDisabled(n1.props);
7194 const currentContainer = wasDisabled ? container : target;
7195 const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
7196 isSVG = isSVG || isTargetSVG(target);
7197 if (dynamicChildren) {
7198 // fast path when the teleport happens to be a block root
7199 patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG, slotScopeIds);
7200 // even in block tree mode we need to make sure all root-level nodes
7201 // in the teleport inherit previous DOM references so that they can
7202 // be moved in future patches.
7203 traverseStaticChildren(n1, n2, true);
7204 }
7205 else if (!optimized) {
7206 patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, false);
7207 }
7208 if (disabled) {
7209 if (!wasDisabled) {
7210 // enabled -> disabled
7211 // move into main container
7212 moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);
7213 }
7214 }
7215 else {
7216 // target changed
7217 if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
7218 const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));
7219 if (nextTarget) {
7220 moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);
7221 }
7222 else {
7223 warn$1('Invalid Teleport target on update:', target, `(${typeof target})`);
7224 }
7225 }
7226 else if (wasDisabled) {
7227 // disabled -> enabled
7228 // move into teleport target
7229 moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);
7230 }
7231 }
7232 }
7233 },
7234 remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
7235 const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
7236 if (target) {
7237 hostRemove(targetAnchor);
7238 }
7239 // an unmounted teleport should always remove its children if not disabled
7240 if (doRemove || !isTeleportDisabled(props)) {
7241 hostRemove(anchor);
7242 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
7243 for (let i = 0; i < children.length; i++) {
7244 const child = children[i];
7245 unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
7246 }
7247 }
7248 }
7249 },
7250 move: moveTeleport,
7251 hydrate: hydrateTeleport
7252};
7253function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {
7254 // move target anchor if this is a target change.
7255 if (moveType === 0 /* TARGET_CHANGE */) {
7256 insert(vnode.targetAnchor, container, parentAnchor);
7257 }
7258 const { el, anchor, shapeFlag, children, props } = vnode;
7259 const isReorder = moveType === 2 /* REORDER */;
7260 // move main view anchor if this is a re-order.
7261 if (isReorder) {
7262 insert(el, container, parentAnchor);
7263 }
7264 // if this is a re-order and teleport is enabled (content is in target)
7265 // do not move children. So the opposite is: only move children if this
7266 // is not a reorder, or the teleport is disabled
7267 if (!isReorder || isTeleportDisabled(props)) {
7268 // Teleport has either Array children or no children.
7269 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
7270 for (let i = 0; i < children.length; i++) {
7271 move(children[i], container, parentAnchor, 2 /* REORDER */);
7272 }
7273 }
7274 }
7275 // move main view anchor if this is a re-order.
7276 if (isReorder) {
7277 insert(anchor, container, parentAnchor);
7278 }
7279}
7280function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {
7281 const target = (vnode.target = resolveTarget(vnode.props, querySelector));
7282 if (target) {
7283 // if multiple teleports rendered to the same target element, we need to
7284 // pick up from where the last teleport finished instead of the first node
7285 const targetNode = target._lpa || target.firstChild;
7286 if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {
7287 if (isTeleportDisabled(vnode.props)) {
7288 vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
7289 vnode.targetAnchor = targetNode;
7290 }
7291 else {
7292 vnode.anchor = nextSibling(node);
7293 vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7294 }
7295 target._lpa =
7296 vnode.targetAnchor && nextSibling(vnode.targetAnchor);
7297 }
7298 }
7299 return vnode.anchor && nextSibling(vnode.anchor);
7300}
7301// Force-casted public typing for h and TSX props inference
7302const Teleport = TeleportImpl;
7303
7304const COMPONENTS = 'components';
7305const DIRECTIVES = 'directives';
7306/**
7307 * @private
7308 */
7309function resolveComponent(name, maybeSelfReference) {
7310 return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
7311}
7312const NULL_DYNAMIC_COMPONENT = Symbol();
7313/**
7314 * @private
7315 */
7316function resolveDynamicComponent(component) {
7317 if (isString(component)) {
7318 return resolveAsset(COMPONENTS, component, false) || component;
7319 }
7320 else {
7321 // invalid types will fallthrough to createVNode and raise warning
7322 return (component || NULL_DYNAMIC_COMPONENT);
7323 }
7324}
7325/**
7326 * @private
7327 */
7328function resolveDirective(name) {
7329 return resolveAsset(DIRECTIVES, name);
7330}
7331// implementation
7332function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
7333 const instance = currentRenderingInstance || currentInstance;
7334 if (instance) {
7335 const Component = instance.type;
7336 // explicit self name has highest priority
7337 if (type === COMPONENTS) {
7338 const selfName = getComponentName(Component);
7339 if (selfName &&
7340 (selfName === name ||
7341 selfName === camelize(name) ||
7342 selfName === capitalize(camelize(name)))) {
7343 return Component;
7344 }
7345 }
7346 const res =
7347 // local registration
7348 // check instance[type] first which is resolved for options API
7349 resolve(instance[type] || Component[type], name) ||
7350 // global registration
7351 resolve(instance.appContext[type], name);
7352 if (!res && maybeSelfReference) {
7353 // fallback to implicit self-reference
7354 return Component;
7355 }
7356 if (warnMissing && !res) {
7357 const extra = type === COMPONENTS
7358 ? `\nIf this is a native custom element, make sure to exclude it from ` +
7359 `component resolution via compilerOptions.isCustomElement.`
7360 : ``;
7361 warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
7362 }
7363 return res;
7364 }
7365 else {
7366 warn$1(`resolve${capitalize(type.slice(0, -1))} ` +
7367 `can only be used in render() or setup().`);
7368 }
7369}
7370function resolve(registry, name) {
7371 return (registry &&
7372 (registry[name] ||
7373 registry[camelize(name)] ||
7374 registry[capitalize(camelize(name))]));
7375}
7376
7377const Fragment = Symbol('Fragment' );
7378const Text = Symbol('Text' );
7379const Comment = Symbol('Comment' );
7380const Static = Symbol('Static' );
7381// Since v-if and v-for are the two possible ways node structure can dynamically
7382// change, once we consider v-if branches and each v-for fragment a block, we
7383// can divide a template into nested blocks, and within each block the node
7384// structure would be stable. This allows us to skip most children diffing
7385// and only worry about the dynamic nodes (indicated by patch flags).
7386const blockStack = [];
7387let currentBlock = null;
7388/**
7389 * Open a block.
7390 * This must be called before `createBlock`. It cannot be part of `createBlock`
7391 * because the children of the block are evaluated before `createBlock` itself
7392 * is called. The generated code typically looks like this:
7393 *
7394 * ```js
7395 * function render() {
7396 * return (openBlock(),createBlock('div', null, [...]))
7397 * }
7398 * ```
7399 * disableTracking is true when creating a v-for fragment block, since a v-for
7400 * fragment always diffs its children.
7401 *
7402 * @private
7403 */
7404function openBlock(disableTracking = false) {
7405 blockStack.push((currentBlock = disableTracking ? null : []));
7406}
7407function closeBlock() {
7408 blockStack.pop();
7409 currentBlock = blockStack[blockStack.length - 1] || null;
7410}
7411// Whether we should be tracking dynamic child nodes inside a block.
7412// Only tracks when this value is > 0
7413// We are not using a simple boolean because this value may need to be
7414// incremented/decremented by nested usage of v-once (see below)
7415let isBlockTreeEnabled = 1;
7416/**
7417 * Block tracking sometimes needs to be disabled, for example during the
7418 * creation of a tree that needs to be cached by v-once. The compiler generates
7419 * code like this:
7420 *
7421 * ``` js
7422 * _cache[1] || (
7423 * setBlockTracking(-1),
7424 * _cache[1] = createVNode(...),
7425 * setBlockTracking(1),
7426 * _cache[1]
7427 * )
7428 * ```
7429 *
7430 * @private
7431 */
7432function setBlockTracking(value) {
7433 isBlockTreeEnabled += value;
7434}
7435function setupBlock(vnode) {
7436 // save current block children on the block vnode
7437 vnode.dynamicChildren =
7438 isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
7439 // close block
7440 closeBlock();
7441 // a block is always going to be patched, so track it as a child of its
7442 // parent block
7443 if (isBlockTreeEnabled > 0 && currentBlock) {
7444 currentBlock.push(vnode);
7445 }
7446 return vnode;
7447}
7448/**
7449 * @private
7450 */
7451function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
7452 return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true /* isBlock */));
7453}
7454/**
7455 * Create a block root vnode. Takes the same exact arguments as `createVNode`.
7456 * A block root keeps track of dynamic nodes within the block in the
7457 * `dynamicChildren` array.
7458 *
7459 * @private
7460 */
7461function createBlock(type, props, children, patchFlag, dynamicProps) {
7462 return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */));
7463}
7464function isVNode(value) {
7465 return value ? value.__v_isVNode === true : false;
7466}
7467function isSameVNodeType(n1, n2) {
7468 if (n2.shapeFlag & 6 /* COMPONENT */ &&
7469 hmrDirtyComponents.has(n2.type)) {
7470 // HMR only: if the component has been hot-updated, force a reload.
7471 return false;
7472 }
7473 return n1.type === n2.type && n1.key === n2.key;
7474}
7475let vnodeArgsTransformer;
7476/**
7477 * Internal API for registering an arguments transform for createVNode
7478 * used for creating stubs in the test-utils
7479 * It is *internal* but needs to be exposed for test-utils to pick up proper
7480 * typings
7481 */
7482function transformVNodeArgs(transformer) {
7483 vnodeArgsTransformer = transformer;
7484}
7485const createVNodeWithArgsTransform = (...args) => {
7486 return _createVNode(...(vnodeArgsTransformer
7487 ? vnodeArgsTransformer(args, currentRenderingInstance)
7488 : args));
7489};
7490const InternalObjectKey = `__vInternal`;
7491const normalizeKey = ({ key }) => key != null ? key : null;
7492const normalizeRef = ({ ref, ref_key, ref_for }) => {
7493 return (ref != null
7494 ? isString(ref) || isRef(ref) || isFunction(ref)
7495 ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for }
7496 : ref
7497 : null);
7498};
7499function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1 /* ELEMENT */, isBlockNode = false, needFullChildrenNormalization = false) {
7500 const vnode = {
7501 __v_isVNode: true,
7502 __v_skip: true,
7503 type,
7504 props,
7505 key: props && normalizeKey(props),
7506 ref: props && normalizeRef(props),
7507 scopeId: currentScopeId,
7508 slotScopeIds: null,
7509 children,
7510 component: null,
7511 suspense: null,
7512 ssContent: null,
7513 ssFallback: null,
7514 dirs: null,
7515 transition: null,
7516 el: null,
7517 anchor: null,
7518 target: null,
7519 targetAnchor: null,
7520 staticCount: 0,
7521 shapeFlag,
7522 patchFlag,
7523 dynamicProps,
7524 dynamicChildren: null,
7525 appContext: null
7526 };
7527 if (needFullChildrenNormalization) {
7528 normalizeChildren(vnode, children);
7529 // normalize suspense children
7530 if (shapeFlag & 128 /* SUSPENSE */) {
7531 type.normalize(vnode);
7532 }
7533 }
7534 else if (children) {
7535 // compiled element vnode - if children is passed, only possible types are
7536 // string or Array.
7537 vnode.shapeFlag |= isString(children)
7538 ? 8 /* TEXT_CHILDREN */
7539 : 16 /* ARRAY_CHILDREN */;
7540 }
7541 // validate key
7542 if (vnode.key !== vnode.key) {
7543 warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
7544 }
7545 // track vnode for block tree
7546 if (isBlockTreeEnabled > 0 &&
7547 // avoid a block node from tracking itself
7548 !isBlockNode &&
7549 // has current parent block
7550 currentBlock &&
7551 // presence of a patch flag indicates this node needs patching on updates.
7552 // component nodes also should always be patched, because even if the
7553 // component doesn't need to update, it needs to persist the instance on to
7554 // the next vnode so that it can be properly unmounted later.
7555 (vnode.patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&
7556 // the EVENTS flag is only for hydration and if it is the only flag, the
7557 // vnode should not be considered dynamic due to handler caching.
7558 vnode.patchFlag !== 32 /* HYDRATE_EVENTS */) {
7559 currentBlock.push(vnode);
7560 }
7561 return vnode;
7562}
7563const createVNode = (createVNodeWithArgsTransform );
7564function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
7565 if (!type || type === NULL_DYNAMIC_COMPONENT) {
7566 if (!type) {
7567 warn$1(`Invalid vnode type when creating vnode: ${type}.`);
7568 }
7569 type = Comment;
7570 }
7571 if (isVNode(type)) {
7572 // createVNode receiving an existing vnode. This happens in cases like
7573 // <component :is="vnode"/>
7574 // #2078 make sure to merge refs during the clone instead of overwriting it
7575 const cloned = cloneVNode(type, props, true /* mergeRef: true */);
7576 if (children) {
7577 normalizeChildren(cloned, children);
7578 }
7579 return cloned;
7580 }
7581 // class component normalization.
7582 if (isClassComponent(type)) {
7583 type = type.__vccOpts;
7584 }
7585 // class & style normalization.
7586 if (props) {
7587 // for reactive or proxy objects, we need to clone it to enable mutation.
7588 props = guardReactiveProps(props);
7589 let { class: klass, style } = props;
7590 if (klass && !isString(klass)) {
7591 props.class = normalizeClass(klass);
7592 }
7593 if (isObject(style)) {
7594 // reactive state objects need to be cloned since they are likely to be
7595 // mutated
7596 if (isProxy(style) && !isArray(style)) {
7597 style = extend({}, style);
7598 }
7599 props.style = normalizeStyle(style);
7600 }
7601 }
7602 // encode the vnode type information into a bitmap
7603 const shapeFlag = isString(type)
7604 ? 1 /* ELEMENT */
7605 : isSuspense(type)
7606 ? 128 /* SUSPENSE */
7607 : isTeleport(type)
7608 ? 64 /* TELEPORT */
7609 : isObject(type)
7610 ? 4 /* STATEFUL_COMPONENT */
7611 : isFunction(type)
7612 ? 2 /* FUNCTIONAL_COMPONENT */
7613 : 0;
7614 if (shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) {
7615 type = toRaw(type);
7616 warn$1(`Vue received a Component which was made a reactive object. This can ` +
7617 `lead to unnecessary performance overhead, and should be avoided by ` +
7618 `marking the component with \`markRaw\` or using \`shallowRef\` ` +
7619 `instead of \`ref\`.`, `\nComponent that was made reactive: `, type);
7620 }
7621 return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
7622}
7623function guardReactiveProps(props) {
7624 if (!props)
7625 return null;
7626 return isProxy(props) || InternalObjectKey in props
7627 ? extend({}, props)
7628 : props;
7629}
7630function cloneVNode(vnode, extraProps, mergeRef = false) {
7631 // This is intentionally NOT using spread or extend to avoid the runtime
7632 // key enumeration cost.
7633 const { props, ref, patchFlag, children } = vnode;
7634 const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
7635 const cloned = {
7636 __v_isVNode: true,
7637 __v_skip: true,
7638 type: vnode.type,
7639 props: mergedProps,
7640 key: mergedProps && normalizeKey(mergedProps),
7641 ref: extraProps && extraProps.ref
7642 ? // #2078 in the case of <component :is="vnode" ref="extra"/>
7643 // if the vnode itself already has a ref, cloneVNode will need to merge
7644 // the refs so the single vnode can be set on multiple refs
7645 mergeRef && ref
7646 ? isArray(ref)
7647 ? ref.concat(normalizeRef(extraProps))
7648 : [ref, normalizeRef(extraProps)]
7649 : normalizeRef(extraProps)
7650 : ref,
7651 scopeId: vnode.scopeId,
7652 slotScopeIds: vnode.slotScopeIds,
7653 children: patchFlag === -1 /* HOISTED */ && isArray(children)
7654 ? children.map(deepCloneVNode)
7655 : children,
7656 target: vnode.target,
7657 targetAnchor: vnode.targetAnchor,
7658 staticCount: vnode.staticCount,
7659 shapeFlag: vnode.shapeFlag,
7660 // if the vnode is cloned with extra props, we can no longer assume its
7661 // existing patch flag to be reliable and need to add the FULL_PROPS flag.
7662 // note: preserve flag for fragments since they use the flag for children
7663 // fast paths only.
7664 patchFlag: extraProps && vnode.type !== Fragment
7665 ? patchFlag === -1 // hoisted node
7666 ? 16 /* FULL_PROPS */
7667 : patchFlag | 16 /* FULL_PROPS */
7668 : patchFlag,
7669 dynamicProps: vnode.dynamicProps,
7670 dynamicChildren: vnode.dynamicChildren,
7671 appContext: vnode.appContext,
7672 dirs: vnode.dirs,
7673 transition: vnode.transition,
7674 // These should technically only be non-null on mounted VNodes. However,
7675 // they *should* be copied for kept-alive vnodes. So we just always copy
7676 // them since them being non-null during a mount doesn't affect the logic as
7677 // they will simply be overwritten.
7678 component: vnode.component,
7679 suspense: vnode.suspense,
7680 ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
7681 ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
7682 el: vnode.el,
7683 anchor: vnode.anchor
7684 };
7685 return cloned;
7686}
7687/**
7688 * Dev only, for HMR of hoisted vnodes reused in v-for
7689 * https://github.com/vitejs/vite/issues/2022
7690 */
7691function deepCloneVNode(vnode) {
7692 const cloned = cloneVNode(vnode);
7693 if (isArray(vnode.children)) {
7694 cloned.children = vnode.children.map(deepCloneVNode);
7695 }
7696 return cloned;
7697}
7698/**
7699 * @private
7700 */
7701function createTextVNode(text = ' ', flag = 0) {
7702 return createVNode(Text, null, text, flag);
7703}
7704/**
7705 * @private
7706 */
7707function createStaticVNode(content, numberOfNodes) {
7708 // A static vnode can contain multiple stringified elements, and the number
7709 // of elements is necessary for hydration.
7710 const vnode = createVNode(Static, null, content);
7711 vnode.staticCount = numberOfNodes;
7712 return vnode;
7713}
7714/**
7715 * @private
7716 */
7717function createCommentVNode(text = '',
7718// when used as the v-else branch, the comment node must be created as a
7719// block to ensure correct updates.
7720asBlock = false) {
7721 return asBlock
7722 ? (openBlock(), createBlock(Comment, null, text))
7723 : createVNode(Comment, null, text);
7724}
7725function normalizeVNode(child) {
7726 if (child == null || typeof child === 'boolean') {
7727 // empty placeholder
7728 return createVNode(Comment);
7729 }
7730 else if (isArray(child)) {
7731 // fragment
7732 return createVNode(Fragment, null,
7733 // #3666, avoid reference pollution when reusing vnode
7734 child.slice());
7735 }
7736 else if (typeof child === 'object') {
7737 // already vnode, this should be the most common since compiled templates
7738 // always produce all-vnode children arrays
7739 return cloneIfMounted(child);
7740 }
7741 else {
7742 // strings and numbers
7743 return createVNode(Text, null, String(child));
7744 }
7745}
7746// optimized normalization for template-compiled render fns
7747function cloneIfMounted(child) {
7748 return child.el === null || child.memo ? child : cloneVNode(child);
7749}
7750function normalizeChildren(vnode, children) {
7751 let type = 0;
7752 const { shapeFlag } = vnode;
7753 if (children == null) {
7754 children = null;
7755 }
7756 else if (isArray(children)) {
7757 type = 16 /* ARRAY_CHILDREN */;
7758 }
7759 else if (typeof children === 'object') {
7760 if (shapeFlag & (1 /* ELEMENT */ | 64 /* TELEPORT */)) {
7761 // Normalize slot to plain children for plain element and Teleport
7762 const slot = children.default;
7763 if (slot) {
7764 // _c marker is added by withCtx() indicating this is a compiled slot
7765 slot._c && (slot._d = false);
7766 normalizeChildren(vnode, slot());
7767 slot._c && (slot._d = true);
7768 }
7769 return;
7770 }
7771 else {
7772 type = 32 /* SLOTS_CHILDREN */;
7773 const slotFlag = children._;
7774 if (!slotFlag && !(InternalObjectKey in children)) {
7775 children._ctx = currentRenderingInstance;
7776 }
7777 else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {
7778 // a child component receives forwarded slots from the parent.
7779 // its slot type is determined by its parent's slot type.
7780 if (currentRenderingInstance.slots._ === 1 /* STABLE */) {
7781 children._ = 1 /* STABLE */;
7782 }
7783 else {
7784 children._ = 2 /* DYNAMIC */;
7785 vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;
7786 }
7787 }
7788 }
7789 }
7790 else if (isFunction(children)) {
7791 children = { default: children, _ctx: currentRenderingInstance };
7792 type = 32 /* SLOTS_CHILDREN */;
7793 }
7794 else {
7795 children = String(children);
7796 // force teleport children to array so it can be moved around
7797 if (shapeFlag & 64 /* TELEPORT */) {
7798 type = 16 /* ARRAY_CHILDREN */;
7799 children = [createTextVNode(children)];
7800 }
7801 else {
7802 type = 8 /* TEXT_CHILDREN */;
7803 }
7804 }
7805 vnode.children = children;
7806 vnode.shapeFlag |= type;
7807}
7808function mergeProps(...args) {
7809 const ret = {};
7810 for (let i = 0; i < args.length; i++) {
7811 const toMerge = args[i];
7812 for (const key in toMerge) {
7813 if (key === 'class') {
7814 if (ret.class !== toMerge.class) {
7815 ret.class = normalizeClass([ret.class, toMerge.class]);
7816 }
7817 }
7818 else if (key === 'style') {
7819 ret.style = normalizeStyle([ret.style, toMerge.style]);
7820 }
7821 else if (isOn(key)) {
7822 const existing = ret[key];
7823 const incoming = toMerge[key];
7824 if (incoming &&
7825 existing !== incoming &&
7826 !(isArray(existing) && existing.includes(incoming))) {
7827 ret[key] = existing
7828 ? [].concat(existing, incoming)
7829 : incoming;
7830 }
7831 }
7832 else if (key !== '') {
7833 ret[key] = toMerge[key];
7834 }
7835 }
7836 }
7837 return ret;
7838}
7839function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7840 callWithAsyncErrorHandling(hook, instance, 7 /* VNODE_HOOK */, [
7841 vnode,
7842 prevVNode
7843 ]);
7844}
7845
7846/**
7847 * Actual implementation
7848 */
7849function renderList(source, renderItem, cache, index) {
7850 let ret;
7851 const cached = (cache && cache[index]);
7852 if (isArray(source) || isString(source)) {
7853 ret = new Array(source.length);
7854 for (let i = 0, l = source.length; i < l; i++) {
7855 ret[i] = renderItem(source[i], i, undefined, cached && cached[i]);
7856 }
7857 }
7858 else if (typeof source === 'number') {
7859 if (!Number.isInteger(source)) {
7860 warn$1(`The v-for range expect an integer value but got ${source}.`);
7861 return [];
7862 }
7863 ret = new Array(source);
7864 for (let i = 0; i < source; i++) {
7865 ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]);
7866 }
7867 }
7868 else if (isObject(source)) {
7869 if (source[Symbol.iterator]) {
7870 ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i]));
7871 }
7872 else {
7873 const keys = Object.keys(source);
7874 ret = new Array(keys.length);
7875 for (let i = 0, l = keys.length; i < l; i++) {
7876 const key = keys[i];
7877 ret[i] = renderItem(source[key], key, i, cached && cached[i]);
7878 }
7879 }
7880 }
7881 else {
7882 ret = [];
7883 }
7884 if (cache) {
7885 cache[index] = ret;
7886 }
7887 return ret;
7888}
7889
7890/**
7891 * Compiler runtime helper for creating dynamic slots object
7892 * @private
7893 */
7894function createSlots(slots, dynamicSlots) {
7895 for (let i = 0; i < dynamicSlots.length; i++) {
7896 const slot = dynamicSlots[i];
7897 // array of dynamic slot generated by <template v-for="..." #[...]>
7898 if (isArray(slot)) {
7899 for (let j = 0; j < slot.length; j++) {
7900 slots[slot[j].name] = slot[j].fn;
7901 }
7902 }
7903 else if (slot) {
7904 // conditional single slot generated by <template v-if="..." #foo>
7905 slots[slot.name] = slot.fn;
7906 }
7907 }
7908 return slots;
7909}
7910
7911/**
7912 * Compiler runtime helper for rendering `<slot/>`
7913 * @private
7914 */
7915function renderSlot(slots, name, props = {},
7916// this is not a user-facing function, so the fallback is always generated by
7917// the compiler and guaranteed to be a function returning an array
7918fallback, noSlotted) {
7919 if (currentRenderingInstance.isCE) {
7920 return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
7921 }
7922 let slot = slots[name];
7923 if (slot && slot.length > 1) {
7924 warn$1(`SSR-optimized slot function detected in a non-SSR-optimized render ` +
7925 `function. You need to mark this component with $dynamic-slots in the ` +
7926 `parent template.`);
7927 slot = () => [];
7928 }
7929 // a compiled slot disables block tracking by default to avoid manual
7930 // invocation interfering with template-based block tracking, but in
7931 // `renderSlot` we can be sure that it's template-based so we can force
7932 // enable it.
7933 if (slot && slot._c) {
7934 slot._d = false;
7935 }
7936 openBlock();
7937 const validSlotContent = slot && ensureValidVNode(slot(props));
7938 const rendered = createBlock(Fragment, { key: props.key || `_${name}` }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 /* STABLE */
7939 ? 64 /* STABLE_FRAGMENT */
7940 : -2 /* BAIL */);
7941 if (!noSlotted && rendered.scopeId) {
7942 rendered.slotScopeIds = [rendered.scopeId + '-s'];
7943 }
7944 if (slot && slot._c) {
7945 slot._d = true;
7946 }
7947 return rendered;
7948}
7949function ensureValidVNode(vnodes) {
7950 return vnodes.some(child => {
7951 if (!isVNode(child))
7952 return true;
7953 if (child.type === Comment)
7954 return false;
7955 if (child.type === Fragment &&
7956 !ensureValidVNode(child.children))
7957 return false;
7958 return true;
7959 })
7960 ? vnodes
7961 : null;
7962}
7963
7964/**
7965 * For prefixing keys in v-on="obj" with "on"
7966 * @private
7967 */
7968function toHandlers(obj) {
7969 const ret = {};
7970 if (!isObject(obj)) {
7971 warn$1(`v-on with no argument expects an object value.`);
7972 return ret;
7973 }
7974 for (const key in obj) {
7975 ret[toHandlerKey(key)] = obj[key];
7976 }
7977 return ret;
7978}
7979
7980/**
7981 * #2437 In Vue 3, functional components do not have a public instance proxy but
7982 * they exist in the internal parent chain. For code that relies on traversing
7983 * public $parent chains, skip functional ones and go to the parent instead.
7984 */
7985const getPublicInstance = (i) => {
7986 if (!i)
7987 return null;
7988 if (isStatefulComponent(i))
7989 return getExposeProxy(i) || i.proxy;
7990 return getPublicInstance(i.parent);
7991};
7992const publicPropertiesMap = extend(Object.create(null), {
7993 $: i => i,
7994 $el: i => i.vnode.el,
7995 $data: i => i.data,
7996 $props: i => (shallowReadonly(i.props) ),
7997 $attrs: i => (shallowReadonly(i.attrs) ),
7998 $slots: i => (shallowReadonly(i.slots) ),
7999 $refs: i => (shallowReadonly(i.refs) ),
8000 $parent: i => getPublicInstance(i.parent),
8001 $root: i => getPublicInstance(i.root),
8002 $emit: i => i.emit,
8003 $options: i => (resolveMergedOptions(i) ),
8004 $forceUpdate: i => () => queueJob(i.update),
8005 $nextTick: i => nextTick.bind(i.proxy),
8006 $watch: i => (instanceWatch.bind(i) )
8007});
8008const PublicInstanceProxyHandlers = {
8009 get({ _: instance }, key) {
8010 const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
8011 // for internal formatters to know that this is a Vue instance
8012 if (key === '__isVue') {
8013 return true;
8014 }
8015 // prioritize <script setup> bindings during dev.
8016 // this allows even properties that start with _ or $ to be used - so that
8017 // it aligns with the production behavior where the render fn is inlined and
8018 // indeed has access to all declared variables.
8019 if (setupState !== EMPTY_OBJ &&
8020 setupState.__isScriptSetup &&
8021 hasOwn(setupState, key)) {
8022 return setupState[key];
8023 }
8024 // data / props / ctx
8025 // This getter gets called for every property access on the render context
8026 // during render and is a major hotspot. The most expensive part of this
8027 // is the multiple hasOwn() calls. It's much faster to do a simple property
8028 // access on a plain object, so we use an accessCache object (with null
8029 // prototype) to memoize what access type a key corresponds to.
8030 let normalizedProps;
8031 if (key[0] !== '$') {
8032 const n = accessCache[key];
8033 if (n !== undefined) {
8034 switch (n) {
8035 case 1 /* SETUP */:
8036 return setupState[key];
8037 case 2 /* DATA */:
8038 return data[key];
8039 case 4 /* CONTEXT */:
8040 return ctx[key];
8041 case 3 /* PROPS */:
8042 return props[key];
8043 // default: just fallthrough
8044 }
8045 }
8046 else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8047 accessCache[key] = 1 /* SETUP */;
8048 return setupState[key];
8049 }
8050 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8051 accessCache[key] = 2 /* DATA */;
8052 return data[key];
8053 }
8054 else if (
8055 // only cache other properties when instance has declared (thus stable)
8056 // props
8057 (normalizedProps = instance.propsOptions[0]) &&
8058 hasOwn(normalizedProps, key)) {
8059 accessCache[key] = 3 /* PROPS */;
8060 return props[key];
8061 }
8062 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8063 accessCache[key] = 4 /* CONTEXT */;
8064 return ctx[key];
8065 }
8066 else if (shouldCacheAccess) {
8067 accessCache[key] = 0 /* OTHER */;
8068 }
8069 }
8070 const publicGetter = publicPropertiesMap[key];
8071 let cssModule, globalProperties;
8072 // public $xxx properties
8073 if (publicGetter) {
8074 if (key === '$attrs') {
8075 track(instance, "get" /* GET */, key);
8076 markAttrsAccessed();
8077 }
8078 return publicGetter(instance);
8079 }
8080 else if (
8081 // css module (injected by vue-loader)
8082 (cssModule = type.__cssModules) &&
8083 (cssModule = cssModule[key])) {
8084 return cssModule;
8085 }
8086 else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
8087 // user may set custom properties to `this` that start with `$`
8088 accessCache[key] = 4 /* CONTEXT */;
8089 return ctx[key];
8090 }
8091 else if (
8092 // global properties
8093 ((globalProperties = appContext.config.globalProperties),
8094 hasOwn(globalProperties, key))) {
8095 {
8096 return globalProperties[key];
8097 }
8098 }
8099 else if (currentRenderingInstance &&
8100 (!isString(key) ||
8101 // #1091 avoid internal isRef/isVNode checks on component instance leading
8102 // to infinite warning loop
8103 key.indexOf('__v') !== 0)) {
8104 if (data !== EMPTY_OBJ &&
8105 (key[0] === '$' || key[0] === '_') &&
8106 hasOwn(data, key)) {
8107 warn$1(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` +
8108 `character ("$" or "_") and is not proxied on the render context.`);
8109 }
8110 else if (instance === currentRenderingInstance) {
8111 warn$1(`Property ${JSON.stringify(key)} was accessed during render ` +
8112 `but is not defined on instance.`);
8113 }
8114 }
8115 },
8116 set({ _: instance }, key, value) {
8117 const { data, setupState, ctx } = instance;
8118 if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
8119 setupState[key] = value;
8120 return true;
8121 }
8122 else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
8123 data[key] = value;
8124 return true;
8125 }
8126 else if (hasOwn(instance.props, key)) {
8127 warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
8128 return false;
8129 }
8130 if (key[0] === '$' && key.slice(1) in instance) {
8131 warn$1(`Attempting to mutate public property "${key}". ` +
8132 `Properties starting with $ are reserved and readonly.`, instance);
8133 return false;
8134 }
8135 else {
8136 if (key in instance.appContext.config.globalProperties) {
8137 Object.defineProperty(ctx, key, {
8138 enumerable: true,
8139 configurable: true,
8140 value
8141 });
8142 }
8143 else {
8144 ctx[key] = value;
8145 }
8146 }
8147 return true;
8148 },
8149 has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
8150 let normalizedProps;
8151 return (!!accessCache[key] ||
8152 (data !== EMPTY_OBJ && hasOwn(data, key)) ||
8153 (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
8154 ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
8155 hasOwn(ctx, key) ||
8156 hasOwn(publicPropertiesMap, key) ||
8157 hasOwn(appContext.config.globalProperties, key));
8158 },
8159 defineProperty(target, key, descriptor) {
8160 if (descriptor.get != null) {
8161 this.set(target, key, descriptor.get(), null);
8162 }
8163 else if (descriptor.value != null) {
8164 this.set(target, key, descriptor.value, null);
8165 }
8166 return Reflect.defineProperty(target, key, descriptor);
8167 }
8168};
8169{
8170 PublicInstanceProxyHandlers.ownKeys = (target) => {
8171 warn$1(`Avoid app logic that relies on enumerating keys on a component instance. ` +
8172 `The keys will be empty in production mode to avoid performance overhead.`);
8173 return Reflect.ownKeys(target);
8174 };
8175}
8176const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend({}, PublicInstanceProxyHandlers, {
8177 get(target, key) {
8178 // fast path for unscopables when using `with` block
8179 if (key === Symbol.unscopables) {
8180 return;
8181 }
8182 return PublicInstanceProxyHandlers.get(target, key, target);
8183 },
8184 has(_, key) {
8185 const has = key[0] !== '_' && !isGloballyWhitelisted(key);
8186 if (!has && PublicInstanceProxyHandlers.has(_, key)) {
8187 warn$1(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`);
8188 }
8189 return has;
8190 }
8191});
8192// dev only
8193// In dev mode, the proxy target exposes the same properties as seen on `this`
8194// for easier console inspection. In prod mode it will be an empty object so
8195// these properties definitions can be skipped.
8196function createDevRenderContext(instance) {
8197 const target = {};
8198 // expose internal instance for proxy handlers
8199 Object.defineProperty(target, `_`, {
8200 configurable: true,
8201 enumerable: false,
8202 get: () => instance
8203 });
8204 // expose public properties
8205 Object.keys(publicPropertiesMap).forEach(key => {
8206 Object.defineProperty(target, key, {
8207 configurable: true,
8208 enumerable: false,
8209 get: () => publicPropertiesMap[key](instance),
8210 // intercepted by the proxy so no need for implementation,
8211 // but needed to prevent set errors
8212 set: NOOP
8213 });
8214 });
8215 return target;
8216}
8217// dev only
8218function exposePropsOnRenderContext(instance) {
8219 const { ctx, propsOptions: [propsOptions] } = instance;
8220 if (propsOptions) {
8221 Object.keys(propsOptions).forEach(key => {
8222 Object.defineProperty(ctx, key, {
8223 enumerable: true,
8224 configurable: true,
8225 get: () => instance.props[key],
8226 set: NOOP
8227 });
8228 });
8229 }
8230}
8231// dev only
8232function exposeSetupStateOnRenderContext(instance) {
8233 const { ctx, setupState } = instance;
8234 Object.keys(toRaw(setupState)).forEach(key => {
8235 if (!setupState.__isScriptSetup) {
8236 if (key[0] === '$' || key[0] === '_') {
8237 warn$1(`setup() return property ${JSON.stringify(key)} should not start with "$" or "_" ` +
8238 `which are reserved prefixes for Vue internals.`);
8239 return;
8240 }
8241 Object.defineProperty(ctx, key, {
8242 enumerable: true,
8243 configurable: true,
8244 get: () => setupState[key],
8245 set: NOOP
8246 });
8247 }
8248 });
8249}
8250
8251const emptyAppContext = createAppContext();
8252let uid$1 = 0;
8253function createComponentInstance(vnode, parent, suspense) {
8254 const type = vnode.type;
8255 // inherit parent app context - or - if root, adopt from root vnode
8256 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
8257 const instance = {
8258 uid: uid$1++,
8259 vnode,
8260 type,
8261 parent,
8262 appContext,
8263 root: null,
8264 next: null,
8265 subTree: null,
8266 effect: null,
8267 update: null,
8268 scope: new EffectScope(true /* detached */),
8269 render: null,
8270 proxy: null,
8271 exposed: null,
8272 exposeProxy: null,
8273 withProxy: null,
8274 provides: parent ? parent.provides : Object.create(appContext.provides),
8275 accessCache: null,
8276 renderCache: [],
8277 // local resovled assets
8278 components: null,
8279 directives: null,
8280 // resolved props and emits options
8281 propsOptions: normalizePropsOptions(type, appContext),
8282 emitsOptions: normalizeEmitsOptions(type, appContext),
8283 // emit
8284 emit: null,
8285 emitted: null,
8286 // props default value
8287 propsDefaults: EMPTY_OBJ,
8288 // inheritAttrs
8289 inheritAttrs: type.inheritAttrs,
8290 // state
8291 ctx: EMPTY_OBJ,
8292 data: EMPTY_OBJ,
8293 props: EMPTY_OBJ,
8294 attrs: EMPTY_OBJ,
8295 slots: EMPTY_OBJ,
8296 refs: EMPTY_OBJ,
8297 setupState: EMPTY_OBJ,
8298 setupContext: null,
8299 // suspense related
8300 suspense,
8301 suspenseId: suspense ? suspense.pendingId : 0,
8302 asyncDep: null,
8303 asyncResolved: false,
8304 // lifecycle hooks
8305 // not using enums here because it results in computed properties
8306 isMounted: false,
8307 isUnmounted: false,
8308 isDeactivated: false,
8309 bc: null,
8310 c: null,
8311 bm: null,
8312 m: null,
8313 bu: null,
8314 u: null,
8315 um: null,
8316 bum: null,
8317 da: null,
8318 a: null,
8319 rtg: null,
8320 rtc: null,
8321 ec: null,
8322 sp: null
8323 };
8324 {
8325 instance.ctx = createDevRenderContext(instance);
8326 }
8327 instance.root = parent ? parent.root : instance;
8328 instance.emit = emit$1.bind(null, instance);
8329 // apply custom element special handling
8330 if (vnode.ce) {
8331 vnode.ce(instance);
8332 }
8333 return instance;
8334}
8335let currentInstance = null;
8336const getCurrentInstance = () => currentInstance || currentRenderingInstance;
8337const setCurrentInstance = (instance) => {
8338 currentInstance = instance;
8339 instance.scope.on();
8340};
8341const unsetCurrentInstance = () => {
8342 currentInstance && currentInstance.scope.off();
8343 currentInstance = null;
8344};
8345const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component');
8346function validateComponentName(name, config) {
8347 const appIsNativeTag = config.isNativeTag || NO;
8348 if (isBuiltInTag(name) || appIsNativeTag(name)) {
8349 warn$1('Do not use built-in or reserved HTML elements as component id: ' + name);
8350 }
8351}
8352function isStatefulComponent(instance) {
8353 return instance.vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */;
8354}
8355let isInSSRComponentSetup = false;
8356function setupComponent(instance, isSSR = false) {
8357 isInSSRComponentSetup = isSSR;
8358 const { props, children } = instance.vnode;
8359 const isStateful = isStatefulComponent(instance);
8360 initProps(instance, props, isStateful, isSSR);
8361 initSlots(instance, children);
8362 const setupResult = isStateful
8363 ? setupStatefulComponent(instance, isSSR)
8364 : undefined;
8365 isInSSRComponentSetup = false;
8366 return setupResult;
8367}
8368function setupStatefulComponent(instance, isSSR) {
8369 const Component = instance.type;
8370 {
8371 if (Component.name) {
8372 validateComponentName(Component.name, instance.appContext.config);
8373 }
8374 if (Component.components) {
8375 const names = Object.keys(Component.components);
8376 for (let i = 0; i < names.length; i++) {
8377 validateComponentName(names[i], instance.appContext.config);
8378 }
8379 }
8380 if (Component.directives) {
8381 const names = Object.keys(Component.directives);
8382 for (let i = 0; i < names.length; i++) {
8383 validateDirectiveName(names[i]);
8384 }
8385 }
8386 if (Component.compilerOptions && isRuntimeOnly()) {
8387 warn$1(`"compilerOptions" is only supported when using a build of Vue that ` +
8388 `includes the runtime compiler. Since you are using a runtime-only ` +
8389 `build, the options should be passed via your build tool config instead.`);
8390 }
8391 }
8392 // 0. create render proxy property access cache
8393 instance.accessCache = Object.create(null);
8394 // 1. create public instance / render proxy
8395 // also mark it raw so it's never observed
8396 instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
8397 {
8398 exposePropsOnRenderContext(instance);
8399 }
8400 // 2. call setup()
8401 const { setup } = Component;
8402 if (setup) {
8403 const setupContext = (instance.setupContext =
8404 setup.length > 1 ? createSetupContext(instance) : null);
8405 setCurrentInstance(instance);
8406 pauseTracking();
8407 const setupResult = callWithErrorHandling(setup, instance, 0 /* SETUP_FUNCTION */, [shallowReadonly(instance.props) , setupContext]);
8408 resetTracking();
8409 unsetCurrentInstance();
8410 if (isPromise(setupResult)) {
8411 setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
8412 if (isSSR) {
8413 // return the promise so server-renderer can wait on it
8414 return setupResult
8415 .then((resolvedResult) => {
8416 handleSetupResult(instance, resolvedResult, isSSR);
8417 })
8418 .catch(e => {
8419 handleError(e, instance, 0 /* SETUP_FUNCTION */);
8420 });
8421 }
8422 else {
8423 // async setup returned Promise.
8424 // bail here and wait for re-entry.
8425 instance.asyncDep = setupResult;
8426 }
8427 }
8428 else {
8429 handleSetupResult(instance, setupResult, isSSR);
8430 }
8431 }
8432 else {
8433 finishComponentSetup(instance, isSSR);
8434 }
8435}
8436function handleSetupResult(instance, setupResult, isSSR) {
8437 if (isFunction(setupResult)) {
8438 // setup returned an inline render function
8439 {
8440 instance.render = setupResult;
8441 }
8442 }
8443 else if (isObject(setupResult)) {
8444 if (isVNode(setupResult)) {
8445 warn$1(`setup() should not return VNodes directly - ` +
8446 `return a render function instead.`);
8447 }
8448 // setup returned bindings.
8449 // assuming a render function compiled from template is present.
8450 {
8451 instance.devtoolsRawSetupState = setupResult;
8452 }
8453 instance.setupState = proxyRefs(setupResult);
8454 {
8455 exposeSetupStateOnRenderContext(instance);
8456 }
8457 }
8458 else if (setupResult !== undefined) {
8459 warn$1(`setup() should return an object. Received: ${setupResult === null ? 'null' : typeof setupResult}`);
8460 }
8461 finishComponentSetup(instance, isSSR);
8462}
8463let compile;
8464let installWithProxy;
8465/**
8466 * For runtime-dom to register the compiler.
8467 * Note the exported method uses any to avoid d.ts relying on the compiler types.
8468 */
8469function registerRuntimeCompiler(_compile) {
8470 compile = _compile;
8471 installWithProxy = i => {
8472 if (i.render._rc) {
8473 i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
8474 }
8475 };
8476}
8477// dev only
8478const isRuntimeOnly = () => !compile;
8479function finishComponentSetup(instance, isSSR, skipOptions) {
8480 const Component = instance.type;
8481 // template / render function normalization
8482 // could be already set when returned from setup()
8483 if (!instance.render) {
8484 // only do on-the-fly compile if not in SSR - SSR on-the-fly compilation
8485 // is done by server-renderer
8486 if (!isSSR && compile && !Component.render) {
8487 const template = Component.template;
8488 if (template) {
8489 {
8490 startMeasure(instance, `compile`);
8491 }
8492 const { isCustomElement, compilerOptions } = instance.appContext.config;
8493 const { delimiters, compilerOptions: componentCompilerOptions } = Component;
8494 const finalCompilerOptions = extend(extend({
8495 isCustomElement,
8496 delimiters
8497 }, compilerOptions), componentCompilerOptions);
8498 Component.render = compile(template, finalCompilerOptions);
8499 {
8500 endMeasure(instance, `compile`);
8501 }
8502 }
8503 }
8504 instance.render = (Component.render || NOOP);
8505 // for runtime-compiled render functions using `with` blocks, the render
8506 // proxy used needs a different `has` handler which is more performant and
8507 // also only allows a whitelist of globals to fallthrough.
8508 if (installWithProxy) {
8509 installWithProxy(instance);
8510 }
8511 }
8512 // support for 2.x options
8513 {
8514 setCurrentInstance(instance);
8515 pauseTracking();
8516 applyOptions(instance);
8517 resetTracking();
8518 unsetCurrentInstance();
8519 }
8520 // warn missing template/render
8521 // the runtime compilation of template in SSR is done by server-render
8522 if (!Component.render && instance.render === NOOP && !isSSR) {
8523 /* istanbul ignore if */
8524 if (!compile && Component.template) {
8525 warn$1(`Component provided template option but ` +
8526 `runtime compilation is not supported in this build of Vue.` +
8527 (` Use "vue.esm-browser.js" instead.`
8528 ) /* should not happen */);
8529 }
8530 else {
8531 warn$1(`Component is missing template or render function.`);
8532 }
8533 }
8534}
8535function createAttrsProxy(instance) {
8536 return new Proxy(instance.attrs, {
8537 get(target, key) {
8538 markAttrsAccessed();
8539 track(instance, "get" /* GET */, '$attrs');
8540 return target[key];
8541 },
8542 set() {
8543 warn$1(`setupContext.attrs is readonly.`);
8544 return false;
8545 },
8546 deleteProperty() {
8547 warn$1(`setupContext.attrs is readonly.`);
8548 return false;
8549 }
8550 }
8551 );
8552}
8553function createSetupContext(instance) {
8554 const expose = exposed => {
8555 if (instance.exposed) {
8556 warn$1(`expose() should be called only once per setup().`);
8557 }
8558 instance.exposed = exposed || {};
8559 };
8560 let attrs;
8561 {
8562 // We use getters in dev in case libs like test-utils overwrite instance
8563 // properties (overwrites should not be done in prod)
8564 return Object.freeze({
8565 get attrs() {
8566 return attrs || (attrs = createAttrsProxy(instance));
8567 },
8568 get slots() {
8569 return shallowReadonly(instance.slots);
8570 },
8571 get emit() {
8572 return (event, ...args) => instance.emit(event, ...args);
8573 },
8574 expose
8575 });
8576 }
8577}
8578function getExposeProxy(instance) {
8579 if (instance.exposed) {
8580 return (instance.exposeProxy ||
8581 (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
8582 get(target, key) {
8583 if (key in target) {
8584 return target[key];
8585 }
8586 else if (key in publicPropertiesMap) {
8587 return publicPropertiesMap[key](instance);
8588 }
8589 }
8590 })));
8591 }
8592}
8593const classifyRE = /(?:^|[-_])(\w)/g;
8594const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
8595function getComponentName(Component) {
8596 return isFunction(Component)
8597 ? Component.displayName || Component.name
8598 : Component.name;
8599}
8600/* istanbul ignore next */
8601function formatComponentName(instance, Component, isRoot = false) {
8602 let name = getComponentName(Component);
8603 if (!name && Component.__file) {
8604 const match = Component.__file.match(/([^/\\]+)\.\w+$/);
8605 if (match) {
8606 name = match[1];
8607 }
8608 }
8609 if (!name && instance && instance.parent) {
8610 // try to infer the name based on reverse resolution
8611 const inferFromRegistry = (registry) => {
8612 for (const key in registry) {
8613 if (registry[key] === Component) {
8614 return key;
8615 }
8616 }
8617 };
8618 name =
8619 inferFromRegistry(instance.components ||
8620 instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
8621 }
8622 return name ? classify(name) : isRoot ? `App` : `Anonymous`;
8623}
8624function isClassComponent(value) {
8625 return isFunction(value) && '__vccOpts' in value;
8626}
8627
8628const computed$1 = ((getterOrOptions, debugOptions) => {
8629 // @ts-ignore
8630 return computed(getterOrOptions, debugOptions, isInSSRComponentSetup);
8631});
8632
8633// dev only
8634const warnRuntimeUsage = (method) => warn$1(`${method}() is a compiler-hint helper that is only usable inside ` +
8635 `<script setup> of a single file component. Its arguments should be ` +
8636 `compiled away and passing it at runtime has no effect.`);
8637// implementation
8638function defineProps() {
8639 {
8640 warnRuntimeUsage(`defineProps`);
8641 }
8642 return null;
8643}
8644// implementation
8645function defineEmits() {
8646 {
8647 warnRuntimeUsage(`defineEmits`);
8648 }
8649 return null;
8650}
8651/**
8652 * Vue `<script setup>` compiler macro for declaring a component's exposed
8653 * instance properties when it is accessed by a parent component via template
8654 * refs.
8655 *
8656 * `<script setup>` components are closed by default - i.e. variables inside
8657 * the `<script setup>` scope is not exposed to parent unless explicitly exposed
8658 * via `defineExpose`.
8659 *
8660 * This is only usable inside `<script setup>`, is compiled away in the
8661 * output and should **not** be actually called at runtime.
8662 */
8663function defineExpose(exposed) {
8664 {
8665 warnRuntimeUsage(`defineExpose`);
8666 }
8667}
8668/**
8669 * Vue `<script setup>` compiler macro for providing props default values when
8670 * using type-based `defineProps` declaration.
8671 *
8672 * Example usage:
8673 * ```ts
8674 * withDefaults(defineProps<{
8675 * size?: number
8676 * labels?: string[]
8677 * }>(), {
8678 * size: 3,
8679 * labels: () => ['default label']
8680 * })
8681 * ```
8682 *
8683 * This is only usable inside `<script setup>`, is compiled away in the output
8684 * and should **not** be actually called at runtime.
8685 */
8686function withDefaults(props, defaults) {
8687 {
8688 warnRuntimeUsage(`withDefaults`);
8689 }
8690 return null;
8691}
8692function useSlots() {
8693 return getContext().slots;
8694}
8695function useAttrs() {
8696 return getContext().attrs;
8697}
8698function getContext() {
8699 const i = getCurrentInstance();
8700 if (!i) {
8701 warn$1(`useContext() called without active instance.`);
8702 }
8703 return i.setupContext || (i.setupContext = createSetupContext(i));
8704}
8705/**
8706 * Runtime helper for merging default declarations. Imported by compiled code
8707 * only.
8708 * @internal
8709 */
8710function mergeDefaults(raw, defaults) {
8711 const props = isArray(raw)
8712 ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8713 : raw;
8714 for (const key in defaults) {
8715 const opt = props[key];
8716 if (opt) {
8717 if (isArray(opt) || isFunction(opt)) {
8718 props[key] = { type: opt, default: defaults[key] };
8719 }
8720 else {
8721 opt.default = defaults[key];
8722 }
8723 }
8724 else if (opt === null) {
8725 props[key] = { default: defaults[key] };
8726 }
8727 else {
8728 warn$1(`props default key "${key}" has no corresponding declaration.`);
8729 }
8730 }
8731 return props;
8732}
8733/**
8734 * Used to create a proxy for the rest element when destructuring props with
8735 * defineProps().
8736 * @internal
8737 */
8738function createPropsRestProxy(props, excludedKeys) {
8739 const ret = {};
8740 for (const key in props) {
8741 if (!excludedKeys.includes(key)) {
8742 Object.defineProperty(ret, key, {
8743 enumerable: true,
8744 get: () => props[key]
8745 });
8746 }
8747 }
8748 return ret;
8749}
8750/**
8751 * `<script setup>` helper for persisting the current instance context over
8752 * async/await flows.
8753 *
8754 * `@vue/compiler-sfc` converts the following:
8755 *
8756 * ```ts
8757 * const x = await foo()
8758 * ```
8759 *
8760 * into:
8761 *
8762 * ```ts
8763 * let __temp, __restore
8764 * const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
8765 * ```
8766 * @internal
8767 */
8768function withAsyncContext(getAwaitable) {
8769 const ctx = getCurrentInstance();
8770 if (!ctx) {
8771 warn$1(`withAsyncContext called without active current instance. ` +
8772 `This is likely a bug.`);
8773 }
8774 let awaitable = getAwaitable();
8775 unsetCurrentInstance();
8776 if (isPromise(awaitable)) {
8777 awaitable = awaitable.catch(e => {
8778 setCurrentInstance(ctx);
8779 throw e;
8780 });
8781 }
8782 return [awaitable, () => setCurrentInstance(ctx)];
8783}
8784
8785// Actual implementation
8786function h(type, propsOrChildren, children) {
8787 const l = arguments.length;
8788 if (l === 2) {
8789 if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
8790 // single vnode without props
8791 if (isVNode(propsOrChildren)) {
8792 return createVNode(type, null, [propsOrChildren]);
8793 }
8794 // props without children
8795 return createVNode(type, propsOrChildren);
8796 }
8797 else {
8798 // omit props
8799 return createVNode(type, null, propsOrChildren);
8800 }
8801 }
8802 else {
8803 if (l > 3) {
8804 children = Array.prototype.slice.call(arguments, 2);
8805 }
8806 else if (l === 3 && isVNode(children)) {
8807 children = [children];
8808 }
8809 return createVNode(type, propsOrChildren, children);
8810 }
8811}
8812
8813const ssrContextKey = Symbol(`ssrContext` );
8814const useSSRContext = () => {
8815 {
8816 const ctx = inject(ssrContextKey);
8817 if (!ctx) {
8818 warn$1(`Server rendering context not provided. Make sure to only call ` +
8819 `useSSRContext() conditionally in the server build.`);
8820 }
8821 return ctx;
8822 }
8823};
8824
8825function initCustomFormatter() {
8826 /* eslint-disable no-restricted-globals */
8827 if (typeof window === 'undefined') {
8828 return;
8829 }
8830 const vueStyle = { style: 'color:#3ba776' };
8831 const numberStyle = { style: 'color:#0b1bc9' };
8832 const stringStyle = { style: 'color:#b62e24' };
8833 const keywordStyle = { style: 'color:#9d288c' };
8834 // custom formatter for Chrome
8835 // https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
8836 const formatter = {
8837 header(obj) {
8838 // TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
8839 if (!isObject(obj)) {
8840 return null;
8841 }
8842 if (obj.__isVue) {
8843 return ['div', vueStyle, `VueInstance`];
8844 }
8845 else if (isRef(obj)) {
8846 return [
8847 'div',
8848 {},
8849 ['span', vueStyle, genRefFlag(obj)],
8850 '<',
8851 formatValue(obj.value),
8852 `>`
8853 ];
8854 }
8855 else if (isReactive(obj)) {
8856 return [
8857 'div',
8858 {},
8859 ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
8860 '<',
8861 formatValue(obj),
8862 `>${isReadonly(obj) ? ` (readonly)` : ``}`
8863 ];
8864 }
8865 else if (isReadonly(obj)) {
8866 return [
8867 'div',
8868 {},
8869 ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
8870 '<',
8871 formatValue(obj),
8872 '>'
8873 ];
8874 }
8875 return null;
8876 },
8877 hasBody(obj) {
8878 return obj && obj.__isVue;
8879 },
8880 body(obj) {
8881 if (obj && obj.__isVue) {
8882 return [
8883 'div',
8884 {},
8885 ...formatInstance(obj.$)
8886 ];
8887 }
8888 }
8889 };
8890 function formatInstance(instance) {
8891 const blocks = [];
8892 if (instance.type.props && instance.props) {
8893 blocks.push(createInstanceBlock('props', toRaw(instance.props)));
8894 }
8895 if (instance.setupState !== EMPTY_OBJ) {
8896 blocks.push(createInstanceBlock('setup', instance.setupState));
8897 }
8898 if (instance.data !== EMPTY_OBJ) {
8899 blocks.push(createInstanceBlock('data', toRaw(instance.data)));
8900 }
8901 const computed = extractKeys(instance, 'computed');
8902 if (computed) {
8903 blocks.push(createInstanceBlock('computed', computed));
8904 }
8905 const injected = extractKeys(instance, 'inject');
8906 if (injected) {
8907 blocks.push(createInstanceBlock('injected', injected));
8908 }
8909 blocks.push([
8910 'div',
8911 {},
8912 [
8913 'span',
8914 {
8915 style: keywordStyle.style + ';opacity:0.66'
8916 },
8917 '$ (internal): '
8918 ],
8919 ['object', { object: instance }]
8920 ]);
8921 return blocks;
8922 }
8923 function createInstanceBlock(type, target) {
8924 target = extend({}, target);
8925 if (!Object.keys(target).length) {
8926 return ['span', {}];
8927 }
8928 return [
8929 'div',
8930 { style: 'line-height:1.25em;margin-bottom:0.6em' },
8931 [
8932 'div',
8933 {
8934 style: 'color:#476582'
8935 },
8936 type
8937 ],
8938 [
8939 'div',
8940 {
8941 style: 'padding-left:1.25em'
8942 },
8943 ...Object.keys(target).map(key => {
8944 return [
8945 'div',
8946 {},
8947 ['span', keywordStyle, key + ': '],
8948 formatValue(target[key], false)
8949 ];
8950 })
8951 ]
8952 ];
8953 }
8954 function formatValue(v, asRaw = true) {
8955 if (typeof v === 'number') {
8956 return ['span', numberStyle, v];
8957 }
8958 else if (typeof v === 'string') {
8959 return ['span', stringStyle, JSON.stringify(v)];
8960 }
8961 else if (typeof v === 'boolean') {
8962 return ['span', keywordStyle, v];
8963 }
8964 else if (isObject(v)) {
8965 return ['object', { object: asRaw ? toRaw(v) : v }];
8966 }
8967 else {
8968 return ['span', stringStyle, String(v)];
8969 }
8970 }
8971 function extractKeys(instance, type) {
8972 const Comp = instance.type;
8973 if (isFunction(Comp)) {
8974 return;
8975 }
8976 const extracted = {};
8977 for (const key in instance.ctx) {
8978 if (isKeyOfType(Comp, key, type)) {
8979 extracted[key] = instance.ctx[key];
8980 }
8981 }
8982 return extracted;
8983 }
8984 function isKeyOfType(Comp, key, type) {
8985 const opts = Comp[type];
8986 if ((isArray(opts) && opts.includes(key)) ||
8987 (isObject(opts) && key in opts)) {
8988 return true;
8989 }
8990 if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
8991 return true;
8992 }
8993 if (Comp.mixins && Comp.mixins.some(m => isKeyOfType(m, key, type))) {
8994 return true;
8995 }
8996 }
8997 function genRefFlag(v) {
8998 if (isShallow(v)) {
8999 return `ShallowRef`;
9000 }
9001 if (v.effect) {
9002 return `ComputedRef`;
9003 }
9004 return `Ref`;
9005 }
9006 if (window.devtoolsFormatters) {
9007 window.devtoolsFormatters.push(formatter);
9008 }
9009 else {
9010 window.devtoolsFormatters = [formatter];
9011 }
9012}
9013
9014function withMemo(memo, render, cache, index) {
9015 const cached = cache[index];
9016 if (cached && isMemoSame(cached, memo)) {
9017 return cached;
9018 }
9019 const ret = render();
9020 // shallow clone
9021 ret.memo = memo.slice();
9022 return (cache[index] = ret);
9023}
9024function isMemoSame(cached, memo) {
9025 const prev = cached.memo;
9026 if (prev.length != memo.length) {
9027 return false;
9028 }
9029 for (let i = 0; i < prev.length; i++) {
9030 if (prev[i] !== memo[i]) {
9031 return false;
9032 }
9033 }
9034 // make sure to let parent block track it when returning cached
9035 if (isBlockTreeEnabled > 0 && currentBlock) {
9036 currentBlock.push(cached);
9037 }
9038 return true;
9039}
9040
9041// Core API ------------------------------------------------------------------
9042const version = "3.2.31";
9043/**
9044 * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9045 * @internal
9046 */
9047const ssrUtils = (null);
9048/**
9049 * @internal only exposed in compat builds
9050 */
9051const resolveFilter = null;
9052/**
9053 * @internal only exposed in compat builds.
9054 */
9055const compatUtils = (null);
9056
9057const svgNS = 'http://www.w3.org/2000/svg';
9058const doc = (typeof document !== 'undefined' ? document : null);
9059const templateContainer = doc && doc.createElement('template');
9060const nodeOps = {
9061 insert: (child, parent, anchor) => {
9062 parent.insertBefore(child, anchor || null);
9063 },
9064 remove: child => {
9065 const parent = child.parentNode;
9066 if (parent) {
9067 parent.removeChild(child);
9068 }
9069 },
9070 createElement: (tag, isSVG, is, props) => {
9071 const el = isSVG
9072 ? doc.createElementNS(svgNS, tag)
9073 : doc.createElement(tag, is ? { is } : undefined);
9074 if (tag === 'select' && props && props.multiple != null) {
9075 el.setAttribute('multiple', props.multiple);
9076 }
9077 return el;
9078 },
9079 createText: text => doc.createTextNode(text),
9080 createComment: text => doc.createComment(text),
9081 setText: (node, text) => {
9082 node.nodeValue = text;
9083 },
9084 setElementText: (el, text) => {
9085 el.textContent = text;
9086 },
9087 parentNode: node => node.parentNode,
9088 nextSibling: node => node.nextSibling,
9089 querySelector: selector => doc.querySelector(selector),
9090 setScopeId(el, id) {
9091 el.setAttribute(id, '');
9092 },
9093 cloneNode(el) {
9094 const cloned = el.cloneNode(true);
9095 // #3072
9096 // - in `patchDOMProp`, we store the actual value in the `el._value` property.
9097 // - normally, elements using `:value` bindings will not be hoisted, but if
9098 // the bound value is a constant, e.g. `:value="true"` - they do get
9099 // hoisted.
9100 // - in production, hoisted nodes are cloned when subsequent inserts, but
9101 // cloneNode() does not copy the custom property we attached.
9102 // - This may need to account for other custom DOM properties we attach to
9103 // elements in addition to `_value` in the future.
9104 if (`_value` in el) {
9105 cloned._value = el._value;
9106 }
9107 return cloned;
9108 },
9109 // __UNSAFE__
9110 // Reason: innerHTML.
9111 // Static content here can only come from compiled templates.
9112 // As long as the user only uses trusted templates, this is safe.
9113 insertStaticContent(content, parent, anchor, isSVG, start, end) {
9114 // <parent> before | first ... last | anchor </parent>
9115 const before = anchor ? anchor.previousSibling : parent.lastChild;
9116 // #5308 can only take cached path if:
9117 // - has a single root node
9118 // - nextSibling info is still available
9119 if (start && (start === end || start.nextSibling)) {
9120 // cached
9121 while (true) {
9122 parent.insertBefore(start.cloneNode(true), anchor);
9123 if (start === end || !(start = start.nextSibling))
9124 break;
9125 }
9126 }
9127 else {
9128 // fresh insert
9129 templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
9130 const template = templateContainer.content;
9131 if (isSVG) {
9132 // remove outer svg wrapper
9133 const wrapper = template.firstChild;
9134 while (wrapper.firstChild) {
9135 template.appendChild(wrapper.firstChild);
9136 }
9137 template.removeChild(wrapper);
9138 }
9139 parent.insertBefore(template, anchor);
9140 }
9141 return [
9142 // first
9143 before ? before.nextSibling : parent.firstChild,
9144 // last
9145 anchor ? anchor.previousSibling : parent.lastChild
9146 ];
9147 }
9148};
9149
9150// compiler should normalize class + :class bindings on the same element
9151// into a single binding ['staticClass', dynamic]
9152function patchClass(el, value, isSVG) {
9153 // directly setting className should be faster than setAttribute in theory
9154 // if this is an element during a transition, take the temporary transition
9155 // classes into account.
9156 const transitionClasses = el._vtc;
9157 if (transitionClasses) {
9158 value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
9159 }
9160 if (value == null) {
9161 el.removeAttribute('class');
9162 }
9163 else if (isSVG) {
9164 el.setAttribute('class', value);
9165 }
9166 else {
9167 el.className = value;
9168 }
9169}
9170
9171function patchStyle(el, prev, next) {
9172 const style = el.style;
9173 const isCssString = isString(next);
9174 if (next && !isCssString) {
9175 for (const key in next) {
9176 setStyle(style, key, next[key]);
9177 }
9178 if (prev && !isString(prev)) {
9179 for (const key in prev) {
9180 if (next[key] == null) {
9181 setStyle(style, key, '');
9182 }
9183 }
9184 }
9185 }
9186 else {
9187 const currentDisplay = style.display;
9188 if (isCssString) {
9189 if (prev !== next) {
9190 style.cssText = next;
9191 }
9192 }
9193 else if (prev) {
9194 el.removeAttribute('style');
9195 }
9196 // indicates that the `display` of the element is controlled by `v-show`,
9197 // so we always keep the current `display` value regardless of the `style`
9198 // value, thus handing over control to `v-show`.
9199 if ('_vod' in el) {
9200 style.display = currentDisplay;
9201 }
9202 }
9203}
9204const importantRE = /\s*!important$/;
9205function setStyle(style, name, val) {
9206 if (isArray(val)) {
9207 val.forEach(v => setStyle(style, name, v));
9208 }
9209 else {
9210 if (name.startsWith('--')) {
9211 // custom property definition
9212 style.setProperty(name, val);
9213 }
9214 else {
9215 const prefixed = autoPrefix(style, name);
9216 if (importantRE.test(val)) {
9217 // !important
9218 style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
9219 }
9220 else {
9221 style[prefixed] = val;
9222 }
9223 }
9224 }
9225}
9226const prefixes = ['Webkit', 'Moz', 'ms'];
9227const prefixCache = {};
9228function autoPrefix(style, rawName) {
9229 const cached = prefixCache[rawName];
9230 if (cached) {
9231 return cached;
9232 }
9233 let name = camelize(rawName);
9234 if (name !== 'filter' && name in style) {
9235 return (prefixCache[rawName] = name);
9236 }
9237 name = capitalize(name);
9238 for (let i = 0; i < prefixes.length; i++) {
9239 const prefixed = prefixes[i] + name;
9240 if (prefixed in style) {
9241 return (prefixCache[rawName] = prefixed);
9242 }
9243 }
9244 return rawName;
9245}
9246
9247const xlinkNS = 'http://www.w3.org/1999/xlink';
9248function patchAttr(el, key, value, isSVG, instance) {
9249 if (isSVG && key.startsWith('xlink:')) {
9250 if (value == null) {
9251 el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
9252 }
9253 else {
9254 el.setAttributeNS(xlinkNS, key, value);
9255 }
9256 }
9257 else {
9258 // note we are only checking boolean attributes that don't have a
9259 // corresponding dom prop of the same name here.
9260 const isBoolean = isSpecialBooleanAttr(key);
9261 if (value == null || (isBoolean && !includeBooleanAttr(value))) {
9262 el.removeAttribute(key);
9263 }
9264 else {
9265 el.setAttribute(key, isBoolean ? '' : value);
9266 }
9267 }
9268}
9269
9270// __UNSAFE__
9271// functions. The user is responsible for using them with only trusted content.
9272function patchDOMProp(el, key, value,
9273// the following args are passed only due to potential innerHTML/textContent
9274// overriding existing VNodes, in which case the old tree must be properly
9275// unmounted.
9276prevChildren, parentComponent, parentSuspense, unmountChildren) {
9277 if (key === 'innerHTML' || key === 'textContent') {
9278 if (prevChildren) {
9279 unmountChildren(prevChildren, parentComponent, parentSuspense);
9280 }
9281 el[key] = value == null ? '' : value;
9282 return;
9283 }
9284 if (key === 'value' &&
9285 el.tagName !== 'PROGRESS' &&
9286 // custom elements may use _value internally
9287 !el.tagName.includes('-')) {
9288 // store value as _value as well since
9289 // non-string values will be stringified.
9290 el._value = value;
9291 const newValue = value == null ? '' : value;
9292 if (el.value !== newValue ||
9293 // #4956: always set for OPTION elements because its value falls back to
9294 // textContent if no value attribute is present. And setting .value for
9295 // OPTION has no side effect
9296 el.tagName === 'OPTION') {
9297 el.value = newValue;
9298 }
9299 if (value == null) {
9300 el.removeAttribute(key);
9301 }
9302 return;
9303 }
9304 if (value === '' || value == null) {
9305 const type = typeof el[key];
9306 if (type === 'boolean') {
9307 // e.g. <select multiple> compiles to { multiple: '' }
9308 el[key] = includeBooleanAttr(value);
9309 return;
9310 }
9311 else if (value == null && type === 'string') {
9312 // e.g. <div :id="null">
9313 el[key] = '';
9314 el.removeAttribute(key);
9315 return;
9316 }
9317 else if (type === 'number') {
9318 // e.g. <img :width="null">
9319 // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
9320 try {
9321 el[key] = 0;
9322 }
9323 catch (_a) { }
9324 el.removeAttribute(key);
9325 return;
9326 }
9327 }
9328 // some properties perform value validation and throw
9329 try {
9330 el[key] = value;
9331 }
9332 catch (e) {
9333 {
9334 warn$1(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
9335 `value ${value} is invalid.`, e);
9336 }
9337 }
9338}
9339
9340// Async edge case fix requires storing an event listener's attach timestamp.
9341let _getNow = Date.now;
9342let skipTimestampCheck = false;
9343if (typeof window !== 'undefined') {
9344 // Determine what event timestamp the browser is using. Annoyingly, the
9345 // timestamp can either be hi-res (relative to page load) or low-res
9346 // (relative to UNIX epoch), so in order to compare time we have to use the
9347 // same timestamp type when saving the flush timestamp.
9348 if (_getNow() > document.createEvent('Event').timeStamp) {
9349 // if the low-res timestamp which is bigger than the event timestamp
9350 // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
9351 // and we need to use the hi-res version for event listeners as well.
9352 _getNow = () => performance.now();
9353 }
9354 // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
9355 // and does not fire microtasks in between event propagation, so safe to exclude.
9356 const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
9357 skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
9358}
9359// To avoid the overhead of repeatedly calling performance.now(), we cache
9360// and use the same timestamp for all event listeners attached in the same tick.
9361let cachedNow = 0;
9362const p = Promise.resolve();
9363const reset = () => {
9364 cachedNow = 0;
9365};
9366const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
9367function addEventListener(el, event, handler, options) {
9368 el.addEventListener(event, handler, options);
9369}
9370function removeEventListener(el, event, handler, options) {
9371 el.removeEventListener(event, handler, options);
9372}
9373function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
9374 // vei = vue event invokers
9375 const invokers = el._vei || (el._vei = {});
9376 const existingInvoker = invokers[rawName];
9377 if (nextValue && existingInvoker) {
9378 // patch
9379 existingInvoker.value = nextValue;
9380 }
9381 else {
9382 const [name, options] = parseName(rawName);
9383 if (nextValue) {
9384 // add
9385 const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
9386 addEventListener(el, name, invoker, options);
9387 }
9388 else if (existingInvoker) {
9389 // remove
9390 removeEventListener(el, name, existingInvoker, options);
9391 invokers[rawName] = undefined;
9392 }
9393 }
9394}
9395const optionsModifierRE = /(?:Once|Passive|Capture)$/;
9396function parseName(name) {
9397 let options;
9398 if (optionsModifierRE.test(name)) {
9399 options = {};
9400 let m;
9401 while ((m = name.match(optionsModifierRE))) {
9402 name = name.slice(0, name.length - m[0].length);
9403 options[m[0].toLowerCase()] = true;
9404 }
9405 }
9406 return [hyphenate(name.slice(2)), options];
9407}
9408function createInvoker(initialValue, instance) {
9409 const invoker = (e) => {
9410 // async edge case #6566: inner click event triggers patch, event handler
9411 // attached to outer element during patch, and triggered again. This
9412 // happens because browsers fire microtask ticks between event propagation.
9413 // the solution is simple: we save the timestamp when a handler is attached,
9414 // and the handler would only fire if the event passed to it was fired
9415 // AFTER it was attached.
9416 const timeStamp = e.timeStamp || _getNow();
9417 if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
9418 callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
9419 }
9420 };
9421 invoker.value = initialValue;
9422 invoker.attached = getNow();
9423 return invoker;
9424}
9425function patchStopImmediatePropagation(e, value) {
9426 if (isArray(value)) {
9427 const originalStop = e.stopImmediatePropagation;
9428 e.stopImmediatePropagation = () => {
9429 originalStop.call(e);
9430 e._stopped = true;
9431 };
9432 return value.map(fn => (e) => !e._stopped && fn && fn(e));
9433 }
9434 else {
9435 return value;
9436 }
9437}
9438
9439const nativeOnRE = /^on[a-z]/;
9440const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
9441 if (key === 'class') {
9442 patchClass(el, nextValue, isSVG);
9443 }
9444 else if (key === 'style') {
9445 patchStyle(el, prevValue, nextValue);
9446 }
9447 else if (isOn(key)) {
9448 // ignore v-model listeners
9449 if (!isModelListener(key)) {
9450 patchEvent(el, key, prevValue, nextValue, parentComponent);
9451 }
9452 }
9453 else if (key[0] === '.'
9454 ? ((key = key.slice(1)), true)
9455 : key[0] === '^'
9456 ? ((key = key.slice(1)), false)
9457 : shouldSetAsProp(el, key, nextValue, isSVG)) {
9458 patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
9459 }
9460 else {
9461 // special case for <input v-model type="checkbox"> with
9462 // :true-value & :false-value
9463 // store value as dom properties since non-string values will be
9464 // stringified.
9465 if (key === 'true-value') {
9466 el._trueValue = nextValue;
9467 }
9468 else if (key === 'false-value') {
9469 el._falseValue = nextValue;
9470 }
9471 patchAttr(el, key, nextValue, isSVG);
9472 }
9473};
9474function shouldSetAsProp(el, key, value, isSVG) {
9475 if (isSVG) {
9476 // most keys must be set as attribute on svg elements to work
9477 // ...except innerHTML & textContent
9478 if (key === 'innerHTML' || key === 'textContent') {
9479 return true;
9480 }
9481 // or native onclick with function values
9482 if (key in el && nativeOnRE.test(key) && isFunction(value)) {
9483 return true;
9484 }
9485 return false;
9486 }
9487 // spellcheck and draggable are numerated attrs, however their
9488 // corresponding DOM properties are actually booleans - this leads to
9489 // setting it with a string "false" value leading it to be coerced to
9490 // `true`, so we need to always treat them as attributes.
9491 // Note that `contentEditable` doesn't have this problem: its DOM
9492 // property is also enumerated string values.
9493 if (key === 'spellcheck' || key === 'draggable') {
9494 return false;
9495 }
9496 // #1787, #2840 form property on form elements is readonly and must be set as
9497 // attribute.
9498 if (key === 'form') {
9499 return false;
9500 }
9501 // #1526 <input list> must be set as attribute
9502 if (key === 'list' && el.tagName === 'INPUT') {
9503 return false;
9504 }
9505 // #2766 <textarea type> must be set as attribute
9506 if (key === 'type' && el.tagName === 'TEXTAREA') {
9507 return false;
9508 }
9509 // native onclick with string value, must be set as attribute
9510 if (nativeOnRE.test(key) && isString(value)) {
9511 return false;
9512 }
9513 return key in el;
9514}
9515
9516function defineCustomElement(options, hydate) {
9517 const Comp = defineComponent(options);
9518 class VueCustomElement extends VueElement {
9519 constructor(initialProps) {
9520 super(Comp, initialProps, hydate);
9521 }
9522 }
9523 VueCustomElement.def = Comp;
9524 return VueCustomElement;
9525}
9526const defineSSRCustomElement = ((options) => {
9527 // @ts-ignore
9528 return defineCustomElement(options, hydrate);
9529});
9530const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
9531});
9532class VueElement extends BaseClass {
9533 constructor(_def, _props = {}, hydrate) {
9534 super();
9535 this._def = _def;
9536 this._props = _props;
9537 /**
9538 * @internal
9539 */
9540 this._instance = null;
9541 this._connected = false;
9542 this._resolved = false;
9543 this._numberProps = null;
9544 if (this.shadowRoot && hydrate) {
9545 hydrate(this._createVNode(), this.shadowRoot);
9546 }
9547 else {
9548 if (this.shadowRoot) {
9549 warn$1(`Custom element has pre-rendered declarative shadow root but is not ` +
9550 `defined as hydratable. Use \`defineSSRCustomElement\`.`);
9551 }
9552 this.attachShadow({ mode: 'open' });
9553 }
9554 }
9555 connectedCallback() {
9556 this._connected = true;
9557 if (!this._instance) {
9558 this._resolveDef();
9559 }
9560 }
9561 disconnectedCallback() {
9562 this._connected = false;
9563 nextTick(() => {
9564 if (!this._connected) {
9565 render(null, this.shadowRoot);
9566 this._instance = null;
9567 }
9568 });
9569 }
9570 /**
9571 * resolve inner component definition (handle possible async component)
9572 */
9573 _resolveDef() {
9574 if (this._resolved) {
9575 return;
9576 }
9577 this._resolved = true;
9578 // set initial attrs
9579 for (let i = 0; i < this.attributes.length; i++) {
9580 this._setAttr(this.attributes[i].name);
9581 }
9582 // watch future attr changes
9583 new MutationObserver(mutations => {
9584 for (const m of mutations) {
9585 this._setAttr(m.attributeName);
9586 }
9587 }).observe(this, { attributes: true });
9588 const resolve = (def) => {
9589 const { props, styles } = def;
9590 const hasOptions = !isArray(props);
9591 const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
9592 // cast Number-type props set before resolve
9593 let numberProps;
9594 if (hasOptions) {
9595 for (const key in this._props) {
9596 const opt = props[key];
9597 if (opt === Number || (opt && opt.type === Number)) {
9598 this._props[key] = toNumber(this._props[key]);
9599 (numberProps || (numberProps = Object.create(null)))[key] = true;
9600 }
9601 }
9602 }
9603 this._numberProps = numberProps;
9604 // check if there are props set pre-upgrade or connect
9605 for (const key of Object.keys(this)) {
9606 if (key[0] !== '_') {
9607 this._setProp(key, this[key], true, false);
9608 }
9609 }
9610 // defining getter/setters on prototype
9611 for (const key of rawKeys.map(camelize)) {
9612 Object.defineProperty(this, key, {
9613 get() {
9614 return this._getProp(key);
9615 },
9616 set(val) {
9617 this._setProp(key, val);
9618 }
9619 });
9620 }
9621 // apply CSS
9622 this._applyStyles(styles);
9623 // initial render
9624 this._update();
9625 };
9626 const asyncDef = this._def.__asyncLoader;
9627 if (asyncDef) {
9628 asyncDef().then(resolve);
9629 }
9630 else {
9631 resolve(this._def);
9632 }
9633 }
9634 _setAttr(key) {
9635 let value = this.getAttribute(key);
9636 if (this._numberProps && this._numberProps[key]) {
9637 value = toNumber(value);
9638 }
9639 this._setProp(camelize(key), value, false);
9640 }
9641 /**
9642 * @internal
9643 */
9644 _getProp(key) {
9645 return this._props[key];
9646 }
9647 /**
9648 * @internal
9649 */
9650 _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9651 if (val !== this._props[key]) {
9652 this._props[key] = val;
9653 if (shouldUpdate && this._instance) {
9654 this._update();
9655 }
9656 // reflect
9657 if (shouldReflect) {
9658 if (val === true) {
9659 this.setAttribute(hyphenate(key), '');
9660 }
9661 else if (typeof val === 'string' || typeof val === 'number') {
9662 this.setAttribute(hyphenate(key), val + '');
9663 }
9664 else if (!val) {
9665 this.removeAttribute(hyphenate(key));
9666 }
9667 }
9668 }
9669 }
9670 _update() {
9671 render(this._createVNode(), this.shadowRoot);
9672 }
9673 _createVNode() {
9674 const vnode = createVNode(this._def, extend({}, this._props));
9675 if (!this._instance) {
9676 vnode.ce = instance => {
9677 this._instance = instance;
9678 instance.isCE = true;
9679 // HMR
9680 {
9681 instance.ceReload = newStyles => {
9682 // always reset styles
9683 if (this._styles) {
9684 this._styles.forEach(s => this.shadowRoot.removeChild(s));
9685 this._styles.length = 0;
9686 }
9687 this._applyStyles(newStyles);
9688 // if this is an async component, ceReload is called from the inner
9689 // component so no need to reload the async wrapper
9690 if (!this._def.__asyncLoader) {
9691 // reload
9692 this._instance = null;
9693 this._update();
9694 }
9695 };
9696 }
9697 // intercept emit
9698 instance.emit = (event, ...args) => {
9699 this.dispatchEvent(new CustomEvent(event, {
9700 detail: args
9701 }));
9702 };
9703 // locate nearest Vue custom element parent for provide/inject
9704 let parent = this;
9705 while ((parent =
9706 parent && (parent.parentNode || parent.host))) {
9707 if (parent instanceof VueElement) {
9708 instance.parent = parent._instance;
9709 break;
9710 }
9711 }
9712 };
9713 }
9714 return vnode;
9715 }
9716 _applyStyles(styles) {
9717 if (styles) {
9718 styles.forEach(css => {
9719 const s = document.createElement('style');
9720 s.textContent = css;
9721 this.shadowRoot.appendChild(s);
9722 // record for HMR
9723 {
9724 (this._styles || (this._styles = [])).push(s);
9725 }
9726 });
9727 }
9728 }
9729}
9730
9731function useCssModule(name = '$style') {
9732 /* istanbul ignore else */
9733 {
9734 const instance = getCurrentInstance();
9735 if (!instance) {
9736 warn$1(`useCssModule must be called inside setup()`);
9737 return EMPTY_OBJ;
9738 }
9739 const modules = instance.type.__cssModules;
9740 if (!modules) {
9741 warn$1(`Current instance does not have CSS modules injected.`);
9742 return EMPTY_OBJ;
9743 }
9744 const mod = modules[name];
9745 if (!mod) {
9746 warn$1(`Current instance does not have CSS module named "${name}".`);
9747 return EMPTY_OBJ;
9748 }
9749 return mod;
9750 }
9751}
9752
9753/**
9754 * Runtime helper for SFC's CSS variable injection feature.
9755 * @private
9756 */
9757function useCssVars(getter) {
9758 const instance = getCurrentInstance();
9759 /* istanbul ignore next */
9760 if (!instance) {
9761 warn$1(`useCssVars is called without current active component instance.`);
9762 return;
9763 }
9764 const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
9765 watchPostEffect(setVars);
9766 onMounted(() => {
9767 const ob = new MutationObserver(setVars);
9768 ob.observe(instance.subTree.el.parentNode, { childList: true });
9769 onUnmounted(() => ob.disconnect());
9770 });
9771}
9772function setVarsOnVNode(vnode, vars) {
9773 if (vnode.shapeFlag & 128 /* SUSPENSE */) {
9774 const suspense = vnode.suspense;
9775 vnode = suspense.activeBranch;
9776 if (suspense.pendingBranch && !suspense.isHydrating) {
9777 suspense.effects.push(() => {
9778 setVarsOnVNode(suspense.activeBranch, vars);
9779 });
9780 }
9781 }
9782 // drill down HOCs until it's a non-component vnode
9783 while (vnode.component) {
9784 vnode = vnode.component.subTree;
9785 }
9786 if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
9787 setVarsOnNode(vnode.el, vars);
9788 }
9789 else if (vnode.type === Fragment) {
9790 vnode.children.forEach(c => setVarsOnVNode(c, vars));
9791 }
9792 else if (vnode.type === Static) {
9793 let { el, anchor } = vnode;
9794 while (el) {
9795 setVarsOnNode(el, vars);
9796 if (el === anchor)
9797 break;
9798 el = el.nextSibling;
9799 }
9800 }
9801}
9802function setVarsOnNode(el, vars) {
9803 if (el.nodeType === 1) {
9804 const style = el.style;
9805 for (const key in vars) {
9806 style.setProperty(`--${key}`, vars[key]);
9807 }
9808 }
9809}
9810
9811const TRANSITION = 'transition';
9812const ANIMATION = 'animation';
9813// DOM Transition is a higher-order-component based on the platform-agnostic
9814// base Transition component, with DOM-specific logic.
9815const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
9816Transition.displayName = 'Transition';
9817const DOMTransitionPropsValidators = {
9818 name: String,
9819 type: String,
9820 css: {
9821 type: Boolean,
9822 default: true
9823 },
9824 duration: [String, Number, Object],
9825 enterFromClass: String,
9826 enterActiveClass: String,
9827 enterToClass: String,
9828 appearFromClass: String,
9829 appearActiveClass: String,
9830 appearToClass: String,
9831 leaveFromClass: String,
9832 leaveActiveClass: String,
9833 leaveToClass: String
9834};
9835const TransitionPropsValidators = (Transition.props =
9836 /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
9837/**
9838 * #3227 Incoming hooks may be merged into arrays when wrapping Transition
9839 * with custom HOCs.
9840 */
9841const callHook$1 = (hook, args = []) => {
9842 if (isArray(hook)) {
9843 hook.forEach(h => h(...args));
9844 }
9845 else if (hook) {
9846 hook(...args);
9847 }
9848};
9849/**
9850 * Check if a hook expects a callback (2nd arg), which means the user
9851 * intends to explicitly control the end of the transition.
9852 */
9853const hasExplicitCallback = (hook) => {
9854 return hook
9855 ? isArray(hook)
9856 ? hook.some(h => h.length > 1)
9857 : hook.length > 1
9858 : false;
9859};
9860function resolveTransitionProps(rawProps) {
9861 const baseProps = {};
9862 for (const key in rawProps) {
9863 if (!(key in DOMTransitionPropsValidators)) {
9864 baseProps[key] = rawProps[key];
9865 }
9866 }
9867 if (rawProps.css === false) {
9868 return baseProps;
9869 }
9870 const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
9871 const durations = normalizeDuration(duration);
9872 const enterDuration = durations && durations[0];
9873 const leaveDuration = durations && durations[1];
9874 const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
9875 const finishEnter = (el, isAppear, done) => {
9876 removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
9877 removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
9878 done && done();
9879 };
9880 const finishLeave = (el, done) => {
9881 removeTransitionClass(el, leaveToClass);
9882 removeTransitionClass(el, leaveActiveClass);
9883 done && done();
9884 };
9885 const makeEnterHook = (isAppear) => {
9886 return (el, done) => {
9887 const hook = isAppear ? onAppear : onEnter;
9888 const resolve = () => finishEnter(el, isAppear, done);
9889 callHook$1(hook, [el, resolve]);
9890 nextFrame(() => {
9891 removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
9892 addTransitionClass(el, isAppear ? appearToClass : enterToClass);
9893 if (!hasExplicitCallback(hook)) {
9894 whenTransitionEnds(el, type, enterDuration, resolve);
9895 }
9896 });
9897 };
9898 };
9899 return extend(baseProps, {
9900 onBeforeEnter(el) {
9901 callHook$1(onBeforeEnter, [el]);
9902 addTransitionClass(el, enterFromClass);
9903 addTransitionClass(el, enterActiveClass);
9904 },
9905 onBeforeAppear(el) {
9906 callHook$1(onBeforeAppear, [el]);
9907 addTransitionClass(el, appearFromClass);
9908 addTransitionClass(el, appearActiveClass);
9909 },
9910 onEnter: makeEnterHook(false),
9911 onAppear: makeEnterHook(true),
9912 onLeave(el, done) {
9913 const resolve = () => finishLeave(el, done);
9914 addTransitionClass(el, leaveFromClass);
9915 // force reflow so *-leave-from classes immediately take effect (#2593)
9916 forceReflow();
9917 addTransitionClass(el, leaveActiveClass);
9918 nextFrame(() => {
9919 removeTransitionClass(el, leaveFromClass);
9920 addTransitionClass(el, leaveToClass);
9921 if (!hasExplicitCallback(onLeave)) {
9922 whenTransitionEnds(el, type, leaveDuration, resolve);
9923 }
9924 });
9925 callHook$1(onLeave, [el, resolve]);
9926 },
9927 onEnterCancelled(el) {
9928 finishEnter(el, false);
9929 callHook$1(onEnterCancelled, [el]);
9930 },
9931 onAppearCancelled(el) {
9932 finishEnter(el, true);
9933 callHook$1(onAppearCancelled, [el]);
9934 },
9935 onLeaveCancelled(el) {
9936 finishLeave(el);
9937 callHook$1(onLeaveCancelled, [el]);
9938 }
9939 });
9940}
9941function normalizeDuration(duration) {
9942 if (duration == null) {
9943 return null;
9944 }
9945 else if (isObject(duration)) {
9946 return [NumberOf(duration.enter), NumberOf(duration.leave)];
9947 }
9948 else {
9949 const n = NumberOf(duration);
9950 return [n, n];
9951 }
9952}
9953function NumberOf(val) {
9954 const res = toNumber(val);
9955 validateDuration(res);
9956 return res;
9957}
9958function validateDuration(val) {
9959 if (typeof val !== 'number') {
9960 warn$1(`<transition> explicit duration is not a valid number - ` +
9961 `got ${JSON.stringify(val)}.`);
9962 }
9963 else if (isNaN(val)) {
9964 warn$1(`<transition> explicit duration is NaN - ` +
9965 'the duration expression might be incorrect.');
9966 }
9967}
9968function addTransitionClass(el, cls) {
9969 cls.split(/\s+/).forEach(c => c && el.classList.add(c));
9970 (el._vtc ||
9971 (el._vtc = new Set())).add(cls);
9972}
9973function removeTransitionClass(el, cls) {
9974 cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
9975 const { _vtc } = el;
9976 if (_vtc) {
9977 _vtc.delete(cls);
9978 if (!_vtc.size) {
9979 el._vtc = undefined;
9980 }
9981 }
9982}
9983function nextFrame(cb) {
9984 requestAnimationFrame(() => {
9985 requestAnimationFrame(cb);
9986 });
9987}
9988let endId = 0;
9989function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
9990 const id = (el._endId = ++endId);
9991 const resolveIfNotStale = () => {
9992 if (id === el._endId) {
9993 resolve();
9994 }
9995 };
9996 if (explicitTimeout) {
9997 return setTimeout(resolveIfNotStale, explicitTimeout);
9998 }
9999 const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
10000 if (!type) {
10001 return resolve();
10002 }
10003 const endEvent = type + 'end';
10004 let ended = 0;
10005 const end = () => {
10006 el.removeEventListener(endEvent, onEnd);
10007 resolveIfNotStale();
10008 };
10009 const onEnd = (e) => {
10010 if (e.target === el && ++ended >= propCount) {
10011 end();
10012 }
10013 };
10014 setTimeout(() => {
10015 if (ended < propCount) {
10016 end();
10017 }
10018 }, timeout + 1);
10019 el.addEventListener(endEvent, onEnd);
10020}
10021function getTransitionInfo(el, expectedType) {
10022 const styles = window.getComputedStyle(el);
10023 // JSDOM may return undefined for transition properties
10024 const getStyleProperties = (key) => (styles[key] || '').split(', ');
10025 const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
10026 const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
10027 const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
10028 const animationDelays = getStyleProperties(ANIMATION + 'Delay');
10029 const animationDurations = getStyleProperties(ANIMATION + 'Duration');
10030 const animationTimeout = getTimeout(animationDelays, animationDurations);
10031 let type = null;
10032 let timeout = 0;
10033 let propCount = 0;
10034 /* istanbul ignore if */
10035 if (expectedType === TRANSITION) {
10036 if (transitionTimeout > 0) {
10037 type = TRANSITION;
10038 timeout = transitionTimeout;
10039 propCount = transitionDurations.length;
10040 }
10041 }
10042 else if (expectedType === ANIMATION) {
10043 if (animationTimeout > 0) {
10044 type = ANIMATION;
10045 timeout = animationTimeout;
10046 propCount = animationDurations.length;
10047 }
10048 }
10049 else {
10050 timeout = Math.max(transitionTimeout, animationTimeout);
10051 type =
10052 timeout > 0
10053 ? transitionTimeout > animationTimeout
10054 ? TRANSITION
10055 : ANIMATION
10056 : null;
10057 propCount = type
10058 ? type === TRANSITION
10059 ? transitionDurations.length
10060 : animationDurations.length
10061 : 0;
10062 }
10063 const hasTransform = type === TRANSITION &&
10064 /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
10065 return {
10066 type,
10067 timeout,
10068 propCount,
10069 hasTransform
10070 };
10071}
10072function getTimeout(delays, durations) {
10073 while (delays.length < durations.length) {
10074 delays = delays.concat(delays);
10075 }
10076 return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
10077}
10078// Old versions of Chromium (below 61.0.3163.100) formats floating pointer
10079// numbers in a locale-dependent way, using a comma instead of a dot.
10080// If comma is not replaced with a dot, the input will be rounded down
10081// (i.e. acting as a floor function) causing unexpected behaviors
10082function toMs(s) {
10083 return Number(s.slice(0, -1).replace(',', '.')) * 1000;
10084}
10085// synchronously force layout to put elements into a certain state
10086function forceReflow() {
10087 return document.body.offsetHeight;
10088}
10089
10090const positionMap = new WeakMap();
10091const newPositionMap = new WeakMap();
10092const TransitionGroupImpl = {
10093 name: 'TransitionGroup',
10094 props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
10095 tag: String,
10096 moveClass: String
10097 }),
10098 setup(props, { slots }) {
10099 const instance = getCurrentInstance();
10100 const state = useTransitionState();
10101 let prevChildren;
10102 let children;
10103 onUpdated(() => {
10104 // children is guaranteed to exist after initial render
10105 if (!prevChildren.length) {
10106 return;
10107 }
10108 const moveClass = props.moveClass || `${props.name || 'v'}-move`;
10109 if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
10110 return;
10111 }
10112 // we divide the work into three loops to avoid mixing DOM reads and writes
10113 // in each iteration - which helps prevent layout thrashing.
10114 prevChildren.forEach(callPendingCbs);
10115 prevChildren.forEach(recordPosition);
10116 const movedChildren = prevChildren.filter(applyTranslation);
10117 // force reflow to put everything in position
10118 forceReflow();
10119 movedChildren.forEach(c => {
10120 const el = c.el;
10121 const style = el.style;
10122 addTransitionClass(el, moveClass);
10123 style.transform = style.webkitTransform = style.transitionDuration = '';
10124 const cb = (el._moveCb = (e) => {
10125 if (e && e.target !== el) {
10126 return;
10127 }
10128 if (!e || /transform$/.test(e.propertyName)) {
10129 el.removeEventListener('transitionend', cb);
10130 el._moveCb = null;
10131 removeTransitionClass(el, moveClass);
10132 }
10133 });
10134 el.addEventListener('transitionend', cb);
10135 });
10136 });
10137 return () => {
10138 const rawProps = toRaw(props);
10139 const cssTransitionProps = resolveTransitionProps(rawProps);
10140 let tag = rawProps.tag || Fragment;
10141 prevChildren = children;
10142 children = slots.default ? getTransitionRawChildren(slots.default()) : [];
10143 for (let i = 0; i < children.length; i++) {
10144 const child = children[i];
10145 if (child.key != null) {
10146 setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
10147 }
10148 else {
10149 warn$1(`<TransitionGroup> children must be keyed.`);
10150 }
10151 }
10152 if (prevChildren) {
10153 for (let i = 0; i < prevChildren.length; i++) {
10154 const child = prevChildren[i];
10155 setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
10156 positionMap.set(child, child.el.getBoundingClientRect());
10157 }
10158 }
10159 return createVNode(tag, null, children);
10160 };
10161 }
10162};
10163const TransitionGroup = TransitionGroupImpl;
10164function callPendingCbs(c) {
10165 const el = c.el;
10166 if (el._moveCb) {
10167 el._moveCb();
10168 }
10169 if (el._enterCb) {
10170 el._enterCb();
10171 }
10172}
10173function recordPosition(c) {
10174 newPositionMap.set(c, c.el.getBoundingClientRect());
10175}
10176function applyTranslation(c) {
10177 const oldPos = positionMap.get(c);
10178 const newPos = newPositionMap.get(c);
10179 const dx = oldPos.left - newPos.left;
10180 const dy = oldPos.top - newPos.top;
10181 if (dx || dy) {
10182 const s = c.el.style;
10183 s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
10184 s.transitionDuration = '0s';
10185 return c;
10186 }
10187}
10188function hasCSSTransform(el, root, moveClass) {
10189 // Detect whether an element with the move class applied has
10190 // CSS transitions. Since the element may be inside an entering
10191 // transition at this very moment, we make a clone of it and remove
10192 // all other transition classes applied to ensure only the move class
10193 // is applied.
10194 const clone = el.cloneNode();
10195 if (el._vtc) {
10196 el._vtc.forEach(cls => {
10197 cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
10198 });
10199 }
10200 moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
10201 clone.style.display = 'none';
10202 const container = (root.nodeType === 1 ? root : root.parentNode);
10203 container.appendChild(clone);
10204 const { hasTransform } = getTransitionInfo(clone);
10205 container.removeChild(clone);
10206 return hasTransform;
10207}
10208
10209const getModelAssigner = (vnode) => {
10210 const fn = vnode.props['onUpdate:modelValue'];
10211 return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
10212};
10213function onCompositionStart(e) {
10214 e.target.composing = true;
10215}
10216function onCompositionEnd(e) {
10217 const target = e.target;
10218 if (target.composing) {
10219 target.composing = false;
10220 trigger$1(target, 'input');
10221 }
10222}
10223function trigger$1(el, type) {
10224 const e = document.createEvent('HTMLEvents');
10225 e.initEvent(type, true, true);
10226 el.dispatchEvent(e);
10227}
10228// We are exporting the v-model runtime directly as vnode hooks so that it can
10229// be tree-shaken in case v-model is never used.
10230const vModelText = {
10231 created(el, { modifiers: { lazy, trim, number } }, vnode) {
10232 el._assign = getModelAssigner(vnode);
10233 const castToNumber = number || (vnode.props && vnode.props.type === 'number');
10234 addEventListener(el, lazy ? 'change' : 'input', e => {
10235 if (e.target.composing)
10236 return;
10237 let domValue = el.value;
10238 if (trim) {
10239 domValue = domValue.trim();
10240 }
10241 else if (castToNumber) {
10242 domValue = toNumber(domValue);
10243 }
10244 el._assign(domValue);
10245 });
10246 if (trim) {
10247 addEventListener(el, 'change', () => {
10248 el.value = el.value.trim();
10249 });
10250 }
10251 if (!lazy) {
10252 addEventListener(el, 'compositionstart', onCompositionStart);
10253 addEventListener(el, 'compositionend', onCompositionEnd);
10254 // Safari < 10.2 & UIWebView doesn't fire compositionend when
10255 // switching focus before confirming composition choice
10256 // this also fixes the issue where some browsers e.g. iOS Chrome
10257 // fires "change" instead of "input" on autocomplete.
10258 addEventListener(el, 'change', onCompositionEnd);
10259 }
10260 },
10261 // set value on mounted so it's after min/max for type="range"
10262 mounted(el, { value }) {
10263 el.value = value == null ? '' : value;
10264 },
10265 beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
10266 el._assign = getModelAssigner(vnode);
10267 // avoid clearing unresolved text. #2302
10268 if (el.composing)
10269 return;
10270 if (document.activeElement === el) {
10271 if (lazy) {
10272 return;
10273 }
10274 if (trim && el.value.trim() === value) {
10275 return;
10276 }
10277 if ((number || el.type === 'number') && toNumber(el.value) === value) {
10278 return;
10279 }
10280 }
10281 const newValue = value == null ? '' : value;
10282 if (el.value !== newValue) {
10283 el.value = newValue;
10284 }
10285 }
10286};
10287const vModelCheckbox = {
10288 // #4096 array checkboxes need to be deep traversed
10289 deep: true,
10290 created(el, _, vnode) {
10291 el._assign = getModelAssigner(vnode);
10292 addEventListener(el, 'change', () => {
10293 const modelValue = el._modelValue;
10294 const elementValue = getValue(el);
10295 const checked = el.checked;
10296 const assign = el._assign;
10297 if (isArray(modelValue)) {
10298 const index = looseIndexOf(modelValue, elementValue);
10299 const found = index !== -1;
10300 if (checked && !found) {
10301 assign(modelValue.concat(elementValue));
10302 }
10303 else if (!checked && found) {
10304 const filtered = [...modelValue];
10305 filtered.splice(index, 1);
10306 assign(filtered);
10307 }
10308 }
10309 else if (isSet(modelValue)) {
10310 const cloned = new Set(modelValue);
10311 if (checked) {
10312 cloned.add(elementValue);
10313 }
10314 else {
10315 cloned.delete(elementValue);
10316 }
10317 assign(cloned);
10318 }
10319 else {
10320 assign(getCheckboxValue(el, checked));
10321 }
10322 });
10323 },
10324 // set initial checked on mount to wait for true-value/false-value
10325 mounted: setChecked,
10326 beforeUpdate(el, binding, vnode) {
10327 el._assign = getModelAssigner(vnode);
10328 setChecked(el, binding, vnode);
10329 }
10330};
10331function setChecked(el, { value, oldValue }, vnode) {
10332 el._modelValue = value;
10333 if (isArray(value)) {
10334 el.checked = looseIndexOf(value, vnode.props.value) > -1;
10335 }
10336 else if (isSet(value)) {
10337 el.checked = value.has(vnode.props.value);
10338 }
10339 else if (value !== oldValue) {
10340 el.checked = looseEqual(value, getCheckboxValue(el, true));
10341 }
10342}
10343const vModelRadio = {
10344 created(el, { value }, vnode) {
10345 el.checked = looseEqual(value, vnode.props.value);
10346 el._assign = getModelAssigner(vnode);
10347 addEventListener(el, 'change', () => {
10348 el._assign(getValue(el));
10349 });
10350 },
10351 beforeUpdate(el, { value, oldValue }, vnode) {
10352 el._assign = getModelAssigner(vnode);
10353 if (value !== oldValue) {
10354 el.checked = looseEqual(value, vnode.props.value);
10355 }
10356 }
10357};
10358const vModelSelect = {
10359 // <select multiple> value need to be deep traversed
10360 deep: true,
10361 created(el, { value, modifiers: { number } }, vnode) {
10362 const isSetModel = isSet(value);
10363 addEventListener(el, 'change', () => {
10364 const selectedVal = Array.prototype.filter
10365 .call(el.options, (o) => o.selected)
10366 .map((o) => number ? toNumber(getValue(o)) : getValue(o));
10367 el._assign(el.multiple
10368 ? isSetModel
10369 ? new Set(selectedVal)
10370 : selectedVal
10371 : selectedVal[0]);
10372 });
10373 el._assign = getModelAssigner(vnode);
10374 },
10375 // set value in mounted & updated because <select> relies on its children
10376 // <option>s.
10377 mounted(el, { value }) {
10378 setSelected(el, value);
10379 },
10380 beforeUpdate(el, _binding, vnode) {
10381 el._assign = getModelAssigner(vnode);
10382 },
10383 updated(el, { value }) {
10384 setSelected(el, value);
10385 }
10386};
10387function setSelected(el, value) {
10388 const isMultiple = el.multiple;
10389 if (isMultiple && !isArray(value) && !isSet(value)) {
10390 warn$1(`<select multiple v-model> expects an Array or Set value for its binding, ` +
10391 `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
10392 return;
10393 }
10394 for (let i = 0, l = el.options.length; i < l; i++) {
10395 const option = el.options[i];
10396 const optionValue = getValue(option);
10397 if (isMultiple) {
10398 if (isArray(value)) {
10399 option.selected = looseIndexOf(value, optionValue) > -1;
10400 }
10401 else {
10402 option.selected = value.has(optionValue);
10403 }
10404 }
10405 else {
10406 if (looseEqual(getValue(option), value)) {
10407 if (el.selectedIndex !== i)
10408 el.selectedIndex = i;
10409 return;
10410 }
10411 }
10412 }
10413 if (!isMultiple && el.selectedIndex !== -1) {
10414 el.selectedIndex = -1;
10415 }
10416}
10417// retrieve raw value set via :value bindings
10418function getValue(el) {
10419 return '_value' in el ? el._value : el.value;
10420}
10421// retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
10422function getCheckboxValue(el, checked) {
10423 const key = checked ? '_trueValue' : '_falseValue';
10424 return key in el ? el[key] : checked;
10425}
10426const vModelDynamic = {
10427 created(el, binding, vnode) {
10428 callModelHook(el, binding, vnode, null, 'created');
10429 },
10430 mounted(el, binding, vnode) {
10431 callModelHook(el, binding, vnode, null, 'mounted');
10432 },
10433 beforeUpdate(el, binding, vnode, prevVNode) {
10434 callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
10435 },
10436 updated(el, binding, vnode, prevVNode) {
10437 callModelHook(el, binding, vnode, prevVNode, 'updated');
10438 }
10439};
10440function callModelHook(el, binding, vnode, prevVNode, hook) {
10441 let modelToUse;
10442 switch (el.tagName) {
10443 case 'SELECT':
10444 modelToUse = vModelSelect;
10445 break;
10446 case 'TEXTAREA':
10447 modelToUse = vModelText;
10448 break;
10449 default:
10450 switch (vnode.props && vnode.props.type) {
10451 case 'checkbox':
10452 modelToUse = vModelCheckbox;
10453 break;
10454 case 'radio':
10455 modelToUse = vModelRadio;
10456 break;
10457 default:
10458 modelToUse = vModelText;
10459 }
10460 }
10461 const fn = modelToUse[hook];
10462 fn && fn(el, binding, vnode, prevVNode);
10463}
10464
10465const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
10466const modifierGuards = {
10467 stop: e => e.stopPropagation(),
10468 prevent: e => e.preventDefault(),
10469 self: e => e.target !== e.currentTarget,
10470 ctrl: e => !e.ctrlKey,
10471 shift: e => !e.shiftKey,
10472 alt: e => !e.altKey,
10473 meta: e => !e.metaKey,
10474 left: e => 'button' in e && e.button !== 0,
10475 middle: e => 'button' in e && e.button !== 1,
10476 right: e => 'button' in e && e.button !== 2,
10477 exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
10478};
10479/**
10480 * @private
10481 */
10482const withModifiers = (fn, modifiers) => {
10483 return (event, ...args) => {
10484 for (let i = 0; i < modifiers.length; i++) {
10485 const guard = modifierGuards[modifiers[i]];
10486 if (guard && guard(event, modifiers))
10487 return;
10488 }
10489 return fn(event, ...args);
10490 };
10491};
10492// Kept for 2.x compat.
10493// Note: IE11 compat for `spacebar` and `del` is removed for now.
10494const keyNames = {
10495 esc: 'escape',
10496 space: ' ',
10497 up: 'arrow-up',
10498 left: 'arrow-left',
10499 right: 'arrow-right',
10500 down: 'arrow-down',
10501 delete: 'backspace'
10502};
10503/**
10504 * @private
10505 */
10506const withKeys = (fn, modifiers) => {
10507 return (event) => {
10508 if (!('key' in event)) {
10509 return;
10510 }
10511 const eventKey = hyphenate(event.key);
10512 if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
10513 return fn(event);
10514 }
10515 };
10516};
10517
10518const vShow = {
10519 beforeMount(el, { value }, { transition }) {
10520 el._vod = el.style.display === 'none' ? '' : el.style.display;
10521 if (transition && value) {
10522 transition.beforeEnter(el);
10523 }
10524 else {
10525 setDisplay(el, value);
10526 }
10527 },
10528 mounted(el, { value }, { transition }) {
10529 if (transition && value) {
10530 transition.enter(el);
10531 }
10532 },
10533 updated(el, { value, oldValue }, { transition }) {
10534 if (!value === !oldValue)
10535 return;
10536 if (transition) {
10537 if (value) {
10538 transition.beforeEnter(el);
10539 setDisplay(el, true);
10540 transition.enter(el);
10541 }
10542 else {
10543 transition.leave(el, () => {
10544 setDisplay(el, false);
10545 });
10546 }
10547 }
10548 else {
10549 setDisplay(el, value);
10550 }
10551 },
10552 beforeUnmount(el, { value }) {
10553 setDisplay(el, value);
10554 }
10555};
10556function setDisplay(el, value) {
10557 el.style.display = value ? el._vod : 'none';
10558}
10559
10560const rendererOptions = extend({ patchProp }, nodeOps);
10561// lazy create the renderer - this makes core renderer logic tree-shakable
10562// in case the user only imports reactivity utilities from Vue.
10563let renderer;
10564let enabledHydration = false;
10565function ensureRenderer() {
10566 return (renderer ||
10567 (renderer = createRenderer(rendererOptions)));
10568}
10569function ensureHydrationRenderer() {
10570 renderer = enabledHydration
10571 ? renderer
10572 : createHydrationRenderer(rendererOptions);
10573 enabledHydration = true;
10574 return renderer;
10575}
10576// use explicit type casts here to avoid import() calls in rolled-up d.ts
10577const render = ((...args) => {
10578 ensureRenderer().render(...args);
10579});
10580const hydrate = ((...args) => {
10581 ensureHydrationRenderer().hydrate(...args);
10582});
10583const createApp = ((...args) => {
10584 const app = ensureRenderer().createApp(...args);
10585 {
10586 injectNativeTagCheck(app);
10587 injectCompilerOptionsCheck(app);
10588 }
10589 const { mount } = app;
10590 app.mount = (containerOrSelector) => {
10591 const container = normalizeContainer(containerOrSelector);
10592 if (!container)
10593 return;
10594 const component = app._component;
10595 if (!isFunction(component) && !component.render && !component.template) {
10596 // __UNSAFE__
10597 // Reason: potential execution of JS expressions in in-DOM template.
10598 // The user must make sure the in-DOM template is trusted. If it's
10599 // rendered by the server, the template should not contain any user data.
10600 component.template = container.innerHTML;
10601 }
10602 // clear content before mounting
10603 container.innerHTML = '';
10604 const proxy = mount(container, false, container instanceof SVGElement);
10605 if (container instanceof Element) {
10606 container.removeAttribute('v-cloak');
10607 container.setAttribute('data-v-app', '');
10608 }
10609 return proxy;
10610 };
10611 return app;
10612});
10613const createSSRApp = ((...args) => {
10614 const app = ensureHydrationRenderer().createApp(...args);
10615 {
10616 injectNativeTagCheck(app);
10617 injectCompilerOptionsCheck(app);
10618 }
10619 const { mount } = app;
10620 app.mount = (containerOrSelector) => {
10621 const container = normalizeContainer(containerOrSelector);
10622 if (container) {
10623 return mount(container, true, container instanceof SVGElement);
10624 }
10625 };
10626 return app;
10627});
10628function injectNativeTagCheck(app) {
10629 // Inject `isNativeTag`
10630 // this is used for component name validation (dev only)
10631 Object.defineProperty(app.config, 'isNativeTag', {
10632 value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
10633 writable: false
10634 });
10635}
10636// dev only
10637function injectCompilerOptionsCheck(app) {
10638 if (isRuntimeOnly()) {
10639 const isCustomElement = app.config.isCustomElement;
10640 Object.defineProperty(app.config, 'isCustomElement', {
10641 get() {
10642 return isCustomElement;
10643 },
10644 set() {
10645 warn$1(`The \`isCustomElement\` config option is deprecated. Use ` +
10646 `\`compilerOptions.isCustomElement\` instead.`);
10647 }
10648 });
10649 const compilerOptions = app.config.compilerOptions;
10650 const msg = `The \`compilerOptions\` config option is only respected when using ` +
10651 `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
10652 `Since you are using the runtime-only build, \`compilerOptions\` ` +
10653 `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
10654 `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
10655 `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
10656 `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
10657 Object.defineProperty(app.config, 'compilerOptions', {
10658 get() {
10659 warn$1(msg);
10660 return compilerOptions;
10661 },
10662 set() {
10663 warn$1(msg);
10664 }
10665 });
10666 }
10667}
10668function normalizeContainer(container) {
10669 if (isString(container)) {
10670 const res = document.querySelector(container);
10671 if (!res) {
10672 warn$1(`Failed to mount app: mount target selector "${container}" returned null.`);
10673 }
10674 return res;
10675 }
10676 if (window.ShadowRoot &&
10677 container instanceof window.ShadowRoot &&
10678 container.mode === 'closed') {
10679 warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
10680 }
10681 return container;
10682}
10683/**
10684 * @internal
10685 */
10686const initDirectivesForSSR = NOOP;
10687
10688function initDev() {
10689 {
10690 {
10691 console.info(`You are running a development build of Vue.\n` +
10692 `Make sure to use the production build (*.prod.js) when deploying for production.`);
10693 }
10694 initCustomFormatter();
10695 }
10696}
10697
10698// This entry exports the runtime only, and is built as
10699{
10700 initDev();
10701}
10702const compile$1 = () => {
10703 {
10704 warn$1(`Runtime compilation is not supported in this build of Vue.` +
10705 (` Use "vue.esm-browser.js" instead.`
10706 ) /* should not happen */);
10707 }
10708};
10709
10710export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compile$1 as compile, computed$1 as computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };