UNPKG

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