5532 lines
196 KiB
JavaScript
5532 lines
196 KiB
JavaScript
/*!
|
|
* watermark-js-plus v1.6.3
|
|
* (c) 2022-2024 Michael Sun
|
|
* Released under the MIT License.
|
|
*/
|
|
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WatermarkPlus = {}));
|
|
})(this, (function (exports) { 'use strict';
|
|
|
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
|
|
var es_array_from = {};
|
|
|
|
var globalThis_1;
|
|
var hasRequiredGlobalThis;
|
|
|
|
function requireGlobalThis () {
|
|
if (hasRequiredGlobalThis) return globalThis_1;
|
|
hasRequiredGlobalThis = 1;
|
|
var check = function (it) {
|
|
return it && it.Math === Math && it;
|
|
};
|
|
|
|
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
globalThis_1 =
|
|
// eslint-disable-next-line es/no-global-this -- safe
|
|
check(typeof globalThis == 'object' && globalThis) ||
|
|
check(typeof window == 'object' && window) ||
|
|
// eslint-disable-next-line no-restricted-globals -- safe
|
|
check(typeof self == 'object' && self) ||
|
|
check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
|
|
check(typeof globalThis_1 == 'object' && globalThis_1) ||
|
|
// eslint-disable-next-line no-new-func -- fallback
|
|
(function () { return this; })() || Function('return this')();
|
|
return globalThis_1;
|
|
}
|
|
|
|
var objectGetOwnPropertyDescriptor = {};
|
|
|
|
var fails;
|
|
var hasRequiredFails;
|
|
|
|
function requireFails () {
|
|
if (hasRequiredFails) return fails;
|
|
hasRequiredFails = 1;
|
|
fails = function (exec) {
|
|
try {
|
|
return !!exec();
|
|
} catch (error) {
|
|
return true;
|
|
}
|
|
};
|
|
return fails;
|
|
}
|
|
|
|
var descriptors;
|
|
var hasRequiredDescriptors;
|
|
|
|
function requireDescriptors () {
|
|
if (hasRequiredDescriptors) return descriptors;
|
|
hasRequiredDescriptors = 1;
|
|
var fails = requireFails();
|
|
|
|
// Detect IE8's incomplete defineProperty implementation
|
|
descriptors = !fails(function () {
|
|
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
|
|
});
|
|
return descriptors;
|
|
}
|
|
|
|
var functionBindNative;
|
|
var hasRequiredFunctionBindNative;
|
|
|
|
function requireFunctionBindNative () {
|
|
if (hasRequiredFunctionBindNative) return functionBindNative;
|
|
hasRequiredFunctionBindNative = 1;
|
|
var fails = requireFails();
|
|
|
|
functionBindNative = !fails(function () {
|
|
// eslint-disable-next-line es/no-function-prototype-bind -- safe
|
|
var test = (function () { /* empty */ }).bind();
|
|
// eslint-disable-next-line no-prototype-builtins -- safe
|
|
return typeof test != 'function' || test.hasOwnProperty('prototype');
|
|
});
|
|
return functionBindNative;
|
|
}
|
|
|
|
var functionCall;
|
|
var hasRequiredFunctionCall;
|
|
|
|
function requireFunctionCall () {
|
|
if (hasRequiredFunctionCall) return functionCall;
|
|
hasRequiredFunctionCall = 1;
|
|
var NATIVE_BIND = requireFunctionBindNative();
|
|
|
|
var call = Function.prototype.call;
|
|
// eslint-disable-next-line es/no-function-prototype-bind -- safe
|
|
functionCall = NATIVE_BIND ? call.bind(call) : function () {
|
|
return call.apply(call, arguments);
|
|
};
|
|
return functionCall;
|
|
}
|
|
|
|
var objectPropertyIsEnumerable = {};
|
|
|
|
var hasRequiredObjectPropertyIsEnumerable;
|
|
|
|
function requireObjectPropertyIsEnumerable () {
|
|
if (hasRequiredObjectPropertyIsEnumerable) return objectPropertyIsEnumerable;
|
|
hasRequiredObjectPropertyIsEnumerable = 1;
|
|
var $propertyIsEnumerable = {}.propertyIsEnumerable;
|
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
|
|
// Nashorn ~ JDK8 bug
|
|
var NASHORN_BUG = getOwnPropertyDescriptor && !$propertyIsEnumerable.call({ 1: 2 }, 1);
|
|
|
|
// `Object.prototype.propertyIsEnumerable` method implementation
|
|
// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
|
|
objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
|
|
var descriptor = getOwnPropertyDescriptor(this, V);
|
|
return !!descriptor && descriptor.enumerable;
|
|
} : $propertyIsEnumerable;
|
|
return objectPropertyIsEnumerable;
|
|
}
|
|
|
|
var createPropertyDescriptor;
|
|
var hasRequiredCreatePropertyDescriptor;
|
|
|
|
function requireCreatePropertyDescriptor () {
|
|
if (hasRequiredCreatePropertyDescriptor) return createPropertyDescriptor;
|
|
hasRequiredCreatePropertyDescriptor = 1;
|
|
createPropertyDescriptor = function (bitmap, value) {
|
|
return {
|
|
enumerable: !(bitmap & 1),
|
|
configurable: !(bitmap & 2),
|
|
writable: !(bitmap & 4),
|
|
value: value
|
|
};
|
|
};
|
|
return createPropertyDescriptor;
|
|
}
|
|
|
|
var functionUncurryThis;
|
|
var hasRequiredFunctionUncurryThis;
|
|
|
|
function requireFunctionUncurryThis () {
|
|
if (hasRequiredFunctionUncurryThis) return functionUncurryThis;
|
|
hasRequiredFunctionUncurryThis = 1;
|
|
var NATIVE_BIND = requireFunctionBindNative();
|
|
|
|
var FunctionPrototype = Function.prototype;
|
|
var call = FunctionPrototype.call;
|
|
// eslint-disable-next-line es/no-function-prototype-bind -- safe
|
|
var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype.bind.bind(call, call);
|
|
|
|
functionUncurryThis = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
|
|
return function () {
|
|
return call.apply(fn, arguments);
|
|
};
|
|
};
|
|
return functionUncurryThis;
|
|
}
|
|
|
|
var classofRaw;
|
|
var hasRequiredClassofRaw;
|
|
|
|
function requireClassofRaw () {
|
|
if (hasRequiredClassofRaw) return classofRaw;
|
|
hasRequiredClassofRaw = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
|
|
var toString = uncurryThis({}.toString);
|
|
var stringSlice = uncurryThis(''.slice);
|
|
|
|
classofRaw = function (it) {
|
|
return stringSlice(toString(it), 8, -1);
|
|
};
|
|
return classofRaw;
|
|
}
|
|
|
|
var indexedObject;
|
|
var hasRequiredIndexedObject;
|
|
|
|
function requireIndexedObject () {
|
|
if (hasRequiredIndexedObject) return indexedObject;
|
|
hasRequiredIndexedObject = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
var fails = requireFails();
|
|
var classof = requireClassofRaw();
|
|
|
|
var $Object = Object;
|
|
var split = uncurryThis(''.split);
|
|
|
|
// fallback for non-array-like ES3 and non-enumerable old V8 strings
|
|
indexedObject = fails(function () {
|
|
// throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
|
|
// eslint-disable-next-line no-prototype-builtins -- safe
|
|
return !$Object('z').propertyIsEnumerable(0);
|
|
}) ? function (it) {
|
|
return classof(it) === 'String' ? split(it, '') : $Object(it);
|
|
} : $Object;
|
|
return indexedObject;
|
|
}
|
|
|
|
var isNullOrUndefined;
|
|
var hasRequiredIsNullOrUndefined;
|
|
|
|
function requireIsNullOrUndefined () {
|
|
if (hasRequiredIsNullOrUndefined) return isNullOrUndefined;
|
|
hasRequiredIsNullOrUndefined = 1;
|
|
// we can't use just `it == null` since of `document.all` special case
|
|
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
|
|
isNullOrUndefined = function (it) {
|
|
return it === null || it === undefined;
|
|
};
|
|
return isNullOrUndefined;
|
|
}
|
|
|
|
var requireObjectCoercible;
|
|
var hasRequiredRequireObjectCoercible;
|
|
|
|
function requireRequireObjectCoercible () {
|
|
if (hasRequiredRequireObjectCoercible) return requireObjectCoercible;
|
|
hasRequiredRequireObjectCoercible = 1;
|
|
var isNullOrUndefined = requireIsNullOrUndefined();
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
// `RequireObjectCoercible` abstract operation
|
|
// https://tc39.es/ecma262/#sec-requireobjectcoercible
|
|
requireObjectCoercible = function (it) {
|
|
if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it);
|
|
return it;
|
|
};
|
|
return requireObjectCoercible;
|
|
}
|
|
|
|
var toIndexedObject;
|
|
var hasRequiredToIndexedObject;
|
|
|
|
function requireToIndexedObject () {
|
|
if (hasRequiredToIndexedObject) return toIndexedObject;
|
|
hasRequiredToIndexedObject = 1;
|
|
// toObject with fallback for non-array-like ES3 strings
|
|
var IndexedObject = requireIndexedObject();
|
|
var requireObjectCoercible = requireRequireObjectCoercible();
|
|
|
|
toIndexedObject = function (it) {
|
|
return IndexedObject(requireObjectCoercible(it));
|
|
};
|
|
return toIndexedObject;
|
|
}
|
|
|
|
var isCallable;
|
|
var hasRequiredIsCallable;
|
|
|
|
function requireIsCallable () {
|
|
if (hasRequiredIsCallable) return isCallable;
|
|
hasRequiredIsCallable = 1;
|
|
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
|
|
var documentAll = typeof document == 'object' && document.all;
|
|
|
|
// `IsCallable` abstract operation
|
|
// https://tc39.es/ecma262/#sec-iscallable
|
|
// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
|
|
isCallable = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
|
|
return typeof argument == 'function' || argument === documentAll;
|
|
} : function (argument) {
|
|
return typeof argument == 'function';
|
|
};
|
|
return isCallable;
|
|
}
|
|
|
|
var isObject;
|
|
var hasRequiredIsObject;
|
|
|
|
function requireIsObject () {
|
|
if (hasRequiredIsObject) return isObject;
|
|
hasRequiredIsObject = 1;
|
|
var isCallable = requireIsCallable();
|
|
|
|
isObject = function (it) {
|
|
return typeof it == 'object' ? it !== null : isCallable(it);
|
|
};
|
|
return isObject;
|
|
}
|
|
|
|
var getBuiltIn;
|
|
var hasRequiredGetBuiltIn;
|
|
|
|
function requireGetBuiltIn () {
|
|
if (hasRequiredGetBuiltIn) return getBuiltIn;
|
|
hasRequiredGetBuiltIn = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var isCallable = requireIsCallable();
|
|
|
|
var aFunction = function (argument) {
|
|
return isCallable(argument) ? argument : undefined;
|
|
};
|
|
|
|
getBuiltIn = function (namespace, method) {
|
|
return arguments.length < 2 ? aFunction(globalThis[namespace]) : globalThis[namespace] && globalThis[namespace][method];
|
|
};
|
|
return getBuiltIn;
|
|
}
|
|
|
|
var objectIsPrototypeOf;
|
|
var hasRequiredObjectIsPrototypeOf;
|
|
|
|
function requireObjectIsPrototypeOf () {
|
|
if (hasRequiredObjectIsPrototypeOf) return objectIsPrototypeOf;
|
|
hasRequiredObjectIsPrototypeOf = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
|
|
objectIsPrototypeOf = uncurryThis({}.isPrototypeOf);
|
|
return objectIsPrototypeOf;
|
|
}
|
|
|
|
var environmentUserAgent;
|
|
var hasRequiredEnvironmentUserAgent;
|
|
|
|
function requireEnvironmentUserAgent () {
|
|
if (hasRequiredEnvironmentUserAgent) return environmentUserAgent;
|
|
hasRequiredEnvironmentUserAgent = 1;
|
|
var globalThis = requireGlobalThis();
|
|
|
|
var navigator = globalThis.navigator;
|
|
var userAgent = navigator && navigator.userAgent;
|
|
|
|
environmentUserAgent = userAgent ? String(userAgent) : '';
|
|
return environmentUserAgent;
|
|
}
|
|
|
|
var environmentV8Version;
|
|
var hasRequiredEnvironmentV8Version;
|
|
|
|
function requireEnvironmentV8Version () {
|
|
if (hasRequiredEnvironmentV8Version) return environmentV8Version;
|
|
hasRequiredEnvironmentV8Version = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var userAgent = requireEnvironmentUserAgent();
|
|
|
|
var process = globalThis.process;
|
|
var Deno = globalThis.Deno;
|
|
var versions = process && process.versions || Deno && Deno.version;
|
|
var v8 = versions && versions.v8;
|
|
var match, version;
|
|
|
|
if (v8) {
|
|
match = v8.split('.');
|
|
// in old Chrome, versions of V8 isn't V8 = Chrome / 10
|
|
// but their correct versions are not interesting for us
|
|
version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
|
|
}
|
|
|
|
// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
|
|
// so check `userAgent` even if `.v8` exists, but 0
|
|
if (!version && userAgent) {
|
|
match = userAgent.match(/Edge\/(\d+)/);
|
|
if (!match || match[1] >= 74) {
|
|
match = userAgent.match(/Chrome\/(\d+)/);
|
|
if (match) version = +match[1];
|
|
}
|
|
}
|
|
|
|
environmentV8Version = version;
|
|
return environmentV8Version;
|
|
}
|
|
|
|
var symbolConstructorDetection;
|
|
var hasRequiredSymbolConstructorDetection;
|
|
|
|
function requireSymbolConstructorDetection () {
|
|
if (hasRequiredSymbolConstructorDetection) return symbolConstructorDetection;
|
|
hasRequiredSymbolConstructorDetection = 1;
|
|
/* eslint-disable es/no-symbol -- required for testing */
|
|
var V8_VERSION = requireEnvironmentV8Version();
|
|
var fails = requireFails();
|
|
var globalThis = requireGlobalThis();
|
|
|
|
var $String = globalThis.String;
|
|
|
|
// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
|
|
symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails(function () {
|
|
var symbol = Symbol('symbol detection');
|
|
// Chrome 38 Symbol has incorrect toString conversion
|
|
// `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
|
|
// nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
|
|
// of course, fail.
|
|
return !$String(symbol) || !(Object(symbol) instanceof Symbol) ||
|
|
// Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
|
|
!Symbol.sham && V8_VERSION && V8_VERSION < 41;
|
|
});
|
|
return symbolConstructorDetection;
|
|
}
|
|
|
|
var useSymbolAsUid;
|
|
var hasRequiredUseSymbolAsUid;
|
|
|
|
function requireUseSymbolAsUid () {
|
|
if (hasRequiredUseSymbolAsUid) return useSymbolAsUid;
|
|
hasRequiredUseSymbolAsUid = 1;
|
|
/* eslint-disable es/no-symbol -- required for testing */
|
|
var NATIVE_SYMBOL = requireSymbolConstructorDetection();
|
|
|
|
useSymbolAsUid = NATIVE_SYMBOL &&
|
|
!Symbol.sham &&
|
|
typeof Symbol.iterator == 'symbol';
|
|
return useSymbolAsUid;
|
|
}
|
|
|
|
var isSymbol;
|
|
var hasRequiredIsSymbol;
|
|
|
|
function requireIsSymbol () {
|
|
if (hasRequiredIsSymbol) return isSymbol;
|
|
hasRequiredIsSymbol = 1;
|
|
var getBuiltIn = requireGetBuiltIn();
|
|
var isCallable = requireIsCallable();
|
|
var isPrototypeOf = requireObjectIsPrototypeOf();
|
|
var USE_SYMBOL_AS_UID = requireUseSymbolAsUid();
|
|
|
|
var $Object = Object;
|
|
|
|
isSymbol = USE_SYMBOL_AS_UID ? function (it) {
|
|
return typeof it == 'symbol';
|
|
} : function (it) {
|
|
var $Symbol = getBuiltIn('Symbol');
|
|
return isCallable($Symbol) && isPrototypeOf($Symbol.prototype, $Object(it));
|
|
};
|
|
return isSymbol;
|
|
}
|
|
|
|
var tryToString;
|
|
var hasRequiredTryToString;
|
|
|
|
function requireTryToString () {
|
|
if (hasRequiredTryToString) return tryToString;
|
|
hasRequiredTryToString = 1;
|
|
var $String = String;
|
|
|
|
tryToString = function (argument) {
|
|
try {
|
|
return $String(argument);
|
|
} catch (error) {
|
|
return 'Object';
|
|
}
|
|
};
|
|
return tryToString;
|
|
}
|
|
|
|
var aCallable;
|
|
var hasRequiredACallable;
|
|
|
|
function requireACallable () {
|
|
if (hasRequiredACallable) return aCallable;
|
|
hasRequiredACallable = 1;
|
|
var isCallable = requireIsCallable();
|
|
var tryToString = requireTryToString();
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
// `Assert: IsCallable(argument) is true`
|
|
aCallable = function (argument) {
|
|
if (isCallable(argument)) return argument;
|
|
throw new $TypeError(tryToString(argument) + ' is not a function');
|
|
};
|
|
return aCallable;
|
|
}
|
|
|
|
var getMethod;
|
|
var hasRequiredGetMethod;
|
|
|
|
function requireGetMethod () {
|
|
if (hasRequiredGetMethod) return getMethod;
|
|
hasRequiredGetMethod = 1;
|
|
var aCallable = requireACallable();
|
|
var isNullOrUndefined = requireIsNullOrUndefined();
|
|
|
|
// `GetMethod` abstract operation
|
|
// https://tc39.es/ecma262/#sec-getmethod
|
|
getMethod = function (V, P) {
|
|
var func = V[P];
|
|
return isNullOrUndefined(func) ? undefined : aCallable(func);
|
|
};
|
|
return getMethod;
|
|
}
|
|
|
|
var ordinaryToPrimitive;
|
|
var hasRequiredOrdinaryToPrimitive;
|
|
|
|
function requireOrdinaryToPrimitive () {
|
|
if (hasRequiredOrdinaryToPrimitive) return ordinaryToPrimitive;
|
|
hasRequiredOrdinaryToPrimitive = 1;
|
|
var call = requireFunctionCall();
|
|
var isCallable = requireIsCallable();
|
|
var isObject = requireIsObject();
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
// `OrdinaryToPrimitive` abstract operation
|
|
// https://tc39.es/ecma262/#sec-ordinarytoprimitive
|
|
ordinaryToPrimitive = function (input, pref) {
|
|
var fn, val;
|
|
if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
|
|
if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
|
|
if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
|
|
throw new $TypeError("Can't convert object to primitive value");
|
|
};
|
|
return ordinaryToPrimitive;
|
|
}
|
|
|
|
var sharedStore = {exports: {}};
|
|
|
|
var isPure;
|
|
var hasRequiredIsPure;
|
|
|
|
function requireIsPure () {
|
|
if (hasRequiredIsPure) return isPure;
|
|
hasRequiredIsPure = 1;
|
|
isPure = false;
|
|
return isPure;
|
|
}
|
|
|
|
var defineGlobalProperty;
|
|
var hasRequiredDefineGlobalProperty;
|
|
|
|
function requireDefineGlobalProperty () {
|
|
if (hasRequiredDefineGlobalProperty) return defineGlobalProperty;
|
|
hasRequiredDefineGlobalProperty = 1;
|
|
var globalThis = requireGlobalThis();
|
|
|
|
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
var defineProperty = Object.defineProperty;
|
|
|
|
defineGlobalProperty = function (key, value) {
|
|
try {
|
|
defineProperty(globalThis, key, { value: value, configurable: true, writable: true });
|
|
} catch (error) {
|
|
globalThis[key] = value;
|
|
} return value;
|
|
};
|
|
return defineGlobalProperty;
|
|
}
|
|
|
|
var hasRequiredSharedStore;
|
|
|
|
function requireSharedStore () {
|
|
if (hasRequiredSharedStore) return sharedStore.exports;
|
|
hasRequiredSharedStore = 1;
|
|
var IS_PURE = requireIsPure();
|
|
var globalThis = requireGlobalThis();
|
|
var defineGlobalProperty = requireDefineGlobalProperty();
|
|
|
|
var SHARED = '__core-js_shared__';
|
|
var store = sharedStore.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
|
|
|
|
(store.versions || (store.versions = [])).push({
|
|
version: '3.44.0',
|
|
mode: IS_PURE ? 'pure' : 'global',
|
|
copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)',
|
|
license: 'https://github.com/zloirock/core-js/blob/v3.44.0/LICENSE',
|
|
source: 'https://github.com/zloirock/core-js'
|
|
});
|
|
return sharedStore.exports;
|
|
}
|
|
|
|
var shared;
|
|
var hasRequiredShared;
|
|
|
|
function requireShared () {
|
|
if (hasRequiredShared) return shared;
|
|
hasRequiredShared = 1;
|
|
var store = requireSharedStore();
|
|
|
|
shared = function (key, value) {
|
|
return store[key] || (store[key] = value || {});
|
|
};
|
|
return shared;
|
|
}
|
|
|
|
var toObject;
|
|
var hasRequiredToObject;
|
|
|
|
function requireToObject () {
|
|
if (hasRequiredToObject) return toObject;
|
|
hasRequiredToObject = 1;
|
|
var requireObjectCoercible = requireRequireObjectCoercible();
|
|
|
|
var $Object = Object;
|
|
|
|
// `ToObject` abstract operation
|
|
// https://tc39.es/ecma262/#sec-toobject
|
|
toObject = function (argument) {
|
|
return $Object(requireObjectCoercible(argument));
|
|
};
|
|
return toObject;
|
|
}
|
|
|
|
var hasOwnProperty_1;
|
|
var hasRequiredHasOwnProperty;
|
|
|
|
function requireHasOwnProperty () {
|
|
if (hasRequiredHasOwnProperty) return hasOwnProperty_1;
|
|
hasRequiredHasOwnProperty = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
var toObject = requireToObject();
|
|
|
|
var hasOwnProperty = uncurryThis({}.hasOwnProperty);
|
|
|
|
// `HasOwnProperty` abstract operation
|
|
// https://tc39.es/ecma262/#sec-hasownproperty
|
|
// eslint-disable-next-line es/no-object-hasown -- safe
|
|
hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
|
|
return hasOwnProperty(toObject(it), key);
|
|
};
|
|
return hasOwnProperty_1;
|
|
}
|
|
|
|
var uid;
|
|
var hasRequiredUid;
|
|
|
|
function requireUid () {
|
|
if (hasRequiredUid) return uid;
|
|
hasRequiredUid = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
|
|
var id = 0;
|
|
var postfix = Math.random();
|
|
var toString = uncurryThis(1.1.toString);
|
|
|
|
uid = function (key) {
|
|
return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
|
|
};
|
|
return uid;
|
|
}
|
|
|
|
var wellKnownSymbol;
|
|
var hasRequiredWellKnownSymbol;
|
|
|
|
function requireWellKnownSymbol () {
|
|
if (hasRequiredWellKnownSymbol) return wellKnownSymbol;
|
|
hasRequiredWellKnownSymbol = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var shared = requireShared();
|
|
var hasOwn = requireHasOwnProperty();
|
|
var uid = requireUid();
|
|
var NATIVE_SYMBOL = requireSymbolConstructorDetection();
|
|
var USE_SYMBOL_AS_UID = requireUseSymbolAsUid();
|
|
|
|
var Symbol = globalThis.Symbol;
|
|
var WellKnownSymbolsStore = shared('wks');
|
|
var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol['for'] || Symbol : Symbol && Symbol.withoutSetter || uid;
|
|
|
|
wellKnownSymbol = function (name) {
|
|
if (!hasOwn(WellKnownSymbolsStore, name)) {
|
|
WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn(Symbol, name)
|
|
? Symbol[name]
|
|
: createWellKnownSymbol('Symbol.' + name);
|
|
} return WellKnownSymbolsStore[name];
|
|
};
|
|
return wellKnownSymbol;
|
|
}
|
|
|
|
var toPrimitive;
|
|
var hasRequiredToPrimitive;
|
|
|
|
function requireToPrimitive () {
|
|
if (hasRequiredToPrimitive) return toPrimitive;
|
|
hasRequiredToPrimitive = 1;
|
|
var call = requireFunctionCall();
|
|
var isObject = requireIsObject();
|
|
var isSymbol = requireIsSymbol();
|
|
var getMethod = requireGetMethod();
|
|
var ordinaryToPrimitive = requireOrdinaryToPrimitive();
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
|
|
var $TypeError = TypeError;
|
|
var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
|
|
|
|
// `ToPrimitive` abstract operation
|
|
// https://tc39.es/ecma262/#sec-toprimitive
|
|
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 = call(exoticToPrim, input, pref);
|
|
if (!isObject(result) || isSymbol(result)) return result;
|
|
throw new $TypeError("Can't convert object to primitive value");
|
|
}
|
|
if (pref === undefined) pref = 'number';
|
|
return ordinaryToPrimitive(input, pref);
|
|
};
|
|
return toPrimitive;
|
|
}
|
|
|
|
var toPropertyKey;
|
|
var hasRequiredToPropertyKey;
|
|
|
|
function requireToPropertyKey () {
|
|
if (hasRequiredToPropertyKey) return toPropertyKey;
|
|
hasRequiredToPropertyKey = 1;
|
|
var toPrimitive = requireToPrimitive();
|
|
var isSymbol = requireIsSymbol();
|
|
|
|
// `ToPropertyKey` abstract operation
|
|
// https://tc39.es/ecma262/#sec-topropertykey
|
|
toPropertyKey = function (argument) {
|
|
var key = toPrimitive(argument, 'string');
|
|
return isSymbol(key) ? key : key + '';
|
|
};
|
|
return toPropertyKey;
|
|
}
|
|
|
|
var documentCreateElement;
|
|
var hasRequiredDocumentCreateElement;
|
|
|
|
function requireDocumentCreateElement () {
|
|
if (hasRequiredDocumentCreateElement) return documentCreateElement;
|
|
hasRequiredDocumentCreateElement = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var isObject = requireIsObject();
|
|
|
|
var document = globalThis.document;
|
|
// typeof document.createElement is 'object' in old IE
|
|
var EXISTS = isObject(document) && isObject(document.createElement);
|
|
|
|
documentCreateElement = function (it) {
|
|
return EXISTS ? document.createElement(it) : {};
|
|
};
|
|
return documentCreateElement;
|
|
}
|
|
|
|
var ie8DomDefine;
|
|
var hasRequiredIe8DomDefine;
|
|
|
|
function requireIe8DomDefine () {
|
|
if (hasRequiredIe8DomDefine) return ie8DomDefine;
|
|
hasRequiredIe8DomDefine = 1;
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var fails = requireFails();
|
|
var createElement = requireDocumentCreateElement();
|
|
|
|
// Thanks to IE8 for its funny defineProperty
|
|
ie8DomDefine = !DESCRIPTORS && !fails(function () {
|
|
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
return Object.defineProperty(createElement('div'), 'a', {
|
|
get: function () { return 7; }
|
|
}).a !== 7;
|
|
});
|
|
return ie8DomDefine;
|
|
}
|
|
|
|
var hasRequiredObjectGetOwnPropertyDescriptor;
|
|
|
|
function requireObjectGetOwnPropertyDescriptor () {
|
|
if (hasRequiredObjectGetOwnPropertyDescriptor) return objectGetOwnPropertyDescriptor;
|
|
hasRequiredObjectGetOwnPropertyDescriptor = 1;
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var call = requireFunctionCall();
|
|
var propertyIsEnumerableModule = requireObjectPropertyIsEnumerable();
|
|
var createPropertyDescriptor = requireCreatePropertyDescriptor();
|
|
var toIndexedObject = requireToIndexedObject();
|
|
var toPropertyKey = requireToPropertyKey();
|
|
var hasOwn = requireHasOwnProperty();
|
|
var IE8_DOM_DEFINE = requireIe8DomDefine();
|
|
|
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
|
|
// `Object.getOwnPropertyDescriptor` method
|
|
// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
|
|
objectGetOwnPropertyDescriptor.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
|
|
O = toIndexedObject(O);
|
|
P = toPropertyKey(P);
|
|
if (IE8_DOM_DEFINE) try {
|
|
return $getOwnPropertyDescriptor(O, P);
|
|
} catch (error) { /* empty */ }
|
|
if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
|
|
};
|
|
return objectGetOwnPropertyDescriptor;
|
|
}
|
|
|
|
var objectDefineProperty = {};
|
|
|
|
var v8PrototypeDefineBug;
|
|
var hasRequiredV8PrototypeDefineBug;
|
|
|
|
function requireV8PrototypeDefineBug () {
|
|
if (hasRequiredV8PrototypeDefineBug) return v8PrototypeDefineBug;
|
|
hasRequiredV8PrototypeDefineBug = 1;
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var fails = requireFails();
|
|
|
|
// V8 ~ Chrome 36-
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3334
|
|
v8PrototypeDefineBug = DESCRIPTORS && fails(function () {
|
|
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
return Object.defineProperty(function () { /* empty */ }, 'prototype', {
|
|
value: 42,
|
|
writable: false
|
|
}).prototype !== 42;
|
|
});
|
|
return v8PrototypeDefineBug;
|
|
}
|
|
|
|
var anObject;
|
|
var hasRequiredAnObject;
|
|
|
|
function requireAnObject () {
|
|
if (hasRequiredAnObject) return anObject;
|
|
hasRequiredAnObject = 1;
|
|
var isObject = requireIsObject();
|
|
|
|
var $String = String;
|
|
var $TypeError = TypeError;
|
|
|
|
// `Assert: Type(argument) is Object`
|
|
anObject = function (argument) {
|
|
if (isObject(argument)) return argument;
|
|
throw new $TypeError($String(argument) + ' is not an object');
|
|
};
|
|
return anObject;
|
|
}
|
|
|
|
var hasRequiredObjectDefineProperty;
|
|
|
|
function requireObjectDefineProperty () {
|
|
if (hasRequiredObjectDefineProperty) return objectDefineProperty;
|
|
hasRequiredObjectDefineProperty = 1;
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var IE8_DOM_DEFINE = requireIe8DomDefine();
|
|
var V8_PROTOTYPE_DEFINE_BUG = requireV8PrototypeDefineBug();
|
|
var anObject = requireAnObject();
|
|
var toPropertyKey = requireToPropertyKey();
|
|
|
|
var $TypeError = TypeError;
|
|
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
var $defineProperty = Object.defineProperty;
|
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
var ENUMERABLE = 'enumerable';
|
|
var CONFIGURABLE = 'configurable';
|
|
var WRITABLE = 'writable';
|
|
|
|
// `Object.defineProperty` method
|
|
// https://tc39.es/ecma262/#sec-object.defineproperty
|
|
objectDefineProperty.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? 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 in Attributes ? Attributes[CONFIGURABLE] : current[CONFIGURABLE],
|
|
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 (IE8_DOM_DEFINE) try {
|
|
return $defineProperty(O, P, Attributes);
|
|
} catch (error) { /* empty */ }
|
|
if ('get' in Attributes || 'set' in Attributes) throw new $TypeError('Accessors not supported');
|
|
if ('value' in Attributes) O[P] = Attributes.value;
|
|
return O;
|
|
};
|
|
return objectDefineProperty;
|
|
}
|
|
|
|
var createNonEnumerableProperty;
|
|
var hasRequiredCreateNonEnumerableProperty;
|
|
|
|
function requireCreateNonEnumerableProperty () {
|
|
if (hasRequiredCreateNonEnumerableProperty) return createNonEnumerableProperty;
|
|
hasRequiredCreateNonEnumerableProperty = 1;
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var definePropertyModule = requireObjectDefineProperty();
|
|
var createPropertyDescriptor = requireCreatePropertyDescriptor();
|
|
|
|
createNonEnumerableProperty = DESCRIPTORS ? function (object, key, value) {
|
|
return definePropertyModule.f(object, key, createPropertyDescriptor(1, value));
|
|
} : function (object, key, value) {
|
|
object[key] = value;
|
|
return object;
|
|
};
|
|
return createNonEnumerableProperty;
|
|
}
|
|
|
|
var makeBuiltIn = {exports: {}};
|
|
|
|
var functionName;
|
|
var hasRequiredFunctionName;
|
|
|
|
function requireFunctionName () {
|
|
if (hasRequiredFunctionName) return functionName;
|
|
hasRequiredFunctionName = 1;
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var hasOwn = requireHasOwnProperty();
|
|
|
|
var FunctionPrototype = Function.prototype;
|
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
|
|
|
|
var EXISTS = hasOwn(FunctionPrototype, 'name');
|
|
// additional protection from minified / mangled / dropped function names
|
|
var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
|
|
var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
|
|
|
|
functionName = {
|
|
EXISTS: EXISTS,
|
|
PROPER: PROPER,
|
|
CONFIGURABLE: CONFIGURABLE
|
|
};
|
|
return functionName;
|
|
}
|
|
|
|
var inspectSource;
|
|
var hasRequiredInspectSource;
|
|
|
|
function requireInspectSource () {
|
|
if (hasRequiredInspectSource) return inspectSource;
|
|
hasRequiredInspectSource = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
var isCallable = requireIsCallable();
|
|
var store = requireSharedStore();
|
|
|
|
var functionToString = uncurryThis(Function.toString);
|
|
|
|
// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
|
|
if (!isCallable(store.inspectSource)) {
|
|
store.inspectSource = function (it) {
|
|
return functionToString(it);
|
|
};
|
|
}
|
|
|
|
inspectSource = store.inspectSource;
|
|
return inspectSource;
|
|
}
|
|
|
|
var weakMapBasicDetection;
|
|
var hasRequiredWeakMapBasicDetection;
|
|
|
|
function requireWeakMapBasicDetection () {
|
|
if (hasRequiredWeakMapBasicDetection) return weakMapBasicDetection;
|
|
hasRequiredWeakMapBasicDetection = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var isCallable = requireIsCallable();
|
|
|
|
var WeakMap = globalThis.WeakMap;
|
|
|
|
weakMapBasicDetection = isCallable(WeakMap) && /native code/.test(String(WeakMap));
|
|
return weakMapBasicDetection;
|
|
}
|
|
|
|
var sharedKey;
|
|
var hasRequiredSharedKey;
|
|
|
|
function requireSharedKey () {
|
|
if (hasRequiredSharedKey) return sharedKey;
|
|
hasRequiredSharedKey = 1;
|
|
var shared = requireShared();
|
|
var uid = requireUid();
|
|
|
|
var keys = shared('keys');
|
|
|
|
sharedKey = function (key) {
|
|
return keys[key] || (keys[key] = uid(key));
|
|
};
|
|
return sharedKey;
|
|
}
|
|
|
|
var hiddenKeys;
|
|
var hasRequiredHiddenKeys;
|
|
|
|
function requireHiddenKeys () {
|
|
if (hasRequiredHiddenKeys) return hiddenKeys;
|
|
hasRequiredHiddenKeys = 1;
|
|
hiddenKeys = {};
|
|
return hiddenKeys;
|
|
}
|
|
|
|
var internalState;
|
|
var hasRequiredInternalState;
|
|
|
|
function requireInternalState () {
|
|
if (hasRequiredInternalState) return internalState;
|
|
hasRequiredInternalState = 1;
|
|
var NATIVE_WEAK_MAP = requireWeakMapBasicDetection();
|
|
var globalThis = requireGlobalThis();
|
|
var isObject = requireIsObject();
|
|
var createNonEnumerableProperty = requireCreateNonEnumerableProperty();
|
|
var hasOwn = requireHasOwnProperty();
|
|
var shared = requireSharedStore();
|
|
var sharedKey = requireSharedKey();
|
|
var hiddenKeys = requireHiddenKeys();
|
|
|
|
var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
|
|
var TypeError = globalThis.TypeError;
|
|
var WeakMap = globalThis.WeakMap;
|
|
var set, get, has;
|
|
|
|
var enforce = function (it) {
|
|
return has(it) ? get(it) : set(it, {});
|
|
};
|
|
|
|
var getterFor = function (TYPE) {
|
|
return function (it) {
|
|
var state;
|
|
if (!isObject(it) || (state = get(it)).type !== TYPE) {
|
|
throw new TypeError('Incompatible receiver, ' + TYPE + ' required');
|
|
} return state;
|
|
};
|
|
};
|
|
|
|
if (NATIVE_WEAK_MAP || shared.state) {
|
|
var store = shared.state || (shared.state = new WeakMap());
|
|
/* eslint-disable no-self-assign -- prototype methods protection */
|
|
store.get = store.get;
|
|
store.has = store.has;
|
|
store.set = store.set;
|
|
/* eslint-enable no-self-assign -- prototype methods protection */
|
|
set = function (it, metadata) {
|
|
if (store.has(it)) throw new TypeError(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[STATE] = true;
|
|
set = function (it, metadata) {
|
|
if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
|
|
metadata.facade = it;
|
|
createNonEnumerableProperty(it, STATE, metadata);
|
|
return metadata;
|
|
};
|
|
get = function (it) {
|
|
return hasOwn(it, STATE) ? it[STATE] : {};
|
|
};
|
|
has = function (it) {
|
|
return hasOwn(it, STATE);
|
|
};
|
|
}
|
|
|
|
internalState = {
|
|
set: set,
|
|
get: get,
|
|
has: has,
|
|
enforce: enforce,
|
|
getterFor: getterFor
|
|
};
|
|
return internalState;
|
|
}
|
|
|
|
var hasRequiredMakeBuiltIn;
|
|
|
|
function requireMakeBuiltIn () {
|
|
if (hasRequiredMakeBuiltIn) return makeBuiltIn.exports;
|
|
hasRequiredMakeBuiltIn = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
var fails = requireFails();
|
|
var isCallable = requireIsCallable();
|
|
var hasOwn = requireHasOwnProperty();
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var CONFIGURABLE_FUNCTION_NAME = requireFunctionName().CONFIGURABLE;
|
|
var inspectSource = requireInspectSource();
|
|
var InternalStateModule = requireInternalState();
|
|
|
|
var enforceInternalState = InternalStateModule.enforce;
|
|
var getInternalState = InternalStateModule.get;
|
|
var $String = String;
|
|
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
|
var defineProperty = Object.defineProperty;
|
|
var stringSlice = uncurryThis(''.slice);
|
|
var replace = uncurryThis(''.replace);
|
|
var join = uncurryThis([].join);
|
|
|
|
var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails(function () {
|
|
return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
|
|
});
|
|
|
|
var TEMPLATE = String(String).split('String');
|
|
|
|
var makeBuiltIn$1 = makeBuiltIn.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 (!hasOwn(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 && hasOwn(options, 'arity') && value.length !== options.arity) {
|
|
defineProperty(value, 'length', { value: options.arity });
|
|
}
|
|
try {
|
|
if (options && hasOwn(options, 'constructor') && options.constructor) {
|
|
if (DESCRIPTORS) defineProperty(value, 'prototype', { writable: false });
|
|
// in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
|
|
} else if (value.prototype) value.prototype = undefined;
|
|
} catch (error) { /* empty */ }
|
|
var state = enforceInternalState(value);
|
|
if (!hasOwn(state, 'source')) {
|
|
state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
|
|
} return value;
|
|
};
|
|
|
|
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
|
|
// eslint-disable-next-line no-extend-native -- required
|
|
Function.prototype.toString = makeBuiltIn$1(function toString() {
|
|
return isCallable(this) && getInternalState(this).source || inspectSource(this);
|
|
}, 'toString');
|
|
return makeBuiltIn.exports;
|
|
}
|
|
|
|
var defineBuiltIn;
|
|
var hasRequiredDefineBuiltIn;
|
|
|
|
function requireDefineBuiltIn () {
|
|
if (hasRequiredDefineBuiltIn) return defineBuiltIn;
|
|
hasRequiredDefineBuiltIn = 1;
|
|
var isCallable = requireIsCallable();
|
|
var definePropertyModule = requireObjectDefineProperty();
|
|
var makeBuiltIn = requireMakeBuiltIn();
|
|
var defineGlobalProperty = requireDefineGlobalProperty();
|
|
|
|
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(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) { /* empty */ }
|
|
if (simple) O[key] = value;
|
|
else definePropertyModule.f(O, key, {
|
|
value: value,
|
|
enumerable: false,
|
|
configurable: !options.nonConfigurable,
|
|
writable: !options.nonWritable
|
|
});
|
|
} return O;
|
|
};
|
|
return defineBuiltIn;
|
|
}
|
|
|
|
var objectGetOwnPropertyNames = {};
|
|
|
|
var mathTrunc;
|
|
var hasRequiredMathTrunc;
|
|
|
|
function requireMathTrunc () {
|
|
if (hasRequiredMathTrunc) return mathTrunc;
|
|
hasRequiredMathTrunc = 1;
|
|
var ceil = Math.ceil;
|
|
var floor = Math.floor;
|
|
|
|
// `Math.trunc` method
|
|
// https://tc39.es/ecma262/#sec-math.trunc
|
|
// eslint-disable-next-line es/no-math-trunc -- safe
|
|
mathTrunc = Math.trunc || function trunc(x) {
|
|
var n = +x;
|
|
return (n > 0 ? floor : ceil)(n);
|
|
};
|
|
return mathTrunc;
|
|
}
|
|
|
|
var toIntegerOrInfinity;
|
|
var hasRequiredToIntegerOrInfinity;
|
|
|
|
function requireToIntegerOrInfinity () {
|
|
if (hasRequiredToIntegerOrInfinity) return toIntegerOrInfinity;
|
|
hasRequiredToIntegerOrInfinity = 1;
|
|
var trunc = requireMathTrunc();
|
|
|
|
// `ToIntegerOrInfinity` abstract operation
|
|
// https://tc39.es/ecma262/#sec-tointegerorinfinity
|
|
toIntegerOrInfinity = function (argument) {
|
|
var number = +argument;
|
|
// eslint-disable-next-line no-self-compare -- NaN check
|
|
return number !== number || number === 0 ? 0 : trunc(number);
|
|
};
|
|
return toIntegerOrInfinity;
|
|
}
|
|
|
|
var toAbsoluteIndex;
|
|
var hasRequiredToAbsoluteIndex;
|
|
|
|
function requireToAbsoluteIndex () {
|
|
if (hasRequiredToAbsoluteIndex) return toAbsoluteIndex;
|
|
hasRequiredToAbsoluteIndex = 1;
|
|
var toIntegerOrInfinity = requireToIntegerOrInfinity();
|
|
|
|
var max = Math.max;
|
|
var min = Math.min;
|
|
|
|
// Helper for a popular repeating case of the spec:
|
|
// Let integer be ? ToInteger(index).
|
|
// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
|
|
toAbsoluteIndex = function (index, length) {
|
|
var integer = toIntegerOrInfinity(index);
|
|
return integer < 0 ? max(integer + length, 0) : min(integer, length);
|
|
};
|
|
return toAbsoluteIndex;
|
|
}
|
|
|
|
var toLength;
|
|
var hasRequiredToLength;
|
|
|
|
function requireToLength () {
|
|
if (hasRequiredToLength) return toLength;
|
|
hasRequiredToLength = 1;
|
|
var toIntegerOrInfinity = requireToIntegerOrInfinity();
|
|
|
|
var min = Math.min;
|
|
|
|
// `ToLength` abstract operation
|
|
// https://tc39.es/ecma262/#sec-tolength
|
|
toLength = function (argument) {
|
|
var len = toIntegerOrInfinity(argument);
|
|
return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
|
|
};
|
|
return toLength;
|
|
}
|
|
|
|
var lengthOfArrayLike;
|
|
var hasRequiredLengthOfArrayLike;
|
|
|
|
function requireLengthOfArrayLike () {
|
|
if (hasRequiredLengthOfArrayLike) return lengthOfArrayLike;
|
|
hasRequiredLengthOfArrayLike = 1;
|
|
var toLength = requireToLength();
|
|
|
|
// `LengthOfArrayLike` abstract operation
|
|
// https://tc39.es/ecma262/#sec-lengthofarraylike
|
|
lengthOfArrayLike = function (obj) {
|
|
return toLength(obj.length);
|
|
};
|
|
return lengthOfArrayLike;
|
|
}
|
|
|
|
var arrayIncludes;
|
|
var hasRequiredArrayIncludes;
|
|
|
|
function requireArrayIncludes () {
|
|
if (hasRequiredArrayIncludes) return arrayIncludes;
|
|
hasRequiredArrayIncludes = 1;
|
|
var toIndexedObject = requireToIndexedObject();
|
|
var toAbsoluteIndex = requireToAbsoluteIndex();
|
|
var lengthOfArrayLike = requireLengthOfArrayLike();
|
|
|
|
// `Array.prototype.{ indexOf, includes }` methods implementation
|
|
var createMethod = 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;
|
|
// Array#includes uses SameValueZero equality algorithm
|
|
// eslint-disable-next-line no-self-compare -- NaN check
|
|
if (IS_INCLUDES && el !== el) while (length > index) {
|
|
value = O[index++];
|
|
// eslint-disable-next-line no-self-compare -- NaN check
|
|
if (value !== value) return true;
|
|
// Array#indexOf ignores holes, Array#includes - not
|
|
} else for (;length > index; index++) {
|
|
if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
|
|
} return !IS_INCLUDES && -1;
|
|
};
|
|
};
|
|
|
|
arrayIncludes = {
|
|
// `Array.prototype.includes` method
|
|
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
includes: createMethod(true),
|
|
// `Array.prototype.indexOf` method
|
|
// https://tc39.es/ecma262/#sec-array.prototype.indexof
|
|
indexOf: createMethod(false)
|
|
};
|
|
return arrayIncludes;
|
|
}
|
|
|
|
var objectKeysInternal;
|
|
var hasRequiredObjectKeysInternal;
|
|
|
|
function requireObjectKeysInternal () {
|
|
if (hasRequiredObjectKeysInternal) return objectKeysInternal;
|
|
hasRequiredObjectKeysInternal = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
var hasOwn = requireHasOwnProperty();
|
|
var toIndexedObject = requireToIndexedObject();
|
|
var indexOf = requireArrayIncludes().indexOf;
|
|
var hiddenKeys = requireHiddenKeys();
|
|
|
|
var push = uncurryThis([].push);
|
|
|
|
objectKeysInternal = function (object, names) {
|
|
var O = toIndexedObject(object);
|
|
var i = 0;
|
|
var result = [];
|
|
var key;
|
|
for (key in O) !hasOwn(hiddenKeys, key) && hasOwn(O, key) && push(result, key);
|
|
// Don't enum bug & hidden keys
|
|
while (names.length > i) if (hasOwn(O, key = names[i++])) {
|
|
~indexOf(result, key) || push(result, key);
|
|
}
|
|
return result;
|
|
};
|
|
return objectKeysInternal;
|
|
}
|
|
|
|
var enumBugKeys;
|
|
var hasRequiredEnumBugKeys;
|
|
|
|
function requireEnumBugKeys () {
|
|
if (hasRequiredEnumBugKeys) return enumBugKeys;
|
|
hasRequiredEnumBugKeys = 1;
|
|
// IE8- don't enum bug keys
|
|
enumBugKeys = [
|
|
'constructor',
|
|
'hasOwnProperty',
|
|
'isPrototypeOf',
|
|
'propertyIsEnumerable',
|
|
'toLocaleString',
|
|
'toString',
|
|
'valueOf'
|
|
];
|
|
return enumBugKeys;
|
|
}
|
|
|
|
var hasRequiredObjectGetOwnPropertyNames;
|
|
|
|
function requireObjectGetOwnPropertyNames () {
|
|
if (hasRequiredObjectGetOwnPropertyNames) return objectGetOwnPropertyNames;
|
|
hasRequiredObjectGetOwnPropertyNames = 1;
|
|
var internalObjectKeys = requireObjectKeysInternal();
|
|
var enumBugKeys = requireEnumBugKeys();
|
|
|
|
var hiddenKeys = enumBugKeys.concat('length', 'prototype');
|
|
|
|
// `Object.getOwnPropertyNames` method
|
|
// https://tc39.es/ecma262/#sec-object.getownpropertynames
|
|
// eslint-disable-next-line es/no-object-getownpropertynames -- safe
|
|
objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
|
return internalObjectKeys(O, hiddenKeys);
|
|
};
|
|
return objectGetOwnPropertyNames;
|
|
}
|
|
|
|
var objectGetOwnPropertySymbols = {};
|
|
|
|
var hasRequiredObjectGetOwnPropertySymbols;
|
|
|
|
function requireObjectGetOwnPropertySymbols () {
|
|
if (hasRequiredObjectGetOwnPropertySymbols) return objectGetOwnPropertySymbols;
|
|
hasRequiredObjectGetOwnPropertySymbols = 1;
|
|
// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
|
|
objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
|
|
return objectGetOwnPropertySymbols;
|
|
}
|
|
|
|
var ownKeys;
|
|
var hasRequiredOwnKeys;
|
|
|
|
function requireOwnKeys () {
|
|
if (hasRequiredOwnKeys) return ownKeys;
|
|
hasRequiredOwnKeys = 1;
|
|
var getBuiltIn = requireGetBuiltIn();
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
var getOwnPropertyNamesModule = requireObjectGetOwnPropertyNames();
|
|
var getOwnPropertySymbolsModule = requireObjectGetOwnPropertySymbols();
|
|
var anObject = requireAnObject();
|
|
|
|
var concat = uncurryThis([].concat);
|
|
|
|
// all object keys, includes non-enumerable and symbols
|
|
ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
|
|
var keys = getOwnPropertyNamesModule.f(anObject(it));
|
|
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
|
return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
|
|
};
|
|
return ownKeys;
|
|
}
|
|
|
|
var copyConstructorProperties;
|
|
var hasRequiredCopyConstructorProperties;
|
|
|
|
function requireCopyConstructorProperties () {
|
|
if (hasRequiredCopyConstructorProperties) return copyConstructorProperties;
|
|
hasRequiredCopyConstructorProperties = 1;
|
|
var hasOwn = requireHasOwnProperty();
|
|
var ownKeys = requireOwnKeys();
|
|
var getOwnPropertyDescriptorModule = requireObjectGetOwnPropertyDescriptor();
|
|
var definePropertyModule = requireObjectDefineProperty();
|
|
|
|
copyConstructorProperties = function (target, source, exceptions) {
|
|
var keys = ownKeys(source);
|
|
var defineProperty = definePropertyModule.f;
|
|
var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
|
|
for (var i = 0; i < keys.length; i++) {
|
|
var key = keys[i];
|
|
if (!hasOwn(target, key) && !(exceptions && hasOwn(exceptions, key))) {
|
|
defineProperty(target, key, getOwnPropertyDescriptor(source, key));
|
|
}
|
|
}
|
|
};
|
|
return copyConstructorProperties;
|
|
}
|
|
|
|
var isForced_1;
|
|
var hasRequiredIsForced;
|
|
|
|
function requireIsForced () {
|
|
if (hasRequiredIsForced) return isForced_1;
|
|
hasRequiredIsForced = 1;
|
|
var fails = requireFails();
|
|
var isCallable = requireIsCallable();
|
|
|
|
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';
|
|
|
|
isForced_1 = isForced;
|
|
return isForced_1;
|
|
}
|
|
|
|
var _export;
|
|
var hasRequired_export;
|
|
|
|
function require_export () {
|
|
if (hasRequired_export) return _export;
|
|
hasRequired_export = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var getOwnPropertyDescriptor = requireObjectGetOwnPropertyDescriptor().f;
|
|
var createNonEnumerableProperty = requireCreateNonEnumerableProperty();
|
|
var defineBuiltIn = requireDefineBuiltIn();
|
|
var defineGlobalProperty = requireDefineGlobalProperty();
|
|
var copyConstructorProperties = requireCopyConstructorProperties();
|
|
var isForced = requireIsForced();
|
|
|
|
/*
|
|
options.target - name of the target object
|
|
options.global - target is the global object
|
|
options.stat - export as static methods of target
|
|
options.proto - export as prototype methods of target
|
|
options.real - real prototype method for the `pure` version
|
|
options.forced - export even if the native feature is available
|
|
options.bind - bind methods to the target, required for the `pure` version
|
|
options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
|
|
options.unsafe - use the simple assignment of property instead of delete + defineProperty
|
|
options.sham - add a flag to not completely full polyfills
|
|
options.enumerable - export as enumerable property
|
|
options.dontCallGetSet - prevent calling a getter on target
|
|
options.name - the .name of the function if it does not match the key
|
|
*/
|
|
_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 = globalThis;
|
|
} else if (STATIC) {
|
|
target = globalThis[TARGET] || defineGlobalProperty(TARGET, {});
|
|
} else {
|
|
target = globalThis[TARGET] && globalThis[TARGET].prototype;
|
|
}
|
|
if (target) for (key in source) {
|
|
sourceProperty = source[key];
|
|
if (options.dontCallGetSet) {
|
|
descriptor = getOwnPropertyDescriptor(target, key);
|
|
targetProperty = descriptor && descriptor.value;
|
|
} else targetProperty = target[key];
|
|
FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
|
|
// contained in target
|
|
if (!FORCED && targetProperty !== undefined) {
|
|
if (typeof sourceProperty == typeof targetProperty) continue;
|
|
copyConstructorProperties(sourceProperty, targetProperty);
|
|
}
|
|
// add a flag to not completely full polyfills
|
|
if (options.sham || (targetProperty && targetProperty.sham)) {
|
|
createNonEnumerableProperty(sourceProperty, 'sham', true);
|
|
}
|
|
defineBuiltIn(target, key, sourceProperty, options);
|
|
}
|
|
};
|
|
return _export;
|
|
}
|
|
|
|
var functionUncurryThisClause;
|
|
var hasRequiredFunctionUncurryThisClause;
|
|
|
|
function requireFunctionUncurryThisClause () {
|
|
if (hasRequiredFunctionUncurryThisClause) return functionUncurryThisClause;
|
|
hasRequiredFunctionUncurryThisClause = 1;
|
|
var classofRaw = requireClassofRaw();
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
|
|
functionUncurryThisClause = function (fn) {
|
|
// Nashorn bug:
|
|
// https://github.com/zloirock/core-js/issues/1128
|
|
// https://github.com/zloirock/core-js/issues/1130
|
|
if (classofRaw(fn) === 'Function') return uncurryThis(fn);
|
|
};
|
|
return functionUncurryThisClause;
|
|
}
|
|
|
|
var functionBindContext;
|
|
var hasRequiredFunctionBindContext;
|
|
|
|
function requireFunctionBindContext () {
|
|
if (hasRequiredFunctionBindContext) return functionBindContext;
|
|
hasRequiredFunctionBindContext = 1;
|
|
var uncurryThis = requireFunctionUncurryThisClause();
|
|
var aCallable = requireACallable();
|
|
var NATIVE_BIND = requireFunctionBindNative();
|
|
|
|
var bind = uncurryThis(uncurryThis.bind);
|
|
|
|
// optional / simple context binding
|
|
functionBindContext = function (fn, that) {
|
|
aCallable(fn);
|
|
return that === undefined ? fn : NATIVE_BIND ? bind(fn, that) : function (/* ...args */) {
|
|
return fn.apply(that, arguments);
|
|
};
|
|
};
|
|
return functionBindContext;
|
|
}
|
|
|
|
var iteratorClose;
|
|
var hasRequiredIteratorClose;
|
|
|
|
function requireIteratorClose () {
|
|
if (hasRequiredIteratorClose) return iteratorClose;
|
|
hasRequiredIteratorClose = 1;
|
|
var call = requireFunctionCall();
|
|
var anObject = requireAnObject();
|
|
var getMethod = requireGetMethod();
|
|
|
|
iteratorClose = function (iterator, kind, value) {
|
|
var innerResult, innerError;
|
|
anObject(iterator);
|
|
try {
|
|
innerResult = getMethod(iterator, 'return');
|
|
if (!innerResult) {
|
|
if (kind === 'throw') throw value;
|
|
return value;
|
|
}
|
|
innerResult = call(innerResult, iterator);
|
|
} catch (error) {
|
|
innerError = true;
|
|
innerResult = error;
|
|
}
|
|
if (kind === 'throw') throw value;
|
|
if (innerError) throw innerResult;
|
|
anObject(innerResult);
|
|
return value;
|
|
};
|
|
return iteratorClose;
|
|
}
|
|
|
|
var callWithSafeIterationClosing;
|
|
var hasRequiredCallWithSafeIterationClosing;
|
|
|
|
function requireCallWithSafeIterationClosing () {
|
|
if (hasRequiredCallWithSafeIterationClosing) return callWithSafeIterationClosing;
|
|
hasRequiredCallWithSafeIterationClosing = 1;
|
|
var anObject = requireAnObject();
|
|
var iteratorClose = requireIteratorClose();
|
|
|
|
// call something on iterator step with safe closing on error
|
|
callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
|
|
try {
|
|
return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
|
|
} catch (error) {
|
|
iteratorClose(iterator, 'throw', error);
|
|
}
|
|
};
|
|
return callWithSafeIterationClosing;
|
|
}
|
|
|
|
var iterators;
|
|
var hasRequiredIterators;
|
|
|
|
function requireIterators () {
|
|
if (hasRequiredIterators) return iterators;
|
|
hasRequiredIterators = 1;
|
|
iterators = {};
|
|
return iterators;
|
|
}
|
|
|
|
var isArrayIteratorMethod;
|
|
var hasRequiredIsArrayIteratorMethod;
|
|
|
|
function requireIsArrayIteratorMethod () {
|
|
if (hasRequiredIsArrayIteratorMethod) return isArrayIteratorMethod;
|
|
hasRequiredIsArrayIteratorMethod = 1;
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
var Iterators = requireIterators();
|
|
|
|
var ITERATOR = wellKnownSymbol('iterator');
|
|
var ArrayPrototype = Array.prototype;
|
|
|
|
// check on default Array iterator
|
|
isArrayIteratorMethod = function (it) {
|
|
return it !== undefined && (Iterators.Array === it || ArrayPrototype[ITERATOR] === it);
|
|
};
|
|
return isArrayIteratorMethod;
|
|
}
|
|
|
|
var toStringTagSupport;
|
|
var hasRequiredToStringTagSupport;
|
|
|
|
function requireToStringTagSupport () {
|
|
if (hasRequiredToStringTagSupport) return toStringTagSupport;
|
|
hasRequiredToStringTagSupport = 1;
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
|
|
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
var test = {};
|
|
|
|
test[TO_STRING_TAG] = 'z';
|
|
|
|
toStringTagSupport = String(test) === '[object z]';
|
|
return toStringTagSupport;
|
|
}
|
|
|
|
var classof;
|
|
var hasRequiredClassof;
|
|
|
|
function requireClassof () {
|
|
if (hasRequiredClassof) return classof;
|
|
hasRequiredClassof = 1;
|
|
var TO_STRING_TAG_SUPPORT = requireToStringTagSupport();
|
|
var isCallable = requireIsCallable();
|
|
var classofRaw = requireClassofRaw();
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
|
|
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
var $Object = Object;
|
|
|
|
// ES3 wrong here
|
|
var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
|
|
|
|
// fallback for IE11 Script Access Denied error
|
|
var tryGet = function (it, key) {
|
|
try {
|
|
return it[key];
|
|
} catch (error) { /* empty */ }
|
|
};
|
|
|
|
// getting tag from ES6+ `Object.prototype.toString`
|
|
classof = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
|
|
var O, tag, result;
|
|
return it === undefined ? 'Undefined' : it === null ? 'Null'
|
|
// @@toStringTag case
|
|
: typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
|
|
// builtinTag case
|
|
: CORRECT_ARGUMENTS ? classofRaw(O)
|
|
// ES3 arguments fallback
|
|
: (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
|
|
};
|
|
return classof;
|
|
}
|
|
|
|
var isConstructor;
|
|
var hasRequiredIsConstructor;
|
|
|
|
function requireIsConstructor () {
|
|
if (hasRequiredIsConstructor) return isConstructor;
|
|
hasRequiredIsConstructor = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
var fails = requireFails();
|
|
var isCallable = requireIsCallable();
|
|
var classof = requireClassof();
|
|
var getBuiltIn = requireGetBuiltIn();
|
|
var inspectSource = requireInspectSource();
|
|
|
|
var noop = function () { /* empty */ };
|
|
var construct = getBuiltIn('Reflect', 'construct');
|
|
var constructorRegExp = /^\s*(?:class|function)\b/;
|
|
var exec = uncurryThis(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 {
|
|
// we can't check .prototype since constructors produced by .bind haven't it
|
|
// `Function#toString` throws on some built-it function in some legacy engines
|
|
// (for example, `DOMQuad` and similar in FF41-)
|
|
return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource(argument));
|
|
} catch (error) {
|
|
return true;
|
|
}
|
|
};
|
|
|
|
isConstructorLegacy.sham = true;
|
|
|
|
// `IsConstructor` abstract operation
|
|
// https://tc39.es/ecma262/#sec-isconstructor
|
|
isConstructor = !construct || fails(function () {
|
|
var called;
|
|
return isConstructorModern(isConstructorModern.call)
|
|
|| !isConstructorModern(Object)
|
|
|| !isConstructorModern(function () { called = true; })
|
|
|| called;
|
|
}) ? isConstructorLegacy : isConstructorModern;
|
|
return isConstructor;
|
|
}
|
|
|
|
var createProperty;
|
|
var hasRequiredCreateProperty;
|
|
|
|
function requireCreateProperty () {
|
|
if (hasRequiredCreateProperty) return createProperty;
|
|
hasRequiredCreateProperty = 1;
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var definePropertyModule = requireObjectDefineProperty();
|
|
var createPropertyDescriptor = requireCreatePropertyDescriptor();
|
|
|
|
createProperty = function (object, key, value) {
|
|
if (DESCRIPTORS) definePropertyModule.f(object, key, createPropertyDescriptor(0, value));
|
|
else object[key] = value;
|
|
};
|
|
return createProperty;
|
|
}
|
|
|
|
var getIteratorMethod;
|
|
var hasRequiredGetIteratorMethod;
|
|
|
|
function requireGetIteratorMethod () {
|
|
if (hasRequiredGetIteratorMethod) return getIteratorMethod;
|
|
hasRequiredGetIteratorMethod = 1;
|
|
var classof = requireClassof();
|
|
var getMethod = requireGetMethod();
|
|
var isNullOrUndefined = requireIsNullOrUndefined();
|
|
var Iterators = requireIterators();
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
|
|
var ITERATOR = wellKnownSymbol('iterator');
|
|
|
|
getIteratorMethod = function (it) {
|
|
if (!isNullOrUndefined(it)) return getMethod(it, ITERATOR)
|
|
|| getMethod(it, '@@iterator')
|
|
|| Iterators[classof(it)];
|
|
};
|
|
return getIteratorMethod;
|
|
}
|
|
|
|
var getIterator;
|
|
var hasRequiredGetIterator;
|
|
|
|
function requireGetIterator () {
|
|
if (hasRequiredGetIterator) return getIterator;
|
|
hasRequiredGetIterator = 1;
|
|
var call = requireFunctionCall();
|
|
var aCallable = requireACallable();
|
|
var anObject = requireAnObject();
|
|
var tryToString = requireTryToString();
|
|
var getIteratorMethod = requireGetIteratorMethod();
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
getIterator = function (argument, usingIterator) {
|
|
var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator;
|
|
if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument));
|
|
throw new $TypeError(tryToString(argument) + ' is not iterable');
|
|
};
|
|
return getIterator;
|
|
}
|
|
|
|
var arrayFrom;
|
|
var hasRequiredArrayFrom;
|
|
|
|
function requireArrayFrom () {
|
|
if (hasRequiredArrayFrom) return arrayFrom;
|
|
hasRequiredArrayFrom = 1;
|
|
var bind = requireFunctionBindContext();
|
|
var call = requireFunctionCall();
|
|
var toObject = requireToObject();
|
|
var callWithSafeIterationClosing = requireCallWithSafeIterationClosing();
|
|
var isArrayIteratorMethod = requireIsArrayIteratorMethod();
|
|
var isConstructor = requireIsConstructor();
|
|
var lengthOfArrayLike = requireLengthOfArrayLike();
|
|
var createProperty = requireCreateProperty();
|
|
var getIterator = requireGetIterator();
|
|
var getIteratorMethod = requireGetIteratorMethod();
|
|
|
|
var $Array = Array;
|
|
|
|
// `Array.from` method implementation
|
|
// https://tc39.es/ecma262/#sec-array.from
|
|
arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
|
|
var O = toObject(arrayLike);
|
|
var IS_CONSTRUCTOR = isConstructor(this);
|
|
var argumentsLength = arguments.length;
|
|
var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
|
|
var mapping = mapfn !== undefined;
|
|
if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
|
|
var iteratorMethod = getIteratorMethod(O);
|
|
var index = 0;
|
|
var length, result, step, iterator, next, value;
|
|
// if the target is not iterable or it's an array with the default iterator - use a simple case
|
|
if (iteratorMethod && !(this === $Array && isArrayIteratorMethod(iteratorMethod))) {
|
|
result = IS_CONSTRUCTOR ? new this() : [];
|
|
iterator = getIterator(O, iteratorMethod);
|
|
next = iterator.next;
|
|
for (;!(step = call(next, iterator)).done; index++) {
|
|
value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
|
|
createProperty(result, index, value);
|
|
}
|
|
} else {
|
|
length = lengthOfArrayLike(O);
|
|
result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
|
|
for (;length > index; index++) {
|
|
value = mapping ? mapfn(O[index], index) : O[index];
|
|
createProperty(result, index, value);
|
|
}
|
|
}
|
|
result.length = index;
|
|
return result;
|
|
};
|
|
return arrayFrom;
|
|
}
|
|
|
|
var checkCorrectnessOfIteration;
|
|
var hasRequiredCheckCorrectnessOfIteration;
|
|
|
|
function requireCheckCorrectnessOfIteration () {
|
|
if (hasRequiredCheckCorrectnessOfIteration) return checkCorrectnessOfIteration;
|
|
hasRequiredCheckCorrectnessOfIteration = 1;
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
|
|
var ITERATOR = wellKnownSymbol('iterator');
|
|
var SAFE_CLOSING = false;
|
|
|
|
try {
|
|
var called = 0;
|
|
var iteratorWithReturn = {
|
|
next: function () {
|
|
return { done: !!called++ };
|
|
},
|
|
'return': function () {
|
|
SAFE_CLOSING = true;
|
|
}
|
|
};
|
|
iteratorWithReturn[ITERATOR] = function () {
|
|
return this;
|
|
};
|
|
// eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
|
|
Array.from(iteratorWithReturn, function () { throw 2; });
|
|
} catch (error) { /* empty */ }
|
|
|
|
checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
|
|
try {
|
|
if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
|
|
} catch (error) { return false; } // workaround of old WebKit + `eval` bug
|
|
var ITERATION_SUPPORT = false;
|
|
try {
|
|
var object = {};
|
|
object[ITERATOR] = function () {
|
|
return {
|
|
next: function () {
|
|
return { done: ITERATION_SUPPORT = true };
|
|
}
|
|
};
|
|
};
|
|
exec(object);
|
|
} catch (error) { /* empty */ }
|
|
return ITERATION_SUPPORT;
|
|
};
|
|
return checkCorrectnessOfIteration;
|
|
}
|
|
|
|
var hasRequiredEs_array_from;
|
|
|
|
function requireEs_array_from () {
|
|
if (hasRequiredEs_array_from) return es_array_from;
|
|
hasRequiredEs_array_from = 1;
|
|
var $ = require_export();
|
|
var from = requireArrayFrom();
|
|
var checkCorrectnessOfIteration = requireCheckCorrectnessOfIteration();
|
|
|
|
var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
|
|
// eslint-disable-next-line es/no-array-from -- required for testing
|
|
Array.from(iterable);
|
|
});
|
|
|
|
// `Array.from` method
|
|
// https://tc39.es/ecma262/#sec-array.from
|
|
$({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
|
|
from: from
|
|
});
|
|
return es_array_from;
|
|
}
|
|
|
|
requireEs_array_from();
|
|
|
|
var es_promise = {};
|
|
|
|
var es_promise_constructor = {};
|
|
|
|
var environment;
|
|
var hasRequiredEnvironment;
|
|
|
|
function requireEnvironment () {
|
|
if (hasRequiredEnvironment) return environment;
|
|
hasRequiredEnvironment = 1;
|
|
/* global Bun, Deno -- detection */
|
|
var globalThis = requireGlobalThis();
|
|
var userAgent = requireEnvironmentUserAgent();
|
|
var classof = requireClassofRaw();
|
|
|
|
var userAgentStartsWith = function (string) {
|
|
return userAgent.slice(0, string.length) === string;
|
|
};
|
|
|
|
environment = (function () {
|
|
if (userAgentStartsWith('Bun/')) return 'BUN';
|
|
if (userAgentStartsWith('Cloudflare-Workers')) return 'CLOUDFLARE';
|
|
if (userAgentStartsWith('Deno/')) return 'DENO';
|
|
if (userAgentStartsWith('Node.js/')) return 'NODE';
|
|
if (globalThis.Bun && typeof Bun.version == 'string') return 'BUN';
|
|
if (globalThis.Deno && typeof Deno.version == 'object') return 'DENO';
|
|
if (classof(globalThis.process) === 'process') return 'NODE';
|
|
if (globalThis.window && globalThis.document) return 'BROWSER';
|
|
return 'REST';
|
|
})();
|
|
return environment;
|
|
}
|
|
|
|
var environmentIsNode;
|
|
var hasRequiredEnvironmentIsNode;
|
|
|
|
function requireEnvironmentIsNode () {
|
|
if (hasRequiredEnvironmentIsNode) return environmentIsNode;
|
|
hasRequiredEnvironmentIsNode = 1;
|
|
var ENVIRONMENT = requireEnvironment();
|
|
|
|
environmentIsNode = ENVIRONMENT === 'NODE';
|
|
return environmentIsNode;
|
|
}
|
|
|
|
var path;
|
|
var hasRequiredPath;
|
|
|
|
function requirePath () {
|
|
if (hasRequiredPath) return path;
|
|
hasRequiredPath = 1;
|
|
var globalThis = requireGlobalThis();
|
|
|
|
path = globalThis;
|
|
return path;
|
|
}
|
|
|
|
var functionUncurryThisAccessor;
|
|
var hasRequiredFunctionUncurryThisAccessor;
|
|
|
|
function requireFunctionUncurryThisAccessor () {
|
|
if (hasRequiredFunctionUncurryThisAccessor) return functionUncurryThisAccessor;
|
|
hasRequiredFunctionUncurryThisAccessor = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
var aCallable = requireACallable();
|
|
|
|
functionUncurryThisAccessor = function (object, key, method) {
|
|
try {
|
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
return uncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method]));
|
|
} catch (error) { /* empty */ }
|
|
};
|
|
return functionUncurryThisAccessor;
|
|
}
|
|
|
|
var isPossiblePrototype;
|
|
var hasRequiredIsPossiblePrototype;
|
|
|
|
function requireIsPossiblePrototype () {
|
|
if (hasRequiredIsPossiblePrototype) return isPossiblePrototype;
|
|
hasRequiredIsPossiblePrototype = 1;
|
|
var isObject = requireIsObject();
|
|
|
|
isPossiblePrototype = function (argument) {
|
|
return isObject(argument) || argument === null;
|
|
};
|
|
return isPossiblePrototype;
|
|
}
|
|
|
|
var aPossiblePrototype;
|
|
var hasRequiredAPossiblePrototype;
|
|
|
|
function requireAPossiblePrototype () {
|
|
if (hasRequiredAPossiblePrototype) return aPossiblePrototype;
|
|
hasRequiredAPossiblePrototype = 1;
|
|
var isPossiblePrototype = requireIsPossiblePrototype();
|
|
|
|
var $String = String;
|
|
var $TypeError = TypeError;
|
|
|
|
aPossiblePrototype = function (argument) {
|
|
if (isPossiblePrototype(argument)) return argument;
|
|
throw new $TypeError("Can't set " + $String(argument) + ' as a prototype');
|
|
};
|
|
return aPossiblePrototype;
|
|
}
|
|
|
|
var objectSetPrototypeOf;
|
|
var hasRequiredObjectSetPrototypeOf;
|
|
|
|
function requireObjectSetPrototypeOf () {
|
|
if (hasRequiredObjectSetPrototypeOf) return objectSetPrototypeOf;
|
|
hasRequiredObjectSetPrototypeOf = 1;
|
|
/* eslint-disable no-proto -- safe */
|
|
var uncurryThisAccessor = requireFunctionUncurryThisAccessor();
|
|
var isObject = requireIsObject();
|
|
var requireObjectCoercible = requireRequireObjectCoercible();
|
|
var aPossiblePrototype = requireAPossiblePrototype();
|
|
|
|
// `Object.setPrototypeOf` method
|
|
// https://tc39.es/ecma262/#sec-object.setprototypeof
|
|
// Works with __proto__ only. Old v8 can't work with null proto objects.
|
|
// eslint-disable-next-line es/no-object-setprototypeof -- safe
|
|
objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
|
|
var CORRECT_SETTER = false;
|
|
var test = {};
|
|
var setter;
|
|
try {
|
|
setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
|
|
setter(test, []);
|
|
CORRECT_SETTER = test instanceof Array;
|
|
} catch (error) { /* empty */ }
|
|
return function setPrototypeOf(O, proto) {
|
|
requireObjectCoercible(O);
|
|
aPossiblePrototype(proto);
|
|
if (!isObject(O)) return O;
|
|
if (CORRECT_SETTER) setter(O, proto);
|
|
else O.__proto__ = proto;
|
|
return O;
|
|
};
|
|
}() : undefined);
|
|
return objectSetPrototypeOf;
|
|
}
|
|
|
|
var setToStringTag;
|
|
var hasRequiredSetToStringTag;
|
|
|
|
function requireSetToStringTag () {
|
|
if (hasRequiredSetToStringTag) return setToStringTag;
|
|
hasRequiredSetToStringTag = 1;
|
|
var defineProperty = requireObjectDefineProperty().f;
|
|
var hasOwn = requireHasOwnProperty();
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
|
|
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
|
|
setToStringTag = function (target, TAG, STATIC) {
|
|
if (target && !STATIC) target = target.prototype;
|
|
if (target && !hasOwn(target, TO_STRING_TAG)) {
|
|
defineProperty(target, TO_STRING_TAG, { configurable: true, value: TAG });
|
|
}
|
|
};
|
|
return setToStringTag;
|
|
}
|
|
|
|
var defineBuiltInAccessor;
|
|
var hasRequiredDefineBuiltInAccessor;
|
|
|
|
function requireDefineBuiltInAccessor () {
|
|
if (hasRequiredDefineBuiltInAccessor) return defineBuiltInAccessor;
|
|
hasRequiredDefineBuiltInAccessor = 1;
|
|
var makeBuiltIn = requireMakeBuiltIn();
|
|
var defineProperty = requireObjectDefineProperty();
|
|
|
|
defineBuiltInAccessor = function (target, name, descriptor) {
|
|
if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
|
|
if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
|
|
return defineProperty.f(target, name, descriptor);
|
|
};
|
|
return defineBuiltInAccessor;
|
|
}
|
|
|
|
var setSpecies;
|
|
var hasRequiredSetSpecies;
|
|
|
|
function requireSetSpecies () {
|
|
if (hasRequiredSetSpecies) return setSpecies;
|
|
hasRequiredSetSpecies = 1;
|
|
var getBuiltIn = requireGetBuiltIn();
|
|
var defineBuiltInAccessor = requireDefineBuiltInAccessor();
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
var DESCRIPTORS = requireDescriptors();
|
|
|
|
var SPECIES = wellKnownSymbol('species');
|
|
|
|
setSpecies = function (CONSTRUCTOR_NAME) {
|
|
var Constructor = getBuiltIn(CONSTRUCTOR_NAME);
|
|
|
|
if (DESCRIPTORS && Constructor && !Constructor[SPECIES]) {
|
|
defineBuiltInAccessor(Constructor, SPECIES, {
|
|
configurable: true,
|
|
get: function () { return this; }
|
|
});
|
|
}
|
|
};
|
|
return setSpecies;
|
|
}
|
|
|
|
var anInstance;
|
|
var hasRequiredAnInstance;
|
|
|
|
function requireAnInstance () {
|
|
if (hasRequiredAnInstance) return anInstance;
|
|
hasRequiredAnInstance = 1;
|
|
var isPrototypeOf = requireObjectIsPrototypeOf();
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
anInstance = function (it, Prototype) {
|
|
if (isPrototypeOf(Prototype, it)) return it;
|
|
throw new $TypeError('Incorrect invocation');
|
|
};
|
|
return anInstance;
|
|
}
|
|
|
|
var aConstructor;
|
|
var hasRequiredAConstructor;
|
|
|
|
function requireAConstructor () {
|
|
if (hasRequiredAConstructor) return aConstructor;
|
|
hasRequiredAConstructor = 1;
|
|
var isConstructor = requireIsConstructor();
|
|
var tryToString = requireTryToString();
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
// `Assert: IsConstructor(argument) is true`
|
|
aConstructor = function (argument) {
|
|
if (isConstructor(argument)) return argument;
|
|
throw new $TypeError(tryToString(argument) + ' is not a constructor');
|
|
};
|
|
return aConstructor;
|
|
}
|
|
|
|
var speciesConstructor;
|
|
var hasRequiredSpeciesConstructor;
|
|
|
|
function requireSpeciesConstructor () {
|
|
if (hasRequiredSpeciesConstructor) return speciesConstructor;
|
|
hasRequiredSpeciesConstructor = 1;
|
|
var anObject = requireAnObject();
|
|
var aConstructor = requireAConstructor();
|
|
var isNullOrUndefined = requireIsNullOrUndefined();
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
|
|
var SPECIES = wellKnownSymbol('species');
|
|
|
|
// `SpeciesConstructor` abstract operation
|
|
// https://tc39.es/ecma262/#sec-speciesconstructor
|
|
speciesConstructor = function (O, defaultConstructor) {
|
|
var C = anObject(O).constructor;
|
|
var S;
|
|
return C === undefined || isNullOrUndefined(S = anObject(C)[SPECIES]) ? defaultConstructor : aConstructor(S);
|
|
};
|
|
return speciesConstructor;
|
|
}
|
|
|
|
var functionApply;
|
|
var hasRequiredFunctionApply;
|
|
|
|
function requireFunctionApply () {
|
|
if (hasRequiredFunctionApply) return functionApply;
|
|
hasRequiredFunctionApply = 1;
|
|
var NATIVE_BIND = requireFunctionBindNative();
|
|
|
|
var FunctionPrototype = Function.prototype;
|
|
var apply = FunctionPrototype.apply;
|
|
var call = FunctionPrototype.call;
|
|
|
|
// eslint-disable-next-line es/no-function-prototype-bind, es/no-reflect -- safe
|
|
functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply) : function () {
|
|
return call.apply(apply, arguments);
|
|
});
|
|
return functionApply;
|
|
}
|
|
|
|
var html;
|
|
var hasRequiredHtml;
|
|
|
|
function requireHtml () {
|
|
if (hasRequiredHtml) return html;
|
|
hasRequiredHtml = 1;
|
|
var getBuiltIn = requireGetBuiltIn();
|
|
|
|
html = getBuiltIn('document', 'documentElement');
|
|
return html;
|
|
}
|
|
|
|
var arraySlice;
|
|
var hasRequiredArraySlice;
|
|
|
|
function requireArraySlice () {
|
|
if (hasRequiredArraySlice) return arraySlice;
|
|
hasRequiredArraySlice = 1;
|
|
var uncurryThis = requireFunctionUncurryThis();
|
|
|
|
arraySlice = uncurryThis([].slice);
|
|
return arraySlice;
|
|
}
|
|
|
|
var validateArgumentsLength;
|
|
var hasRequiredValidateArgumentsLength;
|
|
|
|
function requireValidateArgumentsLength () {
|
|
if (hasRequiredValidateArgumentsLength) return validateArgumentsLength;
|
|
hasRequiredValidateArgumentsLength = 1;
|
|
var $TypeError = TypeError;
|
|
|
|
validateArgumentsLength = function (passed, required) {
|
|
if (passed < required) throw new $TypeError('Not enough arguments');
|
|
return passed;
|
|
};
|
|
return validateArgumentsLength;
|
|
}
|
|
|
|
var environmentIsIos;
|
|
var hasRequiredEnvironmentIsIos;
|
|
|
|
function requireEnvironmentIsIos () {
|
|
if (hasRequiredEnvironmentIsIos) return environmentIsIos;
|
|
hasRequiredEnvironmentIsIos = 1;
|
|
var userAgent = requireEnvironmentUserAgent();
|
|
|
|
// eslint-disable-next-line redos/no-vulnerable -- safe
|
|
environmentIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
|
|
return environmentIsIos;
|
|
}
|
|
|
|
var task;
|
|
var hasRequiredTask;
|
|
|
|
function requireTask () {
|
|
if (hasRequiredTask) return task;
|
|
hasRequiredTask = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var apply = requireFunctionApply();
|
|
var bind = requireFunctionBindContext();
|
|
var isCallable = requireIsCallable();
|
|
var hasOwn = requireHasOwnProperty();
|
|
var fails = requireFails();
|
|
var html = requireHtml();
|
|
var arraySlice = requireArraySlice();
|
|
var createElement = requireDocumentCreateElement();
|
|
var validateArgumentsLength = requireValidateArgumentsLength();
|
|
var IS_IOS = requireEnvironmentIsIos();
|
|
var IS_NODE = requireEnvironmentIsNode();
|
|
|
|
var set = globalThis.setImmediate;
|
|
var clear = globalThis.clearImmediate;
|
|
var process = globalThis.process;
|
|
var Dispatch = globalThis.Dispatch;
|
|
var Function = globalThis.Function;
|
|
var MessageChannel = globalThis.MessageChannel;
|
|
var String = globalThis.String;
|
|
var counter = 0;
|
|
var queue = {};
|
|
var ONREADYSTATECHANGE = 'onreadystatechange';
|
|
var $location, defer, channel, port;
|
|
|
|
fails(function () {
|
|
// Deno throws a ReferenceError on `location` access without `--location` flag
|
|
$location = globalThis.location;
|
|
});
|
|
|
|
var run = function (id) {
|
|
if (hasOwn(queue, id)) {
|
|
var fn = queue[id];
|
|
delete queue[id];
|
|
fn();
|
|
}
|
|
};
|
|
|
|
var runner = function (id) {
|
|
return function () {
|
|
run(id);
|
|
};
|
|
};
|
|
|
|
var eventListener = function (event) {
|
|
run(event.data);
|
|
};
|
|
|
|
var globalPostMessageDefer = function (id) {
|
|
// old engines have not location.origin
|
|
globalThis.postMessage(String(id), $location.protocol + '//' + $location.host);
|
|
};
|
|
|
|
// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
|
|
if (!set || !clear) {
|
|
set = function setImmediate(handler) {
|
|
validateArgumentsLength(arguments.length, 1);
|
|
var fn = isCallable(handler) ? handler : Function(handler);
|
|
var args = arraySlice(arguments, 1);
|
|
queue[++counter] = function () {
|
|
apply(fn, undefined, args);
|
|
};
|
|
defer(counter);
|
|
return counter;
|
|
};
|
|
clear = function clearImmediate(id) {
|
|
delete queue[id];
|
|
};
|
|
// Node.js 0.8-
|
|
if (IS_NODE) {
|
|
defer = function (id) {
|
|
process.nextTick(runner(id));
|
|
};
|
|
// Sphere (JS game engine) Dispatch API
|
|
} else if (Dispatch && Dispatch.now) {
|
|
defer = function (id) {
|
|
Dispatch.now(runner(id));
|
|
};
|
|
// Browsers with MessageChannel, includes WebWorkers
|
|
// except iOS - https://github.com/zloirock/core-js/issues/624
|
|
} else if (MessageChannel && !IS_IOS) {
|
|
channel = new MessageChannel();
|
|
port = channel.port2;
|
|
channel.port1.onmessage = eventListener;
|
|
defer = bind(port.postMessage, port);
|
|
// Browsers with postMessage, skip WebWorkers
|
|
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
|
|
} else if (
|
|
globalThis.addEventListener &&
|
|
isCallable(globalThis.postMessage) &&
|
|
!globalThis.importScripts &&
|
|
$location && $location.protocol !== 'file:' &&
|
|
!fails(globalPostMessageDefer)
|
|
) {
|
|
defer = globalPostMessageDefer;
|
|
globalThis.addEventListener('message', eventListener, false);
|
|
// IE8-
|
|
} else if (ONREADYSTATECHANGE in createElement('script')) {
|
|
defer = function (id) {
|
|
html.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
|
|
html.removeChild(this);
|
|
run(id);
|
|
};
|
|
};
|
|
// Rest old browsers
|
|
} else {
|
|
defer = function (id) {
|
|
setTimeout(runner(id), 0);
|
|
};
|
|
}
|
|
}
|
|
|
|
task = {
|
|
set: set,
|
|
clear: clear
|
|
};
|
|
return task;
|
|
}
|
|
|
|
var safeGetBuiltIn;
|
|
var hasRequiredSafeGetBuiltIn;
|
|
|
|
function requireSafeGetBuiltIn () {
|
|
if (hasRequiredSafeGetBuiltIn) return safeGetBuiltIn;
|
|
hasRequiredSafeGetBuiltIn = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var DESCRIPTORS = requireDescriptors();
|
|
|
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
|
|
// Avoid NodeJS experimental warning
|
|
safeGetBuiltIn = function (name) {
|
|
if (!DESCRIPTORS) return globalThis[name];
|
|
var descriptor = getOwnPropertyDescriptor(globalThis, name);
|
|
return descriptor && descriptor.value;
|
|
};
|
|
return safeGetBuiltIn;
|
|
}
|
|
|
|
var queue;
|
|
var hasRequiredQueue;
|
|
|
|
function requireQueue () {
|
|
if (hasRequiredQueue) return queue;
|
|
hasRequiredQueue = 1;
|
|
var Queue = function () {
|
|
this.head = null;
|
|
this.tail = null;
|
|
};
|
|
|
|
Queue.prototype = {
|
|
add: function (item) {
|
|
var entry = { item: item, next: null };
|
|
var tail = this.tail;
|
|
if (tail) tail.next = entry;
|
|
else this.head = entry;
|
|
this.tail = entry;
|
|
},
|
|
get: function () {
|
|
var entry = this.head;
|
|
if (entry) {
|
|
var next = this.head = entry.next;
|
|
if (next === null) this.tail = null;
|
|
return entry.item;
|
|
}
|
|
}
|
|
};
|
|
|
|
queue = Queue;
|
|
return queue;
|
|
}
|
|
|
|
var environmentIsIosPebble;
|
|
var hasRequiredEnvironmentIsIosPebble;
|
|
|
|
function requireEnvironmentIsIosPebble () {
|
|
if (hasRequiredEnvironmentIsIosPebble) return environmentIsIosPebble;
|
|
hasRequiredEnvironmentIsIosPebble = 1;
|
|
var userAgent = requireEnvironmentUserAgent();
|
|
|
|
environmentIsIosPebble = /ipad|iphone|ipod/i.test(userAgent) && typeof Pebble != 'undefined';
|
|
return environmentIsIosPebble;
|
|
}
|
|
|
|
var environmentIsWebosWebkit;
|
|
var hasRequiredEnvironmentIsWebosWebkit;
|
|
|
|
function requireEnvironmentIsWebosWebkit () {
|
|
if (hasRequiredEnvironmentIsWebosWebkit) return environmentIsWebosWebkit;
|
|
hasRequiredEnvironmentIsWebosWebkit = 1;
|
|
var userAgent = requireEnvironmentUserAgent();
|
|
|
|
environmentIsWebosWebkit = /web0s(?!.*chrome)/i.test(userAgent);
|
|
return environmentIsWebosWebkit;
|
|
}
|
|
|
|
var microtask_1;
|
|
var hasRequiredMicrotask;
|
|
|
|
function requireMicrotask () {
|
|
if (hasRequiredMicrotask) return microtask_1;
|
|
hasRequiredMicrotask = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var safeGetBuiltIn = requireSafeGetBuiltIn();
|
|
var bind = requireFunctionBindContext();
|
|
var macrotask = requireTask().set;
|
|
var Queue = requireQueue();
|
|
var IS_IOS = requireEnvironmentIsIos();
|
|
var IS_IOS_PEBBLE = requireEnvironmentIsIosPebble();
|
|
var IS_WEBOS_WEBKIT = requireEnvironmentIsWebosWebkit();
|
|
var IS_NODE = requireEnvironmentIsNode();
|
|
|
|
var MutationObserver = globalThis.MutationObserver || globalThis.WebKitMutationObserver;
|
|
var document = globalThis.document;
|
|
var process = globalThis.process;
|
|
var Promise = globalThis.Promise;
|
|
var microtask = safeGetBuiltIn('queueMicrotask');
|
|
var notify, toggle, node, promise, then;
|
|
|
|
// modern engines have queueMicrotask method
|
|
if (!microtask) {
|
|
var queue = new Queue();
|
|
|
|
var flush = function () {
|
|
var parent, fn;
|
|
if (IS_NODE && (parent = process.domain)) parent.exit();
|
|
while (fn = queue.get()) try {
|
|
fn();
|
|
} catch (error) {
|
|
if (queue.head) notify();
|
|
throw error;
|
|
}
|
|
if (parent) parent.enter();
|
|
};
|
|
|
|
// browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
|
|
// also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
|
|
if (!IS_IOS && !IS_NODE && !IS_WEBOS_WEBKIT && MutationObserver && document) {
|
|
toggle = true;
|
|
node = document.createTextNode('');
|
|
new MutationObserver(flush).observe(node, { characterData: true });
|
|
notify = function () {
|
|
node.data = toggle = !toggle;
|
|
};
|
|
// environments with maybe non-completely correct, but existent Promise
|
|
} else if (!IS_IOS_PEBBLE && Promise && Promise.resolve) {
|
|
// Promise.resolve without an argument throws an error in LG WebOS 2
|
|
promise = Promise.resolve(undefined);
|
|
// workaround of WebKit ~ iOS Safari 10.1 bug
|
|
promise.constructor = Promise;
|
|
then = bind(promise.then, promise);
|
|
notify = function () {
|
|
then(flush);
|
|
};
|
|
// Node.js without promises
|
|
} else if (IS_NODE) {
|
|
notify = function () {
|
|
process.nextTick(flush);
|
|
};
|
|
// for other environments - macrotask based on:
|
|
// - setImmediate
|
|
// - MessageChannel
|
|
// - window.postMessage
|
|
// - onreadystatechange
|
|
// - setTimeout
|
|
} else {
|
|
// `webpack` dev server bug on IE global methods - use bind(fn, global)
|
|
macrotask = bind(macrotask, globalThis);
|
|
notify = function () {
|
|
macrotask(flush);
|
|
};
|
|
}
|
|
|
|
microtask = function (fn) {
|
|
if (!queue.head) notify();
|
|
queue.add(fn);
|
|
};
|
|
}
|
|
|
|
microtask_1 = microtask;
|
|
return microtask_1;
|
|
}
|
|
|
|
var hostReportErrors;
|
|
var hasRequiredHostReportErrors;
|
|
|
|
function requireHostReportErrors () {
|
|
if (hasRequiredHostReportErrors) return hostReportErrors;
|
|
hasRequiredHostReportErrors = 1;
|
|
hostReportErrors = function (a, b) {
|
|
try {
|
|
// eslint-disable-next-line no-console -- safe
|
|
arguments.length === 1 ? (void 0) : (void 0);
|
|
} catch (error) { /* empty */ }
|
|
};
|
|
return hostReportErrors;
|
|
}
|
|
|
|
var perform;
|
|
var hasRequiredPerform;
|
|
|
|
function requirePerform () {
|
|
if (hasRequiredPerform) return perform;
|
|
hasRequiredPerform = 1;
|
|
perform = function (exec) {
|
|
try {
|
|
return { error: false, value: exec() };
|
|
} catch (error) {
|
|
return { error: true, value: error };
|
|
}
|
|
};
|
|
return perform;
|
|
}
|
|
|
|
var promiseNativeConstructor;
|
|
var hasRequiredPromiseNativeConstructor;
|
|
|
|
function requirePromiseNativeConstructor () {
|
|
if (hasRequiredPromiseNativeConstructor) return promiseNativeConstructor;
|
|
hasRequiredPromiseNativeConstructor = 1;
|
|
var globalThis = requireGlobalThis();
|
|
|
|
promiseNativeConstructor = globalThis.Promise;
|
|
return promiseNativeConstructor;
|
|
}
|
|
|
|
var promiseConstructorDetection;
|
|
var hasRequiredPromiseConstructorDetection;
|
|
|
|
function requirePromiseConstructorDetection () {
|
|
if (hasRequiredPromiseConstructorDetection) return promiseConstructorDetection;
|
|
hasRequiredPromiseConstructorDetection = 1;
|
|
var globalThis = requireGlobalThis();
|
|
var NativePromiseConstructor = requirePromiseNativeConstructor();
|
|
var isCallable = requireIsCallable();
|
|
var isForced = requireIsForced();
|
|
var inspectSource = requireInspectSource();
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
var ENVIRONMENT = requireEnvironment();
|
|
var IS_PURE = requireIsPure();
|
|
var V8_VERSION = requireEnvironmentV8Version();
|
|
|
|
var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
|
|
var SPECIES = wellKnownSymbol('species');
|
|
var SUBCLASSING = false;
|
|
var NATIVE_PROMISE_REJECTION_EVENT = isCallable(globalThis.PromiseRejectionEvent);
|
|
|
|
var FORCED_PROMISE_CONSTRUCTOR = isForced('Promise', function () {
|
|
var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor);
|
|
var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor);
|
|
// V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
|
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=830565
|
|
// We can't detect it synchronously, so just check versions
|
|
if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
|
|
// We need Promise#{ catch, finally } in the pure version for preventing prototype pollution
|
|
if (IS_PURE && !(NativePromisePrototype['catch'] && NativePromisePrototype['finally'])) return true;
|
|
// We can't use @@species feature detection in V8 since it causes
|
|
// deoptimization and performance degradation
|
|
// https://github.com/zloirock/core-js/issues/679
|
|
if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
|
|
// Detect correctness of subclassing with @@species support
|
|
var promise = new NativePromiseConstructor(function (resolve) { resolve(1); });
|
|
var FakePromise = function (exec) {
|
|
exec(function () { /* empty */ }, function () { /* empty */ });
|
|
};
|
|
var constructor = promise.constructor = {};
|
|
constructor[SPECIES] = FakePromise;
|
|
SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
|
|
if (!SUBCLASSING) return true;
|
|
// Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
|
|
} return !GLOBAL_CORE_JS_PROMISE && (ENVIRONMENT === 'BROWSER' || ENVIRONMENT === 'DENO') && !NATIVE_PROMISE_REJECTION_EVENT;
|
|
});
|
|
|
|
promiseConstructorDetection = {
|
|
CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR,
|
|
REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT,
|
|
SUBCLASSING: SUBCLASSING
|
|
};
|
|
return promiseConstructorDetection;
|
|
}
|
|
|
|
var newPromiseCapability = {};
|
|
|
|
var hasRequiredNewPromiseCapability;
|
|
|
|
function requireNewPromiseCapability () {
|
|
if (hasRequiredNewPromiseCapability) return newPromiseCapability;
|
|
hasRequiredNewPromiseCapability = 1;
|
|
var aCallable = requireACallable();
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
var PromiseCapability = function (C) {
|
|
var resolve, reject;
|
|
this.promise = new C(function ($$resolve, $$reject) {
|
|
if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor');
|
|
resolve = $$resolve;
|
|
reject = $$reject;
|
|
});
|
|
this.resolve = aCallable(resolve);
|
|
this.reject = aCallable(reject);
|
|
};
|
|
|
|
// `NewPromiseCapability` abstract operation
|
|
// https://tc39.es/ecma262/#sec-newpromisecapability
|
|
newPromiseCapability.f = function (C) {
|
|
return new PromiseCapability(C);
|
|
};
|
|
return newPromiseCapability;
|
|
}
|
|
|
|
var hasRequiredEs_promise_constructor;
|
|
|
|
function requireEs_promise_constructor () {
|
|
if (hasRequiredEs_promise_constructor) return es_promise_constructor;
|
|
hasRequiredEs_promise_constructor = 1;
|
|
var $ = require_export();
|
|
var IS_PURE = requireIsPure();
|
|
var IS_NODE = requireEnvironmentIsNode();
|
|
var globalThis = requireGlobalThis();
|
|
var path = requirePath();
|
|
var call = requireFunctionCall();
|
|
var defineBuiltIn = requireDefineBuiltIn();
|
|
var setPrototypeOf = requireObjectSetPrototypeOf();
|
|
var setToStringTag = requireSetToStringTag();
|
|
var setSpecies = requireSetSpecies();
|
|
var aCallable = requireACallable();
|
|
var isCallable = requireIsCallable();
|
|
var isObject = requireIsObject();
|
|
var anInstance = requireAnInstance();
|
|
var speciesConstructor = requireSpeciesConstructor();
|
|
var task = requireTask().set;
|
|
var microtask = requireMicrotask();
|
|
var hostReportErrors = requireHostReportErrors();
|
|
var perform = requirePerform();
|
|
var Queue = requireQueue();
|
|
var InternalStateModule = requireInternalState();
|
|
var NativePromiseConstructor = requirePromiseNativeConstructor();
|
|
var PromiseConstructorDetection = requirePromiseConstructorDetection();
|
|
var newPromiseCapabilityModule = requireNewPromiseCapability();
|
|
|
|
var PROMISE = 'Promise';
|
|
var FORCED_PROMISE_CONSTRUCTOR = PromiseConstructorDetection.CONSTRUCTOR;
|
|
var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
|
|
var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
|
|
var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
|
|
var setInternalState = InternalStateModule.set;
|
|
var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
|
|
var PromiseConstructor = NativePromiseConstructor;
|
|
var PromisePrototype = NativePromisePrototype;
|
|
var TypeError = globalThis.TypeError;
|
|
var document = globalThis.document;
|
|
var process = globalThis.process;
|
|
var newPromiseCapability = newPromiseCapabilityModule.f;
|
|
var newGenericPromiseCapability = newPromiseCapability;
|
|
|
|
var DISPATCH_EVENT = !!(document && document.createEvent && globalThis.dispatchEvent);
|
|
var UNHANDLED_REJECTION = 'unhandledrejection';
|
|
var REJECTION_HANDLED = 'rejectionhandled';
|
|
var PENDING = 0;
|
|
var FULFILLED = 1;
|
|
var REJECTED = 2;
|
|
var HANDLED = 1;
|
|
var UNHANDLED = 2;
|
|
|
|
var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
|
|
|
|
// helpers
|
|
var isThenable = function (it) {
|
|
var then;
|
|
return isObject(it) && isCallable(then = it.then) ? then : false;
|
|
};
|
|
|
|
var callReaction = function (reaction, state) {
|
|
var value = state.value;
|
|
var ok = state.state === FULFILLED;
|
|
var handler = ok ? reaction.ok : reaction.fail;
|
|
var resolve = reaction.resolve;
|
|
var reject = reaction.reject;
|
|
var domain = reaction.domain;
|
|
var result, then, exited;
|
|
try {
|
|
if (handler) {
|
|
if (!ok) {
|
|
if (state.rejection === UNHANDLED) onHandleUnhandled(state);
|
|
state.rejection = HANDLED;
|
|
}
|
|
if (handler === true) result = value;
|
|
else {
|
|
if (domain) domain.enter();
|
|
result = handler(value); // can throw
|
|
if (domain) {
|
|
domain.exit();
|
|
exited = true;
|
|
}
|
|
}
|
|
if (result === reaction.promise) {
|
|
reject(new TypeError('Promise-chain cycle'));
|
|
} else if (then = isThenable(result)) {
|
|
call(then, result, resolve, reject);
|
|
} else resolve(result);
|
|
} else reject(value);
|
|
} catch (error) {
|
|
if (domain && !exited) domain.exit();
|
|
reject(error);
|
|
}
|
|
};
|
|
|
|
var notify = function (state, isReject) {
|
|
if (state.notified) return;
|
|
state.notified = true;
|
|
microtask(function () {
|
|
var reactions = state.reactions;
|
|
var reaction;
|
|
while (reaction = reactions.get()) {
|
|
callReaction(reaction, state);
|
|
}
|
|
state.notified = false;
|
|
if (isReject && !state.rejection) onUnhandled(state);
|
|
});
|
|
};
|
|
|
|
var dispatchEvent = function (name, promise, reason) {
|
|
var event, handler;
|
|
if (DISPATCH_EVENT) {
|
|
event = document.createEvent('Event');
|
|
event.promise = promise;
|
|
event.reason = reason;
|
|
event.initEvent(name, false, true);
|
|
globalThis.dispatchEvent(event);
|
|
} else event = { promise: promise, reason: reason };
|
|
if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = globalThis['on' + name])) handler(event);
|
|
else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
|
|
};
|
|
|
|
var onUnhandled = function (state) {
|
|
call(task, globalThis, function () {
|
|
var promise = state.facade;
|
|
var value = state.value;
|
|
var IS_UNHANDLED = isUnhandled(state);
|
|
var result;
|
|
if (IS_UNHANDLED) {
|
|
result = perform(function () {
|
|
if (IS_NODE) {
|
|
process.emit('unhandledRejection', value, promise);
|
|
} else dispatchEvent(UNHANDLED_REJECTION, promise, value);
|
|
});
|
|
// Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
|
|
state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
|
|
if (result.error) throw result.value;
|
|
}
|
|
});
|
|
};
|
|
|
|
var isUnhandled = function (state) {
|
|
return state.rejection !== HANDLED && !state.parent;
|
|
};
|
|
|
|
var onHandleUnhandled = function (state) {
|
|
call(task, globalThis, function () {
|
|
var promise = state.facade;
|
|
if (IS_NODE) {
|
|
process.emit('rejectionHandled', promise);
|
|
} else dispatchEvent(REJECTION_HANDLED, promise, state.value);
|
|
});
|
|
};
|
|
|
|
var bind = function (fn, state, unwrap) {
|
|
return function (value) {
|
|
fn(state, value, unwrap);
|
|
};
|
|
};
|
|
|
|
var internalReject = function (state, value, unwrap) {
|
|
if (state.done) return;
|
|
state.done = true;
|
|
if (unwrap) state = unwrap;
|
|
state.value = value;
|
|
state.state = REJECTED;
|
|
notify(state, true);
|
|
};
|
|
|
|
var internalResolve = function (state, value, unwrap) {
|
|
if (state.done) return;
|
|
state.done = true;
|
|
if (unwrap) state = unwrap;
|
|
try {
|
|
if (state.facade === value) throw new TypeError("Promise can't be resolved itself");
|
|
var then = isThenable(value);
|
|
if (then) {
|
|
microtask(function () {
|
|
var wrapper = { done: false };
|
|
try {
|
|
call(then, value,
|
|
bind(internalResolve, wrapper, state),
|
|
bind(internalReject, wrapper, state)
|
|
);
|
|
} catch (error) {
|
|
internalReject(wrapper, error, state);
|
|
}
|
|
});
|
|
} else {
|
|
state.value = value;
|
|
state.state = FULFILLED;
|
|
notify(state, false);
|
|
}
|
|
} catch (error) {
|
|
internalReject({ done: false }, error, state);
|
|
}
|
|
};
|
|
|
|
// constructor polyfill
|
|
if (FORCED_PROMISE_CONSTRUCTOR) {
|
|
// 25.4.3.1 Promise(executor)
|
|
PromiseConstructor = function Promise(executor) {
|
|
anInstance(this, PromisePrototype);
|
|
aCallable(executor);
|
|
call(Internal, this);
|
|
var state = getInternalPromiseState(this);
|
|
try {
|
|
executor(bind(internalResolve, state), bind(internalReject, state));
|
|
} catch (error) {
|
|
internalReject(state, error);
|
|
}
|
|
};
|
|
|
|
PromisePrototype = PromiseConstructor.prototype;
|
|
|
|
// eslint-disable-next-line no-unused-vars -- required for `.length`
|
|
Internal = function Promise(executor) {
|
|
setInternalState(this, {
|
|
type: PROMISE,
|
|
done: false,
|
|
notified: false,
|
|
parent: false,
|
|
reactions: new Queue(),
|
|
rejection: false,
|
|
state: PENDING,
|
|
value: null
|
|
});
|
|
};
|
|
|
|
// `Promise.prototype.then` method
|
|
// https://tc39.es/ecma262/#sec-promise.prototype.then
|
|
Internal.prototype = defineBuiltIn(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
|
|
var state = getInternalPromiseState(this);
|
|
var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
|
|
state.parent = true;
|
|
reaction.ok = isCallable(onFulfilled) ? onFulfilled : true;
|
|
reaction.fail = isCallable(onRejected) && onRejected;
|
|
reaction.domain = IS_NODE ? process.domain : undefined;
|
|
if (state.state === PENDING) state.reactions.add(reaction);
|
|
else microtask(function () {
|
|
callReaction(reaction, state);
|
|
});
|
|
return reaction.promise;
|
|
});
|
|
|
|
OwnPromiseCapability = function () {
|
|
var promise = new Internal();
|
|
var state = getInternalPromiseState(promise);
|
|
this.promise = promise;
|
|
this.resolve = bind(internalResolve, state);
|
|
this.reject = bind(internalReject, state);
|
|
};
|
|
|
|
newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
|
|
return C === PromiseConstructor || C === PromiseWrapper
|
|
? new OwnPromiseCapability(C)
|
|
: newGenericPromiseCapability(C);
|
|
};
|
|
|
|
if (!IS_PURE && isCallable(NativePromiseConstructor) && NativePromisePrototype !== Object.prototype) {
|
|
nativeThen = NativePromisePrototype.then;
|
|
|
|
if (!NATIVE_PROMISE_SUBCLASSING) {
|
|
// make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
|
|
defineBuiltIn(NativePromisePrototype, 'then', function then(onFulfilled, onRejected) {
|
|
var that = this;
|
|
return new PromiseConstructor(function (resolve, reject) {
|
|
call(nativeThen, that, resolve, reject);
|
|
}).then(onFulfilled, onRejected);
|
|
// https://github.com/zloirock/core-js/issues/640
|
|
}, { unsafe: true });
|
|
}
|
|
|
|
// make `.constructor === Promise` work for native promise-based APIs
|
|
try {
|
|
delete NativePromisePrototype.constructor;
|
|
} catch (error) { /* empty */ }
|
|
|
|
// make `instanceof Promise` work for native promise-based APIs
|
|
if (setPrototypeOf) {
|
|
setPrototypeOf(NativePromisePrototype, PromisePrototype);
|
|
}
|
|
}
|
|
}
|
|
|
|
// `Promise` constructor
|
|
// https://tc39.es/ecma262/#sec-promise-executor
|
|
$({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
|
|
Promise: PromiseConstructor
|
|
});
|
|
|
|
PromiseWrapper = path.Promise;
|
|
|
|
setToStringTag(PromiseConstructor, PROMISE, false, true);
|
|
setSpecies(PROMISE);
|
|
return es_promise_constructor;
|
|
}
|
|
|
|
var es_promise_all = {};
|
|
|
|
var iterate;
|
|
var hasRequiredIterate;
|
|
|
|
function requireIterate () {
|
|
if (hasRequiredIterate) return iterate;
|
|
hasRequiredIterate = 1;
|
|
var bind = requireFunctionBindContext();
|
|
var call = requireFunctionCall();
|
|
var anObject = requireAnObject();
|
|
var tryToString = requireTryToString();
|
|
var isArrayIteratorMethod = requireIsArrayIteratorMethod();
|
|
var lengthOfArrayLike = requireLengthOfArrayLike();
|
|
var isPrototypeOf = requireObjectIsPrototypeOf();
|
|
var getIterator = requireGetIterator();
|
|
var getIteratorMethod = requireGetIteratorMethod();
|
|
var iteratorClose = requireIteratorClose();
|
|
|
|
var $TypeError = TypeError;
|
|
|
|
var Result = function (stopped, result) {
|
|
this.stopped = stopped;
|
|
this.result = result;
|
|
};
|
|
|
|
var ResultPrototype = Result.prototype;
|
|
|
|
iterate = function (iterable, unboundFunction, options) {
|
|
var that = options && options.that;
|
|
var AS_ENTRIES = !!(options && options.AS_ENTRIES);
|
|
var IS_RECORD = !!(options && options.IS_RECORD);
|
|
var IS_ITERATOR = !!(options && options.IS_ITERATOR);
|
|
var INTERRUPTED = !!(options && options.INTERRUPTED);
|
|
var fn = bind(unboundFunction, that);
|
|
var iterator, iterFn, index, length, result, next, step;
|
|
|
|
var stop = function (condition) {
|
|
if (iterator) iteratorClose(iterator, 'normal');
|
|
return new Result(true, condition);
|
|
};
|
|
|
|
var callFn = function (value) {
|
|
if (AS_ENTRIES) {
|
|
anObject(value);
|
|
return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
|
|
} return INTERRUPTED ? fn(value, stop) : fn(value);
|
|
};
|
|
|
|
if (IS_RECORD) {
|
|
iterator = iterable.iterator;
|
|
} else if (IS_ITERATOR) {
|
|
iterator = iterable;
|
|
} else {
|
|
iterFn = getIteratorMethod(iterable);
|
|
if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable');
|
|
// optimisation for array iterators
|
|
if (isArrayIteratorMethod(iterFn)) {
|
|
for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
|
|
result = callFn(iterable[index]);
|
|
if (result && isPrototypeOf(ResultPrototype, result)) return result;
|
|
} return new Result(false);
|
|
}
|
|
iterator = getIterator(iterable, iterFn);
|
|
}
|
|
|
|
next = IS_RECORD ? iterable.next : iterator.next;
|
|
while (!(step = call(next, iterator)).done) {
|
|
try {
|
|
result = callFn(step.value);
|
|
} catch (error) {
|
|
iteratorClose(iterator, 'throw', error);
|
|
}
|
|
if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
|
|
} return new Result(false);
|
|
};
|
|
return iterate;
|
|
}
|
|
|
|
var promiseStaticsIncorrectIteration;
|
|
var hasRequiredPromiseStaticsIncorrectIteration;
|
|
|
|
function requirePromiseStaticsIncorrectIteration () {
|
|
if (hasRequiredPromiseStaticsIncorrectIteration) return promiseStaticsIncorrectIteration;
|
|
hasRequiredPromiseStaticsIncorrectIteration = 1;
|
|
var NativePromiseConstructor = requirePromiseNativeConstructor();
|
|
var checkCorrectnessOfIteration = requireCheckCorrectnessOfIteration();
|
|
var FORCED_PROMISE_CONSTRUCTOR = requirePromiseConstructorDetection().CONSTRUCTOR;
|
|
|
|
promiseStaticsIncorrectIteration = FORCED_PROMISE_CONSTRUCTOR || !checkCorrectnessOfIteration(function (iterable) {
|
|
NativePromiseConstructor.all(iterable).then(undefined, function () { /* empty */ });
|
|
});
|
|
return promiseStaticsIncorrectIteration;
|
|
}
|
|
|
|
var hasRequiredEs_promise_all;
|
|
|
|
function requireEs_promise_all () {
|
|
if (hasRequiredEs_promise_all) return es_promise_all;
|
|
hasRequiredEs_promise_all = 1;
|
|
var $ = require_export();
|
|
var call = requireFunctionCall();
|
|
var aCallable = requireACallable();
|
|
var newPromiseCapabilityModule = requireNewPromiseCapability();
|
|
var perform = requirePerform();
|
|
var iterate = requireIterate();
|
|
var PROMISE_STATICS_INCORRECT_ITERATION = requirePromiseStaticsIncorrectIteration();
|
|
|
|
// `Promise.all` method
|
|
// https://tc39.es/ecma262/#sec-promise.all
|
|
$({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
|
|
all: function all(iterable) {
|
|
var C = this;
|
|
var capability = newPromiseCapabilityModule.f(C);
|
|
var resolve = capability.resolve;
|
|
var reject = capability.reject;
|
|
var result = perform(function () {
|
|
var $promiseResolve = aCallable(C.resolve);
|
|
var values = [];
|
|
var counter = 0;
|
|
var remaining = 1;
|
|
iterate(iterable, function (promise) {
|
|
var index = counter++;
|
|
var alreadyCalled = false;
|
|
remaining++;
|
|
call($promiseResolve, C, promise).then(function (value) {
|
|
if (alreadyCalled) return;
|
|
alreadyCalled = true;
|
|
values[index] = value;
|
|
--remaining || resolve(values);
|
|
}, reject);
|
|
});
|
|
--remaining || resolve(values);
|
|
});
|
|
if (result.error) reject(result.value);
|
|
return capability.promise;
|
|
}
|
|
});
|
|
return es_promise_all;
|
|
}
|
|
|
|
var es_promise_catch = {};
|
|
|
|
var hasRequiredEs_promise_catch;
|
|
|
|
function requireEs_promise_catch () {
|
|
if (hasRequiredEs_promise_catch) return es_promise_catch;
|
|
hasRequiredEs_promise_catch = 1;
|
|
var $ = require_export();
|
|
var IS_PURE = requireIsPure();
|
|
var FORCED_PROMISE_CONSTRUCTOR = requirePromiseConstructorDetection().CONSTRUCTOR;
|
|
var NativePromiseConstructor = requirePromiseNativeConstructor();
|
|
var getBuiltIn = requireGetBuiltIn();
|
|
var isCallable = requireIsCallable();
|
|
var defineBuiltIn = requireDefineBuiltIn();
|
|
|
|
var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
|
|
|
|
// `Promise.prototype.catch` method
|
|
// https://tc39.es/ecma262/#sec-promise.prototype.catch
|
|
$({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR, real: true }, {
|
|
'catch': function (onRejected) {
|
|
return this.then(undefined, onRejected);
|
|
}
|
|
});
|
|
|
|
// makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
|
|
if (!IS_PURE && isCallable(NativePromiseConstructor)) {
|
|
var method = getBuiltIn('Promise').prototype['catch'];
|
|
if (NativePromisePrototype['catch'] !== method) {
|
|
defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
|
|
}
|
|
}
|
|
return es_promise_catch;
|
|
}
|
|
|
|
var es_promise_race = {};
|
|
|
|
var hasRequiredEs_promise_race;
|
|
|
|
function requireEs_promise_race () {
|
|
if (hasRequiredEs_promise_race) return es_promise_race;
|
|
hasRequiredEs_promise_race = 1;
|
|
var $ = require_export();
|
|
var call = requireFunctionCall();
|
|
var aCallable = requireACallable();
|
|
var newPromiseCapabilityModule = requireNewPromiseCapability();
|
|
var perform = requirePerform();
|
|
var iterate = requireIterate();
|
|
var PROMISE_STATICS_INCORRECT_ITERATION = requirePromiseStaticsIncorrectIteration();
|
|
|
|
// `Promise.race` method
|
|
// https://tc39.es/ecma262/#sec-promise.race
|
|
$({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
|
|
race: function race(iterable) {
|
|
var C = this;
|
|
var capability = newPromiseCapabilityModule.f(C);
|
|
var reject = capability.reject;
|
|
var result = perform(function () {
|
|
var $promiseResolve = aCallable(C.resolve);
|
|
iterate(iterable, function (promise) {
|
|
call($promiseResolve, C, promise).then(capability.resolve, reject);
|
|
});
|
|
});
|
|
if (result.error) reject(result.value);
|
|
return capability.promise;
|
|
}
|
|
});
|
|
return es_promise_race;
|
|
}
|
|
|
|
var es_promise_reject = {};
|
|
|
|
var hasRequiredEs_promise_reject;
|
|
|
|
function requireEs_promise_reject () {
|
|
if (hasRequiredEs_promise_reject) return es_promise_reject;
|
|
hasRequiredEs_promise_reject = 1;
|
|
var $ = require_export();
|
|
var newPromiseCapabilityModule = requireNewPromiseCapability();
|
|
var FORCED_PROMISE_CONSTRUCTOR = requirePromiseConstructorDetection().CONSTRUCTOR;
|
|
|
|
// `Promise.reject` method
|
|
// https://tc39.es/ecma262/#sec-promise.reject
|
|
$({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
|
|
reject: function reject(r) {
|
|
var capability = newPromiseCapabilityModule.f(this);
|
|
var capabilityReject = capability.reject;
|
|
capabilityReject(r);
|
|
return capability.promise;
|
|
}
|
|
});
|
|
return es_promise_reject;
|
|
}
|
|
|
|
var es_promise_resolve = {};
|
|
|
|
var promiseResolve;
|
|
var hasRequiredPromiseResolve;
|
|
|
|
function requirePromiseResolve () {
|
|
if (hasRequiredPromiseResolve) return promiseResolve;
|
|
hasRequiredPromiseResolve = 1;
|
|
var anObject = requireAnObject();
|
|
var isObject = requireIsObject();
|
|
var newPromiseCapability = requireNewPromiseCapability();
|
|
|
|
promiseResolve = function (C, x) {
|
|
anObject(C);
|
|
if (isObject(x) && x.constructor === C) return x;
|
|
var promiseCapability = newPromiseCapability.f(C);
|
|
var resolve = promiseCapability.resolve;
|
|
resolve(x);
|
|
return promiseCapability.promise;
|
|
};
|
|
return promiseResolve;
|
|
}
|
|
|
|
var hasRequiredEs_promise_resolve;
|
|
|
|
function requireEs_promise_resolve () {
|
|
if (hasRequiredEs_promise_resolve) return es_promise_resolve;
|
|
hasRequiredEs_promise_resolve = 1;
|
|
var $ = require_export();
|
|
var getBuiltIn = requireGetBuiltIn();
|
|
var IS_PURE = requireIsPure();
|
|
var NativePromiseConstructor = requirePromiseNativeConstructor();
|
|
var FORCED_PROMISE_CONSTRUCTOR = requirePromiseConstructorDetection().CONSTRUCTOR;
|
|
var promiseResolve = requirePromiseResolve();
|
|
|
|
var PromiseConstructorWrapper = getBuiltIn('Promise');
|
|
var CHECK_WRAPPER = IS_PURE && !FORCED_PROMISE_CONSTRUCTOR;
|
|
|
|
// `Promise.resolve` method
|
|
// https://tc39.es/ecma262/#sec-promise.resolve
|
|
$({ target: 'Promise', stat: true, forced: IS_PURE || FORCED_PROMISE_CONSTRUCTOR }, {
|
|
resolve: function resolve(x) {
|
|
return promiseResolve(CHECK_WRAPPER && this === PromiseConstructorWrapper ? NativePromiseConstructor : this, x);
|
|
}
|
|
});
|
|
return es_promise_resolve;
|
|
}
|
|
|
|
var hasRequiredEs_promise;
|
|
|
|
function requireEs_promise () {
|
|
if (hasRequiredEs_promise) return es_promise;
|
|
hasRequiredEs_promise = 1;
|
|
// TODO: Remove this module from `core-js@4` since it's split to modules listed below
|
|
requireEs_promise_constructor();
|
|
requireEs_promise_all();
|
|
requireEs_promise_catch();
|
|
requireEs_promise_race();
|
|
requireEs_promise_reject();
|
|
requireEs_promise_resolve();
|
|
return es_promise;
|
|
}
|
|
|
|
requireEs_promise();
|
|
|
|
var es_array_includes = {};
|
|
|
|
var objectDefineProperties = {};
|
|
|
|
var objectKeys;
|
|
var hasRequiredObjectKeys;
|
|
|
|
function requireObjectKeys () {
|
|
if (hasRequiredObjectKeys) return objectKeys;
|
|
hasRequiredObjectKeys = 1;
|
|
var internalObjectKeys = requireObjectKeysInternal();
|
|
var enumBugKeys = requireEnumBugKeys();
|
|
|
|
// `Object.keys` method
|
|
// https://tc39.es/ecma262/#sec-object.keys
|
|
// eslint-disable-next-line es/no-object-keys -- safe
|
|
objectKeys = Object.keys || function keys(O) {
|
|
return internalObjectKeys(O, enumBugKeys);
|
|
};
|
|
return objectKeys;
|
|
}
|
|
|
|
var hasRequiredObjectDefineProperties;
|
|
|
|
function requireObjectDefineProperties () {
|
|
if (hasRequiredObjectDefineProperties) return objectDefineProperties;
|
|
hasRequiredObjectDefineProperties = 1;
|
|
var DESCRIPTORS = requireDescriptors();
|
|
var V8_PROTOTYPE_DEFINE_BUG = requireV8PrototypeDefineBug();
|
|
var definePropertyModule = requireObjectDefineProperty();
|
|
var anObject = requireAnObject();
|
|
var toIndexedObject = requireToIndexedObject();
|
|
var objectKeys = requireObjectKeys();
|
|
|
|
// `Object.defineProperties` method
|
|
// https://tc39.es/ecma262/#sec-object.defineproperties
|
|
// eslint-disable-next-line es/no-object-defineproperties -- safe
|
|
objectDefineProperties.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
anObject(O);
|
|
var props = toIndexedObject(Properties);
|
|
var keys = objectKeys(Properties);
|
|
var length = keys.length;
|
|
var index = 0;
|
|
var key;
|
|
while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
|
|
return O;
|
|
};
|
|
return objectDefineProperties;
|
|
}
|
|
|
|
var objectCreate;
|
|
var hasRequiredObjectCreate;
|
|
|
|
function requireObjectCreate () {
|
|
if (hasRequiredObjectCreate) return objectCreate;
|
|
hasRequiredObjectCreate = 1;
|
|
/* global ActiveXObject -- old IE, WSH */
|
|
var anObject = requireAnObject();
|
|
var definePropertiesModule = requireObjectDefineProperties();
|
|
var enumBugKeys = requireEnumBugKeys();
|
|
var hiddenKeys = requireHiddenKeys();
|
|
var html = requireHtml();
|
|
var documentCreateElement = requireDocumentCreateElement();
|
|
var sharedKey = requireSharedKey();
|
|
|
|
var GT = '>';
|
|
var LT = '<';
|
|
var PROTOTYPE = 'prototype';
|
|
var SCRIPT = 'script';
|
|
var IE_PROTO = sharedKey('IE_PROTO');
|
|
|
|
var EmptyConstructor = function () { /* empty */ };
|
|
|
|
var scriptTag = function (content) {
|
|
return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
|
|
};
|
|
|
|
// Create object with fake `null` prototype: use ActiveX Object with cleared prototype
|
|
var NullProtoObjectViaActiveX = function (activeXDocument) {
|
|
activeXDocument.write(scriptTag(''));
|
|
activeXDocument.close();
|
|
var temp = activeXDocument.parentWindow.Object;
|
|
// eslint-disable-next-line no-useless-assignment -- avoid memory leak
|
|
activeXDocument = null;
|
|
return temp;
|
|
};
|
|
|
|
// Create object with fake `null` prototype: use iframe Object with cleared prototype
|
|
var NullProtoObjectViaIFrame = function () {
|
|
// Thrash, waste and sodomy: IE GC bug
|
|
var iframe = documentCreateElement('iframe');
|
|
var JS = 'java' + SCRIPT + ':';
|
|
var iframeDocument;
|
|
iframe.style.display = 'none';
|
|
html.appendChild(iframe);
|
|
// https://github.com/zloirock/core-js/issues/475
|
|
iframe.src = String(JS);
|
|
iframeDocument = iframe.contentWindow.document;
|
|
iframeDocument.open();
|
|
iframeDocument.write(scriptTag('document.F=Object'));
|
|
iframeDocument.close();
|
|
return iframeDocument.F;
|
|
};
|
|
|
|
// Check for document.domain and active x support
|
|
// No need to use active x approach when document.domain is not set
|
|
// see https://github.com/es-shims/es5-shim/issues/150
|
|
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
|
|
// avoid IE GC bug
|
|
var activeXDocument;
|
|
var NullProtoObject = function () {
|
|
try {
|
|
activeXDocument = new ActiveXObject('htmlfile');
|
|
} catch (error) { /* ignore */ }
|
|
NullProtoObject = typeof document != 'undefined'
|
|
? document.domain && activeXDocument
|
|
? NullProtoObjectViaActiveX(activeXDocument) // old IE
|
|
: NullProtoObjectViaIFrame()
|
|
: NullProtoObjectViaActiveX(activeXDocument); // WSH
|
|
var length = enumBugKeys.length;
|
|
while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
|
|
return NullProtoObject();
|
|
};
|
|
|
|
hiddenKeys[IE_PROTO] = true;
|
|
|
|
// `Object.create` method
|
|
// https://tc39.es/ecma262/#sec-object.create
|
|
// eslint-disable-next-line es/no-object-create -- safe
|
|
objectCreate = Object.create || function create(O, Properties) {
|
|
var result;
|
|
if (O !== null) {
|
|
EmptyConstructor[PROTOTYPE] = anObject(O);
|
|
result = new EmptyConstructor();
|
|
EmptyConstructor[PROTOTYPE] = null;
|
|
// add "__proto__" for Object.getPrototypeOf polyfill
|
|
result[IE_PROTO] = O;
|
|
} else result = NullProtoObject();
|
|
return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
|
|
};
|
|
return objectCreate;
|
|
}
|
|
|
|
var addToUnscopables;
|
|
var hasRequiredAddToUnscopables;
|
|
|
|
function requireAddToUnscopables () {
|
|
if (hasRequiredAddToUnscopables) return addToUnscopables;
|
|
hasRequiredAddToUnscopables = 1;
|
|
var wellKnownSymbol = requireWellKnownSymbol();
|
|
var create = requireObjectCreate();
|
|
var defineProperty = requireObjectDefineProperty().f;
|
|
|
|
var UNSCOPABLES = wellKnownSymbol('unscopables');
|
|
var ArrayPrototype = Array.prototype;
|
|
|
|
// Array.prototype[@@unscopables]
|
|
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
if (ArrayPrototype[UNSCOPABLES] === undefined) {
|
|
defineProperty(ArrayPrototype, UNSCOPABLES, {
|
|
configurable: true,
|
|
value: create(null)
|
|
});
|
|
}
|
|
|
|
// add a key to Array.prototype[@@unscopables]
|
|
addToUnscopables = function (key) {
|
|
ArrayPrototype[UNSCOPABLES][key] = true;
|
|
};
|
|
return addToUnscopables;
|
|
}
|
|
|
|
var hasRequiredEs_array_includes;
|
|
|
|
function requireEs_array_includes () {
|
|
if (hasRequiredEs_array_includes) return es_array_includes;
|
|
hasRequiredEs_array_includes = 1;
|
|
var $ = require_export();
|
|
var $includes = requireArrayIncludes().includes;
|
|
var fails = requireFails();
|
|
var addToUnscopables = requireAddToUnscopables();
|
|
|
|
// FF99+ bug
|
|
var BROKEN_ON_SPARSE = fails(function () {
|
|
// eslint-disable-next-line es/no-array-prototype-includes -- detection
|
|
return !Array(1).includes();
|
|
});
|
|
|
|
// `Array.prototype.includes` method
|
|
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
$({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
|
|
includes: function includes(el /* , fromIndex = 0 */) {
|
|
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
|
}
|
|
});
|
|
|
|
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
addToUnscopables('includes');
|
|
return es_array_includes;
|
|
}
|
|
|
|
requireEs_array_includes();
|
|
|
|
var es_array_fill = {};
|
|
|
|
var arrayFill;
|
|
var hasRequiredArrayFill;
|
|
|
|
function requireArrayFill () {
|
|
if (hasRequiredArrayFill) return arrayFill;
|
|
hasRequiredArrayFill = 1;
|
|
var toObject = requireToObject();
|
|
var toAbsoluteIndex = requireToAbsoluteIndex();
|
|
var lengthOfArrayLike = requireLengthOfArrayLike();
|
|
|
|
// `Array.prototype.fill` method implementation
|
|
// https://tc39.es/ecma262/#sec-array.prototype.fill
|
|
arrayFill = function fill(value /* , start = 0, end = @length */) {
|
|
var O = toObject(this);
|
|
var length = lengthOfArrayLike(O);
|
|
var argumentsLength = arguments.length;
|
|
var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
|
|
var end = argumentsLength > 2 ? arguments[2] : undefined;
|
|
var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
|
|
while (endPos > index) O[index++] = value;
|
|
return O;
|
|
};
|
|
return arrayFill;
|
|
}
|
|
|
|
var hasRequiredEs_array_fill;
|
|
|
|
function requireEs_array_fill () {
|
|
if (hasRequiredEs_array_fill) return es_array_fill;
|
|
hasRequiredEs_array_fill = 1;
|
|
var $ = require_export();
|
|
var fill = requireArrayFill();
|
|
var addToUnscopables = requireAddToUnscopables();
|
|
|
|
// `Array.prototype.fill` method
|
|
// https://tc39.es/ecma262/#sec-array.prototype.fill
|
|
$({ target: 'Array', proto: true }, {
|
|
fill: fill
|
|
});
|
|
|
|
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
addToUnscopables('fill');
|
|
return es_array_fill;
|
|
}
|
|
|
|
requireEs_array_fill();
|
|
|
|
/* eslint-disable no-prototype-builtins */
|
|
var g =
|
|
(typeof globalThis !== 'undefined' && globalThis) ||
|
|
(typeof self !== 'undefined' && self) ||
|
|
// eslint-disable-next-line no-undef
|
|
(typeof global !== 'undefined' && global) ||
|
|
{};
|
|
|
|
var support = {
|
|
searchParams: 'URLSearchParams' in g,
|
|
iterable: 'Symbol' in g && 'iterator' in Symbol,
|
|
blob:
|
|
'FileReader' in g &&
|
|
'Blob' in g &&
|
|
(function() {
|
|
try {
|
|
new Blob();
|
|
return true
|
|
} catch (e) {
|
|
return false
|
|
}
|
|
})(),
|
|
formData: 'FormData' in g,
|
|
arrayBuffer: 'ArrayBuffer' in g
|
|
};
|
|
|
|
function isDataView(obj) {
|
|
return obj && DataView.prototype.isPrototypeOf(obj)
|
|
}
|
|
|
|
if (support.arrayBuffer) {
|
|
var viewClasses = [
|
|
'[object Int8Array]',
|
|
'[object Uint8Array]',
|
|
'[object Uint8ClampedArray]',
|
|
'[object Int16Array]',
|
|
'[object Uint16Array]',
|
|
'[object Int32Array]',
|
|
'[object Uint32Array]',
|
|
'[object Float32Array]',
|
|
'[object Float64Array]'
|
|
];
|
|
|
|
var isArrayBufferView =
|
|
ArrayBuffer.isView ||
|
|
function(obj) {
|
|
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
|
|
};
|
|
}
|
|
|
|
function normalizeName(name) {
|
|
if (typeof name !== 'string') {
|
|
name = String(name);
|
|
}
|
|
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
|
|
throw new TypeError('Invalid character in header field name: "' + name + '"')
|
|
}
|
|
return name.toLowerCase()
|
|
}
|
|
|
|
function normalizeValue(value) {
|
|
if (typeof value !== 'string') {
|
|
value = String(value);
|
|
}
|
|
return value
|
|
}
|
|
|
|
// Build a destructive iterator for the value list
|
|
function iteratorFor(items) {
|
|
var iterator = {
|
|
next: function() {
|
|
var value = items.shift();
|
|
return {done: value === undefined, value: value}
|
|
}
|
|
};
|
|
|
|
if (support.iterable) {
|
|
iterator[Symbol.iterator] = function() {
|
|
return iterator
|
|
};
|
|
}
|
|
|
|
return iterator
|
|
}
|
|
|
|
function Headers(headers) {
|
|
this.map = {};
|
|
|
|
if (headers instanceof Headers) {
|
|
headers.forEach(function(value, name) {
|
|
this.append(name, value);
|
|
}, this);
|
|
} else if (Array.isArray(headers)) {
|
|
headers.forEach(function(header) {
|
|
if (header.length != 2) {
|
|
throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
|
|
}
|
|
this.append(header[0], header[1]);
|
|
}, this);
|
|
} else if (headers) {
|
|
Object.getOwnPropertyNames(headers).forEach(function(name) {
|
|
this.append(name, headers[name]);
|
|
}, this);
|
|
}
|
|
}
|
|
|
|
Headers.prototype.append = function(name, value) {
|
|
name = normalizeName(name);
|
|
value = normalizeValue(value);
|
|
var oldValue = this.map[name];
|
|
this.map[name] = oldValue ? oldValue + ', ' + value : value;
|
|
};
|
|
|
|
Headers.prototype['delete'] = function(name) {
|
|
delete this.map[normalizeName(name)];
|
|
};
|
|
|
|
Headers.prototype.get = function(name) {
|
|
name = normalizeName(name);
|
|
return this.has(name) ? this.map[name] : null
|
|
};
|
|
|
|
Headers.prototype.has = function(name) {
|
|
return this.map.hasOwnProperty(normalizeName(name))
|
|
};
|
|
|
|
Headers.prototype.set = function(name, value) {
|
|
this.map[normalizeName(name)] = normalizeValue(value);
|
|
};
|
|
|
|
Headers.prototype.forEach = function(callback, thisArg) {
|
|
for (var name in this.map) {
|
|
if (this.map.hasOwnProperty(name)) {
|
|
callback.call(thisArg, this.map[name], name, this);
|
|
}
|
|
}
|
|
};
|
|
|
|
Headers.prototype.keys = function() {
|
|
var items = [];
|
|
this.forEach(function(value, name) {
|
|
items.push(name);
|
|
});
|
|
return iteratorFor(items)
|
|
};
|
|
|
|
Headers.prototype.values = function() {
|
|
var items = [];
|
|
this.forEach(function(value) {
|
|
items.push(value);
|
|
});
|
|
return iteratorFor(items)
|
|
};
|
|
|
|
Headers.prototype.entries = function() {
|
|
var items = [];
|
|
this.forEach(function(value, name) {
|
|
items.push([name, value]);
|
|
});
|
|
return iteratorFor(items)
|
|
};
|
|
|
|
if (support.iterable) {
|
|
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
|
|
}
|
|
|
|
function consumed(body) {
|
|
if (body._noBody) return
|
|
if (body.bodyUsed) {
|
|
return Promise.reject(new TypeError('Already read'))
|
|
}
|
|
body.bodyUsed = true;
|
|
}
|
|
|
|
function fileReaderReady(reader) {
|
|
return new Promise(function(resolve, reject) {
|
|
reader.onload = function() {
|
|
resolve(reader.result);
|
|
};
|
|
reader.onerror = function() {
|
|
reject(reader.error);
|
|
};
|
|
})
|
|
}
|
|
|
|
function readBlobAsArrayBuffer(blob) {
|
|
var reader = new FileReader();
|
|
var promise = fileReaderReady(reader);
|
|
reader.readAsArrayBuffer(blob);
|
|
return promise
|
|
}
|
|
|
|
function readBlobAsText(blob) {
|
|
var reader = new FileReader();
|
|
var promise = fileReaderReady(reader);
|
|
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
|
|
var encoding = match ? match[1] : 'utf-8';
|
|
reader.readAsText(blob, encoding);
|
|
return promise
|
|
}
|
|
|
|
function readArrayBufferAsText(buf) {
|
|
var view = new Uint8Array(buf);
|
|
var chars = new Array(view.length);
|
|
|
|
for (var i = 0; i < view.length; i++) {
|
|
chars[i] = String.fromCharCode(view[i]);
|
|
}
|
|
return chars.join('')
|
|
}
|
|
|
|
function bufferClone(buf) {
|
|
if (buf.slice) {
|
|
return buf.slice(0)
|
|
} else {
|
|
var view = new Uint8Array(buf.byteLength);
|
|
view.set(new Uint8Array(buf));
|
|
return view.buffer
|
|
}
|
|
}
|
|
|
|
function Body() {
|
|
this.bodyUsed = false;
|
|
|
|
this._initBody = function(body) {
|
|
/*
|
|
fetch-mock wraps the Response object in an ES6 Proxy to
|
|
provide useful test harness features such as flush. However, on
|
|
ES5 browsers without fetch or Proxy support pollyfills must be used;
|
|
the proxy-pollyfill is unable to proxy an attribute unless it exists
|
|
on the object before the Proxy is created. This change ensures
|
|
Response.bodyUsed exists on the instance, while maintaining the
|
|
semantic of setting Request.bodyUsed in the constructor before
|
|
_initBody is called.
|
|
*/
|
|
// eslint-disable-next-line no-self-assign
|
|
this.bodyUsed = this.bodyUsed;
|
|
this._bodyInit = body;
|
|
if (!body) {
|
|
this._noBody = true;
|
|
this._bodyText = '';
|
|
} else if (typeof body === 'string') {
|
|
this._bodyText = body;
|
|
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
|
|
this._bodyBlob = body;
|
|
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
|
|
this._bodyFormData = body;
|
|
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
this._bodyText = body.toString();
|
|
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
|
|
this._bodyArrayBuffer = bufferClone(body.buffer);
|
|
// IE 10-11 can't handle a DataView body.
|
|
this._bodyInit = new Blob([this._bodyArrayBuffer]);
|
|
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
|
|
this._bodyArrayBuffer = bufferClone(body);
|
|
} else {
|
|
this._bodyText = body = Object.prototype.toString.call(body);
|
|
}
|
|
|
|
if (!this.headers.get('content-type')) {
|
|
if (typeof body === 'string') {
|
|
this.headers.set('content-type', 'text/plain;charset=UTF-8');
|
|
} else if (this._bodyBlob && this._bodyBlob.type) {
|
|
this.headers.set('content-type', this._bodyBlob.type);
|
|
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
|
|
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
|
|
}
|
|
}
|
|
};
|
|
|
|
if (support.blob) {
|
|
this.blob = function() {
|
|
var rejected = consumed(this);
|
|
if (rejected) {
|
|
return rejected
|
|
}
|
|
|
|
if (this._bodyBlob) {
|
|
return Promise.resolve(this._bodyBlob)
|
|
} else if (this._bodyArrayBuffer) {
|
|
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
|
|
} else if (this._bodyFormData) {
|
|
throw new Error('could not read FormData body as blob')
|
|
} else {
|
|
return Promise.resolve(new Blob([this._bodyText]))
|
|
}
|
|
};
|
|
}
|
|
|
|
this.arrayBuffer = function() {
|
|
if (this._bodyArrayBuffer) {
|
|
var isConsumed = consumed(this);
|
|
if (isConsumed) {
|
|
return isConsumed
|
|
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
|
return Promise.resolve(
|
|
this._bodyArrayBuffer.buffer.slice(
|
|
this._bodyArrayBuffer.byteOffset,
|
|
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
)
|
|
)
|
|
} else {
|
|
return Promise.resolve(this._bodyArrayBuffer)
|
|
}
|
|
} else if (support.blob) {
|
|
return this.blob().then(readBlobAsArrayBuffer)
|
|
} else {
|
|
throw new Error('could not read as ArrayBuffer')
|
|
}
|
|
};
|
|
|
|
this.text = function() {
|
|
var rejected = consumed(this);
|
|
if (rejected) {
|
|
return rejected
|
|
}
|
|
|
|
if (this._bodyBlob) {
|
|
return readBlobAsText(this._bodyBlob)
|
|
} else if (this._bodyArrayBuffer) {
|
|
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
|
|
} else if (this._bodyFormData) {
|
|
throw new Error('could not read FormData body as text')
|
|
} else {
|
|
return Promise.resolve(this._bodyText)
|
|
}
|
|
};
|
|
|
|
if (support.formData) {
|
|
this.formData = function() {
|
|
return this.text().then(decode)
|
|
};
|
|
}
|
|
|
|
this.json = function() {
|
|
return this.text().then(JSON.parse)
|
|
};
|
|
|
|
return this
|
|
}
|
|
|
|
// HTTP methods whose capitalization should be normalized
|
|
var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
|
|
|
|
function normalizeMethod(method) {
|
|
var upcased = method.toUpperCase();
|
|
return methods.indexOf(upcased) > -1 ? upcased : method
|
|
}
|
|
|
|
function Request(input, options) {
|
|
if (!(this instanceof Request)) {
|
|
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
|
}
|
|
|
|
options = options || {};
|
|
var body = options.body;
|
|
|
|
if (input instanceof Request) {
|
|
if (input.bodyUsed) {
|
|
throw new TypeError('Already read')
|
|
}
|
|
this.url = input.url;
|
|
this.credentials = input.credentials;
|
|
if (!options.headers) {
|
|
this.headers = new Headers(input.headers);
|
|
}
|
|
this.method = input.method;
|
|
this.mode = input.mode;
|
|
this.signal = input.signal;
|
|
if (!body && input._bodyInit != null) {
|
|
body = input._bodyInit;
|
|
input.bodyUsed = true;
|
|
}
|
|
} else {
|
|
this.url = String(input);
|
|
}
|
|
|
|
this.credentials = options.credentials || this.credentials || 'same-origin';
|
|
if (options.headers || !this.headers) {
|
|
this.headers = new Headers(options.headers);
|
|
}
|
|
this.method = normalizeMethod(options.method || this.method || 'GET');
|
|
this.mode = options.mode || this.mode || null;
|
|
this.signal = options.signal || this.signal || (function () {
|
|
if ('AbortController' in g) {
|
|
var ctrl = new AbortController();
|
|
return ctrl.signal;
|
|
}
|
|
}());
|
|
this.referrer = null;
|
|
|
|
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
|
|
throw new TypeError('Body not allowed for GET or HEAD requests')
|
|
}
|
|
this._initBody(body);
|
|
|
|
if (this.method === 'GET' || this.method === 'HEAD') {
|
|
if (options.cache === 'no-store' || options.cache === 'no-cache') {
|
|
// Search for a '_' parameter in the query string
|
|
var reParamSearch = /([?&])_=[^&]*/;
|
|
if (reParamSearch.test(this.url)) {
|
|
// If it already exists then set the value with the current time
|
|
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
|
|
} else {
|
|
// Otherwise add a new '_' parameter to the end with the current time
|
|
var reQueryString = /\?/;
|
|
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Request.prototype.clone = function() {
|
|
return new Request(this, {body: this._bodyInit})
|
|
};
|
|
|
|
function decode(body) {
|
|
var form = new FormData();
|
|
body
|
|
.trim()
|
|
.split('&')
|
|
.forEach(function(bytes) {
|
|
if (bytes) {
|
|
var split = bytes.split('=');
|
|
var name = split.shift().replace(/\+/g, ' ');
|
|
var value = split.join('=').replace(/\+/g, ' ');
|
|
form.append(decodeURIComponent(name), decodeURIComponent(value));
|
|
}
|
|
});
|
|
return form
|
|
}
|
|
|
|
function parseHeaders(rawHeaders) {
|
|
var headers = new Headers();
|
|
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
|
// https://tools.ietf.org/html/rfc7230#section-3.2
|
|
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
|
// Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
|
|
// https://github.com/github/fetch/issues/748
|
|
// https://github.com/zloirock/core-js/issues/751
|
|
preProcessedHeaders
|
|
.split('\r')
|
|
.map(function(header) {
|
|
return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
|
|
})
|
|
.forEach(function(line) {
|
|
var parts = line.split(':');
|
|
var key = parts.shift().trim();
|
|
if (key) {
|
|
var value = parts.join(':').trim();
|
|
try {
|
|
headers.append(key, value);
|
|
} catch (error) {
|
|
}
|
|
}
|
|
});
|
|
return headers
|
|
}
|
|
|
|
Body.call(Request.prototype);
|
|
|
|
function Response(bodyInit, options) {
|
|
if (!(this instanceof Response)) {
|
|
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
|
}
|
|
if (!options) {
|
|
options = {};
|
|
}
|
|
|
|
this.type = 'default';
|
|
this.status = options.status === undefined ? 200 : options.status;
|
|
if (this.status < 200 || this.status > 599) {
|
|
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
|
|
}
|
|
this.ok = this.status >= 200 && this.status < 300;
|
|
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
|
|
this.headers = new Headers(options.headers);
|
|
this.url = options.url || '';
|
|
this._initBody(bodyInit);
|
|
}
|
|
|
|
Body.call(Response.prototype);
|
|
|
|
Response.prototype.clone = function() {
|
|
return new Response(this._bodyInit, {
|
|
status: this.status,
|
|
statusText: this.statusText,
|
|
headers: new Headers(this.headers),
|
|
url: this.url
|
|
})
|
|
};
|
|
|
|
Response.error = function() {
|
|
var response = new Response(null, {status: 200, statusText: ''});
|
|
response.ok = false;
|
|
response.status = 0;
|
|
response.type = 'error';
|
|
return response
|
|
};
|
|
|
|
var redirectStatuses = [301, 302, 303, 307, 308];
|
|
|
|
Response.redirect = function(url, status) {
|
|
if (redirectStatuses.indexOf(status) === -1) {
|
|
throw new RangeError('Invalid status code')
|
|
}
|
|
|
|
return new Response(null, {status: status, headers: {location: url}})
|
|
};
|
|
|
|
var DOMException = g.DOMException;
|
|
try {
|
|
new DOMException();
|
|
} catch (err) {
|
|
DOMException = function(message, name) {
|
|
this.message = message;
|
|
this.name = name;
|
|
var error = Error(message);
|
|
this.stack = error.stack;
|
|
};
|
|
DOMException.prototype = Object.create(Error.prototype);
|
|
DOMException.prototype.constructor = DOMException;
|
|
}
|
|
|
|
function fetch$1(input, init) {
|
|
return new Promise(function(resolve, reject) {
|
|
var request = new Request(input, init);
|
|
|
|
if (request.signal && request.signal.aborted) {
|
|
return reject(new DOMException('Aborted', 'AbortError'))
|
|
}
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
function abortXhr() {
|
|
xhr.abort();
|
|
}
|
|
|
|
xhr.onload = function() {
|
|
var options = {
|
|
statusText: xhr.statusText,
|
|
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
|
|
};
|
|
// This check if specifically for when a user fetches a file locally from the file system
|
|
// Only if the status is out of a normal range
|
|
if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
options.status = 200;
|
|
} else {
|
|
options.status = xhr.status;
|
|
}
|
|
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
|
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
|
setTimeout(function() {
|
|
resolve(new Response(body, options));
|
|
}, 0);
|
|
};
|
|
|
|
xhr.onerror = function() {
|
|
setTimeout(function() {
|
|
reject(new TypeError('Network request failed'));
|
|
}, 0);
|
|
};
|
|
|
|
xhr.ontimeout = function() {
|
|
setTimeout(function() {
|
|
reject(new TypeError('Network request timed out'));
|
|
}, 0);
|
|
};
|
|
|
|
xhr.onabort = function() {
|
|
setTimeout(function() {
|
|
reject(new DOMException('Aborted', 'AbortError'));
|
|
}, 0);
|
|
};
|
|
|
|
function fixUrl(url) {
|
|
try {
|
|
return url === '' && g.location.href ? g.location.href : url
|
|
} catch (e) {
|
|
return url
|
|
}
|
|
}
|
|
|
|
xhr.open(request.method, fixUrl(request.url), true);
|
|
|
|
if (request.credentials === 'include') {
|
|
xhr.withCredentials = true;
|
|
} else if (request.credentials === 'omit') {
|
|
xhr.withCredentials = false;
|
|
}
|
|
|
|
if ('responseType' in xhr) {
|
|
if (support.blob) {
|
|
xhr.responseType = 'blob';
|
|
} else if (
|
|
support.arrayBuffer
|
|
) {
|
|
xhr.responseType = 'arraybuffer';
|
|
}
|
|
}
|
|
|
|
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
|
|
var names = [];
|
|
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
|
names.push(normalizeName(name));
|
|
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
|
});
|
|
request.headers.forEach(function(value, name) {
|
|
if (names.indexOf(name) === -1) {
|
|
xhr.setRequestHeader(name, value);
|
|
}
|
|
});
|
|
} else {
|
|
request.headers.forEach(function(value, name) {
|
|
xhr.setRequestHeader(name, value);
|
|
});
|
|
}
|
|
|
|
if (request.signal) {
|
|
request.signal.addEventListener('abort', abortXhr);
|
|
|
|
xhr.onreadystatechange = function() {
|
|
// DONE (success or failure)
|
|
if (xhr.readyState === 4) {
|
|
request.signal.removeEventListener('abort', abortXhr);
|
|
}
|
|
};
|
|
}
|
|
|
|
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
|
|
})
|
|
}
|
|
|
|
fetch$1.polyfill = true;
|
|
|
|
if (!g.fetch) {
|
|
g.fetch = fetch$1;
|
|
g.Headers = Headers;
|
|
g.Request = Request;
|
|
g.Response = Response;
|
|
}
|
|
|
|
if (typeof CanvasRenderingContext2D !== 'undefined' && !CanvasRenderingContext2D.prototype.resetTransform) {
|
|
CanvasRenderingContext2D.prototype.resetTransform = function () {
|
|
this.setTransform(1, 0, 0, 1, 0, 0);
|
|
};
|
|
}
|
|
|
|
function styleInject(css, ref) {
|
|
if ( ref === void 0 ) ref = {};
|
|
var insertAt = ref.insertAt;
|
|
|
|
if (typeof document === 'undefined') { return; }
|
|
|
|
var head = document.head || document.getElementsByTagName('head')[0];
|
|
var style = document.createElement('style');
|
|
style.type = 'text/css';
|
|
|
|
if (insertAt === 'top') {
|
|
if (head.firstChild) {
|
|
head.insertBefore(style, head.firstChild);
|
|
} else {
|
|
head.appendChild(style);
|
|
}
|
|
} else {
|
|
head.appendChild(style);
|
|
}
|
|
|
|
if (style.styleSheet) {
|
|
style.styleSheet.cssText = css;
|
|
} else {
|
|
style.appendChild(document.createTextNode(css));
|
|
}
|
|
}
|
|
|
|
var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:100% 0}75%{background-position:0 100%}to{background-position:0 0}}@keyframes watermark-horizontal{0%{background-position-x:0}to{background-position-x:100%}}@keyframes watermark-vertical{0%{background-position-y:0}to{background-position-y:100%}}";
|
|
styleInject(css_248z);
|
|
|
|
/******************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */
|
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
|
|
var extendStatics = function(d, b) {
|
|
extendStatics = Object.setPrototypeOf ||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
return extendStatics(d, b);
|
|
};
|
|
|
|
function __extends(d, b) {
|
|
if (typeof b !== "function" && b !== null)
|
|
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
extendStatics(d, b);
|
|
function __() { this.constructor = d; }
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
}
|
|
|
|
var __assign = function() {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
}
|
|
|
|
function __generator(thisArg, body) {
|
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
function step(op) {
|
|
if (f) throw new TypeError("Generator is already executing.");
|
|
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
switch (op[0]) {
|
|
case 0: case 1: t = op; break;
|
|
case 4: _.label++; return { value: op[1], done: false };
|
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
default:
|
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
if (t[2]) _.ops.pop();
|
|
_.trys.pop(); continue;
|
|
}
|
|
op = body.call(thisArg, _);
|
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
}
|
|
}
|
|
|
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
var e = new Error(message);
|
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
};
|
|
|
|
var convertImage = function (canvas) {
|
|
return canvas.toDataURL('image/png', 1);
|
|
};
|
|
var isFunction = function (value) {
|
|
return typeof value === 'function';
|
|
};
|
|
var isUndefined = function (value) {
|
|
return value === undefined;
|
|
};
|
|
var isString = function (value) {
|
|
return typeof value === 'string';
|
|
};
|
|
var createSVGElement = function (tagName, attrs, namespaceURI) {
|
|
if (attrs === void 0) { attrs = {}; }
|
|
if (namespaceURI === void 0) { namespaceURI = 'http://www.w3.org/2000/svg'; }
|
|
var element = document.createElementNS(namespaceURI, tagName);
|
|
for (var attr in attrs) {
|
|
element.setAttribute(attr, attrs[attr]);
|
|
}
|
|
return element;
|
|
};
|
|
var getMultiLineData = function (ctx, text, maxWidth) {
|
|
var result = [];
|
|
var str = '';
|
|
var word = '';
|
|
for (var i = 0, len = text.length; i < len; i++) {
|
|
word = text.charAt(i);
|
|
if (word === '\n') {
|
|
result.push(str);
|
|
str = '';
|
|
continue;
|
|
}
|
|
str += word;
|
|
if (ctx.measureText(str).width > maxWidth) {
|
|
result.push(str.substring(0, str.length - 1));
|
|
str = '';
|
|
i--;
|
|
}
|
|
}
|
|
result.push(str);
|
|
return result;
|
|
};
|
|
var createCustomContentSVG = function (ctx, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
var svgElement, bodyElement, rect, rectWidth, rectHeight, width, height, foreignObjectElement;
|
|
var _a;
|
|
return __generator(this, function (_b) {
|
|
switch (_b.label) {
|
|
case 0:
|
|
svgElement = createSVGElement('svg', {
|
|
xmlns: 'http://www.w3.org/2000/svg',
|
|
});
|
|
bodyElement = document.createElement('div');
|
|
bodyElement.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
|
|
bodyElement.style.cssText = "\n text-align: center;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font: ".concat(ctx.font, ";\n color: ").concat(options.fontColor, ";\n");
|
|
bodyElement.innerHTML = "<div class='rich-text-content'>".concat(options.content, "</div>");
|
|
document.body.appendChild(bodyElement);
|
|
// convert all images to base64
|
|
return [4 /*yield*/, convertImgToBase64(bodyElement)];
|
|
case 1:
|
|
// convert all images to base64
|
|
_b.sent();
|
|
rect = (_a = bodyElement.querySelector('.rich-text-content')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
rectWidth = rect === null || rect === void 0 ? void 0 : rect.width;
|
|
rectHeight = rect === null || rect === void 0 ? void 0 : rect.height;
|
|
document.body.removeChild(bodyElement);
|
|
width = options.richTextWidth || rectWidth || options.width;
|
|
height = options.richTextHeight || rectHeight || options.height;
|
|
svgElement.setAttribute('width', width.toString());
|
|
svgElement.setAttribute('height', height.toString());
|
|
foreignObjectElement = createSVGElement('foreignObject', {
|
|
width: width.toString(),
|
|
height: height.toString(),
|
|
});
|
|
foreignObjectElement.appendChild(bodyElement);
|
|
svgElement.appendChild(foreignObjectElement);
|
|
return [2 /*return*/, {
|
|
element: svgElement,
|
|
width: width,
|
|
height: height,
|
|
}];
|
|
}
|
|
});
|
|
}); };
|
|
function convertImgToBase64(bodyElement) {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var imgElements, _loop_1, _i, _a, img;
|
|
return __generator(this, function (_b) {
|
|
switch (_b.label) {
|
|
case 0:
|
|
imgElements = bodyElement.querySelectorAll('img');
|
|
_loop_1 = function (img) {
|
|
var src, response, blob_1, imgData, error_1;
|
|
return __generator(this, function (_c) {
|
|
switch (_c.label) {
|
|
case 0:
|
|
src = img.getAttribute('src');
|
|
if (!src) return [3 /*break*/, 6];
|
|
_c.label = 1;
|
|
case 1:
|
|
_c.trys.push([1, 5, , 6]);
|
|
return [4 /*yield*/, fetch(src)];
|
|
case 2:
|
|
response = _c.sent();
|
|
return [4 /*yield*/, response.blob()];
|
|
case 3:
|
|
blob_1 = _c.sent();
|
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
var reader = new FileReader();
|
|
reader.onloadend = function () { return resolve(reader.result); };
|
|
reader.onerror = reject;
|
|
reader.readAsDataURL(blob_1);
|
|
})];
|
|
case 4:
|
|
imgData = _c.sent();
|
|
if (isString(imgData)) {
|
|
img.setAttribute('src', imgData);
|
|
}
|
|
return [3 /*break*/, 6];
|
|
case 5:
|
|
error_1 = _c.sent();
|
|
console.error("Error converting ".concat(src, " to base64:"), error_1);
|
|
return [3 /*break*/, 6];
|
|
case 6: return [2 /*return*/];
|
|
}
|
|
});
|
|
};
|
|
_i = 0, _a = Array.from(imgElements);
|
|
_b.label = 1;
|
|
case 1:
|
|
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
img = _a[_i];
|
|
return [5 /*yield**/, _loop_1(img)];
|
|
case 2:
|
|
_b.sent();
|
|
_b.label = 3;
|
|
case 3:
|
|
_i++;
|
|
return [3 /*break*/, 1];
|
|
case 4: return [2 /*return*/];
|
|
}
|
|
});
|
|
});
|
|
}
|
|
var convertSVGToImage = function (svg) {
|
|
var richContent = svg.outerHTML
|
|
.replace(/<(img|br|input|hr|embed)(.*?)>/g, '<$1$2/>')
|
|
.replace(/\n/g, '')
|
|
.replace(/\t/g, '')
|
|
.replace(/#/g, '%23');
|
|
return "data:image/svg+xml;charset=utf-8,".concat(richContent);
|
|
};
|
|
var getValue = function (v1, v2) {
|
|
if (isUndefined(v1)) {
|
|
return v2;
|
|
}
|
|
else {
|
|
return v1;
|
|
}
|
|
};
|
|
var loadImage = function (url, width, height) {
|
|
if (width === void 0) { width = undefined; }
|
|
if (height === void 0) { height = undefined; }
|
|
var image = new Image();
|
|
image.setAttribute('crossOrigin', 'anonymous');
|
|
!isUndefined(width) && (image.width = width);
|
|
!isUndefined(height) && (image.height = height);
|
|
image.src = url;
|
|
return new Promise(function (resolve) {
|
|
image.onload = function () {
|
|
resolve(image);
|
|
};
|
|
});
|
|
};
|
|
var generateMatrix = function (rows, columns, value) {
|
|
return Array.from({ length: rows }, function () { return new Array(columns).fill(value); });
|
|
};
|
|
var generateAnimationStyle = function (movable, backgroundRepeat) {
|
|
if (!movable) {
|
|
return '';
|
|
}
|
|
var horizontalDuration = Math.random() * (8 - 2) + 2;
|
|
var verticalDuration = Math.random() * (4 - 2) + 2;
|
|
switch (backgroundRepeat) {
|
|
case 'repeat':
|
|
return 'animation: 200s linear 0s infinite alternate watermark !important;';
|
|
case 'repeat-x':
|
|
return "animation: ".concat(horizontalDuration, "s linear 0s infinite alternate watermark-vertical !important;'");
|
|
case 'repeat-y':
|
|
return "animation: ".concat(verticalDuration, "s linear 0s infinite alternate watermark-horizontal !important;'");
|
|
case 'no-repeat':
|
|
return "animation: ".concat(horizontalDuration, "s linear 0s infinite alternate watermark-horizontal, ").concat(verticalDuration, "s linear 0s infinite alternate watermark-vertical !important;");
|
|
default:
|
|
return '';
|
|
}
|
|
};
|
|
|
|
var initialOptions = {
|
|
width: 300,
|
|
height: 300,
|
|
rotate: 45,
|
|
layout: 'default',
|
|
auxiliaryLine: false,
|
|
translatePlacement: 'middle',
|
|
contentType: 'text',
|
|
content: 'hello watermark-js-plus',
|
|
textType: 'fill',
|
|
imageWidth: 0,
|
|
imageHeight: 0,
|
|
lineHeight: 30,
|
|
zIndex: 2147483647,
|
|
backgroundPosition: '0 0',
|
|
backgroundRepeat: 'repeat',
|
|
fontSize: '20px',
|
|
fontFamily: 'sans-serif',
|
|
fontStyle: '',
|
|
fontVariant: '',
|
|
fontColor: '#000',
|
|
fontWeight: 'normal',
|
|
filter: 'none',
|
|
letterSpacing: '0px',
|
|
wordSpacing: '0px',
|
|
globalAlpha: 0.5,
|
|
mode: 'default',
|
|
mutationObserve: true,
|
|
monitorProtection: false,
|
|
movable: false,
|
|
parent: 'body',
|
|
onSuccess: function () { },
|
|
onBeforeDestroy: function () { },
|
|
onDestroyed: function () { },
|
|
onObserveError: function () { },
|
|
};
|
|
var generateRecommendOptions = function (canvas, options, args) {
|
|
var ctx = canvas.getContext('2d');
|
|
if (ctx === null) {
|
|
throw new Error('get context error');
|
|
}
|
|
ctx.font = "".concat(options.fontStyle, " ").concat(options.fontVariant, " ").concat(options.fontWeight, " ").concat(options.fontSize, " ").concat(options.fontFamily);
|
|
ctx.filter = options.filter;
|
|
ctx.letterSpacing = options.letterSpacing;
|
|
ctx.wordSpacing = options.wordSpacing;
|
|
if (options === null || options === void 0 ? void 0 : options.rotate) {
|
|
options.rotate = (360 - (options.rotate % 360)) * (Math.PI / 180);
|
|
}
|
|
if (isUndefined(args.textRowMaxWidth)) {
|
|
options.textRowMaxWidth = options.width;
|
|
}
|
|
var result = {
|
|
image: {
|
|
rect: {
|
|
width: options.imageWidth,
|
|
height: options.imageHeight,
|
|
},
|
|
position: {
|
|
x: 0,
|
|
y: 0,
|
|
},
|
|
},
|
|
textLine: {
|
|
data: [],
|
|
yOffsetValue: 0,
|
|
},
|
|
advancedStyleParams: {
|
|
linear: {
|
|
x0: 0,
|
|
x1: 0,
|
|
},
|
|
radial: {
|
|
x0: 0,
|
|
y0: 0,
|
|
r0: 0,
|
|
x1: 0,
|
|
y1: 0,
|
|
r1: 0,
|
|
},
|
|
conic: {
|
|
x: 0,
|
|
y: 0,
|
|
startAngle: 0,
|
|
},
|
|
pattern: {},
|
|
},
|
|
};
|
|
switch (options.contentType) {
|
|
case 'text':
|
|
result.textLine.data = [options.content];
|
|
break;
|
|
case 'multi-line-text':
|
|
result.textLine.data = getMultiLineData(ctx, options.content, options.textRowMaxWidth);
|
|
break;
|
|
// case 'image':
|
|
// break
|
|
// case 'rich-text':
|
|
// break
|
|
}
|
|
var translateX = options.width / 2;
|
|
var translateY = options.height / 2;
|
|
var textBaseline = 'middle';
|
|
var textAlign = 'center';
|
|
if (!isUndefined(args === null || args === void 0 ? void 0 : args.translateX) && !isUndefined(args === null || args === void 0 ? void 0 : args.translateY)) {
|
|
translateX = args === null || args === void 0 ? void 0 : args.translateX;
|
|
translateY = args === null || args === void 0 ? void 0 : args.translateY;
|
|
textBaseline = 'top';
|
|
textAlign = 'left';
|
|
}
|
|
else {
|
|
// default middle
|
|
// translateX = options.width / 2
|
|
// translateY = options.height / 2
|
|
// TextBaselineType = 'middle'
|
|
// textAlign = 'center'
|
|
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
// result.advancedStyleParams.radial.x0 = 0
|
|
// result.advancedStyleParams.radial.y0 = 0
|
|
result.advancedStyleParams.radial.r0 = 0;
|
|
// result.advancedStyleParams.radial.x1 = 0
|
|
// result.advancedStyleParams.radial.y1 = 0
|
|
result.advancedStyleParams.radial.r1 = options.width / 2;
|
|
// result.advancedStyleParams.conic.x = 0
|
|
// result.advancedStyleParams.conic.y = 0
|
|
}
|
|
switch (args.translatePlacement) {
|
|
case 'top':
|
|
translateX = options.width / 2;
|
|
translateY = 0;
|
|
textBaseline = 'top';
|
|
// textAlign = 'center'
|
|
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
// result.advancedStyleParams.radial.x0 = 0
|
|
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r0 = 0
|
|
// result.advancedStyleParams.radial.x1 = 0
|
|
// result.advancedStyleParams.radial.y1 = 0
|
|
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
// result.advancedStyleParams.conic.x = 0
|
|
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
break;
|
|
case 'top-start':
|
|
translateX = 0;
|
|
translateY = 0;
|
|
textBaseline = 'top';
|
|
textAlign = 'start';
|
|
result.advancedStyleParams.linear.x0 = 0;
|
|
result.advancedStyleParams.linear.x1 = options.width;
|
|
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r0 = 0
|
|
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
result.advancedStyleParams.conic.x = options.width / 2;
|
|
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
break;
|
|
case 'top-end':
|
|
translateX = options.width;
|
|
translateY = 0;
|
|
textBaseline = 'top';
|
|
textAlign = 'end';
|
|
result.advancedStyleParams.linear.x0 = 0;
|
|
result.advancedStyleParams.linear.x1 = -options.width;
|
|
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r0 = 0
|
|
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
|
|
break;
|
|
case 'bottom':
|
|
translateX = options.width / 2;
|
|
translateY = options.height;
|
|
textBaseline = 'bottom';
|
|
// textAlign = 'center'
|
|
result.advancedStyleParams.linear.x0 = -options.width / 2;
|
|
result.advancedStyleParams.linear.x1 = options.width / 2;
|
|
// result.advancedStyleParams.radial.x0 = 0
|
|
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r0 = 0
|
|
// result.advancedStyleParams.radial.x1 = 0
|
|
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
result.advancedStyleParams.conic.x = 0;
|
|
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
break;
|
|
case 'bottom-start':
|
|
translateX = 0;
|
|
translateY = options.height;
|
|
textBaseline = 'bottom';
|
|
textAlign = 'start';
|
|
result.advancedStyleParams.linear.x0 = 0;
|
|
result.advancedStyleParams.linear.x1 = options.width;
|
|
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r0 = 0
|
|
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
result.advancedStyleParams.conic.x = options.width / 2;
|
|
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
break;
|
|
case 'bottom-end':
|
|
translateX = options.width;
|
|
translateY = options.height;
|
|
textBaseline = 'bottom';
|
|
textAlign = 'end';
|
|
result.advancedStyleParams.linear.x0 = 0;
|
|
result.advancedStyleParams.linear.x1 = -options.width;
|
|
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r0 = 0
|
|
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
|
|
break;
|
|
case 'left':
|
|
translateX = 0;
|
|
translateY = options.height / 2;
|
|
// TextBaselineType = 'middle'
|
|
textAlign = 'start';
|
|
result.advancedStyleParams.linear.x0 = 0;
|
|
result.advancedStyleParams.linear.x1 = options.width;
|
|
result.advancedStyleParams.radial.x0 = options.width / 2;
|
|
// result.advancedStyleParams.radial.y0 = 0
|
|
// result.advancedStyleParams.radial.r0 = 0
|
|
result.advancedStyleParams.radial.x1 = options.width / 2;
|
|
// result.advancedStyleParams.radial.y1 = 0
|
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
result.advancedStyleParams.conic.x = options.width / 2;
|
|
result.advancedStyleParams.conic.y = 0;
|
|
break;
|
|
case 'right':
|
|
translateX = options.width;
|
|
translateY = options.height / 2;
|
|
// TextBaselineType = 'middle'
|
|
textAlign = 'end';
|
|
result.advancedStyleParams.linear.x0 = 0;
|
|
result.advancedStyleParams.linear.x1 = -options.width;
|
|
result.advancedStyleParams.radial.x0 = -options.width / 2;
|
|
// result.advancedStyleParams.radial.y0 = 0
|
|
// result.advancedStyleParams.radial.r0 = 0
|
|
result.advancedStyleParams.radial.x1 = -options.width / 2;
|
|
// result.advancedStyleParams.radial.y1 = 0
|
|
// result.advancedStyleParams.radial.r1 = options.width / 2
|
|
result.advancedStyleParams.conic.x = -options.width / 2;
|
|
result.advancedStyleParams.conic.y = 0;
|
|
break;
|
|
}
|
|
options.translateX = translateX;
|
|
options.translateY = translateY;
|
|
isUndefined(args === null || args === void 0 ? void 0 : args.textBaseline) && (options.textBaseline = textBaseline);
|
|
isUndefined(args === null || args === void 0 ? void 0 : args.textAlign) && (options.textAlign = textAlign);
|
|
if (['text', 'multi-line-text'].includes(options.contentType)) {
|
|
switch (options.textBaseline) {
|
|
case 'middle':
|
|
result.textLine.yOffsetValue = ((result.textLine.data.length - 1) * options.lineHeight) / 2;
|
|
break;
|
|
case 'bottom':
|
|
case 'alphabetic':
|
|
case 'ideographic':
|
|
result.textLine.yOffsetValue =
|
|
(result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
|
|
break;
|
|
case 'top':
|
|
case 'hanging':
|
|
result.textLine.yOffsetValue = -options.lineHeight / 2 + parseInt(options.fontSize) / 2;
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
|
|
var protection = (function (need) {
|
|
if (typeof window === 'undefined') {
|
|
return;
|
|
}
|
|
if (need) {
|
|
Object.defineProperty(window, 'MutationObserver', {
|
|
writable: false,
|
|
configurable: false,
|
|
});
|
|
}
|
|
});
|
|
|
|
var WatermarkCanvas = /** @class */ (function () {
|
|
function WatermarkCanvas(args, options) {
|
|
this.props = args;
|
|
this.options = options;
|
|
this.canvas = WatermarkCanvas.createCanvas(this.options.width, this.options.height);
|
|
this.recommendOptions = generateRecommendOptions(this.canvas, this.options, this.props);
|
|
}
|
|
/**
|
|
* Create an HD canvas.
|
|
* @param width - width of canvas
|
|
* @param height - height of canvas
|
|
*/
|
|
WatermarkCanvas.createCanvas = function (width, height) {
|
|
var _a;
|
|
var ratio = window.devicePixelRatio || 1;
|
|
var canvas = document.createElement('canvas');
|
|
canvas.width = width * ratio; // actual rendered pixel
|
|
canvas.height = height * ratio; // actual rendered pixel
|
|
canvas.style.width = "".concat(width, "px"); // control display size
|
|
canvas.style.height = "".concat(height, "px"); // control display size
|
|
(_a = canvas.getContext('2d')) === null || _a === void 0 ? void 0 : _a.setTransform(ratio, 0, 0, ratio, 0, 0);
|
|
return canvas;
|
|
};
|
|
/**
|
|
* Clean the canvas
|
|
* @param canvas
|
|
*/
|
|
WatermarkCanvas.clearCanvas = function (canvas) {
|
|
var ctx = canvas.getContext('2d');
|
|
if (ctx === null) {
|
|
throw new Error('get context error');
|
|
}
|
|
ctx.restore();
|
|
ctx.resetTransform();
|
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
var ratio = window.devicePixelRatio || 1;
|
|
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
|
|
};
|
|
WatermarkCanvas.prototype.getCanvas = function () {
|
|
return this.canvas;
|
|
};
|
|
WatermarkCanvas.prototype.clear = function () {
|
|
WatermarkCanvas.clearCanvas(this.canvas);
|
|
};
|
|
WatermarkCanvas.prototype.draw = function () {
|
|
var _this = this;
|
|
var ctx = this.canvas.getContext('2d');
|
|
if (ctx === null) {
|
|
throw new Error('get context error');
|
|
}
|
|
if (this.options.auxiliaryLine) {
|
|
ctx.beginPath();
|
|
ctx.rect(0, 0, this.options.width, this.options.height);
|
|
ctx.lineWidth = 1;
|
|
ctx.strokeStyle = '#000';
|
|
ctx.stroke();
|
|
ctx.closePath();
|
|
ctx.beginPath();
|
|
ctx.rect(this.options.translateX, this.options.translateY, 1, 1);
|
|
ctx.lineWidth = 1;
|
|
ctx.strokeStyle = '#f00';
|
|
ctx.stroke();
|
|
ctx.closePath();
|
|
}
|
|
this.setStyle(ctx);
|
|
ctx.save();
|
|
ctx.translate(this.options.translateX, this.options.translateY);
|
|
ctx.rotate(this.options.rotate);
|
|
return new Promise(function (resolve) {
|
|
switch (_this.options.contentType) {
|
|
case 'text':
|
|
_this.drawText(ctx, resolve);
|
|
break;
|
|
case 'image':
|
|
_this.drawImage(ctx, resolve);
|
|
break;
|
|
case 'multi-line-text':
|
|
_this.drawMultiLineText(ctx, resolve);
|
|
break;
|
|
case 'rich-text':
|
|
_this.drawRichText(ctx, resolve);
|
|
break;
|
|
}
|
|
});
|
|
};
|
|
WatermarkCanvas.prototype.setStyle = function (ctx) {
|
|
var _a;
|
|
var propName = 'fillStyle';
|
|
if (this.options.textType === 'stroke') {
|
|
propName = 'strokeStyle';
|
|
}
|
|
var style = this.options.fontColor;
|
|
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) {
|
|
switch (this.options.advancedStyle.type) {
|
|
case 'linear':
|
|
style = this.createLinearGradient(ctx);
|
|
break;
|
|
case 'radial':
|
|
style = this.createRadialGradient(ctx);
|
|
break;
|
|
case 'conic':
|
|
style = this.createConicGradient(ctx);
|
|
break;
|
|
case 'pattern':
|
|
style = this.createPattern(ctx);
|
|
break;
|
|
}
|
|
}
|
|
ctx[propName] && style && (ctx[propName] = style);
|
|
this.options.textAlign && (ctx.textAlign = this.options.textAlign);
|
|
this.options.textBaseline && (ctx.textBaseline = this.options.textBaseline);
|
|
ctx.globalAlpha = this.options.globalAlpha;
|
|
if (this.options.shadowStyle) {
|
|
ctx.shadowBlur = getValue(this.options.shadowStyle.shadowBlur, 0);
|
|
ctx.shadowColor = getValue(this.options.shadowStyle.shadowColor, '#00000000');
|
|
ctx.shadowOffsetX = getValue(this.options.shadowStyle.shadowOffsetX, 0);
|
|
ctx.shadowOffsetY = getValue(this.options.shadowStyle.shadowOffsetY, 0);
|
|
}
|
|
if (isFunction(this.options.extraDrawFunc)) {
|
|
this.options.extraDrawFunc(ctx);
|
|
}
|
|
};
|
|
WatermarkCanvas.prototype.createLinearGradient = function (ctx) {
|
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
var gradient = ctx.createLinearGradient((getValue((_c = (_b = (_a = this.options.advancedStyle) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.linear) === null || _c === void 0 ? void 0 : _c.x0, this.recommendOptions.advancedStyleParams.linear.x0)), getValue((_f = (_e = (_d = this.options.advancedStyle) === null || _d === void 0 ? void 0 : _d.params) === null || _e === void 0 ? void 0 : _e.linear) === null || _f === void 0 ? void 0 : _f.y0, 0), (getValue((_j = (_h = (_g = this.options.advancedStyle) === null || _g === void 0 ? void 0 : _g.params) === null || _h === void 0 ? void 0 : _h.linear) === null || _j === void 0 ? void 0 : _j.x1, this.recommendOptions.advancedStyleParams.linear.x1)), getValue((_m = (_l = (_k = this.options.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.linear) === null || _m === void 0 ? void 0 : _m.y1, 0));
|
|
(_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.colorStops) === null || _q === void 0 ? void 0 : _q.forEach(function (item) {
|
|
gradient.addColorStop(item.offset, item.color);
|
|
});
|
|
return gradient;
|
|
};
|
|
WatermarkCanvas.prototype.createConicGradient = function (ctx) {
|
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
var gradient = ctx.createConicGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.conic) === null || _d === void 0 ? void 0 : _d.startAngle, 0), (getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.conic) === null || _h === void 0 ? void 0 : _h.x, this.recommendOptions.advancedStyleParams.conic.x)), (getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.conic) === null || _m === void 0 ? void 0 : _m.y, this.recommendOptions.advancedStyleParams.conic.y)));
|
|
(_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.colorStops) === null || _q === void 0 ? void 0 : _q.forEach(function (item) {
|
|
gradient.addColorStop(item.offset, item.color);
|
|
});
|
|
return gradient;
|
|
};
|
|
WatermarkCanvas.prototype.createRadialGradient = function (ctx) {
|
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
var gradient = ctx.createRadialGradient((getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.radial) === null || _d === void 0 ? void 0 : _d.x0, this.recommendOptions.advancedStyleParams.radial.x0)), (getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.radial) === null || _h === void 0 ? void 0 : _h.y0, this.recommendOptions.advancedStyleParams.radial.y0)), (getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.radial) === null || _m === void 0 ? void 0 : _m.r0, this.recommendOptions.advancedStyleParams.radial.r0)), (getValue((_r = (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.params) === null || _q === void 0 ? void 0 : _q.radial) === null || _r === void 0 ? void 0 : _r.x1, this.recommendOptions.advancedStyleParams.radial.x1)), (getValue((_v = (_u = (_t = (_s = this.options) === null || _s === void 0 ? void 0 : _s.advancedStyle) === null || _t === void 0 ? void 0 : _t.params) === null || _u === void 0 ? void 0 : _u.radial) === null || _v === void 0 ? void 0 : _v.y1, this.recommendOptions.advancedStyleParams.radial.y1)), (getValue((_z = (_y = (_x = (_w = this.options) === null || _w === void 0 ? void 0 : _w.advancedStyle) === null || _x === void 0 ? void 0 : _x.params) === null || _y === void 0 ? void 0 : _y.radial) === null || _z === void 0 ? void 0 : _z.r1, this.recommendOptions.advancedStyleParams.radial.r1)));
|
|
(_2 = (_1 = (_0 = this.options) === null || _0 === void 0 ? void 0 : _0.advancedStyle) === null || _1 === void 0 ? void 0 : _1.colorStops) === null || _2 === void 0 ? void 0 : _2.forEach(function (item) {
|
|
gradient.addColorStop(item.offset, item.color);
|
|
});
|
|
return gradient;
|
|
};
|
|
WatermarkCanvas.prototype.createPattern = function (ctx) {
|
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
return ctx.createPattern(((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.pattern) === null || _d === void 0 ? void 0 : _d.image), ((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.pattern) === null || _h === void 0 ? void 0 : _h.repetition) || '');
|
|
};
|
|
WatermarkCanvas.prototype.setText = function (ctx, params) {
|
|
var methodName = 'fillText';
|
|
if (this.options.textType === 'stroke') {
|
|
methodName = 'strokeText';
|
|
}
|
|
ctx[methodName] && ctx[methodName](params.text, params.x, params.y, params.maxWidth);
|
|
};
|
|
WatermarkCanvas.prototype.drawText = function (ctx, resolve) {
|
|
this.setText(ctx, {
|
|
text: this.options.content,
|
|
x: 0,
|
|
y: 0 - this.recommendOptions.textLine.yOffsetValue,
|
|
maxWidth: this.options.textRowMaxWidth || this.options.width,
|
|
});
|
|
resolve(ctx.canvas);
|
|
};
|
|
WatermarkCanvas.prototype.drawImage = function (ctx, resolve) {
|
|
var _this = this;
|
|
loadImage(this.options.image).then(function (image) {
|
|
var _a = _this.getImageRect(image), imageWidth = _a.width, imageHeight = _a.height;
|
|
var imagePosition = _this.getDrawImagePosition(imageWidth, imageHeight);
|
|
ctx.drawImage(image, imagePosition.x, imagePosition.y, imageWidth, imageHeight);
|
|
resolve(ctx.canvas);
|
|
});
|
|
};
|
|
WatermarkCanvas.prototype.drawMultiLineText = function (ctx, resolve) {
|
|
var _this = this;
|
|
// image.width = this.options.width
|
|
// image.height = this.options.height
|
|
// const element = createCustomContentSvg(context, this.options)
|
|
// image.src = convertSVGToImage(element)
|
|
// image.onload = () => {
|
|
// context.translate(this.options.width / 2, this.options.height / 2)
|
|
// context.rotate(this.options.rotate)
|
|
// context.drawImage(
|
|
// image,
|
|
// -this.options.width / 2,
|
|
// -this.options.height / 2,
|
|
// context.canvas.width,
|
|
// context.canvas.height
|
|
// )
|
|
// resolve(canvas)
|
|
// }
|
|
var lines = this.recommendOptions.textLine.data;
|
|
var yOffsetValue = this.recommendOptions.textLine.yOffsetValue;
|
|
lines.forEach(function (text, index) {
|
|
_this.setText(ctx, {
|
|
text: text,
|
|
x: 0,
|
|
y: _this.options.lineHeight * index - yOffsetValue,
|
|
maxWidth: _this.options.textRowMaxWidth || _this.options.width,
|
|
});
|
|
});
|
|
resolve(ctx.canvas);
|
|
};
|
|
WatermarkCanvas.prototype.drawRichText = function (ctx, resolve) {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var obj;
|
|
var _this = this;
|
|
return __generator(this, function (_a) {
|
|
switch (_a.label) {
|
|
case 0: return [4 /*yield*/, createCustomContentSVG(ctx, this.options)];
|
|
case 1:
|
|
obj = _a.sent();
|
|
loadImage(convertSVGToImage(obj.element), obj.width, obj.height).then(function (image) {
|
|
var imagePosition = _this.getDrawImagePosition(image.width, image.height);
|
|
ctx.drawImage(image, imagePosition.x, imagePosition.y, image.width, image.height);
|
|
resolve(ctx.canvas);
|
|
});
|
|
return [2 /*return*/];
|
|
}
|
|
});
|
|
});
|
|
};
|
|
WatermarkCanvas.prototype.getImageRect = function (image) {
|
|
var rect = { width: this.options.imageWidth || 0, height: this.options.imageHeight || 0 };
|
|
switch (true) {
|
|
case rect.width !== 0 && rect.height === 0:
|
|
rect.height = (rect.width * image.height) / image.width;
|
|
break;
|
|
case rect.width === 0 && rect.height !== 0:
|
|
rect.width = (rect.height * image.width) / image.height;
|
|
break;
|
|
case rect.width === 0 && rect.height === 0:
|
|
rect.width = image.width;
|
|
rect.height = image.height;
|
|
break;
|
|
}
|
|
return rect;
|
|
};
|
|
WatermarkCanvas.prototype.getDrawImagePosition = function (imageWidth, imageHeight) {
|
|
var _a, _b;
|
|
var result = {
|
|
x: -imageWidth / 2,
|
|
y: -imageHeight / 2,
|
|
};
|
|
switch (this.options.translatePlacement) {
|
|
case 'top':
|
|
result.x = -imageWidth / 2;
|
|
result.y = 0;
|
|
break;
|
|
case 'top-start':
|
|
result.x = 0;
|
|
result.y = 0;
|
|
break;
|
|
case 'top-end':
|
|
result.x = -imageWidth;
|
|
result.y = 0;
|
|
break;
|
|
case 'bottom':
|
|
result.x = -imageWidth / 2;
|
|
result.y = -imageHeight;
|
|
break;
|
|
case 'bottom-start':
|
|
result.x = 0;
|
|
result.y = -imageHeight;
|
|
break;
|
|
case 'bottom-end':
|
|
result.x = -imageWidth;
|
|
result.y = -imageHeight;
|
|
break;
|
|
case 'left':
|
|
result.x = 0;
|
|
result.y = -imageHeight / 2;
|
|
break;
|
|
case 'right':
|
|
result.x = -imageWidth;
|
|
result.y = -imageHeight / 2;
|
|
break;
|
|
}
|
|
!isUndefined((_a = this.props) === null || _a === void 0 ? void 0 : _a.translateX) && (result.x = 0);
|
|
!isUndefined((_b = this.props) === null || _b === void 0 ? void 0 : _b.translateY) && (result.y = 0);
|
|
return result;
|
|
};
|
|
return WatermarkCanvas;
|
|
}());
|
|
|
|
var GridLayout = /** @class */ (function () {
|
|
function GridLayout(args, partialCanvas) {
|
|
var _a, _b, _c, _d;
|
|
this.options = args;
|
|
this.partialWidth = this.options.width;
|
|
this.partialHeight = this.options.height;
|
|
this.rows = ((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.rows) || 1;
|
|
this.cols = ((_b = this.options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.cols) || 1;
|
|
this.matrix = ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.matrix) || generateMatrix(this.rows, this.cols, 1);
|
|
this.gap = ((_d = this.options.gridLayoutOptions) === null || _d === void 0 ? void 0 : _d.gap) || [0, 0];
|
|
this.partialCanvas = partialCanvas;
|
|
}
|
|
GridLayout.prototype.draw = function () {
|
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
var layoutCanvas = WatermarkCanvas.createCanvas(((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.width) || this.partialWidth * this.cols + this.gap[0] * this.cols, ((_b = this.options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.height) || this.partialHeight * this.rows + this.gap[1] * this.rows);
|
|
var layoutContext = layoutCanvas.getContext('2d');
|
|
if ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.backgroundImage) {
|
|
layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.drawImage((_d = this.options.gridLayoutOptions) === null || _d === void 0 ? void 0 : _d.backgroundImage, 0, 0, (_e = this.options.gridLayoutOptions) === null || _e === void 0 ? void 0 : _e.width, (_f = this.options.gridLayoutOptions) === null || _f === void 0 ? void 0 : _f.height);
|
|
}
|
|
for (var rowIndex = 0; rowIndex < this.rows; rowIndex++) {
|
|
for (var colIndex = 0; colIndex < this.cols; colIndex++) {
|
|
if (!((_h = (_g = this.matrix) === null || _g === void 0 ? void 0 : _g[rowIndex]) === null || _h === void 0 ? void 0 : _h[colIndex])) {
|
|
continue;
|
|
}
|
|
layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.drawImage(this.partialCanvas, this.partialWidth * colIndex + this.gap[0] * colIndex, this.partialHeight * rowIndex + this.gap[1] * rowIndex, this.partialWidth, this.partialHeight);
|
|
}
|
|
}
|
|
return layoutCanvas;
|
|
};
|
|
return GridLayout;
|
|
}());
|
|
|
|
var renderLayout = function (options, partialCanvas) {
|
|
switch (options.layout) {
|
|
case 'grid':
|
|
return new GridLayout(options, partialCanvas).draw();
|
|
default:
|
|
return partialCanvas;
|
|
}
|
|
};
|
|
var generateBackgroundSize = function (options) {
|
|
var _a, _b, _c;
|
|
switch (options.layout) {
|
|
case 'grid': {
|
|
var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
|
|
var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
|
|
var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
|
|
return [options.width * cols + gap[0] * cols, options.height * rows + gap[1] * rows];
|
|
}
|
|
default:
|
|
return [options.width, options.height];
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Watermark class
|
|
*/
|
|
var Watermark = /** @class */ (function () {
|
|
/**
|
|
* Watermark constructor
|
|
* @param args - watermark args
|
|
*/
|
|
function Watermark(args) {
|
|
if (args === void 0) { args = {}; }
|
|
this.parentElement = document.body;
|
|
this.isCreating = false;
|
|
this.props = args;
|
|
this.options = __assign(__assign({}, initialOptions), args);
|
|
this.changeParentElement(this.options.parent);
|
|
this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
|
|
protection(this.options.monitorProtection);
|
|
}
|
|
/**
|
|
* Change watermark options
|
|
* @param args
|
|
* @param mode
|
|
* @param redraw
|
|
*/
|
|
Watermark.prototype.changeOptions = function () {
|
|
return __awaiter(this, arguments, void 0, function (args, mode, redraw) {
|
|
if (args === void 0) { args = {}; }
|
|
if (mode === void 0) { mode = 'overwrite'; }
|
|
if (redraw === void 0) { redraw = true; }
|
|
return __generator(this, function (_a) {
|
|
switch (_a.label) {
|
|
case 0:
|
|
this.initConfigData(args, mode);
|
|
protection(this.options.monitorProtection);
|
|
if (!redraw) return [3 /*break*/, 2];
|
|
this.remove();
|
|
return [4 /*yield*/, this.create()];
|
|
case 1:
|
|
_a.sent();
|
|
_a.label = 2;
|
|
case 2: return [2 /*return*/];
|
|
}
|
|
});
|
|
});
|
|
};
|
|
/**
|
|
* Creating a watermark.
|
|
*/
|
|
Watermark.prototype.create = function () {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var firstDraw, image, watermarkInnerDom, parentElementType, backgroundSize;
|
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
return __generator(this, function (_h) {
|
|
switch (_h.label) {
|
|
case 0:
|
|
if (this.isCreating) {
|
|
return [2 /*return*/];
|
|
}
|
|
this.isCreating = true;
|
|
if (!this.validateUnique()) {
|
|
this.isCreating = false;
|
|
return [2 /*return*/];
|
|
}
|
|
if (!this.validateContent()) {
|
|
this.isCreating = false;
|
|
return [2 /*return*/];
|
|
}
|
|
firstDraw = isUndefined(this.watermarkDom);
|
|
return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
|
|
case 1:
|
|
_h.sent();
|
|
this.layoutCanvas = renderLayout(this.options, (_b = this.watermarkCanvas) === null || _b === void 0 ? void 0 : _b.getCanvas());
|
|
image = convertImage(this.layoutCanvas);
|
|
(_c = this.watermarkCanvas) === null || _c === void 0 ? void 0 : _c.clear();
|
|
this.watermarkDom = document.createElement('div');
|
|
watermarkInnerDom = document.createElement('div');
|
|
this.watermarkDom.__WATERMARK__ = 'watermark';
|
|
this.watermarkDom.__WATERMARK__INSTANCE__ = this;
|
|
parentElementType = this.checkParentElementType();
|
|
this.watermarkDom.style.cssText = "\n z-index:".concat(this.options.zIndex, "!important;display:block!important;visibility:visible!important;transform:none!important;scale:none!important;\n ").concat(parentElementType === 'custom' ? 'top:0!important;bottom:0!important;left:0!important;right:0!important;height:100%!important;pointer-events:none!important;position:absolute!important;' : 'position:relative!important;', "\n ");
|
|
backgroundSize = generateBackgroundSize(this.options);
|
|
watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(generateAnimationStyle(this.options.movable, this.options.backgroundRepeat), "\n ");
|
|
this.watermarkDom.appendChild(watermarkInnerDom);
|
|
this.parentElement.appendChild(this.watermarkDom);
|
|
if (this.options.mutationObserve) {
|
|
try {
|
|
this.bindMutationObserve();
|
|
}
|
|
catch (_j) {
|
|
(_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
|
|
}
|
|
}
|
|
firstDraw && ((_g = (_f = this.options).onSuccess) === null || _g === void 0 ? void 0 : _g.call(_f));
|
|
this.isCreating = false;
|
|
return [2 /*return*/];
|
|
}
|
|
});
|
|
});
|
|
};
|
|
/**
|
|
* Delete this watermark.
|
|
*/
|
|
Watermark.prototype.destroy = function () {
|
|
this.remove();
|
|
this.watermarkDom = undefined;
|
|
};
|
|
Watermark.prototype.check = function () {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
return __generator(this, function (_a) {
|
|
return [2 /*return*/, this.parentElement.contains(this.watermarkDom)];
|
|
});
|
|
});
|
|
};
|
|
Watermark.prototype.remove = function () {
|
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
(_b = (_a = this.options).onBeforeDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
(_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
(_d = this.parentObserve) === null || _d === void 0 ? void 0 : _d.disconnect();
|
|
(_f = (_e = this.watermarkDom) === null || _e === void 0 ? void 0 : _e.parentNode) === null || _f === void 0 ? void 0 : _f.removeChild(this.watermarkDom);
|
|
(_h = (_g = this.options).onDestroyed) === null || _h === void 0 ? void 0 : _h.call(_g);
|
|
};
|
|
Watermark.prototype.initConfigData = function (args, mode) {
|
|
var _this = this;
|
|
if (mode === void 0) { mode = 'overwrite'; }
|
|
if (mode === 'append') {
|
|
Object.keys(args).forEach(function (key) {
|
|
_this.props && (_this.props[key] = args[key]);
|
|
});
|
|
}
|
|
else {
|
|
this.props = args;
|
|
}
|
|
this.options = __assign(__assign({}, initialOptions), this.props);
|
|
this.changeParentElement(this.options.parent);
|
|
this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
|
|
};
|
|
Watermark.prototype.changeParentElement = function (parent) {
|
|
if (typeof parent === 'string') {
|
|
var parentElement = document.querySelector(parent);
|
|
parentElement && (this.parentElement = parentElement);
|
|
}
|
|
else {
|
|
this.parentElement = parent;
|
|
}
|
|
if (!this.parentElement) {
|
|
console.error('[WatermarkJsPlus]: please pass a valid parent element.');
|
|
}
|
|
};
|
|
Watermark.prototype.validateUnique = function () {
|
|
var result = true;
|
|
Array.from(this.parentElement.childNodes).forEach(function (node) {
|
|
if (!result) {
|
|
return;
|
|
}
|
|
if (Object.hasOwnProperty.call(node, '__WATERMARK__')) {
|
|
result = false;
|
|
// throw new Error('duplicate watermark error')
|
|
}
|
|
});
|
|
return result;
|
|
};
|
|
Watermark.prototype.validateContent = function () {
|
|
switch (this.options.contentType) {
|
|
case 'image':
|
|
return Object.hasOwnProperty.call(this.options, 'image');
|
|
case 'multi-line-text':
|
|
case 'rich-text':
|
|
case 'text':
|
|
return this.options.content.length > 0;
|
|
}
|
|
};
|
|
Watermark.prototype.checkParentElementType = function () {
|
|
if (['html', 'body'].includes(this.parentElement.tagName.toLocaleLowerCase())) {
|
|
return 'root';
|
|
}
|
|
return 'custom';
|
|
};
|
|
Watermark.prototype.bindMutationObserve = function () {
|
|
var _this = this;
|
|
if (!this.watermarkDom) {
|
|
return;
|
|
}
|
|
this.observer = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
|
|
return __generator(this, function (_a) {
|
|
switch (_a.label) {
|
|
case 0:
|
|
if (!(mutationsList.length > 0)) return [3 /*break*/, 2];
|
|
this.remove();
|
|
return [4 /*yield*/, this.create()];
|
|
case 1:
|
|
_a.sent();
|
|
_a.label = 2;
|
|
case 2: return [2 /*return*/];
|
|
}
|
|
});
|
|
}); });
|
|
this.observer.observe(this.watermarkDom, {
|
|
attributes: true, // 属性的变动
|
|
childList: true, // 子节点的变动(指新增,删除或者更改)
|
|
subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
|
|
characterData: true, // 节点内容或节点文本的变动。
|
|
});
|
|
this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
|
|
var _i, mutationsList_1, item;
|
|
var _a;
|
|
return __generator(this, function (_b) {
|
|
switch (_b.label) {
|
|
case 0:
|
|
_i = 0, mutationsList_1 = mutationsList;
|
|
_b.label = 1;
|
|
case 1:
|
|
if (!(_i < mutationsList_1.length)) return [3 /*break*/, 4];
|
|
item = mutationsList_1[_i];
|
|
if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
|
|
((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
|
|
(item.type === 'childList' &&
|
|
item.target === this.parentElement &&
|
|
item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
|
|
this.remove();
|
|
return [4 /*yield*/, this.create()];
|
|
case 2:
|
|
_b.sent();
|
|
_b.label = 3;
|
|
case 3:
|
|
_i++;
|
|
return [3 /*break*/, 1];
|
|
case 4: return [2 /*return*/];
|
|
}
|
|
});
|
|
}); });
|
|
this.parentObserve.observe(this.parentElement, {
|
|
attributes: true, // 属性的变动
|
|
childList: true, // 子节点的变动(指新增,删除或者更改)
|
|
subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
|
|
characterData: true, // 节点内容或节点文本的变动。
|
|
});
|
|
};
|
|
return Watermark;
|
|
}());
|
|
|
|
/**
|
|
* BlindWatermark class
|
|
*/
|
|
var BlindWatermark = /** @class */ (function (_super) {
|
|
__extends(BlindWatermark, _super);
|
|
/**
|
|
* BlindWatermark constructor
|
|
* @param props - blind watermark options
|
|
*/
|
|
function BlindWatermark(props) {
|
|
if (props === void 0) { props = {}; }
|
|
var defaultProps = {
|
|
globalAlpha: 0.005,
|
|
mode: 'blind',
|
|
};
|
|
return _super.call(this, __assign(__assign({}, props), defaultProps)) || this;
|
|
}
|
|
BlindWatermark.prototype.changeOptions = function () {
|
|
return __awaiter(this, arguments, void 0, function (args, mode, redraw) {
|
|
if (args === void 0) { args = {}; }
|
|
if (mode === void 0) { mode = 'overwrite'; }
|
|
if (redraw === void 0) { redraw = true; }
|
|
return __generator(this, function (_a) {
|
|
switch (_a.label) {
|
|
case 0:
|
|
args.globalAlpha = 0.005;
|
|
args.mode = 'blind';
|
|
this.initConfigData(args, mode);
|
|
protection(this.options.monitorProtection);
|
|
if (!redraw) return [3 /*break*/, 2];
|
|
this.remove();
|
|
return [4 /*yield*/, this.create()];
|
|
case 1:
|
|
_a.sent();
|
|
_a.label = 2;
|
|
case 2: return [2 /*return*/];
|
|
}
|
|
});
|
|
});
|
|
};
|
|
/**
|
|
* Decode blind watermark.
|
|
* @param props - decode options
|
|
*/
|
|
BlindWatermark.decode = function (props) {
|
|
var _a = props.url, url = _a === void 0 ? '' : _a, _b = props.fillColor, fillColor = _b === void 0 ? '#000' : _b, _c = props.compositeOperation, compositeOperation = _c === void 0 ? 'color-burn' : _c, _d = props.mode, mode = _d === void 0 ? 'canvas' : _d, _e = props.compositeTimes, compositeTimes = _e === void 0 ? 3 : _e, onSuccess = props.onSuccess;
|
|
if (!url) {
|
|
return;
|
|
}
|
|
if (mode === 'canvas') {
|
|
var img_1 = new Image();
|
|
img_1.src = url;
|
|
img_1.addEventListener('load', function () {
|
|
var width = img_1.width, height = img_1.height;
|
|
var canvas = WatermarkCanvas.createCanvas(width, height);
|
|
var ctx = canvas.getContext('2d');
|
|
if (!ctx) {
|
|
throw new Error('get context error');
|
|
}
|
|
ctx.drawImage(img_1, 0, 0, width, height);
|
|
ctx.globalCompositeOperation = compositeOperation;
|
|
ctx.fillStyle = fillColor;
|
|
for (var i = 0; i < compositeTimes; i++) {
|
|
ctx.fillRect(0, 0, width, height);
|
|
}
|
|
var resultImage = convertImage(canvas);
|
|
if (isFunction(onSuccess)) {
|
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(resultImage);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
return BlindWatermark;
|
|
}(Watermark));
|
|
|
|
/**
|
|
* ImageWatermark class
|
|
*/
|
|
var ImageWatermark = /** @class */ (function () {
|
|
/**
|
|
* ImageWatermark constructor
|
|
* @param args - image watermark args
|
|
*/
|
|
function ImageWatermark(args) {
|
|
if (args === void 0) { args = {}; }
|
|
var _a, _b;
|
|
this.drew = false;
|
|
this.props = args;
|
|
this.options = __assign(__assign({}, initialOptions), args);
|
|
if (this.props.crossOrigin) {
|
|
(_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.setAttribute('crossOrigin', 'anonymous');
|
|
}
|
|
this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
|
|
this.originalSrc = (_b = this.props.dom) === null || _b === void 0 ? void 0 : _b.src;
|
|
this.backgroundImage = this.getBackgroundImage();
|
|
}
|
|
ImageWatermark.prototype.create = function () {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var _a, _b, _c, _d, _e;
|
|
return __generator(this, function (_f) {
|
|
switch (_f.label) {
|
|
case 0:
|
|
if (this.drew) {
|
|
return [2 /*return*/];
|
|
}
|
|
return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
|
|
case 1:
|
|
_f.sent();
|
|
this.options.layout = 'grid';
|
|
this.options.gridLayoutOptions = __assign(__assign({}, this.options.gridLayoutOptions), { width: (_b = this.backgroundImage) === null || _b === void 0 ? void 0 : _b.width, height: (_c = this.backgroundImage) === null || _c === void 0 ? void 0 : _c.height, backgroundImage: this.backgroundImage });
|
|
this.layoutCanvas = renderLayout(this.options, (_d = this.watermarkCanvas) === null || _d === void 0 ? void 0 : _d.getCanvas());
|
|
this.options.dom.src = convertImage(this.layoutCanvas);
|
|
(_e = this.watermarkCanvas) === null || _e === void 0 ? void 0 : _e.clear();
|
|
this.drew = true;
|
|
return [2 /*return*/];
|
|
}
|
|
});
|
|
});
|
|
};
|
|
ImageWatermark.prototype.destroy = function () {
|
|
this.options.dom.src = this.originalSrc;
|
|
this.drew = false;
|
|
};
|
|
ImageWatermark.prototype.getBackgroundImage = function () {
|
|
if (this.options.dom) {
|
|
return this.options.dom;
|
|
}
|
|
};
|
|
return ImageWatermark;
|
|
}());
|
|
|
|
exports.BlindWatermark = BlindWatermark;
|
|
exports.ImageWatermark = ImageWatermark;
|
|
exports.Watermark = Watermark;
|
|
|
|
}));
|
|
//# sourceMappingURL=index.umd.js.map
|