UNPKG

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