[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 /** 2 * Make a map and return a function for checking if a key 3 * is in that map. 4 * IMPORTANT: all calls of this function must be prefixed with 5 * \/\*#\_\_PURE\_\_\*\/ 6 * So that rollup can tree-shake them if necessary. 7 */ 8 function makeMap(str, expectsLowerCase) { 9 const map = Object.create(null); 10 const list = str.split(','); 11 12 for (let i = 0; i < list.length; i++) { 13 map[list[i]] = true; 14 } 15 16 return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; 17 } 18 /** 19 * On the client we only need to offer special cases for boolean attributes that 20 * have different names from their corresponding dom properties: 21 * - itemscope -> N/A 22 * - allowfullscreen -> allowFullscreen 23 * - formnovalidate -> formNoValidate 24 * - ismap -> isMap 25 * - nomodule -> noModule 26 * - novalidate -> noValidate 27 * - readonly -> readOnly 28 */ 29 30 31 const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; 32 const isSpecialBooleanAttr = /*#__PURE__*/makeMap(specialBooleanAttrs); 33 /** 34 * Boolean attributes should be included if the value is truthy or ''. 35 * e.g. `<select multiple>` compiles to `{ multiple: '' }` 36 */ 37 38 function includeBooleanAttr(value) { 39 return !!value || value === ''; 40 } 41 42 function normalizeStyle(value) { 43 if (isArray(value)) { 44 const res = {}; 45 46 for (let i = 0; i < value.length; i++) { 47 const item = value[i]; 48 const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item); 49 50 if (normalized) { 51 for (const key in normalized) { 52 res[key] = normalized[key]; 53 } 54 } 55 } 56 57 return res; 58 } else if (isString(value)) { 59 return value; 60 } else if (isObject$1(value)) { 61 return value; 62 } 63 } 64 65 const listDelimiterRE = /;(?![^(]*\))/g; 66 const propertyDelimiterRE = /:(.+)/; 67 68 function parseStringStyle(cssText) { 69 const ret = {}; 70 cssText.split(listDelimiterRE).forEach(item => { 71 if (item) { 72 const tmp = item.split(propertyDelimiterRE); 73 tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim()); 74 } 75 }); 76 return ret; 77 } 78 79 function normalizeClass(value) { 80 let res = ''; 81 82 if (isString(value)) { 83 res = value; 84 } else if (isArray(value)) { 85 for (let i = 0; i < value.length; i++) { 86 const normalized = normalizeClass(value[i]); 87 88 if (normalized) { 89 res += normalized + ' '; 90 } 91 } 92 } else if (isObject$1(value)) { 93 for (const name in value) { 94 if (value[name]) { 95 res += name + ' '; 96 } 97 } 98 } 99 100 return res.trim(); 101 } 102 /** 103 * For converting {{ interpolation }} values to displayed strings. 104 * @private 105 */ 106 107 108 const toDisplayString = val => { 109 return val == null ? '' : isArray(val) || isObject$1(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val); 110 }; 111 112 const replacer = (_key, val) => { 113 // can't use isRef here since @vue/shared has no deps 114 if (val && val.__v_isRef) { 115 return replacer(_key, val.value); 116 } else if (isMap(val)) { 117 return { 118 [`Map($val.size})`]: [...val.entries()].reduce((entries, _ref) => { 119 let [key, val] = _ref; 120 entries[`$key} =>`] = val; 121 return entries; 122 }, {}) 123 }; 124 } else if (isSet(val)) { 125 return { 126 [`Set($val.size})`]: [...val.values()] 127 }; 128 } else if (isObject$1(val) && !isArray(val) && !isPlainObject(val)) { 129 return String(val); 130 } 131 132 return val; 133 }; 134 135 const EMPTY_OBJ = {}; 136 const EMPTY_ARR = []; 137 138 const NOOP = () => {}; 139 /** 140 * Always return false. 141 */ 142 143 144 const NO = () => false; 145 146 const onRE = /^on[^a-z]/; 147 148 const isOn = key => onRE.test(key); 149 150 const isModelListener = key => key.startsWith('onUpdate:'); 151 152 const extend = Object.assign; 153 154 const remove = (arr, el) => { 155 const i = arr.indexOf(el); 156 157 if (i > -1) { 158 arr.splice(i, 1); 159 } 160 }; 161 162 const hasOwnProperty = Object.prototype.hasOwnProperty; 163 164 const hasOwn = (val, key) => hasOwnProperty.call(val, key); 165 166 const isArray = Array.isArray; 167 168 const isMap = val => toTypeString(val) === '[object Map]'; 169 170 const isSet = val => toTypeString(val) === '[object Set]'; 171 172 const isFunction = val => typeof val === 'function'; 173 174 const isString = val => typeof val === 'string'; 175 176 const isSymbol = val => typeof val === 'symbol'; 177 178 const isObject$1 = val => val !== null && typeof val === 'object'; 179 180 const isPromise$1 = val => { 181 return isObject$1(val) && isFunction(val.then) && isFunction(val.catch); 182 }; 183 184 const objectToString = Object.prototype.toString; 185 186 const toTypeString = value => objectToString.call(value); 187 188 const toRawType = value => { 189 // extract "RawType" from strings like "[object RawType]" 190 return toTypeString(value).slice(8, -1); 191 }; 192 193 const isPlainObject = val => toTypeString(val) === '[object Object]'; 194 195 const isIntegerKey = key => isString(key) && key !== 'NaN' && key[0] !== '-' && '' + parseInt(key, 10) === key; 196 197 const isReservedProp = /*#__PURE__*/makeMap( // the leading comma is intentional so empty string "" is also included 198 ',key,ref,ref_for,ref_key,' + 'onVnodeBeforeMount,onVnodeMounted,' + 'onVnodeBeforeUpdate,onVnodeUpdated,' + 'onVnodeBeforeUnmount,onVnodeUnmounted'); 199 200 const cacheStringFunction = fn => { 201 const cache = Object.create(null); 202 return str => { 203 const hit = cache[str]; 204 return hit || (cache[str] = fn(str)); 205 }; 206 }; 207 208 const camelizeRE = /-(\w)/g; 209 /** 210 * @private 211 */ 212 213 const camelize = cacheStringFunction(str => { 214 return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : ''); 215 }); 216 const hyphenateRE = /\B([A-Z])/g; 217 /** 218 * @private 219 */ 220 221 const hyphenate = cacheStringFunction(str => str.replace(hyphenateRE, '-$1').toLowerCase()); 222 /** 223 * @private 224 */ 225 226 const capitalize = cacheStringFunction(str => str.charAt(0).toUpperCase() + str.slice(1)); 227 /** 228 * @private 229 */ 230 231 const toHandlerKey = cacheStringFunction(str => str ? `on$capitalize(str)}` : ``); // compare whether a value has changed, accounting for NaN. 232 233 const hasChanged = (value, oldValue) => !Object.is(value, oldValue); 234 235 const invokeArrayFns = (fns, arg) => { 236 for (let i = 0; i < fns.length; i++) { 237 fns[i](arg); 238 } 239 }; 240 241 const def = (obj, key, value) => { 242 Object.defineProperty(obj, key, { 243 configurable: true, 244 enumerable: false, 245 value 246 }); 247 }; 248 249 const toNumber = val => { 250 const n = parseFloat(val); 251 return isNaN(n) ? val : n; 252 }; 253 254 let _globalThis; 255 256 const getGlobalThis = () => { 257 return _globalThis || (_globalThis = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {}); 258 }; 259 260 let activeEffectScope; 261 const effectScopeStack = []; 262 263 class EffectScope { 264 constructor(detached) { 265 if (detached === void 0) { 266 detached = false; 267 } 268 269 this.active = true; 270 this.effects = []; 271 this.cleanups = []; 272 273 if (!detached && activeEffectScope) { 274 this.parent = activeEffectScope; 275 this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1; 276 } 277 } 278 279 run(fn) { 280 if (this.active) { 281 try { 282 this.on(); 283 return fn(); 284 } finally { 285 this.off(); 286 } 287 } 288 } 289 290 on() { 291 if (this.active) { 292 effectScopeStack.push(this); 293 activeEffectScope = this; 294 } 295 } 296 297 off() { 298 if (this.active) { 299 effectScopeStack.pop(); 300 activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; 301 } 302 } 303 304 stop(fromParent) { 305 if (this.active) { 306 this.effects.forEach(e => e.stop()); 307 this.cleanups.forEach(cleanup => cleanup()); 308 309 if (this.scopes) { 310 this.scopes.forEach(e => e.stop(true)); 311 } // nested scope, dereference from parent to avoid memory leaks 312 313 314 if (this.parent && !fromParent) { 315 // optimized O(1) removal 316 const last = this.parent.scopes.pop(); 317 318 if (last && last !== this) { 319 this.parent.scopes[this.index] = last; 320 last.index = this.index; 321 } 322 } 323 324 this.active = false; 325 } 326 } 327 328 } 329 330 function recordEffectScope(effect, scope) { 331 scope = scope || activeEffectScope; 332 333 if (scope && scope.active) { 334 scope.effects.push(effect); 335 } 336 } 337 338 const createDep = effects => { 339 const dep = new Set(effects); 340 dep.w = 0; 341 dep.n = 0; 342 return dep; 343 }; 344 345 const wasTracked = dep => (dep.w & trackOpBit) > 0; 346 347 const newTracked = dep => (dep.n & trackOpBit) > 0; 348 349 const initDepMarkers = _ref => { 350 let { 351 deps 352 } = _ref; 353 354 if (deps.length) { 355 for (let i = 0; i < deps.length; i++) { 356 deps[i].w |= trackOpBit; // set was tracked 357 } 358 } 359 }; 360 361 const finalizeDepMarkers = effect => { 362 const { 363 deps 364 } = effect; 365 366 if (deps.length) { 367 let ptr = 0; 368 369 for (let i = 0; i < deps.length; i++) { 370 const dep = deps[i]; 371 372 if (wasTracked(dep) && !newTracked(dep)) { 373 dep.delete(effect); 374 } else { 375 deps[ptr++] = dep; 376 } // clear bits 377 378 379 dep.w &= ~trackOpBit; 380 dep.n &= ~trackOpBit; 381 } 382 383 deps.length = ptr; 384 } 385 }; 386 387 const targetMap = new WeakMap(); // The number of effects currently being tracked recursively. 388 389 let effectTrackDepth = 0; 390 let trackOpBit = 1; 391 /** 392 * The bitwise track markers support at most 30 levels of recursion. 393 * This value is chosen to enable modern JS engines to use a SMI on all platforms. 394 * When recursion depth is greater, fall back to using a full cleanup. 395 */ 396 397 const maxMarkerBits = 30; 398 const effectStack = []; 399 let activeEffect; 400 const ITERATE_KEY = Symbol(''); 401 const MAP_KEY_ITERATE_KEY = Symbol(''); 402 403 class ReactiveEffect { 404 constructor(fn, scheduler, scope) { 405 if (scheduler === void 0) { 406 scheduler = null; 407 } 408 409 this.fn = fn; 410 this.scheduler = scheduler; 411 this.active = true; 412 this.deps = []; 413 recordEffectScope(this, scope); 414 } 415 416 run() { 417 if (!this.active) { 418 return this.fn(); 419 } 420 421 if (!effectStack.includes(this)) { 422 try { 423 effectStack.push(activeEffect = this); 424 enableTracking(); 425 trackOpBit = 1 << ++effectTrackDepth; 426 427 if (effectTrackDepth <= maxMarkerBits) { 428 initDepMarkers(this); 429 } else { 430 cleanupEffect(this); 431 } 432 433 return this.fn(); 434 } finally { 435 if (effectTrackDepth <= maxMarkerBits) { 436 finalizeDepMarkers(this); 437 } 438 439 trackOpBit = 1 << --effectTrackDepth; 440 resetTracking(); 441 effectStack.pop(); 442 const n = effectStack.length; 443 activeEffect = n > 0 ? effectStack[n - 1] : undefined; 444 } 445 } 446 } 447 448 stop() { 449 if (this.active) { 450 cleanupEffect(this); 451 452 if (this.onStop) { 453 this.onStop(); 454 } 455 456 this.active = false; 457 } 458 } 459 460 } 461 462 function cleanupEffect(effect) { 463 const { 464 deps 465 } = effect; 466 467 if (deps.length) { 468 for (let i = 0; i < deps.length; i++) { 469 deps[i].delete(effect); 470 } 471 472 deps.length = 0; 473 } 474 } 475 476 let shouldTrack = true; 477 const trackStack = []; 478 479 function pauseTracking() { 480 trackStack.push(shouldTrack); 481 shouldTrack = false; 482 } 483 484 function enableTracking() { 485 trackStack.push(shouldTrack); 486 shouldTrack = true; 487 } 488 489 function resetTracking() { 490 const last = trackStack.pop(); 491 shouldTrack = last === undefined ? true : last; 492 } 493 494 function track(target, type, key) { 495 if (!isTracking()) { 496 return; 497 } 498 499 let depsMap = targetMap.get(target); 500 501 if (!depsMap) { 502 targetMap.set(target, depsMap = new Map()); 503 } 504 505 let dep = depsMap.get(key); 506 507 if (!dep) { 508 depsMap.set(key, dep = createDep()); 509 } 510 trackEffects(dep); 511 } 512 513 function isTracking() { 514 return shouldTrack && activeEffect !== undefined; 515 } 516 517 function trackEffects(dep, debuggerEventExtraInfo) { 518 let shouldTrack = false; 519 520 if (effectTrackDepth <= maxMarkerBits) { 521 if (!newTracked(dep)) { 522 dep.n |= trackOpBit; // set newly tracked 523 524 shouldTrack = !wasTracked(dep); 525 } 526 } else { 527 // Full cleanup mode. 528 shouldTrack = !dep.has(activeEffect); 529 } 530 531 if (shouldTrack) { 532 dep.add(activeEffect); 533 activeEffect.deps.push(dep); 534 } 535 } 536 537 function trigger$1(target, type, key, newValue, oldValue, oldTarget) { 538 const depsMap = targetMap.get(target); 539 540 if (!depsMap) { 541 // never been tracked 542 return; 543 } 544 545 let deps = []; 546 547 if (type === "clear" 548 /* CLEAR */ 549 ) { 550 // collection being cleared 551 // trigger all effects for target 552 deps = [...depsMap.values()]; 553 } else if (key === 'length' && isArray(target)) { 554 depsMap.forEach((dep, key) => { 555 if (key === 'length' || key >= newValue) { 556 deps.push(dep); 557 } 558 }); 559 } else { 560 // schedule runs for SET | ADD | DELETE 561 if (key !== void 0) { 562 deps.push(depsMap.get(key)); 563 } // also run for iteration key on ADD | DELETE | Map.SET 564 565 566 switch (type) { 567 case "add" 568 /* ADD */ 569 : 570 if (!isArray(target)) { 571 deps.push(depsMap.get(ITERATE_KEY)); 572 573 if (isMap(target)) { 574 deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); 575 } 576 } else if (isIntegerKey(key)) { 577 // new index added to array -> length changes 578 deps.push(depsMap.get('length')); 579 } 580 581 break; 582 583 case "delete" 584 /* DELETE */ 585 : 586 if (!isArray(target)) { 587 deps.push(depsMap.get(ITERATE_KEY)); 588 589 if (isMap(target)) { 590 deps.push(depsMap.get(MAP_KEY_ITERATE_KEY)); 591 } 592 } 593 594 break; 595 596 case "set" 597 /* SET */ 598 : 599 if (isMap(target)) { 600 deps.push(depsMap.get(ITERATE_KEY)); 601 } 602 603 break; 604 } 605 } 606 607 if (deps.length === 1) { 608 if (deps[0]) { 609 { 610 triggerEffects(deps[0]); 611 } 612 } 613 } else { 614 const effects = []; 615 616 for (const dep of deps) { 617 if (dep) { 618 effects.push(...dep); 619 } 620 } 621 622 { 623 triggerEffects(createDep(effects)); 624 } 625 } 626 } 627 628 function triggerEffects(dep, debuggerEventExtraInfo) { 629 // spread into array for stabilization 630 for (const effect of isArray(dep) ? dep : [...dep]) { 631 if (effect !== activeEffect || effect.allowRecurse) { 632 633 if (effect.scheduler) { 634 effect.scheduler(); 635 } else { 636 effect.run(); 637 } 638 } 639 } 640 } 641 642 const isNonTrackableKeys = /*#__PURE__*/makeMap(`__proto__,__v_isRef,__isVue`); 643 const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map(key => Symbol[key]).filter(isSymbol)); 644 const get = /*#__PURE__*/createGetter(); 645 const shallowGet = /*#__PURE__*/createGetter(false, true); 646 const readonlyGet = /*#__PURE__*/createGetter(true); 647 const arrayInstrumentations = /*#__PURE__*/createArrayInstrumentations(); 648 649 function createArrayInstrumentations() { 650 const instrumentations = {}; 651 ['includes', 'indexOf', 'lastIndexOf'].forEach(key => { 652 instrumentations[key] = function () { 653 const arr = toRaw(this); 654 655 for (let i = 0, l = this.length; i < l; i++) { 656 track(arr, "get" 657 /* GET */ 658 , i + ''); 659 } // we run the method using the original args first (which may be reactive) 660 661 662 for (var _len2 = arguments.length, args = new Array(_len2), _key3 = 0; _key3 < _len2; _key3++) { 663 args[_key3] = arguments[_key3]; 664 } 665 666 const res = arr[key](...args); 667 668 if (res === -1 || res === false) { 669 // if that didn't work, run it again using raw values. 670 return arr[key](...args.map(toRaw)); 671 } else { 672 return res; 673 } 674 }; 675 }); 676 ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(key => { 677 instrumentations[key] = function () { 678 pauseTracking(); 679 680 for (var _len3 = arguments.length, args = new Array(_len3), _key4 = 0; _key4 < _len3; _key4++) { 681 args[_key4] = arguments[_key4]; 682 } 683 684 const res = toRaw(this)[key].apply(this, args); 685 resetTracking(); 686 return res; 687 }; 688 }); 689 return instrumentations; 690 } 691 692 function createGetter(isReadonly, shallow) { 693 if (isReadonly === void 0) { 694 isReadonly = false; 695 } 696 697 if (shallow === void 0) { 698 shallow = false; 699 } 700 701 return function get(target, key, receiver) { 702 if (key === "__v_isReactive" 703 /* IS_REACTIVE */ 704 ) { 705 return !isReadonly; 706 } else if (key === "__v_isReadonly" 707 /* IS_READONLY */ 708 ) { 709 return isReadonly; 710 } else if (key === "__v_raw" 711 /* RAW */ 712 && receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { 713 return target; 714 } 715 716 const targetIsArray = isArray(target); 717 718 if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) { 719 return Reflect.get(arrayInstrumentations, key, receiver); 720 } 721 722 const res = Reflect.get(target, key, receiver); 723 724 if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { 725 return res; 726 } 727 728 if (!isReadonly) { 729 track(target, "get" 730 /* GET */ 731 , key); 732 } 733 734 if (shallow) { 735 return res; 736 } 737 738 if (isRef(res)) { 739 // ref unwrapping - does not apply for Array + integer key. 740 const shouldUnwrap = !targetIsArray || !isIntegerKey(key); 741 return shouldUnwrap ? res.value : res; 742 } 743 744 if (isObject$1(res)) { 745 // Convert returned value into a proxy as well. we do the isObject check 746 // here to avoid invalid value warning. Also need to lazy access readonly 747 // and reactive here to avoid circular dependency. 748 return isReadonly ? readonly(res) : reactive(res); 749 } 750 751 return res; 752 }; 753 } 754 755 const set = /*#__PURE__*/createSetter(); 756 const shallowSet = /*#__PURE__*/createSetter(true); 757 758 function createSetter(shallow) { 759 if (shallow === void 0) { 760 shallow = false; 761 } 762 763 return function set(target, key, value, receiver) { 764 let oldValue = target[key]; 765 766 if (!shallow && !isReadonly(value)) { 767 value = toRaw(value); 768 oldValue = toRaw(oldValue); 769 770 if (!isArray(target) && isRef(oldValue) && !isRef(value)) { 771 oldValue.value = value; 772 return true; 773 } 774 } 775 776 const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); 777 const result = Reflect.set(target, key, value, receiver); // don't trigger if target is something up in the prototype chain of original 778 779 if (target === toRaw(receiver)) { 780 if (!hadKey) { 781 trigger$1(target, "add" 782 /* ADD */ 783 , key, value); 784 } else if (hasChanged(value, oldValue)) { 785 trigger$1(target, "set" 786 /* SET */ 787 , key, value); 788 } 789 } 790 791 return result; 792 }; 793 } 794 795 function deleteProperty(target, key) { 796 const hadKey = hasOwn(target, key); 797 target[key]; 798 const result = Reflect.deleteProperty(target, key); 799 800 if (result && hadKey) { 801 trigger$1(target, "delete" 802 /* DELETE */ 803 , key, undefined); 804 } 805 806 return result; 807 } 808 809 function has(target, key) { 810 const result = Reflect.has(target, key); 811 812 if (!isSymbol(key) || !builtInSymbols.has(key)) { 813 track(target, "has" 814 /* HAS */ 815 , key); 816 } 817 818 return result; 819 } 820 821 function ownKeys(target) { 822 track(target, "iterate" 823 /* ITERATE */ 824 , isArray(target) ? 'length' : ITERATE_KEY); 825 return Reflect.ownKeys(target); 826 } 827 828 const mutableHandlers = { 829 get, 830 set, 831 deleteProperty, 832 has, 833 ownKeys 834 }; 835 const readonlyHandlers = { 836 get: readonlyGet, 837 838 set(target, key) { 839 840 return true; 841 }, 842 843 deleteProperty(target, key) { 844 845 return true; 846 } 847 848 }; 849 const shallowReactiveHandlers = /*#__PURE__*/extend({}, mutableHandlers, { 850 get: shallowGet, 851 set: shallowSet 852 }); // Props handlers are special in the sense that it should not unwrap top-level 853 854 const toShallow = value => value; 855 856 const getProto = v => Reflect.getPrototypeOf(v); 857 858 function get$1(target, key, isReadonly, isShallow) { 859 if (isReadonly === void 0) { 860 isReadonly = false; 861 } 862 863 if (isShallow === void 0) { 864 isShallow = false; 865 } 866 867 // #1772: readonly(reactive(Map)) should return readonly + reactive version 868 // of the value 869 target = target["__v_raw" 870 /* RAW */ 871 ]; 872 const rawTarget = toRaw(target); 873 const rawKey = toRaw(key); 874 875 if (key !== rawKey) { 876 !isReadonly && track(rawTarget, "get" 877 /* GET */ 878 , key); 879 } 880 881 !isReadonly && track(rawTarget, "get" 882 /* GET */ 883 , rawKey); 884 const { 885 has 886 } = getProto(rawTarget); 887 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 888 889 if (has.call(rawTarget, key)) { 890 return wrap(target.get(key)); 891 } else if (has.call(rawTarget, rawKey)) { 892 return wrap(target.get(rawKey)); 893 } else if (target !== rawTarget) { 894 // #3602 readonly(reactive(Map)) 895 // ensure that the nested reactive `Map` can do tracking for itself 896 target.get(key); 897 } 898 } 899 900 function has$1(key, isReadonly) { 901 if (isReadonly === void 0) { 902 isReadonly = false; 903 } 904 905 const target = this["__v_raw" 906 /* RAW */ 907 ]; 908 const rawTarget = toRaw(target); 909 const rawKey = toRaw(key); 910 911 if (key !== rawKey) { 912 !isReadonly && track(rawTarget, "has" 913 /* HAS */ 914 , key); 915 } 916 917 !isReadonly && track(rawTarget, "has" 918 /* HAS */ 919 , rawKey); 920 return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); 921 } 922 923 function size(target, isReadonly) { 924 if (isReadonly === void 0) { 925 isReadonly = false; 926 } 927 928 target = target["__v_raw" 929 /* RAW */ 930 ]; 931 !isReadonly && track(toRaw(target), "iterate" 932 /* ITERATE */ 933 , ITERATE_KEY); 934 return Reflect.get(target, 'size', target); 935 } 936 937 function add(value) { 938 value = toRaw(value); 939 const target = toRaw(this); 940 const proto = getProto(target); 941 const hadKey = proto.has.call(target, value); 942 943 if (!hadKey) { 944 target.add(value); 945 trigger$1(target, "add" 946 /* ADD */ 947 , value, value); 948 } 949 950 return this; 951 } 952 953 function set$1(key, value) { 954 value = toRaw(value); 955 const target = toRaw(this); 956 const { 957 has, 958 get 959 } = getProto(target); 960 let hadKey = has.call(target, key); 961 962 if (!hadKey) { 963 key = toRaw(key); 964 hadKey = has.call(target, key); 965 } 966 967 const oldValue = get.call(target, key); 968 target.set(key, value); 969 970 if (!hadKey) { 971 trigger$1(target, "add" 972 /* ADD */ 973 , key, value); 974 } else if (hasChanged(value, oldValue)) { 975 trigger$1(target, "set" 976 /* SET */ 977 , key, value); 978 } 979 980 return this; 981 } 982 983 function deleteEntry(key) { 984 const target = toRaw(this); 985 const { 986 has, 987 get 988 } = getProto(target); 989 let hadKey = has.call(target, key); 990 991 if (!hadKey) { 992 key = toRaw(key); 993 hadKey = has.call(target, key); 994 } 995 996 get ? get.call(target, key) : undefined; // forward the operation before queueing reactions 997 998 const result = target.delete(key); 999 1000 if (hadKey) { 1001 trigger$1(target, "delete" 1002 /* DELETE */ 1003 , key, undefined); 1004 } 1005 1006 return result; 1007 } 1008 1009 function clear() { 1010 const target = toRaw(this); 1011 const hadItems = target.size !== 0; 1012 1013 const result = target.clear(); 1014 1015 if (hadItems) { 1016 trigger$1(target, "clear" 1017 /* CLEAR */ 1018 , undefined, undefined); 1019 } 1020 1021 return result; 1022 } 1023 1024 function createForEach(isReadonly, isShallow) { 1025 return function forEach(callback, thisArg) { 1026 const observed = this; 1027 const target = observed["__v_raw" 1028 /* RAW */ 1029 ]; 1030 const rawTarget = toRaw(target); 1031 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 1032 !isReadonly && track(rawTarget, "iterate" 1033 /* ITERATE */ 1034 , ITERATE_KEY); 1035 return target.forEach((value, key) => { 1036 // important: make sure the callback is 1037 // 1. invoked with the reactive map as `this` and 3rd arg 1038 // 2. the value received should be a corresponding reactive/readonly. 1039 return callback.call(thisArg, wrap(value), wrap(key), observed); 1040 }); 1041 }; 1042 } 1043 1044 function createIterableMethod(method, isReadonly, isShallow) { 1045 return function () { 1046 const target = this["__v_raw" 1047 /* RAW */ 1048 ]; 1049 const rawTarget = toRaw(target); 1050 const targetIsMap = isMap(rawTarget); 1051 const isPair = method === 'entries' || method === Symbol.iterator && targetIsMap; 1052 const isKeyOnly = method === 'keys' && targetIsMap; 1053 const innerIterator = target[method](...arguments); 1054 const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; 1055 !isReadonly && track(rawTarget, "iterate" 1056 /* ITERATE */ 1057 , isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); // return a wrapped iterator which returns observed versions of the 1058 // values emitted from the real iterator 1059 1060 return { 1061 // iterator protocol 1062 next() { 1063 const { 1064 value, 1065 done 1066 } = innerIterator.next(); 1067 return done ? { 1068 value, 1069 done 1070 } : { 1071 value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), 1072 done 1073 }; 1074 }, 1075 1076 // iterable protocol 1077 [Symbol.iterator]() { 1078 return this; 1079 } 1080 1081 }; 1082 }; 1083 } 1084 1085 function createReadonlyMethod(type) { 1086 return function () { 1087 1088 return type === "delete" 1089 /* DELETE */ 1090 ? false : this; 1091 }; 1092 } 1093 1094 function createInstrumentations() { 1095 const mutableInstrumentations = { 1096 get(key) { 1097 return get$1(this, key); 1098 }, 1099 1100 get size() { 1101 return size(this); 1102 }, 1103 1104 has: has$1, 1105 add, 1106 set: set$1, 1107 delete: deleteEntry, 1108 clear, 1109 forEach: createForEach(false, false) 1110 }; 1111 const shallowInstrumentations = { 1112 get(key) { 1113 return get$1(this, key, false, true); 1114 }, 1115 1116 get size() { 1117 return size(this); 1118 }, 1119 1120 has: has$1, 1121 add, 1122 set: set$1, 1123 delete: deleteEntry, 1124 clear, 1125 forEach: createForEach(false, true) 1126 }; 1127 const readonlyInstrumentations = { 1128 get(key) { 1129 return get$1(this, key, true); 1130 }, 1131 1132 get size() { 1133 return size(this, true); 1134 }, 1135 1136 has(key) { 1137 return has$1.call(this, key, true); 1138 }, 1139 1140 add: createReadonlyMethod("add" 1141 /* ADD */ 1142 ), 1143 set: createReadonlyMethod("set" 1144 /* SET */ 1145 ), 1146 delete: createReadonlyMethod("delete" 1147 /* DELETE */ 1148 ), 1149 clear: createReadonlyMethod("clear" 1150 /* CLEAR */ 1151 ), 1152 forEach: createForEach(true, false) 1153 }; 1154 const shallowReadonlyInstrumentations = { 1155 get(key) { 1156 return get$1(this, key, true, true); 1157 }, 1158 1159 get size() { 1160 return size(this, true); 1161 }, 1162 1163 has(key) { 1164 return has$1.call(this, key, true); 1165 }, 1166 1167 add: createReadonlyMethod("add" 1168 /* ADD */ 1169 ), 1170 set: createReadonlyMethod("set" 1171 /* SET */ 1172 ), 1173 delete: createReadonlyMethod("delete" 1174 /* DELETE */ 1175 ), 1176 clear: createReadonlyMethod("clear" 1177 /* CLEAR */ 1178 ), 1179 forEach: createForEach(true, true) 1180 }; 1181 const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; 1182 iteratorMethods.forEach(method => { 1183 mutableInstrumentations[method] = createIterableMethod(method, false, false); 1184 readonlyInstrumentations[method] = createIterableMethod(method, true, false); 1185 shallowInstrumentations[method] = createIterableMethod(method, false, true); 1186 shallowReadonlyInstrumentations[method] = createIterableMethod(method, true, true); 1187 }); 1188 return [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations]; 1189 } 1190 1191 const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* #__PURE__*/createInstrumentations(); 1192 1193 function createInstrumentationGetter(isReadonly, shallow) { 1194 const instrumentations = shallow ? isReadonly ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly ? readonlyInstrumentations : mutableInstrumentations; 1195 return (target, key, receiver) => { 1196 if (key === "__v_isReactive" 1197 /* IS_REACTIVE */ 1198 ) { 1199 return !isReadonly; 1200 } else if (key === "__v_isReadonly" 1201 /* IS_READONLY */ 1202 ) { 1203 return isReadonly; 1204 } else if (key === "__v_raw" 1205 /* RAW */ 1206 ) { 1207 return target; 1208 } 1209 1210 return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); 1211 }; 1212 } 1213 1214 const mutableCollectionHandlers = { 1215 get: /*#__PURE__*/createInstrumentationGetter(false, false) 1216 }; 1217 const shallowCollectionHandlers = { 1218 get: /*#__PURE__*/createInstrumentationGetter(false, true) 1219 }; 1220 const readonlyCollectionHandlers = { 1221 get: /*#__PURE__*/createInstrumentationGetter(true, false) 1222 }; 1223 1224 const reactiveMap = new WeakMap(); 1225 const shallowReactiveMap = new WeakMap(); 1226 const readonlyMap = new WeakMap(); 1227 const shallowReadonlyMap = new WeakMap(); 1228 1229 function targetTypeMap(rawType) { 1230 switch (rawType) { 1231 case 'Object': 1232 case 'Array': 1233 return 1 1234 /* COMMON */ 1235 ; 1236 1237 case 'Map': 1238 case 'Set': 1239 case 'WeakMap': 1240 case 'WeakSet': 1241 return 2 1242 /* COLLECTION */ 1243 ; 1244 1245 default: 1246 return 0 1247 /* INVALID */ 1248 ; 1249 } 1250 } 1251 1252 function getTargetType(value) { 1253 return value["__v_skip" 1254 /* SKIP */ 1255 ] || !Object.isExtensible(value) ? 0 1256 /* INVALID */ 1257 : targetTypeMap(toRawType(value)); 1258 } 1259 1260 function reactive(target) { 1261 // if trying to observe a readonly proxy, return the readonly version. 1262 if (target && target["__v_isReadonly" 1263 /* IS_READONLY */ 1264 ]) { 1265 return target; 1266 } 1267 1268 return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); 1269 } 1270 /** 1271 * Return a shallowly-reactive copy of the original object, where only the root 1272 * level properties are reactive. It also does not auto-unwrap refs (even at the 1273 * root level). 1274 */ 1275 1276 1277 function shallowReactive(target) { 1278 return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); 1279 } 1280 /** 1281 * Creates a readonly copy of the original object. Note the returned copy is not 1282 * made reactive, but `readonly` can be called on an already reactive object. 1283 */ 1284 1285 1286 function readonly(target) { 1287 return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); 1288 } 1289 1290 function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers, proxyMap) { 1291 if (!isObject$1(target)) { 1292 1293 return target; 1294 } // target is already a Proxy, return it. 1295 // exception: calling readonly() on a reactive object 1296 1297 1298 if (target["__v_raw" 1299 /* RAW */ 1300 ] && !(isReadonly && target["__v_isReactive" 1301 /* IS_REACTIVE */ 1302 ])) { 1303 return target; 1304 } // target already has corresponding Proxy 1305 1306 1307 const existingProxy = proxyMap.get(target); 1308 1309 if (existingProxy) { 1310 return existingProxy; 1311 } // only a whitelist of value types can be observed. 1312 1313 1314 const targetType = getTargetType(target); 1315 1316 if (targetType === 0 1317 /* INVALID */ 1318 ) { 1319 return target; 1320 } 1321 1322 const proxy = new Proxy(target, targetType === 2 1323 /* COLLECTION */ 1324 ? collectionHandlers : baseHandlers); 1325 proxyMap.set(target, proxy); 1326 return proxy; 1327 } 1328 1329 function isReactive(value) { 1330 if (isReadonly(value)) { 1331 return isReactive(value["__v_raw" 1332 /* RAW */ 1333 ]); 1334 } 1335 1336 return !!(value && value["__v_isReactive" 1337 /* IS_REACTIVE */ 1338 ]); 1339 } 1340 1341 function isReadonly(value) { 1342 return !!(value && value["__v_isReadonly" 1343 /* IS_READONLY */ 1344 ]); 1345 } 1346 1347 function isProxy(value) { 1348 return isReactive(value) || isReadonly(value); 1349 } 1350 1351 function toRaw(observed) { 1352 const raw = observed && observed["__v_raw" 1353 /* RAW */ 1354 ]; 1355 return raw ? toRaw(raw) : observed; 1356 } 1357 1358 function markRaw(value) { 1359 def(value, "__v_skip" 1360 /* SKIP */ 1361 , true); 1362 return value; 1363 } 1364 1365 const toReactive = value => isObject$1(value) ? reactive(value) : value; 1366 1367 const toReadonly = value => isObject$1(value) ? readonly(value) : value; 1368 1369 function trackRefValue(ref) { 1370 if (isTracking()) { 1371 ref = toRaw(ref); 1372 1373 if (!ref.dep) { 1374 ref.dep = createDep(); 1375 } 1376 1377 { 1378 trackEffects(ref.dep); 1379 } 1380 } 1381 } 1382 1383 function triggerRefValue(ref, newVal) { 1384 ref = toRaw(ref); 1385 1386 if (ref.dep) { 1387 { 1388 triggerEffects(ref.dep); 1389 } 1390 } 1391 } 1392 1393 function isRef(r) { 1394 return Boolean(r && r.__v_isRef === true); 1395 } 1396 1397 function unref(ref) { 1398 return isRef(ref) ? ref.value : ref; 1399 } 1400 1401 const shallowUnwrapHandlers = { 1402 get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)), 1403 set: (target, key, value, receiver) => { 1404 const oldValue = target[key]; 1405 1406 if (isRef(oldValue) && !isRef(value)) { 1407 oldValue.value = value; 1408 return true; 1409 } else { 1410 return Reflect.set(target, key, value, receiver); 1411 } 1412 } 1413 }; 1414 1415 function proxyRefs(objectWithRefs) { 1416 return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers); 1417 } 1418 1419 class ComputedRefImpl { 1420 constructor(getter, _setter, isReadonly) { 1421 this._setter = _setter; 1422 this.dep = undefined; 1423 this._dirty = true; 1424 this.__v_isRef = true; 1425 this.effect = new ReactiveEffect(getter, () => { 1426 if (!this._dirty) { 1427 this._dirty = true; 1428 triggerRefValue(this); 1429 } 1430 }); 1431 this["__v_isReadonly" 1432 /* IS_READONLY */ 1433 ] = isReadonly; 1434 } 1435 1436 get value() { 1437 // the computed ref may get wrapped by other proxies e.g. readonly() #3376 1438 const self = toRaw(this); 1439 trackRefValue(self); 1440 1441 if (self._dirty) { 1442 self._dirty = false; 1443 self._value = self.effect.run(); 1444 } 1445 1446 return self._value; 1447 } 1448 1449 set value(newValue) { 1450 this._setter(newValue); 1451 } 1452 1453 } 1454 1455 function computed(getterOrOptions, debugOptions) { 1456 let getter; 1457 let setter; 1458 const onlyGetter = isFunction(getterOrOptions); 1459 1460 if (onlyGetter) { 1461 getter = getterOrOptions; 1462 setter = NOOP; 1463 } else { 1464 getter = getterOrOptions.get; 1465 setter = getterOrOptions.set; 1466 } 1467 1468 const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter); 1469 1470 return cRef; 1471 } 1472 1473 Promise.resolve(); 1474 1475 let devtools; 1476 let buffer = []; 1477 let devtoolsNotInstalled = false; 1478 1479 function emit(event) { 1480 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 1481 args[_key - 1] = arguments[_key]; 1482 } 1483 1484 if (devtools) { 1485 devtools.emit(event, ...args); 1486 } else if (!devtoolsNotInstalled) { 1487 buffer.push({ 1488 event, 1489 args 1490 }); 1491 } 1492 } 1493 1494 function setDevtoolsHook(hook, target) { 1495 var _a, _b; 1496 1497 devtools = hook; 1498 1499 if (devtools) { 1500 devtools.enabled = true; 1501 buffer.forEach(_ref => { 1502 let { 1503 event, 1504 args 1505 } = _ref; 1506 return devtools.emit(event, ...args); 1507 }); 1508 buffer = []; 1509 } else if ( // handle late devtools injection - only do this if we are in an actual 1510 // browser environment to avoid the timer handle stalling test runner exit 1511 // (#4815) 1512 // eslint-disable-next-line no-restricted-globals 1513 typeof window !== 'undefined' && // some envs mock window but not fully 1514 window.HTMLElement && // also exclude jsdom 1515 !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) { 1516 const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []; 1517 replay.push(newHook => { 1518 setDevtoolsHook(newHook, target); 1519 }); // clear buffer after 3s - the user probably doesn't have devtools installed 1520 // at all, and keeping the buffer will cause memory leaks (#4738) 1521 1522 setTimeout(() => { 1523 if (!devtools) { 1524 target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null; 1525 devtoolsNotInstalled = true; 1526 buffer = []; 1527 } 1528 }, 3000); 1529 } else { 1530 // non-browser env, assume not installed 1531 devtoolsNotInstalled = true; 1532 buffer = []; 1533 } 1534 } 1535 1536 function devtoolsInitApp(app, version) { 1537 emit("app:init" 1538 /* APP_INIT */ 1539 , app, version, { 1540 Fragment, 1541 Text, 1542 Comment, 1543 Static 1544 }); 1545 } 1546 1547 function devtoolsUnmountApp(app) { 1548 emit("app:unmount" 1549 /* APP_UNMOUNT */ 1550 , app); 1551 } 1552 1553 const devtoolsComponentAdded = /*#__PURE__*/createDevtoolsComponentHook("component:added" 1554 /* COMPONENT_ADDED */ 1555 ); 1556 const devtoolsComponentUpdated = /*#__PURE__*/createDevtoolsComponentHook("component:updated" 1557 /* COMPONENT_UPDATED */ 1558 ); 1559 const devtoolsComponentRemoved = /*#__PURE__*/createDevtoolsComponentHook("component:removed" 1560 /* COMPONENT_REMOVED */ 1561 ); 1562 1563 function createDevtoolsComponentHook(hook) { 1564 return component => { 1565 emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component); 1566 }; 1567 } 1568 1569 function devtoolsComponentEmit(component, event, params) { 1570 emit("component:emit" 1571 /* COMPONENT_EMIT */ 1572 , component.appContext.app, component, event, params); 1573 } 1574 1575 function emit$1(instance, event) { 1576 const props = instance.vnode.props || EMPTY_OBJ; 1577 1578 for (var _len2 = arguments.length, rawArgs = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { 1579 rawArgs[_key2 - 2] = arguments[_key2]; 1580 } 1581 1582 let args = rawArgs; 1583 const isModelListener = event.startsWith('update:'); // for v-model update:xxx events, apply modifiers on args 1584 1585 const modelArg = isModelListener && event.slice(7); 1586 1587 if (modelArg && modelArg in props) { 1588 const modifiersKey = `$modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`; 1589 const { 1590 number, 1591 trim 1592 } = props[modifiersKey] || EMPTY_OBJ; 1593 1594 if (trim) { 1595 args = rawArgs.map(a => a.trim()); 1596 } else if (number) { 1597 args = rawArgs.map(toNumber); 1598 } 1599 } 1600 1601 if (__VUE_PROD_DEVTOOLS__) { 1602 devtoolsComponentEmit(instance, event, args); 1603 } 1604 1605 let handlerName; 1606 let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249) 1607 props[handlerName = toHandlerKey(camelize(event))]; // for v-model update:xxx events, also trigger kebab-case equivalent 1608 // for props passed via kebab-case 1609 1610 if (!handler && isModelListener) { 1611 handler = props[handlerName = toHandlerKey(hyphenate(event))]; 1612 } 1613 1614 if (handler) { 1615 callWithAsyncErrorHandling(handler, instance, 6 1616 /* COMPONENT_EVENT_HANDLER */ 1617 , args); 1618 } 1619 1620 const onceHandler = props[handlerName + `Once`]; 1621 1622 if (onceHandler) { 1623 if (!instance.emitted) { 1624 instance.emitted = {}; 1625 } else if (instance.emitted[handlerName]) { 1626 return; 1627 } 1628 1629 instance.emitted[handlerName] = true; 1630 callWithAsyncErrorHandling(onceHandler, instance, 6 1631 /* COMPONENT_EVENT_HANDLER */ 1632 , args); 1633 } 1634 } 1635 1636 function normalizeEmitsOptions(comp, appContext, asMixin) { 1637 if (asMixin === void 0) { 1638 asMixin = false; 1639 } 1640 1641 const cache = appContext.emitsCache; 1642 const cached = cache.get(comp); 1643 1644 if (cached !== undefined) { 1645 return cached; 1646 } 1647 1648 const raw = comp.emits; 1649 let normalized = {}; // apply mixin/extends props 1650 1651 let hasExtends = false; 1652 1653 if (__VUE_OPTIONS_API__ && !isFunction(comp)) { 1654 const extendEmits = raw => { 1655 const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true); 1656 1657 if (normalizedFromExtend) { 1658 hasExtends = true; 1659 extend(normalized, normalizedFromExtend); 1660 } 1661 }; 1662 1663 if (!asMixin && appContext.mixins.length) { 1664 appContext.mixins.forEach(extendEmits); 1665 } 1666 1667 if (comp.extends) { 1668 extendEmits(comp.extends); 1669 } 1670 1671 if (comp.mixins) { 1672 comp.mixins.forEach(extendEmits); 1673 } 1674 } 1675 1676 if (!raw && !hasExtends) { 1677 cache.set(comp, null); 1678 return null; 1679 } 1680 1681 if (isArray(raw)) { 1682 raw.forEach(key => normalized[key] = null); 1683 } else { 1684 extend(normalized, raw); 1685 } 1686 1687 cache.set(comp, normalized); 1688 return normalized; 1689 } // Check if an incoming prop key is a declared emit event listener. 1690 // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are 1691 // both considered matched listeners. 1692 1693 1694 function isEmitListener(options, key) { 1695 if (!options || !isOn(key)) { 1696 return false; 1697 } 1698 1699 key = key.slice(2).replace(/Once$/, ''); 1700 return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key); 1701 } 1702 /** 1703 * mark the current rendering instance for asset resolution (e.g. 1704 * resolveComponent, resolveDirective) during render 1705 */ 1706 1707 1708 let currentRenderingInstance = null; 1709 let currentScopeId = null; 1710 /** 1711 * Note: rendering calls maybe nested. The function returns the parent rendering 1712 * instance if present, which should be restored after the render is done: 1713 * 1714 * ```js 1715 * const prev = setCurrentRenderingInstance(i) 1716 * // ...render 1717 * setCurrentRenderingInstance(prev) 1718 * ``` 1719 */ 1720 1721 function setCurrentRenderingInstance(instance) { 1722 const prev = currentRenderingInstance; 1723 currentRenderingInstance = instance; 1724 currentScopeId = instance && instance.type.__scopeId || null; 1725 return prev; 1726 } 1727 /** 1728 * Wrap a slot function to memoize current rendering instance 1729 * @private compiler helper 1730 */ 1731 1732 1733 function withCtx(fn, ctx, isNonScopedSlot // false only 1734 ) { 1735 if (ctx === void 0) { 1736 ctx = currentRenderingInstance; 1737 } 1738 1739 if (!ctx) return fn; // already normalized 1740 1741 if (fn._n) { 1742 return fn; 1743 } 1744 1745 const renderFnWithContext = function () { 1746 // If a user calls a compiled slot inside a template expression (#1745), it 1747 // can mess up block tracking, so by default we disable block tracking and 1748 // force bail out when invoking a compiled slot (indicated by the ._d flag). 1749 // This isn't necessary if rendering a compiled `<slot>`, so we flip the 1750 // ._d flag off when invoking the wrapped fn inside `renderSlot`. 1751 if (renderFnWithContext._d) { 1752 setBlockTracking(-1); 1753 } 1754 1755 const prevInstance = setCurrentRenderingInstance(ctx); 1756 const res = fn(...arguments); 1757 setCurrentRenderingInstance(prevInstance); 1758 1759 if (renderFnWithContext._d) { 1760 setBlockTracking(1); 1761 } 1762 1763 if (__VUE_PROD_DEVTOOLS__) { 1764 devtoolsComponentUpdated(ctx); 1765 } 1766 1767 return res; 1768 }; // mark normalized to avoid duplicated wrapping 1769 1770 1771 renderFnWithContext._n = true; // mark this as compiled by default 1772 // this is used in vnode.ts -> normalizeChildren() to set the slot 1773 // rendering flag. 1774 1775 renderFnWithContext._c = true; // disable block tracking by default 1776 1777 renderFnWithContext._d = true; 1778 return renderFnWithContext; 1779 } 1780 1781 function markAttrsAccessed() { 1782 } 1783 1784 function renderComponentRoot(instance) { 1785 const { 1786 type: Component, 1787 vnode, 1788 proxy, 1789 withProxy, 1790 props, 1791 propsOptions: [propsOptions], 1792 slots, 1793 attrs, 1794 emit, 1795 render, 1796 renderCache, 1797 data, 1798 setupState, 1799 ctx, 1800 inheritAttrs 1801 } = instance; 1802 let result; 1803 let fallthroughAttrs; 1804 const prev = setCurrentRenderingInstance(instance); 1805 1806 try { 1807 if (vnode.shapeFlag & 4 1808 /* STATEFUL_COMPONENT */ 1809 ) { 1810 // withProxy is a proxy with a different `has` trap only for 1811 // runtime-compiled render functions using `with` block. 1812 const proxyToUse = withProxy || proxy; 1813 result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx)); 1814 fallthroughAttrs = attrs; 1815 } else { 1816 // functional 1817 const render = Component; // in dev, mark attrs accessed if optional props (attrs === props) 1818 1819 if ("production" !== 'production' && attrs === props) ; 1820 1821 result = normalizeVNode(render.length > 1 ? render(props, "production" !== 'production' ? { 1822 get attrs() { 1823 markAttrsAccessed(); 1824 return attrs; 1825 }, 1826 1827 slots, 1828 emit 1829 } : { 1830 attrs, 1831 slots, 1832 emit 1833 }) : render(props, null 1834 /* we know it doesn't need it */ 1835 )); 1836 fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs); 1837 } 1838 } catch (err) { 1839 blockStack.length = 0; 1840 handleError(err, instance, 1 1841 /* RENDER_FUNCTION */ 1842 ); 1843 result = createVNode(Comment); 1844 } // attr merging 1845 // in dev mode, comments are preserved, and it's possible for a template 1846 // to have comments along side the root element which makes it a fragment 1847 1848 1849 let root = result; 1850 1851 if (fallthroughAttrs && inheritAttrs !== false) { 1852 const keys = Object.keys(fallthroughAttrs); 1853 const { 1854 shapeFlag 1855 } = root; 1856 1857 if (keys.length) { 1858 if (shapeFlag & (1 1859 /* ELEMENT */ 1860 | 6 1861 /* COMPONENT */ 1862 )) { 1863 if (propsOptions && keys.some(isModelListener)) { 1864 // If a v-model listener (onUpdate:xxx) has a corresponding declared 1865 // prop, it indicates this component expects to handle v-model and 1866 // it should not fallthrough. 1867 // related: #1543, #1643, #1989 1868 fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions); 1869 } 1870 1871 root = cloneVNode(root, fallthroughAttrs); 1872 } 1873 } 1874 } // inherit directives 1875 1876 1877 if (vnode.dirs) { 1878 1879 root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs; 1880 } // inherit transition data 1881 1882 1883 if (vnode.transition) { 1884 1885 root.transition = vnode.transition; 1886 } 1887 1888 { 1889 result = root; 1890 } 1891 1892 setCurrentRenderingInstance(prev); 1893 return result; 1894 } 1895 1896 const getFunctionalFallthrough = attrs => { 1897 let res; 1898 1899 for (const key in attrs) { 1900 if (key === 'class' || key === 'style' || isOn(key)) { 1901 (res || (res = {}))[key] = attrs[key]; 1902 } 1903 } 1904 1905 return res; 1906 }; 1907 1908 const filterModelListeners = (attrs, props) => { 1909 const res = {}; 1910 1911 for (const key in attrs) { 1912 if (!isModelListener(key) || !(key.slice(9) in props)) { 1913 res[key] = attrs[key]; 1914 } 1915 } 1916 1917 return res; 1918 }; 1919 1920 function shouldUpdateComponent(prevVNode, nextVNode, optimized) { 1921 const { 1922 props: prevProps, 1923 children: prevChildren, 1924 component 1925 } = prevVNode; 1926 const { 1927 props: nextProps, 1928 children: nextChildren, 1929 patchFlag 1930 } = nextVNode; 1931 const emits = component.emitsOptions; // Parent component's render function was hot-updated. Since this may have 1932 1933 1934 if (nextVNode.dirs || nextVNode.transition) { 1935 return true; 1936 } 1937 1938 if (optimized && patchFlag >= 0) { 1939 if (patchFlag & 1024 1940 /* DYNAMIC_SLOTS */ 1941 ) { 1942 // slot content that references values that might have changed, 1943 // e.g. in a v-for 1944 return true; 1945 } 1946 1947 if (patchFlag & 16 1948 /* FULL_PROPS */ 1949 ) { 1950 if (!prevProps) { 1951 return !!nextProps; 1952 } // presence of this flag indicates props are always non-null 1953 1954 1955 return hasPropsChanged(prevProps, nextProps, emits); 1956 } else if (patchFlag & 8 1957 /* PROPS */ 1958 ) { 1959 const dynamicProps = nextVNode.dynamicProps; 1960 1961 for (let i = 0; i < dynamicProps.length; i++) { 1962 const key = dynamicProps[i]; 1963 1964 if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) { 1965 return true; 1966 } 1967 } 1968 } 1969 } else { 1970 // this path is only taken by manually written render functions 1971 // so presence of any children leads to a forced update 1972 if (prevChildren || nextChildren) { 1973 if (!nextChildren || !nextChildren.$stable) { 1974 return true; 1975 } 1976 } 1977 1978 if (prevProps === nextProps) { 1979 return false; 1980 } 1981 1982 if (!prevProps) { 1983 return !!nextProps; 1984 } 1985 1986 if (!nextProps) { 1987 return true; 1988 } 1989 1990 return hasPropsChanged(prevProps, nextProps, emits); 1991 } 1992 1993 return false; 1994 } 1995 1996 function hasPropsChanged(prevProps, nextProps, emitsOptions) { 1997 const nextKeys = Object.keys(nextProps); 1998 1999 if (nextKeys.length !== Object.keys(prevProps).length) { 2000 return true; 2001 } 2002 2003 for (let i = 0; i < nextKeys.length; i++) { 2004 const key = nextKeys[i]; 2005 2006 if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) { 2007 return true; 2008 } 2009 } 2010 2011 return false; 2012 } 2013 2014 function updateHOCHostEl(_ref2, el // HostNode 2015 ) { 2016 let { 2017 vnode, 2018 parent 2019 } = _ref2; 2020 2021 while (parent && parent.subTree === vnode) { 2022 (vnode = parent.vnode).el = el; 2023 parent = parent.parent; 2024 } 2025 } 2026 2027 const isSuspense = type => type.__isSuspense; // Suspense exposes a component-like API, and is treated like a component 2028 2029 function queueEffectWithSuspense(fn, suspense) { 2030 if (suspense && suspense.pendingBranch) { 2031 if (isArray(fn)) { 2032 suspense.effects.push(...fn); 2033 } else { 2034 suspense.effects.push(fn); 2035 } 2036 } else { 2037 queuePostFlushCb(fn); 2038 } 2039 } 2040 2041 function provide(key, value) { 2042 if (!currentInstance) ; else { 2043 let provides = currentInstance.provides; // by default an instance inherits its parent's provides object 2044 // but when it needs to provide values of its own, it creates its 2045 // own provides object using parent provides object as prototype. 2046 // this way in `inject` we can simply look up injections from direct 2047 // parent and let the prototype chain do the work. 2048 2049 const parentProvides = currentInstance.parent && currentInstance.parent.provides; 2050 2051 if (parentProvides === provides) { 2052 provides = currentInstance.provides = Object.create(parentProvides); 2053 } // TS doesn't allow symbol as index type 2054 2055 2056 provides[key] = value; 2057 } 2058 } 2059 2060 function inject(key, defaultValue, treatDefaultAsFactory) { 2061 if (treatDefaultAsFactory === void 0) { 2062 treatDefaultAsFactory = false; 2063 } 2064 2065 // fallback to `currentRenderingInstance` so that this can be called in 2066 // a functional component 2067 const instance = currentInstance || currentRenderingInstance; 2068 2069 if (instance) { 2070 // #2400 2071 // to support `app.use` plugins, 2072 // fallback to appContext's `provides` if the intance is at root 2073 const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides; 2074 2075 if (provides && key in provides) { 2076 // TS doesn't allow symbol as index type 2077 return provides[key]; 2078 } else if (arguments.length > 1) { 2079 return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue; 2080 } else ; 2081 } 2082 } 2083 2084 function useTransitionState() { 2085 const state = { 2086 isMounted: false, 2087 isLeaving: false, 2088 isUnmounting: false, 2089 leavingVNodes: new Map() 2090 }; 2091 onMounted(() => { 2092 state.isMounted = true; 2093 }); 2094 onBeforeUnmount(() => { 2095 state.isUnmounting = true; 2096 }); 2097 return state; 2098 } 2099 2100 const TransitionHookValidator = [Function, Array]; 2101 const BaseTransitionImpl = { 2102 name: `BaseTransition`, 2103 props: { 2104 mode: String, 2105 appear: Boolean, 2106 persisted: Boolean, 2107 // enter 2108 onBeforeEnter: TransitionHookValidator, 2109 onEnter: TransitionHookValidator, 2110 onAfterEnter: TransitionHookValidator, 2111 onEnterCancelled: TransitionHookValidator, 2112 // leave 2113 onBeforeLeave: TransitionHookValidator, 2114 onLeave: TransitionHookValidator, 2115 onAfterLeave: TransitionHookValidator, 2116 onLeaveCancelled: TransitionHookValidator, 2117 // appear 2118 onBeforeAppear: TransitionHookValidator, 2119 onAppear: TransitionHookValidator, 2120 onAfterAppear: TransitionHookValidator, 2121 onAppearCancelled: TransitionHookValidator 2122 }, 2123 2124 setup(props, _ref4) { 2125 let { 2126 slots 2127 } = _ref4; 2128 const instance = getCurrentInstance(); 2129 const state = useTransitionState(); 2130 let prevTransitionKey; 2131 return () => { 2132 const children = slots.default && getTransitionRawChildren(slots.default(), true); 2133 2134 if (!children || !children.length) { 2135 return; 2136 } // warn multiple elements 2137 // props for a bit better perf 2138 2139 2140 const rawProps = toRaw(props); 2141 const { 2142 mode 2143 } = rawProps; // check mode 2144 2145 2146 const child = children[0]; 2147 2148 if (state.isLeaving) { 2149 return emptyPlaceholder(child); 2150 } // in the case of <transition><keep-alive/></transition>, we need to 2151 // compare the type of the kept-alive children. 2152 2153 2154 const innerChild = getKeepAliveChild(child); 2155 2156 if (!innerChild) { 2157 return emptyPlaceholder(child); 2158 } 2159 2160 const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance); 2161 setTransitionHooks(innerChild, enterHooks); 2162 const oldChild = instance.subTree; 2163 const oldInnerChild = oldChild && getKeepAliveChild(oldChild); 2164 let transitionKeyChanged = false; 2165 const { 2166 getTransitionKey 2167 } = innerChild.type; 2168 2169 if (getTransitionKey) { 2170 const key = getTransitionKey(); 2171 2172 if (prevTransitionKey === undefined) { 2173 prevTransitionKey = key; 2174 } else if (key !== prevTransitionKey) { 2175 prevTransitionKey = key; 2176 transitionKeyChanged = true; 2177 } 2178 } // handle mode 2179 2180 2181 if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) { 2182 const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance); // update old tree's hooks in case of dynamic transition 2183 2184 setTransitionHooks(oldInnerChild, leavingHooks); // switching between different views 2185 2186 if (mode === 'out-in') { 2187 state.isLeaving = true; // return placeholder node and queue update when leave finishes 2188 2189 leavingHooks.afterLeave = () => { 2190 state.isLeaving = false; 2191 instance.update(); 2192 }; 2193 2194 return emptyPlaceholder(child); 2195 } else if (mode === 'in-out' && innerChild.type !== Comment) { 2196 leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => { 2197 const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild); 2198 leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild; // early removal callback 2199 2200 el._leaveCb = () => { 2201 earlyRemove(); 2202 el._leaveCb = undefined; 2203 delete enterHooks.delayedLeave; 2204 }; 2205 2206 enterHooks.delayedLeave = delayedLeave; 2207 }; 2208 } 2209 } 2210 2211 return child; 2212 }; 2213 } 2214 2215 }; // export the public type for h/tsx inference 2216 // also to avoid inline import() in generated d.ts files 2217 2218 const BaseTransition = BaseTransitionImpl; 2219 2220 function getLeavingNodesForType(state, vnode) { 2221 const { 2222 leavingVNodes 2223 } = state; 2224 let leavingVNodesCache = leavingVNodes.get(vnode.type); 2225 2226 if (!leavingVNodesCache) { 2227 leavingVNodesCache = Object.create(null); 2228 leavingVNodes.set(vnode.type, leavingVNodesCache); 2229 } 2230 2231 return leavingVNodesCache; 2232 } // The transition hooks are attached to the vnode as vnode.transition 2233 // and will be called at appropriate timing in the renderer. 2234 2235 2236 function resolveTransitionHooks(vnode, props, state, instance) { 2237 const { 2238 appear, 2239 mode, 2240 persisted = false, 2241 onBeforeEnter, 2242 onEnter, 2243 onAfterEnter, 2244 onEnterCancelled, 2245 onBeforeLeave, 2246 onLeave, 2247 onAfterLeave, 2248 onLeaveCancelled, 2249 onBeforeAppear, 2250 onAppear, 2251 onAfterAppear, 2252 onAppearCancelled 2253 } = props; 2254 const key = String(vnode.key); 2255 const leavingVNodesCache = getLeavingNodesForType(state, vnode); 2256 2257 const callHook = (hook, args) => { 2258 hook && callWithAsyncErrorHandling(hook, instance, 9 2259 /* TRANSITION_HOOK */ 2260 , args); 2261 }; 2262 2263 const hooks = { 2264 mode, 2265 persisted, 2266 2267 beforeEnter(el) { 2268 let hook = onBeforeEnter; 2269 2270 if (!state.isMounted) { 2271 if (appear) { 2272 hook = onBeforeAppear || onBeforeEnter; 2273 } else { 2274 return; 2275 } 2276 } // for same element (v-show) 2277 2278 2279 if (el._leaveCb) { 2280 el._leaveCb(true 2281 /* cancelled */ 2282 ); 2283 } // for toggled element with same key (v-if) 2284 2285 2286 const leavingVNode = leavingVNodesCache[key]; 2287 2288 if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el._leaveCb) { 2289 // force early removal (not cancelled) 2290 leavingVNode.el._leaveCb(); 2291 } 2292 2293 callHook(hook, [el]); 2294 }, 2295 2296 enter(el) { 2297 let hook = onEnter; 2298 let afterHook = onAfterEnter; 2299 let cancelHook = onEnterCancelled; 2300 2301 if (!state.isMounted) { 2302 if (appear) { 2303 hook = onAppear || onEnter; 2304 afterHook = onAfterAppear || onAfterEnter; 2305 cancelHook = onAppearCancelled || onEnterCancelled; 2306 } else { 2307 return; 2308 } 2309 } 2310 2311 let called = false; 2312 2313 const done = el._enterCb = cancelled => { 2314 if (called) return; 2315 called = true; 2316 2317 if (cancelled) { 2318 callHook(cancelHook, [el]); 2319 } else { 2320 callHook(afterHook, [el]); 2321 } 2322 2323 if (hooks.delayedLeave) { 2324 hooks.delayedLeave(); 2325 } 2326 2327 el._enterCb = undefined; 2328 }; 2329 2330 if (hook) { 2331 hook(el, done); 2332 2333 if (hook.length <= 1) { 2334 done(); 2335 } 2336 } else { 2337 done(); 2338 } 2339 }, 2340 2341 leave(el, remove) { 2342 const key = String(vnode.key); 2343 2344 if (el._enterCb) { 2345 el._enterCb(true 2346 /* cancelled */ 2347 ); 2348 } 2349 2350 if (state.isUnmounting) { 2351 return remove(); 2352 } 2353 2354 callHook(onBeforeLeave, [el]); 2355 let called = false; 2356 2357 const done = el._leaveCb = cancelled => { 2358 if (called) return; 2359 called = true; 2360 remove(); 2361 2362 if (cancelled) { 2363 callHook(onLeaveCancelled, [el]); 2364 } else { 2365 callHook(onAfterLeave, [el]); 2366 } 2367 2368 el._leaveCb = undefined; 2369 2370 if (leavingVNodesCache[key] === vnode) { 2371 delete leavingVNodesCache[key]; 2372 } 2373 }; 2374 2375 leavingVNodesCache[key] = vnode; 2376 2377 if (onLeave) { 2378 onLeave(el, done); 2379 2380 if (onLeave.length <= 1) { 2381 done(); 2382 } 2383 } else { 2384 done(); 2385 } 2386 }, 2387 2388 clone(vnode) { 2389 return resolveTransitionHooks(vnode, props, state, instance); 2390 } 2391 2392 }; 2393 return hooks; 2394 } // the placeholder really only handles one special case: KeepAlive 2395 // in the case of a KeepAlive in a leave phase we need to return a KeepAlive 2396 // placeholder with empty content to avoid the KeepAlive instance from being 2397 // unmounted. 2398 2399 2400 function emptyPlaceholder(vnode) { 2401 if (isKeepAlive(vnode)) { 2402 vnode = cloneVNode(vnode); 2403 vnode.children = null; 2404 return vnode; 2405 } 2406 } 2407 2408 function getKeepAliveChild(vnode) { 2409 return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : undefined : vnode; 2410 } 2411 2412 function setTransitionHooks(vnode, hooks) { 2413 if (vnode.shapeFlag & 6 2414 /* COMPONENT */ 2415 && vnode.component) { 2416 setTransitionHooks(vnode.component.subTree, hooks); 2417 } else if (vnode.shapeFlag & 128 2418 /* SUSPENSE */ 2419 ) { 2420 vnode.ssContent.transition = hooks.clone(vnode.ssContent); 2421 vnode.ssFallback.transition = hooks.clone(vnode.ssFallback); 2422 } else { 2423 vnode.transition = hooks; 2424 } 2425 } 2426 2427 function getTransitionRawChildren(children, keepComment) { 2428 if (keepComment === void 0) { 2429 keepComment = false; 2430 } 2431 2432 let ret = []; 2433 let keyedFragmentCount = 0; 2434 2435 for (let i = 0; i < children.length; i++) { 2436 const child = children[i]; // handle fragment children case, e.g. v-for 2437 2438 if (child.type === Fragment) { 2439 if (child.patchFlag & 128 2440 /* KEYED_FRAGMENT */ 2441 ) keyedFragmentCount++; 2442 ret = ret.concat(getTransitionRawChildren(child.children, keepComment)); 2443 } // comment placeholders should be skipped, e.g. v-if 2444 else if (keepComment || child.type !== Comment) { 2445 ret.push(child); 2446 } 2447 } // #1126 if a transition children list contains multiple sub fragments, these 2448 // fragments will be merged into a flat children array. Since each v-for 2449 // fragment may contain different static bindings inside, we need to de-op 2450 // these children to force full diffs to ensure correct behavior. 2451 2452 2453 if (keyedFragmentCount > 1) { 2454 for (let i = 0; i < ret.length; i++) { 2455 ret[i].patchFlag = -2 2456 /* BAIL */ 2457 ; 2458 } 2459 } 2460 2461 return ret; 2462 } // implementation, close to no-op 2463 2464 const isAsyncWrapper = i => !!i.type.__asyncLoader; 2465 2466 const isKeepAlive = vnode => vnode.type.__isKeepAlive; 2467 2468 function onActivated(hook, target) { 2469 registerKeepAliveHook(hook, "a" 2470 /* ACTIVATED */ 2471 , target); 2472 } 2473 2474 function onDeactivated(hook, target) { 2475 registerKeepAliveHook(hook, "da" 2476 /* DEACTIVATED */ 2477 , target); 2478 } 2479 2480 function registerKeepAliveHook(hook, type, target) { 2481 if (target === void 0) { 2482 target = currentInstance; 2483 } 2484 2485 // cache the deactivate branch check wrapper for injected hooks so the same 2486 // hook can be properly deduped by the scheduler. "__wdc" stands for "with 2487 // deactivation check". 2488 const wrappedHook = hook.__wdc || (hook.__wdc = () => { 2489 // only fire the hook if the target instance is NOT in a deactivated branch. 2490 let current = target; 2491 2492 while (current) { 2493 if (current.isDeactivated) { 2494 return; 2495 } 2496 2497 current = current.parent; 2498 } 2499 2500 return hook(); 2501 }); 2502 2503 injectHook(type, wrappedHook, target); // In addition to registering it on the target instance, we walk up the parent 2504 // chain and register it on all ancestor instances that are keep-alive roots. 2505 // This avoids the need to walk the entire component tree when invoking these 2506 // hooks, and more importantly, avoids the need to track child components in 2507 // arrays. 2508 2509 if (target) { 2510 let current = target.parent; 2511 2512 while (current && current.parent) { 2513 if (isKeepAlive(current.parent.vnode)) { 2514 injectToKeepAliveRoot(wrappedHook, type, target, current); 2515 } 2516 2517 current = current.parent; 2518 } 2519 } 2520 } 2521 2522 function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) { 2523 // injectHook wraps the original for error handling, so make sure to remove 2524 // the wrapped version. 2525 const injected = injectHook(type, hook, keepAliveRoot, true 2526 /* prepend */ 2527 ); 2528 onUnmounted(() => { 2529 remove(keepAliveRoot[type], injected); 2530 }, target); 2531 } 2532 2533 function injectHook(type, hook, target, prepend) { 2534 if (target === void 0) { 2535 target = currentInstance; 2536 } 2537 2538 if (prepend === void 0) { 2539 prepend = false; 2540 } 2541 2542 if (target) { 2543 const hooks = target[type] || (target[type] = []); // cache the error handling wrapper for injected hooks so the same hook 2544 // can be properly deduped by the scheduler. "__weh" stands for "with error 2545 // handling". 2546 2547 const wrappedHook = hook.__weh || (hook.__weh = function () { 2548 if (target.isUnmounted) { 2549 return; 2550 } // disable tracking inside all lifecycle hooks 2551 // since they can potentially be called inside effects. 2552 2553 2554 pauseTracking(); // Set currentInstance during hook invocation. 2555 // This assumes the hook does not synchronously trigger other hooks, which 2556 // can only be false when the user does something really funky. 2557 2558 setCurrentInstance(target); 2559 2560 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { 2561 args[_key3] = arguments[_key3]; 2562 } 2563 2564 const res = callWithAsyncErrorHandling(hook, target, type, args); 2565 unsetCurrentInstance(); 2566 resetTracking(); 2567 return res; 2568 }); 2569 2570 if (prepend) { 2571 hooks.unshift(wrappedHook); 2572 } else { 2573 hooks.push(wrappedHook); 2574 } 2575 2576 return wrappedHook; 2577 } 2578 } 2579 2580 const createHook = lifecycle => function (hook, target) { 2581 if (target === void 0) { 2582 target = currentInstance; 2583 } 2584 2585 return (// post-create lifecycle registrations are noops during SSR (except for serverPrefetch) 2586 (!isInSSRComponentSetup || lifecycle === "sp" 2587 /* SERVER_PREFETCH */ 2588 ) && injectHook(lifecycle, hook, target) 2589 ); 2590 }; 2591 2592 const onBeforeMount = createHook("bm" 2593 /* BEFORE_MOUNT */ 2594 ); 2595 const onMounted = createHook("m" 2596 /* MOUNTED */ 2597 ); 2598 const onBeforeUpdate = createHook("bu" 2599 /* BEFORE_UPDATE */ 2600 ); 2601 const onUpdated = createHook("u" 2602 /* UPDATED */ 2603 ); 2604 const onBeforeUnmount = createHook("bum" 2605 /* BEFORE_UNMOUNT */ 2606 ); 2607 const onUnmounted = createHook("um" 2608 /* UNMOUNTED */ 2609 ); 2610 const onServerPrefetch = createHook("sp" 2611 /* SERVER_PREFETCH */ 2612 ); 2613 const onRenderTriggered = createHook("rtg" 2614 /* RENDER_TRIGGERED */ 2615 ); 2616 const onRenderTracked = createHook("rtc" 2617 /* RENDER_TRACKED */ 2618 ); 2619 2620 function onErrorCaptured(hook, target) { 2621 if (target === void 0) { 2622 target = currentInstance; 2623 } 2624 2625 injectHook("ec" 2626 /* ERROR_CAPTURED */ 2627 , hook, target); 2628 } 2629 2630 let shouldCacheAccess = true; 2631 2632 function applyOptions(instance) { 2633 const options = resolveMergedOptions(instance); 2634 const publicThis = instance.proxy; 2635 const ctx = instance.ctx; // do not cache property access on public proxy during state initialization 2636 2637 shouldCacheAccess = false; // call beforeCreate first before accessing other options since 2638 // the hook may mutate resolved options (#2791) 2639 2640 if (options.beforeCreate) { 2641 callHook$1(options.beforeCreate, instance, "bc" 2642 /* BEFORE_CREATE */ 2643 ); 2644 } 2645 2646 const { 2647 // state 2648 data: dataOptions, 2649 computed: computedOptions, 2650 methods, 2651 watch: watchOptions, 2652 provide: provideOptions, 2653 inject: injectOptions, 2654 // lifecycle 2655 created, 2656 beforeMount, 2657 mounted, 2658 beforeUpdate, 2659 updated, 2660 activated, 2661 deactivated, 2662 beforeDestroy, 2663 beforeUnmount, 2664 destroyed, 2665 unmounted, 2666 render, 2667 renderTracked, 2668 renderTriggered, 2669 errorCaptured, 2670 serverPrefetch, 2671 // public API 2672 expose, 2673 inheritAttrs, 2674 // assets 2675 components, 2676 directives, 2677 filters 2678 } = options; 2679 const checkDuplicateProperties = null; 2680 // - props (already done outside of this function) 2681 // - inject 2682 // - methods 2683 // - data (deferred since it relies on `this` access) 2684 // - computed 2685 // - watch (deferred since it relies on `this` access) 2686 2687 2688 if (injectOptions) { 2689 resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef); 2690 } 2691 2692 if (methods) { 2693 for (const key in methods) { 2694 const methodHandler = methods[key]; 2695 2696 if (isFunction(methodHandler)) { 2697 // In dev mode, we use the `createRenderContext` function to define 2698 // methods to the proxy target, and those are read-only but 2699 // reconfigurable, so it needs to be redefined here 2700 { 2701 ctx[key] = methodHandler.bind(publicThis); 2702 } 2703 } 2704 } 2705 } 2706 2707 if (dataOptions) { 2708 2709 const data = dataOptions.call(publicThis, publicThis); 2710 2711 if (!isObject$1(data)) ; else { 2712 instance.data = reactive(data); 2713 } 2714 } // state initialization complete at this point - start caching access 2715 2716 2717 shouldCacheAccess = true; 2718 2719 if (computedOptions) { 2720 for (const key in computedOptions) { 2721 const opt = computedOptions[key]; 2722 const get = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP; 2723 2724 const set = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : NOOP; 2725 const c = computed({ 2726 get, 2727 set 2728 }); 2729 Object.defineProperty(ctx, key, { 2730 enumerable: true, 2731 configurable: true, 2732 get: () => c.value, 2733 set: v => c.value = v 2734 }); 2735 } 2736 } 2737 2738 if (watchOptions) { 2739 for (const key in watchOptions) { 2740 createWatcher(watchOptions[key], ctx, publicThis, key); 2741 } 2742 } 2743 2744 if (provideOptions) { 2745 const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions; 2746 Reflect.ownKeys(provides).forEach(key => { 2747 provide(key, provides[key]); 2748 }); 2749 } 2750 2751 if (created) { 2752 callHook$1(created, instance, "c" 2753 /* CREATED */ 2754 ); 2755 } 2756 2757 function registerLifecycleHook(register, hook) { 2758 if (isArray(hook)) { 2759 hook.forEach(_hook => register(_hook.bind(publicThis))); 2760 } else if (hook) { 2761 register(hook.bind(publicThis)); 2762 } 2763 } 2764 2765 registerLifecycleHook(onBeforeMount, beforeMount); 2766 registerLifecycleHook(onMounted, mounted); 2767 registerLifecycleHook(onBeforeUpdate, beforeUpdate); 2768 registerLifecycleHook(onUpdated, updated); 2769 registerLifecycleHook(onActivated, activated); 2770 registerLifecycleHook(onDeactivated, deactivated); 2771 registerLifecycleHook(onErrorCaptured, errorCaptured); 2772 registerLifecycleHook(onRenderTracked, renderTracked); 2773 registerLifecycleHook(onRenderTriggered, renderTriggered); 2774 registerLifecycleHook(onBeforeUnmount, beforeUnmount); 2775 registerLifecycleHook(onUnmounted, unmounted); 2776 registerLifecycleHook(onServerPrefetch, serverPrefetch); 2777 2778 if (isArray(expose)) { 2779 if (expose.length) { 2780 const exposed = instance.exposed || (instance.exposed = {}); 2781 expose.forEach(key => { 2782 Object.defineProperty(exposed, key, { 2783 get: () => publicThis[key], 2784 set: val => publicThis[key] = val 2785 }); 2786 }); 2787 } else if (!instance.exposed) { 2788 instance.exposed = {}; 2789 } 2790 } // options that are handled when creating the instance but also need to be 2791 // applied from mixins 2792 2793 2794 if (render && instance.render === NOOP) { 2795 instance.render = render; 2796 } 2797 2798 if (inheritAttrs != null) { 2799 instance.inheritAttrs = inheritAttrs; 2800 } // asset options. 2801 2802 2803 if (components) instance.components = components; 2804 if (directives) instance.directives = directives; 2805 } 2806 2807 function resolveInjections(injectOptions, ctx, checkDuplicateProperties, unwrapRef) { 2808 2809 if (unwrapRef === void 0) { 2810 unwrapRef = false; 2811 } 2812 2813 if (isArray(injectOptions)) { 2814 injectOptions = normalizeInject(injectOptions); 2815 } 2816 2817 for (const key in injectOptions) { 2818 const opt = injectOptions[key]; 2819 let injected; 2820 2821 if (isObject$1(opt)) { 2822 if ('default' in opt) { 2823 injected = inject(opt.from || key, opt.default, true 2824 /* treat default function as factory */ 2825 ); 2826 } else { 2827 injected = inject(opt.from || key); 2828 } 2829 } else { 2830 injected = inject(opt); 2831 } 2832 2833 if (isRef(injected)) { 2834 // TODO remove the check in 3.3 2835 if (unwrapRef) { 2836 Object.defineProperty(ctx, key, { 2837 enumerable: true, 2838 configurable: true, 2839 get: () => injected.value, 2840 set: v => injected.value = v 2841 }); 2842 } else { 2843 2844 ctx[key] = injected; 2845 } 2846 } else { 2847 ctx[key] = injected; 2848 } 2849 } 2850 } 2851 2852 function callHook$1(hook, instance, type) { 2853 callWithAsyncErrorHandling(isArray(hook) ? hook.map(h => h.bind(instance.proxy)) : hook.bind(instance.proxy), instance, type); 2854 } 2855 2856 function createWatcher(raw, ctx, publicThis, key) { 2857 const getter = key.includes('.') ? createPathGetter(publicThis, key) : () => publicThis[key]; 2858 2859 if (isString(raw)) { 2860 const handler = ctx[raw]; 2861 2862 if (isFunction(handler)) { 2863 watch(getter, handler); 2864 } 2865 } else if (isFunction(raw)) { 2866 watch(getter, raw.bind(publicThis)); 2867 } else if (isObject$1(raw)) { 2868 if (isArray(raw)) { 2869 raw.forEach(r => createWatcher(r, ctx, publicThis, key)); 2870 } else { 2871 const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler]; 2872 2873 if (isFunction(handler)) { 2874 watch(getter, handler, raw); 2875 } 2876 } 2877 } else ; 2878 } 2879 /** 2880 * Resolve merged options and cache it on the component. 2881 * This is done only once per-component since the merging does not involve 2882 * instances. 2883 */ 2884 2885 2886 function resolveMergedOptions(instance) { 2887 const base = instance.type; 2888 const { 2889 mixins, 2890 extends: extendsOptions 2891 } = base; 2892 const { 2893 mixins: globalMixins, 2894 optionsCache: cache, 2895 config: { 2896 optionMergeStrategies 2897 } 2898 } = instance.appContext; 2899 const cached = cache.get(base); 2900 let resolved; 2901 2902 if (cached) { 2903 resolved = cached; 2904 } else if (!globalMixins.length && !mixins && !extendsOptions) { 2905 { 2906 resolved = base; 2907 } 2908 } else { 2909 resolved = {}; 2910 2911 if (globalMixins.length) { 2912 globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true)); 2913 } 2914 2915 mergeOptions(resolved, base, optionMergeStrategies); 2916 } 2917 2918 cache.set(base, resolved); 2919 return resolved; 2920 } 2921 2922 function mergeOptions(to, from, strats, asMixin) { 2923 if (asMixin === void 0) { 2924 asMixin = false; 2925 } 2926 2927 const { 2928 mixins, 2929 extends: extendsOptions 2930 } = from; 2931 2932 if (extendsOptions) { 2933 mergeOptions(to, extendsOptions, strats, true); 2934 } 2935 2936 if (mixins) { 2937 mixins.forEach(m => mergeOptions(to, m, strats, true)); 2938 } 2939 2940 for (const key in from) { 2941 if (asMixin && key === 'expose') ; else { 2942 const strat = internalOptionMergeStrats[key] || strats && strats[key]; 2943 to[key] = strat ? strat(to[key], from[key]) : from[key]; 2944 } 2945 } 2946 2947 return to; 2948 } 2949 2950 const internalOptionMergeStrats = { 2951 data: mergeDataFn, 2952 props: mergeObjectOptions, 2953 emits: mergeObjectOptions, 2954 // objects 2955 methods: mergeObjectOptions, 2956 computed: mergeObjectOptions, 2957 // lifecycle 2958 beforeCreate: mergeAsArray, 2959 created: mergeAsArray, 2960 beforeMount: mergeAsArray, 2961 mounted: mergeAsArray, 2962 beforeUpdate: mergeAsArray, 2963 updated: mergeAsArray, 2964 beforeDestroy: mergeAsArray, 2965 beforeUnmount: mergeAsArray, 2966 destroyed: mergeAsArray, 2967 unmounted: mergeAsArray, 2968 activated: mergeAsArray, 2969 deactivated: mergeAsArray, 2970 errorCaptured: mergeAsArray, 2971 serverPrefetch: mergeAsArray, 2972 // assets 2973 components: mergeObjectOptions, 2974 directives: mergeObjectOptions, 2975 // watch 2976 watch: mergeWatchOptions, 2977 // provide / inject 2978 provide: mergeDataFn, 2979 inject: mergeInject 2980 }; 2981 2982 function mergeDataFn(to, from) { 2983 if (!from) { 2984 return to; 2985 } 2986 2987 if (!to) { 2988 return from; 2989 } 2990 2991 return function mergedDataFn() { 2992 return extend(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from); 2993 }; 2994 } 2995 2996 function mergeInject(to, from) { 2997 return mergeObjectOptions(normalizeInject(to), normalizeInject(from)); 2998 } 2999 3000 function normalizeInject(raw) { 3001 if (isArray(raw)) { 3002 const res = {}; 3003 3004 for (let i = 0; i < raw.length; i++) { 3005 res[raw[i]] = raw[i]; 3006 } 3007 3008 return res; 3009 } 3010 3011 return raw; 3012 } 3013 3014 function mergeAsArray(to, from) { 3015 return to ? [...new Set([].concat(to, from))] : from; 3016 } 3017 3018 function mergeObjectOptions(to, from) { 3019 return to ? extend(extend(Object.create(null), to), from) : from; 3020 } 3021 3022 function mergeWatchOptions(to, from) { 3023 if (!to) return from; 3024 if (!from) return to; 3025 const merged = extend(Object.create(null), to); 3026 3027 for (const key in from) { 3028 merged[key] = mergeAsArray(to[key], from[key]); 3029 } 3030 3031 return merged; 3032 } 3033 3034 function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison 3035 isSSR) { 3036 if (isSSR === void 0) { 3037 isSSR = false; 3038 } 3039 3040 const props = {}; 3041 const attrs = {}; 3042 def(attrs, InternalObjectKey, 1); 3043 instance.propsDefaults = Object.create(null); 3044 setFullProps(instance, rawProps, props, attrs); // ensure all declared prop keys are present 3045 3046 for (const key in instance.propsOptions[0]) { 3047 if (!(key in props)) { 3048 props[key] = undefined; 3049 } 3050 } // validation 3051 3052 if (isStateful) { 3053 // stateful 3054 instance.props = isSSR ? props : shallowReactive(props); 3055 } else { 3056 if (!instance.type.props) { 3057 // functional w/ optional props, props === attrs 3058 instance.props = attrs; 3059 } else { 3060 // functional w/ declared props 3061 instance.props = props; 3062 } 3063 } 3064 3065 instance.attrs = attrs; 3066 } 3067 3068 function updateProps(instance, rawProps, rawPrevProps, optimized) { 3069 const { 3070 props, 3071 attrs, 3072 vnode: { 3073 patchFlag 3074 } 3075 } = instance; 3076 const rawCurrentProps = toRaw(props); 3077 const [options] = instance.propsOptions; 3078 let hasAttrsChanged = false; 3079 3080 if ( // always force full diff in dev 3081 // - #1942 if hmr is enabled with sfc component 3082 // - vite#872 non-sfc component used by sfc component 3083 (optimized || patchFlag > 0) && !(patchFlag & 16 3084 /* FULL_PROPS */ 3085 )) { 3086 if (patchFlag & 8 3087 /* PROPS */ 3088 ) { 3089 // Compiler-generated props & no keys change, just set the updated 3090 // the props. 3091 const propsToUpdate = instance.vnode.dynamicProps; 3092 3093 for (let i = 0; i < propsToUpdate.length; i++) { 3094 let key = propsToUpdate[i]; // PROPS flag guarantees rawProps to be non-null 3095 3096 const value = rawProps[key]; 3097 3098 if (options) { 3099 // attr / props separation was done on init and will be consistent 3100 // in this code path, so just check if attrs have it. 3101 if (hasOwn(attrs, key)) { 3102 if (value !== attrs[key]) { 3103 attrs[key] = value; 3104 hasAttrsChanged = true; 3105 } 3106 } else { 3107 const camelizedKey = camelize(key); 3108 props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false 3109 /* isAbsent */ 3110 ); 3111 } 3112 } else { 3113 if (value !== attrs[key]) { 3114 attrs[key] = value; 3115 hasAttrsChanged = true; 3116 } 3117 } 3118 } 3119 } 3120 } else { 3121 // full props update. 3122 if (setFullProps(instance, rawProps, props, attrs)) { 3123 hasAttrsChanged = true; 3124 } // in case of dynamic props, check if we need to delete keys from 3125 // the props object 3126 3127 3128 let kebabKey; 3129 3130 for (const key in rawCurrentProps) { 3131 if (!rawProps || // for camelCase 3132 !hasOwn(rawProps, key) && ( // it's possible the original props was passed in as kebab-case 3133 // and converted to camelCase (#955) 3134 (kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) { 3135 if (options) { 3136 if (rawPrevProps && ( // for camelCase 3137 rawPrevProps[key] !== undefined || // for kebab-case 3138 rawPrevProps[kebabKey] !== undefined)) { 3139 props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true 3140 /* isAbsent */ 3141 ); 3142 } 3143 } else { 3144 delete props[key]; 3145 } 3146 } 3147 } // in the case of functional component w/o props declaration, props and 3148 // attrs point to the same object so it should already have been updated. 3149 3150 3151 if (attrs !== rawCurrentProps) { 3152 for (const key in attrs) { 3153 if (!rawProps || !hasOwn(rawProps, key)) { 3154 delete attrs[key]; 3155 hasAttrsChanged = true; 3156 } 3157 } 3158 } 3159 } // trigger updates for $attrs in case it's used in component slots 3160 3161 3162 if (hasAttrsChanged) { 3163 trigger$1(instance, "set" 3164 /* SET */ 3165 , '$attrs'); 3166 } 3167 } 3168 3169 function setFullProps(instance, rawProps, props, attrs) { 3170 const [options, needCastKeys] = instance.propsOptions; 3171 let hasAttrsChanged = false; 3172 let rawCastValues; 3173 3174 if (rawProps) { 3175 for (let key in rawProps) { 3176 // key, ref are reserved and never passed down 3177 if (isReservedProp(key)) { 3178 continue; 3179 } 3180 3181 const value = rawProps[key]; // prop option names are camelized during normalization, so to support 3182 // kebab -> camel conversion here we need to camelize the key. 3183 3184 let camelKey; 3185 3186 if (options && hasOwn(options, camelKey = camelize(key))) { 3187 if (!needCastKeys || !needCastKeys.includes(camelKey)) { 3188 props[camelKey] = value; 3189 } else { 3190 (rawCastValues || (rawCastValues = {}))[camelKey] = value; 3191 } 3192 } else if (!isEmitListener(instance.emitsOptions, key)) { 3193 if (!(key in attrs) || value !== attrs[key]) { 3194 attrs[key] = value; 3195 hasAttrsChanged = true; 3196 } 3197 } 3198 } 3199 } 3200 3201 if (needCastKeys) { 3202 const rawCurrentProps = toRaw(props); 3203 const castValues = rawCastValues || EMPTY_OBJ; 3204 3205 for (let i = 0; i < needCastKeys.length; i++) { 3206 const key = needCastKeys[i]; 3207 props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key)); 3208 } 3209 } 3210 3211 return hasAttrsChanged; 3212 } 3213 3214 function resolvePropValue(options, props, key, value, instance, isAbsent) { 3215 const opt = options[key]; 3216 3217 if (opt != null) { 3218 const hasDefault = hasOwn(opt, 'default'); // default values 3219 3220 if (hasDefault && value === undefined) { 3221 const defaultValue = opt.default; 3222 3223 if (opt.type !== Function && isFunction(defaultValue)) { 3224 const { 3225 propsDefaults 3226 } = instance; 3227 3228 if (key in propsDefaults) { 3229 value = propsDefaults[key]; 3230 } else { 3231 setCurrentInstance(instance); 3232 value = propsDefaults[key] = defaultValue.call(null, props); 3233 unsetCurrentInstance(); 3234 } 3235 } else { 3236 value = defaultValue; 3237 } 3238 } // boolean casting 3239 3240 3241 if (opt[0 3242 /* shouldCast */ 3243 ]) { 3244 if (isAbsent && !hasDefault) { 3245 value = false; 3246 } else if (opt[1 3247 /* shouldCastTrue */ 3248 ] && (value === '' || value === hyphenate(key))) { 3249 value = true; 3250 } 3251 } 3252 } 3253 3254 return value; 3255 } 3256 3257 function normalizePropsOptions(comp, appContext, asMixin) { 3258 if (asMixin === void 0) { 3259 asMixin = false; 3260 } 3261 3262 const cache = appContext.propsCache; 3263 const cached = cache.get(comp); 3264 3265 if (cached) { 3266 return cached; 3267 } 3268 3269 const raw = comp.props; 3270 const normalized = {}; 3271 const needCastKeys = []; // apply mixin/extends props 3272 3273 let hasExtends = false; 3274 3275 if (__VUE_OPTIONS_API__ && !isFunction(comp)) { 3276 const extendProps = raw => { 3277 hasExtends = true; 3278 const [props, keys] = normalizePropsOptions(raw, appContext, true); 3279 extend(normalized, props); 3280 if (keys) needCastKeys.push(...keys); 3281 }; 3282 3283 if (!asMixin && appContext.mixins.length) { 3284 appContext.mixins.forEach(extendProps); 3285 } 3286 3287 if (comp.extends) { 3288 extendProps(comp.extends); 3289 } 3290 3291 if (comp.mixins) { 3292 comp.mixins.forEach(extendProps); 3293 } 3294 } 3295 3296 if (!raw && !hasExtends) { 3297 cache.set(comp, EMPTY_ARR); 3298 return EMPTY_ARR; 3299 } 3300 3301 if (isArray(raw)) { 3302 for (let i = 0; i < raw.length; i++) { 3303 3304 const normalizedKey = camelize(raw[i]); 3305 3306 if (validatePropName(normalizedKey)) { 3307 normalized[normalizedKey] = EMPTY_OBJ; 3308 } 3309 } 3310 } else if (raw) { 3311 3312 for (const key in raw) { 3313 const normalizedKey = camelize(key); 3314 3315 if (validatePropName(normalizedKey)) { 3316 const opt = raw[key]; 3317 const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { 3318 type: opt 3319 } : opt; 3320 3321 if (prop) { 3322 const booleanIndex = getTypeIndex(Boolean, prop.type); 3323 const stringIndex = getTypeIndex(String, prop.type); 3324 prop[0 3325 /* shouldCast */ 3326 ] = booleanIndex > -1; 3327 prop[1 3328 /* shouldCastTrue */ 3329 ] = stringIndex < 0 || booleanIndex < stringIndex; // if the prop needs boolean casting or default value 3330 3331 if (booleanIndex > -1 || hasOwn(prop, 'default')) { 3332 needCastKeys.push(normalizedKey); 3333 } 3334 } 3335 } 3336 } 3337 } 3338 3339 const res = [normalized, needCastKeys]; 3340 cache.set(comp, res); 3341 return res; 3342 } 3343 3344 function validatePropName(key) { 3345 if (key[0] !== '$') { 3346 return true; 3347 } 3348 3349 return false; 3350 } // use function string name to check type constructors 3351 // so that it works across vms / iframes. 3352 3353 3354 function getType(ctor) { 3355 const match = ctor && ctor.toString().match(/^\s*function (\w+)/); 3356 return match ? match[1] : ctor === null ? 'null' : ''; 3357 } 3358 3359 function isSameType(a, b) { 3360 return getType(a) === getType(b); 3361 } 3362 3363 function getTypeIndex(type, expectedTypes) { 3364 if (isArray(expectedTypes)) { 3365 return expectedTypes.findIndex(t => isSameType(t, type)); 3366 } else if (isFunction(expectedTypes)) { 3367 return isSameType(expectedTypes, type) ? 0 : -1; 3368 } 3369 3370 return -1; 3371 } 3372 3373 const isInternalKey = key => key[0] === '_' || key === '$stable'; 3374 3375 const normalizeSlotValue = value => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)]; 3376 3377 const normalizeSlot = (key, rawSlot, ctx) => { 3378 const normalized = withCtx(function () { 3379 3380 return normalizeSlotValue(rawSlot(...arguments)); 3381 }, ctx); 3382 normalized._c = false; 3383 return normalized; 3384 }; 3385 3386 const normalizeObjectSlots = (rawSlots, slots, instance) => { 3387 const ctx = rawSlots._ctx; 3388 3389 for (const key in rawSlots) { 3390 if (isInternalKey(key)) continue; 3391 const value = rawSlots[key]; 3392 3393 if (isFunction(value)) { 3394 slots[key] = normalizeSlot(key, value, ctx); 3395 } else if (value != null) { 3396 3397 const normalized = normalizeSlotValue(value); 3398 3399 slots[key] = () => normalized; 3400 } 3401 } 3402 }; 3403 3404 const normalizeVNodeSlots = (instance, children) => { 3405 3406 const normalized = normalizeSlotValue(children); 3407 3408 instance.slots.default = () => normalized; 3409 }; 3410 3411 const initSlots = (instance, children) => { 3412 if (instance.vnode.shapeFlag & 32 3413 /* SLOTS_CHILDREN */ 3414 ) { 3415 const type = children._; 3416 3417 if (type) { 3418 // users can get the shallow readonly version of the slots object through `this.$slots`, 3419 // we should avoid the proxy object polluting the slots of the internal instance 3420 instance.slots = toRaw(children); // make compiler marker non-enumerable 3421 3422 def(children, '_', type); 3423 } else { 3424 normalizeObjectSlots(children, instance.slots = {}); 3425 } 3426 } else { 3427 instance.slots = {}; 3428 3429 if (children) { 3430 normalizeVNodeSlots(instance, children); 3431 } 3432 } 3433 3434 def(instance.slots, InternalObjectKey, 1); 3435 }; 3436 3437 const updateSlots = (instance, children, optimized) => { 3438 const { 3439 vnode, 3440 slots 3441 } = instance; 3442 let needDeletionCheck = true; 3443 let deletionComparisonTarget = EMPTY_OBJ; 3444 3445 if (vnode.shapeFlag & 32 3446 /* SLOTS_CHILDREN */ 3447 ) { 3448 const type = children._; 3449 3450 if (type) { 3451 // compiled slots. 3452 if (optimized && type === 1 3453 /* STABLE */ 3454 ) { 3455 // compiled AND stable. 3456 // no need to update, and skip stale slots removal. 3457 needDeletionCheck = false; 3458 } else { 3459 // compiled but dynamic (v-if/v-for on slots) - update slots, but skip 3460 // normalization. 3461 extend(slots, children); // #2893 3462 // when rendering the optimized slots by manually written render function, 3463 // we need to delete the `slots._` flag if necessary to make subsequent updates reliable, 3464 // i.e. let the `renderSlot` create the bailed Fragment 3465 3466 if (!optimized && type === 1 3467 /* STABLE */ 3468 ) { 3469 delete slots._; 3470 } 3471 } 3472 } else { 3473 needDeletionCheck = !children.$stable; 3474 normalizeObjectSlots(children, slots); 3475 } 3476 3477 deletionComparisonTarget = children; 3478 } else if (children) { 3479 // non slot object children (direct value) passed to a component 3480 normalizeVNodeSlots(instance, children); 3481 deletionComparisonTarget = { 3482 default: 1 3483 }; 3484 } // delete stale slots 3485 3486 3487 if (needDeletionCheck) { 3488 for (const key in slots) { 3489 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) { 3490 delete slots[key]; 3491 } 3492 } 3493 } 3494 }; 3495 /** 3496 * Adds directives to a VNode. 3497 */ 3498 3499 3500 function withDirectives(vnode, directives) { 3501 const internalInstance = currentRenderingInstance; 3502 3503 if (internalInstance === null) { 3504 return vnode; 3505 } 3506 3507 const instance = internalInstance.proxy; 3508 const bindings = vnode.dirs || (vnode.dirs = []); 3509 3510 for (let i = 0; i < directives.length; i++) { 3511 let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i]; 3512 3513 if (isFunction(dir)) { 3514 dir = { 3515 mounted: dir, 3516 updated: dir 3517 }; 3518 } 3519 3520 if (dir.deep) { 3521 traverse(value); 3522 } 3523 3524 bindings.push({ 3525 dir, 3526 instance, 3527 value, 3528 oldValue: void 0, 3529 arg, 3530 modifiers 3531 }); 3532 } 3533 3534 return vnode; 3535 } 3536 3537 function invokeDirectiveHook(vnode, prevVNode, instance, name) { 3538 const bindings = vnode.dirs; 3539 const oldBindings = prevVNode && prevVNode.dirs; 3540 3541 for (let i = 0; i < bindings.length; i++) { 3542 const binding = bindings[i]; 3543 3544 if (oldBindings) { 3545 binding.oldValue = oldBindings[i].value; 3546 } 3547 3548 let hook = binding.dir[name]; 3549 3550 if (hook) { 3551 // disable tracking inside all lifecycle hooks 3552 // since they can potentially be called inside effects. 3553 pauseTracking(); 3554 callWithAsyncErrorHandling(hook, instance, 8 3555 /* DIRECTIVE_HOOK */ 3556 , [vnode.el, binding, vnode, prevVNode]); 3557 resetTracking(); 3558 } 3559 } 3560 } 3561 3562 function createAppContext() { 3563 return { 3564 app: null, 3565 config: { 3566 isNativeTag: NO, 3567 performance: false, 3568 globalProperties: {}, 3569 optionMergeStrategies: {}, 3570 errorHandler: undefined, 3571 warnHandler: undefined, 3572 compilerOptions: {} 3573 }, 3574 mixins: [], 3575 components: {}, 3576 directives: {}, 3577 provides: Object.create(null), 3578 optionsCache: new WeakMap(), 3579 propsCache: new WeakMap(), 3580 emitsCache: new WeakMap() 3581 }; 3582 } 3583 3584 let uid = 0; 3585 3586 function createAppAPI(render, hydrate) { 3587 return function createApp(rootComponent, rootProps) { 3588 if (rootProps === void 0) { 3589 rootProps = null; 3590 } 3591 3592 if (rootProps != null && !isObject$1(rootProps)) { 3593 rootProps = null; 3594 } 3595 3596 const context = createAppContext(); 3597 const installedPlugins = new Set(); 3598 let isMounted = false; 3599 const app = context.app = { 3600 _uid: uid++, 3601 _component: rootComponent, 3602 _props: rootProps, 3603 _container: null, 3604 _context: context, 3605 _instance: null, 3606 version, 3607 3608 get config() { 3609 return context.config; 3610 }, 3611 3612 set config(v) { 3613 }, 3614 3615 use(plugin) { 3616 for (var _len5 = arguments.length, options = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { 3617 options[_key5 - 1] = arguments[_key5]; 3618 } 3619 3620 if (installedPlugins.has(plugin)) ; else if (plugin && isFunction(plugin.install)) { 3621 installedPlugins.add(plugin); 3622 plugin.install(app, ...options); 3623 } else if (isFunction(plugin)) { 3624 installedPlugins.add(plugin); 3625 plugin(app, ...options); 3626 } else ; 3627 3628 return app; 3629 }, 3630 3631 mixin(mixin) { 3632 if (__VUE_OPTIONS_API__) { 3633 if (!context.mixins.includes(mixin)) { 3634 context.mixins.push(mixin); 3635 } 3636 } 3637 3638 return app; 3639 }, 3640 3641 component(name, component) { 3642 3643 if (!component) { 3644 return context.components[name]; 3645 } 3646 3647 context.components[name] = component; 3648 return app; 3649 }, 3650 3651 directive(name, directive) { 3652 3653 if (!directive) { 3654 return context.directives[name]; 3655 } 3656 3657 context.directives[name] = directive; 3658 return app; 3659 }, 3660 3661 mount(rootContainer, isHydrate, isSVG) { 3662 if (!isMounted) { 3663 const vnode = createVNode(rootComponent, rootProps); // store app context on the root VNode. 3664 // this will be set on the root instance on initial mount. 3665 3666 vnode.appContext = context; // HMR root reload 3667 3668 if (isHydrate && hydrate) { 3669 hydrate(vnode, rootContainer); 3670 } else { 3671 render(vnode, rootContainer, isSVG); 3672 } 3673 3674 isMounted = true; 3675 app._container = rootContainer; 3676 rootContainer.__vue_app__ = app; 3677 3678 if (__VUE_PROD_DEVTOOLS__) { 3679 app._instance = vnode.component; 3680 devtoolsInitApp(app, version); 3681 } 3682 3683 return getExposeProxy(vnode.component) || vnode.component.proxy; 3684 } 3685 }, 3686 3687 unmount() { 3688 if (isMounted) { 3689 render(null, app._container); 3690 3691 if (__VUE_PROD_DEVTOOLS__) { 3692 app._instance = null; 3693 devtoolsUnmountApp(app); 3694 } 3695 3696 delete app._container.__vue_app__; 3697 } 3698 }, 3699 3700 provide(key, value) { 3701 // https://github.com/Microsoft/TypeScript/issues/24587 3702 3703 3704 context.provides[key] = value; 3705 return app; 3706 } 3707 3708 }; 3709 return app; 3710 }; 3711 } 3712 /** 3713 * Function for handling a template ref 3714 */ 3715 3716 3717 function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount) { 3718 if (isUnmount === void 0) { 3719 isUnmount = false; 3720 } 3721 3722 if (isArray(rawRef)) { 3723 rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount)); 3724 return; 3725 } 3726 3727 if (isAsyncWrapper(vnode) && !isUnmount) { 3728 // when mounting async components, nothing needs to be done, 3729 // because the template ref is forwarded to inner component 3730 return; 3731 } 3732 3733 const refValue = vnode.shapeFlag & 4 3734 /* STATEFUL_COMPONENT */ 3735 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el; 3736 const value = isUnmount ? null : refValue; 3737 const { 3738 i: owner, 3739 r: ref 3740 } = rawRef; 3741 3742 const oldRef = oldRawRef && oldRawRef.r; 3743 const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs; 3744 const setupState = owner.setupState; // dynamic ref changed. unset old ref 3745 3746 if (oldRef != null && oldRef !== ref) { 3747 if (isString(oldRef)) { 3748 refs[oldRef] = null; 3749 3750 if (hasOwn(setupState, oldRef)) { 3751 setupState[oldRef] = null; 3752 } 3753 } else if (isRef(oldRef)) { 3754 oldRef.value = null; 3755 } 3756 } 3757 3758 if (isFunction(ref)) { 3759 callWithErrorHandling(ref, owner, 12 3760 /* FUNCTION_REF */ 3761 , [value, refs]); 3762 } else { 3763 const _isString = isString(ref); 3764 3765 const _isRef = isRef(ref); 3766 3767 if (_isString || _isRef) { 3768 const doSet = () => { 3769 if (rawRef.f) { 3770 const existing = _isString ? refs[ref] : ref.value; 3771 3772 if (isUnmount) { 3773 isArray(existing) && remove(existing, refValue); 3774 } else { 3775 if (!isArray(existing)) { 3776 if (_isString) { 3777 refs[ref] = [refValue]; 3778 } else { 3779 ref.value = [refValue]; 3780 if (rawRef.k) refs[rawRef.k] = ref.value; 3781 } 3782 } else if (!existing.includes(refValue)) { 3783 existing.push(refValue); 3784 } 3785 } 3786 } else if (_isString) { 3787 refs[ref] = value; 3788 3789 if (hasOwn(setupState, ref)) { 3790 setupState[ref] = value; 3791 } 3792 } else if (isRef(ref)) { 3793 ref.value = value; 3794 if (rawRef.k) refs[rawRef.k] = value; 3795 } else ; 3796 }; 3797 3798 if (value) { 3799 doSet.id = -1; 3800 queuePostRenderEffect(doSet, parentSuspense); 3801 } else { 3802 doSet(); 3803 } 3804 } 3805 } 3806 } 3807 /** 3808 * This is only called in esm-bundler builds. 3809 * It is called when a renderer is created, in `baseCreateRenderer` so that 3810 * importing runtime-core is side-effects free. 3811 * 3812 * istanbul-ignore-next 3813 */ 3814 3815 3816 function initFeatureFlags() { 3817 3818 if (typeof __VUE_OPTIONS_API__ !== 'boolean') { 3819 getGlobalThis().__VUE_OPTIONS_API__ = true; 3820 } 3821 3822 if (typeof __VUE_PROD_DEVTOOLS__ !== 'boolean') { 3823 getGlobalThis().__VUE_PROD_DEVTOOLS__ = false; 3824 } 3825 } 3826 3827 const queuePostRenderEffect = queueEffectWithSuspense; 3828 /** 3829 * The createRenderer function accepts two generic arguments: 3830 * HostNode and HostElement, corresponding to Node and Element types in the 3831 * host environment. For example, for runtime-dom, HostNode would be the DOM 3832 * `Node` interface and HostElement would be the DOM `Element` interface. 3833 * 3834 * Custom renderers can pass in the platform specific types like this: 3835 * 3836 * ``` js 3837 * const { render, createApp } = createRenderer<Node, Element>({ 3838 * patchProp, 3839 * ...nodeOps 3840 * }) 3841 * ``` 3842 */ 3843 3844 function createRenderer(options) { 3845 return baseCreateRenderer(options); 3846 } // Separate API for creating hydration-enabled renderer. 3847 3848 3849 function baseCreateRenderer(options, createHydrationFns) { 3850 // compile-time feature flags check 3851 { 3852 initFeatureFlags(); 3853 } 3854 const target = getGlobalThis(); 3855 target.__VUE__ = true; 3856 3857 if (__VUE_PROD_DEVTOOLS__) { 3858 setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target); 3859 } 3860 3861 const { 3862 insert: hostInsert, 3863 remove: hostRemove, 3864 patchProp: hostPatchProp, 3865 createElement: hostCreateElement, 3866 createText: hostCreateText, 3867 createComment: hostCreateComment, 3868 setText: hostSetText, 3869 setElementText: hostSetElementText, 3870 parentNode: hostParentNode, 3871 nextSibling: hostNextSibling, 3872 setScopeId: hostSetScopeId = NOOP, 3873 cloneNode: hostCloneNode, 3874 insertStaticContent: hostInsertStaticContent 3875 } = options; // Note: functions inside this closure should use `const xxx = () => {}` 3876 // style in order to prevent being inlined by minifiers. 3877 3878 const patch = function (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) { 3879 if (anchor === void 0) { 3880 anchor = null; 3881 } 3882 3883 if (parentComponent === void 0) { 3884 parentComponent = null; 3885 } 3886 3887 if (parentSuspense === void 0) { 3888 parentSuspense = null; 3889 } 3890 3891 if (isSVG === void 0) { 3892 isSVG = false; 3893 } 3894 3895 if (slotScopeIds === void 0) { 3896 slotScopeIds = null; 3897 } 3898 3899 if (optimized === void 0) { 3900 optimized = !!n2.dynamicChildren; 3901 } 3902 3903 if (n1 === n2) { 3904 return; 3905 } // patching & not same type, unmount old tree 3906 3907 3908 if (n1 && !isSameVNodeType(n1, n2)) { 3909 anchor = getNextHostNode(n1); 3910 unmount(n1, parentComponent, parentSuspense, true); 3911 n1 = null; 3912 } 3913 3914 if (n2.patchFlag === -2 3915 /* BAIL */ 3916 ) { 3917 optimized = false; 3918 n2.dynamicChildren = null; 3919 } 3920 3921 const { 3922 type, 3923 ref, 3924 shapeFlag 3925 } = n2; 3926 3927 switch (type) { 3928 case Text: 3929 processText(n1, n2, container, anchor); 3930 break; 3931 3932 case Comment: 3933 processCommentNode(n1, n2, container, anchor); 3934 break; 3935 3936 case Static: 3937 if (n1 == null) { 3938 mountStaticNode(n2, container, anchor, isSVG); 3939 } 3940 3941 break; 3942 3943 case Fragment: 3944 processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 3945 break; 3946 3947 default: 3948 if (shapeFlag & 1 3949 /* ELEMENT */ 3950 ) { 3951 processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 3952 } else if (shapeFlag & 6 3953 /* COMPONENT */ 3954 ) { 3955 processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 3956 } else if (shapeFlag & 64 3957 /* TELEPORT */ 3958 ) { 3959 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals); 3960 } else if (shapeFlag & 128 3961 /* SUSPENSE */ 3962 ) { 3963 type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals); 3964 } else ; 3965 3966 } // set ref 3967 3968 3969 if (ref != null && parentComponent) { 3970 setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2); 3971 } 3972 }; 3973 3974 const processText = (n1, n2, container, anchor) => { 3975 if (n1 == null) { 3976 hostInsert(n2.el = hostCreateText(n2.children), container, anchor); 3977 } else { 3978 const el = n2.el = n1.el; 3979 3980 if (n2.children !== n1.children) { 3981 hostSetText(el, n2.children); 3982 } 3983 } 3984 }; 3985 3986 const processCommentNode = (n1, n2, container, anchor) => { 3987 if (n1 == null) { 3988 hostInsert(n2.el = hostCreateComment(n2.children || ''), container, anchor); 3989 } else { 3990 // there's no support for dynamic comments 3991 n2.el = n1.el; 3992 } 3993 }; 3994 3995 const mountStaticNode = (n2, container, anchor, isSVG) => { 3996 [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, isSVG); 3997 }; 3998 3999 const moveStaticNode = (_ref8, container, nextSibling) => { 4000 let { 4001 el, 4002 anchor 4003 } = _ref8; 4004 let next; 4005 4006 while (el && el !== anchor) { 4007 next = hostNextSibling(el); 4008 hostInsert(el, container, nextSibling); 4009 el = next; 4010 } 4011 4012 hostInsert(anchor, container, nextSibling); 4013 }; 4014 4015 const removeStaticNode = _ref9 => { 4016 let { 4017 el, 4018 anchor 4019 } = _ref9; 4020 let next; 4021 4022 while (el && el !== anchor) { 4023 next = hostNextSibling(el); 4024 hostRemove(el); 4025 el = next; 4026 } 4027 4028 hostRemove(anchor); 4029 }; 4030 4031 const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { 4032 isSVG = isSVG || n2.type === 'svg'; 4033 4034 if (n1 == null) { 4035 mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4036 } else { 4037 patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4038 } 4039 }; 4040 4041 const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { 4042 let el; 4043 let vnodeHook; 4044 const { 4045 type, 4046 props, 4047 shapeFlag, 4048 transition, 4049 patchFlag, 4050 dirs 4051 } = vnode; 4052 4053 if (vnode.el && hostCloneNode !== undefined && patchFlag === -1 4054 /* HOISTED */ 4055 ) { 4056 // If a vnode has non-null el, it means it's being reused. 4057 // Only static vnodes can be reused, so its mounted DOM nodes should be 4058 // exactly the same, and we can simply do a clone here. 4059 // only do this in production since cloned trees cannot be HMR updated. 4060 el = vnode.el = hostCloneNode(vnode.el); 4061 } else { 4062 el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props); // mount children first, since some props may rely on child content 4063 // being already rendered, e.g. `<select value>` 4064 4065 if (shapeFlag & 8 4066 /* TEXT_CHILDREN */ 4067 ) { 4068 hostSetElementText(el, vnode.children); 4069 } else if (shapeFlag & 16 4070 /* ARRAY_CHILDREN */ 4071 ) { 4072 mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized); 4073 } 4074 4075 if (dirs) { 4076 invokeDirectiveHook(vnode, null, parentComponent, 'created'); 4077 } // props 4078 4079 4080 if (props) { 4081 for (const key in props) { 4082 if (key !== 'value' && !isReservedProp(key)) { 4083 hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren); 4084 } 4085 } 4086 /** 4087 * Special case for setting value on DOM elements: 4088 * - it can be order-sensitive (e.g. should be set *after* min/max, #2325, #4024) 4089 * - it needs to be forced (#1471) 4090 * #2353 proposes adding another renderer option to configure this, but 4091 * the properties affects are so finite it is worth special casing it 4092 * here to reduce the complexity. (Special casing it also should not 4093 * affect non-DOM renderers) 4094 */ 4095 4096 4097 if ('value' in props) { 4098 hostPatchProp(el, 'value', null, props.value); 4099 } 4100 4101 if (vnodeHook = props.onVnodeBeforeMount) { 4102 invokeVNodeHook(vnodeHook, parentComponent, vnode); 4103 } 4104 } // scopeId 4105 4106 4107 setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent); 4108 } 4109 4110 if (__VUE_PROD_DEVTOOLS__) { 4111 Object.defineProperty(el, '__vnode', { 4112 value: vnode, 4113 enumerable: false 4114 }); 4115 Object.defineProperty(el, '__vueParentComponent', { 4116 value: parentComponent, 4117 enumerable: false 4118 }); 4119 } 4120 4121 if (dirs) { 4122 invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount'); 4123 } // #1583 For inside suspense + suspense not resolved case, enter hook should call when suspense resolved 4124 // #1689 For inside suspense + suspense resolved case, just call it 4125 4126 4127 const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted; 4128 4129 if (needCallTransitionHooks) { 4130 transition.beforeEnter(el); 4131 } 4132 4133 hostInsert(el, container, anchor); 4134 4135 if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) { 4136 queuePostRenderEffect(() => { 4137 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode); 4138 needCallTransitionHooks && transition.enter(el); 4139 dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted'); 4140 }, parentSuspense); 4141 } 4142 }; 4143 4144 const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => { 4145 if (scopeId) { 4146 hostSetScopeId(el, scopeId); 4147 } 4148 4149 if (slotScopeIds) { 4150 for (let i = 0; i < slotScopeIds.length; i++) { 4151 hostSetScopeId(el, slotScopeIds[i]); 4152 } 4153 } 4154 4155 if (parentComponent) { 4156 let subTree = parentComponent.subTree; 4157 4158 if (vnode === subTree) { 4159 const parentVNode = parentComponent.vnode; 4160 setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent); 4161 } 4162 } 4163 }; 4164 4165 const mountChildren = function (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start) { 4166 if (start === void 0) { 4167 start = 0; 4168 } 4169 4170 for (let i = start; i < children.length; i++) { 4171 const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]); 4172 patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4173 } 4174 }; 4175 4176 const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { 4177 const el = n2.el = n1.el; 4178 let { 4179 patchFlag, 4180 dynamicChildren, 4181 dirs 4182 } = n2; // #1426 take the old vnode's patch flag into account since user may clone a 4183 // compiler-generated vnode, which de-opts to FULL_PROPS 4184 4185 patchFlag |= n1.patchFlag & 16 4186 /* FULL_PROPS */ 4187 ; 4188 const oldProps = n1.props || EMPTY_OBJ; 4189 const newProps = n2.props || EMPTY_OBJ; 4190 let vnodeHook; // disable recurse in beforeUpdate hooks 4191 4192 parentComponent && toggleRecurse(parentComponent, false); 4193 4194 if (vnodeHook = newProps.onVnodeBeforeUpdate) { 4195 invokeVNodeHook(vnodeHook, parentComponent, n2, n1); 4196 } 4197 4198 if (dirs) { 4199 invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate'); 4200 } 4201 4202 parentComponent && toggleRecurse(parentComponent, true); 4203 4204 const areChildrenSVG = isSVG && n2.type !== 'foreignObject'; 4205 4206 if (dynamicChildren) { 4207 patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds); 4208 } else if (!optimized) { 4209 // full diff 4210 patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false); 4211 } 4212 4213 if (patchFlag > 0) { 4214 // the presence of a patchFlag means this element's render code was 4215 // generated by the compiler and can take the fast path. 4216 // in this path old node and new node are guaranteed to have the same shape 4217 // (i.e. at the exact same position in the source template) 4218 if (patchFlag & 16 4219 /* FULL_PROPS */ 4220 ) { 4221 // element props contain dynamic keys, full diff needed 4222 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG); 4223 } else { 4224 // class 4225 // this flag is matched when the element has dynamic class bindings. 4226 if (patchFlag & 2 4227 /* CLASS */ 4228 ) { 4229 if (oldProps.class !== newProps.class) { 4230 hostPatchProp(el, 'class', null, newProps.class, isSVG); 4231 } 4232 } // style 4233 // this flag is matched when the element has dynamic style bindings 4234 4235 4236 if (patchFlag & 4 4237 /* STYLE */ 4238 ) { 4239 hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG); 4240 } // props 4241 // This flag is matched when the element has dynamic prop/attr bindings 4242 // other than class and style. The keys of dynamic prop/attrs are saved for 4243 // faster iteration. 4244 // Note dynamic keys like :[foo]="bar" will cause this optimization to 4245 // bail out and go through a full diff because we need to unset the old key 4246 4247 4248 if (patchFlag & 8 4249 /* PROPS */ 4250 ) { 4251 // if the flag is present then dynamicProps must be non-null 4252 const propsToUpdate = n2.dynamicProps; 4253 4254 for (let i = 0; i < propsToUpdate.length; i++) { 4255 const key = propsToUpdate[i]; 4256 const prev = oldProps[key]; 4257 const next = newProps[key]; // #1471 force patch value 4258 4259 if (next !== prev || key === 'value') { 4260 hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren); 4261 } 4262 } 4263 } 4264 } // text 4265 // This flag is matched when the element has only dynamic text children. 4266 4267 4268 if (patchFlag & 1 4269 /* TEXT */ 4270 ) { 4271 if (n1.children !== n2.children) { 4272 hostSetElementText(el, n2.children); 4273 } 4274 } 4275 } else if (!optimized && dynamicChildren == null) { 4276 // unoptimized, full diff 4277 patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG); 4278 } 4279 4280 if ((vnodeHook = newProps.onVnodeUpdated) || dirs) { 4281 queuePostRenderEffect(() => { 4282 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1); 4283 dirs && invokeDirectiveHook(n2, n1, parentComponent, 'updated'); 4284 }, parentSuspense); 4285 } 4286 }; // The fast path for blocks. 4287 4288 4289 const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => { 4290 for (let i = 0; i < newChildren.length; i++) { 4291 const oldVNode = oldChildren[i]; 4292 const newVNode = newChildren[i]; // Determine the container (parent element) for the patch. 4293 4294 const container = // oldVNode may be an errored async setup() component inside Suspense 4295 // which will not have a mounted element 4296 oldVNode.el && ( // - In the case of a Fragment, we need to provide the actual parent 4297 // of the Fragment itself so it can move its children. 4298 oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement 4299 // which also requires the correct parent container 4300 !isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything. 4301 oldVNode.shapeFlag & (6 4302 /* COMPONENT */ 4303 | 64 4304 /* TELEPORT */ 4305 )) ? hostParentNode(oldVNode.el) : // In other cases, the parent container is not actually used so we 4306 // just pass the block element here to avoid a DOM parentNode call. 4307 fallbackContainer; 4308 patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true); 4309 } 4310 }; 4311 4312 const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => { 4313 if (oldProps !== newProps) { 4314 for (const key in newProps) { 4315 // empty string is not valid prop 4316 if (isReservedProp(key)) continue; 4317 const next = newProps[key]; 4318 const prev = oldProps[key]; // defer patching value 4319 4320 if (next !== prev && key !== 'value') { 4321 hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren); 4322 } 4323 } 4324 4325 if (oldProps !== EMPTY_OBJ) { 4326 for (const key in oldProps) { 4327 if (!isReservedProp(key) && !(key in newProps)) { 4328 hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren); 4329 } 4330 } 4331 } 4332 4333 if ('value' in newProps) { 4334 hostPatchProp(el, 'value', oldProps.value, newProps.value); 4335 } 4336 } 4337 }; 4338 4339 const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { 4340 const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText(''); 4341 const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText(''); 4342 let { 4343 patchFlag, 4344 dynamicChildren, 4345 slotScopeIds: fragmentSlotScopeIds 4346 } = n2; 4347 4348 4349 if (fragmentSlotScopeIds) { 4350 slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds; 4351 } 4352 4353 if (n1 == null) { 4354 hostInsert(fragmentStartAnchor, container, anchor); 4355 hostInsert(fragmentEndAnchor, container, anchor); // a fragment can only have array children 4356 // since they are either generated by the compiler, or implicitly created 4357 // from arrays. 4358 4359 mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4360 } else { 4361 if (patchFlag > 0 && patchFlag & 64 4362 /* STABLE_FRAGMENT */ 4363 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result 4364 // of renderSlot() with no valid children 4365 n1.dynamicChildren) { 4366 // a stable fragment (template root or <template v-for>) doesn't need to 4367 // patch children order, but it may contain dynamicChildren. 4368 patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds); 4369 4370 if ( // #2080 if the stable fragment has a key, it's a <template v-for> that may 4371 // get moved around. Make sure all root level vnodes inherit el. 4372 // #2134 or if it's a component root, it may also get moved around 4373 // as the component is being moved. 4374 n2.key != null || parentComponent && n2 === parentComponent.subTree) { 4375 traverseStaticChildren(n1, n2, true 4376 /* shallow */ 4377 ); 4378 } 4379 } else { 4380 // keyed / unkeyed, or manual fragments. 4381 // for keyed & unkeyed, since they are compiler generated from v-for, 4382 // each child is guaranteed to be a block so the fragment will never 4383 // have dynamicChildren. 4384 patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4385 } 4386 } 4387 }; 4388 4389 const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { 4390 n2.slotScopeIds = slotScopeIds; 4391 4392 if (n1 == null) { 4393 if (n2.shapeFlag & 512 4394 /* COMPONENT_KEPT_ALIVE */ 4395 ) { 4396 parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized); 4397 } else { 4398 mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized); 4399 } 4400 } else { 4401 updateComponent(n1, n2, optimized); 4402 } 4403 }; 4404 4405 const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => { 4406 const instance = initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense); 4407 4408 4409 if (isKeepAlive(initialVNode)) { 4410 instance.ctx.renderer = internals; 4411 } // resolve props and slots for setup context 4412 4413 4414 { 4415 4416 setupComponent(instance); 4417 } // setup() is async. This component relies on async logic to be resolved 4418 // before proceeding 4419 4420 if (instance.asyncDep) { 4421 parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect); // Give it a placeholder if this is not hydration 4422 // TODO handle self-defined fallback 4423 4424 if (!initialVNode.el) { 4425 const placeholder = instance.subTree = createVNode(Comment); 4426 processCommentNode(null, placeholder, container, anchor); 4427 } 4428 4429 return; 4430 } 4431 4432 setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized); 4433 }; 4434 4435 const updateComponent = (n1, n2, optimized) => { 4436 const instance = n2.component = n1.component; 4437 4438 if (shouldUpdateComponent(n1, n2, optimized)) { 4439 if (instance.asyncDep && !instance.asyncResolved) { 4440 4441 updateComponentPreRender(instance, n2, optimized); 4442 4443 return; 4444 } else { 4445 // normal update 4446 instance.next = n2; // in case the child component is also queued, remove it to avoid 4447 // double updating the same child component in the same flush. 4448 4449 invalidateJob(instance.update); // instance.update is the reactive effect. 4450 4451 instance.update(); 4452 } 4453 } else { 4454 // no update needed. just copy over properties 4455 n2.component = n1.component; 4456 n2.el = n1.el; 4457 instance.vnode = n2; 4458 } 4459 }; 4460 4461 const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => { 4462 const componentUpdateFn = () => { 4463 if (!instance.isMounted) { 4464 let vnodeHook; 4465 const { 4466 el, 4467 props 4468 } = initialVNode; 4469 const { 4470 bm, 4471 m, 4472 parent 4473 } = instance; 4474 const isAsyncWrapperVNode = isAsyncWrapper(initialVNode); 4475 toggleRecurse(instance, false); // beforeMount hook 4476 4477 if (bm) { 4478 invokeArrayFns(bm); 4479 } // onVnodeBeforeMount 4480 4481 4482 if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) { 4483 invokeVNodeHook(vnodeHook, parent, initialVNode); 4484 } 4485 4486 toggleRecurse(instance, true); 4487 4488 if (el && hydrateNode) { 4489 // vnode has adopted host node - perform hydration instead of mount. 4490 const hydrateSubTree = () => { 4491 4492 instance.subTree = renderComponentRoot(instance); 4493 4494 hydrateNode(el, instance.subTree, instance, parentSuspense, null); 4495 }; 4496 4497 if (isAsyncWrapperVNode) { 4498 initialVNode.type.__asyncLoader().then( // note: we are moving the render call into an async callback, 4499 // which means it won't track dependencies - but it's ok because 4500 // a server-rendered async wrapper is already in resolved state 4501 // and it will never need to change. 4502 () => !instance.isUnmounted && hydrateSubTree()); 4503 } else { 4504 hydrateSubTree(); 4505 } 4506 } else { 4507 4508 const subTree = instance.subTree = renderComponentRoot(instance); 4509 4510 patch(null, subTree, container, anchor, instance, parentSuspense, isSVG); 4511 4512 initialVNode.el = subTree.el; 4513 } // mounted hook 4514 4515 4516 if (m) { 4517 queuePostRenderEffect(m, parentSuspense); 4518 } // onVnodeMounted 4519 4520 4521 if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) { 4522 const scopedInitialVNode = initialVNode; 4523 queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense); 4524 } // activated hook for keep-alive roots. 4525 // #1742 activated hook must be accessed after first render 4526 // since the hook may be injected by a child keep-alive 4527 4528 4529 if (initialVNode.shapeFlag & 256 4530 /* COMPONENT_SHOULD_KEEP_ALIVE */ 4531 ) { 4532 instance.a && queuePostRenderEffect(instance.a, parentSuspense); 4533 } 4534 4535 instance.isMounted = true; 4536 4537 if (__VUE_PROD_DEVTOOLS__) { 4538 devtoolsComponentAdded(instance); 4539 } // #2458: deference mount-only object parameters to prevent memleaks 4540 4541 4542 initialVNode = container = anchor = null; 4543 } else { 4544 // updateComponent 4545 // This is triggered by mutation of component's own state (next: null) 4546 // OR parent calling processComponent (next: VNode) 4547 let { 4548 next, 4549 bu, 4550 u, 4551 parent, 4552 vnode 4553 } = instance; 4554 let originNext = next; 4555 let vnodeHook; 4556 4557 4558 toggleRecurse(instance, false); 4559 4560 if (next) { 4561 next.el = vnode.el; 4562 updateComponentPreRender(instance, next, optimized); 4563 } else { 4564 next = vnode; 4565 } // beforeUpdate hook 4566 4567 4568 if (bu) { 4569 invokeArrayFns(bu); 4570 } // onVnodeBeforeUpdate 4571 4572 4573 if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) { 4574 invokeVNodeHook(vnodeHook, parent, next, vnode); 4575 } 4576 4577 toggleRecurse(instance, true); // render 4578 4579 const nextTree = renderComponentRoot(instance); 4580 4581 const prevTree = instance.subTree; 4582 instance.subTree = nextTree; 4583 4584 patch(prevTree, nextTree, // parent may have changed if it's in a teleport 4585 hostParentNode(prevTree.el), // anchor may have changed if it's in a fragment 4586 getNextHostNode(prevTree), instance, parentSuspense, isSVG); 4587 4588 next.el = nextTree.el; 4589 4590 if (originNext === null) { 4591 // self-triggered update. In case of HOC, update parent component 4592 // vnode el. HOC is indicated by parent instance's subTree pointing 4593 // to child component's vnode 4594 updateHOCHostEl(instance, nextTree.el); 4595 } // updated hook 4596 4597 4598 if (u) { 4599 queuePostRenderEffect(u, parentSuspense); 4600 } // onVnodeUpdated 4601 4602 4603 if (vnodeHook = next.props && next.props.onVnodeUpdated) { 4604 queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense); 4605 } 4606 4607 if (__VUE_PROD_DEVTOOLS__) { 4608 devtoolsComponentUpdated(instance); 4609 } 4610 } 4611 }; // create reactive effect for rendering 4612 4613 4614 const effect = instance.effect = new ReactiveEffect(componentUpdateFn, () => queueJob(instance.update), instance.scope // track it in component's effect scope 4615 ); 4616 const update = instance.update = effect.run.bind(effect); 4617 update.id = instance.uid; // allowRecurse 4618 // #1801, #2043 component render effects should allow recursive updates 4619 4620 toggleRecurse(instance, true); 4621 4622 update(); 4623 }; 4624 4625 const updateComponentPreRender = (instance, nextVNode, optimized) => { 4626 nextVNode.component = instance; 4627 const prevProps = instance.vnode.props; 4628 instance.vnode = nextVNode; 4629 instance.next = null; 4630 updateProps(instance, nextVNode.props, prevProps, optimized); 4631 updateSlots(instance, nextVNode.children, optimized); 4632 pauseTracking(); // props update may have triggered pre-flush watchers. 4633 // flush them before the render update. 4634 4635 flushPreFlushCbs(undefined, instance.update); 4636 resetTracking(); 4637 }; 4638 4639 const patchChildren = function (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) { 4640 if (optimized === void 0) { 4641 optimized = false; 4642 } 4643 4644 const c1 = n1 && n1.children; 4645 const prevShapeFlag = n1 ? n1.shapeFlag : 0; 4646 const c2 = n2.children; 4647 const { 4648 patchFlag, 4649 shapeFlag 4650 } = n2; // fast path 4651 4652 if (patchFlag > 0) { 4653 if (patchFlag & 128 4654 /* KEYED_FRAGMENT */ 4655 ) { 4656 // this could be either fully-keyed or mixed (some keyed some not) 4657 // presence of patchFlag means children are guaranteed to be arrays 4658 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4659 return; 4660 } else if (patchFlag & 256 4661 /* UNKEYED_FRAGMENT */ 4662 ) { 4663 // unkeyed 4664 patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4665 return; 4666 } 4667 } // children has 3 possibilities: text, array or no children. 4668 4669 4670 if (shapeFlag & 8 4671 /* TEXT_CHILDREN */ 4672 ) { 4673 // text children fast path 4674 if (prevShapeFlag & 16 4675 /* ARRAY_CHILDREN */ 4676 ) { 4677 unmountChildren(c1, parentComponent, parentSuspense); 4678 } 4679 4680 if (c2 !== c1) { 4681 hostSetElementText(container, c2); 4682 } 4683 } else { 4684 if (prevShapeFlag & 16 4685 /* ARRAY_CHILDREN */ 4686 ) { 4687 // prev children was array 4688 if (shapeFlag & 16 4689 /* ARRAY_CHILDREN */ 4690 ) { 4691 // two arrays, cannot assume anything, do full diff 4692 patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4693 } else { 4694 // no new children, just unmount old 4695 unmountChildren(c1, parentComponent, parentSuspense, true); 4696 } 4697 } else { 4698 // prev children was text OR null 4699 // new children is array OR null 4700 if (prevShapeFlag & 8 4701 /* TEXT_CHILDREN */ 4702 ) { 4703 hostSetElementText(container, ''); 4704 } // mount new if array 4705 4706 4707 if (shapeFlag & 16 4708 /* ARRAY_CHILDREN */ 4709 ) { 4710 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4711 } 4712 } 4713 } 4714 }; 4715 4716 const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { 4717 c1 = c1 || EMPTY_ARR; 4718 c2 = c2 || EMPTY_ARR; 4719 const oldLength = c1.length; 4720 const newLength = c2.length; 4721 const commonLength = Math.min(oldLength, newLength); 4722 let i; 4723 4724 for (i = 0; i < commonLength; i++) { 4725 const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); 4726 patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4727 } 4728 4729 if (oldLength > newLength) { 4730 // remove old 4731 unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength); 4732 } else { 4733 // mount new 4734 mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength); 4735 } 4736 }; // can be all-keyed or mixed 4737 4738 4739 const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { 4740 let i = 0; 4741 const l2 = c2.length; 4742 let e1 = c1.length - 1; // prev ending index 4743 4744 let e2 = l2 - 1; // next ending index 4745 // 1. sync from start 4746 // (a b) c 4747 // (a b) d e 4748 4749 while (i <= e1 && i <= e2) { 4750 const n1 = c1[i]; 4751 const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); 4752 4753 if (isSameVNodeType(n1, n2)) { 4754 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4755 } else { 4756 break; 4757 } 4758 4759 i++; 4760 } // 2. sync from end 4761 // a (b c) 4762 // d e (b c) 4763 4764 4765 while (i <= e1 && i <= e2) { 4766 const n1 = c1[e1]; 4767 const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]); 4768 4769 if (isSameVNodeType(n1, n2)) { 4770 patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4771 } else { 4772 break; 4773 } 4774 4775 e1--; 4776 e2--; 4777 } // 3. common sequence + mount 4778 // (a b) 4779 // (a b) c 4780 // i = 2, e1 = 1, e2 = 2 4781 // (a b) 4782 // c (a b) 4783 // i = 0, e1 = -1, e2 = 0 4784 4785 4786 if (i > e1) { 4787 if (i <= e2) { 4788 const nextPos = e2 + 1; 4789 const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor; 4790 4791 while (i <= e2) { 4792 patch(null, c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4793 i++; 4794 } 4795 } 4796 } // 4. common sequence + unmount 4797 // (a b) c 4798 // (a b) 4799 // i = 2, e1 = 2, e2 = 1 4800 // a (b c) 4801 // (b c) 4802 // i = 0, e1 = 0, e2 = -1 4803 else if (i > e2) { 4804 while (i <= e1) { 4805 unmount(c1[i], parentComponent, parentSuspense, true); 4806 i++; 4807 } 4808 } // 5. unknown sequence 4809 // [i ... e1 + 1]: a b [c d e] f g 4810 // [i ... e2 + 1]: a b [e d c h] f g 4811 // i = 2, e1 = 4, e2 = 5 4812 else { 4813 const s1 = i; // prev starting index 4814 4815 const s2 = i; // next starting index 4816 // 5.1 build key:index map for newChildren 4817 4818 const keyToNewIndexMap = new Map(); 4819 4820 for (i = s2; i <= e2; i++) { 4821 const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); 4822 4823 if (nextChild.key != null) { 4824 4825 keyToNewIndexMap.set(nextChild.key, i); 4826 } 4827 } // 5.2 loop through old children left to be patched and try to patch 4828 // matching nodes & remove nodes that are no longer present 4829 4830 4831 let j; 4832 let patched = 0; 4833 const toBePatched = e2 - s2 + 1; 4834 let moved = false; // used to track whether any node has moved 4835 4836 let maxNewIndexSoFar = 0; // works as Map<newIndex, oldIndex> 4837 // Note that oldIndex is offset by +1 4838 // and oldIndex = 0 is a special value indicating the new node has 4839 // no corresponding old node. 4840 // used for determining longest stable subsequence 4841 4842 const newIndexToOldIndexMap = new Array(toBePatched); 4843 4844 for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0; 4845 4846 for (i = s1; i <= e1; i++) { 4847 const prevChild = c1[i]; 4848 4849 if (patched >= toBePatched) { 4850 // all new children have been patched so this can only be a removal 4851 unmount(prevChild, parentComponent, parentSuspense, true); 4852 continue; 4853 } 4854 4855 let newIndex; 4856 4857 if (prevChild.key != null) { 4858 newIndex = keyToNewIndexMap.get(prevChild.key); 4859 } else { 4860 // key-less node, try to locate a key-less node of the same type 4861 for (j = s2; j <= e2; j++) { 4862 if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) { 4863 newIndex = j; 4864 break; 4865 } 4866 } 4867 } 4868 4869 if (newIndex === undefined) { 4870 unmount(prevChild, parentComponent, parentSuspense, true); 4871 } else { 4872 newIndexToOldIndexMap[newIndex - s2] = i + 1; 4873 4874 if (newIndex >= maxNewIndexSoFar) { 4875 maxNewIndexSoFar = newIndex; 4876 } else { 4877 moved = true; 4878 } 4879 4880 patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4881 patched++; 4882 } 4883 } // 5.3 move and mount 4884 // generate longest stable subsequence only when nodes have moved 4885 4886 4887 const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR; 4888 j = increasingNewIndexSequence.length - 1; // looping backwards so that we can use last patched node as anchor 4889 4890 for (i = toBePatched - 1; i >= 0; i--) { 4891 const nextIndex = s2 + i; 4892 const nextChild = c2[nextIndex]; 4893 const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor; 4894 4895 if (newIndexToOldIndexMap[i] === 0) { 4896 // mount new 4897 patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); 4898 } else if (moved) { 4899 // move if: 4900 // There is no stable subsequence (e.g. a reverse) 4901 // OR current node is not among the stable sequence 4902 if (j < 0 || i !== increasingNewIndexSequence[j]) { 4903 move(nextChild, container, anchor, 2 4904 /* REORDER */ 4905 ); 4906 } else { 4907 j--; 4908 } 4909 } 4910 } 4911 } 4912 }; 4913 4914 const move = function (vnode, container, anchor, moveType, parentSuspense) { 4915 if (parentSuspense === void 0) { 4916 parentSuspense = null; 4917 } 4918 4919 const { 4920 el, 4921 type, 4922 transition, 4923 children, 4924 shapeFlag 4925 } = vnode; 4926 4927 if (shapeFlag & 6 4928 /* COMPONENT */ 4929 ) { 4930 move(vnode.component.subTree, container, anchor, moveType); 4931 return; 4932 } 4933 4934 if (shapeFlag & 128 4935 /* SUSPENSE */ 4936 ) { 4937 vnode.suspense.move(container, anchor, moveType); 4938 return; 4939 } 4940 4941 if (shapeFlag & 64 4942 /* TELEPORT */ 4943 ) { 4944 type.move(vnode, container, anchor, internals); 4945 return; 4946 } 4947 4948 if (type === Fragment) { 4949 hostInsert(el, container, anchor); 4950 4951 for (let i = 0; i < children.length; i++) { 4952 move(children[i], container, anchor, moveType); 4953 } 4954 4955 hostInsert(vnode.anchor, container, anchor); 4956 return; 4957 } 4958 4959 if (type === Static) { 4960 moveStaticNode(vnode, container, anchor); 4961 return; 4962 } // single nodes 4963 4964 4965 const needTransition = moveType !== 2 4966 /* REORDER */ 4967 && shapeFlag & 1 4968 /* ELEMENT */ 4969 && transition; 4970 4971 if (needTransition) { 4972 if (moveType === 0 4973 /* ENTER */ 4974 ) { 4975 transition.beforeEnter(el); 4976 hostInsert(el, container, anchor); 4977 queuePostRenderEffect(() => transition.enter(el), parentSuspense); 4978 } else { 4979 const { 4980 leave, 4981 delayLeave, 4982 afterLeave 4983 } = transition; 4984 4985 const remove = () => hostInsert(el, container, anchor); 4986 4987 const performLeave = () => { 4988 leave(el, () => { 4989 remove(); 4990 afterLeave && afterLeave(); 4991 }); 4992 }; 4993 4994 if (delayLeave) { 4995 delayLeave(el, remove, performLeave); 4996 } else { 4997 performLeave(); 4998 } 4999 } 5000 } else { 5001 hostInsert(el, container, anchor); 5002 } 5003 }; 5004 5005 const unmount = function (vnode, parentComponent, parentSuspense, doRemove, optimized) { 5006 if (doRemove === void 0) { 5007 doRemove = false; 5008 } 5009 5010 if (optimized === void 0) { 5011 optimized = false; 5012 } 5013 5014 const { 5015 type, 5016 props, 5017 ref, 5018 children, 5019 dynamicChildren, 5020 shapeFlag, 5021 patchFlag, 5022 dirs 5023 } = vnode; // unset ref 5024 5025 if (ref != null) { 5026 setRef(ref, null, parentSuspense, vnode, true); 5027 } 5028 5029 if (shapeFlag & 256 5030 /* COMPONENT_SHOULD_KEEP_ALIVE */ 5031 ) { 5032 parentComponent.ctx.deactivate(vnode); 5033 return; 5034 } 5035 5036 const shouldInvokeDirs = shapeFlag & 1 5037 /* ELEMENT */ 5038 && dirs; 5039 const shouldInvokeVnodeHook = !isAsyncWrapper(vnode); 5040 let vnodeHook; 5041 5042 if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) { 5043 invokeVNodeHook(vnodeHook, parentComponent, vnode); 5044 } 5045 5046 if (shapeFlag & 6 5047 /* COMPONENT */ 5048 ) { 5049 unmountComponent(vnode.component, parentSuspense, doRemove); 5050 } else { 5051 if (shapeFlag & 128 5052 /* SUSPENSE */ 5053 ) { 5054 vnode.suspense.unmount(parentSuspense, doRemove); 5055 return; 5056 } 5057 5058 if (shouldInvokeDirs) { 5059 invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount'); 5060 } 5061 5062 if (shapeFlag & 64 5063 /* TELEPORT */ 5064 ) { 5065 vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove); 5066 } else if (dynamicChildren && ( // #1153: fast path should not be taken for non-stable (v-for) fragments 5067 type !== Fragment || patchFlag > 0 && patchFlag & 64 5068 /* STABLE_FRAGMENT */ 5069 )) { 5070 // fast path for block nodes: only need to unmount dynamic children. 5071 unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true); 5072 } else if (type === Fragment && patchFlag & (128 5073 /* KEYED_FRAGMENT */ 5074 | 256 5075 /* UNKEYED_FRAGMENT */ 5076 ) || !optimized && shapeFlag & 16 5077 /* ARRAY_CHILDREN */ 5078 ) { 5079 unmountChildren(children, parentComponent, parentSuspense); 5080 } 5081 5082 if (doRemove) { 5083 remove(vnode); 5084 } 5085 } 5086 5087 if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) { 5088 queuePostRenderEffect(() => { 5089 vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode); 5090 shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, 'unmounted'); 5091 }, parentSuspense); 5092 } 5093 }; 5094 5095 const remove = vnode => { 5096 const { 5097 type, 5098 el, 5099 anchor, 5100 transition 5101 } = vnode; 5102 5103 if (type === Fragment) { 5104 removeFragment(el, anchor); 5105 return; 5106 } 5107 5108 if (type === Static) { 5109 removeStaticNode(vnode); 5110 return; 5111 } 5112 5113 const performRemove = () => { 5114 hostRemove(el); 5115 5116 if (transition && !transition.persisted && transition.afterLeave) { 5117 transition.afterLeave(); 5118 } 5119 }; 5120 5121 if (vnode.shapeFlag & 1 5122 /* ELEMENT */ 5123 && transition && !transition.persisted) { 5124 const { 5125 leave, 5126 delayLeave 5127 } = transition; 5128 5129 const performLeave = () => leave(el, performRemove); 5130 5131 if (delayLeave) { 5132 delayLeave(vnode.el, performRemove, performLeave); 5133 } else { 5134 performLeave(); 5135 } 5136 } else { 5137 performRemove(); 5138 } 5139 }; 5140 5141 const removeFragment = (cur, end) => { 5142 // For fragments, directly remove all contained DOM nodes. 5143 // (fragment child nodes cannot have transition) 5144 let next; 5145 5146 while (cur !== end) { 5147 next = hostNextSibling(cur); 5148 hostRemove(cur); 5149 cur = next; 5150 } 5151 5152 hostRemove(end); 5153 }; 5154 5155 const unmountComponent = (instance, parentSuspense, doRemove) => { 5156 5157 const { 5158 bum, 5159 scope, 5160 update, 5161 subTree, 5162 um 5163 } = instance; // beforeUnmount hook 5164 5165 if (bum) { 5166 invokeArrayFns(bum); 5167 } // stop effects in component scope 5168 5169 5170 scope.stop(); // update may be null if a component is unmounted before its async 5171 // setup has resolved. 5172 5173 if (update) { 5174 // so that scheduler will no longer invoke it 5175 update.active = false; 5176 unmount(subTree, instance, parentSuspense, doRemove); 5177 } // unmounted hook 5178 5179 5180 if (um) { 5181 queuePostRenderEffect(um, parentSuspense); 5182 } 5183 5184 queuePostRenderEffect(() => { 5185 instance.isUnmounted = true; 5186 }, parentSuspense); // A component with async dep inside a pending suspense is unmounted before 5187 // its async dep resolves. This should remove the dep from the suspense, and 5188 // cause the suspense to resolve immediately if that was the last dep. 5189 5190 if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) { 5191 parentSuspense.deps--; 5192 5193 if (parentSuspense.deps === 0) { 5194 parentSuspense.resolve(); 5195 } 5196 } 5197 5198 if (__VUE_PROD_DEVTOOLS__) { 5199 devtoolsComponentRemoved(instance); 5200 } 5201 }; 5202 5203 const unmountChildren = function (children, parentComponent, parentSuspense, doRemove, optimized, start) { 5204 if (doRemove === void 0) { 5205 doRemove = false; 5206 } 5207 5208 if (optimized === void 0) { 5209 optimized = false; 5210 } 5211 5212 if (start === void 0) { 5213 start = 0; 5214 } 5215 5216 for (let i = start; i < children.length; i++) { 5217 unmount(children[i], parentComponent, parentSuspense, doRemove, optimized); 5218 } 5219 }; 5220 5221 const getNextHostNode = vnode => { 5222 if (vnode.shapeFlag & 6 5223 /* COMPONENT */ 5224 ) { 5225 return getNextHostNode(vnode.component.subTree); 5226 } 5227 5228 if (vnode.shapeFlag & 128 5229 /* SUSPENSE */ 5230 ) { 5231 return vnode.suspense.next(); 5232 } 5233 5234 return hostNextSibling(vnode.anchor || vnode.el); 5235 }; 5236 5237 const render = (vnode, container, isSVG) => { 5238 if (vnode == null) { 5239 if (container._vnode) { 5240 unmount(container._vnode, null, null, true); 5241 } 5242 } else { 5243 patch(container._vnode || null, vnode, container, null, null, null, isSVG); 5244 } 5245 5246 flushPostFlushCbs(); 5247 container._vnode = vnode; 5248 }; 5249 5250 const internals = { 5251 p: patch, 5252 um: unmount, 5253 m: move, 5254 r: remove, 5255 mt: mountComponent, 5256 mc: mountChildren, 5257 pc: patchChildren, 5258 pbc: patchBlockChildren, 5259 n: getNextHostNode, 5260 o: options 5261 }; 5262 let hydrate; 5263 let hydrateNode; 5264 5265 if (createHydrationFns) { 5266 [hydrate, hydrateNode] = createHydrationFns(internals); 5267 } 5268 5269 return { 5270 render, 5271 hydrate, 5272 createApp: createAppAPI(render, hydrate) 5273 }; 5274 } 5275 5276 function toggleRecurse(_ref10, allowed) { 5277 let { 5278 effect, 5279 update 5280 } = _ref10; 5281 effect.allowRecurse = update.allowRecurse = allowed; 5282 } 5283 /** 5284 * #1156 5285 * When a component is HMR-enabled, we need to make sure that all static nodes 5286 * inside a block also inherit the DOM element from the previous tree so that 5287 * HMR updates (which are full updates) can retrieve the element for patching. 5288 * 5289 * #2080 5290 * Inside keyed `template` fragment static children, if a fragment is moved, 5291 * the children will always be moved. Therefore, in order to ensure correct move 5292 * position, el should be inherited from previous nodes. 5293 */ 5294 5295 5296 function traverseStaticChildren(n1, n2, shallow) { 5297 if (shallow === void 0) { 5298 shallow = false; 5299 } 5300 5301 const ch1 = n1.children; 5302 const ch2 = n2.children; 5303 5304 if (isArray(ch1) && isArray(ch2)) { 5305 for (let i = 0; i < ch1.length; i++) { 5306 // this is only called in the optimized path so array children are 5307 // guaranteed to be vnodes 5308 const c1 = ch1[i]; 5309 let c2 = ch2[i]; 5310 5311 if (c2.shapeFlag & 1 5312 /* ELEMENT */ 5313 && !c2.dynamicChildren) { 5314 if (c2.patchFlag <= 0 || c2.patchFlag === 32 5315 /* HYDRATE_EVENTS */ 5316 ) { 5317 c2 = ch2[i] = cloneIfMounted(ch2[i]); 5318 c2.el = c1.el; 5319 } 5320 5321 if (!shallow) traverseStaticChildren(c1, c2); 5322 } // also inherit for comment nodes, but not placeholders (e.g. v-if which 5323 } 5324 } 5325 } // https://en.wikipedia.org/wiki/Longest_increasing_subsequence 5326 5327 5328 function getSequence(arr) { 5329 const p = arr.slice(); 5330 const result = [0]; 5331 let i, j, u, v, c; 5332 const len = arr.length; 5333 5334 for (i = 0; i < len; i++) { 5335 const arrI = arr[i]; 5336 5337 if (arrI !== 0) { 5338 j = result[result.length - 1]; 5339 5340 if (arr[j] < arrI) { 5341 p[i] = j; 5342 result.push(i); 5343 continue; 5344 } 5345 5346 u = 0; 5347 v = result.length - 1; 5348 5349 while (u < v) { 5350 c = u + v >> 1; 5351 5352 if (arr[result[c]] < arrI) { 5353 u = c + 1; 5354 } else { 5355 v = c; 5356 } 5357 } 5358 5359 if (arrI < arr[result[u]]) { 5360 if (u > 0) { 5361 p[i] = result[u - 1]; 5362 } 5363 5364 result[u] = i; 5365 } 5366 } 5367 } 5368 5369 u = result.length; 5370 v = result[u - 1]; 5371 5372 while (u-- > 0) { 5373 result[u] = v; 5374 v = p[v]; 5375 } 5376 5377 return result; 5378 } 5379 5380 const isTeleport = type => type.__isTeleport; 5381 const COMPONENTS = 'components'; 5382 /** 5383 * @private 5384 */ 5385 5386 function resolveComponent(name, maybeSelfReference) { 5387 return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name; 5388 } 5389 5390 const NULL_DYNAMIC_COMPONENT = Symbol(); 5391 5392 5393 function resolveAsset(type, name, warnMissing, maybeSelfReference) { 5394 5395 if (maybeSelfReference === void 0) { 5396 maybeSelfReference = false; 5397 } 5398 5399 const instance = currentRenderingInstance || currentInstance; 5400 5401 if (instance) { 5402 const Component = instance.type; // explicit self name has highest priority 5403 5404 if (type === COMPONENTS) { 5405 const selfName = getComponentName(Component); 5406 5407 if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) { 5408 return Component; 5409 } 5410 } 5411 5412 const res = // local registration 5413 // check instance[type] first which is resolved for options API 5414 resolve(instance[type] || Component[type], name) || // global registration 5415 resolve(instance.appContext[type], name); 5416 5417 if (!res && maybeSelfReference) { 5418 // fallback to implicit self-reference 5419 return Component; 5420 } 5421 5422 return res; 5423 } 5424 } 5425 5426 function resolve(registry, name) { 5427 return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]); 5428 } 5429 5430 const Fragment = Symbol(undefined); 5431 const Text = Symbol(undefined); 5432 const Comment = Symbol(undefined); 5433 const Static = Symbol(undefined); // Since v-if and v-for are the two possible ways node structure can dynamically 5434 // change, once we consider v-if branches and each v-for fragment a block, we 5435 // can divide a template into nested blocks, and within each block the node 5436 // structure would be stable. This allows us to skip most children diffing 5437 // and only worry about the dynamic nodes (indicated by patch flags). 5438 5439 const blockStack = []; 5440 let currentBlock = null; 5441 /** 5442 * Open a block. 5443 * This must be called before `createBlock`. It cannot be part of `createBlock` 5444 * because the children of the block are evaluated before `createBlock` itself 5445 * is called. The generated code typically looks like this: 5446 * 5447 * ```js 5448 * function render() { 5449 * return (openBlock(),createBlock('div', null, [...])) 5450 * } 5451 * ``` 5452 * disableTracking is true when creating a v-for fragment block, since a v-for 5453 * fragment always diffs its children. 5454 * 5455 * @private 5456 */ 5457 5458 function openBlock(disableTracking) { 5459 if (disableTracking === void 0) { 5460 disableTracking = false; 5461 } 5462 5463 blockStack.push(currentBlock = disableTracking ? null : []); 5464 } 5465 5466 function closeBlock() { 5467 blockStack.pop(); 5468 currentBlock = blockStack[blockStack.length - 1] || null; 5469 } // Whether we should be tracking dynamic child nodes inside a block. 5470 // Only tracks when this value is > 0 5471 // We are not using a simple boolean because this value may need to be 5472 // incremented/decremented by nested usage of v-once (see below) 5473 5474 5475 let isBlockTreeEnabled = 1; 5476 /** 5477 * Block tracking sometimes needs to be disabled, for example during the 5478 * creation of a tree that needs to be cached by v-once. The compiler generates 5479 * code like this: 5480 * 5481 * ``` js 5482 * _cache[1] || ( 5483 * setBlockTracking(-1), 5484 * _cache[1] = createVNode(...), 5485 * setBlockTracking(1), 5486 * _cache[1] 5487 * ) 5488 * ``` 5489 * 5490 * @private 5491 */ 5492 5493 function setBlockTracking(value) { 5494 isBlockTreeEnabled += value; 5495 } 5496 5497 function setupBlock(vnode) { 5498 // save current block children on the block vnode 5499 vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null; // close block 5500 5501 closeBlock(); // a block is always going to be patched, so track it as a child of its 5502 // parent block 5503 5504 if (isBlockTreeEnabled > 0 && currentBlock) { 5505 currentBlock.push(vnode); 5506 } 5507 5508 return vnode; 5509 } 5510 /** 5511 * @private 5512 */ 5513 5514 5515 function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) { 5516 return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true 5517 /* isBlock */ 5518 )); 5519 } 5520 /** 5521 * Create a block root vnode. Takes the same exact arguments as `createVNode`. 5522 * A block root keeps track of dynamic nodes within the block in the 5523 * `dynamicChildren` array. 5524 * 5525 * @private 5526 */ 5527 5528 5529 function createBlock(type, props, children, patchFlag, dynamicProps) { 5530 return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true 5531 /* isBlock: prevent a block from tracking itself */ 5532 )); 5533 } 5534 5535 function isVNode(value) { 5536 return value ? value.__v_isVNode === true : false; 5537 } 5538 5539 function isSameVNodeType(n1, n2) { 5540 5541 return n1.type === n2.type && n1.key === n2.key; 5542 } 5543 5544 const InternalObjectKey = `__vInternal`; 5545 5546 const normalizeKey = _ref14 => { 5547 let { 5548 key 5549 } = _ref14; 5550 return key != null ? key : null; 5551 }; 5552 5553 const normalizeRef = _ref15 => { 5554 let { 5555 ref, 5556 ref_key, 5557 ref_for 5558 } = _ref15; 5559 return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { 5560 i: currentRenderingInstance, 5561 r: ref, 5562 k: ref_key, 5563 f: !!ref_for 5564 } : ref : null; 5565 }; 5566 5567 function createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag 5568 /* ELEMENT */ 5569 , isBlockNode, needFullChildrenNormalization) { 5570 if (props === void 0) { 5571 props = null; 5572 } 5573 5574 if (children === void 0) { 5575 children = null; 5576 } 5577 5578 if (patchFlag === void 0) { 5579 patchFlag = 0; 5580 } 5581 5582 if (dynamicProps === void 0) { 5583 dynamicProps = null; 5584 } 5585 5586 if (shapeFlag === void 0) { 5587 shapeFlag = type === Fragment ? 0 : 1; 5588 } 5589 5590 if (isBlockNode === void 0) { 5591 isBlockNode = false; 5592 } 5593 5594 if (needFullChildrenNormalization === void 0) { 5595 needFullChildrenNormalization = false; 5596 } 5597 5598 const vnode = { 5599 __v_isVNode: true, 5600 __v_skip: true, 5601 type, 5602 props, 5603 key: props && normalizeKey(props), 5604 ref: props && normalizeRef(props), 5605 scopeId: currentScopeId, 5606 slotScopeIds: null, 5607 children, 5608 component: null, 5609 suspense: null, 5610 ssContent: null, 5611 ssFallback: null, 5612 dirs: null, 5613 transition: null, 5614 el: null, 5615 anchor: null, 5616 target: null, 5617 targetAnchor: null, 5618 staticCount: 0, 5619 shapeFlag, 5620 patchFlag, 5621 dynamicProps, 5622 dynamicChildren: null, 5623 appContext: null 5624 }; 5625 5626 if (needFullChildrenNormalization) { 5627 normalizeChildren(vnode, children); // normalize suspense children 5628 5629 if (shapeFlag & 128 5630 /* SUSPENSE */ 5631 ) { 5632 type.normalize(vnode); 5633 } 5634 } else if (children) { 5635 // compiled element vnode - if children is passed, only possible types are 5636 // string or Array. 5637 vnode.shapeFlag |= isString(children) ? 8 5638 /* TEXT_CHILDREN */ 5639 : 16 5640 /* ARRAY_CHILDREN */ 5641 ; 5642 } // validate key 5643 5644 5645 if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself 5646 !isBlockNode && // has current parent block 5647 currentBlock && ( // presence of a patch flag indicates this node needs patching on updates. 5648 // component nodes also should always be patched, because even if the 5649 // component doesn't need to update, it needs to persist the instance on to 5650 // the next vnode so that it can be properly unmounted later. 5651 vnode.patchFlag > 0 || shapeFlag & 6 5652 /* COMPONENT */ 5653 ) && // the EVENTS flag is only for hydration and if it is the only flag, the 5654 // vnode should not be considered dynamic due to handler caching. 5655 vnode.patchFlag !== 32 5656 /* HYDRATE_EVENTS */ 5657 ) { 5658 currentBlock.push(vnode); 5659 } 5660 5661 return vnode; 5662 } 5663 5664 const createVNode = _createVNode; 5665 5666 function _createVNode(type, props, children, patchFlag, dynamicProps, isBlockNode) { 5667 if (props === void 0) { 5668 props = null; 5669 } 5670 5671 if (children === void 0) { 5672 children = null; 5673 } 5674 5675 if (patchFlag === void 0) { 5676 patchFlag = 0; 5677 } 5678 5679 if (dynamicProps === void 0) { 5680 dynamicProps = null; 5681 } 5682 5683 if (isBlockNode === void 0) { 5684 isBlockNode = false; 5685 } 5686 5687 if (!type || type === NULL_DYNAMIC_COMPONENT) { 5688 5689 type = Comment; 5690 } 5691 5692 if (isVNode(type)) { 5693 // createVNode receiving an existing vnode. This happens in cases like 5694 // <component :is="vnode"/> 5695 // #2078 make sure to merge refs during the clone instead of overwriting it 5696 const cloned = cloneVNode(type, props, true 5697 /* mergeRef: true */ 5698 ); 5699 5700 if (children) { 5701 normalizeChildren(cloned, children); 5702 } 5703 5704 return cloned; 5705 } // class component normalization. 5706 5707 5708 if (isClassComponent(type)) { 5709 type = type.__vccOpts; 5710 } // class & style normalization. 5711 5712 5713 if (props) { 5714 // for reactive or proxy objects, we need to clone it to enable mutation. 5715 props = guardReactiveProps(props); 5716 let { 5717 class: klass, 5718 style 5719 } = props; 5720 5721 if (klass && !isString(klass)) { 5722 props.class = normalizeClass(klass); 5723 } 5724 5725 if (isObject$1(style)) { 5726 // reactive state objects need to be cloned since they are likely to be 5727 // mutated 5728 if (isProxy(style) && !isArray(style)) { 5729 style = extend({}, style); 5730 } 5731 5732 props.style = normalizeStyle(style); 5733 } 5734 } // encode the vnode type information into a bitmap 5735 5736 5737 const shapeFlag = isString(type) ? 1 5738 /* ELEMENT */ 5739 : isSuspense(type) ? 128 5740 /* SUSPENSE */ 5741 : isTeleport(type) ? 64 5742 /* TELEPORT */ 5743 : isObject$1(type) ? 4 5744 /* STATEFUL_COMPONENT */ 5745 : isFunction(type) ? 2 5746 /* FUNCTIONAL_COMPONENT */ 5747 : 0; 5748 5749 return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true); 5750 } 5751 5752 function guardReactiveProps(props) { 5753 if (!props) return null; 5754 return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props; 5755 } 5756 5757 function cloneVNode(vnode, extraProps, mergeRef) { 5758 if (mergeRef === void 0) { 5759 mergeRef = false; 5760 } 5761 5762 // This is intentionally NOT using spread or extend to avoid the runtime 5763 // key enumeration cost. 5764 const { 5765 props, 5766 ref, 5767 patchFlag, 5768 children 5769 } = vnode; 5770 const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props; 5771 const cloned = { 5772 __v_isVNode: true, 5773 __v_skip: true, 5774 type: vnode.type, 5775 props: mergedProps, 5776 key: mergedProps && normalizeKey(mergedProps), 5777 ref: extraProps && extraProps.ref ? // #2078 in the case of <component :is="vnode" ref="extra"/> 5778 // if the vnode itself already has a ref, cloneVNode will need to merge 5779 // the refs so the single vnode can be set on multiple refs 5780 mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps) : ref, 5781 scopeId: vnode.scopeId, 5782 slotScopeIds: vnode.slotScopeIds, 5783 children: children, 5784 target: vnode.target, 5785 targetAnchor: vnode.targetAnchor, 5786 staticCount: vnode.staticCount, 5787 shapeFlag: vnode.shapeFlag, 5788 // if the vnode is cloned with extra props, we can no longer assume its 5789 // existing patch flag to be reliable and need to add the FULL_PROPS flag. 5790 // note: perserve flag for fragments since they use the flag for children 5791 // fast paths only. 5792 patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 // hoisted node 5793 ? 16 5794 /* FULL_PROPS */ 5795 : patchFlag | 16 5796 /* FULL_PROPS */ 5797 : patchFlag, 5798 dynamicProps: vnode.dynamicProps, 5799 dynamicChildren: vnode.dynamicChildren, 5800 appContext: vnode.appContext, 5801 dirs: vnode.dirs, 5802 transition: vnode.transition, 5803 // These should technically only be non-null on mounted VNodes. However, 5804 // they *should* be copied for kept-alive vnodes. So we just always copy 5805 // them since them being non-null during a mount doesn't affect the logic as 5806 // they will simply be overwritten. 5807 component: vnode.component, 5808 suspense: vnode.suspense, 5809 ssContent: vnode.ssContent && cloneVNode(vnode.ssContent), 5810 ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback), 5811 el: vnode.el, 5812 anchor: vnode.anchor 5813 }; 5814 return cloned; 5815 } 5816 /** 5817 * @private 5818 */ 5819 5820 5821 function createTextVNode(text, flag) { 5822 if (text === void 0) { 5823 text = ' '; 5824 } 5825 5826 if (flag === void 0) { 5827 flag = 0; 5828 } 5829 5830 return createVNode(Text, null, text, flag); 5831 } 5832 /** 5833 * @private 5834 */ 5835 5836 5837 function createCommentVNode(text, // when used as the v-else branch, the comment node must be created as a 5838 // block to ensure correct updates. 5839 asBlock) { 5840 if (text === void 0) { 5841 text = ''; 5842 } 5843 5844 if (asBlock === void 0) { 5845 asBlock = false; 5846 } 5847 5848 return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text); 5849 } 5850 5851 function normalizeVNode(child) { 5852 if (child == null || typeof child === 'boolean') { 5853 // empty placeholder 5854 return createVNode(Comment); 5855 } else if (isArray(child)) { 5856 // fragment 5857 return createVNode(Fragment, null, // #3666, avoid reference pollution when reusing vnode 5858 child.slice()); 5859 } else if (typeof child === 'object') { 5860 // already vnode, this should be the most common since compiled templates 5861 // always produce all-vnode children arrays 5862 return cloneIfMounted(child); 5863 } else { 5864 // strings and numbers 5865 return createVNode(Text, null, String(child)); 5866 } 5867 } // optimized normalization for template-compiled render fns 5868 5869 5870 function cloneIfMounted(child) { 5871 return child.el === null || child.memo ? child : cloneVNode(child); 5872 } 5873 5874 function normalizeChildren(vnode, children) { 5875 let type = 0; 5876 const { 5877 shapeFlag 5878 } = vnode; 5879 5880 if (children == null) { 5881 children = null; 5882 } else if (isArray(children)) { 5883 type = 16 5884 /* ARRAY_CHILDREN */ 5885 ; 5886 } else if (typeof children === 'object') { 5887 if (shapeFlag & (1 5888 /* ELEMENT */ 5889 | 64 5890 /* TELEPORT */ 5891 )) { 5892 // Normalize slot to plain children for plain element and Teleport 5893 const slot = children.default; 5894 5895 if (slot) { 5896 // _c marker is added by withCtx() indicating this is a compiled slot 5897 slot._c && (slot._d = false); 5898 normalizeChildren(vnode, slot()); 5899 slot._c && (slot._d = true); 5900 } 5901 5902 return; 5903 } else { 5904 type = 32 5905 /* SLOTS_CHILDREN */ 5906 ; 5907 const slotFlag = children._; 5908 5909 if (!slotFlag && !(InternalObjectKey in children)) { 5910 children._ctx = currentRenderingInstance; 5911 } else if (slotFlag === 3 5912 /* FORWARDED */ 5913 && currentRenderingInstance) { 5914 // a child component receives forwarded slots from the parent. 5915 // its slot type is determined by its parent's slot type. 5916 if (currentRenderingInstance.slots._ === 1 5917 /* STABLE */ 5918 ) { 5919 children._ = 1 5920 /* STABLE */ 5921 ; 5922 } else { 5923 children._ = 2 5924 /* DYNAMIC */ 5925 ; 5926 vnode.patchFlag |= 1024 5927 /* DYNAMIC_SLOTS */ 5928 ; 5929 } 5930 } 5931 } 5932 } else if (isFunction(children)) { 5933 children = { 5934 default: children, 5935 _ctx: currentRenderingInstance 5936 }; 5937 type = 32 5938 /* SLOTS_CHILDREN */ 5939 ; 5940 } else { 5941 children = String(children); // force teleport children to array so it can be moved around 5942 5943 if (shapeFlag & 64 5944 /* TELEPORT */ 5945 ) { 5946 type = 16 5947 /* ARRAY_CHILDREN */ 5948 ; 5949 children = [createTextVNode(children)]; 5950 } else { 5951 type = 8 5952 /* TEXT_CHILDREN */ 5953 ; 5954 } 5955 } 5956 5957 vnode.children = children; 5958 vnode.shapeFlag |= type; 5959 } 5960 5961 function mergeProps() { 5962 const ret = {}; 5963 5964 for (let i = 0; i < arguments.length; i++) { 5965 const toMerge = i < 0 || arguments.length <= i ? undefined : arguments[i]; 5966 5967 for (const key in toMerge) { 5968 if (key === 'class') { 5969 if (ret.class !== toMerge.class) { 5970 ret.class = normalizeClass([ret.class, toMerge.class]); 5971 } 5972 } else if (key === 'style') { 5973 ret.style = normalizeStyle([ret.style, toMerge.style]); 5974 } else if (isOn(key)) { 5975 const existing = ret[key]; 5976 const incoming = toMerge[key]; 5977 5978 if (existing !== incoming && !(isArray(existing) && existing.includes(incoming))) { 5979 ret[key] = existing ? [].concat(existing, incoming) : incoming; 5980 } 5981 } else if (key !== '') { 5982 ret[key] = toMerge[key]; 5983 } 5984 } 5985 } 5986 5987 return ret; 5988 } 5989 5990 function invokeVNodeHook(hook, instance, vnode, prevVNode) { 5991 if (prevVNode === void 0) { 5992 prevVNode = null; 5993 } 5994 5995 callWithAsyncErrorHandling(hook, instance, 7 5996 /* VNODE_HOOK */ 5997 , [vnode, prevVNode]); 5998 } 5999 /** 6000 * Actual implementation 6001 */ 6002 6003 6004 function renderList(source, renderItem, cache, index) { 6005 let ret; 6006 const cached = cache && cache[index]; 6007 6008 if (isArray(source) || isString(source)) { 6009 ret = new Array(source.length); 6010 6011 for (let i = 0, l = source.length; i < l; i++) { 6012 ret[i] = renderItem(source[i], i, undefined, cached && cached[i]); 6013 } 6014 } else if (typeof source === 'number') { 6015 6016 ret = new Array(source); 6017 6018 for (let i = 0; i < source; i++) { 6019 ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]); 6020 } 6021 } else if (isObject$1(source)) { 6022 if (source[Symbol.iterator]) { 6023 ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i])); 6024 } else { 6025 const keys = Object.keys(source); 6026 ret = new Array(keys.length); 6027 6028 for (let i = 0, l = keys.length; i < l; i++) { 6029 const key = keys[i]; 6030 ret[i] = renderItem(source[key], key, i, cached && cached[i]); 6031 } 6032 } 6033 } else { 6034 ret = []; 6035 } 6036 6037 if (cache) { 6038 cache[index] = ret; 6039 } 6040 6041 return ret; 6042 } 6043 /** 6044 * Compiler runtime helper for rendering `<slot/>` 6045 * @private 6046 */ 6047 6048 6049 function renderSlot(slots, name, props, // this is not a user-facing function, so the fallback is always generated by 6050 // the compiler and guaranteed to be a function returning an array 6051 fallback, noSlotted) { 6052 if (props === void 0) { 6053 props = {}; 6054 } 6055 6056 if (currentRenderingInstance.isCE) { 6057 return createVNode('slot', name === 'default' ? null : { 6058 name 6059 }, fallback && fallback()); 6060 } 6061 6062 let slot = slots[name]; 6063 // invocation interfering with template-based block tracking, but in 6064 // `renderSlot` we can be sure that it's template-based so we can force 6065 // enable it. 6066 6067 6068 if (slot && slot._c) { 6069 slot._d = false; 6070 } 6071 6072 openBlock(); 6073 const validSlotContent = slot && ensureValidVNode(slot(props)); 6074 const rendered = createBlock(Fragment, { 6075 key: props.key || `_$name}` 6076 }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 6077 /* STABLE */ 6078 ? 64 6079 /* STABLE_FRAGMENT */ 6080 : -2 6081 /* BAIL */ 6082 ); 6083 6084 if (!noSlotted && rendered.scopeId) { 6085 rendered.slotScopeIds = [rendered.scopeId + '-s']; 6086 } 6087 6088 if (slot && slot._c) { 6089 slot._d = true; 6090 } 6091 6092 return rendered; 6093 } 6094 6095 function ensureValidVNode(vnodes) { 6096 return vnodes.some(child => { 6097 if (!isVNode(child)) return true; 6098 if (child.type === Comment) return false; 6099 if (child.type === Fragment && !ensureValidVNode(child.children)) return false; 6100 return true; 6101 }) ? vnodes : null; 6102 } 6103 /** 6104 * #2437 In Vue 3, functional components do not have a public instance proxy but 6105 * they exist in the internal parent chain. For code that relies on traversing 6106 * public $parent chains, skip functional ones and go to the parent instead. 6107 */ 6108 6109 6110 const getPublicInstance = i => { 6111 if (!i) return null; 6112 if (isStatefulComponent(i)) return getExposeProxy(i) || i.proxy; 6113 return getPublicInstance(i.parent); 6114 }; 6115 6116 const publicPropertiesMap = extend(Object.create(null), { 6117 $: i => i, 6118 $el: i => i.vnode.el, 6119 $data: i => i.data, 6120 $props: i => i.props, 6121 $attrs: i => i.attrs, 6122 $slots: i => i.slots, 6123 $refs: i => i.refs, 6124 $parent: i => getPublicInstance(i.parent), 6125 $root: i => getPublicInstance(i.root), 6126 $emit: i => i.emit, 6127 $options: i => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type, 6128 $forceUpdate: i => () => queueJob(i.update), 6129 $nextTick: i => nextTick.bind(i.proxy), 6130 $watch: i => __VUE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP 6131 }); 6132 const PublicInstanceProxyHandlers = { 6133 get(_ref16, key) { 6134 let { 6135 _: instance 6136 } = _ref16; 6137 const { 6138 ctx, 6139 setupState, 6140 data, 6141 props, 6142 accessCache, 6143 type, 6144 appContext 6145 } = instance; // for internal formatters to know that this is a Vue instance 6146 // This getter gets called for every property access on the render context 6147 // during render and is a major hotspot. The most expensive part of this 6148 // is the multiple hasOwn() calls. It's much faster to do a simple property 6149 // access on a plain object, so we use an accessCache object (with null 6150 // prototype) to memoize what access type a key corresponds to. 6151 6152 6153 let normalizedProps; 6154 6155 if (key[0] !== '$') { 6156 const n = accessCache[key]; 6157 6158 if (n !== undefined) { 6159 switch (n) { 6160 case 1 6161 /* SETUP */ 6162 : 6163 return setupState[key]; 6164 6165 case 2 6166 /* DATA */ 6167 : 6168 return data[key]; 6169 6170 case 4 6171 /* CONTEXT */ 6172 : 6173 return ctx[key]; 6174 6175 case 3 6176 /* PROPS */ 6177 : 6178 return props[key]; 6179 // default: just fallthrough 6180 } 6181 } else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) { 6182 accessCache[key] = 1 6183 /* SETUP */ 6184 ; 6185 return setupState[key]; 6186 } else if (data !== EMPTY_OBJ && hasOwn(data, key)) { 6187 accessCache[key] = 2 6188 /* DATA */ 6189 ; 6190 return data[key]; 6191 } else if ( // only cache other properties when instance has declared (thus stable) 6192 // props 6193 (normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)) { 6194 accessCache[key] = 3 6195 /* PROPS */ 6196 ; 6197 return props[key]; 6198 } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { 6199 accessCache[key] = 4 6200 /* CONTEXT */ 6201 ; 6202 return ctx[key]; 6203 } else if (!__VUE_OPTIONS_API__ || shouldCacheAccess) { 6204 accessCache[key] = 0 6205 /* OTHER */ 6206 ; 6207 } 6208 } 6209 6210 const publicGetter = publicPropertiesMap[key]; 6211 let cssModule, globalProperties; // public $xxx properties 6212 6213 if (publicGetter) { 6214 if (key === '$attrs') { 6215 track(instance, "get" 6216 /* GET */ 6217 , key); 6218 } 6219 6220 return publicGetter(instance); 6221 } else if ( // css module (injected by vue-loader) 6222 (cssModule = type.__cssModules) && (cssModule = cssModule[key])) { 6223 return cssModule; 6224 } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { 6225 // user may set custom properties to `this` that start with `$` 6226 accessCache[key] = 4 6227 /* CONTEXT */ 6228 ; 6229 return ctx[key]; 6230 } else if ( // global properties 6231 globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) { 6232 { 6233 return globalProperties[key]; 6234 } 6235 } else ; 6236 }, 6237 6238 set(_ref17, key, value) { 6239 let { 6240 _: instance 6241 } = _ref17; 6242 const { 6243 data, 6244 setupState, 6245 ctx 6246 } = instance; 6247 6248 if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) { 6249 setupState[key] = value; 6250 } else if (data !== EMPTY_OBJ && hasOwn(data, key)) { 6251 data[key] = value; 6252 } else if (hasOwn(instance.props, key)) { 6253 return false; 6254 } 6255 6256 if (key[0] === '$' && key.slice(1) in instance) { 6257 return false; 6258 } else { 6259 { 6260 ctx[key] = value; 6261 } 6262 } 6263 6264 return true; 6265 }, 6266 6267 has(_ref18, key) { 6268 let { 6269 _: { 6270 data, 6271 setupState, 6272 accessCache, 6273 ctx, 6274 appContext, 6275 propsOptions 6276 } 6277 } = _ref18; 6278 let normalizedProps; 6279 return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || setupState !== EMPTY_OBJ && hasOwn(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key); 6280 } 6281 6282 }; 6283 6284 const emptyAppContext = createAppContext(); 6285 let uid$1 = 0; 6286 6287 function createComponentInstance(vnode, parent, suspense) { 6288 const type = vnode.type; // inherit parent app context - or - if root, adopt from root vnode 6289 6290 const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext; 6291 const instance = { 6292 uid: uid$1++, 6293 vnode, 6294 type, 6295 parent, 6296 appContext, 6297 root: null, 6298 next: null, 6299 subTree: null, 6300 effect: null, 6301 update: null, 6302 scope: new EffectScope(true 6303 /* detached */ 6304 ), 6305 render: null, 6306 proxy: null, 6307 exposed: null, 6308 exposeProxy: null, 6309 withProxy: null, 6310 provides: parent ? parent.provides : Object.create(appContext.provides), 6311 accessCache: null, 6312 renderCache: [], 6313 // local resovled assets 6314 components: null, 6315 directives: null, 6316 // resolved props and emits options 6317 propsOptions: normalizePropsOptions(type, appContext), 6318 emitsOptions: normalizeEmitsOptions(type, appContext), 6319 // emit 6320 emit: null, 6321 emitted: null, 6322 // props default value 6323 propsDefaults: EMPTY_OBJ, 6324 // inheritAttrs 6325 inheritAttrs: type.inheritAttrs, 6326 // state 6327 ctx: EMPTY_OBJ, 6328 data: EMPTY_OBJ, 6329 props: EMPTY_OBJ, 6330 attrs: EMPTY_OBJ, 6331 slots: EMPTY_OBJ, 6332 refs: EMPTY_OBJ, 6333 setupState: EMPTY_OBJ, 6334 setupContext: null, 6335 // suspense related 6336 suspense, 6337 suspenseId: suspense ? suspense.pendingId : 0, 6338 asyncDep: null, 6339 asyncResolved: false, 6340 // lifecycle hooks 6341 // not using enums here because it results in computed properties 6342 isMounted: false, 6343 isUnmounted: false, 6344 isDeactivated: false, 6345 bc: null, 6346 c: null, 6347 bm: null, 6348 m: null, 6349 bu: null, 6350 u: null, 6351 um: null, 6352 bum: null, 6353 da: null, 6354 a: null, 6355 rtg: null, 6356 rtc: null, 6357 ec: null, 6358 sp: null 6359 }; 6360 6361 { 6362 instance.ctx = { 6363 _: instance 6364 }; 6365 } 6366 6367 instance.root = parent ? parent.root : instance; 6368 instance.emit = emit$1.bind(null, instance); // apply custom element special handling 6369 6370 if (vnode.ce) { 6371 vnode.ce(instance); 6372 } 6373 6374 return instance; 6375 } 6376 6377 let currentInstance = null; 6378 6379 const getCurrentInstance = () => currentInstance || currentRenderingInstance; 6380 6381 const setCurrentInstance = instance => { 6382 currentInstance = instance; 6383 instance.scope.on(); 6384 }; 6385 6386 const unsetCurrentInstance = () => { 6387 currentInstance && currentInstance.scope.off(); 6388 currentInstance = null; 6389 }; 6390 6391 function isStatefulComponent(instance) { 6392 return instance.vnode.shapeFlag & 4 6393 /* STATEFUL_COMPONENT */ 6394 ; 6395 } 6396 6397 let isInSSRComponentSetup = false; 6398 6399 function setupComponent(instance, isSSR) { 6400 if (isSSR === void 0) { 6401 isSSR = false; 6402 } 6403 6404 isInSSRComponentSetup = isSSR; 6405 const { 6406 props, 6407 children 6408 } = instance.vnode; 6409 const isStateful = isStatefulComponent(instance); 6410 initProps(instance, props, isStateful, isSSR); 6411 initSlots(instance, children); 6412 const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : undefined; 6413 isInSSRComponentSetup = false; 6414 return setupResult; 6415 } 6416 6417 function setupStatefulComponent(instance, isSSR) { 6418 const Component = instance.type; 6419 6420 6421 instance.accessCache = Object.create(null); // 1. create public instance / render proxy 6422 // also mark it raw so it's never observed 6423 6424 instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers)); 6425 6426 6427 const { 6428 setup 6429 } = Component; 6430 6431 if (setup) { 6432 const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null; 6433 setCurrentInstance(instance); 6434 pauseTracking(); 6435 const setupResult = callWithErrorHandling(setup, instance, 0 6436 /* SETUP_FUNCTION */ 6437 , [instance.props, setupContext]); 6438 resetTracking(); 6439 unsetCurrentInstance(); 6440 6441 if (isPromise$1(setupResult)) { 6442 setupResult.then(unsetCurrentInstance, unsetCurrentInstance); 6443 6444 if (isSSR) { 6445 // return the promise so server-renderer can wait on it 6446 return setupResult.then(resolvedResult => { 6447 handleSetupResult(instance, resolvedResult, isSSR); 6448 }).catch(e => { 6449 handleError(e, instance, 0 6450 /* SETUP_FUNCTION */ 6451 ); 6452 }); 6453 } else { 6454 // async setup returned Promise. 6455 // bail here and wait for re-entry. 6456 instance.asyncDep = setupResult; 6457 } 6458 } else { 6459 handleSetupResult(instance, setupResult, isSSR); 6460 } 6461 } else { 6462 finishComponentSetup(instance, isSSR); 6463 } 6464 } 6465 6466 function handleSetupResult(instance, setupResult, isSSR) { 6467 if (isFunction(setupResult)) { 6468 // setup returned an inline render function 6469 if (instance.type.__ssrInlineRender) { 6470 // when the function's name is `ssrRender` (compiled by SFC inline mode), 6471 // set it as ssrRender instead. 6472 instance.ssrRender = setupResult; 6473 } else { 6474 instance.render = setupResult; 6475 } 6476 } else if (isObject$1(setupResult)) { 6477 // assuming a render function compiled from template is present. 6478 6479 6480 if (__VUE_PROD_DEVTOOLS__) { 6481 instance.devtoolsRawSetupState = setupResult; 6482 } 6483 6484 instance.setupState = proxyRefs(setupResult); 6485 } else ; 6486 6487 finishComponentSetup(instance, isSSR); 6488 } 6489 6490 let compile; 6491 6492 function finishComponentSetup(instance, isSSR, skipOptions) { 6493 const Component = instance.type; // template / render function normalization 6494 // could be already set when returned from setup() 6495 6496 if (!instance.render) { 6497 // only do on-the-fly compile if not in SSR - SSR on-the-fly compliation 6498 // is done by server-renderer 6499 if (!isSSR && compile && !Component.render) { 6500 const template = Component.template; 6501 6502 if (template) { 6503 6504 const { 6505 isCustomElement, 6506 compilerOptions 6507 } = instance.appContext.config; 6508 const { 6509 delimiters, 6510 compilerOptions: componentCompilerOptions 6511 } = Component; 6512 const finalCompilerOptions = extend(extend({ 6513 isCustomElement, 6514 delimiters 6515 }, compilerOptions), componentCompilerOptions); 6516 Component.render = compile(template, finalCompilerOptions); 6517 } 6518 } 6519 6520 instance.render = Component.render || NOOP; // for runtime-compiled render functions using `with` blocks, the render 6521 } // support for 2.x options 6522 6523 6524 if (__VUE_OPTIONS_API__ && !false) { 6525 setCurrentInstance(instance); 6526 pauseTracking(); 6527 applyOptions(instance); 6528 resetTracking(); 6529 unsetCurrentInstance(); 6530 } // warn missing template/render 6531 } 6532 6533 function createAttrsProxy(instance) { 6534 return new Proxy(instance.attrs, { 6535 get(target, key) { 6536 track(instance, "get" 6537 /* GET */ 6538 , '$attrs'); 6539 return target[key]; 6540 } 6541 6542 }); 6543 } 6544 6545 function createSetupContext(instance) { 6546 const expose = exposed => { 6547 6548 instance.exposed = exposed || {}; 6549 }; 6550 6551 let attrs; 6552 6553 { 6554 return { 6555 get attrs() { 6556 return attrs || (attrs = createAttrsProxy(instance)); 6557 }, 6558 6559 slots: instance.slots, 6560 emit: instance.emit, 6561 expose 6562 }; 6563 } 6564 } 6565 6566 function getExposeProxy(instance) { 6567 if (instance.exposed) { 6568 return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), { 6569 get(target, key) { 6570 if (key in target) { 6571 return target[key]; 6572 } else if (key in publicPropertiesMap) { 6573 return publicPropertiesMap[key](instance); 6574 } 6575 } 6576 6577 })); 6578 } 6579 } 6580 6581 function getComponentName(Component) { 6582 return isFunction(Component) ? Component.displayName || Component.name : Component.name; 6583 } 6584 6585 function isClassComponent(value) { 6586 return isFunction(value) && '__vccOpts' in value; 6587 } 6588 6589 function callWithErrorHandling(fn, instance, type, args) { 6590 let res; 6591 6592 try { 6593 res = args ? fn(...args) : fn(); 6594 } catch (err) { 6595 handleError(err, instance, type); 6596 } 6597 6598 return res; 6599 } 6600 6601 function callWithAsyncErrorHandling(fn, instance, type, args) { 6602 if (isFunction(fn)) { 6603 const res = callWithErrorHandling(fn, instance, type, args); 6604 6605 if (res && isPromise$1(res)) { 6606 res.catch(err => { 6607 handleError(err, instance, type); 6608 }); 6609 } 6610 6611 return res; 6612 } 6613 6614 const values = []; 6615 6616 for (let i = 0; i < fn.length; i++) { 6617 values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)); 6618 } 6619 6620 return values; 6621 } 6622 6623 function handleError(err, instance, type, throwInDev) { 6624 6625 instance ? instance.vnode : null; 6626 6627 if (instance) { 6628 let cur = instance.parent; // the exposed instance is the render proxy to keep it consistent with 2.x 6629 6630 const exposedInstance = instance.proxy; // in production the hook receives only the error code 6631 6632 const errorInfo = type; 6633 6634 while (cur) { 6635 const errorCapturedHooks = cur.ec; 6636 6637 if (errorCapturedHooks) { 6638 for (let i = 0; i < errorCapturedHooks.length; i++) { 6639 if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) { 6640 return; 6641 } 6642 } 6643 } 6644 6645 cur = cur.parent; 6646 } // app-level handling 6647 6648 6649 const appErrorHandler = instance.appContext.config.errorHandler; 6650 6651 if (appErrorHandler) { 6652 callWithErrorHandling(appErrorHandler, null, 10 6653 /* APP_ERROR_HANDLER */ 6654 , [err, exposedInstance, errorInfo]); 6655 return; 6656 } 6657 } 6658 6659 logError(err); 6660 } 6661 6662 function logError(err, type, contextVNode, throwInDev) { 6663 6664 { 6665 // recover in prod to reduce the impact on end-user 6666 console.error(err); 6667 } 6668 } 6669 6670 let isFlushing = false; 6671 let isFlushPending = false; 6672 const queue = []; 6673 let flushIndex = 0; 6674 const pendingPreFlushCbs = []; 6675 let activePreFlushCbs = null; 6676 let preFlushIndex = 0; 6677 const pendingPostFlushCbs = []; 6678 let activePostFlushCbs = null; 6679 let postFlushIndex = 0; 6680 const resolvedPromise = Promise.resolve(); 6681 let currentFlushPromise = null; 6682 let currentPreFlushParentJob = null; 6683 6684 function nextTick(fn) { 6685 const p = currentFlushPromise || resolvedPromise; 6686 return fn ? p.then(this ? fn.bind(this) : fn) : p; 6687 } // #2768 6688 // Use binary-search to find a suitable position in the queue, 6689 // so that the queue maintains the increasing order of job's id, 6690 // which can prevent the job from being skipped and also can avoid repeated patching. 6691 6692 6693 function findInsertionIndex(id) { 6694 // the start index should be `flushIndex + 1` 6695 let start = flushIndex + 1; 6696 let end = queue.length; 6697 6698 while (start < end) { 6699 const middle = start + end >>> 1; 6700 const middleJobId = getId(queue[middle]); 6701 middleJobId < id ? start = middle + 1 : end = middle; 6702 } 6703 6704 return start; 6705 } 6706 6707 function queueJob(job) { 6708 // the dedupe search uses the startIndex argument of Array.includes() 6709 // by default the search index includes the current job that is being run 6710 // so it cannot recursively trigger itself again. 6711 // if the job is a watch() callback, the search will start with a +1 index to 6712 // allow it recursively trigger itself - it is the user's responsibility to 6713 // ensure it doesn't end up in an infinite loop. 6714 if ((!queue.length || !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) && job !== currentPreFlushParentJob) { 6715 if (job.id == null) { 6716 queue.push(job); 6717 } else { 6718 queue.splice(findInsertionIndex(job.id), 0, job); 6719 } 6720 6721 queueFlush(); 6722 } 6723 } 6724 6725 function queueFlush() { 6726 if (!isFlushing && !isFlushPending) { 6727 isFlushPending = true; 6728 currentFlushPromise = resolvedPromise.then(flushJobs); 6729 } 6730 } 6731 6732 function invalidateJob(job) { 6733 const i = queue.indexOf(job); 6734 6735 if (i > flushIndex) { 6736 queue.splice(i, 1); 6737 } 6738 } 6739 6740 function queueCb(cb, activeQueue, pendingQueue, index) { 6741 if (!isArray(cb)) { 6742 if (!activeQueue || !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) { 6743 pendingQueue.push(cb); 6744 } 6745 } else { 6746 // if cb is an array, it is a component lifecycle hook which can only be 6747 // triggered by a job, which is already deduped in the main queue, so 6748 // we can skip duplicate check here to improve perf 6749 pendingQueue.push(...cb); 6750 } 6751 6752 queueFlush(); 6753 } 6754 6755 function queuePreFlushCb(cb) { 6756 queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex); 6757 } 6758 6759 function queuePostFlushCb(cb) { 6760 queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex); 6761 } 6762 6763 function flushPreFlushCbs(seen, parentJob) { 6764 if (parentJob === void 0) { 6765 parentJob = null; 6766 } 6767 6768 if (pendingPreFlushCbs.length) { 6769 currentPreFlushParentJob = parentJob; 6770 activePreFlushCbs = [...new Set(pendingPreFlushCbs)]; 6771 pendingPreFlushCbs.length = 0; 6772 6773 for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) { 6774 6775 activePreFlushCbs[preFlushIndex](); 6776 } 6777 6778 activePreFlushCbs = null; 6779 preFlushIndex = 0; 6780 currentPreFlushParentJob = null; // recursively flush until it drains 6781 6782 flushPreFlushCbs(seen, parentJob); 6783 } 6784 } 6785 6786 function flushPostFlushCbs(seen) { 6787 if (pendingPostFlushCbs.length) { 6788 const deduped = [...new Set(pendingPostFlushCbs)]; 6789 pendingPostFlushCbs.length = 0; // #1947 already has active queue, nested flushPostFlushCbs call 6790 6791 if (activePostFlushCbs) { 6792 activePostFlushCbs.push(...deduped); 6793 return; 6794 } 6795 6796 activePostFlushCbs = deduped; 6797 6798 activePostFlushCbs.sort((a, b) => getId(a) - getId(b)); 6799 6800 for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) { 6801 6802 activePostFlushCbs[postFlushIndex](); 6803 } 6804 6805 activePostFlushCbs = null; 6806 postFlushIndex = 0; 6807 } 6808 } 6809 6810 const getId = job => job.id == null ? Infinity : job.id; 6811 6812 function flushJobs(seen) { 6813 isFlushPending = false; 6814 isFlushing = true; 6815 6816 flushPreFlushCbs(seen); // Sort queue before flush. 6817 // This ensures that: 6818 // 1. Components are updated from parent to child. (because parent is always 6819 // created before the child so its render effect will have smaller 6820 // priority number) 6821 // 2. If a component is unmounted during a parent component's update, 6822 // its update can be skipped. 6823 6824 queue.sort((a, b) => getId(a) - getId(b)); // conditional usage of checkRecursiveUpdate must be determined out of 6825 // try ... catch block since Rollup by default de-optimizes treeshaking 6826 // inside try-catch. This can leave all warning code unshaked. Although 6827 // they would get eventually shaken by a minifier like terser, some minifiers 6828 // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610) 6829 6830 const check = NOOP; 6831 6832 try { 6833 for (flushIndex = 0; flushIndex < queue.length; flushIndex++) { 6834 const job = queue[flushIndex]; 6835 6836 if (job && job.active !== false) { 6837 if ("production" !== 'production' && check(job)) ; // console.log(`running:`, job.id) 6838 6839 6840 callWithErrorHandling(job, null, 14 6841 /* SCHEDULER */ 6842 ); 6843 } 6844 } 6845 } finally { 6846 flushIndex = 0; 6847 queue.length = 0; 6848 flushPostFlushCbs(); 6849 isFlushing = false; 6850 currentFlushPromise = null; // some postFlushCb queued jobs! 6851 // keep flushing until it drains. 6852 6853 if (queue.length || pendingPreFlushCbs.length || pendingPostFlushCbs.length) { 6854 flushJobs(seen); 6855 } 6856 } 6857 } 6858 6859 6860 const INITIAL_WATCHER_VALUE = {}; // implementation 6861 6862 function watch(source, cb, options) { 6863 6864 return doWatch(source, cb, options); 6865 } 6866 6867 function doWatch(source, cb, _temp) { 6868 let { 6869 immediate, 6870 deep, 6871 flush, 6872 onTrack, 6873 onTrigger 6874 } = _temp === void 0 ? EMPTY_OBJ : _temp; 6875 6876 const instance = currentInstance; 6877 let getter; 6878 let forceTrigger = false; 6879 let isMultiSource = false; 6880 6881 if (isRef(source)) { 6882 getter = () => source.value; 6883 6884 forceTrigger = !!source._shallow; 6885 } else if (isReactive(source)) { 6886 getter = () => source; 6887 6888 deep = true; 6889 } else if (isArray(source)) { 6890 isMultiSource = true; 6891 forceTrigger = source.some(isReactive); 6892 6893 getter = () => source.map(s => { 6894 if (isRef(s)) { 6895 return s.value; 6896 } else if (isReactive(s)) { 6897 return traverse(s); 6898 } else if (isFunction(s)) { 6899 return callWithErrorHandling(s, instance, 2 6900 /* WATCH_GETTER */ 6901 ); 6902 } else ; 6903 }); 6904 } else if (isFunction(source)) { 6905 if (cb) { 6906 // getter with cb 6907 getter = () => callWithErrorHandling(source, instance, 2 6908 /* WATCH_GETTER */ 6909 ); 6910 } else { 6911 // no cb -> simple effect 6912 getter = () => { 6913 if (instance && instance.isUnmounted) { 6914 return; 6915 } 6916 6917 if (cleanup) { 6918 cleanup(); 6919 } 6920 6921 return callWithAsyncErrorHandling(source, instance, 3 6922 /* WATCH_CALLBACK */ 6923 , [onInvalidate]); 6924 }; 6925 } 6926 } else { 6927 getter = NOOP; 6928 } 6929 6930 if (cb && deep) { 6931 const baseGetter = getter; 6932 6933 getter = () => traverse(baseGetter()); 6934 } 6935 6936 let cleanup; 6937 6938 let onInvalidate = fn => { 6939 cleanup = effect.onStop = () => { 6940 callWithErrorHandling(fn, instance, 4 6941 /* WATCH_CLEANUP */ 6942 ); 6943 }; 6944 }; // in SSR there is no need to setup an actual effect, and it should be noop 6945 // unless it's eager 6946 6947 6948 if (isInSSRComponentSetup) { 6949 // we will also not call the invalidate callback (+ runner is not set up) 6950 onInvalidate = NOOP; 6951 6952 if (!cb) { 6953 getter(); 6954 } else if (immediate) { 6955 callWithAsyncErrorHandling(cb, instance, 3 6956 /* WATCH_CALLBACK */ 6957 , [getter(), isMultiSource ? [] : undefined, onInvalidate]); 6958 } 6959 6960 return NOOP; 6961 } 6962 6963 let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE; 6964 6965 const job = () => { 6966 if (!effect.active) { 6967 return; 6968 } 6969 6970 if (cb) { 6971 // watch(source, cb) 6972 const newValue = effect.run(); 6973 6974 if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) { 6975 // cleanup before running cb again 6976 if (cleanup) { 6977 cleanup(); 6978 } 6979 6980 callWithAsyncErrorHandling(cb, instance, 3 6981 /* WATCH_CALLBACK */ 6982 , [newValue, // pass undefined as the old value when it's changed for the first time 6983 oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue, onInvalidate]); 6984 oldValue = newValue; 6985 } 6986 } else { 6987 // watchEffect 6988 effect.run(); 6989 } 6990 }; // important: mark the job as a watcher callback so that scheduler knows 6991 // it is allowed to self-trigger (#1727) 6992 6993 6994 job.allowRecurse = !!cb; 6995 let scheduler; 6996 6997 if (flush === 'sync') { 6998 scheduler = job; // the scheduler function gets called directly 6999 } else if (flush === 'post') { 7000 scheduler = () => queuePostRenderEffect(job, instance && instance.suspense); 7001 } else { 7002 // default: 'pre' 7003 scheduler = () => { 7004 if (!instance || instance.isMounted) { 7005 queuePreFlushCb(job); 7006 } else { 7007 // with 'pre' option, the first call must happen before 7008 // the component is mounted so it is called synchronously. 7009 job(); 7010 } 7011 }; 7012 } 7013 7014 const effect = new ReactiveEffect(getter, scheduler); 7015 7016 7017 if (cb) { 7018 if (immediate) { 7019 job(); 7020 } else { 7021 oldValue = effect.run(); 7022 } 7023 } else if (flush === 'post') { 7024 queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense); 7025 } else { 7026 effect.run(); 7027 } 7028 7029 return () => { 7030 effect.stop(); 7031 7032 if (instance && instance.scope) { 7033 remove(instance.scope.effects, effect); 7034 } 7035 }; 7036 } // this.$watch 7037 7038 7039 function instanceWatch(source, value, options) { 7040 const publicThis = this.proxy; 7041 const getter = isString(source) ? source.includes('.') ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis); 7042 let cb; 7043 7044 if (isFunction(value)) { 7045 cb = value; 7046 } else { 7047 cb = value.handler; 7048 options = value; 7049 } 7050 7051 const cur = currentInstance; 7052 setCurrentInstance(this); 7053 const res = doWatch(getter, cb.bind(publicThis), options); 7054 7055 if (cur) { 7056 setCurrentInstance(cur); 7057 } else { 7058 unsetCurrentInstance(); 7059 } 7060 7061 return res; 7062 } 7063 7064 function createPathGetter(ctx, path) { 7065 const segments = path.split('.'); 7066 return () => { 7067 let cur = ctx; 7068 7069 for (let i = 0; i < segments.length && cur; i++) { 7070 cur = cur[segments[i]]; 7071 } 7072 7073 return cur; 7074 }; 7075 } 7076 7077 function traverse(value, seen) { 7078 if (!isObject$1(value) || value["__v_skip" 7079 /* SKIP */ 7080 ]) { 7081 return value; 7082 } 7083 7084 seen = seen || new Set(); 7085 7086 if (seen.has(value)) { 7087 return value; 7088 } 7089 7090 seen.add(value); 7091 7092 if (isRef(value)) { 7093 traverse(value.value, seen); 7094 } else if (isArray(value)) { 7095 for (let i = 0; i < value.length; i++) { 7096 traverse(value[i], seen); 7097 } 7098 } else if (isSet(value) || isMap(value)) { 7099 value.forEach(v => { 7100 traverse(v, seen); 7101 }); 7102 } else if (isPlainObject(value)) { 7103 for (const key in value) { 7104 traverse(value[key], seen); 7105 } 7106 } 7107 7108 return value; 7109 } // dev only 7110 7111 7112 function h(type, propsOrChildren, children) { 7113 const l = arguments.length; 7114 7115 if (l === 2) { 7116 if (isObject$1(propsOrChildren) && !isArray(propsOrChildren)) { 7117 // single vnode without props 7118 if (isVNode(propsOrChildren)) { 7119 return createVNode(type, null, [propsOrChildren]); 7120 } // props without children 7121 7122 7123 return createVNode(type, propsOrChildren); 7124 } else { 7125 // omit props 7126 return createVNode(type, null, propsOrChildren); 7127 } 7128 } else { 7129 if (l > 3) { 7130 children = Array.prototype.slice.call(arguments, 2); 7131 } else if (l === 3 && isVNode(children)) { 7132 children = [children]; 7133 } 7134 7135 return createVNode(type, propsOrChildren, children); 7136 } 7137 } 7138 7139 7140 const version = "3.2.26"; 7141 7142 const svgNS = 'http://www.w3.org/2000/svg'; 7143 const doc = typeof document !== 'undefined' ? document : null; 7144 const staticTemplateCache = new Map(); 7145 const nodeOps = { 7146 insert: (child, parent, anchor) => { 7147 parent.insertBefore(child, anchor || null); 7148 }, 7149 remove: child => { 7150 const parent = child.parentNode; 7151 7152 if (parent) { 7153 parent.removeChild(child); 7154 } 7155 }, 7156 createElement: (tag, isSVG, is, props) => { 7157 const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { 7158 is 7159 } : undefined); 7160 7161 if (tag === 'select' && props && props.multiple != null) { 7162 el.setAttribute('multiple', props.multiple); 7163 } 7164 7165 return el; 7166 }, 7167 createText: text => doc.createTextNode(text), 7168 createComment: text => doc.createComment(text), 7169 setText: (node, text) => { 7170 node.nodeValue = text; 7171 }, 7172 setElementText: (el, text) => { 7173 el.textContent = text; 7174 }, 7175 parentNode: node => node.parentNode, 7176 nextSibling: node => node.nextSibling, 7177 querySelector: selector => doc.querySelector(selector), 7178 7179 setScopeId(el, id) { 7180 el.setAttribute(id, ''); 7181 }, 7182 7183 cloneNode(el) { 7184 const cloned = el.cloneNode(true); // #3072 7185 // - in `patchDOMProp`, we store the actual value in the `el._value` property. 7186 // - normally, elements using `:value` bindings will not be hoisted, but if 7187 // the bound value is a constant, e.g. `:value="true"` - they do get 7188 // hoisted. 7189 // - in production, hoisted nodes are cloned when subsequent inserts, but 7190 // cloneNode() does not copy the custom property we attached. 7191 // - This may need to account for other custom DOM properties we attach to 7192 // elements in addition to `_value` in the future. 7193 7194 if (`_value` in el) { 7195 cloned._value = el._value; 7196 } 7197 7198 return cloned; 7199 }, 7200 7201 // __UNSAFE__ 7202 // Reason: innerHTML. 7203 // Static content here can only come from compiled templates. 7204 // As long as the user only uses trusted templates, this is safe. 7205 insertStaticContent(content, parent, anchor, isSVG) { 7206 // <parent> before | first ... last | anchor </parent> 7207 const before = anchor ? anchor.previousSibling : parent.lastChild; 7208 let template = staticTemplateCache.get(content); 7209 7210 if (!template) { 7211 const t = doc.createElement('template'); 7212 t.innerHTML = isSVG ? `<svg>$content}</svg>` : content; 7213 template = t.content; 7214 7215 if (isSVG) { 7216 // remove outer svg wrapper 7217 const wrapper = template.firstChild; 7218 7219 while (wrapper.firstChild) { 7220 template.appendChild(wrapper.firstChild); 7221 } 7222 7223 template.removeChild(wrapper); 7224 } 7225 7226 staticTemplateCache.set(content, template); 7227 } 7228 7229 parent.insertBefore(template.cloneNode(true), anchor); 7230 return [// first 7231 before ? before.nextSibling : parent.firstChild, // last 7232 anchor ? anchor.previousSibling : parent.lastChild]; 7233 } 7234 7235 }; // compiler should normalize class + :class bindings on the same element 7236 // into a single binding ['staticClass', dynamic] 7237 7238 function patchClass(el, value, isSVG) { 7239 // directly setting className should be faster than setAttribute in theory 7240 // if this is an element during a transition, take the temporary transition 7241 // classes into account. 7242 const transitionClasses = el._vtc; 7243 7244 if (transitionClasses) { 7245 value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' '); 7246 } 7247 7248 if (value == null) { 7249 el.removeAttribute('class'); 7250 } else if (isSVG) { 7251 el.setAttribute('class', value); 7252 } else { 7253 el.className = value; 7254 } 7255 } 7256 7257 function patchStyle(el, prev, next) { 7258 const style = el.style; 7259 const isCssString = isString(next); 7260 7261 if (next && !isCssString) { 7262 for (const key in next) { 7263 setStyle(style, key, next[key]); 7264 } 7265 7266 if (prev && !isString(prev)) { 7267 for (const key in prev) { 7268 if (next[key] == null) { 7269 setStyle(style, key, ''); 7270 } 7271 } 7272 } 7273 } else { 7274 const currentDisplay = style.display; 7275 7276 if (isCssString) { 7277 if (prev !== next) { 7278 style.cssText = next; 7279 } 7280 } else if (prev) { 7281 el.removeAttribute('style'); 7282 } // indicates that the `display` of the element is controlled by `v-show`, 7283 // so we always keep the current `display` value regardless of the `style` 7284 // value, thus handing over control to `v-show`. 7285 7286 7287 if ('_vod' in el) { 7288 style.display = currentDisplay; 7289 } 7290 } 7291 } 7292 7293 const importantRE = /\s*!important$/; 7294 7295 function setStyle(style, name, val) { 7296 if (isArray(val)) { 7297 val.forEach(v => setStyle(style, name, v)); 7298 } else { 7299 if (name.startsWith('--')) { 7300 // custom property definition 7301 style.setProperty(name, val); 7302 } else { 7303 const prefixed = autoPrefix(style, name); 7304 7305 if (importantRE.test(val)) { 7306 // !important 7307 style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important'); 7308 } else { 7309 style[prefixed] = val; 7310 } 7311 } 7312 } 7313 } 7314 7315 const prefixes = ['Webkit', 'Moz', 'ms']; 7316 const prefixCache = {}; 7317 7318 function autoPrefix(style, rawName) { 7319 const cached = prefixCache[rawName]; 7320 7321 if (cached) { 7322 return cached; 7323 } 7324 7325 let name = camelize(rawName); 7326 7327 if (name !== 'filter' && name in style) { 7328 return prefixCache[rawName] = name; 7329 } 7330 7331 name = capitalize(name); 7332 7333 for (let i = 0; i < prefixes.length; i++) { 7334 const prefixed = prefixes[i] + name; 7335 7336 if (prefixed in style) { 7337 return prefixCache[rawName] = prefixed; 7338 } 7339 } 7340 7341 return rawName; 7342 } 7343 7344 const xlinkNS = 'http://www.w3.org/1999/xlink'; 7345 7346 function patchAttr(el, key, value, isSVG, instance) { 7347 if (isSVG && key.startsWith('xlink:')) { 7348 if (value == null) { 7349 el.removeAttributeNS(xlinkNS, key.slice(6, key.length)); 7350 } else { 7351 el.setAttributeNS(xlinkNS, key, value); 7352 } 7353 } else { 7354 // note we are only checking boolean attributes that don't have a 7355 // corresponding dom prop of the same name here. 7356 const isBoolean = isSpecialBooleanAttr(key); 7357 7358 if (value == null || isBoolean && !includeBooleanAttr(value)) { 7359 el.removeAttribute(key); 7360 } else { 7361 el.setAttribute(key, isBoolean ? '' : value); 7362 } 7363 } 7364 } // __UNSAFE__ 7365 // functions. The user is responsible for using them with only trusted content. 7366 7367 7368 function patchDOMProp(el, key, value, // the following args are passed only due to potential innerHTML/textContent 7369 // overriding existing VNodes, in which case the old tree must be properly 7370 // unmounted. 7371 prevChildren, parentComponent, parentSuspense, unmountChildren) { 7372 if (key === 'innerHTML' || key === 'textContent') { 7373 if (prevChildren) { 7374 unmountChildren(prevChildren, parentComponent, parentSuspense); 7375 } 7376 7377 el[key] = value == null ? '' : value; 7378 return; 7379 } 7380 7381 if (key === 'value' && el.tagName !== 'PROGRESS' && // custom elements may use _value internally 7382 !el.tagName.includes('-')) { 7383 // store value as _value as well since 7384 // non-string values will be stringified. 7385 el._value = value; 7386 const newValue = value == null ? '' : value; 7387 7388 if (el.value !== newValue || // #4956: always set for OPTION elements because its value falls back to 7389 // textContent if no value attribute is present. And setting .value for 7390 // OPTION has no side effect 7391 el.tagName === 'OPTION') { 7392 el.value = newValue; 7393 } 7394 7395 if (value == null) { 7396 el.removeAttribute(key); 7397 } 7398 7399 return; 7400 } 7401 7402 if (value === '' || value == null) { 7403 const type = typeof el[key]; 7404 7405 if (type === 'boolean') { 7406 // e.g. <select multiple> compiles to { multiple: '' } 7407 el[key] = includeBooleanAttr(value); 7408 return; 7409 } else if (value == null && type === 'string') { 7410 // e.g. <div :id="null"> 7411 el[key] = ''; 7412 el.removeAttribute(key); 7413 return; 7414 } else if (type === 'number') { 7415 // e.g. <img :width="null"> 7416 // the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error 7417 try { 7418 el[key] = 0; 7419 } catch (_a) {} 7420 7421 el.removeAttribute(key); 7422 return; 7423 } 7424 } // some properties perform value validation and throw 7425 7426 7427 try { 7428 el[key] = value; 7429 } catch (e) { 7430 } 7431 } // Async edge case fix requires storing an event listener's attach timestamp. 7432 7433 7434 let _getNow = Date.now; 7435 let skipTimestampCheck = false; 7436 7437 if (typeof window !== 'undefined') { 7438 // Determine what event timestamp the browser is using. Annoyingly, the 7439 // timestamp can either be hi-res (relative to page load) or low-res 7440 // (relative to UNIX epoch), so in order to compare time we have to use the 7441 // same timestamp type when saving the flush timestamp. 7442 if (_getNow() > document.createEvent('Event').timeStamp) { 7443 // if the low-res timestamp which is bigger than the event timestamp 7444 // (which is evaluated AFTER) it means the event is using a hi-res timestamp, 7445 // and we need to use the hi-res version for event listeners as well. 7446 _getNow = () => performance.now(); 7447 } // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation 7448 // and does not fire microtasks in between event propagation, so safe to exclude. 7449 7450 7451 const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i); 7452 skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53); 7453 } // To avoid the overhead of repeatedly calling performance.now(), we cache 7454 // and use the same timestamp for all event listeners attached in the same tick. 7455 7456 7457 let cachedNow = 0; 7458 const p = Promise.resolve(); 7459 7460 const reset = () => { 7461 cachedNow = 0; 7462 }; 7463 7464 const getNow = () => cachedNow || (p.then(reset), cachedNow = _getNow()); 7465 7466 function addEventListener(el, event, handler, options) { 7467 el.addEventListener(event, handler, options); 7468 } 7469 7470 function removeEventListener(el, event, handler, options) { 7471 el.removeEventListener(event, handler, options); 7472 } 7473 7474 function patchEvent(el, rawName, prevValue, nextValue, instance) { 7475 if (instance === void 0) { 7476 instance = null; 7477 } 7478 7479 // vei = vue event invokers 7480 const invokers = el._vei || (el._vei = {}); 7481 const existingInvoker = invokers[rawName]; 7482 7483 if (nextValue && existingInvoker) { 7484 // patch 7485 existingInvoker.value = nextValue; 7486 } else { 7487 const [name, options] = parseName(rawName); 7488 7489 if (nextValue) { 7490 // add 7491 const invoker = invokers[rawName] = createInvoker(nextValue, instance); 7492 addEventListener(el, name, invoker, options); 7493 } else if (existingInvoker) { 7494 // remove 7495 removeEventListener(el, name, existingInvoker, options); 7496 invokers[rawName] = undefined; 7497 } 7498 } 7499 } 7500 7501 const optionsModifierRE = /(?:Once|Passive|Capture)$/; 7502 7503 function parseName(name) { 7504 let options; 7505 7506 if (optionsModifierRE.test(name)) { 7507 options = {}; 7508 let m; 7509 7510 while (m = name.match(optionsModifierRE)) { 7511 name = name.slice(0, name.length - m[0].length); 7512 options[m[0].toLowerCase()] = true; 7513 } 7514 } 7515 7516 return [hyphenate(name.slice(2)), options]; 7517 } 7518 7519 function createInvoker(initialValue, instance) { 7520 const invoker = e => { 7521 // async edge case #6566: inner click event triggers patch, event handler 7522 // attached to outer element during patch, and triggered again. This 7523 // happens because browsers fire microtask ticks between event propagation. 7524 // the solution is simple: we save the timestamp when a handler is attached, 7525 // and the handler would only fire if the event passed to it was fired 7526 // AFTER it was attached. 7527 const timeStamp = e.timeStamp || _getNow(); 7528 7529 if (skipTimestampCheck || timeStamp >= invoker.attached - 1) { 7530 callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 7531 /* NATIVE_EVENT_HANDLER */ 7532 , [e]); 7533 } 7534 }; 7535 7536 invoker.value = initialValue; 7537 invoker.attached = getNow(); 7538 return invoker; 7539 } 7540 7541 function patchStopImmediatePropagation(e, value) { 7542 if (isArray(value)) { 7543 const originalStop = e.stopImmediatePropagation; 7544 7545 e.stopImmediatePropagation = () => { 7546 originalStop.call(e); 7547 e._stopped = true; 7548 }; 7549 7550 return value.map(fn => e => !e._stopped && fn(e)); 7551 } else { 7552 return value; 7553 } 7554 } 7555 7556 const nativeOnRE = /^on[a-z]/; 7557 7558 const patchProp = function (el, key, prevValue, nextValue, isSVG, prevChildren, parentComponent, parentSuspense, unmountChildren) { 7559 if (isSVG === void 0) { 7560 isSVG = false; 7561 } 7562 7563 if (key === 'class') { 7564 patchClass(el, nextValue, isSVG); 7565 } else if (key === 'style') { 7566 patchStyle(el, prevValue, nextValue); 7567 } else if (isOn(key)) { 7568 // ignore v-model listeners 7569 if (!isModelListener(key)) { 7570 patchEvent(el, key, prevValue, nextValue, parentComponent); 7571 } 7572 } else if (key[0] === '.' ? (key = key.slice(1), true) : key[0] === '^' ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) { 7573 patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren); 7574 } else { 7575 // special case for <input v-model type="checkbox"> with 7576 // :true-value & :false-value 7577 // store value as dom properties since non-string values will be 7578 // stringified. 7579 if (key === 'true-value') { 7580 el._trueValue = nextValue; 7581 } else if (key === 'false-value') { 7582 el._falseValue = nextValue; 7583 } 7584 7585 patchAttr(el, key, nextValue, isSVG); 7586 } 7587 }; 7588 7589 function shouldSetAsProp(el, key, value, isSVG) { 7590 if (isSVG) { 7591 // most keys must be set as attribute on svg elements to work 7592 // ...except innerHTML & textContent 7593 if (key === 'innerHTML' || key === 'textContent') { 7594 return true; 7595 } // or native onclick with function values 7596 7597 7598 if (key in el && nativeOnRE.test(key) && isFunction(value)) { 7599 return true; 7600 } 7601 7602 return false; 7603 } // spellcheck and draggable are numerated attrs, however their 7604 // corresponding DOM properties are actually booleans - this leads to 7605 // setting it with a string "false" value leading it to be coerced to 7606 // `true`, so we need to always treat them as attributes. 7607 // Note that `contentEditable` doesn't have this problem: its DOM 7608 // property is also enumerated string values. 7609 7610 7611 if (key === 'spellcheck' || key === 'draggable') { 7612 return false; 7613 } // #1787, #2840 form property on form elements is readonly and must be set as 7614 // attribute. 7615 7616 7617 if (key === 'form') { 7618 return false; 7619 } // #1526 <input list> must be set as attribute 7620 7621 7622 if (key === 'list' && el.tagName === 'INPUT') { 7623 return false; 7624 } // #2766 <textarea type> must be set as attribute 7625 7626 7627 if (key === 'type' && el.tagName === 'TEXTAREA') { 7628 return false; 7629 } // native onclick with string value, must be set as attribute 7630 7631 7632 if (nativeOnRE.test(key) && isString(value)) { 7633 return false; 7634 } 7635 7636 return key in el; 7637 } 7638 7639 const TRANSITION = 'transition'; 7640 const ANIMATION = 'animation'; // DOM Transition is a higher-order-component based on the platform-agnostic 7641 // base Transition component, with DOM-specific logic. 7642 7643 const Transition = (props, _ref) => { 7644 let { 7645 slots 7646 } = _ref; 7647 return h(BaseTransition, resolveTransitionProps(props), slots); 7648 }; 7649 7650 Transition.displayName = 'Transition'; 7651 const DOMTransitionPropsValidators = { 7652 name: String, 7653 type: String, 7654 css: { 7655 type: Boolean, 7656 default: true 7657 }, 7658 duration: [String, Number, Object], 7659 enterFromClass: String, 7660 enterActiveClass: String, 7661 enterToClass: String, 7662 appearFromClass: String, 7663 appearActiveClass: String, 7664 appearToClass: String, 7665 leaveFromClass: String, 7666 leaveActiveClass: String, 7667 leaveToClass: String 7668 }; 7669 Transition.props = /*#__PURE__*/extend({}, BaseTransition.props, DOMTransitionPropsValidators); 7670 /** 7671 * #3227 Incoming hooks may be merged into arrays when wrapping Transition 7672 * with custom HOCs. 7673 */ 7674 7675 const callHook = function (hook, args) { 7676 if (args === void 0) { 7677 args = []; 7678 } 7679 7680 if (isArray(hook)) { 7681 hook.forEach(h => h(...args)); 7682 } else if (hook) { 7683 hook(...args); 7684 } 7685 }; 7686 /** 7687 * Check if a hook expects a callback (2nd arg), which means the user 7688 * intends to explicitly control the end of the transition. 7689 */ 7690 7691 7692 const hasExplicitCallback = hook => { 7693 return hook ? isArray(hook) ? hook.some(h => h.length > 1) : hook.length > 1 : false; 7694 }; 7695 7696 function resolveTransitionProps(rawProps) { 7697 const baseProps = {}; 7698 7699 for (const key in rawProps) { 7700 if (!(key in DOMTransitionPropsValidators)) { 7701 baseProps[key] = rawProps[key]; 7702 } 7703 } 7704 7705 if (rawProps.css === false) { 7706 return baseProps; 7707 } 7708 7709 const { 7710 name = 'v', 7711 type, 7712 duration, 7713 enterFromClass = `$name}-enter-from`, 7714 enterActiveClass = `$name}-enter-active`, 7715 enterToClass = `$name}-enter-to`, 7716 appearFromClass = enterFromClass, 7717 appearActiveClass = enterActiveClass, 7718 appearToClass = enterToClass, 7719 leaveFromClass = `$name}-leave-from`, 7720 leaveActiveClass = `$name}-leave-active`, 7721 leaveToClass = `$name}-leave-to` 7722 } = rawProps; 7723 const durations = normalizeDuration(duration); 7724 const enterDuration = durations && durations[0]; 7725 const leaveDuration = durations && durations[1]; 7726 const { 7727 onBeforeEnter, 7728 onEnter, 7729 onEnterCancelled, 7730 onLeave, 7731 onLeaveCancelled, 7732 onBeforeAppear = onBeforeEnter, 7733 onAppear = onEnter, 7734 onAppearCancelled = onEnterCancelled 7735 } = baseProps; 7736 7737 const finishEnter = (el, isAppear, done) => { 7738 removeTransitionClass(el, isAppear ? appearToClass : enterToClass); 7739 removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass); 7740 done && done(); 7741 }; 7742 7743 const finishLeave = (el, done) => { 7744 removeTransitionClass(el, leaveToClass); 7745 removeTransitionClass(el, leaveActiveClass); 7746 done && done(); 7747 }; 7748 7749 const makeEnterHook = isAppear => { 7750 return (el, done) => { 7751 const hook = isAppear ? onAppear : onEnter; 7752 7753 const resolve = () => finishEnter(el, isAppear, done); 7754 7755 callHook(hook, [el, resolve]); 7756 nextFrame(() => { 7757 removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass); 7758 addTransitionClass(el, isAppear ? appearToClass : enterToClass); 7759 7760 if (!hasExplicitCallback(hook)) { 7761 whenTransitionEnds(el, type, enterDuration, resolve); 7762 } 7763 }); 7764 }; 7765 }; 7766 7767 return extend(baseProps, { 7768 onBeforeEnter(el) { 7769 callHook(onBeforeEnter, [el]); 7770 addTransitionClass(el, enterFromClass); 7771 addTransitionClass(el, enterActiveClass); 7772 }, 7773 7774 onBeforeAppear(el) { 7775 callHook(onBeforeAppear, [el]); 7776 addTransitionClass(el, appearFromClass); 7777 addTransitionClass(el, appearActiveClass); 7778 }, 7779 7780 onEnter: makeEnterHook(false), 7781 onAppear: makeEnterHook(true), 7782 7783 onLeave(el, done) { 7784 const resolve = () => finishLeave(el, done); 7785 7786 addTransitionClass(el, leaveFromClass); // force reflow so *-leave-from classes immediately take effect (#2593) 7787 7788 forceReflow(); 7789 addTransitionClass(el, leaveActiveClass); 7790 nextFrame(() => { 7791 removeTransitionClass(el, leaveFromClass); 7792 addTransitionClass(el, leaveToClass); 7793 7794 if (!hasExplicitCallback(onLeave)) { 7795 whenTransitionEnds(el, type, leaveDuration, resolve); 7796 } 7797 }); 7798 callHook(onLeave, [el, resolve]); 7799 }, 7800 7801 onEnterCancelled(el) { 7802 finishEnter(el, false); 7803 callHook(onEnterCancelled, [el]); 7804 }, 7805 7806 onAppearCancelled(el) { 7807 finishEnter(el, true); 7808 callHook(onAppearCancelled, [el]); 7809 }, 7810 7811 onLeaveCancelled(el) { 7812 finishLeave(el); 7813 callHook(onLeaveCancelled, [el]); 7814 } 7815 7816 }); 7817 } 7818 7819 function normalizeDuration(duration) { 7820 if (duration == null) { 7821 return null; 7822 } else if (isObject$1(duration)) { 7823 return [NumberOf(duration.enter), NumberOf(duration.leave)]; 7824 } else { 7825 const n = NumberOf(duration); 7826 return [n, n]; 7827 } 7828 } 7829 7830 function NumberOf(val) { 7831 const res = toNumber(val); 7832 return res; 7833 } 7834 7835 function addTransitionClass(el, cls) { 7836 cls.split(/\s+/).forEach(c => c && el.classList.add(c)); 7837 (el._vtc || (el._vtc = new Set())).add(cls); 7838 } 7839 7840 function removeTransitionClass(el, cls) { 7841 cls.split(/\s+/).forEach(c => c && el.classList.remove(c)); 7842 const { 7843 _vtc 7844 } = el; 7845 7846 if (_vtc) { 7847 _vtc.delete(cls); 7848 7849 if (!_vtc.size) { 7850 el._vtc = undefined; 7851 } 7852 } 7853 } 7854 7855 function nextFrame(cb) { 7856 requestAnimationFrame(() => { 7857 requestAnimationFrame(cb); 7858 }); 7859 } 7860 7861 let endId = 0; 7862 7863 function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) { 7864 const id = el._endId = ++endId; 7865 7866 const resolveIfNotStale = () => { 7867 if (id === el._endId) { 7868 resolve(); 7869 } 7870 }; 7871 7872 if (explicitTimeout) { 7873 return setTimeout(resolveIfNotStale, explicitTimeout); 7874 } 7875 7876 const { 7877 type, 7878 timeout, 7879 propCount 7880 } = getTransitionInfo(el, expectedType); 7881 7882 if (!type) { 7883 return resolve(); 7884 } 7885 7886 const endEvent = type + 'end'; 7887 let ended = 0; 7888 7889 const end = () => { 7890 el.removeEventListener(endEvent, onEnd); 7891 resolveIfNotStale(); 7892 }; 7893 7894 const onEnd = e => { 7895 if (e.target === el && ++ended >= propCount) { 7896 end(); 7897 } 7898 }; 7899 7900 setTimeout(() => { 7901 if (ended < propCount) { 7902 end(); 7903 } 7904 }, timeout + 1); 7905 el.addEventListener(endEvent, onEnd); 7906 } 7907 7908 function getTransitionInfo(el, expectedType) { 7909 const styles = window.getComputedStyle(el); // JSDOM may return undefined for transition properties 7910 7911 const getStyleProperties = key => (styles[key] || '').split(', '); 7912 7913 const transitionDelays = getStyleProperties(TRANSITION + 'Delay'); 7914 const transitionDurations = getStyleProperties(TRANSITION + 'Duration'); 7915 const transitionTimeout = getTimeout(transitionDelays, transitionDurations); 7916 const animationDelays = getStyleProperties(ANIMATION + 'Delay'); 7917 const animationDurations = getStyleProperties(ANIMATION + 'Duration'); 7918 const animationTimeout = getTimeout(animationDelays, animationDurations); 7919 let type = null; 7920 let timeout = 0; 7921 let propCount = 0; 7922 /* istanbul ignore if */ 7923 7924 if (expectedType === TRANSITION) { 7925 if (transitionTimeout > 0) { 7926 type = TRANSITION; 7927 timeout = transitionTimeout; 7928 propCount = transitionDurations.length; 7929 } 7930 } else if (expectedType === ANIMATION) { 7931 if (animationTimeout > 0) { 7932 type = ANIMATION; 7933 timeout = animationTimeout; 7934 propCount = animationDurations.length; 7935 } 7936 } else { 7937 timeout = Math.max(transitionTimeout, animationTimeout); 7938 type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null; 7939 propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0; 7940 } 7941 7942 const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']); 7943 return { 7944 type, 7945 timeout, 7946 propCount, 7947 hasTransform 7948 }; 7949 } 7950 7951 function getTimeout(delays, durations) { 7952 while (delays.length < durations.length) { 7953 delays = delays.concat(delays); 7954 } 7955 7956 return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i]))); 7957 } // Old versions of Chromium (below 61.0.3163.100) formats floating pointer 7958 // numbers in a locale-dependent way, using a comma instead of a dot. 7959 // If comma is not replaced with a dot, the input will be rounded down 7960 // (i.e. acting as a floor function) causing unexpected behaviors 7961 7962 7963 function toMs(s) { 7964 return Number(s.slice(0, -1).replace(',', '.')) * 1000; 7965 } // synchronously force layout to put elements into a certain state 7966 7967 7968 function forceReflow() { 7969 return document.body.offsetHeight; 7970 } 7971 7972 const getModelAssigner = vnode => { 7973 const fn = vnode.props['onUpdate:modelValue']; 7974 return isArray(fn) ? value => invokeArrayFns(fn, value) : fn; 7975 }; 7976 7977 function onCompositionStart(e) { 7978 e.target.composing = true; 7979 } 7980 7981 function onCompositionEnd(e) { 7982 const target = e.target; 7983 7984 if (target.composing) { 7985 target.composing = false; 7986 trigger(target, 'input'); 7987 } 7988 } 7989 7990 function trigger(el, type) { 7991 const e = document.createEvent('HTMLEvents'); 7992 e.initEvent(type, true, true); 7993 el.dispatchEvent(e); 7994 } // We are exporting the v-model runtime directly as vnode hooks so that it can 7995 // be tree-shaken in case v-model is never used. 7996 7997 7998 const vModelText = { 7999 created(el, _ref3, vnode) { 8000 let { 8001 modifiers: { 8002 lazy, 8003 trim, 8004 number 8005 } 8006 } = _ref3; 8007 el._assign = getModelAssigner(vnode); 8008 const castToNumber = number || vnode.props && vnode.props.type === 'number'; 8009 addEventListener(el, lazy ? 'change' : 'input', e => { 8010 if (e.target.composing) return; 8011 let domValue = el.value; 8012 8013 if (trim) { 8014 domValue = domValue.trim(); 8015 } else if (castToNumber) { 8016 domValue = toNumber(domValue); 8017 } 8018 8019 el._assign(domValue); 8020 }); 8021 8022 if (trim) { 8023 addEventListener(el, 'change', () => { 8024 el.value = el.value.trim(); 8025 }); 8026 } 8027 8028 if (!lazy) { 8029 addEventListener(el, 'compositionstart', onCompositionStart); 8030 addEventListener(el, 'compositionend', onCompositionEnd); // Safari < 10.2 & UIWebView doesn't fire compositionend when 8031 // switching focus before confirming composition choice 8032 // this also fixes the issue where some browsers e.g. iOS Chrome 8033 // fires "change" instead of "input" on autocomplete. 8034 8035 addEventListener(el, 'change', onCompositionEnd); 8036 } 8037 }, 8038 8039 // set value on mounted so it's after min/max for type="range" 8040 mounted(el, _ref4) { 8041 let { 8042 value 8043 } = _ref4; 8044 el.value = value == null ? '' : value; 8045 }, 8046 8047 beforeUpdate(el, _ref5, vnode) { 8048 let { 8049 value, 8050 modifiers: { 8051 lazy, 8052 trim, 8053 number 8054 } 8055 } = _ref5; 8056 el._assign = getModelAssigner(vnode); // avoid clearing unresolved text. #2302 8057 8058 if (el.composing) return; 8059 8060 if (document.activeElement === el) { 8061 if (lazy) { 8062 return; 8063 } 8064 8065 if (trim && el.value.trim() === value) { 8066 return; 8067 } 8068 8069 if ((number || el.type === 'number') && toNumber(el.value) === value) { 8070 return; 8071 } 8072 } 8073 8074 const newValue = value == null ? '' : value; 8075 8076 if (el.value !== newValue) { 8077 el.value = newValue; 8078 } 8079 } 8080 8081 }; 8082 8083 const systemModifiers = ['ctrl', 'shift', 'alt', 'meta']; 8084 const modifierGuards = { 8085 stop: e => e.stopPropagation(), 8086 prevent: e => e.preventDefault(), 8087 self: e => e.target !== e.currentTarget, 8088 ctrl: e => !e.ctrlKey, 8089 shift: e => !e.shiftKey, 8090 alt: e => !e.altKey, 8091 meta: e => !e.metaKey, 8092 left: e => 'button' in e && e.button !== 0, 8093 middle: e => 'button' in e && e.button !== 1, 8094 right: e => 'button' in e && e.button !== 2, 8095 exact: (e, modifiers) => systemModifiers.some(m => e[`$m}Key`] && !modifiers.includes(m)) 8096 }; 8097 /** 8098 * @private 8099 */ 8100 8101 const withModifiers = (fn, modifiers) => { 8102 return function (event) { 8103 for (let i = 0; i < modifiers.length; i++) { 8104 const guard = modifierGuards[modifiers[i]]; 8105 if (guard && guard(event, modifiers)) return; 8106 } 8107 8108 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 8109 args[_key2 - 1] = arguments[_key2]; 8110 } 8111 8112 return fn(event, ...args); 8113 }; 8114 }; // Kept for 2.x compat. 8115 // Note: IE11 compat for `spacebar` and `del` is removed for now. 8116 8117 8118 const keyNames = { 8119 esc: 'escape', 8120 space: ' ', 8121 up: 'arrow-up', 8122 left: 'arrow-left', 8123 right: 'arrow-right', 8124 down: 'arrow-down', 8125 delete: 'backspace' 8126 }; 8127 /** 8128 * @private 8129 */ 8130 8131 const withKeys = (fn, modifiers) => { 8132 return event => { 8133 if (!('key' in event)) { 8134 return; 8135 } 8136 8137 const eventKey = hyphenate(event.key); 8138 8139 if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) { 8140 return fn(event); 8141 } 8142 }; 8143 }; 8144 8145 const vShow = { 8146 beforeMount(el, _ref15, _ref16) { 8147 let { 8148 value 8149 } = _ref15; 8150 let { 8151 transition 8152 } = _ref16; 8153 el._vod = el.style.display === 'none' ? '' : el.style.display; 8154 8155 if (transition && value) { 8156 transition.beforeEnter(el); 8157 } else { 8158 setDisplay(el, value); 8159 } 8160 }, 8161 8162 mounted(el, _ref17, _ref18) { 8163 let { 8164 value 8165 } = _ref17; 8166 let { 8167 transition 8168 } = _ref18; 8169 8170 if (transition && value) { 8171 transition.enter(el); 8172 } 8173 }, 8174 8175 updated(el, _ref19, _ref20) { 8176 let { 8177 value, 8178 oldValue 8179 } = _ref19; 8180 let { 8181 transition 8182 } = _ref20; 8183 if (!value === !oldValue) return; 8184 8185 if (transition) { 8186 if (value) { 8187 transition.beforeEnter(el); 8188 setDisplay(el, true); 8189 transition.enter(el); 8190 } else { 8191 transition.leave(el, () => { 8192 setDisplay(el, false); 8193 }); 8194 } 8195 } else { 8196 setDisplay(el, value); 8197 } 8198 }, 8199 8200 beforeUnmount(el, _ref21) { 8201 let { 8202 value 8203 } = _ref21; 8204 setDisplay(el, value); 8205 } 8206 8207 }; 8208 8209 function setDisplay(el, value) { 8210 el.style.display = value ? el._vod : 'none'; 8211 } // SSR vnode transforms, only used when user includes client-oriented render 8212 8213 const rendererOptions = extend({ 8214 patchProp 8215 }, nodeOps); // lazy create the renderer - this makes core renderer logic tree-shakable 8216 // in case the user only imports reactivity utilities from Vue. 8217 8218 let renderer; 8219 8220 function ensureRenderer() { 8221 return renderer || (renderer = createRenderer(rendererOptions)); 8222 } 8223 8224 const createApp = function () { 8225 const app = ensureRenderer().createApp(...arguments); 8226 8227 const { 8228 mount 8229 } = app; 8230 8231 app.mount = containerOrSelector => { 8232 const container = normalizeContainer(containerOrSelector); 8233 if (!container) return; 8234 const component = app._component; 8235 8236 if (!isFunction(component) && !component.render && !component.template) { 8237 // __UNSAFE__ 8238 // Reason: potential execution of JS expressions in in-DOM template. 8239 // The user must make sure the in-DOM template is trusted. If it's 8240 // rendered by the server, the template should not contain any user data. 8241 component.template = container.innerHTML; 8242 } // clear content before mounting 8243 8244 8245 container.innerHTML = ''; 8246 const proxy = mount(container, false, container instanceof SVGElement); 8247 8248 if (container instanceof Element) { 8249 container.removeAttribute('v-cloak'); 8250 container.setAttribute('data-v-app', ''); 8251 } 8252 8253 return proxy; 8254 }; 8255 8256 return app; 8257 }; 8258 8259 function normalizeContainer(container) { 8260 if (isString(container)) { 8261 const res = document.querySelector(container); 8262 8263 return res; 8264 } 8265 8266 return container; 8267 } 8268 8269 /** 8270 * Media Event bus - used for communication between joomla and vue 8271 */ 8272 class Event { 8273 /** 8274 * Media Event constructor 8275 */ 8276 constructor() { 8277 this.events = {}; 8278 } 8279 /** 8280 * Fire an event 8281 * @param event 8282 * @param data 8283 */ 8284 8285 8286 fire(event, data) { 8287 if (data === void 0) { 8288 data = null; 8289 } 8290 8291 if (this.events[event]) { 8292 this.events[event].forEach(fn => fn(data)); 8293 } 8294 } 8295 /** 8296 * Listen to events 8297 * @param event 8298 * @param callback 8299 */ 8300 8301 8302 listen(event, callback) { 8303 this.events[event] = this.events[event] || []; 8304 this.events[event].push(callback); 8305 } 8306 8307 } 8308 8309 // Loading state 8310 const SET_IS_LOADING = 'SET_IS_LOADING'; // Selecting media items 8311 8312 const SELECT_DIRECTORY = 'SELECT_DIRECTORY'; 8313 const SELECT_BROWSER_ITEM = 'SELECT_BROWSER_ITEM'; 8314 const SELECT_BROWSER_ITEMS = 'SELECT_BROWSER_ITEMS'; 8315 const UNSELECT_BROWSER_ITEM = 'UNSELECT_BROWSER_ITEM'; 8316 const UNSELECT_ALL_BROWSER_ITEMS = 'UNSELECT_ALL_BROWSER_ITEMS'; // In/Decrease grid item size 8317 8318 const INCREASE_GRID_SIZE = 'INCREASE_GRID_SIZE'; 8319 const DECREASE_GRID_SIZE = 'DECREASE_GRID_SIZE'; // Api handlers 8320 8321 const LOAD_CONTENTS_SUCCESS = 'LOAD_CONTENTS_SUCCESS'; 8322 const LOAD_FULL_CONTENTS_SUCCESS = 'LOAD_FULL_CONTENTS_SUCCESS'; 8323 const CREATE_DIRECTORY_SUCCESS = 'CREATE_DIRECTORY_SUCCESS'; 8324 const UPLOAD_SUCCESS = 'UPLOAD_SUCCESS'; // Create folder modal 8325 8326 const SHOW_CREATE_FOLDER_MODAL = 'SHOW_CREATE_FOLDER_MODAL'; 8327 const HIDE_CREATE_FOLDER_MODAL = 'HIDE_CREATE_FOLDER_MODAL'; // Confirm Delete Modal 8328 8329 const SHOW_CONFIRM_DELETE_MODAL = 'SHOW_CONFIRM_DELETE_MODAL'; 8330 const HIDE_CONFIRM_DELETE_MODAL = 'HIDE_CONFIRM_DELETE_MODAL'; // Infobar 8331 8332 const SHOW_INFOBAR = 'SHOW_INFOBAR'; 8333 const HIDE_INFOBAR = 'HIDE_INFOBAR'; // Delete items 8334 8335 const DELETE_SUCCESS = 'DELETE_SUCCESS'; // List view 8336 8337 const CHANGE_LIST_VIEW = 'CHANGE_LIST_VIEW'; // Preview modal 8338 8339 const SHOW_PREVIEW_MODAL = 'SHOW_PREVIEW_MODAL'; 8340 const HIDE_PREVIEW_MODAL = 'HIDE_PREVIEW_MODAL'; // Rename modal 8341 8342 const SHOW_RENAME_MODAL = 'SHOW_RENAME_MODAL'; 8343 const HIDE_RENAME_MODAL = 'HIDE_RENAME_MODAL'; 8344 const RENAME_SUCCESS = 'RENAME_SUCCESS'; // Share model 8345 8346 const SHOW_SHARE_MODAL = 'SHOW_SHARE_MODAL'; 8347 const HIDE_SHARE_MODAL = 'HIDE_SHARE_MODAL'; // Search Query 8348 8349 const SET_SEARCH_QUERY = 'SET_SEARCH_QUERY'; 8350 8351 class Notifications { 8352 /* Send and success notification */ 8353 // eslint-disable-next-line class-methods-use-this 8354 success(message, options) { 8355 // eslint-disable-next-line no-use-before-define 8356 notifications.notify(message, { 8357 type: 'message', 8358 // @todo rename it to success 8359 dismiss: true, 8360 ...options 8361 }); 8362 } 8363 /* Send an error notification */ 8364 // eslint-disable-next-line class-methods-use-this 8365 8366 8367 error(message, options) { 8368 // eslint-disable-next-line no-use-before-define 8369 notifications.notify(message, { 8370 type: 'error', 8371 // @todo rename it to danger 8372 dismiss: true, 8373 ...options 8374 }); 8375 } 8376 /* Ask the user a question */ 8377 // eslint-disable-next-line class-methods-use-this 8378 8379 8380 ask(message) { 8381 return window.confirm(message); 8382 } 8383 /* Send a notification */ 8384 // eslint-disable-next-line class-methods-use-this 8385 8386 8387 notify(message, options) { 8388 let timer; 8389 8390 if (options.type === 'message') { 8391 timer = 3000; 8392 } 8393 8394 Joomla.renderMessages({ 8395 [options.type]: [Joomla.Text._(message)] 8396 }, undefined, true, timer); 8397 } 8398 8399 } // eslint-disable-next-line import/no-mutable-exports,import/prefer-default-export 8400 8401 8402 let notifications = new Notifications(); 8403 8404 var script$t = { 8405 name: 'MediaApp', 8406 data() { 8407 return { 8408 // The full height of the app in px 8409 fullHeight: '', 8410 }; 8411 }, 8412 computed: { 8413 disks() { 8414 return this.$store.state.disks; 8415 }, 8416 }, 8417 created() { 8418 // Listen to the toolbar events 8419 MediaManager.Event.listen('onClickCreateFolder', () => this.$store.commit(SHOW_CREATE_FOLDER_MODAL)); 8420 MediaManager.Event.listen('onClickDelete', () => { 8421 if (this.$store.state.selectedItems.length > 0) { 8422 this.$store.commit(SHOW_CONFIRM_DELETE_MODAL); 8423 } else { 8424 notifications.error('COM_MEDIA_PLEASE_SELECT_ITEM'); 8425 } 8426 }); 8427 }, 8428 mounted() { 8429 // Set the full height and add event listener when dom is updated 8430 this.$nextTick(() => { 8431 this.setFullHeight(); 8432 // Add the global resize event listener 8433 window.addEventListener('resize', this.setFullHeight); 8434 }); 8435 8436 // Initial load the data 8437 this.$store.dispatch('getContents', this.$store.state.selectedDirectory); 8438 }, 8439 beforeUnmount() { 8440 // Remove the global resize event listener 8441 window.removeEventListener('resize', this.setFullHeight); 8442 }, 8443 methods: { 8444 /* Set the full height on the app container */ 8445 setFullHeight() { 8446 this.fullHeight = `$window.innerHeight - this.$el.getBoundingClientRect().top}px`; 8447 }, 8448 }, 8449 }; 8450 8451 const _hoisted_1$t = { class: "media-container" }; 8452 const _hoisted_2$l = { class: "media-sidebar" }; 8453 const _hoisted_3$g = { class: "media-main" }; 8454 8455 function render$t(_ctx, _cache, $props, $setup, $data, $options) { 8456 const _component_media_disk = resolveComponent("media-disk"); 8457 const _component_media_toolbar = resolveComponent("media-toolbar"); 8458 const _component_media_browser = resolveComponent("media-browser"); 8459 const _component_media_upload = resolveComponent("media-upload"); 8460 const _component_media_create_folder_modal = resolveComponent("media-create-folder-modal"); 8461 const _component_media_preview_modal = resolveComponent("media-preview-modal"); 8462 const _component_media_rename_modal = resolveComponent("media-rename-modal"); 8463 const _component_media_share_modal = resolveComponent("media-share-modal"); 8464 const _component_media_confirm_delete_modal = resolveComponent("media-confirm-delete-modal"); 8465 8466 return (openBlock(), createElementBlock("div", _hoisted_1$t, [ 8467 createBaseVNode("div", _hoisted_2$l, [ 8468 (openBlock(true), createElementBlock(Fragment, null, renderList($options.disks, (disk, index) => { 8469 return (openBlock(), createBlock(_component_media_disk, { 8470 key: index, 8471 uid: index, 8472 disk: disk 8473 }, null, 8 /* PROPS */, ["uid", "disk"])) 8474 }), 128 /* KEYED_FRAGMENT */)) 8475 ]), 8476 createBaseVNode("div", _hoisted_3$g, [ 8477 createVNode(_component_media_toolbar), 8478 createVNode(_component_media_browser) 8479 ]), 8480 createVNode(_component_media_upload), 8481 createVNode(_component_media_create_folder_modal), 8482 createVNode(_component_media_preview_modal), 8483 createVNode(_component_media_rename_modal), 8484 createVNode(_component_media_share_modal), 8485 createVNode(_component_media_confirm_delete_modal) 8486 ])) 8487 } 8488 8489 script$t.render = render$t; 8490 script$t.__file = "administrator/components/com_media/resources/scripts/components/app.vue"; 8491 8492 var script$s = { 8493 name: 'MediaDisk', 8494 // eslint-disable-next-line vue/require-prop-types 8495 props: ['disk', 'uid'], 8496 computed: { 8497 diskId() { 8498 return `disk-$this.uid + 1}`; 8499 }, 8500 }, 8501 }; 8502 8503 const _hoisted_1$s = { class: "media-disk" }; 8504 const _hoisted_2$k = ["id"]; 8505 8506 function render$s(_ctx, _cache, $props, $setup, $data, $options) { 8507 const _component_media_drive = resolveComponent("media-drive"); 8508 8509 return (openBlock(), createElementBlock("div", _hoisted_1$s, [ 8510 createBaseVNode("h2", { 8511 id: $options.diskId, 8512 class: "media-disk-name" 8513 }, toDisplayString($props.disk.displayName), 9 /* TEXT, PROPS */, _hoisted_2$k), 8514 (openBlock(true), createElementBlock(Fragment, null, renderList($props.disk.drives, (drive, index) => { 8515 return (openBlock(), createBlock(_component_media_drive, { 8516 key: index, 8517 "disk-id": $options.diskId, 8518 counter: index, 8519 drive: drive, 8520 total: $props.disk.drives.length 8521 }, null, 8 /* PROPS */, ["disk-id", "counter", "drive", "total"])) 8522 }), 128 /* KEYED_FRAGMENT */)) 8523 ])) 8524 } 8525 8526 script$s.render = render$s; 8527 script$s.__file = "administrator/components/com_media/resources/scripts/components/tree/disk.vue"; 8528 8529 var navigable = { 8530 methods: { 8531 navigateTo(path) { 8532 this.$store.dispatch('getContents', path); 8533 } 8534 8535 } 8536 }; 8537 8538 var script$r = { 8539 name: 'MediaDrive', 8540 mixins: [navigable], 8541 // eslint-disable-next-line vue/require-prop-types 8542 props: ['drive', 'total', 'diskId', 'counter'], 8543 computed: { 8544 /* Whether or not the item is active */ 8545 isActive() { 8546 return (this.$store.state.selectedDirectory === this.drive.root); 8547 }, 8548 getTabindex() { 8549 return this.isActive ? 0 : -1; 8550 }, 8551 }, 8552 methods: { 8553 /* Handle the on drive click event */ 8554 onDriveClick() { 8555 this.navigateTo(this.drive.root); 8556 }, 8557 moveFocusToChildElement(nextRoot) { 8558 this.$refs[nextRoot].setFocusToFirstChild(); 8559 }, 8560 restoreFocus() { 8561 this.$refs['drive-root'].focus(); 8562 }, 8563 }, 8564 }; 8565 8566 const _hoisted_1$r = ["aria-labelledby"]; 8567 const _hoisted_2$j = ["aria-setsize", "tabindex"]; 8568 const _hoisted_3$f = { class: "item-name" }; 8569 8570 function render$r(_ctx, _cache, $props, $setup, $data, $options) { 8571 const _component_media_tree = resolveComponent("media-tree"); 8572 8573 return (openBlock(), createElementBlock("div", { 8574 class: "media-drive", 8575 onClick: _cache[2] || (_cache[2] = withModifiers($event => ($options.onDriveClick()), ["stop","prevent"])) 8576 }, [ 8577 createBaseVNode("ul", { 8578 class: "media-tree", 8579 role: "tree", 8580 "aria-labelledby": $props.diskId 8581 }, [ 8582 createBaseVNode("li", { 8583 class: normalizeClass({active: $options.isActive, 'media-tree-item': true, 'media-drive-name': true}), 8584 role: "none" 8585 }, [ 8586 createBaseVNode("a", { 8587 ref: "drive-root", 8588 role: "treeitem", 8589 "aria-level": "1", 8590 "aria-setsize": $props.counter, 8591 "aria-posinset": 1, 8592 tabindex: $options.getTabindex, 8593 onKeyup: [ 8594 _cache[0] || (_cache[0] = withKeys($event => ($options.moveFocusToChildElement($props.drive.root)), ["right"])), 8595 _cache[1] || (_cache[1] = withKeys((...args) => ($options.onDriveClick && $options.onDriveClick(...args)), ["enter"])) 8596 ] 8597 }, [ 8598 createBaseVNode("span", _hoisted_3$f, toDisplayString($props.drive.displayName), 1 /* TEXT */) 8599 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_2$j), 8600 createVNode(_component_media_tree, { 8601 ref: $props.drive.root, 8602 root: $props.drive.root, 8603 level: 2, 8604 "parent-index": 0, 8605 onMoveFocusToParent: $options.restoreFocus 8606 }, null, 8 /* PROPS */, ["root", "onMoveFocusToParent"]) 8607 ], 2 /* CLASS */) 8608 ], 8 /* PROPS */, _hoisted_1$r) 8609 ])) 8610 } 8611 8612 script$r.render = render$r; 8613 script$r.__file = "administrator/components/com_media/resources/scripts/components/tree/drive.vue"; 8614 8615 var script$q = { 8616 name: 'MediaTree', 8617 mixins: [navigable], 8618 props: { 8619 root: { 8620 type: String, 8621 required: true, 8622 }, 8623 level: { 8624 type: Number, 8625 required: true, 8626 }, 8627 parentIndex: { 8628 type: Number, 8629 required: true, 8630 }, 8631 }, 8632 emits: ['move-focus-to-parent'], 8633 computed: { 8634 /* Get the directories */ 8635 directories() { 8636 return this.$store.state.directories 8637 .filter((directory) => (directory.directory === this.root)) 8638 // Sort alphabetically 8639 .sort((a, b) => ((a.name.toUpperCase() < b.name.toUpperCase()) ? -1 : 1)); 8640 }, 8641 }, 8642 methods: { 8643 isActive(item) { 8644 return (item.path === this.$store.state.selectedDirectory); 8645 }, 8646 getTabindex(item) { 8647 return this.isActive(item) ? 0 : -1; 8648 }, 8649 onItemClick(item) { 8650 this.navigateTo(item.path); 8651 window.parent.document.dispatchEvent( 8652 new CustomEvent( 8653 'onMediaFileSelected', 8654 { 8655 bubbles: true, 8656 cancelable: false, 8657 detail: {}, 8658 }, 8659 ), 8660 ); 8661 }, 8662 hasChildren(item) { 8663 return item.directories.length > 0; 8664 }, 8665 isOpen(item) { 8666 return this.$store.state.selectedDirectory.includes(item.path); 8667 }, 8668 iconClass(item) { 8669 return { 8670 fas: false, 8671 'icon-folder': !this.isOpen(item), 8672 'icon-folder-open': this.isOpen(item), 8673 }; 8674 }, 8675 setFocusToFirstChild() { 8676 this.$refs[`$this.root}0`][0].focus(); 8677 }, 8678 moveFocusToNextElement(currentIndex) { 8679 if ((currentIndex + 1) === this.directories.length) { 8680 return; 8681 } 8682 this.$refs[this.root + (currentIndex + 1)][0].focus(); 8683 }, 8684 moveFocusToPreviousElement(currentIndex) { 8685 if (currentIndex === 0) { 8686 return; 8687 } 8688 this.$refs[this.root + (currentIndex - 1)][0].focus(); 8689 }, 8690 moveFocusToChildElement(item) { 8691 if (!this.hasChildren(item)) { 8692 return; 8693 } 8694 this.$refs[item.path][0].setFocusToFirstChild(); 8695 }, 8696 moveFocusToParentElement() { 8697 this.$emit('move-focus-to-parent', this.parentIndex); 8698 }, 8699 restoreFocus(parentIndex) { 8700 this.$refs[this.root + parentIndex][0].focus(); 8701 }, 8702 }, 8703 }; 8704 8705 const _hoisted_1$q = { 8706 class: "media-tree", 8707 role: "group" 8708 }; 8709 const _hoisted_2$i = ["aria-level", "aria-setsize", "aria-posinset", "tabindex", "onClick", "onKeyup"]; 8710 const _hoisted_3$e = { class: "item-icon" }; 8711 const _hoisted_4$a = { class: "item-name" }; 8712 8713 function render$q(_ctx, _cache, $props, $setup, $data, $options) { 8714 const _component_media_tree = resolveComponent("media-tree"); 8715 8716 return (openBlock(), createElementBlock("ul", _hoisted_1$q, [ 8717 (openBlock(true), createElementBlock(Fragment, null, renderList($options.directories, (item, index) => { 8718 return (openBlock(), createElementBlock("li", { 8719 key: item.path, 8720 class: normalizeClass(["media-tree-item", {active: $options.isActive(item)}]), 8721 role: "none" 8722 }, [ 8723 createBaseVNode("a", { 8724 ref_for: true, 8725 ref: $props.root + index, 8726 role: "treeitem", 8727 "aria-level": $props.level, 8728 "aria-setsize": $options.directories.length, 8729 "aria-posinset": index, 8730 tabindex: $options.getTabindex(item), 8731 onClick: withModifiers($event => ($options.onItemClick(item)), ["stop","prevent"]), 8732 onKeyup: [ 8733 withKeys($event => ($options.moveFocusToPreviousElement(index)), ["up"]), 8734 withKeys($event => ($options.moveFocusToNextElement(index)), ["down"]), 8735 withKeys($event => ($options.onItemClick(item)), ["enter"]), 8736 withKeys($event => ($options.moveFocusToChildElement(item)), ["right"]), 8737 _cache[0] || (_cache[0] = withKeys($event => ($options.moveFocusToParentElement()), ["left"])) 8738 ] 8739 }, [ 8740 createBaseVNode("span", _hoisted_3$e, [ 8741 createBaseVNode("span", { 8742 class: normalizeClass($options.iconClass(item)) 8743 }, null, 2 /* CLASS */) 8744 ]), 8745 createBaseVNode("span", _hoisted_4$a, toDisplayString(item.name), 1 /* TEXT */) 8746 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_2$i), 8747 createVNode(Transition, { name: "slide-fade" }, { 8748 default: withCtx(() => [ 8749 ($options.hasChildren(item)) 8750 ? withDirectives((openBlock(), createBlock(_component_media_tree, { 8751 key: 0, 8752 ref_for: true, 8753 ref: item.path, 8754 "aria-expanded": $options.isOpen(item) ? 'true' : 'false', 8755 root: item.path, 8756 level: ($props.level+1), 8757 "parent-index": index, 8758 onMoveFocusToParent: $options.restoreFocus 8759 }, null, 8 /* PROPS */, ["aria-expanded", "root", "level", "parent-index", "onMoveFocusToParent"])), [ 8760 [vShow, $options.isOpen(item)] 8761 ]) 8762 : createCommentVNode("v-if", true) 8763 ]), 8764 _: 2 /* DYNAMIC */ 8765 }, 1024 /* DYNAMIC_SLOTS */) 8766 ], 2 /* CLASS */)) 8767 }), 128 /* KEYED_FRAGMENT */)) 8768 ])) 8769 } 8770 8771 script$q.render = render$q; 8772 script$q.__file = "administrator/components/com_media/resources/scripts/components/tree/tree.vue"; 8773 8774 var script$p = { 8775 name: 'MediaToolbar', 8776 computed: { 8777 toggleListViewBtnIcon() { 8778 return (this.isGridView) ? 'icon-list' : 'icon-th'; 8779 }, 8780 isLoading() { 8781 return this.$store.state.isLoading; 8782 }, 8783 atLeastOneItemSelected() { 8784 return this.$store.state.selectedItems.length > 0; 8785 }, 8786 isGridView() { 8787 return (this.$store.state.listView === 'grid'); 8788 }, 8789 allItemsSelected() { 8790 // eslint-disable-next-line max-len 8791 return (this.$store.getters.getSelectedDirectoryContents.length === this.$store.state.selectedItems.length); 8792 }, 8793 search() { 8794 return this.$store.state.search; 8795 }, 8796 }, 8797 watch: { 8798 // eslint-disable-next-line 8799 '$store.state.selectedItems'() { 8800 if (!this.allItemsSelected) { 8801 this.$refs.mediaToolbarSelectAll.checked = false; 8802 } 8803 }, 8804 }, 8805 methods: { 8806 toggleInfoBar() { 8807 if (this.$store.state.showInfoBar) { 8808 this.$store.commit(HIDE_INFOBAR); 8809 } else { 8810 this.$store.commit(SHOW_INFOBAR); 8811 } 8812 }, 8813 decreaseGridSize() { 8814 if (!this.isGridSize('sm')) { 8815 this.$store.commit(DECREASE_GRID_SIZE); 8816 } 8817 }, 8818 increaseGridSize() { 8819 if (!this.isGridSize('xl')) { 8820 this.$store.commit(INCREASE_GRID_SIZE); 8821 } 8822 }, 8823 changeListView() { 8824 if (this.$store.state.listView === 'grid') { 8825 this.$store.commit(CHANGE_LIST_VIEW, 'table'); 8826 } else { 8827 this.$store.commit(CHANGE_LIST_VIEW, 'grid'); 8828 } 8829 }, 8830 toggleSelectAll() { 8831 if (this.allItemsSelected) { 8832 this.$store.commit(UNSELECT_ALL_BROWSER_ITEMS); 8833 } else { 8834 // eslint-disable-next-line max-len 8835 this.$store.commit(SELECT_BROWSER_ITEMS, this.$store.getters.getSelectedDirectoryContents); 8836 window.parent.document.dispatchEvent( 8837 new CustomEvent( 8838 'onMediaFileSelected', 8839 { 8840 bubbles: true, 8841 cancelable: false, 8842 detail: {}, 8843 }, 8844 ), 8845 ); 8846 } 8847 }, 8848 isGridSize(size) { 8849 return (this.$store.state.gridSize === size); 8850 }, 8851 changeSearch(query) { 8852 this.$store.commit(SET_SEARCH_QUERY, query.target.value); 8853 }, 8854 }, 8855 }; 8856 8857 const _hoisted_1$p = ["aria-label"]; 8858 const _hoisted_2$h = { 8859 key: 0, 8860 class: "media-loader" 8861 }; 8862 const _hoisted_3$d = { class: "media-view-icons" }; 8863 const _hoisted_4$9 = ["aria-label"]; 8864 const _hoisted_5$9 = { 8865 class: "media-view-search-input", 8866 role: "search" 8867 }; 8868 const _hoisted_6$7 = { 8869 for: "media_search", 8870 class: "visually-hidden" 8871 }; 8872 const _hoisted_7$4 = ["placeholder", "value"]; 8873 const _hoisted_8$4 = { class: "media-view-icons" }; 8874 const _hoisted_9$4 = ["aria-label"]; 8875 const _hoisted_10$2 = /*#__PURE__*/createBaseVNode("span", { 8876 class: "icon-search-minus", 8877 "aria-hidden": "true" 8878 }, null, -1 /* HOISTED */); 8879 const _hoisted_11$2 = [ 8880 _hoisted_10$2 8881 ]; 8882 const _hoisted_12$2 = ["aria-label"]; 8883 const _hoisted_13$1 = /*#__PURE__*/createBaseVNode("span", { 8884 class: "icon-search-plus", 8885 "aria-hidden": "true" 8886 }, null, -1 /* HOISTED */); 8887 const _hoisted_14 = [ 8888 _hoisted_13$1 8889 ]; 8890 const _hoisted_15 = ["aria-label"]; 8891 const _hoisted_16 = ["aria-label"]; 8892 const _hoisted_17 = /*#__PURE__*/createBaseVNode("span", { 8893 class: "icon-info", 8894 "aria-hidden": "true" 8895 }, null, -1 /* HOISTED */); 8896 const _hoisted_18 = [ 8897 _hoisted_17 8898 ]; 8899 8900 function render$p(_ctx, _cache, $props, $setup, $data, $options) { 8901 const _component_media_breadcrumb = resolveComponent("media-breadcrumb"); 8902 8903 return (openBlock(), createElementBlock("div", { 8904 class: "media-toolbar", 8905 role: "toolbar", 8906 "aria-label": _ctx.translate('COM_MEDIA_TOOLBAR_LABEL') 8907 }, [ 8908 ($options.isLoading) 8909 ? (openBlock(), createElementBlock("div", _hoisted_2$h)) 8910 : createCommentVNode("v-if", true), 8911 createBaseVNode("div", _hoisted_3$d, [ 8912 createBaseVNode("input", { 8913 ref: "mediaToolbarSelectAll", 8914 type: "checkbox", 8915 class: "media-toolbar-icon media-toolbar-select-all", 8916 "aria-label": _ctx.translate('COM_MEDIA_SELECT_ALL'), 8917 onClick: _cache[0] || (_cache[0] = withModifiers((...args) => ($options.toggleSelectAll && $options.toggleSelectAll(...args)), ["stop"])) 8918 }, null, 8 /* PROPS */, _hoisted_4$9) 8919 ]), 8920 createVNode(_component_media_breadcrumb), 8921 createBaseVNode("div", _hoisted_5$9, [ 8922 createBaseVNode("label", _hoisted_6$7, toDisplayString(_ctx.translate('COM_MEDIA_SEARCH')), 1 /* TEXT */), 8923 createBaseVNode("input", { 8924 id: "media_search", 8925 class: "form-control", 8926 type: "text", 8927 placeholder: _ctx.translate('COM_MEDIA_SEARCH'), 8928 value: $options.search, 8929 onInput: _cache[1] || (_cache[1] = (...args) => ($options.changeSearch && $options.changeSearch(...args))) 8930 }, null, 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_7$4) 8931 ]), 8932 createBaseVNode("div", _hoisted_8$4, [ 8933 ($options.isGridView) 8934 ? (openBlock(), createElementBlock("button", { 8935 key: 0, 8936 type: "button", 8937 class: normalizeClass(["media-toolbar-icon media-toolbar-decrease-grid-size", {disabled: $options.isGridSize('sm')}]), 8938 "aria-label": _ctx.translate('COM_MEDIA_DECREASE_GRID'), 8939 onClick: _cache[2] || (_cache[2] = withModifiers($event => ($options.decreaseGridSize()), ["stop","prevent"])) 8940 }, _hoisted_11$2, 10 /* CLASS, PROPS */, _hoisted_9$4)) 8941 : createCommentVNode("v-if", true), 8942 ($options.isGridView) 8943 ? (openBlock(), createElementBlock("button", { 8944 key: 1, 8945 type: "button", 8946 class: normalizeClass(["media-toolbar-icon media-toolbar-increase-grid-size", {disabled: $options.isGridSize('xl')}]), 8947 "aria-label": _ctx.translate('COM_MEDIA_INCREASE_GRID'), 8948 onClick: _cache[3] || (_cache[3] = withModifiers($event => ($options.increaseGridSize()), ["stop","prevent"])) 8949 }, _hoisted_14, 10 /* CLASS, PROPS */, _hoisted_12$2)) 8950 : createCommentVNode("v-if", true), 8951 createBaseVNode("button", { 8952 type: "button", 8953 href: "#", 8954 class: "media-toolbar-icon media-toolbar-list-view", 8955 "aria-label": _ctx.translate('COM_MEDIA_TOGGLE_LIST_VIEW'), 8956 onClick: _cache[4] || (_cache[4] = withModifiers($event => ($options.changeListView()), ["stop","prevent"])) 8957 }, [ 8958 createBaseVNode("span", { 8959 class: normalizeClass($options.toggleListViewBtnIcon), 8960 "aria-hidden": "true" 8961 }, null, 2 /* CLASS */) 8962 ], 8 /* PROPS */, _hoisted_15), 8963 createBaseVNode("button", { 8964 type: "button", 8965 href: "#", 8966 class: "media-toolbar-icon media-toolbar-info", 8967 "aria-label": _ctx.translate('COM_MEDIA_TOGGLE_INFO'), 8968 onClick: _cache[5] || (_cache[5] = withModifiers((...args) => ($options.toggleInfoBar && $options.toggleInfoBar(...args)), ["stop","prevent"])) 8969 }, _hoisted_18, 8 /* PROPS */, _hoisted_16) 8970 ]) 8971 ], 8 /* PROPS */, _hoisted_1$p)) 8972 } 8973 8974 script$p.render = render$p; 8975 script$p.__file = "administrator/components/com_media/resources/scripts/components/toolbar/toolbar.vue"; 8976 8977 var script$o = { 8978 name: 'MediaBreadcrumb', 8979 mixins: [navigable], 8980 computed: { 8981 /* Get the crumbs from the current directory path */ 8982 crumbs() { 8983 const items = []; 8984 8985 const parts = this.$store.state.selectedDirectory.split('/'); 8986 8987 // Add the drive as first element 8988 if (parts) { 8989 const drive = this.findDrive(parts[0]); 8990 8991 if (drive) { 8992 items.push(drive); 8993 parts.shift(); 8994 } 8995 } 8996 8997 parts 8998 .filter((crumb) => crumb.length !== 0) 8999 .forEach((crumb) => { 9000 items.push({ 9001 name: crumb, 9002 path: this.$store.state.selectedDirectory.split(crumb)[0] + crumb, 9003 }); 9004 }); 9005 9006 return items; 9007 }, 9008 /* Whether or not the crumb is the last element in the list */ 9009 isLast(item) { 9010 return this.crumbs.indexOf(item) === this.crumbs.length - 1; 9011 }, 9012 }, 9013 methods: { 9014 /* Handle the on crumb click event */ 9015 onCrumbClick(crumb) { 9016 this.navigateTo(crumb.path); 9017 window.parent.document.dispatchEvent( 9018 new CustomEvent( 9019 'onMediaFileSelected', 9020 { 9021 bubbles: true, 9022 cancelable: false, 9023 detail: {}, 9024 }, 9025 ), 9026 ); 9027 }, 9028 findDrive(adapter) { 9029 let driveObject = null; 9030 9031 this.$store.state.disks.forEach((disk) => { 9032 disk.drives.forEach((drive) => { 9033 if (drive.root.startsWith(adapter)) { 9034 driveObject = { name: drive.displayName, path: drive.root }; 9035 } 9036 }); 9037 }); 9038 9039 return driveObject; 9040 }, 9041 }, 9042 }; 9043 9044 const _hoisted_1$o = ["aria-label"]; 9045 const _hoisted_2$g = ["aria-current", "onClick"]; 9046 9047 function render$o(_ctx, _cache, $props, $setup, $data, $options) { 9048 return (openBlock(), createElementBlock("nav", { 9049 class: "media-breadcrumb", 9050 "aria-label": _ctx.translate('COM_MEDIA_BREADCRUMB_LABEL') 9051 }, [ 9052 createBaseVNode("ol", null, [ 9053 (openBlock(true), createElementBlock(Fragment, null, renderList($options.crumbs, (val, index) => { 9054 return (openBlock(), createElementBlock("li", { 9055 key: index, 9056 class: "media-breadcrumb-item" 9057 }, [ 9058 createBaseVNode("a", { 9059 href: "#", 9060 "aria-current": (index === Object.keys($options.crumbs).length - 1) ? 'page' : undefined, 9061 onClick: withModifiers($event => ($options.onCrumbClick(val)), ["stop","prevent"]) 9062 }, toDisplayString(val.name), 9 /* TEXT, PROPS */, _hoisted_2$g) 9063 ])) 9064 }), 128 /* KEYED_FRAGMENT */)) 9065 ]) 9066 ], 8 /* PROPS */, _hoisted_1$o)) 9067 } 9068 9069 script$o.render = render$o; 9070 script$o.__file = "administrator/components/com_media/resources/scripts/components/breadcrumb/breadcrumb.vue"; 9071 9072 var script$n = { 9073 name: 'MediaBrowser', 9074 computed: { 9075 /* Get the contents of the currently selected directory */ 9076 items() { 9077 // eslint-disable-next-line vue/no-side-effects-in-computed-properties 9078 const directories = this.$store.getters.getSelectedDirectoryDirectories 9079 // Sort by type and alphabetically 9080 .sort((a, b) => ((a.name.toUpperCase() < b.name.toUpperCase()) ? -1 : 1)) 9081 .filter((dir) => dir.name.toLowerCase().includes(this.$store.state.search.toLowerCase())); 9082 9083 // eslint-disable-next-line vue/no-side-effects-in-computed-properties 9084 const files = this.$store.getters.getSelectedDirectoryFiles 9085 // Sort by type and alphabetically 9086 .sort((a, b) => ((a.name.toUpperCase() < b.name.toUpperCase()) ? -1 : 1)) 9087 .filter((file) => file.name.toLowerCase().includes(this.$store.state.search.toLowerCase())); 9088 9089 return [...directories, ...files]; 9090 }, 9091 /* The styles for the media-browser element */ 9092 mediaBrowserStyles() { 9093 return { 9094 width: this.$store.state.showInfoBar ? '75%' : '100%', 9095 }; 9096 }, 9097 /* The styles for the media-browser element */ 9098 listView() { 9099 return this.$store.state.listView; 9100 }, 9101 mediaBrowserGridItemsClass() { 9102 return { 9103 [`media-browser-items-$this.$store.state.gridSize}`]: true, 9104 }; 9105 }, 9106 isModal() { 9107 return Joomla.getOptions('com_media', {}).isModal; 9108 }, 9109 currentDirectory() { 9110 const parts = this.$store.state.selectedDirectory.split('/').filter((crumb) => crumb.length !== 0); 9111 9112 // The first part is the name of the drive, so if we have a folder name display it. Else 9113 // find the filename 9114 if (parts.length !== 1) { 9115 return parts[parts.length - 1]; 9116 } 9117 9118 let diskName = ''; 9119 9120 this.$store.state.disks.forEach((disk) => { 9121 disk.drives.forEach((drive) => { 9122 if (drive.root === `$parts[0]}/`) { 9123 diskName = drive.displayName; 9124 } 9125 }); 9126 }); 9127 9128 return diskName; 9129 }, 9130 }, 9131 created() { 9132 document.body.addEventListener('click', this.unselectAllBrowserItems, false); 9133 }, 9134 beforeUnmount() { 9135 document.body.removeEventListener('click', this.unselectAllBrowserItems, false); 9136 }, 9137 methods: { 9138 /* Unselect all browser items */ 9139 unselectAllBrowserItems(event) { 9140 const clickedDelete = !!((event.target.id !== undefined && event.target.id === 'mediaDelete')); 9141 const notClickedBrowserItems = (this.$refs.browserItems 9142 && !this.$refs.browserItems.contains(event.target)) 9143 || event.target === this.$refs.browserItems; 9144 9145 const notClickedInfobar = this.$refs.infobar !== undefined 9146 && !this.$refs.infobar.$el.contains(event.target); 9147 9148 const clickedOutside = notClickedBrowserItems && notClickedInfobar && !clickedDelete; 9149 if (clickedOutside) { 9150 this.$store.commit(UNSELECT_ALL_BROWSER_ITEMS); 9151 9152 window.parent.document.dispatchEvent( 9153 new CustomEvent( 9154 'onMediaFileSelected', 9155 { 9156 bubbles: true, 9157 cancelable: false, 9158 detail: { 9159 path: '', 9160 thumb: false, 9161 fileType: false, 9162 extension: false, 9163 }, 9164 }, 9165 ), 9166 ); 9167 } 9168 }, 9169 9170 // Listeners for drag and drop 9171 // Fix for Chrome 9172 onDragEnter(e) { 9173 e.stopPropagation(); 9174 return false; 9175 }, 9176 9177 // Notify user when file is over the drop area 9178 onDragOver(e) { 9179 e.preventDefault(); 9180 document.querySelector('.media-dragoutline').classList.add('active'); 9181 return false; 9182 }, 9183 9184 /* Upload files */ 9185 upload(file) { 9186 // Create a new file reader instance 9187 const reader = new FileReader(); 9188 9189 // Add the on load callback 9190 reader.onload = (progressEvent) => { 9191 const { result } = progressEvent.target; 9192 const splitIndex = result.indexOf('base64') + 7; 9193 const content = result.slice(splitIndex, result.length); 9194 9195 // Upload the file 9196 this.$store.dispatch('uploadFile', { 9197 name: file.name, 9198 parent: this.$store.state.selectedDirectory, 9199 content, 9200 }); 9201 }; 9202 9203 reader.readAsDataURL(file); 9204 }, 9205 9206 // Logic for the dropped file 9207 onDrop(e) { 9208 e.preventDefault(); 9209 9210 // Loop through array of files and upload each file 9211 if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length > 0) { 9212 // eslint-disable-next-line no-plusplus,no-cond-assign 9213 for (let i = 0, f; f = e.dataTransfer.files[i]; i++) { 9214 document.querySelector('.media-dragoutline').classList.remove('active'); 9215 this.upload(f); 9216 } 9217 } 9218 document.querySelector('.media-dragoutline').classList.remove('active'); 9219 }, 9220 9221 // Reset the drop area border 9222 onDragLeave(e) { 9223 e.stopPropagation(); 9224 e.preventDefault(); 9225 document.querySelector('.media-dragoutline').classList.remove('active'); 9226 return false; 9227 }, 9228 }, 9229 }; 9230 9231 const _hoisted_1$n = { class: "media-dragoutline" }; 9232 const _hoisted_2$f = /*#__PURE__*/createBaseVNode("span", { 9233 class: "icon-cloud-upload upload-icon", 9234 "aria-hidden": "true" 9235 }, null, -1 /* HOISTED */); 9236 const _hoisted_3$c = { 9237 key: 0, 9238 class: "table media-browser-table" 9239 }; 9240 const _hoisted_4$8 = { class: "visually-hidden" }; 9241 const _hoisted_5$8 = { class: "media-browser-table-head" }; 9242 const _hoisted_6$6 = /*#__PURE__*/createBaseVNode("th", { 9243 class: "type", 9244 scope: "col" 9245 }, null, -1 /* HOISTED */); 9246 const _hoisted_7$3 = { 9247 class: "name", 9248 scope: "col" 9249 }; 9250 const _hoisted_8$3 = { 9251 class: "size", 9252 scope: "col" 9253 }; 9254 const _hoisted_9$3 = { 9255 class: "dimension", 9256 scope: "col" 9257 }; 9258 const _hoisted_10$1 = { 9259 class: "created", 9260 scope: "col" 9261 }; 9262 const _hoisted_11$1 = { 9263 class: "modified", 9264 scope: "col" 9265 }; 9266 const _hoisted_12$1 = { 9267 key: 1, 9268 class: "media-browser-grid" 9269 }; 9270 9271 function render$n(_ctx, _cache, $props, $setup, $data, $options) { 9272 const _component_media_browser_item_row = resolveComponent("media-browser-item-row"); 9273 const _component_media_browser_item = resolveComponent("media-browser-item"); 9274 const _component_media_infobar = resolveComponent("media-infobar"); 9275 9276 return (openBlock(), createElementBlock("div", null, [ 9277 createBaseVNode("div", { 9278 ref: "browserItems", 9279 class: "media-browser", 9280 style: normalizeStyle($options.mediaBrowserStyles), 9281 onDragenter: _cache[0] || (_cache[0] = (...args) => ($options.onDragEnter && $options.onDragEnter(...args))), 9282 onDrop: _cache[1] || (_cache[1] = (...args) => ($options.onDrop && $options.onDrop(...args))), 9283 onDragover: _cache[2] || (_cache[2] = (...args) => ($options.onDragOver && $options.onDragOver(...args))), 9284 onDragleave: _cache[3] || (_cache[3] = (...args) => ($options.onDragLeave && $options.onDragLeave(...args))) 9285 }, [ 9286 createBaseVNode("div", _hoisted_1$n, [ 9287 _hoisted_2$f, 9288 createBaseVNode("p", null, toDisplayString(_ctx.translate('COM_MEDIA_DROP_FILE')), 1 /* TEXT */) 9289 ]), 9290 ($options.listView === 'table') 9291 ? (openBlock(), createElementBlock("table", _hoisted_3$c, [ 9292 createBaseVNode("caption", _hoisted_4$8, toDisplayString(_ctx.sprintf('COM_MEDIA_BROWSER_TABLE_CAPTION', $options.currentDirectory)), 1 /* TEXT */), 9293 createBaseVNode("thead", _hoisted_5$8, [ 9294 createBaseVNode("tr", null, [ 9295 _hoisted_6$6, 9296 createBaseVNode("th", _hoisted_7$3, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_NAME')), 1 /* TEXT */), 9297 createBaseVNode("th", _hoisted_8$3, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_SIZE')), 1 /* TEXT */), 9298 createBaseVNode("th", _hoisted_9$3, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_DIMENSION')), 1 /* TEXT */), 9299 createBaseVNode("th", _hoisted_10$1, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_DATE_CREATED')), 1 /* TEXT */), 9300 createBaseVNode("th", _hoisted_11$1, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_DATE_MODIFIED')), 1 /* TEXT */) 9301 ]) 9302 ]), 9303 createBaseVNode("tbody", null, [ 9304 (openBlock(true), createElementBlock(Fragment, null, renderList($options.items, (item) => { 9305 return (openBlock(), createBlock(_component_media_browser_item_row, { 9306 key: item.path, 9307 item: item 9308 }, null, 8 /* PROPS */, ["item"])) 9309 }), 128 /* KEYED_FRAGMENT */)) 9310 ]) 9311 ])) 9312 : ($options.listView === 'grid') 9313 ? (openBlock(), createElementBlock("div", _hoisted_12$1, [ 9314 createBaseVNode("div", { 9315 class: normalizeClass(["media-browser-items", $options.mediaBrowserGridItemsClass]) 9316 }, [ 9317 (openBlock(true), createElementBlock(Fragment, null, renderList($options.items, (item) => { 9318 return (openBlock(), createBlock(_component_media_browser_item, { 9319 key: item.path, 9320 item: item 9321 }, null, 8 /* PROPS */, ["item"])) 9322 }), 128 /* KEYED_FRAGMENT */)) 9323 ], 2 /* CLASS */) 9324 ])) 9325 : createCommentVNode("v-if", true) 9326 ], 36 /* STYLE, HYDRATE_EVENTS */), 9327 createVNode(_component_media_infobar, { ref: "infobar" }, null, 512 /* NEED_PATCH */) 9328 ])) 9329 } 9330 9331 script$n.render = render$n; 9332 script$n.__file = "administrator/components/com_media/resources/scripts/components/browser/browser.vue"; 9333 9334 var script$m = { 9335 name: 'MediaBrowserItemDirectory', 9336 mixins: [navigable], 9337 // eslint-disable-next-line vue/require-prop-types 9338 props: ['item'], 9339 emits: ['toggle-settings'], 9340 data() { 9341 return { 9342 showActions: false, 9343 }; 9344 }, 9345 methods: { 9346 /* Handle the on preview double click event */ 9347 onPreviewDblClick() { 9348 this.navigateTo(this.item.path); 9349 }, 9350 /* Hide actions dropdown */ 9351 hideActions() { 9352 this.$refs.container.hideActions(); 9353 }, 9354 toggleSettings(bool) { 9355 this.$emit('toggle-settings', bool); 9356 }, 9357 }, 9358 }; 9359 9360 const _hoisted_1$m = /*#__PURE__*/createBaseVNode("div", { class: "file-background" }, [ 9361 /*#__PURE__*/createBaseVNode("div", { class: "folder-icon" }, [ 9362 /*#__PURE__*/createBaseVNode("span", { class: "icon-folder" }) 9363 ]) 9364 ], -1 /* HOISTED */); 9365 const _hoisted_2$e = [ 9366 _hoisted_1$m 9367 ]; 9368 const _hoisted_3$b = { class: "media-browser-item-info" }; 9369 9370 function render$m(_ctx, _cache, $props, $setup, $data, $options) { 9371 const _component_media_browser_action_items_container = resolveComponent("media-browser-action-items-container"); 9372 9373 return (openBlock(), createElementBlock("div", { 9374 class: "media-browser-item-directory", 9375 onMouseleave: _cache[2] || (_cache[2] = $event => ($options.hideActions())) 9376 }, [ 9377 createBaseVNode("div", { 9378 class: "media-browser-item-preview", 9379 tabindex: "0", 9380 onDblclick: _cache[0] || (_cache[0] = withModifiers($event => ($options.onPreviewDblClick()), ["stop","prevent"])), 9381 onKeyup: _cache[1] || (_cache[1] = withKeys($event => ($options.onPreviewDblClick()), ["enter"])) 9382 }, _hoisted_2$e, 32 /* HYDRATE_EVENTS */), 9383 createBaseVNode("div", _hoisted_3$b, toDisplayString($props.item.name), 1 /* TEXT */), 9384 createVNode(_component_media_browser_action_items_container, { 9385 ref: "container", 9386 item: $props.item, 9387 onToggleSettings: $options.toggleSettings 9388 }, null, 8 /* PROPS */, ["item", "onToggleSettings"]) 9389 ], 32 /* HYDRATE_EVENTS */)) 9390 } 9391 9392 script$m.render = render$m; 9393 script$m.__file = "administrator/components/com_media/resources/scripts/components/browser/items/directory.vue"; 9394 9395 var script$l = { 9396 name: 'MediaBrowserItemFile', 9397 // eslint-disable-next-line vue/require-prop-types 9398 props: ['item', 'focused'], 9399 emits: ['toggle-settings'], 9400 data() { 9401 return { 9402 showActions: false, 9403 }; 9404 }, 9405 methods: { 9406 /* Hide actions dropdown */ 9407 hideActions() { 9408 this.$refs.container.hideActions(); 9409 }, 9410 /* Preview an item */ 9411 openPreview() { 9412 this.$refs.container.openPreview(); 9413 }, 9414 toggleSettings(bool) { 9415 this.$emit('toggle-settings', bool); 9416 }, 9417 }, 9418 }; 9419 9420 const _hoisted_1$l = /*#__PURE__*/createBaseVNode("div", { class: "media-browser-item-preview" }, [ 9421 /*#__PURE__*/createBaseVNode("div", { class: "file-background" }, [ 9422 /*#__PURE__*/createBaseVNode("div", { class: "file-icon" }, [ 9423 /*#__PURE__*/createBaseVNode("span", { class: "icon-file-alt" }) 9424 ]) 9425 ]) 9426 ], -1 /* HOISTED */); 9427 const _hoisted_2$d = { class: "media-browser-item-info" }; 9428 const _hoisted_3$a = ["aria-label", "title"]; 9429 9430 function render$l(_ctx, _cache, $props, $setup, $data, $options) { 9431 const _component_media_browser_action_items_container = resolveComponent("media-browser-action-items-container"); 9432 9433 return (openBlock(), createElementBlock("div", { 9434 class: "media-browser-item-file", 9435 onMouseleave: _cache[0] || (_cache[0] = $event => ($options.hideActions())) 9436 }, [ 9437 _hoisted_1$l, 9438 createBaseVNode("div", _hoisted_2$d, toDisplayString($props.item.name) + " " + toDisplayString($props.item.filetype), 1 /* TEXT */), 9439 createBaseVNode("span", { 9440 class: "media-browser-select", 9441 "aria-label": _ctx.translate('COM_MEDIA_TOGGLE_SELECT_ITEM'), 9442 title: _ctx.translate('COM_MEDIA_TOGGLE_SELECT_ITEM') 9443 }, null, 8 /* PROPS */, _hoisted_3$a), 9444 createVNode(_component_media_browser_action_items_container, { 9445 ref: "container", 9446 item: $props.item, 9447 previewable: true, 9448 downloadable: true, 9449 shareable: true, 9450 onToggleSettings: $options.toggleSettings 9451 }, null, 8 /* PROPS */, ["item", "onToggleSettings"]) 9452 ], 32 /* HYDRATE_EVENTS */)) 9453 } 9454 9455 script$l.render = render$l; 9456 script$l.__file = "administrator/components/com_media/resources/scripts/components/browser/items/file.vue"; 9457 9458 const dirname = path => { 9459 if (typeof path !== 'string') { 9460 throw new TypeError('Path must be a string. Received ' + JSON.stringify(path)); 9461 } 9462 9463 if (path.length === 0) return '.'; 9464 let code = path.charCodeAt(0); 9465 const hasRoot = code === 47; 9466 let end = -1; 9467 let matchedSlash = true; 9468 9469 for (let i = path.length - 1; i >= 1; --i) { 9470 code = path.charCodeAt(i); 9471 9472 if (code === 47) { 9473 if (!matchedSlash) { 9474 end = i; 9475 break; 9476 } 9477 } else { 9478 // We saw the first non-path separator 9479 matchedSlash = false; 9480 } 9481 } 9482 9483 if (end === -1) return hasRoot ? '/' : '.'; 9484 if (hasRoot && end === 1) return '//'; 9485 return path.slice(0, end); 9486 }; 9487 9488 /** 9489 * Api class for communication with the server 9490 */ 9491 9492 class Api { 9493 /** 9494 * Store constructor 9495 */ 9496 constructor() { 9497 const options = Joomla.getOptions('com_media', {}); 9498 9499 if (options.apiBaseUrl === undefined) { 9500 throw new TypeError('Media api baseUrl is not defined'); 9501 } 9502 9503 if (options.csrfToken === undefined) { 9504 throw new TypeError('Media api csrf token is not defined'); 9505 } // eslint-disable-next-line no-underscore-dangle 9506 9507 9508 this._baseUrl = options.apiBaseUrl; // eslint-disable-next-line no-underscore-dangle 9509 9510 this._csrfToken = Joomla.getOptions('csrf.token'); 9511 this.imagesExtensions = options.imagesExtensions; 9512 this.audioExtensions = options.audioExtensions; 9513 this.videoExtensions = options.videoExtensions; 9514 this.documentExtensions = options.documentExtensions; 9515 this.mediaVersion = new Date().getTime().toString(); 9516 this.canCreate = options.canCreate || false; 9517 this.canEdit = options.canEdit || false; 9518 this.canDelete = options.canDelete || false; 9519 } 9520 /** 9521 * Get the contents of a directory from the server 9522 * @param {string} dir The directory path 9523 * @param {number} full whether or not the persistent url should be returned 9524 * @param {number} content whether or not the content should be returned 9525 * @returns {Promise} 9526 */ 9527 9528 9529 getContents(dir, full, content) { 9530 // Wrap the ajax call into a real promise 9531 return new Promise((resolve, reject) => { 9532 // Do a check on full 9533 if (['0', '1'].indexOf(full) !== -1) { 9534 throw Error('Invalid parameter: full'); 9535 } // Do a check on download 9536 9537 9538 if (['0', '1'].indexOf(content) !== -1) { 9539 throw Error('Invalid parameter: content'); 9540 } // eslint-disable-next-line no-underscore-dangle 9541 9542 9543 let url = `$this._baseUrl}&task=api.files&path=$dir}`; 9544 9545 if (full) { 9546 url += `&url=$full}`; 9547 } 9548 9549 if (content) { 9550 url += `&content=$content}`; 9551 } 9552 9553 Joomla.request({ 9554 url, 9555 method: 'GET', 9556 headers: { 9557 'Content-Type': 'application/json' 9558 }, 9559 onSuccess: response => { 9560 // eslint-disable-next-line no-underscore-dangle 9561 resolve(this._normalizeArray(JSON.parse(response).data)); 9562 }, 9563 onError: xhr => { 9564 reject(xhr); 9565 } 9566 }); // eslint-disable-next-line no-underscore-dangle 9567 }).catch(this._handleError); 9568 } 9569 /** 9570 * Create a directory 9571 * @param name 9572 * @param parent 9573 * @returns {Promise.<T>} 9574 */ 9575 9576 9577 createDirectory(name, parent) { 9578 // Wrap the ajax call into a real promise 9579 return new Promise((resolve, reject) => { 9580 // eslint-disable-next-line no-underscore-dangle 9581 const url = `$this._baseUrl}&task=api.files&path=$parent}`; // eslint-disable-next-line no-underscore-dangle 9582 9583 const data = { 9584 [this._csrfToken]: '1', 9585 name 9586 }; 9587 Joomla.request({ 9588 url, 9589 method: 'POST', 9590 data: JSON.stringify(data), 9591 headers: { 9592 'Content-Type': 'application/json' 9593 }, 9594 onSuccess: response => { 9595 notifications.success('COM_MEDIA_CREATE_NEW_FOLDER_SUCCESS'); // eslint-disable-next-line no-underscore-dangle 9596 9597 resolve(this._normalizeItem(JSON.parse(response).data)); 9598 }, 9599 onError: xhr => { 9600 notifications.error('COM_MEDIA_CREATE_NEW_FOLDER_ERROR'); 9601 reject(xhr); 9602 } 9603 }); // eslint-disable-next-line no-underscore-dangle 9604 }).catch(this._handleError); 9605 } 9606 /** 9607 * Upload a file 9608 * @param name 9609 * @param parent 9610 * @param content base64 encoded string 9611 * @param override boolean whether or not we should override existing files 9612 * @return {Promise.<T>} 9613 */ 9614 9615 9616 upload(name, parent, content, override) { 9617 // Wrap the ajax call into a real promise 9618 return new Promise((resolve, reject) => { 9619 // eslint-disable-next-line no-underscore-dangle 9620 const url = `$this._baseUrl}&task=api.files&path=$parent}`; 9621 const data = { 9622 // eslint-disable-next-line no-underscore-dangle 9623 [this._csrfToken]: '1', 9624 name, 9625 content 9626 }; // Append override 9627 9628 if (override === true) { 9629 data.override = true; 9630 } 9631 9632 Joomla.request({ 9633 url, 9634 method: 'POST', 9635 data: JSON.stringify(data), 9636 headers: { 9637 'Content-Type': 'application/json' 9638 }, 9639 onSuccess: response => { 9640 notifications.success('COM_MEDIA_UPLOAD_SUCCESS'); // eslint-disable-next-line no-underscore-dangle 9641 9642 resolve(this._normalizeItem(JSON.parse(response).data)); 9643 }, 9644 onError: xhr => { 9645 reject(xhr); 9646 } 9647 }); // eslint-disable-next-line no-underscore-dangle 9648 }).catch(this._handleError); 9649 } 9650 /** 9651 * Rename an item 9652 * @param path 9653 * @param newPath 9654 * @return {Promise.<T>} 9655 */ 9656 // eslint-disable-next-line no-shadow 9657 9658 9659 rename(path, newPath) { 9660 // Wrap the ajax call into a real promise 9661 return new Promise((resolve, reject) => { 9662 // eslint-disable-next-line no-underscore-dangle 9663 const url = `$this._baseUrl}&task=api.files&path=$path}`; 9664 const data = { 9665 // eslint-disable-next-line no-underscore-dangle 9666 [this._csrfToken]: '1', 9667 newPath 9668 }; 9669 Joomla.request({ 9670 url, 9671 method: 'PUT', 9672 data: JSON.stringify(data), 9673 headers: { 9674 'Content-Type': 'application/json' 9675 }, 9676 onSuccess: response => { 9677 notifications.success('COM_MEDIA_RENAME_SUCCESS'); // eslint-disable-next-line no-underscore-dangle 9678 9679 resolve(this._normalizeItem(JSON.parse(response).data)); 9680 }, 9681 onError: xhr => { 9682 notifications.error('COM_MEDIA_RENAME_ERROR'); 9683 reject(xhr); 9684 } 9685 }); // eslint-disable-next-line no-underscore-dangle 9686 }).catch(this._handleError); 9687 } 9688 /** 9689 * Delete a file 9690 * @param path 9691 * @return {Promise.<T>} 9692 */ 9693 // eslint-disable-next-line no-shadow 9694 9695 9696 delete(path) { 9697 // Wrap the ajax call into a real promise 9698 return new Promise((resolve, reject) => { 9699 // eslint-disable-next-line no-underscore-dangle 9700 const url = `$this._baseUrl}&task=api.files&path=$path}`; // eslint-disable-next-line no-underscore-dangle 9701 9702 const data = { 9703 [this._csrfToken]: '1' 9704 }; 9705 Joomla.request({ 9706 url, 9707 method: 'DELETE', 9708 data: JSON.stringify(data), 9709 headers: { 9710 'Content-Type': 'application/json' 9711 }, 9712 onSuccess: () => { 9713 notifications.success('COM_MEDIA_DELETE_SUCCESS'); 9714 resolve(); 9715 }, 9716 onError: xhr => { 9717 notifications.error('COM_MEDIA_DELETE_ERROR'); 9718 reject(xhr); 9719 } 9720 }); // eslint-disable-next-line no-underscore-dangle 9721 }).catch(this._handleError); 9722 } 9723 /** 9724 * Normalize a single item 9725 * @param item 9726 * @returns {*} 9727 * @private 9728 */ 9729 // eslint-disable-next-line no-underscore-dangle,class-methods-use-this 9730 9731 9732 _normalizeItem(item) { 9733 if (item.type === 'dir') { 9734 item.directories = []; 9735 item.files = []; 9736 } 9737 9738 item.directory = dirname(item.path); 9739 9740 if (item.directory.indexOf(':', item.directory.length - 1) !== -1) { 9741 item.directory += '/'; 9742 } 9743 9744 return item; 9745 } 9746 /** 9747 * Normalize array data 9748 * @param data 9749 * @returns {{directories, files}} 9750 * @private 9751 */ 9752 // eslint-disable-next-line no-underscore-dangle 9753 9754 9755 _normalizeArray(data) { 9756 const directories = data.filter(item => item.type === 'dir') // eslint-disable-next-line no-underscore-dangle 9757 .map(directory => this._normalizeItem(directory)); 9758 const files = data.filter(item => item.type === 'file') // eslint-disable-next-line no-underscore-dangle 9759 .map(file => this._normalizeItem(file)); 9760 return { 9761 directories, 9762 files 9763 }; 9764 } 9765 /** 9766 * Handle errors 9767 * @param error 9768 * @private 9769 * 9770 * @TODO DN improve error handling 9771 */ 9772 // eslint-disable-next-line no-underscore-dangle,class-methods-use-this 9773 9774 9775 _handleError(error) { 9776 const response = JSON.parse(error.response); 9777 9778 if (response.message) { 9779 notifications.error(response.message); 9780 } else { 9781 switch (error.status) { 9782 case 409: 9783 // Handled in consumer 9784 break; 9785 9786 case 404: 9787 notifications.error('COM_MEDIA_ERROR_NOT_FOUND'); 9788 break; 9789 9790 case 401: 9791 notifications.error('COM_MEDIA_ERROR_NOT_AUTHENTICATED'); 9792 break; 9793 9794 case 403: 9795 notifications.error('COM_MEDIA_ERROR_NOT_AUTHORIZED'); 9796 break; 9797 9798 case 500: 9799 notifications.error('COM_MEDIA_SERVER_ERROR'); 9800 break; 9801 9802 default: 9803 notifications.error('COM_MEDIA_ERROR'); 9804 } 9805 } 9806 9807 throw error; 9808 } 9809 9810 } // eslint-disable-next-line import/prefer-default-export 9811 9812 9813 const api = new Api(); 9814 9815 var script$k = { 9816 name: 'MediaBrowserItemImage', 9817 props: { 9818 item: { type: Object, required: true }, 9819 focused: { type: Boolean, required: true, default: false }, 9820 }, 9821 emits: ['toggle-settings'], 9822 data() { 9823 return { 9824 showActions: { type: Boolean, default: false }, 9825 }; 9826 }, 9827 computed: { 9828 getURL() { 9829 if (!this.item.thumb_path) { 9830 return ''; 9831 } 9832 9833 return this.item.thumb_path.split(Joomla.getOptions('system.paths').rootFull).length > 1 9834 ? `$this.item.thumb_path}?$api.mediaVersion}` 9835 : `$this.item.thumb_path}`; 9836 }, 9837 width() { 9838 return this.item.width > 0 ? this.item.width : null; 9839 }, 9840 height() { 9841 return this.item.height > 0 ? this.item.height : null; 9842 }, 9843 loading() { 9844 return this.item.width > 0 ? 'lazy' : null; 9845 }, 9846 altTag() { 9847 return this.item.name; 9848 }, 9849 }, 9850 methods: { 9851 /* Check if the item is an image to edit */ 9852 canEdit() { 9853 return ['jpg', 'jpeg', 'png'].includes(this.item.extension.toLowerCase()); 9854 }, 9855 /* Hide actions dropdown */ 9856 hideActions() { 9857 this.$refs.container.hideActions(); 9858 }, 9859 /* Preview an item */ 9860 openPreview() { 9861 this.$refs.container.openPreview(); 9862 }, 9863 /* Edit an item */ 9864 editItem() { 9865 // @todo should we use relative urls here? 9866 const fileBaseUrl = `$Joomla.getOptions('com_media').editViewUrl}&path=`; 9867 9868 window.location.href = fileBaseUrl + this.item.path; 9869 }, 9870 toggleSettings(bool) { 9871 this.$emit('toggle-settings', bool); 9872 }, 9873 }, 9874 }; 9875 9876 const _hoisted_1$k = ["title"]; 9877 const _hoisted_2$c = { class: "image-background" }; 9878 const _hoisted_3$9 = ["src", "alt", "loading", "width", "height"]; 9879 const _hoisted_4$7 = { 9880 key: 1, 9881 class: "icon-eye-slash image-placeholder", 9882 "aria-hidden": "true" 9883 }; 9884 const _hoisted_5$7 = ["title"]; 9885 const _hoisted_6$5 = ["aria-label", "title"]; 9886 9887 function render$k(_ctx, _cache, $props, $setup, $data, $options) { 9888 const _component_media_browser_action_items_container = resolveComponent("media-browser-action-items-container"); 9889 9890 return (openBlock(), createElementBlock("div", { 9891 class: "media-browser-image", 9892 tabindex: "0", 9893 onDblclick: _cache[0] || (_cache[0] = $event => ($options.openPreview())), 9894 onMouseleave: _cache[1] || (_cache[1] = $event => ($options.hideActions())), 9895 onKeyup: _cache[2] || (_cache[2] = withKeys($event => ($options.openPreview()), ["enter"])) 9896 }, [ 9897 createBaseVNode("div", { 9898 class: "media-browser-item-preview", 9899 title: $props.item.name 9900 }, [ 9901 createBaseVNode("div", _hoisted_2$c, [ 9902 ($options.getURL) 9903 ? (openBlock(), createElementBlock("img", { 9904 key: 0, 9905 class: "image-cropped", 9906 src: $options.getURL, 9907 alt: $options.altTag, 9908 loading: $options.loading, 9909 width: $options.width, 9910 height: $options.height 9911 }, null, 8 /* PROPS */, _hoisted_3$9)) 9912 : createCommentVNode("v-if", true), 9913 (!$options.getURL) 9914 ? (openBlock(), createElementBlock("span", _hoisted_4$7)) 9915 : createCommentVNode("v-if", true) 9916 ]) 9917 ], 8 /* PROPS */, _hoisted_1$k), 9918 createBaseVNode("div", { 9919 class: "media-browser-item-info", 9920 title: $props.item.name 9921 }, toDisplayString($props.item.name) + " " + toDisplayString($props.item.filetype), 9 /* TEXT, PROPS */, _hoisted_5$7), 9922 createBaseVNode("span", { 9923 class: "media-browser-select", 9924 "aria-label": _ctx.translate('COM_MEDIA_TOGGLE_SELECT_ITEM'), 9925 title: _ctx.translate('COM_MEDIA_TOGGLE_SELECT_ITEM') 9926 }, null, 8 /* PROPS */, _hoisted_6$5), 9927 createVNode(_component_media_browser_action_items_container, { 9928 ref: "container", 9929 item: $props.item, 9930 edit: $options.editItem, 9931 previewable: true, 9932 downloadable: true, 9933 shareable: true, 9934 onToggleSettings: $options.toggleSettings 9935 }, null, 8 /* PROPS */, ["item", "edit", "onToggleSettings"]) 9936 ], 32 /* HYDRATE_EVENTS */)) 9937 } 9938 9939 script$k.render = render$k; 9940 script$k.__file = "administrator/components/com_media/resources/scripts/components/browser/items/image.vue"; 9941 9942 var script$j = { 9943 name: 'MediaBrowserItemVideo', 9944 // eslint-disable-next-line vue/require-prop-types 9945 props: ['item', 'focused'], 9946 emits: ['toggle-settings'], 9947 data() { 9948 return { 9949 showActions: false, 9950 }; 9951 }, 9952 methods: { 9953 /* Hide actions dropdown */ 9954 hideActions() { 9955 this.$refs.container.hideActions(); 9956 }, 9957 /* Preview an item */ 9958 openPreview() { 9959 this.$refs.container.openPreview(); 9960 }, 9961 toggleSettings(bool) { 9962 this.$emit('toggle-settings', bool); 9963 }, 9964 }, 9965 }; 9966 9967 const _hoisted_1$j = /*#__PURE__*/createBaseVNode("div", { class: "media-browser-item-preview" }, [ 9968 /*#__PURE__*/createBaseVNode("div", { class: "file-background" }, [ 9969 /*#__PURE__*/createBaseVNode("div", { class: "file-icon" }, [ 9970 /*#__PURE__*/createBaseVNode("span", { class: "fas fa-file-video" }) 9971 ]) 9972 ]) 9973 ], -1 /* HOISTED */); 9974 const _hoisted_2$b = { class: "media-browser-item-info" }; 9975 9976 function render$j(_ctx, _cache, $props, $setup, $data, $options) { 9977 const _component_media_browser_action_items_container = resolveComponent("media-browser-action-items-container"); 9978 9979 return (openBlock(), createElementBlock("div", { 9980 class: "media-browser-image", 9981 onDblclick: _cache[0] || (_cache[0] = $event => ($options.openPreview())), 9982 onMouseleave: _cache[1] || (_cache[1] = $event => ($options.hideActions())) 9983 }, [ 9984 _hoisted_1$j, 9985 createBaseVNode("div", _hoisted_2$b, toDisplayString($props.item.name) + " " + toDisplayString($props.item.filetype), 1 /* TEXT */), 9986 createVNode(_component_media_browser_action_items_container, { 9987 ref: "container", 9988 item: $props.item, 9989 previewable: true, 9990 downloadable: true, 9991 shareable: true, 9992 onToggleSettings: $options.toggleSettings 9993 }, null, 8 /* PROPS */, ["item", "onToggleSettings"]) 9994 ], 32 /* HYDRATE_EVENTS */)) 9995 } 9996 9997 script$j.render = render$j; 9998 script$j.__file = "administrator/components/com_media/resources/scripts/components/browser/items/video.vue"; 9999 10000 var script$i = { 10001 name: 'MediaBrowserItemAudio', 10002 // eslint-disable-next-line vue/require-prop-types 10003 props: ['item', 'focused'], 10004 emits: ['toggle-settings'], 10005 data() { 10006 return { 10007 showActions: false, 10008 }; 10009 }, 10010 methods: { 10011 /* Hide actions dropdown */ 10012 hideActions() { 10013 this.$refs.container.hideActions(); 10014 }, 10015 /* Preview an item */ 10016 openPreview() { 10017 this.$refs.container.openPreview(); 10018 }, 10019 toggleSettings(bool) { 10020 this.$emit('toggle-settings', bool); 10021 }, 10022 }, 10023 }; 10024 10025 const _hoisted_1$i = /*#__PURE__*/createBaseVNode("div", { class: "media-browser-item-preview" }, [ 10026 /*#__PURE__*/createBaseVNode("div", { class: "file-background" }, [ 10027 /*#__PURE__*/createBaseVNode("div", { class: "file-icon" }, [ 10028 /*#__PURE__*/createBaseVNode("span", { class: "fas fa-file-audio" }) 10029 ]) 10030 ]) 10031 ], -1 /* HOISTED */); 10032 const _hoisted_2$a = { class: "media-browser-item-info" }; 10033 10034 function render$i(_ctx, _cache, $props, $setup, $data, $options) { 10035 const _component_media_browser_action_items_container = resolveComponent("media-browser-action-items-container"); 10036 10037 return (openBlock(), createElementBlock("div", { 10038 class: "media-browser-audio", 10039 tabindex: "0", 10040 onDblclick: _cache[0] || (_cache[0] = $event => ($options.openPreview())), 10041 onMouseleave: _cache[1] || (_cache[1] = $event => ($options.hideActions())), 10042 onKeyup: _cache[2] || (_cache[2] = withKeys($event => ($options.openPreview()), ["enter"])) 10043 }, [ 10044 _hoisted_1$i, 10045 createBaseVNode("div", _hoisted_2$a, toDisplayString($props.item.name) + " " + toDisplayString($props.item.filetype), 1 /* TEXT */), 10046 createVNode(_component_media_browser_action_items_container, { 10047 ref: "container", 10048 item: $props.item, 10049 previewable: true, 10050 downloadable: true, 10051 shareable: true, 10052 onToggleSettings: $options.toggleSettings 10053 }, null, 8 /* PROPS */, ["item", "onToggleSettings"]) 10054 ], 32 /* HYDRATE_EVENTS */)) 10055 } 10056 10057 script$i.render = render$i; 10058 script$i.__file = "administrator/components/com_media/resources/scripts/components/browser/items/audio.vue"; 10059 10060 var script$h = { 10061 name: 'MediaBrowserItemDocument', 10062 // eslint-disable-next-line vue/require-prop-types 10063 props: ['item', 'focused'], 10064 emits: ['toggle-settings'], 10065 data() { 10066 return { 10067 showActions: false, 10068 }; 10069 }, 10070 methods: { 10071 /* Hide actions dropdown */ 10072 hideActions() { 10073 this.$refs.container.hideActions(); 10074 }, 10075 /* Preview an item */ 10076 openPreview() { 10077 this.$refs.container.openPreview(); 10078 }, 10079 toggleSettings(bool) { 10080 this.$emit('toggle-settings', bool); 10081 }, 10082 }, 10083 }; 10084 10085 const _hoisted_1$h = /*#__PURE__*/createBaseVNode("div", { class: "media-browser-item-preview" }, [ 10086 /*#__PURE__*/createBaseVNode("div", { class: "file-background" }, [ 10087 /*#__PURE__*/createBaseVNode("div", { class: "file-icon" }, [ 10088 /*#__PURE__*/createBaseVNode("span", { class: "fas fa-file-pdf" }) 10089 ]) 10090 ]) 10091 ], -1 /* HOISTED */); 10092 const _hoisted_2$9 = { class: "media-browser-item-info" }; 10093 const _hoisted_3$8 = ["aria-label", "title"]; 10094 10095 function render$h(_ctx, _cache, $props, $setup, $data, $options) { 10096 const _component_media_browser_action_items_container = resolveComponent("media-browser-action-items-container"); 10097 10098 return (openBlock(), createElementBlock("div", { 10099 class: "media-browser-doc", 10100 onDblclick: _cache[0] || (_cache[0] = $event => ($options.openPreview())), 10101 onMouseleave: _cache[1] || (_cache[1] = $event => ($options.hideActions())) 10102 }, [ 10103 _hoisted_1$h, 10104 createBaseVNode("div", _hoisted_2$9, toDisplayString($props.item.name) + " " + toDisplayString($props.item.filetype), 1 /* TEXT */), 10105 createBaseVNode("span", { 10106 class: "media-browser-select", 10107 "aria-label": _ctx.translate('COM_MEDIA_TOGGLE_SELECT_ITEM'), 10108 title: _ctx.translate('COM_MEDIA_TOGGLE_SELECT_ITEM') 10109 }, null, 8 /* PROPS */, _hoisted_3$8), 10110 createVNode(_component_media_browser_action_items_container, { 10111 ref: "container", 10112 item: $props.item, 10113 previewable: true, 10114 downloadable: true, 10115 shareable: true, 10116 onToggleSettings: $options.toggleSettings 10117 }, null, 8 /* PROPS */, ["item", "onToggleSettings"]) 10118 ], 32 /* HYDRATE_EVENTS */)) 10119 } 10120 10121 script$h.render = render$h; 10122 script$h.__file = "administrator/components/com_media/resources/scripts/components/browser/items/document.vue"; 10123 10124 var BrowserItem = { 10125 props: ['item'], 10126 10127 data() { 10128 return { 10129 hoverActive: false 10130 }; 10131 }, 10132 10133 methods: { 10134 /** 10135 * Return the correct item type component 10136 */ 10137 itemType() { 10138 // Render directory items 10139 if (this.item.type === 'dir') return script$m; // Render image items 10140 10141 if (this.item.extension && api.imagesExtensions.includes(this.item.extension.toLowerCase())) { 10142 return script$k; 10143 } // Render video items 10144 10145 10146 if (this.item.extension && api.videoExtensions.includes(this.item.extension.toLowerCase())) { 10147 return script$j; 10148 } // Render audio items 10149 10150 10151 if (this.item.extension && api.audioExtensions.includes(this.item.extension.toLowerCase())) { 10152 return script$i; 10153 } // Render document items 10154 10155 10156 if (this.item.extension && api.documentExtensions.includes(this.item.extension.toLowerCase())) { 10157 return script$h; 10158 } // Default to file type 10159 10160 10161 return script$l; 10162 }, 10163 10164 /** 10165 * Get the styles for the media browser item 10166 * @returns {{}} 10167 */ 10168 styles() { 10169 return { 10170 width: `calc($this.$store.state.gridSize}% - 20px)` 10171 }; 10172 }, 10173 10174 /** 10175 * Whether or not the item is currently selected 10176 * @returns {boolean} 10177 */ 10178 isSelected() { 10179 return this.$store.state.selectedItems.some(selected => selected.path === this.item.path); 10180 }, 10181 10182 /** 10183 * Whether or not the item is currently active (on hover or via tab) 10184 * @returns {boolean} 10185 */ 10186 isHoverActive() { 10187 return this.hoverActive; 10188 }, 10189 10190 /** 10191 * Turns on the hover class 10192 */ 10193 mouseover() { 10194 this.hoverActive = true; 10195 }, 10196 10197 /** 10198 * Turns off the hover class 10199 */ 10200 mouseleave() { 10201 this.hoverActive = false; 10202 }, 10203 10204 /** 10205 * Handle the click event 10206 * @param event 10207 */ 10208 handleClick(event) { 10209 if (this.item.path && this.item.type === 'file') { 10210 window.parent.document.dispatchEvent(new CustomEvent('onMediaFileSelected', { 10211 bubbles: true, 10212 cancelable: false, 10213 detail: { 10214 path: this.item.path, 10215 thumb: this.item.thumb, 10216 fileType: this.item.mime_type ? this.item.mime_type : false, 10217 extension: this.item.extension ? this.item.extension : false, 10218 width: this.item.width ? this.item.width : 0, 10219 height: this.item.height ? this.item.height : 0 10220 } 10221 })); 10222 } 10223 10224 if (this.item.type === 'dir') { 10225 window.parent.document.dispatchEvent(new CustomEvent('onMediaFileSelected', { 10226 bubbles: true, 10227 cancelable: false, 10228 detail: {} 10229 })); 10230 } // Handle clicks when the item was not selected 10231 10232 10233 if (!this.isSelected()) { 10234 // Unselect all other selected items, 10235 // if the shift key was not pressed during the click event 10236 if (!(event.shiftKey || event.keyCode === 13)) { 10237 this.$store.commit(UNSELECT_ALL_BROWSER_ITEMS); 10238 } 10239 10240 this.$store.commit(SELECT_BROWSER_ITEM, this.item); 10241 return; 10242 } 10243 10244 this.$store.dispatch('toggleBrowserItemSelect', this.item); 10245 window.parent.document.dispatchEvent(new CustomEvent('onMediaFileSelected', { 10246 bubbles: true, 10247 cancelable: false, 10248 detail: {} 10249 })); // If more than one item was selected and the user clicks again on the selected item, 10250 // he most probably wants to unselect all other items. 10251 10252 if (this.$store.state.selectedItems.length > 1) { 10253 this.$store.commit(UNSELECT_ALL_BROWSER_ITEMS); 10254 this.$store.commit(SELECT_BROWSER_ITEM, this.item); 10255 } 10256 }, 10257 10258 /** 10259 * Handle the when an element is focused in the child to display the layover for a11y 10260 * @param active 10261 */ 10262 toggleSettings(active) { 10263 // eslint-disable-next-line no-unused-expressions 10264 active ? this.mouseover() : this.mouseleave(); 10265 } 10266 10267 }, 10268 10269 render() { 10270 return h('div', { 10271 class: { 10272 'media-browser-item': true, 10273 selected: this.isSelected(), 10274 active: this.isHoverActive() 10275 }, 10276 onClick: this.handleClick, 10277 onMouseover: this.mouseover, 10278 onMouseleave: this.mouseleave 10279 }, [h(this.itemType(), { 10280 item: this.item, 10281 onToggleSettings: this.toggleSettings 10282 })]); 10283 } 10284 10285 }; 10286 10287 var script$g = { 10288 name: 'MediaBrowserItemRow', 10289 mixins: [navigable], 10290 // eslint-disable-next-line vue/require-prop-types 10291 props: ['item'], 10292 computed: { 10293 /* The dimension of a file */ 10294 dimension() { 10295 if (!this.item.width) { 10296 return ''; 10297 } 10298 return `$this.item.width}px * $this.item.height}px`; 10299 }, 10300 isDir() { 10301 return (this.item.type === 'dir'); 10302 }, 10303 /* The size of a file in KB */ 10304 size() { 10305 if (!this.item.size) { 10306 return ''; 10307 } 10308 return `${(this.item.size / 1024).toFixed(2)} KB`; 10309 }, 10310 selected() { 10311 return !!this.isSelected(); 10312 }, 10313 }, 10314 10315 methods: { 10316 /* Handle the on row double click event */ 10317 onDblClick() { 10318 if (this.isDir) { 10319 this.navigateTo(this.item.path); 10320 return; 10321 } 10322 10323 // @todo remove the hardcoded extensions here 10324 const extensionWithPreview = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'mp4', 'mp3', 'pdf']; 10325 10326 // Show preview 10327 if (this.item.extension 10328 && extensionWithPreview.includes(this.item.extension.toLowerCase())) { 10329 this.$store.commit(SHOW_PREVIEW_MODAL); 10330 this.$store.dispatch('getFullContents', this.item); 10331 } 10332 }, 10333 10334 /** 10335 * Whether or not the item is currently selected 10336 * @returns {boolean} 10337 */ 10338 isSelected() { 10339 return this.$store.state.selectedItems.some((selected) => selected.path === this.item.path); 10340 }, 10341 10342 /** 10343 * Handle the click event 10344 * @param event 10345 */ 10346 onClick(event) { 10347 const path = false; 10348 const data = { 10349 path, 10350 thumb: false, 10351 fileType: this.item.mime_type ? this.item.mime_type : false, 10352 extension: this.item.extension ? this.item.extension : false, 10353 }; 10354 10355 if (this.item.type === 'file') { 10356 data.path = this.item.path; 10357 data.thumb = this.item.thumb ? this.item.thumb : false; 10358 data.width = this.item.width ? this.item.width : 0; 10359 data.height = this.item.height ? this.item.height : 0; 10360 10361 window.parent.document.dispatchEvent( 10362 new CustomEvent( 10363 'onMediaFileSelected', 10364 { 10365 bubbles: true, 10366 cancelable: false, 10367 detail: data, 10368 }, 10369 ), 10370 ); 10371 } 10372 10373 // Handle clicks when the item was not selected 10374 if (!this.isSelected()) { 10375 // Unselect all other selected items, 10376 // if the shift key was not pressed during the click event 10377 if (!(event.shiftKey || event.keyCode === 13)) { 10378 this.$store.commit(UNSELECT_ALL_BROWSER_ITEMS); 10379 } 10380 this.$store.commit(SELECT_BROWSER_ITEM, this.item); 10381 return; 10382 } 10383 10384 // If more than one item was selected and the user clicks again on the selected item, 10385 // he most probably wants to unselect all other items. 10386 if (this.$store.state.selectedItems.length > 1) { 10387 this.$store.commit(UNSELECT_ALL_BROWSER_ITEMS); 10388 this.$store.commit(SELECT_BROWSER_ITEM, this.item); 10389 } 10390 }, 10391 10392 }, 10393 }; 10394 10395 const _hoisted_1$g = ["data-type"]; 10396 const _hoisted_2$8 = { 10397 scope: "row", 10398 class: "name" 10399 }; 10400 const _hoisted_3$7 = { class: "size" }; 10401 const _hoisted_4$6 = { class: "dimension" }; 10402 const _hoisted_5$6 = { class: "created" }; 10403 const _hoisted_6$4 = { class: "modified" }; 10404 10405 function render$g(_ctx, _cache, $props, $setup, $data, $options) { 10406 return (openBlock(), createElementBlock("tr", { 10407 class: normalizeClass(["media-browser-item", {selected: $options.selected}]), 10408 onDblclick: _cache[0] || (_cache[0] = withModifiers($event => ($options.onDblClick()), ["stop","prevent"])), 10409 onClick: _cache[1] || (_cache[1] = (...args) => ($options.onClick && $options.onClick(...args))) 10410 }, [ 10411 createBaseVNode("td", { 10412 class: "type", 10413 "data-type": $props.item.extension 10414 }, null, 8 /* PROPS */, _hoisted_1$g), 10415 createBaseVNode("th", _hoisted_2$8, toDisplayString($props.item.name), 1 /* TEXT */), 10416 createBaseVNode("td", _hoisted_3$7, toDisplayString($options.size), 1 /* TEXT */), 10417 createBaseVNode("td", _hoisted_4$6, toDisplayString($options.dimension), 1 /* TEXT */), 10418 createBaseVNode("td", _hoisted_5$6, toDisplayString($props.item.create_date_formatted), 1 /* TEXT */), 10419 createBaseVNode("td", _hoisted_6$4, toDisplayString($props.item.modified_date_formatted), 1 /* TEXT */) 10420 ], 34 /* CLASS, HYDRATE_EVENTS */)) 10421 } 10422 10423 script$g.render = render$g; 10424 script$g.__file = "administrator/components/com_media/resources/scripts/components/browser/items/row.vue"; 10425 10426 var script$f = { 10427 name: 'MediaModal', 10428 props: { 10429 /* Whether or not the close button in the header should be shown */ 10430 showClose: { 10431 type: Boolean, 10432 default: true, 10433 }, 10434 /* The size of the modal */ 10435 // eslint-disable-next-line vue/require-default-prop 10436 size: { 10437 type: String, 10438 }, 10439 labelElement: { 10440 type: String, 10441 required: true, 10442 }, 10443 }, 10444 emits: ['close'], 10445 computed: { 10446 /* Get the modal css class */ 10447 modalClass() { 10448 return { 10449 'modal-sm': this.size === 'sm', 10450 }; 10451 }, 10452 }, 10453 mounted() { 10454 // Listen to keydown events on the document 10455 document.addEventListener('keydown', this.onKeyDown); 10456 }, 10457 beforeUnmount() { 10458 // Remove the keydown event listener 10459 document.removeEventListener('keydown', this.onKeyDown); 10460 }, 10461 methods: { 10462 /* Close the modal instance */ 10463 close() { 10464 this.$emit('close'); 10465 }, 10466 /* Handle keydown events */ 10467 onKeyDown(event) { 10468 if (event.keyCode === 27) { 10469 this.close(); 10470 } 10471 }, 10472 }, 10473 }; 10474 10475 const _hoisted_1$f = ["aria-labelledby"]; 10476 const _hoisted_2$7 = { class: "modal-content" }; 10477 const _hoisted_3$6 = { class: "modal-header" }; 10478 const _hoisted_4$5 = { class: "modal-body" }; 10479 const _hoisted_5$5 = { class: "modal-footer" }; 10480 10481 function render$f(_ctx, _cache, $props, $setup, $data, $options) { 10482 const _component_tab_lock = resolveComponent("tab-lock"); 10483 10484 return (openBlock(), createElementBlock("div", { 10485 class: "media-modal-backdrop", 10486 onClick: _cache[2] || (_cache[2] = $event => ($options.close())) 10487 }, [ 10488 createBaseVNode("div", { 10489 class: "modal", 10490 style: {"display":"flex"}, 10491 onClick: _cache[1] || (_cache[1] = withModifiers(() => {}, ["stop"])) 10492 }, [ 10493 createVNode(_component_tab_lock, null, { 10494 default: withCtx(() => [ 10495 createBaseVNode("div", { 10496 class: normalizeClass(["modal-dialog", $options.modalClass]), 10497 role: "dialog", 10498 "aria-labelledby": $props.labelElement 10499 }, [ 10500 createBaseVNode("div", _hoisted_2$7, [ 10501 createBaseVNode("div", _hoisted_3$6, [ 10502 renderSlot(_ctx.$slots, "header"), 10503 renderSlot(_ctx.$slots, "backdrop-close"), 10504 ($props.showClose) 10505 ? (openBlock(), createElementBlock("button", { 10506 key: 0, 10507 type: "button", 10508 class: "btn-close", 10509 "aria-label": "Close", 10510 onClick: _cache[0] || (_cache[0] = $event => ($options.close())) 10511 })) 10512 : createCommentVNode("v-if", true) 10513 ]), 10514 createBaseVNode("div", _hoisted_4$5, [ 10515 renderSlot(_ctx.$slots, "body") 10516 ]), 10517 createBaseVNode("div", _hoisted_5$5, [ 10518 renderSlot(_ctx.$slots, "footer") 10519 ]) 10520 ]) 10521 ], 10 /* CLASS, PROPS */, _hoisted_1$f) 10522 ]), 10523 _: 3 /* FORWARDED */ 10524 }) 10525 ]) 10526 ])) 10527 } 10528 10529 script$f.render = render$f; 10530 script$f.__file = "administrator/components/com_media/resources/scripts/components/modals/modal.vue"; 10531 10532 var script$e = { 10533 name: 'MediaCreateFolderModal', 10534 data() { 10535 return { 10536 folder: '', 10537 }; 10538 }, 10539 methods: { 10540 /* Check if the the form is valid */ 10541 isValid() { 10542 return (this.folder); 10543 }, 10544 /* Close the modal instance */ 10545 close() { 10546 this.reset(); 10547 this.$store.commit(HIDE_CREATE_FOLDER_MODAL); 10548 }, 10549 /* Save the form and create the folder */ 10550 save() { 10551 // Check if the form is valid 10552 if (!this.isValid()) { 10553 // @todo show an error message to user for insert a folder name 10554 // @todo mark the field as invalid 10555 return; 10556 } 10557 10558 // Create the directory 10559 this.$store.dispatch('createDirectory', { 10560 name: this.folder, 10561 parent: this.$store.state.selectedDirectory, 10562 }); 10563 this.reset(); 10564 }, 10565 /* Reset the form */ 10566 reset() { 10567 this.folder = ''; 10568 }, 10569 }, 10570 }; 10571 10572 const _hoisted_1$e = { 10573 id: "createFolderTitle", 10574 class: "modal-title" 10575 }; 10576 const _hoisted_2$6 = { class: "p-3" }; 10577 const _hoisted_3$5 = { class: "form-group" }; 10578 const _hoisted_4$4 = { for: "folder" }; 10579 const _hoisted_5$4 = ["disabled"]; 10580 10581 function render$e(_ctx, _cache, $props, $setup, $data, $options) { 10582 const _component_media_modal = resolveComponent("media-modal"); 10583 10584 return (_ctx.$store.state.showCreateFolderModal) 10585 ? (openBlock(), createBlock(_component_media_modal, { 10586 key: 0, 10587 size: 'md', 10588 "label-element": "createFolderTitle", 10589 onClose: _cache[5] || (_cache[5] = $event => ($options.close())) 10590 }, { 10591 header: withCtx(() => [ 10592 createBaseVNode("h3", _hoisted_1$e, toDisplayString(_ctx.translate('COM_MEDIA_CREATE_NEW_FOLDER')), 1 /* TEXT */) 10593 ]), 10594 body: withCtx(() => [ 10595 createBaseVNode("div", _hoisted_2$6, [ 10596 createBaseVNode("form", { 10597 class: "form", 10598 novalidate: "", 10599 onSubmit: _cache[2] || (_cache[2] = withModifiers((...args) => ($options.save && $options.save(...args)), ["prevent"])) 10600 }, [ 10601 createBaseVNode("div", _hoisted_3$5, [ 10602 createBaseVNode("label", _hoisted_4$4, toDisplayString(_ctx.translate('COM_MEDIA_FOLDER_NAME')), 1 /* TEXT */), 10603 withDirectives(createBaseVNode("input", { 10604 id: "folder", 10605 "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => (($data.folder) = $event)), 10606 class: "form-control", 10607 type: "text", 10608 required: "", 10609 autocomplete: "off", 10610 onInput: _cache[1] || (_cache[1] = $event => ($data.folder = $event.target.value)) 10611 }, null, 544 /* HYDRATE_EVENTS, NEED_PATCH */), [ 10612 [ 10613 vModelText, 10614 $data.folder, 10615 void 0, 10616 { trim: true } 10617 ] 10618 ]) 10619 ]) 10620 ], 32 /* HYDRATE_EVENTS */) 10621 ]) 10622 ]), 10623 footer: withCtx(() => [ 10624 createBaseVNode("div", null, [ 10625 createBaseVNode("button", { 10626 class: "btn btn-secondary", 10627 onClick: _cache[3] || (_cache[3] = $event => ($options.close())) 10628 }, toDisplayString(_ctx.translate('JCANCEL')), 1 /* TEXT */), 10629 createBaseVNode("button", { 10630 class: "btn btn-success", 10631 disabled: !$options.isValid(), 10632 onClick: _cache[4] || (_cache[4] = $event => ($options.save())) 10633 }, toDisplayString(_ctx.translate('JACTION_CREATE')), 9 /* TEXT, PROPS */, _hoisted_5$4) 10634 ]) 10635 ]), 10636 _: 1 /* STABLE */ 10637 })) 10638 : createCommentVNode("v-if", true) 10639 } 10640 10641 script$e.render = render$e; 10642 script$e.__file = "administrator/components/com_media/resources/scripts/components/modals/create-folder-modal.vue"; 10643 10644 var script$d = { 10645 name: 'MediaPreviewModal', 10646 computed: { 10647 /* Get the item to show in the modal */ 10648 item() { 10649 // Use the currently selected directory as a fallback 10650 return this.$store.state.previewItem; 10651 }, 10652 /* Get the hashed URL */ 10653 getHashedURL() { 10654 if (this.item.adapter.startsWith('local-')) { 10655 return `$this.item.url}?$api.mediaVersion}`; 10656 } 10657 return this.item.url; 10658 }, 10659 }, 10660 methods: { 10661 /* Close the modal */ 10662 close() { 10663 this.$store.commit(HIDE_PREVIEW_MODAL); 10664 }, 10665 isImage() { 10666 return this.item.mime_type.indexOf('image/') === 0; 10667 }, 10668 isVideo() { 10669 return this.item.mime_type.indexOf('video/') === 0; 10670 }, 10671 isAudio() { 10672 return this.item.mime_type.indexOf('audio/') === 0; 10673 }, 10674 isDoc() { 10675 return this.item.mime_type.indexOf('application/') === 0; 10676 }, 10677 }, 10678 }; 10679 10680 const _hoisted_1$d = { 10681 id: "previewTitle", 10682 class: "modal-title text-light" 10683 }; 10684 const _hoisted_2$5 = { class: "image-background" }; 10685 const _hoisted_3$4 = ["src"]; 10686 const _hoisted_4$3 = { 10687 key: 1, 10688 controls: "" 10689 }; 10690 const _hoisted_5$3 = ["src", "type"]; 10691 const _hoisted_6$3 = ["type", "data"]; 10692 const _hoisted_7$2 = ["src", "type"]; 10693 const _hoisted_8$2 = /*#__PURE__*/createBaseVNode("span", { class: "icon-times" }, null, -1 /* HOISTED */); 10694 const _hoisted_9$2 = [ 10695 _hoisted_8$2 10696 ]; 10697 10698 function render$d(_ctx, _cache, $props, $setup, $data, $options) { 10699 const _component_media_modal = resolveComponent("media-modal"); 10700 10701 return (_ctx.$store.state.showPreviewModal && $options.item) 10702 ? (openBlock(), createBlock(_component_media_modal, { 10703 key: 0, 10704 size: 'md', 10705 class: "media-preview-modal", 10706 "label-element": "previewTitle", 10707 "show-close": false, 10708 onClose: _cache[1] || (_cache[1] = $event => ($options.close())) 10709 }, { 10710 header: withCtx(() => [ 10711 createBaseVNode("h3", _hoisted_1$d, toDisplayString($options.item.name), 1 /* TEXT */) 10712 ]), 10713 body: withCtx(() => [ 10714 createBaseVNode("div", _hoisted_2$5, [ 10715 ($options.isAudio()) 10716 ? (openBlock(), createElementBlock("audio", { 10717 key: 0, 10718 controls: "", 10719 src: $options.item.url 10720 }, null, 8 /* PROPS */, _hoisted_3$4)) 10721 : createCommentVNode("v-if", true), 10722 ($options.isVideo()) 10723 ? (openBlock(), createElementBlock("video", _hoisted_4$3, [ 10724 createBaseVNode("source", { 10725 src: $options.item.url, 10726 type: $options.item.mime_type 10727 }, null, 8 /* PROPS */, _hoisted_5$3) 10728 ])) 10729 : createCommentVNode("v-if", true), 10730 ($options.isDoc()) 10731 ? (openBlock(), createElementBlock("object", { 10732 key: 2, 10733 type: $options.item.mime_type, 10734 data: $options.item.url, 10735 width: "800", 10736 height: "600" 10737 }, null, 8 /* PROPS */, _hoisted_6$3)) 10738 : createCommentVNode("v-if", true), 10739 ($options.isImage()) 10740 ? (openBlock(), createElementBlock("img", { 10741 key: 3, 10742 src: $options.getHashedURL, 10743 type: $options.item.mime_type 10744 }, null, 8 /* PROPS */, _hoisted_7$2)) 10745 : createCommentVNode("v-if", true) 10746 ]) 10747 ]), 10748 "backdrop-close": withCtx(() => [ 10749 createBaseVNode("button", { 10750 type: "button", 10751 class: "media-preview-close", 10752 onClick: _cache[0] || (_cache[0] = $event => ($options.close())) 10753 }, _hoisted_9$2) 10754 ]), 10755 _: 1 /* STABLE */ 10756 })) 10757 : createCommentVNode("v-if", true) 10758 } 10759 10760 script$d.render = render$d; 10761 script$d.__file = "administrator/components/com_media/resources/scripts/components/modals/preview-modal.vue"; 10762 10763 var script$c = { 10764 name: 'MediaRenameModal', 10765 computed: { 10766 item() { 10767 return this.$store.state.selectedItems[this.$store.state.selectedItems.length - 1]; 10768 }, 10769 name() { 10770 return this.item.name.replace(`.$this.item.extension}`, ''); 10771 }, 10772 extension() { 10773 return this.item.extension; 10774 }, 10775 }, 10776 updated() { 10777 this.$nextTick(() => (this.$refs.nameField ? this.$refs.nameField.focus() : null)); 10778 }, 10779 methods: { 10780 /* Check if the form is valid */ 10781 isValid() { 10782 return this.item.name.length > 0; 10783 }, 10784 /* Close the modal instance */ 10785 close() { 10786 this.$store.commit(HIDE_RENAME_MODAL); 10787 }, 10788 /* Save the form and create the folder */ 10789 save() { 10790 // Check if the form is valid 10791 if (!this.isValid()) { 10792 // @todo mark the field as invalid 10793 return; 10794 } 10795 let newName = this.$refs.nameField.value; 10796 if (this.extension.length) { 10797 newName += `.$this.item.extension}`; 10798 } 10799 10800 let newPath = this.item.directory; 10801 if (newPath.substr(-1) !== '/') { 10802 newPath += '/'; 10803 } 10804 10805 // Rename the item 10806 this.$store.dispatch('renameItem', { 10807 item: this.item, 10808 newPath: newPath + newName, 10809 newName, 10810 }); 10811 }, 10812 }, 10813 }; 10814 10815 const _hoisted_1$c = { 10816 id: "renameTitle", 10817 class: "modal-title" 10818 }; 10819 const _hoisted_2$4 = { class: "form-group p-3" }; 10820 const _hoisted_3$3 = { for: "name" }; 10821 const _hoisted_4$2 = ["placeholder", "value"]; 10822 const _hoisted_5$2 = { 10823 key: 0, 10824 class: "input-group-text" 10825 }; 10826 const _hoisted_6$2 = ["disabled"]; 10827 10828 function render$c(_ctx, _cache, $props, $setup, $data, $options) { 10829 const _component_media_modal = resolveComponent("media-modal"); 10830 10831 return (_ctx.$store.state.showRenameModal) 10832 ? (openBlock(), createBlock(_component_media_modal, { 10833 key: 0, 10834 size: 'sm', 10835 "show-close": false, 10836 "label-element": "renameTitle", 10837 onClose: _cache[5] || (_cache[5] = $event => ($options.close())) 10838 }, { 10839 header: withCtx(() => [ 10840 createBaseVNode("h3", _hoisted_1$c, toDisplayString(_ctx.translate('COM_MEDIA_RENAME')), 1 /* TEXT */) 10841 ]), 10842 body: withCtx(() => [ 10843 createBaseVNode("div", null, [ 10844 createBaseVNode("form", { 10845 class: "form", 10846 novalidate: "", 10847 onSubmit: _cache[0] || (_cache[0] = withModifiers((...args) => ($options.save && $options.save(...args)), ["prevent"])) 10848 }, [ 10849 createBaseVNode("div", _hoisted_2$4, [ 10850 createBaseVNode("label", _hoisted_3$3, toDisplayString(_ctx.translate('COM_MEDIA_NAME')), 1 /* TEXT */), 10851 createBaseVNode("div", { 10852 class: normalizeClass({'input-group': $options.extension.length}) 10853 }, [ 10854 createBaseVNode("input", { 10855 id: "name", 10856 ref: "nameField", 10857 class: "form-control", 10858 type: "text", 10859 placeholder: _ctx.translate('COM_MEDIA_NAME'), 10860 value: $options.name, 10861 required: "", 10862 autocomplete: "off" 10863 }, null, 8 /* PROPS */, _hoisted_4$2), 10864 ($options.extension.length) 10865 ? (openBlock(), createElementBlock("span", _hoisted_5$2, toDisplayString($options.extension), 1 /* TEXT */)) 10866 : createCommentVNode("v-if", true) 10867 ], 2 /* CLASS */) 10868 ]) 10869 ], 32 /* HYDRATE_EVENTS */) 10870 ]) 10871 ]), 10872 footer: withCtx(() => [ 10873 createBaseVNode("div", null, [ 10874 createBaseVNode("button", { 10875 type: "button", 10876 class: "btn btn-secondary", 10877 onClick: _cache[1] || (_cache[1] = $event => ($options.close())), 10878 onKeyup: _cache[2] || (_cache[2] = withKeys($event => ($options.close()), ["enter"])) 10879 }, toDisplayString(_ctx.translate('JCANCEL')), 33 /* TEXT, HYDRATE_EVENTS */), 10880 createBaseVNode("button", { 10881 type: "button", 10882 class: "btn btn-success", 10883 disabled: !$options.isValid(), 10884 onClick: _cache[3] || (_cache[3] = $event => ($options.save())), 10885 onKeyup: _cache[4] || (_cache[4] = withKeys($event => ($options.save()), ["enter"])) 10886 }, toDisplayString(_ctx.translate('JAPPLY')), 41 /* TEXT, PROPS, HYDRATE_EVENTS */, _hoisted_6$2) 10887 ]) 10888 ]), 10889 _: 1 /* STABLE */ 10890 })) 10891 : createCommentVNode("v-if", true) 10892 } 10893 10894 script$c.render = render$c; 10895 script$c.__file = "administrator/components/com_media/resources/scripts/components/modals/rename-modal.vue"; 10896 10897 var script$b = { 10898 name: 'MediaShareModal', 10899 computed: { 10900 item() { 10901 return this.$store.state.selectedItems[this.$store.state.selectedItems.length - 1]; 10902 }, 10903 10904 url() { 10905 return (this.$store.state.previewItem && Object.prototype.hasOwnProperty.call(this.$store.state.previewItem, 'url') ? this.$store.state.previewItem.url : null); 10906 }, 10907 }, 10908 methods: { 10909 /* Close the modal instance and reset the form */ 10910 close() { 10911 this.$store.commit(HIDE_SHARE_MODAL); 10912 this.$store.commit(LOAD_FULL_CONTENTS_SUCCESS, null); 10913 }, 10914 10915 // Generate the url from backend 10916 generateUrl() { 10917 this.$store.dispatch('getFullContents', this.item); 10918 }, 10919 10920 // Copy to clipboard 10921 copyToClipboard() { 10922 this.$refs.urlText.focus(); 10923 this.$refs.urlText.select(); 10924 10925 try { 10926 document.execCommand('copy'); 10927 } catch (err) { 10928 // @todo Error handling in joomla way 10929 // eslint-disable-next-line no-undef 10930 alert(translate('COM_MEDIA_SHARE_COPY_FAILED_ERROR')); 10931 } 10932 }, 10933 }, 10934 }; 10935 10936 const _hoisted_1$b = { 10937 id: "shareTitle", 10938 class: "modal-title" 10939 }; 10940 const _hoisted_2$3 = { class: "p-3" }; 10941 const _hoisted_3$2 = { class: "desc" }; 10942 const _hoisted_4$1 = { 10943 key: 0, 10944 class: "control" 10945 }; 10946 const _hoisted_5$1 = { 10947 key: 1, 10948 class: "control" 10949 }; 10950 const _hoisted_6$1 = { class: "input-group" }; 10951 const _hoisted_7$1 = ["title"]; 10952 const _hoisted_8$1 = /*#__PURE__*/createBaseVNode("span", { 10953 class: "icon-clipboard", 10954 "aria-hidden": "true" 10955 }, null, -1 /* HOISTED */); 10956 const _hoisted_9$1 = [ 10957 _hoisted_8$1 10958 ]; 10959 10960 function render$b(_ctx, _cache, $props, $setup, $data, $options) { 10961 const _component_media_modal = resolveComponent("media-modal"); 10962 10963 return (_ctx.$store.state.showShareModal) 10964 ? (openBlock(), createBlock(_component_media_modal, { 10965 key: 0, 10966 size: 'md', 10967 "show-close": false, 10968 "label-element": "shareTitle", 10969 onClose: _cache[4] || (_cache[4] = $event => ($options.close())) 10970 }, { 10971 header: withCtx(() => [ 10972 createBaseVNode("h3", _hoisted_1$b, toDisplayString(_ctx.translate('COM_MEDIA_SHARE')), 1 /* TEXT */) 10973 ]), 10974 body: withCtx(() => [ 10975 createBaseVNode("div", _hoisted_2$3, [ 10976 createBaseVNode("div", _hoisted_3$2, [ 10977 createTextVNode(toDisplayString(_ctx.translate('COM_MEDIA_SHARE_DESC')) + " ", 1 /* TEXT */), 10978 (!$options.url) 10979 ? (openBlock(), createElementBlock("div", _hoisted_4$1, [ 10980 createBaseVNode("button", { 10981 class: "btn btn-success w-100", 10982 type: "button", 10983 onClick: _cache[0] || (_cache[0] = (...args) => ($options.generateUrl && $options.generateUrl(...args))) 10984 }, toDisplayString(_ctx.translate('COM_MEDIA_ACTION_SHARE')), 1 /* TEXT */) 10985 ])) 10986 : (openBlock(), createElementBlock("div", _hoisted_5$1, [ 10987 createBaseVNode("span", _hoisted_6$1, [ 10988 withDirectives(createBaseVNode("input", { 10989 id: "url", 10990 ref: "urlText", 10991 "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => (($options.url) = $event)), 10992 readonly: "", 10993 type: "url", 10994 class: "form-control input-xxlarge", 10995 placeholder: "URL", 10996 autocomplete: "off" 10997 }, null, 512 /* NEED_PATCH */), [ 10998 [vModelText, $options.url] 10999 ]), 11000 createBaseVNode("button", { 11001 class: "btn btn-secondary", 11002 type: "button", 11003 title: _ctx.translate('COM_MEDIA_SHARE_COPY'), 11004 onClick: _cache[2] || (_cache[2] = (...args) => ($options.copyToClipboard && $options.copyToClipboard(...args))) 11005 }, _hoisted_9$1, 8 /* PROPS */, _hoisted_7$1) 11006 ]) 11007 ])) 11008 ]) 11009 ]) 11010 ]), 11011 footer: withCtx(() => [ 11012 createBaseVNode("div", null, [ 11013 createBaseVNode("button", { 11014 class: "btn btn-secondary", 11015 onClick: _cache[3] || (_cache[3] = $event => ($options.close())) 11016 }, toDisplayString(_ctx.translate('JCANCEL')), 1 /* TEXT */) 11017 ]) 11018 ]), 11019 _: 1 /* STABLE */ 11020 })) 11021 : createCommentVNode("v-if", true) 11022 } 11023 11024 script$b.render = render$b; 11025 script$b.__file = "administrator/components/com_media/resources/scripts/components/modals/share-modal.vue"; 11026 11027 var script$a = { 11028 name: 'MediaShareModal', 11029 computed: { 11030 item() { 11031 return this.$store.state.selectedItems[this.$store.state.selectedItems.length - 1]; 11032 }, 11033 }, 11034 methods: { 11035 /* Delete Item */ 11036 deleteItem() { 11037 this.$store.dispatch('deleteSelectedItems'); 11038 this.$store.commit(HIDE_CONFIRM_DELETE_MODAL); 11039 }, 11040 /* Close the modal instance */ 11041 close() { 11042 this.$store.commit(HIDE_CONFIRM_DELETE_MODAL); 11043 }, 11044 }, 11045 }; 11046 11047 const _hoisted_1$a = { 11048 id: "confirmDeleteTitle", 11049 class: "modal-title" 11050 }; 11051 const _hoisted_2$2 = { class: "p-3" }; 11052 const _hoisted_3$1 = { class: "desc" }; 11053 11054 function render$a(_ctx, _cache, $props, $setup, $data, $options) { 11055 const _component_media_modal = resolveComponent("media-modal"); 11056 11057 return (_ctx.$store.state.showConfirmDeleteModal) 11058 ? (openBlock(), createBlock(_component_media_modal, { 11059 key: 0, 11060 size: 'md', 11061 "show-close": false, 11062 "label-element": "confirmDeleteTitle", 11063 onClose: _cache[2] || (_cache[2] = $event => ($options.close())) 11064 }, { 11065 header: withCtx(() => [ 11066 createBaseVNode("h3", _hoisted_1$a, toDisplayString(_ctx.translate('COM_MEDIA_CONFIRM_DELETE_MODAL_HEADING')), 1 /* TEXT */) 11067 ]), 11068 body: withCtx(() => [ 11069 createBaseVNode("div", _hoisted_2$2, [ 11070 createBaseVNode("div", _hoisted_3$1, toDisplayString(_ctx.translate('JGLOBAL_CONFIRM_DELETE')), 1 /* TEXT */) 11071 ]) 11072 ]), 11073 footer: withCtx(() => [ 11074 createBaseVNode("div", null, [ 11075 createBaseVNode("button", { 11076 class: "btn btn-success", 11077 onClick: _cache[0] || (_cache[0] = $event => ($options.close())) 11078 }, toDisplayString(_ctx.translate('JCANCEL')), 1 /* TEXT */), 11079 createBaseVNode("button", { 11080 id: "media-delete-item", 11081 class: "btn btn-danger", 11082 onClick: _cache[1] || (_cache[1] = $event => ($options.deleteItem())) 11083 }, toDisplayString(_ctx.translate('COM_MEDIA_CONFIRM_DELETE_MODAL')), 1 /* TEXT */) 11084 ]) 11085 ]), 11086 _: 1 /* STABLE */ 11087 })) 11088 : createCommentVNode("v-if", true) 11089 } 11090 11091 script$a.render = render$a; 11092 script$a.__file = "administrator/components/com_media/resources/scripts/components/modals/confirm-delete-modal.vue"; 11093 11094 var script$9 = { 11095 name: 'MediaInfobar', 11096 computed: { 11097 /* Get the item to show in the infobar */ 11098 item() { 11099 // Check if there are selected items 11100 const { selectedItems } = this.$store.state; 11101 11102 // If there is only one selected item, show that one. 11103 if (selectedItems.length === 1) { 11104 return selectedItems[0]; 11105 } 11106 11107 // If there are more selected items, use the last one 11108 if (selectedItems.length > 1) { 11109 return selectedItems.slice(-1)[0]; 11110 } 11111 11112 // Use the currently selected directory as a fallback 11113 return this.$store.getters.getSelectedDirectory; 11114 }, 11115 /* Show/Hide the InfoBar */ 11116 showInfoBar() { 11117 return this.$store.state.showInfoBar; 11118 }, 11119 }, 11120 methods: { 11121 hideInfoBar() { 11122 this.$store.commit(HIDE_INFOBAR); 11123 }, 11124 }, 11125 }; 11126 11127 const _hoisted_1$9 = { 11128 key: 0, 11129 class: "media-infobar" 11130 }; 11131 const _hoisted_2$1 = { 11132 key: 0, 11133 class: "text-center" 11134 }; 11135 const _hoisted_3 = /*#__PURE__*/createBaseVNode("span", { class: "icon-file placeholder-icon" }, null, -1 /* HOISTED */); 11136 const _hoisted_4 = /*#__PURE__*/createTextVNode(" Select file or folder to view its details. "); 11137 const _hoisted_5 = [ 11138 _hoisted_3, 11139 _hoisted_4 11140 ]; 11141 const _hoisted_6 = { key: 1 }; 11142 const _hoisted_7 = { key: 0 }; 11143 const _hoisted_8 = { key: 1 }; 11144 const _hoisted_9 = { key: 2 }; 11145 const _hoisted_10 = { key: 3 }; 11146 const _hoisted_11 = { key: 4 }; 11147 const _hoisted_12 = { key: 5 }; 11148 const _hoisted_13 = { key: 6 }; 11149 11150 function render$9(_ctx, _cache, $props, $setup, $data, $options) { 11151 return (openBlock(), createBlock(Transition, { name: "infobar" }, { 11152 default: withCtx(() => [ 11153 ($options.showInfoBar && $options.item) 11154 ? (openBlock(), createElementBlock("div", _hoisted_1$9, [ 11155 createBaseVNode("span", { 11156 class: "infobar-close", 11157 onClick: _cache[0] || (_cache[0] = $event => ($options.hideInfoBar())) 11158 }, "×"), 11159 createBaseVNode("h2", null, toDisplayString($options.item.name), 1 /* TEXT */), 11160 ($options.item.path === '/') 11161 ? (openBlock(), createElementBlock("div", _hoisted_2$1, _hoisted_5)) 11162 : (openBlock(), createElementBlock("dl", _hoisted_6, [ 11163 createBaseVNode("dt", null, toDisplayString(_ctx.translate('COM_MEDIA_FOLDER')), 1 /* TEXT */), 11164 createBaseVNode("dd", null, toDisplayString($options.item.directory), 1 /* TEXT */), 11165 createBaseVNode("dt", null, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_TYPE')), 1 /* TEXT */), 11166 ($options.item.type === 'file') 11167 ? (openBlock(), createElementBlock("dd", _hoisted_7, toDisplayString(_ctx.translate('COM_MEDIA_FILE')), 1 /* TEXT */)) 11168 : ($options.item.type === 'dir') 11169 ? (openBlock(), createElementBlock("dd", _hoisted_8, toDisplayString(_ctx.translate('COM_MEDIA_FOLDER')), 1 /* TEXT */)) 11170 : (openBlock(), createElementBlock("dd", _hoisted_9, " - ")), 11171 createBaseVNode("dt", null, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_DATE_CREATED')), 1 /* TEXT */), 11172 createBaseVNode("dd", null, toDisplayString($options.item.create_date_formatted), 1 /* TEXT */), 11173 createBaseVNode("dt", null, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_DATE_MODIFIED')), 1 /* TEXT */), 11174 createBaseVNode("dd", null, toDisplayString($options.item.modified_date_formatted), 1 /* TEXT */), 11175 createBaseVNode("dt", null, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_DIMENSION')), 1 /* TEXT */), 11176 ($options.item.width || $options.item.height) 11177 ? (openBlock(), createElementBlock("dd", _hoisted_10, toDisplayString($options.item.width) + "px * " + toDisplayString($options.item.height) + "px ", 1 /* TEXT */)) 11178 : (openBlock(), createElementBlock("dd", _hoisted_11, " - ")), 11179 createBaseVNode("dt", null, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_SIZE')), 1 /* TEXT */), 11180 ($options.item.size) 11181 ? (openBlock(), createElementBlock("dd", _hoisted_12, toDisplayString(($options.item.size / 1024).toFixed(2)) + " KB ", 1 /* TEXT */)) 11182 : (openBlock(), createElementBlock("dd", _hoisted_13, " - ")), 11183 createBaseVNode("dt", null, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_MIME_TYPE')), 1 /* TEXT */), 11184 createBaseVNode("dd", null, toDisplayString($options.item.mime_type), 1 /* TEXT */), 11185 createBaseVNode("dt", null, toDisplayString(_ctx.translate('COM_MEDIA_MEDIA_EXTENSION')), 1 /* TEXT */), 11186 createBaseVNode("dd", null, toDisplayString($options.item.extension || '-'), 1 /* TEXT */) 11187 ])) 11188 ])) 11189 : createCommentVNode("v-if", true) 11190 ]), 11191 _: 1 /* STABLE */ 11192 })) 11193 } 11194 11195 script$9.render = render$9; 11196 script$9.__file = "administrator/components/com_media/resources/scripts/components/infobar/infobar.vue"; 11197 11198 var script$8 = { 11199 name: 'MediaUpload', 11200 props: { 11201 // eslint-disable-next-line vue/require-default-prop 11202 accept: { 11203 type: String, 11204 }, 11205 // eslint-disable-next-line vue/require-prop-types 11206 extensions: { 11207 default: () => [], 11208 }, 11209 name: { 11210 type: String, 11211 default: 'file', 11212 }, 11213 multiple: { 11214 type: Boolean, 11215 default: true, 11216 }, 11217 }, 11218 created() { 11219 // Listen to the toolbar upload click event 11220 MediaManager.Event.listen('onClickUpload', () => this.chooseFiles()); 11221 }, 11222 methods: { 11223 /* Open the choose-file dialog */ 11224 chooseFiles() { 11225 this.$refs.fileInput.click(); 11226 }, 11227 /* Upload files */ 11228 upload(e) { 11229 e.preventDefault(); 11230 const { files } = e.target; 11231 11232 // Loop through array of files and upload each file 11233 Array.from(files).forEach((file) => { 11234 // Create a new file reader instance 11235 const reader = new FileReader(); 11236 11237 // Add the on load callback 11238 reader.onload = (progressEvent) => { 11239 const { result } = progressEvent.target; 11240 const splitIndex = result.indexOf('base64') + 7; 11241 const content = result.slice(splitIndex, result.length); 11242 11243 // Upload the file 11244 this.$store.dispatch('uploadFile', { 11245 name: file.name, 11246 parent: this.$store.state.selectedDirectory, 11247 content, 11248 }); 11249 }; 11250 11251 reader.readAsDataURL(file); 11252 }); 11253 }, 11254 }, 11255 }; 11256 11257 const _hoisted_1$8 = ["name", "multiple", "accept"]; 11258 11259 function render$8(_ctx, _cache, $props, $setup, $data, $options) { 11260 return (openBlock(), createElementBlock("input", { 11261 ref: "fileInput", 11262 type: "file", 11263 class: "hidden", 11264 name: $props.name, 11265 multiple: $props.multiple, 11266 accept: $props.accept, 11267 onChange: _cache[0] || (_cache[0] = (...args) => ($options.upload && $options.upload(...args))) 11268 }, null, 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1$8)) 11269 } 11270 11271 script$8.render = render$8; 11272 script$8.__file = "administrator/components/com_media/resources/scripts/components/upload/upload.vue"; 11273 11274 /** 11275 * Translate plugin 11276 */ 11277 const Translate = { 11278 // Translate from Joomla text 11279 translate: key => Joomla.Text._(key, key), 11280 sprintf: function (string) { 11281 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 11282 args[_key - 1] = arguments[_key]; 11283 } 11284 11285 // eslint-disable-next-line no-param-reassign 11286 string = Translate.translate(string); 11287 let i = 0; 11288 return string.replace(/%((%)|s|d)/g, m => { 11289 let val = args[i]; 11290 11291 if (m === '%d') { 11292 val = parseFloat(val); // eslint-disable-next-line no-restricted-globals 11293 11294 if (isNaN(val)) { 11295 val = 0; 11296 } 11297 } // eslint-disable-next-line no-plusplus 11298 11299 11300 i++; 11301 return val; 11302 }); 11303 }, 11304 install: Vue => Vue.mixin({ 11305 methods: { 11306 translate(key) { 11307 return Translate.translate(key); 11308 }, 11309 11310 sprintf(key) { 11311 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 11312 args[_key2 - 1] = arguments[_key2]; 11313 } 11314 11315 return Translate.sprintf(key, args); 11316 } 11317 11318 } 11319 }) 11320 }; 11321 11322 function getDevtoolsGlobalHook() { 11323 return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__; 11324 } 11325 function getTarget() { 11326 // @ts-ignore 11327 return typeof navigator !== 'undefined' ? window : typeof global !== 'undefined' ? global : {}; 11328 } 11329 11330 const HOOK_SETUP = 'devtools-plugin:setup'; 11331 11332 function setupDevtoolsPlugin(pluginDescriptor, setupFn) { 11333 const hook = getDevtoolsGlobalHook(); 11334 11335 if (hook) { 11336 hook.emit(HOOK_SETUP, pluginDescriptor, setupFn); 11337 } else { 11338 const target = getTarget(); 11339 const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || []; 11340 list.push({ 11341 pluginDescriptor, 11342 setupFn 11343 }); 11344 } 11345 } 11346 11347 /*! 11348 * vuex v4.0.2 11349 * (c) 2021 Evan You 11350 * @license MIT 11351 */ 11352 var storeKey = 'store'; 11353 /** 11354 * forEach for object 11355 */ 11356 11357 11358 function forEachValue(obj, fn) { 11359 Object.keys(obj).forEach(function (key) { 11360 return fn(obj[key], key); 11361 }); 11362 } 11363 11364 function isObject(obj) { 11365 return obj !== null && typeof obj === 'object'; 11366 } 11367 11368 function isPromise(val) { 11369 return val && typeof val.then === 'function'; 11370 } 11371 11372 function partial(fn, arg) { 11373 return function () { 11374 return fn(arg); 11375 }; 11376 } 11377 11378 function genericSubscribe(fn, subs, options) { 11379 if (subs.indexOf(fn) < 0) { 11380 options && options.prepend ? subs.unshift(fn) : subs.push(fn); 11381 } 11382 11383 return function () { 11384 var i = subs.indexOf(fn); 11385 11386 if (i > -1) { 11387 subs.splice(i, 1); 11388 } 11389 }; 11390 } 11391 11392 function resetStore(store, hot) { 11393 store._actions = Object.create(null); 11394 store._mutations = Object.create(null); 11395 store._wrappedGetters = Object.create(null); 11396 store._modulesNamespaceMap = Object.create(null); 11397 var state = store.state; // init all modules 11398 11399 installModule(store, state, [], store._modules.root, true); // reset state 11400 11401 resetStoreState(store, state, hot); 11402 } 11403 11404 function resetStoreState(store, state, hot) { 11405 var oldState = store._state; // bind store public getters 11406 11407 store.getters = {}; // reset local getters cache 11408 11409 store._makeLocalGettersCache = Object.create(null); 11410 var wrappedGetters = store._wrappedGetters; 11411 var computedObj = {}; 11412 forEachValue(wrappedGetters, function (fn, key) { 11413 // use computed to leverage its lazy-caching mechanism 11414 // direct inline function use will lead to closure preserving oldState. 11415 // using partial to return function with only arguments preserved in closure environment. 11416 computedObj[key] = partial(fn, store); 11417 Object.defineProperty(store.getters, key, { 11418 // TODO: use `computed` when it's possible. at the moment we can't due to 11419 // https://github.com/vuejs/vuex/pull/1883 11420 get: function () { 11421 return computedObj[key](); 11422 }, 11423 enumerable: true // for local getters 11424 11425 }); 11426 }); 11427 store._state = reactive({ 11428 data: state 11429 }); // enable strict mode for new state 11430 11431 if (store.strict) { 11432 enableStrictMode(store); 11433 } 11434 11435 if (oldState) { 11436 if (hot) { 11437 // dispatch changes in all subscribed watchers 11438 // to force getter re-evaluation for hot reloading. 11439 store._withCommit(function () { 11440 oldState.data = null; 11441 }); 11442 } 11443 } 11444 } 11445 11446 function installModule(store, rootState, path, module, hot) { 11447 var isRoot = !path.length; 11448 11449 var namespace = store._modules.getNamespace(path); // register in namespace map 11450 11451 11452 if (module.namespaced) { 11453 if (store._modulesNamespaceMap[namespace] && "production" !== 'production') { 11454 console.error("[vuex] duplicate namespace " + namespace + " for the namespaced module " + path.join('/')); 11455 } 11456 11457 store._modulesNamespaceMap[namespace] = module; 11458 } // set state 11459 11460 11461 if (!isRoot && !hot) { 11462 var parentState = getNestedState(rootState, path.slice(0, -1)); 11463 var moduleName = path[path.length - 1]; 11464 11465 store._withCommit(function () { 11466 11467 parentState[moduleName] = module.state; 11468 }); 11469 } 11470 11471 var local = module.context = makeLocalContext(store, namespace, path); 11472 module.forEachMutation(function (mutation, key) { 11473 var namespacedType = namespace + key; 11474 registerMutation(store, namespacedType, mutation, local); 11475 }); 11476 module.forEachAction(function (action, key) { 11477 var type = action.root ? key : namespace + key; 11478 var handler = action.handler || action; 11479 registerAction(store, type, handler, local); 11480 }); 11481 module.forEachGetter(function (getter, key) { 11482 var namespacedType = namespace + key; 11483 registerGetter(store, namespacedType, getter, local); 11484 }); 11485 module.forEachChild(function (child, key) { 11486 installModule(store, rootState, path.concat(key), child, hot); 11487 }); 11488 } 11489 /** 11490 * make localized dispatch, commit, getters and state 11491 * if there is no namespace, just use root ones 11492 */ 11493 11494 11495 function makeLocalContext(store, namespace, path) { 11496 var noNamespace = namespace === ''; 11497 var local = { 11498 dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) { 11499 var args = unifyObjectStyle(_type, _payload, _options); 11500 var payload = args.payload; 11501 var options = args.options; 11502 var type = args.type; 11503 11504 if (!options || !options.root) { 11505 type = namespace + type; 11506 } 11507 11508 return store.dispatch(type, payload); 11509 }, 11510 commit: noNamespace ? store.commit : function (_type, _payload, _options) { 11511 var args = unifyObjectStyle(_type, _payload, _options); 11512 var payload = args.payload; 11513 var options = args.options; 11514 var type = args.type; 11515 11516 if (!options || !options.root) { 11517 type = namespace + type; 11518 } 11519 11520 store.commit(type, payload, options); 11521 } 11522 }; // getters and state object must be gotten lazily 11523 // because they will be changed by state update 11524 11525 Object.defineProperties(local, { 11526 getters: { 11527 get: noNamespace ? function () { 11528 return store.getters; 11529 } : function () { 11530 return makeLocalGetters(store, namespace); 11531 } 11532 }, 11533 state: { 11534 get: function () { 11535 return getNestedState(store.state, path); 11536 } 11537 } 11538 }); 11539 return local; 11540 } 11541 11542 function makeLocalGetters(store, namespace) { 11543 if (!store._makeLocalGettersCache[namespace]) { 11544 var gettersProxy = {}; 11545 var splitPos = namespace.length; 11546 Object.keys(store.getters).forEach(function (type) { 11547 // skip if the target getter is not match this namespace 11548 if (type.slice(0, splitPos) !== namespace) { 11549 return; 11550 } // extract local getter type 11551 11552 11553 var localType = type.slice(splitPos); // Add a port to the getters proxy. 11554 // Define as getter property because 11555 // we do not want to evaluate the getters in this time. 11556 11557 Object.defineProperty(gettersProxy, localType, { 11558 get: function () { 11559 return store.getters[type]; 11560 }, 11561 enumerable: true 11562 }); 11563 }); 11564 store._makeLocalGettersCache[namespace] = gettersProxy; 11565 } 11566 11567 return store._makeLocalGettersCache[namespace]; 11568 } 11569 11570 function registerMutation(store, type, handler, local) { 11571 var entry = store._mutations[type] || (store._mutations[type] = []); 11572 entry.push(function wrappedMutationHandler(payload) { 11573 handler.call(store, local.state, payload); 11574 }); 11575 } 11576 11577 function registerAction(store, type, handler, local) { 11578 var entry = store._actions[type] || (store._actions[type] = []); 11579 entry.push(function wrappedActionHandler(payload) { 11580 var res = handler.call(store, { 11581 dispatch: local.dispatch, 11582 commit: local.commit, 11583 getters: local.getters, 11584 state: local.state, 11585 rootGetters: store.getters, 11586 rootState: store.state 11587 }, payload); 11588 11589 if (!isPromise(res)) { 11590 res = Promise.resolve(res); 11591 } 11592 11593 if (store._devtoolHook) { 11594 return res.catch(function (err) { 11595 store._devtoolHook.emit('vuex:error', err); 11596 11597 throw err; 11598 }); 11599 } else { 11600 return res; 11601 } 11602 }); 11603 } 11604 11605 function registerGetter(store, type, rawGetter, local) { 11606 if (store._wrappedGetters[type]) { 11607 11608 return; 11609 } 11610 11611 store._wrappedGetters[type] = function wrappedGetter(store) { 11612 return rawGetter(local.state, // local state 11613 local.getters, // local getters 11614 store.state, // root state 11615 store.getters // root getters 11616 ); 11617 }; 11618 } 11619 11620 function enableStrictMode(store) { 11621 watch(function () { 11622 return store._state.data; 11623 }, function () { 11624 }, { 11625 deep: true, 11626 flush: 'sync' 11627 }); 11628 } 11629 11630 function getNestedState(state, path) { 11631 return path.reduce(function (state, key) { 11632 return state[key]; 11633 }, state); 11634 } 11635 11636 function unifyObjectStyle(type, payload, options) { 11637 if (isObject(type) && type.type) { 11638 options = payload; 11639 payload = type; 11640 type = type.type; 11641 } 11642 11643 return { 11644 type: type, 11645 payload: payload, 11646 options: options 11647 }; 11648 } 11649 11650 var LABEL_VUEX_BINDINGS = 'vuex bindings'; 11651 var MUTATIONS_LAYER_ID = 'vuex:mutations'; 11652 var ACTIONS_LAYER_ID = 'vuex:actions'; 11653 var INSPECTOR_ID = 'vuex'; 11654 var actionId = 0; 11655 11656 function addDevtools(app, store) { 11657 setupDevtoolsPlugin({ 11658 id: 'org.vuejs.vuex', 11659 app: app, 11660 label: 'Vuex', 11661 homepage: 'https://next.vuex.vuejs.org/', 11662 logo: 'https://vuejs.org/images/icons/favicon-96x96.png', 11663 packageName: 'vuex', 11664 componentStateTypes: [LABEL_VUEX_BINDINGS] 11665 }, function (api) { 11666 api.addTimelineLayer({ 11667 id: MUTATIONS_LAYER_ID, 11668 label: 'Vuex Mutations', 11669 color: COLOR_LIME_500 11670 }); 11671 api.addTimelineLayer({ 11672 id: ACTIONS_LAYER_ID, 11673 label: 'Vuex Actions', 11674 color: COLOR_LIME_500 11675 }); 11676 api.addInspector({ 11677 id: INSPECTOR_ID, 11678 label: 'Vuex', 11679 icon: 'storage', 11680 treeFilterPlaceholder: 'Filter stores...' 11681 }); 11682 api.on.getInspectorTree(function (payload) { 11683 if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { 11684 if (payload.filter) { 11685 var nodes = []; 11686 flattenStoreForInspectorTree(nodes, store._modules.root, payload.filter, ''); 11687 payload.rootNodes = nodes; 11688 } else { 11689 payload.rootNodes = [formatStoreForInspectorTree(store._modules.root, '')]; 11690 } 11691 } 11692 }); 11693 api.on.getInspectorState(function (payload) { 11694 if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { 11695 var modulePath = payload.nodeId; 11696 makeLocalGetters(store, modulePath); 11697 payload.state = formatStoreForInspectorState(getStoreModule(store._modules, modulePath), modulePath === 'root' ? store.getters : store._makeLocalGettersCache, modulePath); 11698 } 11699 }); 11700 api.on.editInspectorState(function (payload) { 11701 if (payload.app === app && payload.inspectorId === INSPECTOR_ID) { 11702 var modulePath = payload.nodeId; 11703 var path = payload.path; 11704 11705 if (modulePath !== 'root') { 11706 path = modulePath.split('/').filter(Boolean).concat(path); 11707 } 11708 11709 store._withCommit(function () { 11710 payload.set(store._state.data, path, payload.state.value); 11711 }); 11712 } 11713 }); 11714 store.subscribe(function (mutation, state) { 11715 var data = {}; 11716 11717 if (mutation.payload) { 11718 data.payload = mutation.payload; 11719 } 11720 11721 data.state = state; 11722 api.notifyComponentUpdate(); 11723 api.sendInspectorTree(INSPECTOR_ID); 11724 api.sendInspectorState(INSPECTOR_ID); 11725 api.addTimelineEvent({ 11726 layerId: MUTATIONS_LAYER_ID, 11727 event: { 11728 time: Date.now(), 11729 title: mutation.type, 11730 data: data 11731 } 11732 }); 11733 }); 11734 store.subscribeAction({ 11735 before: function (action, state) { 11736 var data = {}; 11737 11738 if (action.payload) { 11739 data.payload = action.payload; 11740 } 11741 11742 action._id = actionId++; 11743 action._time = Date.now(); 11744 data.state = state; 11745 api.addTimelineEvent({ 11746 layerId: ACTIONS_LAYER_ID, 11747 event: { 11748 time: action._time, 11749 title: action.type, 11750 groupId: action._id, 11751 subtitle: 'start', 11752 data: data 11753 } 11754 }); 11755 }, 11756 after: function (action, state) { 11757 var data = {}; 11758 11759 var duration = Date.now() - action._time; 11760 11761 data.duration = { 11762 _custom: { 11763 type: 'duration', 11764 display: duration + "ms", 11765 tooltip: 'Action duration', 11766 value: duration 11767 } 11768 }; 11769 11770 if (action.payload) { 11771 data.payload = action.payload; 11772 } 11773 11774 data.state = state; 11775 api.addTimelineEvent({ 11776 layerId: ACTIONS_LAYER_ID, 11777 event: { 11778 time: Date.now(), 11779 title: action.type, 11780 groupId: action._id, 11781 subtitle: 'end', 11782 data: data 11783 } 11784 }); 11785 } 11786 }); 11787 }); 11788 } // extracted from tailwind palette 11789 11790 11791 var COLOR_LIME_500 = 0x84cc16; 11792 var COLOR_DARK = 0x666666; 11793 var COLOR_WHITE = 0xffffff; 11794 var TAG_NAMESPACED = { 11795 label: 'namespaced', 11796 textColor: COLOR_WHITE, 11797 backgroundColor: COLOR_DARK 11798 }; 11799 /** 11800 * @param {string} path 11801 */ 11802 11803 function extractNameFromPath(path) { 11804 return path && path !== 'root' ? path.split('/').slice(-2, -1)[0] : 'Root'; 11805 } 11806 /** 11807 * @param {*} module 11808 * @return {import('@vue/devtools-api').CustomInspectorNode} 11809 */ 11810 11811 11812 function formatStoreForInspectorTree(module, path) { 11813 return { 11814 id: path || 'root', 11815 // all modules end with a `/`, we want the last segment only 11816 // cart/ -> cart 11817 // nested/cart/ -> cart 11818 label: extractNameFromPath(path), 11819 tags: module.namespaced ? [TAG_NAMESPACED] : [], 11820 children: Object.keys(module._children).map(function (moduleName) { 11821 return formatStoreForInspectorTree(module._children[moduleName], path + moduleName + '/'); 11822 }) 11823 }; 11824 } 11825 /** 11826 * @param {import('@vue/devtools-api').CustomInspectorNode[]} result 11827 * @param {*} module 11828 * @param {string} filter 11829 * @param {string} path 11830 */ 11831 11832 11833 function flattenStoreForInspectorTree(result, module, filter, path) { 11834 if (path.includes(filter)) { 11835 result.push({ 11836 id: path || 'root', 11837 label: path.endsWith('/') ? path.slice(0, path.length - 1) : path || 'Root', 11838 tags: module.namespaced ? [TAG_NAMESPACED] : [] 11839 }); 11840 } 11841 11842 Object.keys(module._children).forEach(function (moduleName) { 11843 flattenStoreForInspectorTree(result, module._children[moduleName], filter, path + moduleName + '/'); 11844 }); 11845 } 11846 /** 11847 * @param {*} module 11848 * @return {import('@vue/devtools-api').CustomInspectorState} 11849 */ 11850 11851 11852 function formatStoreForInspectorState(module, getters, path) { 11853 getters = path === 'root' ? getters : getters[path]; 11854 var gettersKeys = Object.keys(getters); 11855 var storeState = { 11856 state: Object.keys(module.state).map(function (key) { 11857 return { 11858 key: key, 11859 editable: true, 11860 value: module.state[key] 11861 }; 11862 }) 11863 }; 11864 11865 if (gettersKeys.length) { 11866 var tree = transformPathsToObjectTree(getters); 11867 storeState.getters = Object.keys(tree).map(function (key) { 11868 return { 11869 key: key.endsWith('/') ? extractNameFromPath(key) : key, 11870 editable: false, 11871 value: canThrow(function () { 11872 return tree[key]; 11873 }) 11874 }; 11875 }); 11876 } 11877 11878 return storeState; 11879 } 11880 11881 function transformPathsToObjectTree(getters) { 11882 var result = {}; 11883 Object.keys(getters).forEach(function (key) { 11884 var path = key.split('/'); 11885 11886 if (path.length > 1) { 11887 var target = result; 11888 var leafKey = path.pop(); 11889 path.forEach(function (p) { 11890 if (!target[p]) { 11891 target[p] = { 11892 _custom: { 11893 value: {}, 11894 display: p, 11895 tooltip: 'Module', 11896 abstract: true 11897 } 11898 }; 11899 } 11900 11901 target = target[p]._custom.value; 11902 }); 11903 target[leafKey] = canThrow(function () { 11904 return getters[key]; 11905 }); 11906 } else { 11907 result[key] = canThrow(function () { 11908 return getters[key]; 11909 }); 11910 } 11911 }); 11912 return result; 11913 } 11914 11915 function getStoreModule(moduleMap, path) { 11916 var names = path.split('/').filter(function (n) { 11917 return n; 11918 }); 11919 return names.reduce(function (module, moduleName, i) { 11920 var child = module[moduleName]; 11921 11922 if (!child) { 11923 throw new Error("Missing module \"" + moduleName + "\" for path \"" + path + "\"."); 11924 } 11925 11926 return i === names.length - 1 ? child : child._children; 11927 }, path === 'root' ? moduleMap : moduleMap.root._children); 11928 } 11929 11930 function canThrow(cb) { 11931 try { 11932 return cb(); 11933 } catch (e) { 11934 return e; 11935 } 11936 } // Base data struct for store's module, package with some attribute and method 11937 11938 11939 var Module = function Module(rawModule, runtime) { 11940 this.runtime = runtime; // Store some children item 11941 11942 this._children = Object.create(null); // Store the origin module object which passed by programmer 11943 11944 this._rawModule = rawModule; 11945 var rawState = rawModule.state; // Store the origin module's state 11946 11947 this.state = (typeof rawState === 'function' ? rawState() : rawState) || {}; 11948 }; 11949 11950 var prototypeAccessors$1 = { 11951 namespaced: { 11952 configurable: true 11953 } 11954 }; 11955 11956 prototypeAccessors$1.namespaced.get = function () { 11957 return !!this._rawModule.namespaced; 11958 }; 11959 11960 Module.prototype.addChild = function addChild(key, module) { 11961 this._children[key] = module; 11962 }; 11963 11964 Module.prototype.removeChild = function removeChild(key) { 11965 delete this._children[key]; 11966 }; 11967 11968 Module.prototype.getChild = function getChild(key) { 11969 return this._children[key]; 11970 }; 11971 11972 Module.prototype.hasChild = function hasChild(key) { 11973 return key in this._children; 11974 }; 11975 11976 Module.prototype.update = function update(rawModule) { 11977 this._rawModule.namespaced = rawModule.namespaced; 11978 11979 if (rawModule.actions) { 11980 this._rawModule.actions = rawModule.actions; 11981 } 11982 11983 if (rawModule.mutations) { 11984 this._rawModule.mutations = rawModule.mutations; 11985 } 11986 11987 if (rawModule.getters) { 11988 this._rawModule.getters = rawModule.getters; 11989 } 11990 }; 11991 11992 Module.prototype.forEachChild = function forEachChild(fn) { 11993 forEachValue(this._children, fn); 11994 }; 11995 11996 Module.prototype.forEachGetter = function forEachGetter(fn) { 11997 if (this._rawModule.getters) { 11998 forEachValue(this._rawModule.getters, fn); 11999 } 12000 }; 12001 12002 Module.prototype.forEachAction = function forEachAction(fn) { 12003 if (this._rawModule.actions) { 12004 forEachValue(this._rawModule.actions, fn); 12005 } 12006 }; 12007 12008 Module.prototype.forEachMutation = function forEachMutation(fn) { 12009 if (this._rawModule.mutations) { 12010 forEachValue(this._rawModule.mutations, fn); 12011 } 12012 }; 12013 12014 Object.defineProperties(Module.prototype, prototypeAccessors$1); 12015 12016 var ModuleCollection = function ModuleCollection(rawRootModule) { 12017 // register root module (Vuex.Store options) 12018 this.register([], rawRootModule, false); 12019 }; 12020 12021 ModuleCollection.prototype.get = function get(path) { 12022 return path.reduce(function (module, key) { 12023 return module.getChild(key); 12024 }, this.root); 12025 }; 12026 12027 ModuleCollection.prototype.getNamespace = function getNamespace(path) { 12028 var module = this.root; 12029 return path.reduce(function (namespace, key) { 12030 module = module.getChild(key); 12031 return namespace + (module.namespaced ? key + '/' : ''); 12032 }, ''); 12033 }; 12034 12035 ModuleCollection.prototype.update = function update$1(rawRootModule) { 12036 update([], this.root, rawRootModule); 12037 }; 12038 12039 ModuleCollection.prototype.register = function register(path, rawModule, runtime) { 12040 var this$1$1 = this; 12041 if (runtime === void 0) runtime = true; 12042 12043 var newModule = new Module(rawModule, runtime); 12044 12045 if (path.length === 0) { 12046 this.root = newModule; 12047 } else { 12048 var parent = this.get(path.slice(0, -1)); 12049 parent.addChild(path[path.length - 1], newModule); 12050 } // register nested modules 12051 12052 12053 if (rawModule.modules) { 12054 forEachValue(rawModule.modules, function (rawChildModule, key) { 12055 this$1$1.register(path.concat(key), rawChildModule, runtime); 12056 }); 12057 } 12058 }; 12059 12060 ModuleCollection.prototype.unregister = function unregister(path) { 12061 var parent = this.get(path.slice(0, -1)); 12062 var key = path[path.length - 1]; 12063 var child = parent.getChild(key); 12064 12065 if (!child) { 12066 12067 return; 12068 } 12069 12070 if (!child.runtime) { 12071 return; 12072 } 12073 12074 parent.removeChild(key); 12075 }; 12076 12077 ModuleCollection.prototype.isRegistered = function isRegistered(path) { 12078 var parent = this.get(path.slice(0, -1)); 12079 var key = path[path.length - 1]; 12080 12081 if (parent) { 12082 return parent.hasChild(key); 12083 } 12084 12085 return false; 12086 }; 12087 12088 function update(path, targetModule, newModule) { 12089 12090 12091 targetModule.update(newModule); // update nested modules 12092 12093 if (newModule.modules) { 12094 for (var key in newModule.modules) { 12095 if (!targetModule.getChild(key)) { 12096 12097 return; 12098 } 12099 12100 update(path.concat(key), targetModule.getChild(key), newModule.modules[key]); 12101 } 12102 } 12103 } 12104 12105 function createStore(options) { 12106 return new Store(options); 12107 } 12108 12109 var Store = function Store(options) { 12110 var this$1$1 = this; 12111 if (options === void 0) options = {}; 12112 12113 var plugins = options.plugins; 12114 if (plugins === void 0) plugins = []; 12115 var strict = options.strict; 12116 if (strict === void 0) strict = false; 12117 var devtools = options.devtools; // store internal state 12118 12119 this._committing = false; 12120 this._actions = Object.create(null); 12121 this._actionSubscribers = []; 12122 this._mutations = Object.create(null); 12123 this._wrappedGetters = Object.create(null); 12124 this._modules = new ModuleCollection(options); 12125 this._modulesNamespaceMap = Object.create(null); 12126 this._subscribers = []; 12127 this._makeLocalGettersCache = Object.create(null); 12128 this._devtools = devtools; // bind commit and dispatch to self 12129 12130 var store = this; 12131 var ref = this; 12132 var dispatch = ref.dispatch; 12133 var commit = ref.commit; 12134 12135 this.dispatch = function boundDispatch(type, payload) { 12136 return dispatch.call(store, type, payload); 12137 }; 12138 12139 this.commit = function boundCommit(type, payload, options) { 12140 return commit.call(store, type, payload, options); 12141 }; // strict mode 12142 12143 12144 this.strict = strict; 12145 var state = this._modules.root.state; // init root module. 12146 // this also recursively registers all sub-modules 12147 // and collects all module getters inside this._wrappedGetters 12148 12149 installModule(this, state, [], this._modules.root); // initialize the store state, which is responsible for the reactivity 12150 // (also registers _wrappedGetters as computed properties) 12151 12152 resetStoreState(this, state); // apply plugins 12153 12154 plugins.forEach(function (plugin) { 12155 return plugin(this$1$1); 12156 }); 12157 }; 12158 12159 var prototypeAccessors = { 12160 state: { 12161 configurable: true 12162 } 12163 }; 12164 12165 Store.prototype.install = function install(app, injectKey) { 12166 app.provide(injectKey || storeKey, this); 12167 app.config.globalProperties.$store = this; 12168 var useDevtools = this._devtools !== undefined ? this._devtools : __VUE_PROD_DEVTOOLS__; 12169 12170 if (useDevtools) { 12171 addDevtools(app, this); 12172 } 12173 }; 12174 12175 prototypeAccessors.state.get = function () { 12176 return this._state.data; 12177 }; 12178 12179 prototypeAccessors.state.set = function (v) { 12180 }; 12181 12182 Store.prototype.commit = function commit(_type, _payload, _options) { 12183 var this$1$1 = this; // check object-style commit 12184 12185 var ref = unifyObjectStyle(_type, _payload, _options); 12186 var type = ref.type; 12187 var payload = ref.payload; 12188 var mutation = { 12189 type: type, 12190 payload: payload 12191 }; 12192 var entry = this._mutations[type]; 12193 12194 if (!entry) { 12195 12196 return; 12197 } 12198 12199 this._withCommit(function () { 12200 entry.forEach(function commitIterator(handler) { 12201 handler(payload); 12202 }); 12203 }); 12204 12205 this._subscribers.slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe 12206 .forEach(function (sub) { 12207 return sub(mutation, this$1$1.state); 12208 }); 12209 }; 12210 12211 Store.prototype.dispatch = function dispatch(_type, _payload) { 12212 var this$1$1 = this; // check object-style dispatch 12213 12214 var ref = unifyObjectStyle(_type, _payload); 12215 var type = ref.type; 12216 var payload = ref.payload; 12217 var action = { 12218 type: type, 12219 payload: payload 12220 }; 12221 var entry = this._actions[type]; 12222 12223 if (!entry) { 12224 12225 return; 12226 } 12227 12228 try { 12229 this._actionSubscribers.slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe 12230 .filter(function (sub) { 12231 return sub.before; 12232 }).forEach(function (sub) { 12233 return sub.before(action, this$1$1.state); 12234 }); 12235 } catch (e) { 12236 } 12237 12238 var result = entry.length > 1 ? Promise.all(entry.map(function (handler) { 12239 return handler(payload); 12240 })) : entry[0](payload); 12241 return new Promise(function (resolve, reject) { 12242 result.then(function (res) { 12243 try { 12244 this$1$1._actionSubscribers.filter(function (sub) { 12245 return sub.after; 12246 }).forEach(function (sub) { 12247 return sub.after(action, this$1$1.state); 12248 }); 12249 } catch (e) { 12250 } 12251 12252 resolve(res); 12253 }, function (error) { 12254 try { 12255 this$1$1._actionSubscribers.filter(function (sub) { 12256 return sub.error; 12257 }).forEach(function (sub) { 12258 return sub.error(action, this$1$1.state, error); 12259 }); 12260 } catch (e) { 12261 } 12262 12263 reject(error); 12264 }); 12265 }); 12266 }; 12267 12268 Store.prototype.subscribe = function subscribe(fn, options) { 12269 return genericSubscribe(fn, this._subscribers, options); 12270 }; 12271 12272 Store.prototype.subscribeAction = function subscribeAction(fn, options) { 12273 var subs = typeof fn === 'function' ? { 12274 before: fn 12275 } : fn; 12276 return genericSubscribe(subs, this._actionSubscribers, options); 12277 }; 12278 12279 Store.prototype.watch = function watch$1(getter, cb, options) { 12280 var this$1$1 = this; 12281 12282 return watch(function () { 12283 return getter(this$1$1.state, this$1$1.getters); 12284 }, cb, Object.assign({}, options)); 12285 }; 12286 12287 Store.prototype.replaceState = function replaceState(state) { 12288 var this$1$1 = this; 12289 12290 this._withCommit(function () { 12291 this$1$1._state.data = state; 12292 }); 12293 }; 12294 12295 Store.prototype.registerModule = function registerModule(path, rawModule, options) { 12296 if (options === void 0) options = {}; 12297 12298 if (typeof path === 'string') { 12299 path = [path]; 12300 } 12301 12302 this._modules.register(path, rawModule); 12303 12304 installModule(this, this.state, path, this._modules.get(path), options.preserveState); // reset store to update getters... 12305 12306 resetStoreState(this, this.state); 12307 }; 12308 12309 Store.prototype.unregisterModule = function unregisterModule(path) { 12310 var this$1$1 = this; 12311 12312 if (typeof path === 'string') { 12313 path = [path]; 12314 } 12315 12316 this._modules.unregister(path); 12317 12318 this._withCommit(function () { 12319 var parentState = getNestedState(this$1$1.state, path.slice(0, -1)); 12320 delete parentState[path[path.length - 1]]; 12321 }); 12322 12323 resetStore(this); 12324 }; 12325 12326 Store.prototype.hasModule = function hasModule(path) { 12327 if (typeof path === 'string') { 12328 path = [path]; 12329 } 12330 12331 return this._modules.isRegistered(path); 12332 }; 12333 12334 Store.prototype.hotUpdate = function hotUpdate(newOptions) { 12335 this._modules.update(newOptions); 12336 12337 resetStore(this, true); 12338 }; 12339 12340 Store.prototype._withCommit = function _withCommit(fn) { 12341 var committing = this._committing; 12342 this._committing = true; 12343 fn(); 12344 this._committing = committing; 12345 }; 12346 12347 Object.defineProperties(Store.prototype, prototypeAccessors); 12348 12349 var r = function (r) { 12350 return function (r) { 12351 return !!r && "object" == typeof r; 12352 }(r) && !function (r) { 12353 var t = Object.prototype.toString.call(r); 12354 return "[object RegExp]" === t || "[object Date]" === t || function (r) { 12355 return r.$$typeof === e; 12356 }(r); 12357 }(r); 12358 }, 12359 e = "function" == typeof Symbol && Symbol.for ? Symbol.for("react.element") : 60103; 12360 12361 function t(r, e) { 12362 return !1 !== e.clone && e.isMergeableObject(r) ? u(Array.isArray(r) ? [] : {}, r, e) : r; 12363 } 12364 12365 function n(r, e, n) { 12366 return r.concat(e).map(function (r) { 12367 return t(r, n); 12368 }); 12369 } 12370 12371 function o(r) { 12372 return Object.keys(r).concat(function (r) { 12373 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(r).filter(function (e) { 12374 return r.propertyIsEnumerable(e); 12375 }) : []; 12376 }(r)); 12377 } 12378 12379 function c(r, e) { 12380 try { 12381 return e in r; 12382 } catch (r) { 12383 return !1; 12384 } 12385 } 12386 12387 function u(e, i, a) { 12388 (a = a || {}).arrayMerge = a.arrayMerge || n, a.isMergeableObject = a.isMergeableObject || r, a.cloneUnlessOtherwiseSpecified = t; 12389 var f = Array.isArray(i); 12390 return f === Array.isArray(e) ? f ? a.arrayMerge(e, i, a) : function (r, e, n) { 12391 var i = {}; 12392 return n.isMergeableObject(r) && o(r).forEach(function (e) { 12393 i[e] = t(r[e], n); 12394 }), o(e).forEach(function (o) { 12395 (function (r, e) { 12396 return c(r, e) && !(Object.hasOwnProperty.call(r, e) && Object.propertyIsEnumerable.call(r, e)); 12397 })(r, o) || (i[o] = c(r, o) && n.isMergeableObject(e[o]) ? function (r, e) { 12398 if (!e.customMerge) return u; 12399 var t = e.customMerge(r); 12400 return "function" == typeof t ? t : u; 12401 }(o, n)(r[o], e[o], n) : t(e[o], n)); 12402 }), i; 12403 }(e, i, a) : t(i, a); 12404 } 12405 12406 u.all = function (r, e) { 12407 if (!Array.isArray(r)) throw new Error("first argument should be an array"); 12408 return r.reduce(function (r, t) { 12409 return u(r, t, e); 12410 }, {}); 12411 }; 12412 12413 var i = u; 12414 12415 function a(r) { 12416 var e = (r = r || {}).storage || window && window.localStorage, 12417 t = r.key || "vuex"; 12418 12419 function n(r, e) { 12420 var t = e.getItem(r); 12421 12422 try { 12423 return "string" == typeof t ? JSON.parse(t) : "object" == typeof t ? t : void 0; 12424 } catch (r) {} 12425 } 12426 12427 function o() { 12428 return !0; 12429 } 12430 12431 function c(r, e, t) { 12432 return t.setItem(r, JSON.stringify(e)); 12433 } 12434 12435 function u(r, e) { 12436 return Array.isArray(e) ? e.reduce(function (e, t) { 12437 return function (r, e, t, n) { 12438 return !/^(__proto__|constructor|prototype)$/.test(e) && ((e = e.split ? e.split(".") : e.slice(0)).slice(0, -1).reduce(function (r, e) { 12439 return r[e] = r[e] || {}; 12440 }, r)[e.pop()] = t), r; 12441 }(e, t, (n = r, void 0 === (n = ((o = t).split ? o.split(".") : o).reduce(function (r, e) { 12442 return r && r[e]; 12443 }, n)) ? void 0 : n)); 12444 var n, o; 12445 }, {}) : r; 12446 } 12447 12448 function a(r) { 12449 return function (e) { 12450 return r.subscribe(e); 12451 }; 12452 } 12453 12454 (r.assertStorage || function () { 12455 e.setItem("@@", 1), e.removeItem("@@"); 12456 })(e); 12457 12458 var f, 12459 s = function () { 12460 return (r.getState || n)(t, e); 12461 }; 12462 12463 return r.fetchBeforeUse && (f = s()), function (n) { 12464 r.fetchBeforeUse || (f = s()), "object" == typeof f && null !== f && (n.replaceState(r.overwrite ? f : i(n.state, f, { 12465 arrayMerge: r.arrayMerger || function (r, e) { 12466 return e; 12467 }, 12468 clone: !1 12469 })), (r.rehydrated || function () {})(n)), (r.subscriber || a)(n)(function (n, i) { 12470 (r.filter || o)(n) && (r.setState || c)(t, (r.reducer || u)(i, r.paths), e); 12471 }); 12472 }; 12473 } 12474 12475 // The options for persisting state 12476 // eslint-disable-next-line import/prefer-default-export 12477 const persistedStateOptions = { 12478 key: 'joomla.mediamanager', 12479 paths: ['selectedDirectory', 'showInfoBar', 'listView', 'gridSize', 'search'], 12480 storage: window.sessionStorage 12481 }; 12482 12483 const options = Joomla.getOptions('com_media', {}); 12484 12485 if (options.providers === undefined || options.providers.length === 0) { 12486 throw new TypeError('Media providers are not defined.'); 12487 } 12488 /** 12489 * Get the drives 12490 * 12491 * @param {Array} adapterNames 12492 * @param {String} provider 12493 * 12494 * @return {Array} 12495 */ 12496 12497 12498 const getDrives = (adapterNames, provider) => { 12499 const drives = []; 12500 adapterNames.map(name => drives.push({ 12501 root: `$provider}-$name}:/`, 12502 displayName: name 12503 })); 12504 return drives; 12505 }; // Load disks from options 12506 12507 12508 const loadedDisks = options.providers.map(disk => ({ 12509 displayName: disk.displayName, 12510 drives: getDrives(disk.adapterNames, disk.name) 12511 })); 12512 const defaultDisk = loadedDisks.find(disk => disk.drives.length > 0 && disk.drives[0] !== undefined); 12513 12514 if (!defaultDisk) { 12515 throw new TypeError('No default media drive was found'); 12516 } // Override the storage if we have a path 12517 12518 12519 if (options.currentPath) { 12520 const storedState = JSON.parse(persistedStateOptions.storage.getItem(persistedStateOptions.key)); 12521 12522 if (storedState && storedState.selectedDirectory && storedState.selectedDirectory !== options.currentPath) { 12523 storedState.selectedDirectory = options.currentPath; 12524 persistedStateOptions.storage.setItem(persistedStateOptions.key, JSON.stringify(storedState)); 12525 } 12526 } // The initial state 12527 12528 12529 var state = { 12530 // The general loading state 12531 isLoading: false, 12532 // Will hold the activated filesystem disks 12533 disks: loadedDisks, 12534 // The loaded directories 12535 directories: loadedDisks.map(() => ({ 12536 path: defaultDisk.drives[0].root, 12537 name: defaultDisk.displayName, 12538 directories: [], 12539 files: [], 12540 directory: null 12541 })), 12542 // The loaded files 12543 files: [], 12544 // The selected disk. Providers are ordered by plugin ordering, so we set the first provider 12545 // in the list as the default provider and load first drive on it as default 12546 selectedDirectory: options.currentPath || defaultDisk.drives[0].root, 12547 // The currently selected items 12548 selectedItems: [], 12549 // The state of the infobar 12550 showInfoBar: false, 12551 // List view 12552 listView: 'grid', 12553 // The size of the grid items 12554 gridSize: 'md', 12555 // The state of confirm delete model 12556 showConfirmDeleteModal: false, 12557 // The state of create folder model 12558 showCreateFolderModal: false, 12559 // The state of preview model 12560 showPreviewModal: false, 12561 // The state of share model 12562 showShareModal: false, 12563 // The state of model 12564 showRenameModal: false, 12565 // The preview item 12566 previewItem: null, 12567 // The Search Query 12568 search: '' 12569 }; 12570 12571 // Sometimes we may need to compute derived state based on store state, 12572 // for example filtering through a list of items and counting them. 12573 12574 /** 12575 * Get the currently selected directory 12576 * @param state 12577 * @returns {*} 12578 */ 12579 const getSelectedDirectory = state => state.directories.find(directory => directory.path === state.selectedDirectory); 12580 /** 12581 * Get the sudirectories of the currently selected directory 12582 * @param state 12583 * 12584 * @returns {Array|directories|{/}|computed.directories|*|Object} 12585 */ 12586 12587 const getSelectedDirectoryDirectories = state => state.directories.filter(directory => directory.directory === state.selectedDirectory); 12588 /** 12589 * Get the files of the currently selected directory 12590 * @param state 12591 * 12592 * @returns {Array|files|{}|FileList|*} 12593 */ 12594 12595 const getSelectedDirectoryFiles = state => state.files.filter(file => file.directory === state.selectedDirectory); 12596 /** 12597 * Whether or not all items of the current directory are selected 12598 * @param state 12599 * @param getters 12600 * @returns Array 12601 */ 12602 12603 const getSelectedDirectoryContents = (state, getters) => [...getters.getSelectedDirectoryDirectories, ...getters.getSelectedDirectoryFiles]; 12604 12605 var getters = /*#__PURE__*/Object.freeze({ 12606 __proto__: null, 12607 getSelectedDirectory: getSelectedDirectory, 12608 getSelectedDirectoryDirectories: getSelectedDirectoryDirectories, 12609 getSelectedDirectoryFiles: getSelectedDirectoryFiles, 12610 getSelectedDirectoryContents: getSelectedDirectoryContents 12611 }); 12612 12613 const updateUrlPath = path => { 12614 const currentPath = path === null ? '' : path; 12615 const url = new URL(window.location.href); 12616 12617 if (url.searchParams.has('path')) { 12618 window.history.pushState(null, '', url.href.replace(/\b(path=).*?(&|$)/, `$1$currentPath}$2`)); 12619 } else { 12620 window.history.pushState(null, '', `$url.href + (url.href.indexOf('?') > 0 ? '&' : '?')}path=$currentPath}`); 12621 } 12622 }; 12623 /** 12624 * Actions are similar to mutations, the difference being that: 12625 * Instead of mutating the state, actions commit mutations. 12626 * Actions can contain arbitrary asynchronous operations. 12627 */ 12628 12629 /** 12630 * Get contents of a directory from the api 12631 * @param context 12632 * @param payload 12633 */ 12634 12635 12636 const getContents = (context, payload) => { 12637 // Update the url 12638 updateUrlPath(payload); 12639 context.commit(SET_IS_LOADING, true); 12640 api.getContents(payload, 0).then(contents => { 12641 context.commit(LOAD_CONTENTS_SUCCESS, contents); 12642 context.commit(UNSELECT_ALL_BROWSER_ITEMS); 12643 context.commit(SELECT_DIRECTORY, payload); 12644 context.commit(SET_IS_LOADING, false); 12645 }).catch(error => { 12646 // @todo error handling 12647 context.commit(SET_IS_LOADING, false); // eslint-disable-next-line no-console 12648 12649 console.log('error', error); 12650 }); 12651 }; 12652 /** 12653 * Get the full contents of a directory 12654 * @param context 12655 * @param payload 12656 */ 12657 12658 const getFullContents = (context, payload) => { 12659 context.commit(SET_IS_LOADING, true); 12660 api.getContents(payload.path, 1).then(contents => { 12661 context.commit(LOAD_FULL_CONTENTS_SUCCESS, contents.files[0]); 12662 context.commit(SET_IS_LOADING, false); 12663 }).catch(error => { 12664 // @todo error handling 12665 context.commit(SET_IS_LOADING, false); // eslint-disable-next-line no-console 12666 12667 console.log('error', error); 12668 }); 12669 }; 12670 /** 12671 * Download a file 12672 * @param context 12673 * @param payload 12674 */ 12675 12676 const download = (context, payload) => { 12677 api.getContents(payload.path, 0, 1).then(contents => { 12678 const file = contents.files[0]; // Convert the base 64 encoded string to a blob 12679 12680 const byteCharacters = atob(file.content); 12681 const byteArrays = []; 12682 12683 for (let offset = 0; offset < byteCharacters.length; offset += 512) { 12684 const slice = byteCharacters.slice(offset, offset + 512); 12685 const byteNumbers = new Array(slice.length); // eslint-disable-next-line no-plusplus 12686 12687 for (let i = 0; i < slice.length; i++) { 12688 byteNumbers[i] = slice.charCodeAt(i); 12689 } 12690 12691 const byteArray = new Uint8Array(byteNumbers); 12692 byteArrays.push(byteArray); 12693 } // Download file 12694 12695 12696 const blobURL = URL.createObjectURL(new Blob(byteArrays, { 12697 type: file.mime_type 12698 })); 12699 const a = document.createElement('a'); 12700 a.href = blobURL; 12701 a.download = file.name; 12702 document.body.appendChild(a); 12703 a.click(); 12704 document.body.removeChild(a); 12705 }).catch(error => { 12706 // eslint-disable-next-line no-console 12707 console.log('error', error); 12708 }); 12709 }; 12710 /** 12711 * Toggle the selection state of an item 12712 * @param context 12713 * @param payload 12714 */ 12715 12716 const toggleBrowserItemSelect = (context, payload) => { 12717 const item = payload; 12718 const isSelected = context.state.selectedItems.some(selected => selected.path === item.path); 12719 12720 if (!isSelected) { 12721 context.commit(SELECT_BROWSER_ITEM, item); 12722 } else { 12723 context.commit(UNSELECT_BROWSER_ITEM, item); 12724 } 12725 }; 12726 /** 12727 * Create a new folder 12728 * @param context 12729 * @param payload object with the new folder name and its parent directory 12730 */ 12731 12732 const createDirectory = (context, payload) => { 12733 if (!api.canCreate) { 12734 return; 12735 } 12736 12737 context.commit(SET_IS_LOADING, true); 12738 api.createDirectory(payload.name, payload.parent).then(folder => { 12739 context.commit(CREATE_DIRECTORY_SUCCESS, folder); 12740 context.commit(HIDE_CREATE_FOLDER_MODAL); 12741 context.commit(SET_IS_LOADING, false); 12742 }).catch(error => { 12743 // @todo error handling 12744 context.commit(SET_IS_LOADING, false); // eslint-disable-next-line no-console 12745 12746 console.log('error', error); 12747 }); 12748 }; 12749 /** 12750 * Create a new folder 12751 * @param context 12752 * @param payload object with the new folder name and its parent directory 12753 */ 12754 12755 const uploadFile = (context, payload) => { 12756 if (!api.canCreate) { 12757 return; 12758 } 12759 12760 context.commit(SET_IS_LOADING, true); 12761 api.upload(payload.name, payload.parent, payload.content, payload.override || false).then(file => { 12762 context.commit(UPLOAD_SUCCESS, file); 12763 context.commit(SET_IS_LOADING, false); 12764 }).catch(error => { 12765 context.commit(SET_IS_LOADING, false); // Handle file exists 12766 12767 if (error.status === 409) { 12768 if (notifications.ask(Translate.sprintf('COM_MEDIA_FILE_EXISTS_AND_OVERRIDE', payload.name), {})) { 12769 payload.override = true; 12770 uploadFile(context, payload); 12771 } 12772 } 12773 }); 12774 }; 12775 /** 12776 * Rename an item 12777 * @param context 12778 * @param payload object: the item and the new path 12779 */ 12780 12781 const renameItem = (context, payload) => { 12782 if (!api.canEdit) { 12783 return; 12784 } 12785 12786 if (typeof payload.item.canEdit !== 'undefined' && payload.item.canEdit === false) { 12787 return; 12788 } 12789 12790 context.commit(SET_IS_LOADING, true); 12791 api.rename(payload.item.path, payload.newPath).then(item => { 12792 context.commit(RENAME_SUCCESS, { 12793 item, 12794 oldPath: payload.item.path, 12795 newName: payload.newName 12796 }); 12797 context.commit(HIDE_RENAME_MODAL); 12798 context.commit(SET_IS_LOADING, false); 12799 }).catch(error => { 12800 // @todo error handling 12801 context.commit(SET_IS_LOADING, false); // eslint-disable-next-line no-console 12802 12803 console.log('error', error); 12804 }); 12805 }; 12806 /** 12807 * Delete the selected items 12808 * @param context 12809 */ 12810 12811 const deleteSelectedItems = context => { 12812 if (!api.canDelete) { 12813 return; 12814 } 12815 12816 context.commit(SET_IS_LOADING, true); // Get the selected items from the store 12817 12818 const { 12819 selectedItems 12820 } = context.state; 12821 12822 if (selectedItems.length > 0) { 12823 selectedItems.forEach(item => { 12824 if (typeof item.canDelete !== 'undefined' && item.canDelete === false) { 12825 return; 12826 } 12827 12828 api.delete(item.path).then(() => { 12829 context.commit(DELETE_SUCCESS, item); 12830 context.commit(UNSELECT_ALL_BROWSER_ITEMS); 12831 context.commit(SET_IS_LOADING, false); 12832 }).catch(error => { 12833 // @todo error handling 12834 context.commit(SET_IS_LOADING, false); // eslint-disable-next-line no-console 12835 12836 console.log('error', error); 12837 }); 12838 }); 12839 } 12840 }; 12841 12842 var actions = /*#__PURE__*/Object.freeze({ 12843 __proto__: null, 12844 getContents: getContents, 12845 getFullContents: getFullContents, 12846 download: download, 12847 toggleBrowserItemSelect: toggleBrowserItemSelect, 12848 createDirectory: createDirectory, 12849 uploadFile: uploadFile, 12850 renameItem: renameItem, 12851 deleteSelectedItems: deleteSelectedItems 12852 }); 12853 12854 // Mutations are very similar to events: each mutation has a string type and a handler. 12855 // The handler function is where we perform actual state modifications, 12856 // and it will receive the state as the first argument. 12857 // The grid item sizes 12858 12859 const gridItemSizes = ['sm', 'md', 'lg', 'xl']; 12860 var mutations = { 12861 /** 12862 * Select a directory 12863 * @param state 12864 * @param payload 12865 */ 12866 [SELECT_DIRECTORY]: (state, payload) => { 12867 state.selectedDirectory = payload; 12868 state.search = ''; 12869 }, 12870 12871 /** 12872 * The load content success mutation 12873 * @param state 12874 * @param payload 12875 */ 12876 [LOAD_CONTENTS_SUCCESS]: (state, payload) => { 12877 /** 12878 * Create the directory structure 12879 * @param path 12880 */ 12881 function createDirectoryStructureFromPath(path) { 12882 const exists = state.directories.some(existing => existing.path === path); 12883 12884 if (!exists) { 12885 // eslint-disable-next-line no-use-before-define 12886 const directory = directoryFromPath(path); // Add the sub directories and files 12887 12888 directory.directories = state.directories.filter(existing => existing.directory === directory.path).map(existing => existing.path); // Add the directory 12889 12890 state.directories.push(directory); 12891 12892 if (directory.directory) { 12893 createDirectoryStructureFromPath(directory.directory); 12894 } 12895 } 12896 } 12897 /** 12898 * Create a directory from a path 12899 * @param path 12900 */ 12901 12902 12903 function directoryFromPath(path) { 12904 const parts = path.split('/'); 12905 let directory = dirname(path); 12906 12907 if (directory.indexOf(':', directory.length - 1) !== -1) { 12908 directory += '/'; 12909 } 12910 12911 return { 12912 path, 12913 name: parts[parts.length - 1], 12914 directories: [], 12915 files: [], 12916 directory: directory !== '.' ? directory : null, 12917 type: 'dir', 12918 mime_type: 'directory' 12919 }; 12920 } 12921 /** 12922 * Add a directory 12923 * @param state 12924 * @param directory 12925 */ 12926 // eslint-disable-next-line no-shadow 12927 12928 12929 function addDirectory(state, directory) { 12930 const parentDirectory = state.directories.find(existing => existing.path === directory.directory); 12931 const parentDirectoryIndex = state.directories.indexOf(parentDirectory); 12932 let index = state.directories.findIndex(existing => existing.path === directory.path); 12933 12934 if (index === -1) { 12935 index = state.directories.length; 12936 } // Add the directory 12937 12938 12939 state.directories.splice(index, 1, directory); // Update the relation to the parent directory 12940 12941 if (parentDirectoryIndex !== -1) { 12942 state.directories.splice(parentDirectoryIndex, 1, { ...parentDirectory, 12943 directories: [...parentDirectory.directories, directory.path] 12944 }); 12945 } 12946 } 12947 /** 12948 * Add a file 12949 * @param state 12950 * @param directory 12951 */ 12952 // eslint-disable-next-line no-shadow 12953 12954 12955 function addFile(state, file) { 12956 const parentDirectory = state.directories.find(directory => directory.path === file.directory); 12957 const parentDirectoryIndex = state.directories.indexOf(parentDirectory); 12958 let index = state.files.findIndex(existing => existing.path === file.path); 12959 12960 if (index === -1) { 12961 index = state.files.length; 12962 } // Add the file 12963 12964 12965 state.files.splice(index, 1, file); // Update the relation to the parent directory 12966 12967 if (parentDirectoryIndex !== -1) { 12968 state.directories.splice(parentDirectoryIndex, 1, { ...parentDirectory, 12969 files: [...parentDirectory.files, file.path] 12970 }); 12971 } 12972 } // Create the parent directory structure if it does not exist 12973 12974 12975 createDirectoryStructureFromPath(state.selectedDirectory); // Add directories 12976 12977 payload.directories.forEach(directory => { 12978 addDirectory(state, directory); 12979 }); // Add files 12980 12981 payload.files.forEach(file => { 12982 addFile(state, file); 12983 }); 12984 }, 12985 12986 /** 12987 * The upload success mutation 12988 * @param state 12989 * @param payload 12990 */ 12991 [UPLOAD_SUCCESS]: (state, payload) => { 12992 const file = payload; 12993 const isNew = !state.files.some(existing => existing.path === file.path); // @todo handle file_exists 12994 12995 if (isNew) { 12996 const parentDirectory = state.directories.find(existing => existing.path === file.directory); 12997 const parentDirectoryIndex = state.directories.indexOf(parentDirectory); // Add the new file to the files array 12998 12999 state.files.push(file); // Update the relation to the parent directory 13000 13001 state.directories.splice(parentDirectoryIndex, 1, { ...parentDirectory, 13002 files: [...parentDirectory.files, file.path] 13003 }); 13004 } 13005 }, 13006 13007 /** 13008 * The create directory success mutation 13009 * @param state 13010 * @param payload 13011 */ 13012 [CREATE_DIRECTORY_SUCCESS]: (state, payload) => { 13013 const directory = payload; 13014 const isNew = !state.directories.some(existing => existing.path === directory.path); 13015 13016 if (isNew) { 13017 const parentDirectory = state.directories.find(existing => existing.path === directory.directory); 13018 const parentDirectoryIndex = state.directories.indexOf(parentDirectory); // Add the new directory to the directory 13019 13020 state.directories.push(directory); // Update the relation to the parent directory 13021 13022 state.directories.splice(parentDirectoryIndex, 1, { ...parentDirectory, 13023 directories: [...parentDirectory.directories, directory.path] 13024 }); 13025 } 13026 }, 13027 13028 /** 13029 * The rename success handler 13030 * @param state 13031 * @param payload 13032 */ 13033 [RENAME_SUCCESS]: (state, payload) => { 13034 state.selectedItems[state.selectedItems.length - 1].name = payload.newName; 13035 const { 13036 item 13037 } = payload; 13038 const { 13039 oldPath 13040 } = payload; 13041 13042 if (item.type === 'file') { 13043 const index = state.files.findIndex(file => file.path === oldPath); 13044 state.files.splice(index, 1, item); 13045 } else { 13046 const index = state.directories.findIndex(directory => directory.path === oldPath); 13047 state.directories.splice(index, 1, item); 13048 } 13049 }, 13050 13051 /** 13052 * The delete success mutation 13053 * @param state 13054 * @param payload 13055 */ 13056 [DELETE_SUCCESS]: (state, payload) => { 13057 const item = payload; // Delete file 13058 13059 if (item.type === 'file') { 13060 state.files.splice(state.files.findIndex(file => file.path === item.path), 1); 13061 } // Delete dir 13062 13063 13064 if (item.type === 'dir') { 13065 state.directories.splice(state.directories.findIndex(directory => directory.path === item.path), 1); 13066 } 13067 }, 13068 13069 /** 13070 * Select a browser item 13071 * @param state 13072 * @param payload the item 13073 */ 13074 [SELECT_BROWSER_ITEM]: (state, payload) => { 13075 state.selectedItems.push(payload); 13076 }, 13077 13078 /** 13079 * Select browser items 13080 * @param state 13081 * @param payload the items 13082 */ 13083 [SELECT_BROWSER_ITEMS]: (state, payload) => { 13084 state.selectedItems = payload; 13085 }, 13086 13087 /** 13088 * Unselect a browser item 13089 * @param state 13090 * @param payload the item 13091 */ 13092 [UNSELECT_BROWSER_ITEM]: (state, payload) => { 13093 const item = payload; 13094 state.selectedItems.splice(state.selectedItems.findIndex(selectedItem => selectedItem.path === item.path), 1); 13095 }, 13096 13097 /** 13098 * Unselect all browser items 13099 * @param state 13100 * @param payload the item 13101 */ 13102 [UNSELECT_ALL_BROWSER_ITEMS]: state => { 13103 state.selectedItems = []; 13104 }, 13105 13106 /** 13107 * Show the create folder modal 13108 * @param state 13109 */ 13110 [SHOW_CREATE_FOLDER_MODAL]: state => { 13111 state.showCreateFolderModal = true; 13112 }, 13113 13114 /** 13115 * Hide the create folder modal 13116 * @param state 13117 */ 13118 [HIDE_CREATE_FOLDER_MODAL]: state => { 13119 state.showCreateFolderModal = false; 13120 }, 13121 13122 /** 13123 * Show the info bar 13124 * @param state 13125 */ 13126 [SHOW_INFOBAR]: state => { 13127 state.showInfoBar = true; 13128 }, 13129 13130 /** 13131 * Show the info bar 13132 * @param state 13133 */ 13134 [HIDE_INFOBAR]: state => { 13135 state.showInfoBar = false; 13136 }, 13137 13138 /** 13139 * Define the list grid view 13140 * @param state 13141 */ 13142 [CHANGE_LIST_VIEW]: (state, view) => { 13143 state.listView = view; 13144 }, 13145 13146 /** 13147 * FUll content is loaded 13148 * @param state 13149 * @param payload 13150 */ 13151 [LOAD_FULL_CONTENTS_SUCCESS]: (state, payload) => { 13152 state.previewItem = payload; 13153 }, 13154 13155 /** 13156 * Show the preview modal 13157 * @param state 13158 */ 13159 [SHOW_PREVIEW_MODAL]: state => { 13160 state.showPreviewModal = true; 13161 }, 13162 13163 /** 13164 * Hide the preview modal 13165 * @param state 13166 */ 13167 [HIDE_PREVIEW_MODAL]: state => { 13168 state.showPreviewModal = false; 13169 }, 13170 13171 /** 13172 * Set the is loading state 13173 * @param state 13174 */ 13175 [SET_IS_LOADING]: (state, payload) => { 13176 state.isLoading = payload; 13177 }, 13178 13179 /** 13180 * Show the rename modal 13181 * @param state 13182 */ 13183 [SHOW_RENAME_MODAL]: state => { 13184 state.showRenameModal = true; 13185 }, 13186 13187 /** 13188 * Hide the rename modal 13189 * @param state 13190 */ 13191 [HIDE_RENAME_MODAL]: state => { 13192 state.showRenameModal = false; 13193 }, 13194 13195 /** 13196 * Show the share modal 13197 * @param state 13198 */ 13199 [SHOW_SHARE_MODAL]: state => { 13200 state.showShareModal = true; 13201 }, 13202 13203 /** 13204 * Hide the share modal 13205 * @param state 13206 */ 13207 [HIDE_SHARE_MODAL]: state => { 13208 state.showShareModal = false; 13209 }, 13210 13211 /** 13212 * Increase the size of the grid items 13213 * @param state 13214 */ 13215 [INCREASE_GRID_SIZE]: state => { 13216 let currentSizeIndex = gridItemSizes.indexOf(state.gridSize); 13217 13218 if (currentSizeIndex >= 0 && currentSizeIndex < gridItemSizes.length - 1) { 13219 // eslint-disable-next-line no-plusplus 13220 state.gridSize = gridItemSizes[++currentSizeIndex]; 13221 } 13222 }, 13223 13224 /** 13225 * Increase the size of the grid items 13226 * @param state 13227 */ 13228 [DECREASE_GRID_SIZE]: state => { 13229 let currentSizeIndex = gridItemSizes.indexOf(state.gridSize); 13230 13231 if (currentSizeIndex > 0 && currentSizeIndex < gridItemSizes.length) { 13232 // eslint-disable-next-line no-plusplus 13233 state.gridSize = gridItemSizes[--currentSizeIndex]; 13234 } 13235 }, 13236 13237 /** 13238 * Set search query 13239 * @param state 13240 * @param query 13241 */ 13242 [SET_SEARCH_QUERY]: (state, query) => { 13243 state.search = query; 13244 }, 13245 13246 /** 13247 * Show the confirm modal 13248 * @param state 13249 */ 13250 [SHOW_CONFIRM_DELETE_MODAL]: state => { 13251 state.showConfirmDeleteModal = true; 13252 }, 13253 13254 /** 13255 * Hide the confirm modal 13256 * @param state 13257 */ 13258 [HIDE_CONFIRM_DELETE_MODAL]: state => { 13259 state.showConfirmDeleteModal = false; 13260 } 13261 }; 13262 13263 var store = createStore({ 13264 state, 13265 getters, 13266 actions, 13267 mutations, 13268 plugins: [a(persistedStateOptions)], 13269 strict: "production" !== 'production' 13270 }); 13271 13272 var script$7 = { 13273 name: 'MediaBrowserActionItemRename', 13274 props: { 13275 onFocused: { type: Function, default: () => {} }, 13276 mainAction: { type: Function, default: () => {} }, 13277 closingAction: { type: Function, default: () => {} }, 13278 }, 13279 methods: { 13280 openRenameModal() { 13281 this.mainAction(); 13282 }, 13283 hideActions() { 13284 this.closingAction(); 13285 }, 13286 focused(bool) { 13287 this.onFocused(bool); 13288 }, 13289 }, 13290 }; 13291 13292 const _hoisted_1$7 = ["aria-label", "title"]; 13293 13294 function render$7(_ctx, _cache, $props, $setup, $data, $options) { 13295 return (openBlock(), createElementBlock("button", { 13296 ref: "actionRenameButton", 13297 type: "button", 13298 class: "action-rename", 13299 "aria-label": _ctx.translate('COM_MEDIA_ACTION_RENAME'), 13300 title: _ctx.translate('COM_MEDIA_ACTION_RENAME'), 13301 onKeyup: [ 13302 _cache[1] || (_cache[1] = withKeys($event => ($options.openRenameModal()), ["enter"])), 13303 _cache[2] || (_cache[2] = withKeys($event => ($options.openRenameModal()), ["space"])), 13304 _cache[5] || (_cache[5] = withKeys($event => ($options.hideActions()), ["esc"])) 13305 ], 13306 onFocus: _cache[3] || (_cache[3] = $event => ($options.focused(true))), 13307 onBlur: _cache[4] || (_cache[4] = $event => ($options.focused(false))) 13308 }, [ 13309 createBaseVNode("span", { 13310 class: "image-browser-action icon-text-width", 13311 "aria-hidden": "true", 13312 onClick: _cache[0] || (_cache[0] = withModifiers($event => ($options.openRenameModal()), ["stop"])) 13313 }) 13314 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1$7)) 13315 } 13316 13317 script$7.render = render$7; 13318 script$7.__file = "administrator/components/com_media/resources/scripts/components/browser/actionItems/rename.vue"; 13319 13320 var script$6 = { 13321 name: 'MediaBrowserActionItemToggle', 13322 props: { 13323 mainAction: { type: Function, default: () => {} }, 13324 }, 13325 emits: ['on-focused'], 13326 methods: { 13327 openActions() { 13328 this.mainAction(); 13329 }, 13330 focused(bool) { 13331 this.$emit('on-focused', bool); 13332 }, 13333 }, 13334 }; 13335 13336 const _hoisted_1$6 = ["aria-label", "title"]; 13337 13338 function render$6(_ctx, _cache, $props, $setup, $data, $options) { 13339 return (openBlock(), createElementBlock("button", { 13340 type: "button", 13341 class: "action-toggle", 13342 tabindex: "0", 13343 "aria-label": _ctx.translate('COM_MEDIA_OPEN_ITEM_ACTIONS'), 13344 title: _ctx.translate('COM_MEDIA_OPEN_ITEM_ACTIONS'), 13345 onKeyup: [ 13346 _cache[1] || (_cache[1] = withKeys($event => ($options.openActions()), ["enter"])), 13347 _cache[4] || (_cache[4] = withKeys($event => ($options.openActions()), ["space"])) 13348 ], 13349 onFocus: _cache[2] || (_cache[2] = $event => ($options.focused(true))), 13350 onBlur: _cache[3] || (_cache[3] = $event => ($options.focused(false))) 13351 }, [ 13352 createBaseVNode("span", { 13353 class: "image-browser-action icon-ellipsis-h", 13354 "aria-hidden": "true", 13355 onClick: _cache[0] || (_cache[0] = withModifiers($event => ($options.openActions()), ["stop"])) 13356 }) 13357 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1$6)) 13358 } 13359 13360 script$6.render = render$6; 13361 script$6.__file = "administrator/components/com_media/resources/scripts/components/browser/actionItems/toggle.vue"; 13362 13363 var script$5 = { 13364 name: 'MediaBrowserActionItemPreview', 13365 props: { 13366 onFocused: { type: Function, default: () => {} }, 13367 mainAction: { type: Function, default: () => {} }, 13368 closingAction: { type: Function, default: () => {} }, 13369 }, 13370 methods: { 13371 openPreview() { 13372 this.mainAction(); 13373 }, 13374 hideActions() { 13375 this.closingAction(); 13376 }, 13377 focused(bool) { 13378 this.onFocused(bool); 13379 }, 13380 }, 13381 }; 13382 13383 const _hoisted_1$5 = ["aria-label", "title"]; 13384 13385 function render$5(_ctx, _cache, $props, $setup, $data, $options) { 13386 return (openBlock(), createElementBlock("button", { 13387 type: "button", 13388 class: "action-preview", 13389 "aria-label": _ctx.translate('COM_MEDIA_ACTION_PREVIEW'), 13390 title: _ctx.translate('COM_MEDIA_ACTION_PREVIEW'), 13391 onKeyup: [ 13392 _cache[1] || (_cache[1] = withKeys($event => ($options.openPreview()), ["enter"])), 13393 _cache[2] || (_cache[2] = withKeys($event => ($options.openPreview()), ["space"])), 13394 _cache[5] || (_cache[5] = withKeys($event => ($options.hideActions()), ["esc"])) 13395 ], 13396 onFocus: _cache[3] || (_cache[3] = $event => ($options.focused(true))), 13397 onBlur: _cache[4] || (_cache[4] = $event => ($options.focused(false))) 13398 }, [ 13399 createBaseVNode("span", { 13400 class: "image-browser-action icon-search-plus", 13401 "aria-hidden": "true", 13402 onClick: _cache[0] || (_cache[0] = withModifiers($event => ($options.openPreview()), ["stop"])) 13403 }) 13404 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1$5)) 13405 } 13406 13407 script$5.render = render$5; 13408 script$5.__file = "administrator/components/com_media/resources/scripts/components/browser/actionItems/preview.vue"; 13409 13410 var script$4 = { 13411 name: 'MediaBrowserActionItemDownload', 13412 props: { 13413 onFocused: { type: Function, default: () => {} }, 13414 mainAction: { type: Function, default: () => {} }, 13415 closingAction: { type: Function, default: () => {} }, 13416 }, 13417 methods: { 13418 download() { 13419 this.mainAction(); 13420 }, 13421 hideActions() { 13422 this.closingAction(); 13423 }, 13424 focused(bool) { 13425 this.onFocused(bool); 13426 }, 13427 }, 13428 }; 13429 13430 const _hoisted_1$4 = ["aria-label", "title"]; 13431 13432 function render$4(_ctx, _cache, $props, $setup, $data, $options) { 13433 return (openBlock(), createElementBlock("button", { 13434 type: "button", 13435 class: "action-download", 13436 "aria-label": _ctx.translate('COM_MEDIA_ACTION_DOWNLOAD'), 13437 title: _ctx.translate('COM_MEDIA_ACTION_DOWNLOAD'), 13438 onKeyup: [ 13439 _cache[1] || (_cache[1] = withKeys($event => ($options.download()), ["enter"])), 13440 _cache[2] || (_cache[2] = withKeys($event => ($options.download()), ["space"])), 13441 _cache[5] || (_cache[5] = withKeys($event => ($options.hideActions()), ["esc"])) 13442 ], 13443 onFocus: _cache[3] || (_cache[3] = $event => ($options.focused(true))), 13444 onBlur: _cache[4] || (_cache[4] = $event => ($options.focused(false))) 13445 }, [ 13446 createBaseVNode("span", { 13447 class: "image-browser-action icon-download", 13448 "aria-hidden": "true", 13449 onClick: _cache[0] || (_cache[0] = withModifiers($event => ($options.download()), ["stop"])) 13450 }) 13451 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1$4)) 13452 } 13453 13454 script$4.render = render$4; 13455 script$4.__file = "administrator/components/com_media/resources/scripts/components/browser/actionItems/download.vue"; 13456 13457 var script$3 = { 13458 name: 'MediaBrowserActionItemShare', 13459 props: { 13460 onFocused: { type: Function, default: () => {} }, 13461 mainAction: { type: Function, default: () => {} }, 13462 closingAction: { type: Function, default: () => {} }, 13463 }, 13464 methods: { 13465 openShareUrlModal() { 13466 this.mainAction(); 13467 }, 13468 hideActions() { 13469 this.closingAction(); 13470 }, 13471 focused(bool) { 13472 this.onFocused(bool); 13473 }, 13474 }, 13475 }; 13476 13477 const _hoisted_1$3 = ["aria-label", "title"]; 13478 13479 function render$3(_ctx, _cache, $props, $setup, $data, $options) { 13480 return (openBlock(), createElementBlock("button", { 13481 type: "button", 13482 class: "action-url", 13483 "aria-label": _ctx.translate('COM_MEDIA_ACTION_SHARE'), 13484 title: _ctx.translate('COM_MEDIA_ACTION_SHARE'), 13485 onKeyup: [ 13486 _cache[1] || (_cache[1] = withKeys($event => ($options.openShareUrlModal()), ["enter"])), 13487 _cache[2] || (_cache[2] = withKeys($event => ($options.openShareUrlModal()), ["space"])), 13488 _cache[5] || (_cache[5] = withKeys($event => ($options.hideActions()), ["esc"])) 13489 ], 13490 onFocus: _cache[3] || (_cache[3] = $event => ($options.focused(true))), 13491 onBlur: _cache[4] || (_cache[4] = $event => ($options.focused(false))) 13492 }, [ 13493 createBaseVNode("span", { 13494 class: "image-browser-action icon-link", 13495 "aria-hidden": "true", 13496 onClick: _cache[0] || (_cache[0] = withModifiers($event => ($options.openShareUrlModal()), ["stop"])) 13497 }) 13498 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1$3)) 13499 } 13500 13501 script$3.render = render$3; 13502 script$3.__file = "administrator/components/com_media/resources/scripts/components/browser/actionItems/share.vue"; 13503 13504 var script$2 = { 13505 name: 'MediaBrowserActionItemDelete', 13506 props: { 13507 onFocused: { type: Function, default: () => {} }, 13508 mainAction: { type: Function, default: () => {} }, 13509 closingAction: { type: Function, default: () => {} }, 13510 }, 13511 methods: { 13512 openConfirmDeleteModal() { 13513 this.mainAction(); 13514 }, 13515 hideActions() { 13516 this.hideActions(); 13517 }, 13518 focused(bool) { 13519 this.onFocused(bool); 13520 }, 13521 }, 13522 }; 13523 13524 const _hoisted_1$2 = ["aria-label", "title"]; 13525 13526 function render$2(_ctx, _cache, $props, $setup, $data, $options) { 13527 return (openBlock(), createElementBlock("button", { 13528 type: "button", 13529 class: "action-delete", 13530 "aria-label": _ctx.translate('COM_MEDIA_ACTION_DELETE'), 13531 title: _ctx.translate('COM_MEDIA_ACTION_DELETE'), 13532 onKeyup: [ 13533 _cache[1] || (_cache[1] = withKeys($event => ($options.openConfirmDeleteModal()), ["enter"])), 13534 _cache[2] || (_cache[2] = withKeys($event => ($options.openConfirmDeleteModal()), ["space"])), 13535 _cache[5] || (_cache[5] = withKeys($event => ($options.hideActions()), ["esc"])) 13536 ], 13537 onFocus: _cache[3] || (_cache[3] = $event => ($options.focused(true))), 13538 onBlur: _cache[4] || (_cache[4] = $event => ($options.focused(false))) 13539 }, [ 13540 createBaseVNode("span", { 13541 class: "image-browser-action icon-trash", 13542 "aria-hidden": "true", 13543 onClick: _cache[0] || (_cache[0] = withModifiers($event => ($options.openConfirmDeleteModal()), ["stop"])) 13544 }) 13545 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1$2)) 13546 } 13547 13548 script$2.render = render$2; 13549 script$2.__file = "administrator/components/com_media/resources/scripts/components/browser/actionItems/delete.vue"; 13550 13551 var script$1 = { 13552 name: 'MediaBrowserActionItemEdit', 13553 props: { 13554 onFocused: { type: Function, default: () => {} }, 13555 mainAction: { type: Function, default: () => {} }, 13556 closingAction: { type: Function, default: () => {} }, 13557 }, 13558 methods: { 13559 openRenameModal() { 13560 this.mainAction(); 13561 }, 13562 hideActions() { 13563 this.closingAction(); 13564 }, 13565 focused(bool) { 13566 this.onFocused(bool); 13567 }, 13568 editItem() { 13569 this.mainAction(); 13570 }, 13571 }, 13572 }; 13573 13574 const _hoisted_1$1 = ["aria-label", "title"]; 13575 13576 function render$1(_ctx, _cache, $props, $setup, $data, $options) { 13577 return (openBlock(), createElementBlock("button", { 13578 type: "button", 13579 class: "action-edit", 13580 "aria-label": _ctx.translate('COM_MEDIA_ACTION_EDIT'), 13581 title: _ctx.translate('COM_MEDIA_ACTION_EDIT'), 13582 onKeyup: [ 13583 _cache[1] || (_cache[1] = withKeys($event => ($options.editItem()), ["enter"])), 13584 _cache[2] || (_cache[2] = withKeys($event => ($options.editItem()), ["space"])), 13585 _cache[5] || (_cache[5] = withKeys($event => ($options.hideActions()), ["esc"])) 13586 ], 13587 onFocus: _cache[3] || (_cache[3] = $event => ($options.focused(true))), 13588 onBlur: _cache[4] || (_cache[4] = $event => ($options.focused(false))) 13589 }, [ 13590 createBaseVNode("span", { 13591 class: "image-browser-action icon-pencil-alt", 13592 "aria-hidden": "true", 13593 onClick: _cache[0] || (_cache[0] = withModifiers($event => ($options.editItem()), ["stop"])) 13594 }) 13595 ], 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1$1)) 13596 } 13597 13598 script$1.render = render$1; 13599 script$1.__file = "administrator/components/com_media/resources/scripts/components/browser/actionItems/edit.vue"; 13600 13601 var script = { 13602 name: 'MediaBrowserActionItemsContainer', 13603 props: { 13604 item: { type: Object, default: () => {} }, 13605 edit: { type: Function, default: () => {} }, 13606 previewable: { type: Boolean, default: false }, 13607 downloadable: { type: Boolean, default: false }, 13608 shareable: { type: Boolean, default: false }, 13609 }, 13610 emits: ['toggle-settings'], 13611 data() { 13612 return { 13613 showActions: false, 13614 }; 13615 }, 13616 computed: { 13617 canEdit() { 13618 return api.canEdit && (typeof this.item.canEdit !== 'undefined' ? this.item.canEdit : true); 13619 }, 13620 canDelete() { 13621 return api.canDelete && (typeof this.item.canDelete !== 'undefined' ? this.item.canDelete : true); 13622 }, 13623 canOpenEditView() { 13624 return ['jpg', 'jpeg', 'png'].includes(this.item.extension.toLowerCase()); 13625 }, 13626 }, 13627 watch: { 13628 // eslint-disable-next-line 13629 "$store.state.showRenameModal"(show) { 13630 if ( 13631 !show 13632 && this.$refs.actionToggle 13633 && this.$store.state.selectedItems.find( 13634 (item) => item.name === this.item.name, 13635 ) !== undefined 13636 ) { 13637 this.$refs.actionToggle.$el.focus(); 13638 } 13639 }, 13640 }, 13641 methods: { 13642 /* Hide actions dropdown */ 13643 hideActions() { 13644 this.showActions = false; 13645 }, 13646 /* Preview an item */ 13647 openPreview() { 13648 this.$store.commit(SHOW_PREVIEW_MODAL); 13649 this.$store.dispatch('getFullContents', this.item); 13650 }, 13651 /* Download an item */ 13652 download() { 13653 this.$store.dispatch('download', this.item); 13654 }, 13655 /* Opening confirm delete modal */ 13656 openConfirmDeleteModal() { 13657 this.$store.commit(UNSELECT_ALL_BROWSER_ITEMS); 13658 this.$store.commit(SELECT_BROWSER_ITEM, this.item); 13659 this.$store.commit(SHOW_CONFIRM_DELETE_MODAL); 13660 }, 13661 /* Rename an item */ 13662 openRenameModal() { 13663 this.hideActions(); 13664 this.$store.commit(SELECT_BROWSER_ITEM, this.item); 13665 this.$store.commit(SHOW_RENAME_MODAL); 13666 }, 13667 /* Open modal for share url */ 13668 openShareUrlModal() { 13669 this.$store.commit(SELECT_BROWSER_ITEM, this.item); 13670 this.$store.commit(SHOW_SHARE_MODAL); 13671 }, 13672 /* Open actions dropdown */ 13673 openActions() { 13674 this.showActions = true; 13675 const buttons = [...this.$el.parentElement.querySelectorAll('.media-browser-actions-list button')]; 13676 if (buttons.length) { 13677 buttons[0].focus(); 13678 } 13679 }, 13680 /* Open actions dropdown and focus on last element */ 13681 openLastActions() { 13682 this.showActions = true; 13683 const buttons = [...this.$el.parentElement.querySelectorAll('.media-browser-actions-list button')]; 13684 if (buttons.length) { 13685 this.$nextTick(() => buttons[buttons.length - 1].focus()); 13686 } 13687 }, 13688 editItem() { 13689 this.edit(); 13690 }, 13691 focused(bool) { 13692 this.$emit('toggle-settings', bool); 13693 }, 13694 }, 13695 }; 13696 13697 const _hoisted_1 = ["aria-label", "title"]; 13698 const _hoisted_2 = { 13699 key: 0, 13700 class: "media-browser-actions-list" 13701 }; 13702 13703 function render(_ctx, _cache, $props, $setup, $data, $options) { 13704 const _component_media_browser_action_item_toggle = resolveComponent("media-browser-action-item-toggle"); 13705 const _component_media_browser_action_item_preview = resolveComponent("media-browser-action-item-preview"); 13706 const _component_media_browser_action_item_download = resolveComponent("media-browser-action-item-download"); 13707 const _component_media_browser_action_item_rename = resolveComponent("media-browser-action-item-rename"); 13708 const _component_media_browser_action_item_edit = resolveComponent("media-browser-action-item-edit"); 13709 const _component_media_browser_action_item_share = resolveComponent("media-browser-action-item-share"); 13710 const _component_media_browser_action_item_delete = resolveComponent("media-browser-action-item-delete"); 13711 13712 return (openBlock(), createElementBlock(Fragment, null, [ 13713 createBaseVNode("span", { 13714 class: "media-browser-select", 13715 "aria-label": _ctx.translate('COM_MEDIA_TOGGLE_SELECT_ITEM'), 13716 title: _ctx.translate('COM_MEDIA_TOGGLE_SELECT_ITEM'), 13717 tabindex: "0", 13718 onFocusin: _cache[0] || (_cache[0] = $event => ($options.focused(true))), 13719 onFocusout: _cache[1] || (_cache[1] = $event => ($options.focused(false))) 13720 }, null, 40 /* PROPS, HYDRATE_EVENTS */, _hoisted_1), 13721 createBaseVNode("div", { 13722 class: normalizeClass(["media-browser-actions", { active: $data.showActions }]) 13723 }, [ 13724 createVNode(_component_media_browser_action_item_toggle, { 13725 ref: "actionToggle", 13726 "main-action": $options.openActions, 13727 onOnFocused: $options.focused, 13728 onKeyup: [ 13729 _cache[2] || (_cache[2] = withKeys($event => ($options.openLastActions()), ["up"])), 13730 _cache[3] || (_cache[3] = withKeys($event => ($options.openActions()), ["down"])) 13731 ] 13732 }, null, 8 /* PROPS */, ["main-action", "onOnFocused"]), 13733 ($data.showActions) 13734 ? (openBlock(), createElementBlock("div", _hoisted_2, [ 13735 createBaseVNode("ul", null, [ 13736 createBaseVNode("li", null, [ 13737 ($props.previewable) 13738 ? (openBlock(), createBlock(_component_media_browser_action_item_preview, { 13739 key: 0, 13740 ref: "actionPreview", 13741 "on-focused": $options.focused, 13742 "main-action": $options.openPreview, 13743 "closing-action": $options.hideActions, 13744 onKeyup: [ 13745 _cache[4] || (_cache[4] = withKeys($event => (_ctx.$refs.actionDelete.$el.focus()), ["up"])), 13746 _cache[5] || (_cache[5] = withKeys($event => (_ctx.$refs.actionDelete.$el.previousElementSibling.focus()), ["down"])), 13747 withKeys($options.hideActions, ["esc"]) 13748 ] 13749 }, null, 8 /* PROPS */, ["on-focused", "main-action", "closing-action", "onKeyup"])) 13750 : createCommentVNode("v-if", true) 13751 ]), 13752 createBaseVNode("li", null, [ 13753 ($props.downloadable) 13754 ? (openBlock(), createBlock(_component_media_browser_action_item_download, { 13755 key: 0, 13756 ref: "actionDownload", 13757 "on-focused": $options.focused, 13758 "main-action": $options.download, 13759 "closing-action": $options.hideActions, 13760 onKeyup: [ 13761 _cache[6] || (_cache[6] = withKeys($event => (_ctx.$refs.actionPreview.$el.focus()), ["up"])), 13762 _cache[7] || (_cache[7] = withKeys($event => (_ctx.$refs.actionPreview.$el.previousElementSibling.focus()), ["down"])), 13763 withKeys($options.hideActions, ["esc"]) 13764 ] 13765 }, null, 8 /* PROPS */, ["on-focused", "main-action", "closing-action", "onKeyup"])) 13766 : createCommentVNode("v-if", true) 13767 ]), 13768 createBaseVNode("li", null, [ 13769 ($options.canEdit) 13770 ? (openBlock(), createBlock(_component_media_browser_action_item_rename, { 13771 key: 0, 13772 ref: "actionRename", 13773 "on-focused": $options.focused, 13774 "main-action": $options.openRenameModal, 13775 "closing-action": $options.hideActions, 13776 onKeyup: [ 13777 _cache[8] || (_cache[8] = withKeys($event => ( 13778 $props.downloadable 13779 ? _ctx.$refs.actionDownload.$el.focus() 13780 : _ctx.$refs.actionDownload.$el.previousElementSibling.focus() 13781 ), ["up"])), 13782 _cache[9] || (_cache[9] = withKeys($event => ( 13783 $options.canEdit 13784 ? _ctx.$refs.actionEdit.$el.focus() 13785 : $props.shareable 13786 ? _ctx.$refs.actionShare.$el.focus() 13787 : _ctx.$refs.actionShare.$el.previousElementSibling.focus() 13788 ), ["down"])), 13789 withKeys($options.hideActions, ["esc"]) 13790 ] 13791 }, null, 8 /* PROPS */, ["on-focused", "main-action", "closing-action", "onKeyup"])) 13792 : createCommentVNode("v-if", true) 13793 ]), 13794 createBaseVNode("li", null, [ 13795 ($options.canEdit && $options.canOpenEditView) 13796 ? (openBlock(), createBlock(_component_media_browser_action_item_edit, { 13797 key: 0, 13798 ref: "actionEdit", 13799 "on-focused": $options.focused, 13800 "main-action": $options.editItem, 13801 "closing-action": $options.hideActions, 13802 onKeyup: [ 13803 _cache[10] || (_cache[10] = withKeys($event => (_ctx.$refs.actionRename.$el.focus()), ["up"])), 13804 _cache[11] || (_cache[11] = withKeys($event => (_ctx.$refs.actionRename.$el.previousElementSibling.focus()), ["down"])), 13805 withKeys($options.hideActions, ["esc"]) 13806 ] 13807 }, null, 8 /* PROPS */, ["on-focused", "main-action", "closing-action", "onKeyup"])) 13808 : createCommentVNode("v-if", true) 13809 ]), 13810 createBaseVNode("li", null, [ 13811 ($props.shareable) 13812 ? (openBlock(), createBlock(_component_media_browser_action_item_share, { 13813 key: 0, 13814 ref: "actionShare", 13815 "on-focused": $options.focused, 13816 "main-action": $options.openShareUrlModal, 13817 "closing-action": $options.hideActions, 13818 onKeyup: [ 13819 _cache[12] || (_cache[12] = withKeys($event => ( 13820 $options.canEdit 13821 ? _ctx.$refs.actionEdit.$el.focus() 13822 : _ctx.$refs.actionEdit.$el.previousElementSibling.focus() 13823 ), ["up"])), 13824 _cache[13] || (_cache[13] = withKeys($event => (_ctx.$refs.actionDelete.$el.focus()), ["down"])), 13825 withKeys($options.hideActions, ["esc"]) 13826 ] 13827 }, null, 8 /* PROPS */, ["on-focused", "main-action", "closing-action", "onKeyup"])) 13828 : createCommentVNode("v-if", true) 13829 ]), 13830 createBaseVNode("li", null, [ 13831 ($options.canDelete) 13832 ? (openBlock(), createBlock(_component_media_browser_action_item_delete, { 13833 key: 0, 13834 ref: "actionDelete", 13835 "on-focused": $options.focused, 13836 "main-action": $options.openConfirmDeleteModal, 13837 "hide-actions": $options.hideActions, 13838 onKeyup: [ 13839 _cache[14] || (_cache[14] = withKeys($event => ( 13840 $props.shareable 13841 ? _ctx.$refs.actionShare.$el.focus() 13842 : _ctx.$refs.actionShare.$el.previousElementSibling.focus() 13843 ), ["up"])), 13844 _cache[15] || (_cache[15] = withKeys($event => ( 13845 $props.previewable 13846 ? _ctx.$refs.actionPreview.$el.focus() 13847 : _ctx.$refs.actionPreview.$el.previousElementSibling.focus() 13848 ), ["down"])), 13849 withKeys($options.hideActions, ["esc"]) 13850 ] 13851 }, null, 8 /* PROPS */, ["on-focused", "main-action", "hide-actions", "onKeyup"])) 13852 : createCommentVNode("v-if", true) 13853 ]) 13854 ]) 13855 ])) 13856 : createCommentVNode("v-if", true) 13857 ], 2 /* CLASS */) 13858 ], 64 /* STABLE_FRAGMENT */)) 13859 } 13860 13861 script.render = render; 13862 script.__file = "administrator/components/com_media/resources/scripts/components/browser/actionItems/actionItemsContainer.vue"; 13863 13864 window.MediaManager = window.MediaManager || {}; // Register the media manager event bus 13865 13866 window.MediaManager.Event = new Event(); // Create the Vue app instance 13867 13868 const app = createApp(script$t); 13869 app.use(store); 13870 app.use(Translate); // Register the vue components 13871 13872 app.component('MediaDrive', script$r); 13873 app.component('MediaDisk', script$s); 13874 app.component('MediaTree', script$q); 13875 app.component('MediaToolbar', script$p); 13876 app.component('MediaBreadcrumb', script$o); 13877 app.component('MediaBrowser', script$n); 13878 app.component('MediaBrowserItem', BrowserItem); 13879 app.component('MediaBrowserItemRow', script$g); 13880 app.component('MediaModal', script$f); 13881 app.component('MediaCreateFolderModal', script$e); 13882 app.component('MediaPreviewModal', script$d); 13883 app.component('MediaRenameModal', script$c); 13884 app.component('MediaShareModal', script$b); 13885 app.component('MediaConfirmDeleteModal', script$a); 13886 app.component('MediaInfobar', script$9); 13887 app.component('MediaUpload', script$8); 13888 app.component('MediaBrowserActionItemToggle', script$6); 13889 app.component('MediaBrowserActionItemPreview', script$5); 13890 app.component('MediaBrowserActionItemDownload', script$4); 13891 app.component('MediaBrowserActionItemRename', script$7); 13892 app.component('MediaBrowserActionItemShare', script$3); 13893 app.component('MediaBrowserActionItemDelete', script$2); 13894 app.component('MediaBrowserActionItemEdit', script$1); 13895 app.component('MediaBrowserActionItemsContainer', script); 13896 app.mount('#com-media');
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |