UNPKG

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