UNPKG

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