appblocks
Version:
A lightweight javascript library for building micro apps for the front-end.
1,314 lines (1,225 loc) • 127 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.AppBlock = factory());
})(this, (function () { 'use strict';
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var check = function (it) {
return it && it.Math === Math && it;
};
var global_1 =
check(typeof globalThis == 'object' && globalThis) ||
check(typeof window == 'object' && window) ||
check(typeof self == 'object' && self) ||
check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
(function () { return this; })() || Function('return this')();
var fails = function (exec) {
try {
return !!exec();
} catch (error) {
return true;
}
};
var descriptors = !fails(function () {
return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
});
var functionBindNative = !fails(function () {
var test = (function () { }).bind();
return typeof test != 'function' || test.hasOwnProperty('prototype');
});
var call$2 = Function.prototype.call;
var functionCall = functionBindNative ? call$2.bind(call$2) : function () {
return call$2.apply(call$2, arguments);
};
var $propertyIsEnumerable = {}.propertyIsEnumerable;
var getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor;
var NASHORN_BUG = getOwnPropertyDescriptor$2 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
var f$6 = NASHORN_BUG ? function propertyIsEnumerable(V) {
var descriptor = getOwnPropertyDescriptor$2(this, V);
return !!descriptor && descriptor.enumerable;
} : $propertyIsEnumerable;
var objectPropertyIsEnumerable = {
f: f$6
};
var createPropertyDescriptor = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
var FunctionPrototype$3 = Function.prototype;
var call$1 = FunctionPrototype$3.call;
var uncurryThisWithBind = functionBindNative && FunctionPrototype$3.bind.bind(call$1, call$1);
var functionUncurryThis = functionBindNative ? uncurryThisWithBind : function (fn) {
return function () {
return call$1.apply(fn, arguments);
};
};
var toString$1 = functionUncurryThis({}.toString);
var stringSlice$5 = functionUncurryThis(''.slice);
var classofRaw = function (it) {
return stringSlice$5(toString$1(it), 8, -1);
};
var $Object$3 = Object;
var split = functionUncurryThis(''.split);
var indexedObject = fails(function () {
return !$Object$3('z').propertyIsEnumerable(0);
}) ? function (it) {
return classofRaw(it) === 'String' ? split(it, '') : $Object$3(it);
} : $Object$3;
var isNullOrUndefined = function (it) {
return it === null || it === undefined;
};
var $TypeError$f = TypeError;
var requireObjectCoercible = function (it) {
if (isNullOrUndefined(it)) throw new $TypeError$f("Can't call method on " + it);
return it;
};
var toIndexedObject = function (it) {
return indexedObject(requireObjectCoercible(it));
};
var documentAll = typeof document == 'object' && document.all;
var isCallable = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
return typeof argument == 'function' || argument === documentAll;
} : function (argument) {
return typeof argument == 'function';
};
var isObject = function (it) {
return typeof it == 'object' ? it !== null : isCallable(it);
};
var aFunction = function (argument) {
return isCallable(argument) ? argument : undefined;
};
var getBuiltIn = function (namespace, method) {
return arguments.length < 2 ? aFunction(global_1[namespace]) : global_1[namespace] && global_1[namespace][method];
};
var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf);
var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
var process$3 = global_1.process;
var Deno$1 = global_1.Deno;
var versions = process$3 && process$3.versions || Deno$1 && Deno$1.version;
var v8 = versions && versions.v8;
var match, version;
if (v8) {
match = v8.split('.');
version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
}
if (!version && engineUserAgent) {
match = engineUserAgent.match(/Edge\/(\d+)/);
if (!match || match[1] >= 74) {
match = engineUserAgent.match(/Chrome\/(\d+)/);
if (match) version = +match[1];
}
}
var engineV8Version = version;
var $String$4 = global_1.String;
var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails(function () {
var symbol = Symbol('symbol detection');
return !$String$4(symbol) || !(Object(symbol) instanceof Symbol) ||
!Symbol.sham && engineV8Version && engineV8Version < 41;
});
var useSymbolAsUid = symbolConstructorDetection
&& !Symbol.sham
&& typeof Symbol.iterator == 'symbol';
var $Object$2 = Object;
var isSymbol = useSymbolAsUid ? function (it) {
return typeof it == 'symbol';
} : function (it) {
var $Symbol = getBuiltIn('Symbol');
return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, $Object$2(it));
};
var $String$3 = String;
var tryToString = function (argument) {
try {
return $String$3(argument);
} catch (error) {
return 'Object';
}
};
var $TypeError$e = TypeError;
var aCallable = function (argument) {
if (isCallable(argument)) return argument;
throw new $TypeError$e(tryToString(argument) + ' is not a function');
};
var getMethod = function (V, P) {
var func = V[P];
return isNullOrUndefined(func) ? undefined : aCallable(func);
};
var $TypeError$d = TypeError;
var ordinaryToPrimitive = function (input, pref) {
var fn, val;
if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val;
if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val;
if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val;
throw new $TypeError$d("Can't convert object to primitive value");
};
var defineProperty$3 = Object.defineProperty;
var defineGlobalProperty = function (key, value) {
try {
defineProperty$3(global_1, key, { value: value, configurable: true, writable: true });
} catch (error) {
global_1[key] = value;
} return value;
};
var sharedStore = createCommonjsModule(function (module) {
var SHARED = '__core-js_shared__';
var store = module.exports = global_1[SHARED] || defineGlobalProperty(SHARED, {});
(store.versions || (store.versions = [])).push({
version: '3.36.0',
mode: 'global',
copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
license: 'https://github.com/zloirock/core-js/blob/v3.36.0/LICENSE',
source: 'https://github.com/zloirock/core-js'
});
});
var shared = function (key, value) {
return sharedStore[key] || (sharedStore[key] = value || {});
};
var $Object$1 = Object;
var toObject = function (argument) {
return $Object$1(requireObjectCoercible(argument));
};
var hasOwnProperty = functionUncurryThis({}.hasOwnProperty);
var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
return hasOwnProperty(toObject(it), key);
};
var id = 0;
var postfix = Math.random();
var toString = functionUncurryThis(1.0.toString);
var uid = function (key) {
return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
};
var Symbol$1 = global_1.Symbol;
var WellKnownSymbolsStore = shared('wks');
var createWellKnownSymbol = useSymbolAsUid ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
var wellKnownSymbol = function (name) {
if (!hasOwnProperty_1(WellKnownSymbolsStore, name)) {
WellKnownSymbolsStore[name] = symbolConstructorDetection && hasOwnProperty_1(Symbol$1, name)
? Symbol$1[name]
: createWellKnownSymbol('Symbol.' + name);
} return WellKnownSymbolsStore[name];
};
var $TypeError$c = TypeError;
var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
var toPrimitive = function (input, pref) {
if (!isObject(input) || isSymbol(input)) return input;
var exoticToPrim = getMethod(input, TO_PRIMITIVE);
var result;
if (exoticToPrim) {
if (pref === undefined) pref = 'default';
result = functionCall(exoticToPrim, input, pref);
if (!isObject(result) || isSymbol(result)) return result;
throw new $TypeError$c("Can't convert object to primitive value");
}
if (pref === undefined) pref = 'number';
return ordinaryToPrimitive(input, pref);
};
var toPropertyKey = function (argument) {
var key = toPrimitive(argument, 'string');
return isSymbol(key) ? key : key + '';
};
var document$3 = global_1.document;
var EXISTS$1 = isObject(document$3) && isObject(document$3.createElement);
var documentCreateElement = function (it) {
return EXISTS$1 ? document$3.createElement(it) : {};
};
var ie8DomDefine = !descriptors && !fails(function () {
return Object.defineProperty(documentCreateElement('div'), 'a', {
get: function () { return 7; }
}).a !== 7;
});
var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
var f$5 = descriptors ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
O = toIndexedObject(O);
P = toPropertyKey(P);
if (ie8DomDefine) try {
return $getOwnPropertyDescriptor$1(O, P);
} catch (error) { }
if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]);
};
var objectGetOwnPropertyDescriptor = {
f: f$5
};
var v8PrototypeDefineBug = descriptors && fails(function () {
return Object.defineProperty(function () { }, 'prototype', {
value: 42,
writable: false
}).prototype !== 42;
});
var $String$2 = String;
var $TypeError$b = TypeError;
var anObject = function (argument) {
if (isObject(argument)) return argument;
throw new $TypeError$b($String$2(argument) + ' is not an object');
};
var $TypeError$a = TypeError;
var $defineProperty = Object.defineProperty;
var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
var ENUMERABLE = 'enumerable';
var CONFIGURABLE$1 = 'configurable';
var WRITABLE = 'writable';
var f$4 = descriptors ? v8PrototypeDefineBug ? function defineProperty(O, P, Attributes) {
anObject(O);
P = toPropertyKey(P);
anObject(Attributes);
if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
var current = $getOwnPropertyDescriptor(O, P);
if (current && current[WRITABLE]) {
O[P] = Attributes.value;
Attributes = {
configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
writable: false
};
}
} return $defineProperty(O, P, Attributes);
} : $defineProperty : function defineProperty(O, P, Attributes) {
anObject(O);
P = toPropertyKey(P);
anObject(Attributes);
if (ie8DomDefine) try {
return $defineProperty(O, P, Attributes);
} catch (error) { }
if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$a('Accessors not supported');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
var objectDefineProperty = {
f: f$4
};
var createNonEnumerableProperty = descriptors ? function (object, key, value) {
return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
var FunctionPrototype$2 = Function.prototype;
var getDescriptor = descriptors && Object.getOwnPropertyDescriptor;
var EXISTS = hasOwnProperty_1(FunctionPrototype$2, 'name');
var PROPER = EXISTS && (function something() { }).name === 'something';
var CONFIGURABLE = EXISTS && (!descriptors || (descriptors && getDescriptor(FunctionPrototype$2, 'name').configurable));
var functionName = {
EXISTS: EXISTS,
PROPER: PROPER,
CONFIGURABLE: CONFIGURABLE
};
var functionToString$1 = functionUncurryThis(Function.toString);
if (!isCallable(sharedStore.inspectSource)) {
sharedStore.inspectSource = function (it) {
return functionToString$1(it);
};
}
var inspectSource = sharedStore.inspectSource;
var WeakMap$1 = global_1.WeakMap;
var weakMapBasicDetection = isCallable(WeakMap$1) && /native code/.test(String(WeakMap$1));
var keys = shared('keys');
var sharedKey = function (key) {
return keys[key] || (keys[key] = uid(key));
};
var hiddenKeys$1 = {};
var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
var TypeError$2 = global_1.TypeError;
var WeakMap = global_1.WeakMap;
var set$1, get, has;
var enforce = function (it) {
return has(it) ? get(it) : set$1(it, {});
};
var getterFor = function (TYPE) {
return function (it) {
var state;
if (!isObject(it) || (state = get(it)).type !== TYPE) {
throw new TypeError$2('Incompatible receiver, ' + TYPE + ' required');
} return state;
};
};
if (weakMapBasicDetection || sharedStore.state) {
var store = sharedStore.state || (sharedStore.state = new WeakMap());
store.get = store.get;
store.has = store.has;
store.set = store.set;
set$1 = function (it, metadata) {
if (store.has(it)) throw new TypeError$2(OBJECT_ALREADY_INITIALIZED);
metadata.facade = it;
store.set(it, metadata);
return metadata;
};
get = function (it) {
return store.get(it) || {};
};
has = function (it) {
return store.has(it);
};
} else {
var STATE = sharedKey('state');
hiddenKeys$1[STATE] = true;
set$1 = function (it, metadata) {
if (hasOwnProperty_1(it, STATE)) throw new TypeError$2(OBJECT_ALREADY_INITIALIZED);
metadata.facade = it;
createNonEnumerableProperty(it, STATE, metadata);
return metadata;
};
get = function (it) {
return hasOwnProperty_1(it, STATE) ? it[STATE] : {};
};
has = function (it) {
return hasOwnProperty_1(it, STATE);
};
}
var internalState = {
set: set$1,
get: get,
has: has,
enforce: enforce,
getterFor: getterFor
};
var makeBuiltIn_1 = createCommonjsModule(function (module) {
var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
var enforceInternalState = internalState.enforce;
var getInternalState = internalState.get;
var $String = String;
var defineProperty = Object.defineProperty;
var stringSlice = functionUncurryThis(''.slice);
var replace = functionUncurryThis(''.replace);
var join = functionUncurryThis([].join);
var CONFIGURABLE_LENGTH = descriptors && !fails(function () {
return defineProperty(function () { }, 'length', { value: 8 }).length !== 8;
});
var TEMPLATE = String(String).split('String');
var makeBuiltIn = module.exports = function (value, name, options) {
if (stringSlice($String(name), 0, 7) === 'Symbol(') {
name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
}
if (options && options.getter) name = 'get ' + name;
if (options && options.setter) name = 'set ' + name;
if (!hasOwnProperty_1(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
if (descriptors) defineProperty(value, 'name', { value: name, configurable: true });
else value.name = name;
}
if (CONFIGURABLE_LENGTH && options && hasOwnProperty_1(options, 'arity') && value.length !== options.arity) {
defineProperty(value, 'length', { value: options.arity });
}
try {
if (options && hasOwnProperty_1(options, 'constructor') && options.constructor) {
if (descriptors) defineProperty(value, 'prototype', { writable: false });
} else if (value.prototype) value.prototype = undefined;
} catch (error) { }
var state = enforceInternalState(value);
if (!hasOwnProperty_1(state, 'source')) {
state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
} return value;
};
Function.prototype.toString = makeBuiltIn(function toString() {
return isCallable(this) && getInternalState(this).source || inspectSource(this);
}, 'toString');
});
var defineBuiltIn = function (O, key, value, options) {
if (!options) options = {};
var simple = options.enumerable;
var name = options.name !== undefined ? options.name : key;
if (isCallable(value)) makeBuiltIn_1(value, name, options);
if (options.global) {
if (simple) O[key] = value;
else defineGlobalProperty(key, value);
} else {
try {
if (!options.unsafe) delete O[key];
else if (O[key]) simple = true;
} catch (error) { }
if (simple) O[key] = value;
else objectDefineProperty.f(O, key, {
value: value,
enumerable: false,
configurable: !options.nonConfigurable,
writable: !options.nonWritable
});
} return O;
};
var ceil = Math.ceil;
var floor$1 = Math.floor;
var mathTrunc = Math.trunc || function trunc(x) {
var n = +x;
return (n > 0 ? floor$1 : ceil)(n);
};
var toIntegerOrInfinity = function (argument) {
var number = +argument;
return number !== number || number === 0 ? 0 : mathTrunc(number);
};
var max$2 = Math.max;
var min$3 = Math.min;
var toAbsoluteIndex = function (index, length) {
var integer = toIntegerOrInfinity(index);
return integer < 0 ? max$2(integer + length, 0) : min$3(integer, length);
};
var min$2 = Math.min;
var toLength = function (argument) {
var len = toIntegerOrInfinity(argument);
return len > 0 ? min$2(len, 0x1FFFFFFFFFFFFF) : 0;
};
var lengthOfArrayLike = function (obj) {
return toLength(obj.length);
};
var createMethod$2 = function (IS_INCLUDES) {
return function ($this, el, fromIndex) {
var O = toIndexedObject($this);
var length = lengthOfArrayLike(O);
if (length === 0) return !IS_INCLUDES && -1;
var index = toAbsoluteIndex(fromIndex, length);
var value;
if (IS_INCLUDES && el !== el) while (length > index) {
value = O[index++];
if (value !== value) return true;
} else for (;length > index; index++) {
if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
} return !IS_INCLUDES && -1;
};
};
var arrayIncludes = {
includes: createMethod$2(true),
indexOf: createMethod$2(false)
};
var indexOf$1 = arrayIncludes.indexOf;
var push$3 = functionUncurryThis([].push);
var objectKeysInternal = function (object, names) {
var O = toIndexedObject(object);
var i = 0;
var result = [];
var key;
for (key in O) !hasOwnProperty_1(hiddenKeys$1, key) && hasOwnProperty_1(O, key) && push$3(result, key);
while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) {
~indexOf$1(result, key) || push$3(result, key);
}
return result;
};
var enumBugKeys = [
'constructor',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'toLocaleString',
'toString',
'valueOf'
];
var hiddenKeys = enumBugKeys.concat('length', 'prototype');
var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
return objectKeysInternal(O, hiddenKeys);
};
var objectGetOwnPropertyNames = {
f: f$3
};
var f$2 = Object.getOwnPropertySymbols;
var objectGetOwnPropertySymbols = {
f: f$2
};
var concat$2 = functionUncurryThis([].concat);
var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
var keys = objectGetOwnPropertyNames.f(anObject(it));
var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
return getOwnPropertySymbols ? concat$2(keys, getOwnPropertySymbols(it)) : keys;
};
var copyConstructorProperties = function (target, source, exceptions) {
var keys = ownKeys(source);
var defineProperty = objectDefineProperty.f;
var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (!hasOwnProperty_1(target, key) && !(exceptions && hasOwnProperty_1(exceptions, key))) {
defineProperty(target, key, getOwnPropertyDescriptor(source, key));
}
}
};
var replacement = /#|\.prototype\./;
var isForced = function (feature, detection) {
var value = data[normalize(feature)];
return value === POLYFILL ? true
: value === NATIVE ? false
: isCallable(detection) ? fails(detection)
: !!detection;
};
var normalize = isForced.normalize = function (string) {
return String(string).replace(replacement, '.').toLowerCase();
};
var data = isForced.data = {};
var NATIVE = isForced.NATIVE = 'N';
var POLYFILL = isForced.POLYFILL = 'P';
var isForced_1 = isForced;
var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
var _export = function (options, source) {
var TARGET = options.target;
var GLOBAL = options.global;
var STATIC = options.stat;
var FORCED, target, key, targetProperty, sourceProperty, descriptor;
if (GLOBAL) {
target = global_1;
} else if (STATIC) {
target = global_1[TARGET] || defineGlobalProperty(TARGET, {});
} else {
target = global_1[TARGET] && global_1[TARGET].prototype;
}
if (target) for (key in source) {
sourceProperty = source[key];
if (options.dontCallGetSet) {
descriptor = getOwnPropertyDescriptor$1(target, key);
targetProperty = descriptor && descriptor.value;
} else targetProperty = target[key];
FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
if (!FORCED && targetProperty !== undefined) {
if (typeof sourceProperty == typeof targetProperty) continue;
copyConstructorProperties(sourceProperty, targetProperty);
}
if (options.sham || (targetProperty && targetProperty.sham)) {
createNonEnumerableProperty(sourceProperty, 'sham', true);
}
defineBuiltIn(target, key, sourceProperty, options);
}
};
var functionUncurryThisClause = function (fn) {
if (classofRaw(fn) === 'Function') return functionUncurryThis(fn);
};
var bind$1 = functionUncurryThisClause(functionUncurryThisClause.bind);
var functionBindContext = function (fn, that) {
aCallable(fn);
return that === undefined ? fn : functionBindNative ? bind$1(fn, that) : function () {
return fn.apply(that, arguments);
};
};
var isArray = Array.isArray || function isArray(argument) {
return classofRaw(argument) === 'Array';
};
var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag');
var test = {};
test[TO_STRING_TAG$2] = 'z';
var toStringTagSupport = String(test) === '[object z]';
var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
var $Object = Object;
var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
var tryGet = function (it, key) {
try {
return it[key];
} catch (error) { }
};
var classof = toStringTagSupport ? classofRaw : function (it) {
var O, tag, result;
return it === undefined ? 'Undefined' : it === null ? 'Null'
: typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG$1)) == 'string' ? tag
: CORRECT_ARGUMENTS ? classofRaw(O)
: (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
};
var noop = function () { };
var construct = getBuiltIn('Reflect', 'construct');
var constructorRegExp = /^\s*(?:class|function)\b/;
var exec = functionUncurryThis(constructorRegExp.exec);
var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
var isConstructorModern = function isConstructor(argument) {
if (!isCallable(argument)) return false;
try {
construct(noop, [], argument);
return true;
} catch (error) {
return false;
}
};
var isConstructorLegacy = function isConstructor(argument) {
if (!isCallable(argument)) return false;
switch (classof(argument)) {
case 'AsyncFunction':
case 'GeneratorFunction':
case 'AsyncGeneratorFunction': return false;
}
try {
return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
} catch (error) {
return true;
}
};
isConstructorLegacy.sham = true;
var isConstructor = !construct || fails(function () {
var called;
return isConstructorModern(isConstructorModern.call)
|| !isConstructorModern(Object)
|| !isConstructorModern(function () { called = true; })
|| called;
}) ? isConstructorLegacy : isConstructorModern;
var SPECIES$6 = wellKnownSymbol('species');
var $Array$1 = Array;
var arraySpeciesConstructor = function (originalArray) {
var C;
if (isArray(originalArray)) {
C = originalArray.constructor;
if (isConstructor(C) && (C === $Array$1 || isArray(C.prototype))) C = undefined;
else if (isObject(C)) {
C = C[SPECIES$6];
if (C === null) C = undefined;
}
} return C === undefined ? $Array$1 : C;
};
var arraySpeciesCreate = function (originalArray, length) {
return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
};
var push$2 = functionUncurryThis([].push);
var createMethod$1 = function (TYPE) {
var IS_MAP = TYPE === 1;
var IS_FILTER = TYPE === 2;
var IS_SOME = TYPE === 3;
var IS_EVERY = TYPE === 4;
var IS_FIND_INDEX = TYPE === 6;
var IS_FILTER_REJECT = TYPE === 7;
var NO_HOLES = TYPE === 5 || IS_FIND_INDEX;
return function ($this, callbackfn, that, specificCreate) {
var O = toObject($this);
var self = indexedObject(O);
var length = lengthOfArrayLike(self);
var boundFunction = functionBindContext(callbackfn, that);
var index = 0;
var create = specificCreate || arraySpeciesCreate;
var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined;
var value, result;
for (;length > index; index++) if (NO_HOLES || index in self) {
value = self[index];
result = boundFunction(value, index, O);
if (TYPE) {
if (IS_MAP) target[index] = result;
else if (result) switch (TYPE) {
case 3: return true;
case 5: return value;
case 6: return index;
case 2: push$2(target, value);
} else switch (TYPE) {
case 4: return false;
case 7: push$2(target, value);
}
}
}
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
};
};
var arrayIteration = {
forEach: createMethod$1(0),
map: createMethod$1(1),
filter: createMethod$1(2),
some: createMethod$1(3),
every: createMethod$1(4),
find: createMethod$1(5),
findIndex: createMethod$1(6),
filterReject: createMethod$1(7)
};
var arrayMethodIsStrict = function (METHOD_NAME, argument) {
var method = [][METHOD_NAME];
return !!method && fails(function () {
method.call(null, argument || function () { return 1; }, 1);
});
};
var $forEach = arrayIteration.forEach;
var STRICT_METHOD = arrayMethodIsStrict('forEach');
var arrayForEach = !STRICT_METHOD ? function forEach(callbackfn ) {
return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
} : [].forEach;
_export({ target: 'Array', proto: true, forced: [].forEach !== arrayForEach }, {
forEach: arrayForEach
});
var defineBuiltInAccessor = function (target, name, descriptor) {
if (descriptor.get) makeBuiltIn_1(descriptor.get, name, { getter: true });
if (descriptor.set) makeBuiltIn_1(descriptor.set, name, { setter: true });
return objectDefineProperty.f(target, name, descriptor);
};
var FUNCTION_NAME_EXISTS = functionName.EXISTS;
var FunctionPrototype$1 = Function.prototype;
var functionToString = functionUncurryThis(FunctionPrototype$1.toString);
var nameRE = /function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/;
var regExpExec = functionUncurryThis(nameRE.exec);
var NAME = 'name';
if (descriptors && !FUNCTION_NAME_EXISTS) {
defineBuiltInAccessor(FunctionPrototype$1, NAME, {
configurable: true,
get: function () {
try {
return regExpExec(nameRE, functionToString(this))[1];
} catch (error) {
return '';
}
}
});
}
var objectKeys = Object.keys || function keys(O) {
return objectKeysInternal(O, enumBugKeys);
};
var $assign = Object.assign;
var defineProperty$2 = Object.defineProperty;
var concat$1 = functionUncurryThis([].concat);
var objectAssign = !$assign || fails(function () {
if (descriptors && $assign({ b: 1 }, $assign(defineProperty$2({}, 'a', {
enumerable: true,
get: function () {
defineProperty$2(this, 'b', {
value: 3,
enumerable: false
});
}
}), { b: 2 })).b !== 1) return true;
var A = {};
var B = {};
var symbol = Symbol('assign detection');
var alphabet = 'abcdefghijklmnopqrst';
A[symbol] = 7;
alphabet.split('').forEach(function (chr) { B[chr] = chr; });
return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet;
}) ? function assign(target, source) {
var T = toObject(target);
var argumentsLength = arguments.length;
var index = 1;
var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
var propertyIsEnumerable = objectPropertyIsEnumerable.f;
while (argumentsLength > index) {
var S = indexedObject(arguments[index++]);
var keys = getOwnPropertySymbols ? concat$1(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
var length = keys.length;
var j = 0;
var key;
while (length > j) {
key = keys[j++];
if (!descriptors || functionCall(propertyIsEnumerable, S, key)) T[key] = S[key];
}
} return T;
} : $assign;
_export({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== objectAssign }, {
assign: objectAssign
});
var objectToString = toStringTagSupport ? {}.toString : function toString() {
return '[object ' + classof(this) + ']';
};
if (!toStringTagSupport) {
defineBuiltIn(Object.prototype, 'toString', objectToString, { unsafe: true });
}
var domIterables = {
CSSRuleList: 0,
CSSStyleDeclaration: 0,
CSSValueList: 0,
ClientRectList: 0,
DOMRectList: 0,
DOMStringList: 0,
DOMTokenList: 1,
DataTransferItemList: 0,
FileList: 0,
HTMLAllCollection: 0,
HTMLCollection: 0,
HTMLFormElement: 0,
HTMLSelectElement: 0,
MediaList: 0,
MimeTypeArray: 0,
NamedNodeMap: 0,
NodeList: 1,
PaintRequestList: 0,
Plugin: 0,
PluginArray: 0,
SVGLengthList: 0,
SVGNumberList: 0,
SVGPathSegList: 0,
SVGPointList: 0,
SVGStringList: 0,
SVGTransformList: 0,
SourceBufferList: 0,
StyleSheetList: 0,
TextTrackCueList: 0,
TextTrackList: 0,
TouchList: 0
};
var classList = documentCreateElement('span').classList;
var DOMTokenListPrototype = classList && classList.constructor && classList.constructor.prototype;
var domTokenListPrototype = DOMTokenListPrototype === Object.prototype ? undefined : DOMTokenListPrototype;
var handlePrototype = function (CollectionPrototype) {
if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
createNonEnumerableProperty(CollectionPrototype, 'forEach', arrayForEach);
} catch (error) {
CollectionPrototype.forEach = arrayForEach;
}
};
for (var COLLECTION_NAME in domIterables) {
if (domIterables[COLLECTION_NAME]) {
handlePrototype(global_1[COLLECTION_NAME] && global_1[COLLECTION_NAME].prototype);
}
}
handlePrototype(domTokenListPrototype);
var Idiomorph = (function () {
let EMPTY_SET = new Set();
let defaults = {
morphStyle: "outerHTML",
callbacks : {
beforeNodeAdded: noOp,
afterNodeAdded: noOp,
beforeNodeMorphed: noOp,
afterNodeMorphed: noOp,
beforeNodeRemoved: noOp,
afterNodeRemoved: noOp,
beforeAttributeUpdated: noOp,
},
head: {
style: 'merge',
shouldPreserve: function (elt) {
return elt.getAttribute("im-preserve") === "true";
},
shouldReAppend: function (elt) {
return elt.getAttribute("im-re-append") === "true";
},
shouldRemove: noOp,
afterHeadMorphed: noOp,
}
};
function morph(oldNode, newContent, config = {}) {
if (oldNode instanceof Document) {
oldNode = oldNode.documentElement;
}
if (typeof newContent === 'string') {
newContent = parseContent(newContent);
}
let normalizedContent = normalizeContent(newContent);
let ctx = createMorphContext(oldNode, normalizedContent, config);
return morphNormalizedContent(oldNode, normalizedContent, ctx);
}
function morphNormalizedContent(oldNode, normalizedNewContent, ctx) {
if (ctx.head.block) {
let oldHead = oldNode.querySelector('head');
let newHead = normalizedNewContent.querySelector('head');
if (oldHead && newHead) {
let promises = handleHeadElement(newHead, oldHead, ctx);
Promise.all(promises).then(function () {
morphNormalizedContent(oldNode, normalizedNewContent, Object.assign(ctx, {
head: {
block: false,
ignore: true
}
}));
});
return;
}
}
if (ctx.morphStyle === "innerHTML") {
morphChildren(normalizedNewContent, oldNode, ctx);
return oldNode.children;
} else if (ctx.morphStyle === "outerHTML" || ctx.morphStyle == null) {
let bestMatch = findBestNodeMatch(normalizedNewContent, oldNode, ctx);
let previousSibling = bestMatch?.previousSibling;
let nextSibling = bestMatch?.nextSibling;
let morphedNode = morphOldNodeTo(oldNode, bestMatch, ctx);
if (bestMatch) {
return insertSiblings(previousSibling, morphedNode, nextSibling);
} else {
return []
}
} else {
throw "Do not understand how to morph style " + ctx.morphStyle;
}
}
function ignoreValueOfActiveElement(possibleActiveElement, ctx) {
return ctx.ignoreActiveValue && possibleActiveElement === document.activeElement;
}
function morphOldNodeTo(oldNode, newContent, ctx) {
if (ctx.ignoreActive && oldNode === document.activeElement) ; else if (newContent == null) {
if (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;
oldNode.remove();
ctx.callbacks.afterNodeRemoved(oldNode);
return null;
} else if (!isSoftMatch(oldNode, newContent)) {
if (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;
if (ctx.callbacks.beforeNodeAdded(newContent) === false) return oldNode;
oldNode.parentElement.replaceChild(newContent, oldNode);
ctx.callbacks.afterNodeAdded(newContent);
ctx.callbacks.afterNodeRemoved(oldNode);
return newContent;
} else {
if (ctx.callbacks.beforeNodeMorphed(oldNode, newContent) === false) return oldNode;
if (oldNode instanceof HTMLHeadElement && ctx.head.ignore) ; else if (oldNode instanceof HTMLHeadElement && ctx.head.style !== "morph") {
handleHeadElement(newContent, oldNode, ctx);
} else {
syncNodeFrom(newContent, oldNode, ctx);
if (!ignoreValueOfActiveElement(oldNode, ctx)) {
morphChildren(newContent, oldNode, ctx);
}
}
ctx.callbacks.afterNodeMorphed(oldNode, newContent);
return oldNode;
}
}
function morphChildren(newParent, oldParent, ctx) {
let nextNewChild = newParent.firstChild;
let insertionPoint = oldParent.firstChild;
let newChild;
while (nextNewChild) {
newChild = nextNewChild;
nextNewChild = newChild.nextSibling;
if (insertionPoint == null) {
if (ctx.callbacks.beforeNodeAdded(newChild) === false) return;
oldParent.appendChild(newChild);
ctx.callbacks.afterNodeAdded(newChild);
removeIdsFromConsideration(ctx, newChild);
continue;
}
if (isIdSetMatch(newChild, insertionPoint, ctx)) {
morphOldNodeTo(insertionPoint, newChild, ctx);
insertionPoint = insertionPoint.nextSibling;
removeIdsFromConsideration(ctx, newChild);
continue;
}
let idSetMatch = findIdSetMatch(newParent, oldParent, newChild, insertionPoint, ctx);
if (idSetMatch) {
insertionPoint = removeNodesBetween(insertionPoint, idSetMatch, ctx);
morphOldNodeTo(idSetMatch, newChild, ctx);
removeIdsFromConsideration(ctx, newChild);
continue;
}
let softMatch = findSoftMatch(newParent, oldParent, newChild, insertionPoint, ctx);
if (softMatch) {
insertionPoint = removeNodesBetween(insertionPoint, softMatch, ctx);
morphOldNodeTo(softMatch, newChild, ctx);
removeIdsFromConsideration(ctx, newChild);
continue;
}
if (ctx.callbacks.beforeNodeAdded(newChild) === false) return;
oldParent.insertBefore(newChild, insertionPoint);
ctx.callbacks.afterNodeAdded(newChild);
removeIdsFromConsideration(ctx, newChild);
}
while (insertionPoint !== null) {
let tempNode = insertionPoint;
insertionPoint = insertionPoint.nextSibling;
removeNode(tempNode, ctx);
}
}
function ignoreAttribute(attr, to, updateType, ctx) {
if(attr === 'value' && ctx.ignoreActiveValue && to === document.activeElement){
return true;
}
return ctx.callbacks.beforeAttributeUpdated(attr, to, updateType) === false;
}
function syncNodeFrom(from, to, ctx) {
let type = from.nodeType;
if (type === 1 ) {
const fromAttributes = from.attributes;
const toAttributes = to.attributes;
for (const fromAttribute of fromAttributes) {
if (ignoreAttribute(fromAttribute.name, to, 'update', ctx)) {
continue;
}
if (to.getAttribute(fromAttribute.name) !== fromAttribute.value) {
to.setAttribute(fromAttribute.name, fromAttribute.value);
}
}
for (let i = toAttributes.length - 1; 0 <= i; i--) {
const toAttribute = toAttributes[i];
if (ignoreAttribute(toAttribute.name, to, 'remove', ctx)) {
continue;
}
if (!from.hasAttribute(toAttribute.name)) {
to.removeAttribute(toAttribute.name);
}
}
}
if (type === 8 || type === 3 ) {
if (to.nodeValue !== from.nodeValue) {
to.nodeValue = from.nodeValue;
}
}
if (!ignoreValueOfActiveElement(to, ctx)) {
syncInputValue(from, to, ctx);
}
}
function syncBooleanAttribute(from, to, attributeName, ctx) {
if (from[attributeName] !== to[attributeName]) {
let ignoreUpdate = ignoreAttribute(attributeName, to, 'update', ctx);
if (!ignoreUpdate) {
to[attributeName] = from[attributeName];
}
if (from[attributeName]) {
if (!ignoreUpdate) {
to.setAttribute(attributeName, from[attributeName]);
}
} else {
if (!ignoreAttribute(attributeName, to, 'remove', ctx)) {
to.removeAttribute(attributeName);
}
}
}
}
function syncInputValue(from, to, ctx) {
if (from instanceof HTMLInputElement &&
to instanceof HTMLInputElement &&
from.type !== 'file') {
let fromValue = from.value;
let toValue = to.value;
syncBooleanAttribute(from, to, 'checked', ctx);
syncBooleanAttribute(from, to, 'disabled', ctx);
if (!from.hasAttribute('value')) {
if (!ignoreAttribute('value', to, 'remove', ctx)) {
to.value = '';
to.removeAttribute('value');
}
} else if (fromValue !== toValue) {
if (!ignoreAttribute('value', to, 'update', ctx)) {
to.setAttribute('value', fromValue);
to.value = fromValue;
}
}
} else if (from instanceof HTMLOptionElement) {
syncBooleanAttribute(from, to, 'selected', ctx);
} else if (from instanceof HTMLTextAreaElement && to instanceof HTMLTextAreaElement) {
let fromValue = from.value;
let toValue = to.value;
if (ignoreAttribute('value', to, 'update', ctx)) {
return;
}
if (fromValue !== toValue) {
to.value = fromValue;
}
if (to.firstChild && to.firstChild.nodeValue !== fromValue) {
to.firstChild.nodeValue = fromValue;
}
}
}
function handleHeadElement(newHeadTag, currentHead, ctx) {
let added = [];
let removed = [];
let preserved = [];
let nodesToAppend = [];
let headMergeStyle = ctx.head.style;
let srcToNewHeadNodes = new Map();
for (const newHeadChild of newHeadTag.children) {
srcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild);
}
for (const currentHeadElt of currentHead.children) {
let inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML);
let isReAppended = ctx.head.shouldReAppend(currentHeadElt);
let isPreserved = ctx.head.shouldPreserve(currentHeadElt);
if (inNewContent || isPreserved) {
if (isReAppended) {
removed.push(currentHeadElt);
} else {
srcToNewHeadNodes.delete(currentHeadElt.outerHTML);
preserved.push(currentHeadElt);
}
} else {
if (headMergeStyle === "append") {
if (isReAppended) {
removed.push(currentHeadElt);
nodesToAppend.push(currentHeadElt);
}
} else {
if (ctx.head.shouldRemove(currentHeadElt) !== false) {
removed.push(currentHeadElt);
}
}
}
}
nodesToAppend.push(...srcToNewHeadNodes.values());
let promises = [];
for (const newNode of nodesToAppend) {
let newElt = document.createRange().createContextualFragment(newNode.outerHTML).firstChild;
if (ctx.callbacks.beforeNodeAdded(newElt) !== false) {
if (newElt.href || newElt.src) {
let resolve = null;
let promise = new Promise(function (_resolve) {
resolve = _resolve;
});
newElt.addEventListener('load', function () {
resolve();
});
promises.push(promise);
}
currentHead.appendChild(newElt);
ctx.callbacks.afterNodeAdded(newElt);
added.push(newElt);
}
}
for (const removedElement of removed) {
if (ctx.callbacks.beforeNodeRemoved(removedElement) !== false) {
currentHead.removeChild(removedElement);
ctx.callbacks.afterNodeRemoved(removedElement);
}
}
ctx.head.afterHeadMorphed(currentHead, {added: added, kept: preserved, removed: removed});
return promises;
}
function noOp() {
}
function mergeDefaults(config) {
let finalConfig = {};
Object.assign(finalConfig, defaults);
Object.assign(finalConfig, config);
finalConfig.callbacks = {};
Object.assign(finalConfig.callbacks, defaults.callbacks);
Object.assign(finalConfig.callbacks, config.callbacks);
finalConfig.head = {};
Object.assign(finalConfig.head, defaults.head);
Object.assign(finalConfig.head, config.head);
return finalConfig;
}
function createMorphContext(oldNode, newContent, config) {
config = mergeDefaults(config);
return {
target: oldNode,
newContent: newContent,
config: config,
morphStyle: config.morphStyle,
ignoreActive: config.ignoreActive,
ignoreActiveValue: config.ignoreActiveValue,
idMap: createIdMap(oldNode, newContent),
deadIds: new Set(),
callbacks: config.callbacks,
head: config.head
}
}
function isIdSetMatch(node1, node2, ctx) {
if (node1 == null || node2 == null) {
return false;
}
if (node1.nodeType === node2.nodeType && node1.tagName === node2.tagName) {
if (node1.id !== "" && node1.id === node2.id) {
return true;
} else {
return getIdIntersectionCount(ctx, node1, node2) > 0;
}
}
return false;
}
function isSoftMatch(node1, node2) {
if (node1 == null || node2 == null) {
return false;
}
return node1.nodeType === node2.nodeType && node1.tagName === node2.tagName
}
function removeNodesBetween(startInclusive, endExclusive, ctx) {
while (startInclusive !== endExclusive) {
let tempNode = startInclusive;
startInclusive = startInclusive.nextSibling;
removeNode(tempNode, ctx);
}
removeIdsFromConsideration(ctx, endExclusive);
return endExclusive.nextSibling;
}
function findIdSetMatch(newContent, oldParent, newChild, insertionPoint, ctx) {
let newChildPotentialIdCount = getIdIntersectionCount(ctx, newChild, oldParent);
let potentialMatch = null;
if (newChildPotentialIdCount > 0) {
let potentialMatch = insertionPoint;
let otherMatchCount = 0;
while (potentialMatch != null) {
if (isIdSetMatch(newChild, potentialMatch, ctx)) {
return potentialMatch;
}
otherMatchCount += getIdIntersectionCount(ctx, potentialMatch, newContent);
if (otherMatchCount > newChildPotentialIdCount) {
return null;
}
potentialMatch = potentialMatch.nextSibling;
}
}
return potentialMatch;
}
function findSoftMatch(newContent, oldParent, newChild, insertionPoint, ctx) {
let potentialSoftMatch = insertionPoint;
let nextSibling = newChild.nextSibling;
let siblingSoftMatchCount = 0;
while (potentialSoftMatch !