UNPKG

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