watermark-js-plus 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/ie/index.cjs.js +4451 -0
  2. package/dist/ie/index.cjs.js.map +1 -0
  3. package/dist/ie/index.cjs.min.js +1 -0
  4. package/dist/ie/index.esm.js +4447 -0
  5. package/dist/ie/index.esm.js.map +1 -0
  6. package/dist/ie/index.esm.min.js +1 -0
  7. package/dist/ie/index.iife.js +4456 -0
  8. package/dist/ie/index.iife.js.map +1 -0
  9. package/dist/ie/index.iife.min.js +1 -0
  10. package/dist/ie/index.umd.js +4457 -0
  11. package/dist/ie/index.umd.js.map +1 -0
  12. package/dist/ie/index.umd.min.js +1 -0
  13. package/dist/ie/types/src/core/blind.d.ts +18 -0
  14. package/dist/ie/types/src/core/canvas.d.ts +51 -0
  15. package/dist/ie/types/src/core/image.d.ts +22 -0
  16. package/dist/ie/types/src/core/layout/grid.d.ts +14 -0
  17. package/dist/ie/types/src/core/layout/index.d.ts +4 -0
  18. package/dist/ie/types/src/core/watermark.d.ts +48 -0
  19. package/dist/ie/types/src/index.d.ts +5 -0
  20. package/dist/ie/types/src/index.ie.d.ts +6 -0
  21. package/dist/ie/types/src/style/index.d.ts +1 -0
  22. package/dist/ie/types/src/types/index.d.ts +127 -0
  23. package/dist/ie/types/src/utils/bootstrap.d.ts +2 -0
  24. package/dist/ie/types/src/utils/index.d.ts +14 -0
  25. package/dist/ie/types/src/utils/initialization.d.ts +19 -0
  26. package/dist/ie/types/tests/core/blind.test.d.ts +1 -0
  27. package/dist/ie/types/tests/core/image.test.d.ts +1 -0
  28. package/dist/ie/types/tests/core/watermark.test.d.ts +1 -0
  29. package/dist/ie/types/tests/utils/index.d.ts +1 -0
  30. package/dist/ie/types/tests/utils/index.test.d.ts +1 -0
  31. package/dist/index.cjs.js +21 -10
  32. package/dist/index.cjs.js.map +1 -1
  33. package/dist/index.cjs.min.js +1 -1
  34. package/dist/index.esm.js +21 -10
  35. package/dist/index.esm.js.map +1 -1
  36. package/dist/index.esm.min.js +1 -1
  37. package/dist/index.iife.js +21 -10
  38. package/dist/index.iife.js.map +1 -1
  39. package/dist/index.iife.min.js +1 -1
  40. package/dist/index.umd.js +21 -10
  41. package/dist/index.umd.js.map +1 -1
  42. package/dist/index.umd.min.js +1 -1
  43. package/dist/types/src/core/watermark.d.ts +1 -0
  44. package/dist/types/src/index.ie.d.ts +6 -0
  45. package/package.json +31 -22
  46. package/dist/types/docs/components/config.d.ts +0 -72
  47. package/dist/types/jest.setup.d.ts +0 -1
@@ -0,0 +1,4456 @@
1
+ /*!
2
+ * watermark-js-plus v1.5.3
3
+ * (c) 2022-2024 Michael Sun
4
+ * Released under the MIT License.
5
+ */
6
+ var WatermarkPlus = (function (exports) {
7
+ 'use strict';
8
+
9
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
+
11
+ var check = function (it) {
12
+ return it && it.Math === Math && it;
13
+ };
14
+
15
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
16
+ var globalThis_1 =
17
+ // eslint-disable-next-line es/no-global-this -- safe
18
+ check(typeof globalThis == 'object' && globalThis) ||
19
+ check(typeof window == 'object' && window) ||
20
+ // eslint-disable-next-line no-restricted-globals -- safe
21
+ check(typeof self == 'object' && self) ||
22
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
23
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
24
+ // eslint-disable-next-line no-new-func -- fallback
25
+ (function () { return this; })() || Function('return this')();
26
+
27
+ var objectGetOwnPropertyDescriptor = {};
28
+
29
+ var fails$b = function (exec) {
30
+ try {
31
+ return !!exec();
32
+ } catch (error) {
33
+ return true;
34
+ }
35
+ };
36
+
37
+ var fails$a = fails$b;
38
+
39
+ // Detect IE8's incomplete defineProperty implementation
40
+ var descriptors = !fails$a(function () {
41
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
42
+ return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
43
+ });
44
+
45
+ var fails$9 = fails$b;
46
+
47
+ var functionBindNative = !fails$9(function () {
48
+ // eslint-disable-next-line es/no-function-prototype-bind -- safe
49
+ var test = (function () { /* empty */ }).bind();
50
+ // eslint-disable-next-line no-prototype-builtins -- safe
51
+ return typeof test != 'function' || test.hasOwnProperty('prototype');
52
+ });
53
+
54
+ var NATIVE_BIND$3 = functionBindNative;
55
+
56
+ var call$c = Function.prototype.call;
57
+
58
+ var functionCall = NATIVE_BIND$3 ? call$c.bind(call$c) : function () {
59
+ return call$c.apply(call$c, arguments);
60
+ };
61
+
62
+ var objectPropertyIsEnumerable = {};
63
+
64
+ var $propertyIsEnumerable = {}.propertyIsEnumerable;
65
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
66
+ var getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor;
67
+
68
+ // Nashorn ~ JDK8 bug
69
+ var NASHORN_BUG = getOwnPropertyDescriptor$2 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
70
+
71
+ // `Object.prototype.propertyIsEnumerable` method implementation
72
+ // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
73
+ objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
74
+ var descriptor = getOwnPropertyDescriptor$2(this, V);
75
+ return !!descriptor && descriptor.enumerable;
76
+ } : $propertyIsEnumerable;
77
+
78
+ var createPropertyDescriptor$3 = function (bitmap, value) {
79
+ return {
80
+ enumerable: !(bitmap & 1),
81
+ configurable: !(bitmap & 2),
82
+ writable: !(bitmap & 4),
83
+ value: value
84
+ };
85
+ };
86
+
87
+ var NATIVE_BIND$2 = functionBindNative;
88
+
89
+ var FunctionPrototype$2 = Function.prototype;
90
+ var call$b = FunctionPrototype$2.call;
91
+ var uncurryThisWithBind = NATIVE_BIND$2 && FunctionPrototype$2.bind.bind(call$b, call$b);
92
+
93
+ var functionUncurryThis = NATIVE_BIND$2 ? uncurryThisWithBind : function (fn) {
94
+ return function () {
95
+ return call$b.apply(fn, arguments);
96
+ };
97
+ };
98
+
99
+ var uncurryThis$d = functionUncurryThis;
100
+
101
+ var toString$1 = uncurryThis$d({}.toString);
102
+ var stringSlice$1 = uncurryThis$d(''.slice);
103
+
104
+ var classofRaw$2 = function (it) {
105
+ return stringSlice$1(toString$1(it), 8, -1);
106
+ };
107
+
108
+ var uncurryThis$c = functionUncurryThis;
109
+ var fails$8 = fails$b;
110
+ var classof$4 = classofRaw$2;
111
+
112
+ var $Object$3 = Object;
113
+ var split = uncurryThis$c(''.split);
114
+
115
+ // fallback for non-array-like ES3 and non-enumerable old V8 strings
116
+ var indexedObject = fails$8(function () {
117
+ // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
118
+ // eslint-disable-next-line no-prototype-builtins -- safe
119
+ return !$Object$3('z').propertyIsEnumerable(0);
120
+ }) ? function (it) {
121
+ return classof$4(it) === 'String' ? split(it, '') : $Object$3(it);
122
+ } : $Object$3;
123
+
124
+ // we can't use just `it == null` since of `document.all` special case
125
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
126
+ var isNullOrUndefined$4 = function (it) {
127
+ return it === null || it === undefined;
128
+ };
129
+
130
+ var isNullOrUndefined$3 = isNullOrUndefined$4;
131
+
132
+ var $TypeError$c = TypeError;
133
+
134
+ // `RequireObjectCoercible` abstract operation
135
+ // https://tc39.es/ecma262/#sec-requireobjectcoercible
136
+ var requireObjectCoercible$3 = function (it) {
137
+ if (isNullOrUndefined$3(it)) throw new $TypeError$c("Can't call method on " + it);
138
+ return it;
139
+ };
140
+
141
+ // toObject with fallback for non-array-like ES3 strings
142
+ var IndexedObject = indexedObject;
143
+ var requireObjectCoercible$2 = requireObjectCoercible$3;
144
+
145
+ var toIndexedObject$4 = function (it) {
146
+ return IndexedObject(requireObjectCoercible$2(it));
147
+ };
148
+
149
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
150
+ var documentAll = typeof document == 'object' && document.all;
151
+
152
+ // `IsCallable` abstract operation
153
+ // https://tc39.es/ecma262/#sec-iscallable
154
+ // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
155
+ var isCallable$g = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
156
+ return typeof argument == 'function' || argument === documentAll;
157
+ } : function (argument) {
158
+ return typeof argument == 'function';
159
+ };
160
+
161
+ var isCallable$f = isCallable$g;
162
+
163
+ var isObject$9 = function (it) {
164
+ return typeof it == 'object' ? it !== null : isCallable$f(it);
165
+ };
166
+
167
+ var globalThis$i = globalThis_1;
168
+ var isCallable$e = isCallable$g;
169
+
170
+ var aFunction = function (argument) {
171
+ return isCallable$e(argument) ? argument : undefined;
172
+ };
173
+
174
+ var getBuiltIn$7 = function (namespace, method) {
175
+ return arguments.length < 2 ? aFunction(globalThis$i[namespace]) : globalThis$i[namespace] && globalThis$i[namespace][method];
176
+ };
177
+
178
+ var uncurryThis$b = functionUncurryThis;
179
+
180
+ var objectIsPrototypeOf = uncurryThis$b({}.isPrototypeOf);
181
+
182
+ var globalThis$h = globalThis_1;
183
+
184
+ var navigator = globalThis$h.navigator;
185
+ var userAgent$5 = navigator && navigator.userAgent;
186
+
187
+ var environmentUserAgent = userAgent$5 ? String(userAgent$5) : '';
188
+
189
+ var globalThis$g = globalThis_1;
190
+ var userAgent$4 = environmentUserAgent;
191
+
192
+ var process$3 = globalThis$g.process;
193
+ var Deno$1 = globalThis$g.Deno;
194
+ var versions = process$3 && process$3.versions || Deno$1 && Deno$1.version;
195
+ var v8 = versions && versions.v8;
196
+ var match, version;
197
+
198
+ if (v8) {
199
+ match = v8.split('.');
200
+ // in old Chrome, versions of V8 isn't V8 = Chrome / 10
201
+ // but their correct versions are not interesting for us
202
+ version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
203
+ }
204
+
205
+ // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
206
+ // so check `userAgent` even if `.v8` exists, but 0
207
+ if (!version && userAgent$4) {
208
+ match = userAgent$4.match(/Edge\/(\d+)/);
209
+ if (!match || match[1] >= 74) {
210
+ match = userAgent$4.match(/Chrome\/(\d+)/);
211
+ if (match) version = +match[1];
212
+ }
213
+ }
214
+
215
+ var environmentV8Version = version;
216
+
217
+ /* eslint-disable es/no-symbol -- required for testing */
218
+ var V8_VERSION$1 = environmentV8Version;
219
+ var fails$7 = fails$b;
220
+ var globalThis$f = globalThis_1;
221
+
222
+ var $String$4 = globalThis$f.String;
223
+
224
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
225
+ var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$7(function () {
226
+ var symbol = Symbol('symbol detection');
227
+ // Chrome 38 Symbol has incorrect toString conversion
228
+ // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
229
+ // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
230
+ // of course, fail.
231
+ return !$String$4(symbol) || !(Object(symbol) instanceof Symbol) ||
232
+ // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
233
+ !Symbol.sham && V8_VERSION$1 && V8_VERSION$1 < 41;
234
+ });
235
+
236
+ /* eslint-disable es/no-symbol -- required for testing */
237
+ var NATIVE_SYMBOL$1 = symbolConstructorDetection;
238
+
239
+ var useSymbolAsUid = NATIVE_SYMBOL$1
240
+ && !Symbol.sham
241
+ && typeof Symbol.iterator == 'symbol';
242
+
243
+ var getBuiltIn$6 = getBuiltIn$7;
244
+ var isCallable$d = isCallable$g;
245
+ var isPrototypeOf$2 = objectIsPrototypeOf;
246
+ var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
247
+
248
+ var $Object$2 = Object;
249
+
250
+ var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
251
+ return typeof it == 'symbol';
252
+ } : function (it) {
253
+ var $Symbol = getBuiltIn$6('Symbol');
254
+ return isCallable$d($Symbol) && isPrototypeOf$2($Symbol.prototype, $Object$2(it));
255
+ };
256
+
257
+ var $String$3 = String;
258
+
259
+ var tryToString$4 = function (argument) {
260
+ try {
261
+ return $String$3(argument);
262
+ } catch (error) {
263
+ return 'Object';
264
+ }
265
+ };
266
+
267
+ var isCallable$c = isCallable$g;
268
+ var tryToString$3 = tryToString$4;
269
+
270
+ var $TypeError$b = TypeError;
271
+
272
+ // `Assert: IsCallable(argument) is true`
273
+ var aCallable$8 = function (argument) {
274
+ if (isCallable$c(argument)) return argument;
275
+ throw new $TypeError$b(tryToString$3(argument) + ' is not a function');
276
+ };
277
+
278
+ var aCallable$7 = aCallable$8;
279
+ var isNullOrUndefined$2 = isNullOrUndefined$4;
280
+
281
+ // `GetMethod` abstract operation
282
+ // https://tc39.es/ecma262/#sec-getmethod
283
+ var getMethod$3 = function (V, P) {
284
+ var func = V[P];
285
+ return isNullOrUndefined$2(func) ? undefined : aCallable$7(func);
286
+ };
287
+
288
+ var call$a = functionCall;
289
+ var isCallable$b = isCallable$g;
290
+ var isObject$8 = isObject$9;
291
+
292
+ var $TypeError$a = TypeError;
293
+
294
+ // `OrdinaryToPrimitive` abstract operation
295
+ // https://tc39.es/ecma262/#sec-ordinarytoprimitive
296
+ var ordinaryToPrimitive$1 = function (input, pref) {
297
+ var fn, val;
298
+ if (pref === 'string' && isCallable$b(fn = input.toString) && !isObject$8(val = call$a(fn, input))) return val;
299
+ if (isCallable$b(fn = input.valueOf) && !isObject$8(val = call$a(fn, input))) return val;
300
+ if (pref !== 'string' && isCallable$b(fn = input.toString) && !isObject$8(val = call$a(fn, input))) return val;
301
+ throw new $TypeError$a("Can't convert object to primitive value");
302
+ };
303
+
304
+ var sharedStore = {exports: {}};
305
+
306
+ var globalThis$e = globalThis_1;
307
+
308
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
309
+ var defineProperty$4 = Object.defineProperty;
310
+
311
+ var defineGlobalProperty$3 = function (key, value) {
312
+ try {
313
+ defineProperty$4(globalThis$e, key, { value: value, configurable: true, writable: true });
314
+ } catch (error) {
315
+ globalThis$e[key] = value;
316
+ } return value;
317
+ };
318
+
319
+ var globalThis$d = globalThis_1;
320
+ var defineGlobalProperty$2 = defineGlobalProperty$3;
321
+
322
+ var SHARED = '__core-js_shared__';
323
+ var store$3 = sharedStore.exports = globalThis$d[SHARED] || defineGlobalProperty$2(SHARED, {});
324
+
325
+ (store$3.versions || (store$3.versions = [])).push({
326
+ version: '3.38.0',
327
+ mode: 'global',
328
+ copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
329
+ license: 'https://github.com/zloirock/core-js/blob/v3.38.0/LICENSE',
330
+ source: 'https://github.com/zloirock/core-js'
331
+ });
332
+
333
+ var sharedStoreExports = sharedStore.exports;
334
+
335
+ var store$2 = sharedStoreExports;
336
+
337
+ var shared$3 = function (key, value) {
338
+ return store$2[key] || (store$2[key] = value || {});
339
+ };
340
+
341
+ var requireObjectCoercible$1 = requireObjectCoercible$3;
342
+
343
+ var $Object$1 = Object;
344
+
345
+ // `ToObject` abstract operation
346
+ // https://tc39.es/ecma262/#sec-toobject
347
+ var toObject$3 = function (argument) {
348
+ return $Object$1(requireObjectCoercible$1(argument));
349
+ };
350
+
351
+ var uncurryThis$a = functionUncurryThis;
352
+ var toObject$2 = toObject$3;
353
+
354
+ var hasOwnProperty = uncurryThis$a({}.hasOwnProperty);
355
+
356
+ // `HasOwnProperty` abstract operation
357
+ // https://tc39.es/ecma262/#sec-hasownproperty
358
+ // eslint-disable-next-line es/no-object-hasown -- safe
359
+ var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
360
+ return hasOwnProperty(toObject$2(it), key);
361
+ };
362
+
363
+ var uncurryThis$9 = functionUncurryThis;
364
+
365
+ var id = 0;
366
+ var postfix = Math.random();
367
+ var toString = uncurryThis$9(1.0.toString);
368
+
369
+ var uid$2 = function (key) {
370
+ return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
371
+ };
372
+
373
+ var globalThis$c = globalThis_1;
374
+ var shared$2 = shared$3;
375
+ var hasOwn$8 = hasOwnProperty_1;
376
+ var uid$1 = uid$2;
377
+ var NATIVE_SYMBOL = symbolConstructorDetection;
378
+ var USE_SYMBOL_AS_UID = useSymbolAsUid;
379
+
380
+ var Symbol$1 = globalThis$c.Symbol;
381
+ var WellKnownSymbolsStore = shared$2('wks');
382
+ var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
383
+
384
+ var wellKnownSymbol$b = function (name) {
385
+ if (!hasOwn$8(WellKnownSymbolsStore, name)) {
386
+ WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn$8(Symbol$1, name)
387
+ ? Symbol$1[name]
388
+ : createWellKnownSymbol('Symbol.' + name);
389
+ } return WellKnownSymbolsStore[name];
390
+ };
391
+
392
+ var call$9 = functionCall;
393
+ var isObject$7 = isObject$9;
394
+ var isSymbol$1 = isSymbol$2;
395
+ var getMethod$2 = getMethod$3;
396
+ var ordinaryToPrimitive = ordinaryToPrimitive$1;
397
+ var wellKnownSymbol$a = wellKnownSymbol$b;
398
+
399
+ var $TypeError$9 = TypeError;
400
+ var TO_PRIMITIVE = wellKnownSymbol$a('toPrimitive');
401
+
402
+ // `ToPrimitive` abstract operation
403
+ // https://tc39.es/ecma262/#sec-toprimitive
404
+ var toPrimitive$1 = function (input, pref) {
405
+ if (!isObject$7(input) || isSymbol$1(input)) return input;
406
+ var exoticToPrim = getMethod$2(input, TO_PRIMITIVE);
407
+ var result;
408
+ if (exoticToPrim) {
409
+ if (pref === undefined) pref = 'default';
410
+ result = call$9(exoticToPrim, input, pref);
411
+ if (!isObject$7(result) || isSymbol$1(result)) return result;
412
+ throw new $TypeError$9("Can't convert object to primitive value");
413
+ }
414
+ if (pref === undefined) pref = 'number';
415
+ return ordinaryToPrimitive(input, pref);
416
+ };
417
+
418
+ var toPrimitive = toPrimitive$1;
419
+ var isSymbol = isSymbol$2;
420
+
421
+ // `ToPropertyKey` abstract operation
422
+ // https://tc39.es/ecma262/#sec-topropertykey
423
+ var toPropertyKey$2 = function (argument) {
424
+ var key = toPrimitive(argument, 'string');
425
+ return isSymbol(key) ? key : key + '';
426
+ };
427
+
428
+ var globalThis$b = globalThis_1;
429
+ var isObject$6 = isObject$9;
430
+
431
+ var document$3 = globalThis$b.document;
432
+ // typeof document.createElement is 'object' in old IE
433
+ var EXISTS$1 = isObject$6(document$3) && isObject$6(document$3.createElement);
434
+
435
+ var documentCreateElement$1 = function (it) {
436
+ return EXISTS$1 ? document$3.createElement(it) : {};
437
+ };
438
+
439
+ var DESCRIPTORS$a = descriptors;
440
+ var fails$6 = fails$b;
441
+ var createElement$1 = documentCreateElement$1;
442
+
443
+ // Thanks to IE8 for its funny defineProperty
444
+ var ie8DomDefine = !DESCRIPTORS$a && !fails$6(function () {
445
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
446
+ return Object.defineProperty(createElement$1('div'), 'a', {
447
+ get: function () { return 7; }
448
+ }).a !== 7;
449
+ });
450
+
451
+ var DESCRIPTORS$9 = descriptors;
452
+ var call$8 = functionCall;
453
+ var propertyIsEnumerableModule = objectPropertyIsEnumerable;
454
+ var createPropertyDescriptor$2 = createPropertyDescriptor$3;
455
+ var toIndexedObject$3 = toIndexedObject$4;
456
+ var toPropertyKey$1 = toPropertyKey$2;
457
+ var hasOwn$7 = hasOwnProperty_1;
458
+ var IE8_DOM_DEFINE$1 = ie8DomDefine;
459
+
460
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
461
+ var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
462
+
463
+ // `Object.getOwnPropertyDescriptor` method
464
+ // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
465
+ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$9 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
466
+ O = toIndexedObject$3(O);
467
+ P = toPropertyKey$1(P);
468
+ if (IE8_DOM_DEFINE$1) try {
469
+ return $getOwnPropertyDescriptor$1(O, P);
470
+ } catch (error) { /* empty */ }
471
+ if (hasOwn$7(O, P)) return createPropertyDescriptor$2(!call$8(propertyIsEnumerableModule.f, O, P), O[P]);
472
+ };
473
+
474
+ var objectDefineProperty = {};
475
+
476
+ var DESCRIPTORS$8 = descriptors;
477
+ var fails$5 = fails$b;
478
+
479
+ // V8 ~ Chrome 36-
480
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3334
481
+ var v8PrototypeDefineBug = DESCRIPTORS$8 && fails$5(function () {
482
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
483
+ return Object.defineProperty(function () { /* empty */ }, 'prototype', {
484
+ value: 42,
485
+ writable: false
486
+ }).prototype !== 42;
487
+ });
488
+
489
+ var isObject$5 = isObject$9;
490
+
491
+ var $String$2 = String;
492
+ var $TypeError$8 = TypeError;
493
+
494
+ // `Assert: Type(argument) is Object`
495
+ var anObject$a = function (argument) {
496
+ if (isObject$5(argument)) return argument;
497
+ throw new $TypeError$8($String$2(argument) + ' is not an object');
498
+ };
499
+
500
+ var DESCRIPTORS$7 = descriptors;
501
+ var IE8_DOM_DEFINE = ie8DomDefine;
502
+ var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug;
503
+ var anObject$9 = anObject$a;
504
+ var toPropertyKey = toPropertyKey$2;
505
+
506
+ var $TypeError$7 = TypeError;
507
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
508
+ var $defineProperty = Object.defineProperty;
509
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
510
+ var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
511
+ var ENUMERABLE = 'enumerable';
512
+ var CONFIGURABLE$1 = 'configurable';
513
+ var WRITABLE = 'writable';
514
+
515
+ // `Object.defineProperty` method
516
+ // https://tc39.es/ecma262/#sec-object.defineproperty
517
+ objectDefineProperty.f = DESCRIPTORS$7 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) {
518
+ anObject$9(O);
519
+ P = toPropertyKey(P);
520
+ anObject$9(Attributes);
521
+ if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
522
+ var current = $getOwnPropertyDescriptor(O, P);
523
+ if (current && current[WRITABLE]) {
524
+ O[P] = Attributes.value;
525
+ Attributes = {
526
+ configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
527
+ enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
528
+ writable: false
529
+ };
530
+ }
531
+ } return $defineProperty(O, P, Attributes);
532
+ } : $defineProperty : function defineProperty(O, P, Attributes) {
533
+ anObject$9(O);
534
+ P = toPropertyKey(P);
535
+ anObject$9(Attributes);
536
+ if (IE8_DOM_DEFINE) try {
537
+ return $defineProperty(O, P, Attributes);
538
+ } catch (error) { /* empty */ }
539
+ if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$7('Accessors not supported');
540
+ if ('value' in Attributes) O[P] = Attributes.value;
541
+ return O;
542
+ };
543
+
544
+ var DESCRIPTORS$6 = descriptors;
545
+ var definePropertyModule$4 = objectDefineProperty;
546
+ var createPropertyDescriptor$1 = createPropertyDescriptor$3;
547
+
548
+ var createNonEnumerableProperty$2 = DESCRIPTORS$6 ? function (object, key, value) {
549
+ return definePropertyModule$4.f(object, key, createPropertyDescriptor$1(1, value));
550
+ } : function (object, key, value) {
551
+ object[key] = value;
552
+ return object;
553
+ };
554
+
555
+ var makeBuiltIn$3 = {exports: {}};
556
+
557
+ var DESCRIPTORS$5 = descriptors;
558
+ var hasOwn$6 = hasOwnProperty_1;
559
+
560
+ var FunctionPrototype$1 = Function.prototype;
561
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
562
+ var getDescriptor = DESCRIPTORS$5 && Object.getOwnPropertyDescriptor;
563
+
564
+ var EXISTS = hasOwn$6(FunctionPrototype$1, 'name');
565
+ // additional protection from minified / mangled / dropped function names
566
+ var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
567
+ var CONFIGURABLE = EXISTS && (!DESCRIPTORS$5 || (DESCRIPTORS$5 && getDescriptor(FunctionPrototype$1, 'name').configurable));
568
+
569
+ var functionName = {
570
+ EXISTS: EXISTS,
571
+ PROPER: PROPER,
572
+ CONFIGURABLE: CONFIGURABLE
573
+ };
574
+
575
+ var uncurryThis$8 = functionUncurryThis;
576
+ var isCallable$a = isCallable$g;
577
+ var store$1 = sharedStoreExports;
578
+
579
+ var functionToString = uncurryThis$8(Function.toString);
580
+
581
+ // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
582
+ if (!isCallable$a(store$1.inspectSource)) {
583
+ store$1.inspectSource = function (it) {
584
+ return functionToString(it);
585
+ };
586
+ }
587
+
588
+ var inspectSource$3 = store$1.inspectSource;
589
+
590
+ var globalThis$a = globalThis_1;
591
+ var isCallable$9 = isCallable$g;
592
+
593
+ var WeakMap$1 = globalThis$a.WeakMap;
594
+
595
+ var weakMapBasicDetection = isCallable$9(WeakMap$1) && /native code/.test(String(WeakMap$1));
596
+
597
+ var shared$1 = shared$3;
598
+ var uid = uid$2;
599
+
600
+ var keys = shared$1('keys');
601
+
602
+ var sharedKey$2 = function (key) {
603
+ return keys[key] || (keys[key] = uid(key));
604
+ };
605
+
606
+ var hiddenKeys$4 = {};
607
+
608
+ var NATIVE_WEAK_MAP = weakMapBasicDetection;
609
+ var globalThis$9 = globalThis_1;
610
+ var isObject$4 = isObject$9;
611
+ var createNonEnumerableProperty$1 = createNonEnumerableProperty$2;
612
+ var hasOwn$5 = hasOwnProperty_1;
613
+ var shared = sharedStoreExports;
614
+ var sharedKey$1 = sharedKey$2;
615
+ var hiddenKeys$3 = hiddenKeys$4;
616
+
617
+ var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
618
+ var TypeError$2 = globalThis$9.TypeError;
619
+ var WeakMap = globalThis$9.WeakMap;
620
+ var set$1, get, has;
621
+
622
+ var enforce = function (it) {
623
+ return has(it) ? get(it) : set$1(it, {});
624
+ };
625
+
626
+ var getterFor = function (TYPE) {
627
+ return function (it) {
628
+ var state;
629
+ if (!isObject$4(it) || (state = get(it)).type !== TYPE) {
630
+ throw new TypeError$2('Incompatible receiver, ' + TYPE + ' required');
631
+ } return state;
632
+ };
633
+ };
634
+
635
+ if (NATIVE_WEAK_MAP || shared.state) {
636
+ var store = shared.state || (shared.state = new WeakMap());
637
+ /* eslint-disable no-self-assign -- prototype methods protection */
638
+ store.get = store.get;
639
+ store.has = store.has;
640
+ store.set = store.set;
641
+ /* eslint-enable no-self-assign -- prototype methods protection */
642
+ set$1 = function (it, metadata) {
643
+ if (store.has(it)) throw new TypeError$2(OBJECT_ALREADY_INITIALIZED);
644
+ metadata.facade = it;
645
+ store.set(it, metadata);
646
+ return metadata;
647
+ };
648
+ get = function (it) {
649
+ return store.get(it) || {};
650
+ };
651
+ has = function (it) {
652
+ return store.has(it);
653
+ };
654
+ } else {
655
+ var STATE = sharedKey$1('state');
656
+ hiddenKeys$3[STATE] = true;
657
+ set$1 = function (it, metadata) {
658
+ if (hasOwn$5(it, STATE)) throw new TypeError$2(OBJECT_ALREADY_INITIALIZED);
659
+ metadata.facade = it;
660
+ createNonEnumerableProperty$1(it, STATE, metadata);
661
+ return metadata;
662
+ };
663
+ get = function (it) {
664
+ return hasOwn$5(it, STATE) ? it[STATE] : {};
665
+ };
666
+ has = function (it) {
667
+ return hasOwn$5(it, STATE);
668
+ };
669
+ }
670
+
671
+ var internalState = {
672
+ set: set$1,
673
+ get: get,
674
+ has: has,
675
+ enforce: enforce,
676
+ getterFor: getterFor
677
+ };
678
+
679
+ var uncurryThis$7 = functionUncurryThis;
680
+ var fails$4 = fails$b;
681
+ var isCallable$8 = isCallable$g;
682
+ var hasOwn$4 = hasOwnProperty_1;
683
+ var DESCRIPTORS$4 = descriptors;
684
+ var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
685
+ var inspectSource$2 = inspectSource$3;
686
+ var InternalStateModule$1 = internalState;
687
+
688
+ var enforceInternalState = InternalStateModule$1.enforce;
689
+ var getInternalState = InternalStateModule$1.get;
690
+ var $String$1 = String;
691
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
692
+ var defineProperty$3 = Object.defineProperty;
693
+ var stringSlice = uncurryThis$7(''.slice);
694
+ var replace = uncurryThis$7(''.replace);
695
+ var join = uncurryThis$7([].join);
696
+
697
+ var CONFIGURABLE_LENGTH = DESCRIPTORS$4 && !fails$4(function () {
698
+ return defineProperty$3(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
699
+ });
700
+
701
+ var TEMPLATE = String(String).split('String');
702
+
703
+ var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) {
704
+ if (stringSlice($String$1(name), 0, 7) === 'Symbol(') {
705
+ name = '[' + replace($String$1(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
706
+ }
707
+ if (options && options.getter) name = 'get ' + name;
708
+ if (options && options.setter) name = 'set ' + name;
709
+ if (!hasOwn$4(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
710
+ if (DESCRIPTORS$4) defineProperty$3(value, 'name', { value: name, configurable: true });
711
+ else value.name = name;
712
+ }
713
+ if (CONFIGURABLE_LENGTH && options && hasOwn$4(options, 'arity') && value.length !== options.arity) {
714
+ defineProperty$3(value, 'length', { value: options.arity });
715
+ }
716
+ try {
717
+ if (options && hasOwn$4(options, 'constructor') && options.constructor) {
718
+ if (DESCRIPTORS$4) defineProperty$3(value, 'prototype', { writable: false });
719
+ // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
720
+ } else if (value.prototype) value.prototype = undefined;
721
+ } catch (error) { /* empty */ }
722
+ var state = enforceInternalState(value);
723
+ if (!hasOwn$4(state, 'source')) {
724
+ state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
725
+ } return value;
726
+ };
727
+
728
+ // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
729
+ // eslint-disable-next-line no-extend-native -- required
730
+ Function.prototype.toString = makeBuiltIn$2(function toString() {
731
+ return isCallable$8(this) && getInternalState(this).source || inspectSource$2(this);
732
+ }, 'toString');
733
+
734
+ var makeBuiltInExports = makeBuiltIn$3.exports;
735
+
736
+ var isCallable$7 = isCallable$g;
737
+ var definePropertyModule$3 = objectDefineProperty;
738
+ var makeBuiltIn$1 = makeBuiltInExports;
739
+ var defineGlobalProperty$1 = defineGlobalProperty$3;
740
+
741
+ var defineBuiltIn$3 = function (O, key, value, options) {
742
+ if (!options) options = {};
743
+ var simple = options.enumerable;
744
+ var name = options.name !== undefined ? options.name : key;
745
+ if (isCallable$7(value)) makeBuiltIn$1(value, name, options);
746
+ if (options.global) {
747
+ if (simple) O[key] = value;
748
+ else defineGlobalProperty$1(key, value);
749
+ } else {
750
+ try {
751
+ if (!options.unsafe) delete O[key];
752
+ else if (O[key]) simple = true;
753
+ } catch (error) { /* empty */ }
754
+ if (simple) O[key] = value;
755
+ else definePropertyModule$3.f(O, key, {
756
+ value: value,
757
+ enumerable: false,
758
+ configurable: !options.nonConfigurable,
759
+ writable: !options.nonWritable
760
+ });
761
+ } return O;
762
+ };
763
+
764
+ var objectGetOwnPropertyNames = {};
765
+
766
+ var ceil = Math.ceil;
767
+ var floor = Math.floor;
768
+
769
+ // `Math.trunc` method
770
+ // https://tc39.es/ecma262/#sec-math.trunc
771
+ // eslint-disable-next-line es/no-math-trunc -- safe
772
+ var mathTrunc = Math.trunc || function trunc(x) {
773
+ var n = +x;
774
+ return (n > 0 ? floor : ceil)(n);
775
+ };
776
+
777
+ var trunc = mathTrunc;
778
+
779
+ // `ToIntegerOrInfinity` abstract operation
780
+ // https://tc39.es/ecma262/#sec-tointegerorinfinity
781
+ var toIntegerOrInfinity$2 = function (argument) {
782
+ var number = +argument;
783
+ // eslint-disable-next-line no-self-compare -- NaN check
784
+ return number !== number || number === 0 ? 0 : trunc(number);
785
+ };
786
+
787
+ var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
788
+
789
+ var max = Math.max;
790
+ var min$1 = Math.min;
791
+
792
+ // Helper for a popular repeating case of the spec:
793
+ // Let integer be ? ToInteger(index).
794
+ // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
795
+ var toAbsoluteIndex$2 = function (index, length) {
796
+ var integer = toIntegerOrInfinity$1(index);
797
+ return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
798
+ };
799
+
800
+ var toIntegerOrInfinity = toIntegerOrInfinity$2;
801
+
802
+ var min = Math.min;
803
+
804
+ // `ToLength` abstract operation
805
+ // https://tc39.es/ecma262/#sec-tolength
806
+ var toLength$1 = function (argument) {
807
+ var len = toIntegerOrInfinity(argument);
808
+ return len > 0 ? min(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
809
+ };
810
+
811
+ var toLength = toLength$1;
812
+
813
+ // `LengthOfArrayLike` abstract operation
814
+ // https://tc39.es/ecma262/#sec-lengthofarraylike
815
+ var lengthOfArrayLike$4 = function (obj) {
816
+ return toLength(obj.length);
817
+ };
818
+
819
+ var toIndexedObject$2 = toIndexedObject$4;
820
+ var toAbsoluteIndex$1 = toAbsoluteIndex$2;
821
+ var lengthOfArrayLike$3 = lengthOfArrayLike$4;
822
+
823
+ // `Array.prototype.{ indexOf, includes }` methods implementation
824
+ var createMethod = function (IS_INCLUDES) {
825
+ return function ($this, el, fromIndex) {
826
+ var O = toIndexedObject$2($this);
827
+ var length = lengthOfArrayLike$3(O);
828
+ if (length === 0) return !IS_INCLUDES && -1;
829
+ var index = toAbsoluteIndex$1(fromIndex, length);
830
+ var value;
831
+ // Array#includes uses SameValueZero equality algorithm
832
+ // eslint-disable-next-line no-self-compare -- NaN check
833
+ if (IS_INCLUDES && el !== el) while (length > index) {
834
+ value = O[index++];
835
+ // eslint-disable-next-line no-self-compare -- NaN check
836
+ if (value !== value) return true;
837
+ // Array#indexOf ignores holes, Array#includes - not
838
+ } else for (;length > index; index++) {
839
+ if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
840
+ } return !IS_INCLUDES && -1;
841
+ };
842
+ };
843
+
844
+ var arrayIncludes = {
845
+ // `Array.prototype.includes` method
846
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
847
+ includes: createMethod(true),
848
+ // `Array.prototype.indexOf` method
849
+ // https://tc39.es/ecma262/#sec-array.prototype.indexof
850
+ indexOf: createMethod(false)
851
+ };
852
+
853
+ var uncurryThis$6 = functionUncurryThis;
854
+ var hasOwn$3 = hasOwnProperty_1;
855
+ var toIndexedObject$1 = toIndexedObject$4;
856
+ var indexOf = arrayIncludes.indexOf;
857
+ var hiddenKeys$2 = hiddenKeys$4;
858
+
859
+ var push = uncurryThis$6([].push);
860
+
861
+ var objectKeysInternal = function (object, names) {
862
+ var O = toIndexedObject$1(object);
863
+ var i = 0;
864
+ var result = [];
865
+ var key;
866
+ for (key in O) !hasOwn$3(hiddenKeys$2, key) && hasOwn$3(O, key) && push(result, key);
867
+ // Don't enum bug & hidden keys
868
+ while (names.length > i) if (hasOwn$3(O, key = names[i++])) {
869
+ ~indexOf(result, key) || push(result, key);
870
+ }
871
+ return result;
872
+ };
873
+
874
+ // IE8- don't enum bug keys
875
+ var enumBugKeys$3 = [
876
+ 'constructor',
877
+ 'hasOwnProperty',
878
+ 'isPrototypeOf',
879
+ 'propertyIsEnumerable',
880
+ 'toLocaleString',
881
+ 'toString',
882
+ 'valueOf'
883
+ ];
884
+
885
+ var internalObjectKeys$1 = objectKeysInternal;
886
+ var enumBugKeys$2 = enumBugKeys$3;
887
+
888
+ var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype');
889
+
890
+ // `Object.getOwnPropertyNames` method
891
+ // https://tc39.es/ecma262/#sec-object.getownpropertynames
892
+ // eslint-disable-next-line es/no-object-getownpropertynames -- safe
893
+ objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
894
+ return internalObjectKeys$1(O, hiddenKeys$1);
895
+ };
896
+
897
+ var objectGetOwnPropertySymbols = {};
898
+
899
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
900
+ objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
901
+
902
+ var getBuiltIn$5 = getBuiltIn$7;
903
+ var uncurryThis$5 = functionUncurryThis;
904
+ var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
905
+ var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
906
+ var anObject$8 = anObject$a;
907
+
908
+ var concat = uncurryThis$5([].concat);
909
+
910
+ // all object keys, includes non-enumerable and symbols
911
+ var ownKeys$1 = getBuiltIn$5('Reflect', 'ownKeys') || function ownKeys(it) {
912
+ var keys = getOwnPropertyNamesModule.f(anObject$8(it));
913
+ var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
914
+ return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys;
915
+ };
916
+
917
+ var hasOwn$2 = hasOwnProperty_1;
918
+ var ownKeys = ownKeys$1;
919
+ var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
920
+ var definePropertyModule$2 = objectDefineProperty;
921
+
922
+ var copyConstructorProperties$1 = function (target, source, exceptions) {
923
+ var keys = ownKeys(source);
924
+ var defineProperty = definePropertyModule$2.f;
925
+ var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f;
926
+ for (var i = 0; i < keys.length; i++) {
927
+ var key = keys[i];
928
+ if (!hasOwn$2(target, key) && !(exceptions && hasOwn$2(exceptions, key))) {
929
+ defineProperty(target, key, getOwnPropertyDescriptor(source, key));
930
+ }
931
+ }
932
+ };
933
+
934
+ var fails$3 = fails$b;
935
+ var isCallable$6 = isCallable$g;
936
+
937
+ var replacement = /#|\.prototype\./;
938
+
939
+ var isForced$2 = function (feature, detection) {
940
+ var value = data[normalize(feature)];
941
+ return value === POLYFILL ? true
942
+ : value === NATIVE ? false
943
+ : isCallable$6(detection) ? fails$3(detection)
944
+ : !!detection;
945
+ };
946
+
947
+ var normalize = isForced$2.normalize = function (string) {
948
+ return String(string).replace(replacement, '.').toLowerCase();
949
+ };
950
+
951
+ var data = isForced$2.data = {};
952
+ var NATIVE = isForced$2.NATIVE = 'N';
953
+ var POLYFILL = isForced$2.POLYFILL = 'P';
954
+
955
+ var isForced_1 = isForced$2;
956
+
957
+ var globalThis$8 = globalThis_1;
958
+ var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
959
+ var createNonEnumerableProperty = createNonEnumerableProperty$2;
960
+ var defineBuiltIn$2 = defineBuiltIn$3;
961
+ var defineGlobalProperty = defineGlobalProperty$3;
962
+ var copyConstructorProperties = copyConstructorProperties$1;
963
+ var isForced$1 = isForced_1;
964
+
965
+ /*
966
+ options.target - name of the target object
967
+ options.global - target is the global object
968
+ options.stat - export as static methods of target
969
+ options.proto - export as prototype methods of target
970
+ options.real - real prototype method for the `pure` version
971
+ options.forced - export even if the native feature is available
972
+ options.bind - bind methods to the target, required for the `pure` version
973
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
974
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
975
+ options.sham - add a flag to not completely full polyfills
976
+ options.enumerable - export as enumerable property
977
+ options.dontCallGetSet - prevent calling a getter on target
978
+ options.name - the .name of the function if it does not match the key
979
+ */
980
+ var _export = function (options, source) {
981
+ var TARGET = options.target;
982
+ var GLOBAL = options.global;
983
+ var STATIC = options.stat;
984
+ var FORCED, target, key, targetProperty, sourceProperty, descriptor;
985
+ if (GLOBAL) {
986
+ target = globalThis$8;
987
+ } else if (STATIC) {
988
+ target = globalThis$8[TARGET] || defineGlobalProperty(TARGET, {});
989
+ } else {
990
+ target = globalThis$8[TARGET] && globalThis$8[TARGET].prototype;
991
+ }
992
+ if (target) for (key in source) {
993
+ sourceProperty = source[key];
994
+ if (options.dontCallGetSet) {
995
+ descriptor = getOwnPropertyDescriptor$1(target, key);
996
+ targetProperty = descriptor && descriptor.value;
997
+ } else targetProperty = target[key];
998
+ FORCED = isForced$1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
999
+ // contained in target
1000
+ if (!FORCED && targetProperty !== undefined) {
1001
+ if (typeof sourceProperty == typeof targetProperty) continue;
1002
+ copyConstructorProperties(sourceProperty, targetProperty);
1003
+ }
1004
+ // add a flag to not completely full polyfills
1005
+ if (options.sham || (targetProperty && targetProperty.sham)) {
1006
+ createNonEnumerableProperty(sourceProperty, 'sham', true);
1007
+ }
1008
+ defineBuiltIn$2(target, key, sourceProperty, options);
1009
+ }
1010
+ };
1011
+
1012
+ var classofRaw$1 = classofRaw$2;
1013
+ var uncurryThis$4 = functionUncurryThis;
1014
+
1015
+ var functionUncurryThisClause = function (fn) {
1016
+ // Nashorn bug:
1017
+ // https://github.com/zloirock/core-js/issues/1128
1018
+ // https://github.com/zloirock/core-js/issues/1130
1019
+ if (classofRaw$1(fn) === 'Function') return uncurryThis$4(fn);
1020
+ };
1021
+
1022
+ var uncurryThis$3 = functionUncurryThisClause;
1023
+ var aCallable$6 = aCallable$8;
1024
+ var NATIVE_BIND$1 = functionBindNative;
1025
+
1026
+ var bind$5 = uncurryThis$3(uncurryThis$3.bind);
1027
+
1028
+ // optional / simple context binding
1029
+ var functionBindContext = function (fn, that) {
1030
+ aCallable$6(fn);
1031
+ return that === undefined ? fn : NATIVE_BIND$1 ? bind$5(fn, that) : function (/* ...args */) {
1032
+ return fn.apply(that, arguments);
1033
+ };
1034
+ };
1035
+
1036
+ var call$7 = functionCall;
1037
+ var anObject$7 = anObject$a;
1038
+ var getMethod$1 = getMethod$3;
1039
+
1040
+ var iteratorClose$2 = function (iterator, kind, value) {
1041
+ var innerResult, innerError;
1042
+ anObject$7(iterator);
1043
+ try {
1044
+ innerResult = getMethod$1(iterator, 'return');
1045
+ if (!innerResult) {
1046
+ if (kind === 'throw') throw value;
1047
+ return value;
1048
+ }
1049
+ innerResult = call$7(innerResult, iterator);
1050
+ } catch (error) {
1051
+ innerError = true;
1052
+ innerResult = error;
1053
+ }
1054
+ if (kind === 'throw') throw value;
1055
+ if (innerError) throw innerResult;
1056
+ anObject$7(innerResult);
1057
+ return value;
1058
+ };
1059
+
1060
+ var anObject$6 = anObject$a;
1061
+ var iteratorClose$1 = iteratorClose$2;
1062
+
1063
+ // call something on iterator step with safe closing on error
1064
+ var callWithSafeIterationClosing$1 = function (iterator, fn, value, ENTRIES) {
1065
+ try {
1066
+ return ENTRIES ? fn(anObject$6(value)[0], value[1]) : fn(value);
1067
+ } catch (error) {
1068
+ iteratorClose$1(iterator, 'throw', error);
1069
+ }
1070
+ };
1071
+
1072
+ var iterators = {};
1073
+
1074
+ var wellKnownSymbol$9 = wellKnownSymbol$b;
1075
+ var Iterators$1 = iterators;
1076
+
1077
+ var ITERATOR$2 = wellKnownSymbol$9('iterator');
1078
+ var ArrayPrototype$1 = Array.prototype;
1079
+
1080
+ // check on default Array iterator
1081
+ var isArrayIteratorMethod$2 = function (it) {
1082
+ return it !== undefined && (Iterators$1.Array === it || ArrayPrototype$1[ITERATOR$2] === it);
1083
+ };
1084
+
1085
+ var wellKnownSymbol$8 = wellKnownSymbol$b;
1086
+
1087
+ var TO_STRING_TAG$2 = wellKnownSymbol$8('toStringTag');
1088
+ var test = {};
1089
+
1090
+ test[TO_STRING_TAG$2] = 'z';
1091
+
1092
+ var toStringTagSupport = String(test) === '[object z]';
1093
+
1094
+ var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1095
+ var isCallable$5 = isCallable$g;
1096
+ var classofRaw = classofRaw$2;
1097
+ var wellKnownSymbol$7 = wellKnownSymbol$b;
1098
+
1099
+ var TO_STRING_TAG$1 = wellKnownSymbol$7('toStringTag');
1100
+ var $Object = Object;
1101
+
1102
+ // ES3 wrong here
1103
+ var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
1104
+
1105
+ // fallback for IE11 Script Access Denied error
1106
+ var tryGet = function (it, key) {
1107
+ try {
1108
+ return it[key];
1109
+ } catch (error) { /* empty */ }
1110
+ };
1111
+
1112
+ // getting tag from ES6+ `Object.prototype.toString`
1113
+ var classof$3 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
1114
+ var O, tag, result;
1115
+ return it === undefined ? 'Undefined' : it === null ? 'Null'
1116
+ // @@toStringTag case
1117
+ : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG$1)) == 'string' ? tag
1118
+ // builtinTag case
1119
+ : CORRECT_ARGUMENTS ? classofRaw(O)
1120
+ // ES3 arguments fallback
1121
+ : (result = classofRaw(O)) === 'Object' && isCallable$5(O.callee) ? 'Arguments' : result;
1122
+ };
1123
+
1124
+ var uncurryThis$2 = functionUncurryThis;
1125
+ var fails$2 = fails$b;
1126
+ var isCallable$4 = isCallable$g;
1127
+ var classof$2 = classof$3;
1128
+ var getBuiltIn$4 = getBuiltIn$7;
1129
+ var inspectSource$1 = inspectSource$3;
1130
+
1131
+ var noop = function () { /* empty */ };
1132
+ var construct = getBuiltIn$4('Reflect', 'construct');
1133
+ var constructorRegExp = /^\s*(?:class|function)\b/;
1134
+ var exec = uncurryThis$2(constructorRegExp.exec);
1135
+ var INCORRECT_TO_STRING = !constructorRegExp.test(noop);
1136
+
1137
+ var isConstructorModern = function isConstructor(argument) {
1138
+ if (!isCallable$4(argument)) return false;
1139
+ try {
1140
+ construct(noop, [], argument);
1141
+ return true;
1142
+ } catch (error) {
1143
+ return false;
1144
+ }
1145
+ };
1146
+
1147
+ var isConstructorLegacy = function isConstructor(argument) {
1148
+ if (!isCallable$4(argument)) return false;
1149
+ switch (classof$2(argument)) {
1150
+ case 'AsyncFunction':
1151
+ case 'GeneratorFunction':
1152
+ case 'AsyncGeneratorFunction': return false;
1153
+ }
1154
+ try {
1155
+ // we can't check .prototype since constructors produced by .bind haven't it
1156
+ // `Function#toString` throws on some built-it function in some legacy engines
1157
+ // (for example, `DOMQuad` and similar in FF41-)
1158
+ return INCORRECT_TO_STRING || !!exec(constructorRegExp, inspectSource$1(argument));
1159
+ } catch (error) {
1160
+ return true;
1161
+ }
1162
+ };
1163
+
1164
+ isConstructorLegacy.sham = true;
1165
+
1166
+ // `IsConstructor` abstract operation
1167
+ // https://tc39.es/ecma262/#sec-isconstructor
1168
+ var isConstructor$2 = !construct || fails$2(function () {
1169
+ var called;
1170
+ return isConstructorModern(isConstructorModern.call)
1171
+ || !isConstructorModern(Object)
1172
+ || !isConstructorModern(function () { called = true; })
1173
+ || called;
1174
+ }) ? isConstructorLegacy : isConstructorModern;
1175
+
1176
+ var DESCRIPTORS$3 = descriptors;
1177
+ var definePropertyModule$1 = objectDefineProperty;
1178
+ var createPropertyDescriptor = createPropertyDescriptor$3;
1179
+
1180
+ var createProperty$1 = function (object, key, value) {
1181
+ if (DESCRIPTORS$3) definePropertyModule$1.f(object, key, createPropertyDescriptor(0, value));
1182
+ else object[key] = value;
1183
+ };
1184
+
1185
+ var classof$1 = classof$3;
1186
+ var getMethod = getMethod$3;
1187
+ var isNullOrUndefined$1 = isNullOrUndefined$4;
1188
+ var Iterators = iterators;
1189
+ var wellKnownSymbol$6 = wellKnownSymbol$b;
1190
+
1191
+ var ITERATOR$1 = wellKnownSymbol$6('iterator');
1192
+
1193
+ var getIteratorMethod$3 = function (it) {
1194
+ if (!isNullOrUndefined$1(it)) return getMethod(it, ITERATOR$1)
1195
+ || getMethod(it, '@@iterator')
1196
+ || Iterators[classof$1(it)];
1197
+ };
1198
+
1199
+ var call$6 = functionCall;
1200
+ var aCallable$5 = aCallable$8;
1201
+ var anObject$5 = anObject$a;
1202
+ var tryToString$2 = tryToString$4;
1203
+ var getIteratorMethod$2 = getIteratorMethod$3;
1204
+
1205
+ var $TypeError$6 = TypeError;
1206
+
1207
+ var getIterator$2 = function (argument, usingIterator) {
1208
+ var iteratorMethod = arguments.length < 2 ? getIteratorMethod$2(argument) : usingIterator;
1209
+ if (aCallable$5(iteratorMethod)) return anObject$5(call$6(iteratorMethod, argument));
1210
+ throw new $TypeError$6(tryToString$2(argument) + ' is not iterable');
1211
+ };
1212
+
1213
+ var bind$4 = functionBindContext;
1214
+ var call$5 = functionCall;
1215
+ var toObject$1 = toObject$3;
1216
+ var callWithSafeIterationClosing = callWithSafeIterationClosing$1;
1217
+ var isArrayIteratorMethod$1 = isArrayIteratorMethod$2;
1218
+ var isConstructor$1 = isConstructor$2;
1219
+ var lengthOfArrayLike$2 = lengthOfArrayLike$4;
1220
+ var createProperty = createProperty$1;
1221
+ var getIterator$1 = getIterator$2;
1222
+ var getIteratorMethod$1 = getIteratorMethod$3;
1223
+
1224
+ var $Array = Array;
1225
+
1226
+ // `Array.from` method implementation
1227
+ // https://tc39.es/ecma262/#sec-array.from
1228
+ var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
1229
+ var O = toObject$1(arrayLike);
1230
+ var IS_CONSTRUCTOR = isConstructor$1(this);
1231
+ var argumentsLength = arguments.length;
1232
+ var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
1233
+ var mapping = mapfn !== undefined;
1234
+ if (mapping) mapfn = bind$4(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
1235
+ var iteratorMethod = getIteratorMethod$1(O);
1236
+ var index = 0;
1237
+ var length, result, step, iterator, next, value;
1238
+ // if the target is not iterable or it's an array with the default iterator - use a simple case
1239
+ if (iteratorMethod && !(this === $Array && isArrayIteratorMethod$1(iteratorMethod))) {
1240
+ result = IS_CONSTRUCTOR ? new this() : [];
1241
+ iterator = getIterator$1(O, iteratorMethod);
1242
+ next = iterator.next;
1243
+ for (;!(step = call$5(next, iterator)).done; index++) {
1244
+ value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
1245
+ createProperty(result, index, value);
1246
+ }
1247
+ } else {
1248
+ length = lengthOfArrayLike$2(O);
1249
+ result = IS_CONSTRUCTOR ? new this(length) : $Array(length);
1250
+ for (;length > index; index++) {
1251
+ value = mapping ? mapfn(O[index], index) : O[index];
1252
+ createProperty(result, index, value);
1253
+ }
1254
+ }
1255
+ result.length = index;
1256
+ return result;
1257
+ };
1258
+
1259
+ var wellKnownSymbol$5 = wellKnownSymbol$b;
1260
+
1261
+ var ITERATOR = wellKnownSymbol$5('iterator');
1262
+ var SAFE_CLOSING = false;
1263
+
1264
+ try {
1265
+ var called = 0;
1266
+ var iteratorWithReturn = {
1267
+ next: function () {
1268
+ return { done: !!called++ };
1269
+ },
1270
+ 'return': function () {
1271
+ SAFE_CLOSING = true;
1272
+ }
1273
+ };
1274
+ iteratorWithReturn[ITERATOR] = function () {
1275
+ return this;
1276
+ };
1277
+ // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
1278
+ Array.from(iteratorWithReturn, function () { throw 2; });
1279
+ } catch (error) { /* empty */ }
1280
+
1281
+ var checkCorrectnessOfIteration$2 = function (exec, SKIP_CLOSING) {
1282
+ try {
1283
+ if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
1284
+ } catch (error) { return false; } // workaround of old WebKit + `eval` bug
1285
+ var ITERATION_SUPPORT = false;
1286
+ try {
1287
+ var object = {};
1288
+ object[ITERATOR] = function () {
1289
+ return {
1290
+ next: function () {
1291
+ return { done: ITERATION_SUPPORT = true };
1292
+ }
1293
+ };
1294
+ };
1295
+ exec(object);
1296
+ } catch (error) { /* empty */ }
1297
+ return ITERATION_SUPPORT;
1298
+ };
1299
+
1300
+ var $$8 = _export;
1301
+ var from = arrayFrom;
1302
+ var checkCorrectnessOfIteration$1 = checkCorrectnessOfIteration$2;
1303
+
1304
+ var INCORRECT_ITERATION = !checkCorrectnessOfIteration$1(function (iterable) {
1305
+ // eslint-disable-next-line es/no-array-from -- required for testing
1306
+ Array.from(iterable);
1307
+ });
1308
+
1309
+ // `Array.from` method
1310
+ // https://tc39.es/ecma262/#sec-array.from
1311
+ $$8({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
1312
+ from: from
1313
+ });
1314
+
1315
+ /* global Bun, Deno -- detection */
1316
+ var globalThis$7 = globalThis_1;
1317
+ var userAgent$3 = environmentUserAgent;
1318
+ var classof = classofRaw$2;
1319
+
1320
+ var userAgentStartsWith = function (string) {
1321
+ return userAgent$3.slice(0, string.length) === string;
1322
+ };
1323
+
1324
+ var environment = (function () {
1325
+ if (userAgentStartsWith('Bun/')) return 'BUN';
1326
+ if (userAgentStartsWith('Cloudflare-Workers')) return 'CLOUDFLARE';
1327
+ if (userAgentStartsWith('Deno/')) return 'DENO';
1328
+ if (userAgentStartsWith('Node.js/')) return 'NODE';
1329
+ if (globalThis$7.Bun && typeof Bun.version == 'string') return 'BUN';
1330
+ if (globalThis$7.Deno && typeof Deno.version == 'object') return 'DENO';
1331
+ if (classof(globalThis$7.process) === 'process') return 'NODE';
1332
+ if (globalThis$7.window && globalThis$7.document) return 'BROWSER';
1333
+ return 'REST';
1334
+ })();
1335
+
1336
+ var ENVIRONMENT$1 = environment;
1337
+
1338
+ var environmentIsNode = ENVIRONMENT$1 === 'NODE';
1339
+
1340
+ var uncurryThis$1 = functionUncurryThis;
1341
+ var aCallable$4 = aCallable$8;
1342
+
1343
+ var functionUncurryThisAccessor = function (object, key, method) {
1344
+ try {
1345
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1346
+ return uncurryThis$1(aCallable$4(Object.getOwnPropertyDescriptor(object, key)[method]));
1347
+ } catch (error) { /* empty */ }
1348
+ };
1349
+
1350
+ var isObject$3 = isObject$9;
1351
+
1352
+ var isPossiblePrototype$1 = function (argument) {
1353
+ return isObject$3(argument) || argument === null;
1354
+ };
1355
+
1356
+ var isPossiblePrototype = isPossiblePrototype$1;
1357
+
1358
+ var $String = String;
1359
+ var $TypeError$5 = TypeError;
1360
+
1361
+ var aPossiblePrototype$1 = function (argument) {
1362
+ if (isPossiblePrototype(argument)) return argument;
1363
+ throw new $TypeError$5("Can't set " + $String(argument) + ' as a prototype');
1364
+ };
1365
+
1366
+ /* eslint-disable no-proto -- safe */
1367
+ var uncurryThisAccessor = functionUncurryThisAccessor;
1368
+ var isObject$2 = isObject$9;
1369
+ var requireObjectCoercible = requireObjectCoercible$3;
1370
+ var aPossiblePrototype = aPossiblePrototype$1;
1371
+
1372
+ // `Object.setPrototypeOf` method
1373
+ // https://tc39.es/ecma262/#sec-object.setprototypeof
1374
+ // Works with __proto__ only. Old v8 can't work with null proto objects.
1375
+ // eslint-disable-next-line es/no-object-setprototypeof -- safe
1376
+ var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () {
1377
+ var CORRECT_SETTER = false;
1378
+ var test = {};
1379
+ var setter;
1380
+ try {
1381
+ setter = uncurryThisAccessor(Object.prototype, '__proto__', 'set');
1382
+ setter(test, []);
1383
+ CORRECT_SETTER = test instanceof Array;
1384
+ } catch (error) { /* empty */ }
1385
+ return function setPrototypeOf(O, proto) {
1386
+ requireObjectCoercible(O);
1387
+ aPossiblePrototype(proto);
1388
+ if (!isObject$2(O)) return O;
1389
+ if (CORRECT_SETTER) setter(O, proto);
1390
+ else O.__proto__ = proto;
1391
+ return O;
1392
+ };
1393
+ }() : undefined);
1394
+
1395
+ var defineProperty$2 = objectDefineProperty.f;
1396
+ var hasOwn$1 = hasOwnProperty_1;
1397
+ var wellKnownSymbol$4 = wellKnownSymbol$b;
1398
+
1399
+ var TO_STRING_TAG = wellKnownSymbol$4('toStringTag');
1400
+
1401
+ var setToStringTag$1 = function (target, TAG, STATIC) {
1402
+ if (target && !STATIC) target = target.prototype;
1403
+ if (target && !hasOwn$1(target, TO_STRING_TAG)) {
1404
+ defineProperty$2(target, TO_STRING_TAG, { configurable: true, value: TAG });
1405
+ }
1406
+ };
1407
+
1408
+ var makeBuiltIn = makeBuiltInExports;
1409
+ var defineProperty$1 = objectDefineProperty;
1410
+
1411
+ var defineBuiltInAccessor$1 = function (target, name, descriptor) {
1412
+ if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
1413
+ if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
1414
+ return defineProperty$1.f(target, name, descriptor);
1415
+ };
1416
+
1417
+ var getBuiltIn$3 = getBuiltIn$7;
1418
+ var defineBuiltInAccessor = defineBuiltInAccessor$1;
1419
+ var wellKnownSymbol$3 = wellKnownSymbol$b;
1420
+ var DESCRIPTORS$2 = descriptors;
1421
+
1422
+ var SPECIES$2 = wellKnownSymbol$3('species');
1423
+
1424
+ var setSpecies$1 = function (CONSTRUCTOR_NAME) {
1425
+ var Constructor = getBuiltIn$3(CONSTRUCTOR_NAME);
1426
+
1427
+ if (DESCRIPTORS$2 && Constructor && !Constructor[SPECIES$2]) {
1428
+ defineBuiltInAccessor(Constructor, SPECIES$2, {
1429
+ configurable: true,
1430
+ get: function () { return this; }
1431
+ });
1432
+ }
1433
+ };
1434
+
1435
+ var isPrototypeOf$1 = objectIsPrototypeOf;
1436
+
1437
+ var $TypeError$4 = TypeError;
1438
+
1439
+ var anInstance$1 = function (it, Prototype) {
1440
+ if (isPrototypeOf$1(Prototype, it)) return it;
1441
+ throw new $TypeError$4('Incorrect invocation');
1442
+ };
1443
+
1444
+ var isConstructor = isConstructor$2;
1445
+ var tryToString$1 = tryToString$4;
1446
+
1447
+ var $TypeError$3 = TypeError;
1448
+
1449
+ // `Assert: IsConstructor(argument) is true`
1450
+ var aConstructor$1 = function (argument) {
1451
+ if (isConstructor(argument)) return argument;
1452
+ throw new $TypeError$3(tryToString$1(argument) + ' is not a constructor');
1453
+ };
1454
+
1455
+ var anObject$4 = anObject$a;
1456
+ var aConstructor = aConstructor$1;
1457
+ var isNullOrUndefined = isNullOrUndefined$4;
1458
+ var wellKnownSymbol$2 = wellKnownSymbol$b;
1459
+
1460
+ var SPECIES$1 = wellKnownSymbol$2('species');
1461
+
1462
+ // `SpeciesConstructor` abstract operation
1463
+ // https://tc39.es/ecma262/#sec-speciesconstructor
1464
+ var speciesConstructor$1 = function (O, defaultConstructor) {
1465
+ var C = anObject$4(O).constructor;
1466
+ var S;
1467
+ return C === undefined || isNullOrUndefined(S = anObject$4(C)[SPECIES$1]) ? defaultConstructor : aConstructor(S);
1468
+ };
1469
+
1470
+ var NATIVE_BIND = functionBindNative;
1471
+
1472
+ var FunctionPrototype = Function.prototype;
1473
+ var apply$1 = FunctionPrototype.apply;
1474
+ var call$4 = FunctionPrototype.call;
1475
+
1476
+ // eslint-disable-next-line es/no-reflect -- safe
1477
+ var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call$4.bind(apply$1) : function () {
1478
+ return call$4.apply(apply$1, arguments);
1479
+ });
1480
+
1481
+ var getBuiltIn$2 = getBuiltIn$7;
1482
+
1483
+ var html$2 = getBuiltIn$2('document', 'documentElement');
1484
+
1485
+ var uncurryThis = functionUncurryThis;
1486
+
1487
+ var arraySlice$1 = uncurryThis([].slice);
1488
+
1489
+ var $TypeError$2 = TypeError;
1490
+
1491
+ var validateArgumentsLength$1 = function (passed, required) {
1492
+ if (passed < required) throw new $TypeError$2('Not enough arguments');
1493
+ return passed;
1494
+ };
1495
+
1496
+ var userAgent$2 = environmentUserAgent;
1497
+
1498
+ // eslint-disable-next-line redos/no-vulnerable -- safe
1499
+ var environmentIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent$2);
1500
+
1501
+ var globalThis$6 = globalThis_1;
1502
+ var apply = functionApply;
1503
+ var bind$3 = functionBindContext;
1504
+ var isCallable$3 = isCallable$g;
1505
+ var hasOwn = hasOwnProperty_1;
1506
+ var fails$1 = fails$b;
1507
+ var html$1 = html$2;
1508
+ var arraySlice = arraySlice$1;
1509
+ var createElement = documentCreateElement$1;
1510
+ var validateArgumentsLength = validateArgumentsLength$1;
1511
+ var IS_IOS$1 = environmentIsIos;
1512
+ var IS_NODE$2 = environmentIsNode;
1513
+
1514
+ var set = globalThis$6.setImmediate;
1515
+ var clear = globalThis$6.clearImmediate;
1516
+ var process$2 = globalThis$6.process;
1517
+ var Dispatch = globalThis$6.Dispatch;
1518
+ var Function$1 = globalThis$6.Function;
1519
+ var MessageChannel = globalThis$6.MessageChannel;
1520
+ var String$1 = globalThis$6.String;
1521
+ var counter = 0;
1522
+ var queue$2 = {};
1523
+ var ONREADYSTATECHANGE = 'onreadystatechange';
1524
+ var $location, defer, channel, port;
1525
+
1526
+ fails$1(function () {
1527
+ // Deno throws a ReferenceError on `location` access without `--location` flag
1528
+ $location = globalThis$6.location;
1529
+ });
1530
+
1531
+ var run = function (id) {
1532
+ if (hasOwn(queue$2, id)) {
1533
+ var fn = queue$2[id];
1534
+ delete queue$2[id];
1535
+ fn();
1536
+ }
1537
+ };
1538
+
1539
+ var runner = function (id) {
1540
+ return function () {
1541
+ run(id);
1542
+ };
1543
+ };
1544
+
1545
+ var eventListener = function (event) {
1546
+ run(event.data);
1547
+ };
1548
+
1549
+ var globalPostMessageDefer = function (id) {
1550
+ // old engines have not location.origin
1551
+ globalThis$6.postMessage(String$1(id), $location.protocol + '//' + $location.host);
1552
+ };
1553
+
1554
+ // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
1555
+ if (!set || !clear) {
1556
+ set = function setImmediate(handler) {
1557
+ validateArgumentsLength(arguments.length, 1);
1558
+ var fn = isCallable$3(handler) ? handler : Function$1(handler);
1559
+ var args = arraySlice(arguments, 1);
1560
+ queue$2[++counter] = function () {
1561
+ apply(fn, undefined, args);
1562
+ };
1563
+ defer(counter);
1564
+ return counter;
1565
+ };
1566
+ clear = function clearImmediate(id) {
1567
+ delete queue$2[id];
1568
+ };
1569
+ // Node.js 0.8-
1570
+ if (IS_NODE$2) {
1571
+ defer = function (id) {
1572
+ process$2.nextTick(runner(id));
1573
+ };
1574
+ // Sphere (JS game engine) Dispatch API
1575
+ } else if (Dispatch && Dispatch.now) {
1576
+ defer = function (id) {
1577
+ Dispatch.now(runner(id));
1578
+ };
1579
+ // Browsers with MessageChannel, includes WebWorkers
1580
+ // except iOS - https://github.com/zloirock/core-js/issues/624
1581
+ } else if (MessageChannel && !IS_IOS$1) {
1582
+ channel = new MessageChannel();
1583
+ port = channel.port2;
1584
+ channel.port1.onmessage = eventListener;
1585
+ defer = bind$3(port.postMessage, port);
1586
+ // Browsers with postMessage, skip WebWorkers
1587
+ // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
1588
+ } else if (
1589
+ globalThis$6.addEventListener &&
1590
+ isCallable$3(globalThis$6.postMessage) &&
1591
+ !globalThis$6.importScripts &&
1592
+ $location && $location.protocol !== 'file:' &&
1593
+ !fails$1(globalPostMessageDefer)
1594
+ ) {
1595
+ defer = globalPostMessageDefer;
1596
+ globalThis$6.addEventListener('message', eventListener, false);
1597
+ // IE8-
1598
+ } else if (ONREADYSTATECHANGE in createElement('script')) {
1599
+ defer = function (id) {
1600
+ html$1.appendChild(createElement('script'))[ONREADYSTATECHANGE] = function () {
1601
+ html$1.removeChild(this);
1602
+ run(id);
1603
+ };
1604
+ };
1605
+ // Rest old browsers
1606
+ } else {
1607
+ defer = function (id) {
1608
+ setTimeout(runner(id), 0);
1609
+ };
1610
+ }
1611
+ }
1612
+
1613
+ var task$1 = {
1614
+ set: set,
1615
+ clear: clear
1616
+ };
1617
+
1618
+ var globalThis$5 = globalThis_1;
1619
+ var DESCRIPTORS$1 = descriptors;
1620
+
1621
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
1622
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1623
+
1624
+ // Avoid NodeJS experimental warning
1625
+ var safeGetBuiltIn$1 = function (name) {
1626
+ if (!DESCRIPTORS$1) return globalThis$5[name];
1627
+ var descriptor = getOwnPropertyDescriptor(globalThis$5, name);
1628
+ return descriptor && descriptor.value;
1629
+ };
1630
+
1631
+ var Queue$2 = function () {
1632
+ this.head = null;
1633
+ this.tail = null;
1634
+ };
1635
+
1636
+ Queue$2.prototype = {
1637
+ add: function (item) {
1638
+ var entry = { item: item, next: null };
1639
+ var tail = this.tail;
1640
+ if (tail) tail.next = entry;
1641
+ else this.head = entry;
1642
+ this.tail = entry;
1643
+ },
1644
+ get: function () {
1645
+ var entry = this.head;
1646
+ if (entry) {
1647
+ var next = this.head = entry.next;
1648
+ if (next === null) this.tail = null;
1649
+ return entry.item;
1650
+ }
1651
+ }
1652
+ };
1653
+
1654
+ var queue$1 = Queue$2;
1655
+
1656
+ var userAgent$1 = environmentUserAgent;
1657
+
1658
+ var environmentIsIosPebble = /ipad|iphone|ipod/i.test(userAgent$1) && typeof Pebble != 'undefined';
1659
+
1660
+ var userAgent = environmentUserAgent;
1661
+
1662
+ var environmentIsWebosWebkit = /web0s(?!.*chrome)/i.test(userAgent);
1663
+
1664
+ var globalThis$4 = globalThis_1;
1665
+ var safeGetBuiltIn = safeGetBuiltIn$1;
1666
+ var bind$2 = functionBindContext;
1667
+ var macrotask = task$1.set;
1668
+ var Queue$1 = queue$1;
1669
+ var IS_IOS = environmentIsIos;
1670
+ var IS_IOS_PEBBLE = environmentIsIosPebble;
1671
+ var IS_WEBOS_WEBKIT = environmentIsWebosWebkit;
1672
+ var IS_NODE$1 = environmentIsNode;
1673
+
1674
+ var MutationObserver$1 = globalThis$4.MutationObserver || globalThis$4.WebKitMutationObserver;
1675
+ var document$2 = globalThis$4.document;
1676
+ var process$1 = globalThis$4.process;
1677
+ var Promise$1 = globalThis$4.Promise;
1678
+ var microtask$1 = safeGetBuiltIn('queueMicrotask');
1679
+ var notify$1, toggle, node, promise, then;
1680
+
1681
+ // modern engines have queueMicrotask method
1682
+ if (!microtask$1) {
1683
+ var queue = new Queue$1();
1684
+
1685
+ var flush = function () {
1686
+ var parent, fn;
1687
+ if (IS_NODE$1 && (parent = process$1.domain)) parent.exit();
1688
+ while (fn = queue.get()) try {
1689
+ fn();
1690
+ } catch (error) {
1691
+ if (queue.head) notify$1();
1692
+ throw error;
1693
+ }
1694
+ if (parent) parent.enter();
1695
+ };
1696
+
1697
+ // browsers with MutationObserver, except iOS - https://github.com/zloirock/core-js/issues/339
1698
+ // also except WebOS Webkit https://github.com/zloirock/core-js/issues/898
1699
+ if (!IS_IOS && !IS_NODE$1 && !IS_WEBOS_WEBKIT && MutationObserver$1 && document$2) {
1700
+ toggle = true;
1701
+ node = document$2.createTextNode('');
1702
+ new MutationObserver$1(flush).observe(node, { characterData: true });
1703
+ notify$1 = function () {
1704
+ node.data = toggle = !toggle;
1705
+ };
1706
+ // environments with maybe non-completely correct, but existent Promise
1707
+ } else if (!IS_IOS_PEBBLE && Promise$1 && Promise$1.resolve) {
1708
+ // Promise.resolve without an argument throws an error in LG WebOS 2
1709
+ promise = Promise$1.resolve(undefined);
1710
+ // workaround of WebKit ~ iOS Safari 10.1 bug
1711
+ promise.constructor = Promise$1;
1712
+ then = bind$2(promise.then, promise);
1713
+ notify$1 = function () {
1714
+ then(flush);
1715
+ };
1716
+ // Node.js without promises
1717
+ } else if (IS_NODE$1) {
1718
+ notify$1 = function () {
1719
+ process$1.nextTick(flush);
1720
+ };
1721
+ // for other environments - macrotask based on:
1722
+ // - setImmediate
1723
+ // - MessageChannel
1724
+ // - window.postMessage
1725
+ // - onreadystatechange
1726
+ // - setTimeout
1727
+ } else {
1728
+ // `webpack` dev server bug on IE global methods - use bind(fn, global)
1729
+ macrotask = bind$2(macrotask, globalThis$4);
1730
+ notify$1 = function () {
1731
+ macrotask(flush);
1732
+ };
1733
+ }
1734
+
1735
+ microtask$1 = function (fn) {
1736
+ if (!queue.head) notify$1();
1737
+ queue.add(fn);
1738
+ };
1739
+ }
1740
+
1741
+ var microtask_1 = microtask$1;
1742
+
1743
+ var hostReportErrors$1 = function (a, b) {
1744
+ try {
1745
+ // eslint-disable-next-line no-console -- safe
1746
+ arguments.length === 1 ? (void 0) : (void 0);
1747
+ } catch (error) { /* empty */ }
1748
+ };
1749
+
1750
+ var perform$3 = function (exec) {
1751
+ try {
1752
+ return { error: false, value: exec() };
1753
+ } catch (error) {
1754
+ return { error: true, value: error };
1755
+ }
1756
+ };
1757
+
1758
+ var globalThis$3 = globalThis_1;
1759
+
1760
+ var promiseNativeConstructor = globalThis$3.Promise;
1761
+
1762
+ var globalThis$2 = globalThis_1;
1763
+ var NativePromiseConstructor$3 = promiseNativeConstructor;
1764
+ var isCallable$2 = isCallable$g;
1765
+ var isForced = isForced_1;
1766
+ var inspectSource = inspectSource$3;
1767
+ var wellKnownSymbol$1 = wellKnownSymbol$b;
1768
+ var ENVIRONMENT = environment;
1769
+ var V8_VERSION = environmentV8Version;
1770
+
1771
+ NativePromiseConstructor$3 && NativePromiseConstructor$3.prototype;
1772
+ var SPECIES = wellKnownSymbol$1('species');
1773
+ var SUBCLASSING = false;
1774
+ var NATIVE_PROMISE_REJECTION_EVENT$1 = isCallable$2(globalThis$2.PromiseRejectionEvent);
1775
+
1776
+ var FORCED_PROMISE_CONSTRUCTOR$5 = isForced('Promise', function () {
1777
+ var PROMISE_CONSTRUCTOR_SOURCE = inspectSource(NativePromiseConstructor$3);
1778
+ var GLOBAL_CORE_JS_PROMISE = PROMISE_CONSTRUCTOR_SOURCE !== String(NativePromiseConstructor$3);
1779
+ // V8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
1780
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
1781
+ // We can't detect it synchronously, so just check versions
1782
+ if (!GLOBAL_CORE_JS_PROMISE && V8_VERSION === 66) return true;
1783
+ // We can't use @@species feature detection in V8 since it causes
1784
+ // deoptimization and performance degradation
1785
+ // https://github.com/zloirock/core-js/issues/679
1786
+ if (!V8_VERSION || V8_VERSION < 51 || !/native code/.test(PROMISE_CONSTRUCTOR_SOURCE)) {
1787
+ // Detect correctness of subclassing with @@species support
1788
+ var promise = new NativePromiseConstructor$3(function (resolve) { resolve(1); });
1789
+ var FakePromise = function (exec) {
1790
+ exec(function () { /* empty */ }, function () { /* empty */ });
1791
+ };
1792
+ var constructor = promise.constructor = {};
1793
+ constructor[SPECIES] = FakePromise;
1794
+ SUBCLASSING = promise.then(function () { /* empty */ }) instanceof FakePromise;
1795
+ if (!SUBCLASSING) return true;
1796
+ // Unhandled rejections tracking support, NodeJS Promise without it fails @@species test
1797
+ } return !GLOBAL_CORE_JS_PROMISE && (ENVIRONMENT === 'BROWSER' || ENVIRONMENT === 'DENO') && !NATIVE_PROMISE_REJECTION_EVENT$1;
1798
+ });
1799
+
1800
+ var promiseConstructorDetection = {
1801
+ CONSTRUCTOR: FORCED_PROMISE_CONSTRUCTOR$5,
1802
+ REJECTION_EVENT: NATIVE_PROMISE_REJECTION_EVENT$1,
1803
+ SUBCLASSING: SUBCLASSING
1804
+ };
1805
+
1806
+ var newPromiseCapability$2 = {};
1807
+
1808
+ var aCallable$3 = aCallable$8;
1809
+
1810
+ var $TypeError$1 = TypeError;
1811
+
1812
+ var PromiseCapability = function (C) {
1813
+ var resolve, reject;
1814
+ this.promise = new C(function ($$resolve, $$reject) {
1815
+ if (resolve !== undefined || reject !== undefined) throw new $TypeError$1('Bad Promise constructor');
1816
+ resolve = $$resolve;
1817
+ reject = $$reject;
1818
+ });
1819
+ this.resolve = aCallable$3(resolve);
1820
+ this.reject = aCallable$3(reject);
1821
+ };
1822
+
1823
+ // `NewPromiseCapability` abstract operation
1824
+ // https://tc39.es/ecma262/#sec-newpromisecapability
1825
+ newPromiseCapability$2.f = function (C) {
1826
+ return new PromiseCapability(C);
1827
+ };
1828
+
1829
+ var $$7 = _export;
1830
+ var IS_NODE = environmentIsNode;
1831
+ var globalThis$1 = globalThis_1;
1832
+ var call$3 = functionCall;
1833
+ var defineBuiltIn$1 = defineBuiltIn$3;
1834
+ var setPrototypeOf = objectSetPrototypeOf;
1835
+ var setToStringTag = setToStringTag$1;
1836
+ var setSpecies = setSpecies$1;
1837
+ var aCallable$2 = aCallable$8;
1838
+ var isCallable$1 = isCallable$g;
1839
+ var isObject$1 = isObject$9;
1840
+ var anInstance = anInstance$1;
1841
+ var speciesConstructor = speciesConstructor$1;
1842
+ var task = task$1.set;
1843
+ var microtask = microtask_1;
1844
+ var hostReportErrors = hostReportErrors$1;
1845
+ var perform$2 = perform$3;
1846
+ var Queue = queue$1;
1847
+ var InternalStateModule = internalState;
1848
+ var NativePromiseConstructor$2 = promiseNativeConstructor;
1849
+ var PromiseConstructorDetection = promiseConstructorDetection;
1850
+ var newPromiseCapabilityModule$3 = newPromiseCapability$2;
1851
+
1852
+ var PROMISE = 'Promise';
1853
+ var FORCED_PROMISE_CONSTRUCTOR$4 = PromiseConstructorDetection.CONSTRUCTOR;
1854
+ var NATIVE_PROMISE_REJECTION_EVENT = PromiseConstructorDetection.REJECTION_EVENT;
1855
+ var NATIVE_PROMISE_SUBCLASSING = PromiseConstructorDetection.SUBCLASSING;
1856
+ var getInternalPromiseState = InternalStateModule.getterFor(PROMISE);
1857
+ var setInternalState = InternalStateModule.set;
1858
+ var NativePromisePrototype$1 = NativePromiseConstructor$2 && NativePromiseConstructor$2.prototype;
1859
+ var PromiseConstructor = NativePromiseConstructor$2;
1860
+ var PromisePrototype = NativePromisePrototype$1;
1861
+ var TypeError$1 = globalThis$1.TypeError;
1862
+ var document$1 = globalThis$1.document;
1863
+ var process = globalThis$1.process;
1864
+ var newPromiseCapability$1 = newPromiseCapabilityModule$3.f;
1865
+ var newGenericPromiseCapability = newPromiseCapability$1;
1866
+
1867
+ var DISPATCH_EVENT = !!(document$1 && document$1.createEvent && globalThis$1.dispatchEvent);
1868
+ var UNHANDLED_REJECTION = 'unhandledrejection';
1869
+ var REJECTION_HANDLED = 'rejectionhandled';
1870
+ var PENDING = 0;
1871
+ var FULFILLED = 1;
1872
+ var REJECTED = 2;
1873
+ var HANDLED = 1;
1874
+ var UNHANDLED = 2;
1875
+
1876
+ var Internal, OwnPromiseCapability, PromiseWrapper, nativeThen;
1877
+
1878
+ // helpers
1879
+ var isThenable = function (it) {
1880
+ var then;
1881
+ return isObject$1(it) && isCallable$1(then = it.then) ? then : false;
1882
+ };
1883
+
1884
+ var callReaction = function (reaction, state) {
1885
+ var value = state.value;
1886
+ var ok = state.state === FULFILLED;
1887
+ var handler = ok ? reaction.ok : reaction.fail;
1888
+ var resolve = reaction.resolve;
1889
+ var reject = reaction.reject;
1890
+ var domain = reaction.domain;
1891
+ var result, then, exited;
1892
+ try {
1893
+ if (handler) {
1894
+ if (!ok) {
1895
+ if (state.rejection === UNHANDLED) onHandleUnhandled(state);
1896
+ state.rejection = HANDLED;
1897
+ }
1898
+ if (handler === true) result = value;
1899
+ else {
1900
+ if (domain) domain.enter();
1901
+ result = handler(value); // can throw
1902
+ if (domain) {
1903
+ domain.exit();
1904
+ exited = true;
1905
+ }
1906
+ }
1907
+ if (result === reaction.promise) {
1908
+ reject(new TypeError$1('Promise-chain cycle'));
1909
+ } else if (then = isThenable(result)) {
1910
+ call$3(then, result, resolve, reject);
1911
+ } else resolve(result);
1912
+ } else reject(value);
1913
+ } catch (error) {
1914
+ if (domain && !exited) domain.exit();
1915
+ reject(error);
1916
+ }
1917
+ };
1918
+
1919
+ var notify = function (state, isReject) {
1920
+ if (state.notified) return;
1921
+ state.notified = true;
1922
+ microtask(function () {
1923
+ var reactions = state.reactions;
1924
+ var reaction;
1925
+ while (reaction = reactions.get()) {
1926
+ callReaction(reaction, state);
1927
+ }
1928
+ state.notified = false;
1929
+ if (isReject && !state.rejection) onUnhandled(state);
1930
+ });
1931
+ };
1932
+
1933
+ var dispatchEvent = function (name, promise, reason) {
1934
+ var event, handler;
1935
+ if (DISPATCH_EVENT) {
1936
+ event = document$1.createEvent('Event');
1937
+ event.promise = promise;
1938
+ event.reason = reason;
1939
+ event.initEvent(name, false, true);
1940
+ globalThis$1.dispatchEvent(event);
1941
+ } else event = { promise: promise, reason: reason };
1942
+ if (!NATIVE_PROMISE_REJECTION_EVENT && (handler = globalThis$1['on' + name])) handler(event);
1943
+ else if (name === UNHANDLED_REJECTION) hostReportErrors('Unhandled promise rejection', reason);
1944
+ };
1945
+
1946
+ var onUnhandled = function (state) {
1947
+ call$3(task, globalThis$1, function () {
1948
+ var promise = state.facade;
1949
+ var value = state.value;
1950
+ var IS_UNHANDLED = isUnhandled(state);
1951
+ var result;
1952
+ if (IS_UNHANDLED) {
1953
+ result = perform$2(function () {
1954
+ if (IS_NODE) {
1955
+ process.emit('unhandledRejection', value, promise);
1956
+ } else dispatchEvent(UNHANDLED_REJECTION, promise, value);
1957
+ });
1958
+ // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
1959
+ state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
1960
+ if (result.error) throw result.value;
1961
+ }
1962
+ });
1963
+ };
1964
+
1965
+ var isUnhandled = function (state) {
1966
+ return state.rejection !== HANDLED && !state.parent;
1967
+ };
1968
+
1969
+ var onHandleUnhandled = function (state) {
1970
+ call$3(task, globalThis$1, function () {
1971
+ var promise = state.facade;
1972
+ if (IS_NODE) {
1973
+ process.emit('rejectionHandled', promise);
1974
+ } else dispatchEvent(REJECTION_HANDLED, promise, state.value);
1975
+ });
1976
+ };
1977
+
1978
+ var bind$1 = function (fn, state, unwrap) {
1979
+ return function (value) {
1980
+ fn(state, value, unwrap);
1981
+ };
1982
+ };
1983
+
1984
+ var internalReject = function (state, value, unwrap) {
1985
+ if (state.done) return;
1986
+ state.done = true;
1987
+ if (unwrap) state = unwrap;
1988
+ state.value = value;
1989
+ state.state = REJECTED;
1990
+ notify(state, true);
1991
+ };
1992
+
1993
+ var internalResolve = function (state, value, unwrap) {
1994
+ if (state.done) return;
1995
+ state.done = true;
1996
+ if (unwrap) state = unwrap;
1997
+ try {
1998
+ if (state.facade === value) throw new TypeError$1("Promise can't be resolved itself");
1999
+ var then = isThenable(value);
2000
+ if (then) {
2001
+ microtask(function () {
2002
+ var wrapper = { done: false };
2003
+ try {
2004
+ call$3(then, value,
2005
+ bind$1(internalResolve, wrapper, state),
2006
+ bind$1(internalReject, wrapper, state)
2007
+ );
2008
+ } catch (error) {
2009
+ internalReject(wrapper, error, state);
2010
+ }
2011
+ });
2012
+ } else {
2013
+ state.value = value;
2014
+ state.state = FULFILLED;
2015
+ notify(state, false);
2016
+ }
2017
+ } catch (error) {
2018
+ internalReject({ done: false }, error, state);
2019
+ }
2020
+ };
2021
+
2022
+ // constructor polyfill
2023
+ if (FORCED_PROMISE_CONSTRUCTOR$4) {
2024
+ // 25.4.3.1 Promise(executor)
2025
+ PromiseConstructor = function Promise(executor) {
2026
+ anInstance(this, PromisePrototype);
2027
+ aCallable$2(executor);
2028
+ call$3(Internal, this);
2029
+ var state = getInternalPromiseState(this);
2030
+ try {
2031
+ executor(bind$1(internalResolve, state), bind$1(internalReject, state));
2032
+ } catch (error) {
2033
+ internalReject(state, error);
2034
+ }
2035
+ };
2036
+
2037
+ PromisePrototype = PromiseConstructor.prototype;
2038
+
2039
+ // eslint-disable-next-line no-unused-vars -- required for `.length`
2040
+ Internal = function Promise(executor) {
2041
+ setInternalState(this, {
2042
+ type: PROMISE,
2043
+ done: false,
2044
+ notified: false,
2045
+ parent: false,
2046
+ reactions: new Queue(),
2047
+ rejection: false,
2048
+ state: PENDING,
2049
+ value: undefined
2050
+ });
2051
+ };
2052
+
2053
+ // `Promise.prototype.then` method
2054
+ // https://tc39.es/ecma262/#sec-promise.prototype.then
2055
+ Internal.prototype = defineBuiltIn$1(PromisePrototype, 'then', function then(onFulfilled, onRejected) {
2056
+ var state = getInternalPromiseState(this);
2057
+ var reaction = newPromiseCapability$1(speciesConstructor(this, PromiseConstructor));
2058
+ state.parent = true;
2059
+ reaction.ok = isCallable$1(onFulfilled) ? onFulfilled : true;
2060
+ reaction.fail = isCallable$1(onRejected) && onRejected;
2061
+ reaction.domain = IS_NODE ? process.domain : undefined;
2062
+ if (state.state === PENDING) state.reactions.add(reaction);
2063
+ else microtask(function () {
2064
+ callReaction(reaction, state);
2065
+ });
2066
+ return reaction.promise;
2067
+ });
2068
+
2069
+ OwnPromiseCapability = function () {
2070
+ var promise = new Internal();
2071
+ var state = getInternalPromiseState(promise);
2072
+ this.promise = promise;
2073
+ this.resolve = bind$1(internalResolve, state);
2074
+ this.reject = bind$1(internalReject, state);
2075
+ };
2076
+
2077
+ newPromiseCapabilityModule$3.f = newPromiseCapability$1 = function (C) {
2078
+ return C === PromiseConstructor || C === PromiseWrapper
2079
+ ? new OwnPromiseCapability(C)
2080
+ : newGenericPromiseCapability(C);
2081
+ };
2082
+
2083
+ if (isCallable$1(NativePromiseConstructor$2) && NativePromisePrototype$1 !== Object.prototype) {
2084
+ nativeThen = NativePromisePrototype$1.then;
2085
+
2086
+ if (!NATIVE_PROMISE_SUBCLASSING) {
2087
+ // make `Promise#then` return a polyfilled `Promise` for native promise-based APIs
2088
+ defineBuiltIn$1(NativePromisePrototype$1, 'then', function then(onFulfilled, onRejected) {
2089
+ var that = this;
2090
+ return new PromiseConstructor(function (resolve, reject) {
2091
+ call$3(nativeThen, that, resolve, reject);
2092
+ }).then(onFulfilled, onRejected);
2093
+ // https://github.com/zloirock/core-js/issues/640
2094
+ }, { unsafe: true });
2095
+ }
2096
+
2097
+ // make `.constructor === Promise` work for native promise-based APIs
2098
+ try {
2099
+ delete NativePromisePrototype$1.constructor;
2100
+ } catch (error) { /* empty */ }
2101
+
2102
+ // make `instanceof Promise` work for native promise-based APIs
2103
+ if (setPrototypeOf) {
2104
+ setPrototypeOf(NativePromisePrototype$1, PromisePrototype);
2105
+ }
2106
+ }
2107
+ }
2108
+
2109
+ $$7({ global: true, constructor: true, wrap: true, forced: FORCED_PROMISE_CONSTRUCTOR$4 }, {
2110
+ Promise: PromiseConstructor
2111
+ });
2112
+
2113
+ setToStringTag(PromiseConstructor, PROMISE, false);
2114
+ setSpecies(PROMISE);
2115
+
2116
+ var bind = functionBindContext;
2117
+ var call$2 = functionCall;
2118
+ var anObject$3 = anObject$a;
2119
+ var tryToString = tryToString$4;
2120
+ var isArrayIteratorMethod = isArrayIteratorMethod$2;
2121
+ var lengthOfArrayLike$1 = lengthOfArrayLike$4;
2122
+ var isPrototypeOf = objectIsPrototypeOf;
2123
+ var getIterator = getIterator$2;
2124
+ var getIteratorMethod = getIteratorMethod$3;
2125
+ var iteratorClose = iteratorClose$2;
2126
+
2127
+ var $TypeError = TypeError;
2128
+
2129
+ var Result = function (stopped, result) {
2130
+ this.stopped = stopped;
2131
+ this.result = result;
2132
+ };
2133
+
2134
+ var ResultPrototype = Result.prototype;
2135
+
2136
+ var iterate$2 = function (iterable, unboundFunction, options) {
2137
+ var that = options && options.that;
2138
+ var AS_ENTRIES = !!(options && options.AS_ENTRIES);
2139
+ var IS_RECORD = !!(options && options.IS_RECORD);
2140
+ var IS_ITERATOR = !!(options && options.IS_ITERATOR);
2141
+ var INTERRUPTED = !!(options && options.INTERRUPTED);
2142
+ var fn = bind(unboundFunction, that);
2143
+ var iterator, iterFn, index, length, result, next, step;
2144
+
2145
+ var stop = function (condition) {
2146
+ if (iterator) iteratorClose(iterator, 'normal', condition);
2147
+ return new Result(true, condition);
2148
+ };
2149
+
2150
+ var callFn = function (value) {
2151
+ if (AS_ENTRIES) {
2152
+ anObject$3(value);
2153
+ return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
2154
+ } return INTERRUPTED ? fn(value, stop) : fn(value);
2155
+ };
2156
+
2157
+ if (IS_RECORD) {
2158
+ iterator = iterable.iterator;
2159
+ } else if (IS_ITERATOR) {
2160
+ iterator = iterable;
2161
+ } else {
2162
+ iterFn = getIteratorMethod(iterable);
2163
+ if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable');
2164
+ // optimisation for array iterators
2165
+ if (isArrayIteratorMethod(iterFn)) {
2166
+ for (index = 0, length = lengthOfArrayLike$1(iterable); length > index; index++) {
2167
+ result = callFn(iterable[index]);
2168
+ if (result && isPrototypeOf(ResultPrototype, result)) return result;
2169
+ } return new Result(false);
2170
+ }
2171
+ iterator = getIterator(iterable, iterFn);
2172
+ }
2173
+
2174
+ next = IS_RECORD ? iterable.next : iterator.next;
2175
+ while (!(step = call$2(next, iterator)).done) {
2176
+ try {
2177
+ result = callFn(step.value);
2178
+ } catch (error) {
2179
+ iteratorClose(iterator, 'throw', error);
2180
+ }
2181
+ if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
2182
+ } return new Result(false);
2183
+ };
2184
+
2185
+ var NativePromiseConstructor$1 = promiseNativeConstructor;
2186
+ var checkCorrectnessOfIteration = checkCorrectnessOfIteration$2;
2187
+ var FORCED_PROMISE_CONSTRUCTOR$3 = promiseConstructorDetection.CONSTRUCTOR;
2188
+
2189
+ var promiseStaticsIncorrectIteration = FORCED_PROMISE_CONSTRUCTOR$3 || !checkCorrectnessOfIteration(function (iterable) {
2190
+ NativePromiseConstructor$1.all(iterable).then(undefined, function () { /* empty */ });
2191
+ });
2192
+
2193
+ var $$6 = _export;
2194
+ var call$1 = functionCall;
2195
+ var aCallable$1 = aCallable$8;
2196
+ var newPromiseCapabilityModule$2 = newPromiseCapability$2;
2197
+ var perform$1 = perform$3;
2198
+ var iterate$1 = iterate$2;
2199
+ var PROMISE_STATICS_INCORRECT_ITERATION$1 = promiseStaticsIncorrectIteration;
2200
+
2201
+ // `Promise.all` method
2202
+ // https://tc39.es/ecma262/#sec-promise.all
2203
+ $$6({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION$1 }, {
2204
+ all: function all(iterable) {
2205
+ var C = this;
2206
+ var capability = newPromiseCapabilityModule$2.f(C);
2207
+ var resolve = capability.resolve;
2208
+ var reject = capability.reject;
2209
+ var result = perform$1(function () {
2210
+ var $promiseResolve = aCallable$1(C.resolve);
2211
+ var values = [];
2212
+ var counter = 0;
2213
+ var remaining = 1;
2214
+ iterate$1(iterable, function (promise) {
2215
+ var index = counter++;
2216
+ var alreadyCalled = false;
2217
+ remaining++;
2218
+ call$1($promiseResolve, C, promise).then(function (value) {
2219
+ if (alreadyCalled) return;
2220
+ alreadyCalled = true;
2221
+ values[index] = value;
2222
+ --remaining || resolve(values);
2223
+ }, reject);
2224
+ });
2225
+ --remaining || resolve(values);
2226
+ });
2227
+ if (result.error) reject(result.value);
2228
+ return capability.promise;
2229
+ }
2230
+ });
2231
+
2232
+ var $$5 = _export;
2233
+ var FORCED_PROMISE_CONSTRUCTOR$2 = promiseConstructorDetection.CONSTRUCTOR;
2234
+ var NativePromiseConstructor = promiseNativeConstructor;
2235
+ var getBuiltIn$1 = getBuiltIn$7;
2236
+ var isCallable = isCallable$g;
2237
+ var defineBuiltIn = defineBuiltIn$3;
2238
+
2239
+ var NativePromisePrototype = NativePromiseConstructor && NativePromiseConstructor.prototype;
2240
+
2241
+ // `Promise.prototype.catch` method
2242
+ // https://tc39.es/ecma262/#sec-promise.prototype.catch
2243
+ $$5({ target: 'Promise', proto: true, forced: FORCED_PROMISE_CONSTRUCTOR$2, real: true }, {
2244
+ 'catch': function (onRejected) {
2245
+ return this.then(undefined, onRejected);
2246
+ }
2247
+ });
2248
+
2249
+ // makes sure that native promise-based APIs `Promise#catch` properly works with patched `Promise#then`
2250
+ if (isCallable(NativePromiseConstructor)) {
2251
+ var method = getBuiltIn$1('Promise').prototype['catch'];
2252
+ if (NativePromisePrototype['catch'] !== method) {
2253
+ defineBuiltIn(NativePromisePrototype, 'catch', method, { unsafe: true });
2254
+ }
2255
+ }
2256
+
2257
+ var $$4 = _export;
2258
+ var call = functionCall;
2259
+ var aCallable = aCallable$8;
2260
+ var newPromiseCapabilityModule$1 = newPromiseCapability$2;
2261
+ var perform = perform$3;
2262
+ var iterate = iterate$2;
2263
+ var PROMISE_STATICS_INCORRECT_ITERATION = promiseStaticsIncorrectIteration;
2264
+
2265
+ // `Promise.race` method
2266
+ // https://tc39.es/ecma262/#sec-promise.race
2267
+ $$4({ target: 'Promise', stat: true, forced: PROMISE_STATICS_INCORRECT_ITERATION }, {
2268
+ race: function race(iterable) {
2269
+ var C = this;
2270
+ var capability = newPromiseCapabilityModule$1.f(C);
2271
+ var reject = capability.reject;
2272
+ var result = perform(function () {
2273
+ var $promiseResolve = aCallable(C.resolve);
2274
+ iterate(iterable, function (promise) {
2275
+ call($promiseResolve, C, promise).then(capability.resolve, reject);
2276
+ });
2277
+ });
2278
+ if (result.error) reject(result.value);
2279
+ return capability.promise;
2280
+ }
2281
+ });
2282
+
2283
+ var $$3 = _export;
2284
+ var newPromiseCapabilityModule = newPromiseCapability$2;
2285
+ var FORCED_PROMISE_CONSTRUCTOR$1 = promiseConstructorDetection.CONSTRUCTOR;
2286
+
2287
+ // `Promise.reject` method
2288
+ // https://tc39.es/ecma262/#sec-promise.reject
2289
+ $$3({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR$1 }, {
2290
+ reject: function reject(r) {
2291
+ var capability = newPromiseCapabilityModule.f(this);
2292
+ var capabilityReject = capability.reject;
2293
+ capabilityReject(r);
2294
+ return capability.promise;
2295
+ }
2296
+ });
2297
+
2298
+ var anObject$2 = anObject$a;
2299
+ var isObject = isObject$9;
2300
+ var newPromiseCapability = newPromiseCapability$2;
2301
+
2302
+ var promiseResolve$1 = function (C, x) {
2303
+ anObject$2(C);
2304
+ if (isObject(x) && x.constructor === C) return x;
2305
+ var promiseCapability = newPromiseCapability.f(C);
2306
+ var resolve = promiseCapability.resolve;
2307
+ resolve(x);
2308
+ return promiseCapability.promise;
2309
+ };
2310
+
2311
+ var $$2 = _export;
2312
+ var getBuiltIn = getBuiltIn$7;
2313
+ var FORCED_PROMISE_CONSTRUCTOR = promiseConstructorDetection.CONSTRUCTOR;
2314
+ var promiseResolve = promiseResolve$1;
2315
+
2316
+ getBuiltIn('Promise');
2317
+
2318
+ // `Promise.resolve` method
2319
+ // https://tc39.es/ecma262/#sec-promise.resolve
2320
+ $$2({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
2321
+ resolve: function resolve(x) {
2322
+ return promiseResolve(this, x);
2323
+ }
2324
+ });
2325
+
2326
+ var objectDefineProperties = {};
2327
+
2328
+ var internalObjectKeys = objectKeysInternal;
2329
+ var enumBugKeys$1 = enumBugKeys$3;
2330
+
2331
+ // `Object.keys` method
2332
+ // https://tc39.es/ecma262/#sec-object.keys
2333
+ // eslint-disable-next-line es/no-object-keys -- safe
2334
+ var objectKeys$1 = Object.keys || function keys(O) {
2335
+ return internalObjectKeys(O, enumBugKeys$1);
2336
+ };
2337
+
2338
+ var DESCRIPTORS = descriptors;
2339
+ var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
2340
+ var definePropertyModule = objectDefineProperty;
2341
+ var anObject$1 = anObject$a;
2342
+ var toIndexedObject = toIndexedObject$4;
2343
+ var objectKeys = objectKeys$1;
2344
+
2345
+ // `Object.defineProperties` method
2346
+ // https://tc39.es/ecma262/#sec-object.defineproperties
2347
+ // eslint-disable-next-line es/no-object-defineproperties -- safe
2348
+ objectDefineProperties.f = DESCRIPTORS && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) {
2349
+ anObject$1(O);
2350
+ var props = toIndexedObject(Properties);
2351
+ var keys = objectKeys(Properties);
2352
+ var length = keys.length;
2353
+ var index = 0;
2354
+ var key;
2355
+ while (length > index) definePropertyModule.f(O, key = keys[index++], props[key]);
2356
+ return O;
2357
+ };
2358
+
2359
+ /* global ActiveXObject -- old IE, WSH */
2360
+ var anObject = anObject$a;
2361
+ var definePropertiesModule = objectDefineProperties;
2362
+ var enumBugKeys = enumBugKeys$3;
2363
+ var hiddenKeys = hiddenKeys$4;
2364
+ var html = html$2;
2365
+ var documentCreateElement = documentCreateElement$1;
2366
+ var sharedKey = sharedKey$2;
2367
+
2368
+ var GT = '>';
2369
+ var LT = '<';
2370
+ var PROTOTYPE = 'prototype';
2371
+ var SCRIPT = 'script';
2372
+ var IE_PROTO = sharedKey('IE_PROTO');
2373
+
2374
+ var EmptyConstructor = function () { /* empty */ };
2375
+
2376
+ var scriptTag = function (content) {
2377
+ return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT;
2378
+ };
2379
+
2380
+ // Create object with fake `null` prototype: use ActiveX Object with cleared prototype
2381
+ var NullProtoObjectViaActiveX = function (activeXDocument) {
2382
+ activeXDocument.write(scriptTag(''));
2383
+ activeXDocument.close();
2384
+ var temp = activeXDocument.parentWindow.Object;
2385
+ // eslint-disable-next-line no-useless-assignment -- avoid memory leak
2386
+ activeXDocument = null;
2387
+ return temp;
2388
+ };
2389
+
2390
+ // Create object with fake `null` prototype: use iframe Object with cleared prototype
2391
+ var NullProtoObjectViaIFrame = function () {
2392
+ // Thrash, waste and sodomy: IE GC bug
2393
+ var iframe = documentCreateElement('iframe');
2394
+ var JS = 'java' + SCRIPT + ':';
2395
+ var iframeDocument;
2396
+ iframe.style.display = 'none';
2397
+ html.appendChild(iframe);
2398
+ // https://github.com/zloirock/core-js/issues/475
2399
+ iframe.src = String(JS);
2400
+ iframeDocument = iframe.contentWindow.document;
2401
+ iframeDocument.open();
2402
+ iframeDocument.write(scriptTag('document.F=Object'));
2403
+ iframeDocument.close();
2404
+ return iframeDocument.F;
2405
+ };
2406
+
2407
+ // Check for document.domain and active x support
2408
+ // No need to use active x approach when document.domain is not set
2409
+ // see https://github.com/es-shims/es5-shim/issues/150
2410
+ // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
2411
+ // avoid IE GC bug
2412
+ var activeXDocument;
2413
+ var NullProtoObject = function () {
2414
+ try {
2415
+ activeXDocument = new ActiveXObject('htmlfile');
2416
+ } catch (error) { /* ignore */ }
2417
+ NullProtoObject = typeof document != 'undefined'
2418
+ ? document.domain && activeXDocument
2419
+ ? NullProtoObjectViaActiveX(activeXDocument) // old IE
2420
+ : NullProtoObjectViaIFrame()
2421
+ : NullProtoObjectViaActiveX(activeXDocument); // WSH
2422
+ var length = enumBugKeys.length;
2423
+ while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]];
2424
+ return NullProtoObject();
2425
+ };
2426
+
2427
+ hiddenKeys[IE_PROTO] = true;
2428
+
2429
+ // `Object.create` method
2430
+ // https://tc39.es/ecma262/#sec-object.create
2431
+ // eslint-disable-next-line es/no-object-create -- safe
2432
+ var objectCreate = Object.create || function create(O, Properties) {
2433
+ var result;
2434
+ if (O !== null) {
2435
+ EmptyConstructor[PROTOTYPE] = anObject(O);
2436
+ result = new EmptyConstructor();
2437
+ EmptyConstructor[PROTOTYPE] = null;
2438
+ // add "__proto__" for Object.getPrototypeOf polyfill
2439
+ result[IE_PROTO] = O;
2440
+ } else result = NullProtoObject();
2441
+ return Properties === undefined ? result : definePropertiesModule.f(result, Properties);
2442
+ };
2443
+
2444
+ var wellKnownSymbol = wellKnownSymbol$b;
2445
+ var create = objectCreate;
2446
+ var defineProperty = objectDefineProperty.f;
2447
+
2448
+ var UNSCOPABLES = wellKnownSymbol('unscopables');
2449
+ var ArrayPrototype = Array.prototype;
2450
+
2451
+ // Array.prototype[@@unscopables]
2452
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2453
+ if (ArrayPrototype[UNSCOPABLES] === undefined) {
2454
+ defineProperty(ArrayPrototype, UNSCOPABLES, {
2455
+ configurable: true,
2456
+ value: create(null)
2457
+ });
2458
+ }
2459
+
2460
+ // add a key to Array.prototype[@@unscopables]
2461
+ var addToUnscopables$2 = function (key) {
2462
+ ArrayPrototype[UNSCOPABLES][key] = true;
2463
+ };
2464
+
2465
+ var $$1 = _export;
2466
+ var $includes = arrayIncludes.includes;
2467
+ var fails = fails$b;
2468
+ var addToUnscopables$1 = addToUnscopables$2;
2469
+
2470
+ // FF99+ bug
2471
+ var BROKEN_ON_SPARSE = fails(function () {
2472
+ // eslint-disable-next-line es/no-array-prototype-includes -- detection
2473
+ return !Array(1).includes();
2474
+ });
2475
+
2476
+ // `Array.prototype.includes` method
2477
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
2478
+ $$1({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
2479
+ includes: function includes(el /* , fromIndex = 0 */) {
2480
+ return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
2481
+ }
2482
+ });
2483
+
2484
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2485
+ addToUnscopables$1('includes');
2486
+
2487
+ var toObject = toObject$3;
2488
+ var toAbsoluteIndex = toAbsoluteIndex$2;
2489
+ var lengthOfArrayLike = lengthOfArrayLike$4;
2490
+
2491
+ // `Array.prototype.fill` method implementation
2492
+ // https://tc39.es/ecma262/#sec-array.prototype.fill
2493
+ var arrayFill = function fill(value /* , start = 0, end = @length */) {
2494
+ var O = toObject(this);
2495
+ var length = lengthOfArrayLike(O);
2496
+ var argumentsLength = arguments.length;
2497
+ var index = toAbsoluteIndex(argumentsLength > 1 ? arguments[1] : undefined, length);
2498
+ var end = argumentsLength > 2 ? arguments[2] : undefined;
2499
+ var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
2500
+ while (endPos > index) O[index++] = value;
2501
+ return O;
2502
+ };
2503
+
2504
+ var $ = _export;
2505
+ var fill = arrayFill;
2506
+ var addToUnscopables = addToUnscopables$2;
2507
+
2508
+ // `Array.prototype.fill` method
2509
+ // https://tc39.es/ecma262/#sec-array.prototype.fill
2510
+ $({ target: 'Array', proto: true }, {
2511
+ fill: fill
2512
+ });
2513
+
2514
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2515
+ addToUnscopables('fill');
2516
+
2517
+ /* eslint-disable no-prototype-builtins */
2518
+ var g =
2519
+ (typeof globalThis !== 'undefined' && globalThis) ||
2520
+ (typeof self !== 'undefined' && self) ||
2521
+ // eslint-disable-next-line no-undef
2522
+ (typeof global !== 'undefined' && global) ||
2523
+ {};
2524
+
2525
+ var support = {
2526
+ searchParams: 'URLSearchParams' in g,
2527
+ iterable: 'Symbol' in g && 'iterator' in Symbol,
2528
+ blob:
2529
+ 'FileReader' in g &&
2530
+ 'Blob' in g &&
2531
+ (function() {
2532
+ try {
2533
+ new Blob();
2534
+ return true
2535
+ } catch (e) {
2536
+ return false
2537
+ }
2538
+ })(),
2539
+ formData: 'FormData' in g,
2540
+ arrayBuffer: 'ArrayBuffer' in g
2541
+ };
2542
+
2543
+ function isDataView(obj) {
2544
+ return obj && DataView.prototype.isPrototypeOf(obj)
2545
+ }
2546
+
2547
+ if (support.arrayBuffer) {
2548
+ var viewClasses = [
2549
+ '[object Int8Array]',
2550
+ '[object Uint8Array]',
2551
+ '[object Uint8ClampedArray]',
2552
+ '[object Int16Array]',
2553
+ '[object Uint16Array]',
2554
+ '[object Int32Array]',
2555
+ '[object Uint32Array]',
2556
+ '[object Float32Array]',
2557
+ '[object Float64Array]'
2558
+ ];
2559
+
2560
+ var isArrayBufferView =
2561
+ ArrayBuffer.isView ||
2562
+ function(obj) {
2563
+ return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
2564
+ };
2565
+ }
2566
+
2567
+ function normalizeName(name) {
2568
+ if (typeof name !== 'string') {
2569
+ name = String(name);
2570
+ }
2571
+ if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
2572
+ throw new TypeError('Invalid character in header field name: "' + name + '"')
2573
+ }
2574
+ return name.toLowerCase()
2575
+ }
2576
+
2577
+ function normalizeValue(value) {
2578
+ if (typeof value !== 'string') {
2579
+ value = String(value);
2580
+ }
2581
+ return value
2582
+ }
2583
+
2584
+ // Build a destructive iterator for the value list
2585
+ function iteratorFor(items) {
2586
+ var iterator = {
2587
+ next: function() {
2588
+ var value = items.shift();
2589
+ return {done: value === undefined, value: value}
2590
+ }
2591
+ };
2592
+
2593
+ if (support.iterable) {
2594
+ iterator[Symbol.iterator] = function() {
2595
+ return iterator
2596
+ };
2597
+ }
2598
+
2599
+ return iterator
2600
+ }
2601
+
2602
+ function Headers(headers) {
2603
+ this.map = {};
2604
+
2605
+ if (headers instanceof Headers) {
2606
+ headers.forEach(function(value, name) {
2607
+ this.append(name, value);
2608
+ }, this);
2609
+ } else if (Array.isArray(headers)) {
2610
+ headers.forEach(function(header) {
2611
+ if (header.length != 2) {
2612
+ throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
2613
+ }
2614
+ this.append(header[0], header[1]);
2615
+ }, this);
2616
+ } else if (headers) {
2617
+ Object.getOwnPropertyNames(headers).forEach(function(name) {
2618
+ this.append(name, headers[name]);
2619
+ }, this);
2620
+ }
2621
+ }
2622
+
2623
+ Headers.prototype.append = function(name, value) {
2624
+ name = normalizeName(name);
2625
+ value = normalizeValue(value);
2626
+ var oldValue = this.map[name];
2627
+ this.map[name] = oldValue ? oldValue + ', ' + value : value;
2628
+ };
2629
+
2630
+ Headers.prototype['delete'] = function(name) {
2631
+ delete this.map[normalizeName(name)];
2632
+ };
2633
+
2634
+ Headers.prototype.get = function(name) {
2635
+ name = normalizeName(name);
2636
+ return this.has(name) ? this.map[name] : null
2637
+ };
2638
+
2639
+ Headers.prototype.has = function(name) {
2640
+ return this.map.hasOwnProperty(normalizeName(name))
2641
+ };
2642
+
2643
+ Headers.prototype.set = function(name, value) {
2644
+ this.map[normalizeName(name)] = normalizeValue(value);
2645
+ };
2646
+
2647
+ Headers.prototype.forEach = function(callback, thisArg) {
2648
+ for (var name in this.map) {
2649
+ if (this.map.hasOwnProperty(name)) {
2650
+ callback.call(thisArg, this.map[name], name, this);
2651
+ }
2652
+ }
2653
+ };
2654
+
2655
+ Headers.prototype.keys = function() {
2656
+ var items = [];
2657
+ this.forEach(function(value, name) {
2658
+ items.push(name);
2659
+ });
2660
+ return iteratorFor(items)
2661
+ };
2662
+
2663
+ Headers.prototype.values = function() {
2664
+ var items = [];
2665
+ this.forEach(function(value) {
2666
+ items.push(value);
2667
+ });
2668
+ return iteratorFor(items)
2669
+ };
2670
+
2671
+ Headers.prototype.entries = function() {
2672
+ var items = [];
2673
+ this.forEach(function(value, name) {
2674
+ items.push([name, value]);
2675
+ });
2676
+ return iteratorFor(items)
2677
+ };
2678
+
2679
+ if (support.iterable) {
2680
+ Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
2681
+ }
2682
+
2683
+ function consumed(body) {
2684
+ if (body._noBody) return
2685
+ if (body.bodyUsed) {
2686
+ return Promise.reject(new TypeError('Already read'))
2687
+ }
2688
+ body.bodyUsed = true;
2689
+ }
2690
+
2691
+ function fileReaderReady(reader) {
2692
+ return new Promise(function(resolve, reject) {
2693
+ reader.onload = function() {
2694
+ resolve(reader.result);
2695
+ };
2696
+ reader.onerror = function() {
2697
+ reject(reader.error);
2698
+ };
2699
+ })
2700
+ }
2701
+
2702
+ function readBlobAsArrayBuffer(blob) {
2703
+ var reader = new FileReader();
2704
+ var promise = fileReaderReady(reader);
2705
+ reader.readAsArrayBuffer(blob);
2706
+ return promise
2707
+ }
2708
+
2709
+ function readBlobAsText(blob) {
2710
+ var reader = new FileReader();
2711
+ var promise = fileReaderReady(reader);
2712
+ var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
2713
+ var encoding = match ? match[1] : 'utf-8';
2714
+ reader.readAsText(blob, encoding);
2715
+ return promise
2716
+ }
2717
+
2718
+ function readArrayBufferAsText(buf) {
2719
+ var view = new Uint8Array(buf);
2720
+ var chars = new Array(view.length);
2721
+
2722
+ for (var i = 0; i < view.length; i++) {
2723
+ chars[i] = String.fromCharCode(view[i]);
2724
+ }
2725
+ return chars.join('')
2726
+ }
2727
+
2728
+ function bufferClone(buf) {
2729
+ if (buf.slice) {
2730
+ return buf.slice(0)
2731
+ } else {
2732
+ var view = new Uint8Array(buf.byteLength);
2733
+ view.set(new Uint8Array(buf));
2734
+ return view.buffer
2735
+ }
2736
+ }
2737
+
2738
+ function Body() {
2739
+ this.bodyUsed = false;
2740
+
2741
+ this._initBody = function(body) {
2742
+ /*
2743
+ fetch-mock wraps the Response object in an ES6 Proxy to
2744
+ provide useful test harness features such as flush. However, on
2745
+ ES5 browsers without fetch or Proxy support pollyfills must be used;
2746
+ the proxy-pollyfill is unable to proxy an attribute unless it exists
2747
+ on the object before the Proxy is created. This change ensures
2748
+ Response.bodyUsed exists on the instance, while maintaining the
2749
+ semantic of setting Request.bodyUsed in the constructor before
2750
+ _initBody is called.
2751
+ */
2752
+ // eslint-disable-next-line no-self-assign
2753
+ this.bodyUsed = this.bodyUsed;
2754
+ this._bodyInit = body;
2755
+ if (!body) {
2756
+ this._noBody = true;
2757
+ this._bodyText = '';
2758
+ } else if (typeof body === 'string') {
2759
+ this._bodyText = body;
2760
+ } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
2761
+ this._bodyBlob = body;
2762
+ } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
2763
+ this._bodyFormData = body;
2764
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
2765
+ this._bodyText = body.toString();
2766
+ } else if (support.arrayBuffer && support.blob && isDataView(body)) {
2767
+ this._bodyArrayBuffer = bufferClone(body.buffer);
2768
+ // IE 10-11 can't handle a DataView body.
2769
+ this._bodyInit = new Blob([this._bodyArrayBuffer]);
2770
+ } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
2771
+ this._bodyArrayBuffer = bufferClone(body);
2772
+ } else {
2773
+ this._bodyText = body = Object.prototype.toString.call(body);
2774
+ }
2775
+
2776
+ if (!this.headers.get('content-type')) {
2777
+ if (typeof body === 'string') {
2778
+ this.headers.set('content-type', 'text/plain;charset=UTF-8');
2779
+ } else if (this._bodyBlob && this._bodyBlob.type) {
2780
+ this.headers.set('content-type', this._bodyBlob.type);
2781
+ } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
2782
+ this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
2783
+ }
2784
+ }
2785
+ };
2786
+
2787
+ if (support.blob) {
2788
+ this.blob = function() {
2789
+ var rejected = consumed(this);
2790
+ if (rejected) {
2791
+ return rejected
2792
+ }
2793
+
2794
+ if (this._bodyBlob) {
2795
+ return Promise.resolve(this._bodyBlob)
2796
+ } else if (this._bodyArrayBuffer) {
2797
+ return Promise.resolve(new Blob([this._bodyArrayBuffer]))
2798
+ } else if (this._bodyFormData) {
2799
+ throw new Error('could not read FormData body as blob')
2800
+ } else {
2801
+ return Promise.resolve(new Blob([this._bodyText]))
2802
+ }
2803
+ };
2804
+ }
2805
+
2806
+ this.arrayBuffer = function() {
2807
+ if (this._bodyArrayBuffer) {
2808
+ var isConsumed = consumed(this);
2809
+ if (isConsumed) {
2810
+ return isConsumed
2811
+ } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
2812
+ return Promise.resolve(
2813
+ this._bodyArrayBuffer.buffer.slice(
2814
+ this._bodyArrayBuffer.byteOffset,
2815
+ this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
2816
+ )
2817
+ )
2818
+ } else {
2819
+ return Promise.resolve(this._bodyArrayBuffer)
2820
+ }
2821
+ } else if (support.blob) {
2822
+ return this.blob().then(readBlobAsArrayBuffer)
2823
+ } else {
2824
+ throw new Error('could not read as ArrayBuffer')
2825
+ }
2826
+ };
2827
+
2828
+ this.text = function() {
2829
+ var rejected = consumed(this);
2830
+ if (rejected) {
2831
+ return rejected
2832
+ }
2833
+
2834
+ if (this._bodyBlob) {
2835
+ return readBlobAsText(this._bodyBlob)
2836
+ } else if (this._bodyArrayBuffer) {
2837
+ return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
2838
+ } else if (this._bodyFormData) {
2839
+ throw new Error('could not read FormData body as text')
2840
+ } else {
2841
+ return Promise.resolve(this._bodyText)
2842
+ }
2843
+ };
2844
+
2845
+ if (support.formData) {
2846
+ this.formData = function() {
2847
+ return this.text().then(decode)
2848
+ };
2849
+ }
2850
+
2851
+ this.json = function() {
2852
+ return this.text().then(JSON.parse)
2853
+ };
2854
+
2855
+ return this
2856
+ }
2857
+
2858
+ // HTTP methods whose capitalization should be normalized
2859
+ var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
2860
+
2861
+ function normalizeMethod(method) {
2862
+ var upcased = method.toUpperCase();
2863
+ return methods.indexOf(upcased) > -1 ? upcased : method
2864
+ }
2865
+
2866
+ function Request(input, options) {
2867
+ if (!(this instanceof Request)) {
2868
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
2869
+ }
2870
+
2871
+ options = options || {};
2872
+ var body = options.body;
2873
+
2874
+ if (input instanceof Request) {
2875
+ if (input.bodyUsed) {
2876
+ throw new TypeError('Already read')
2877
+ }
2878
+ this.url = input.url;
2879
+ this.credentials = input.credentials;
2880
+ if (!options.headers) {
2881
+ this.headers = new Headers(input.headers);
2882
+ }
2883
+ this.method = input.method;
2884
+ this.mode = input.mode;
2885
+ this.signal = input.signal;
2886
+ if (!body && input._bodyInit != null) {
2887
+ body = input._bodyInit;
2888
+ input.bodyUsed = true;
2889
+ }
2890
+ } else {
2891
+ this.url = String(input);
2892
+ }
2893
+
2894
+ this.credentials = options.credentials || this.credentials || 'same-origin';
2895
+ if (options.headers || !this.headers) {
2896
+ this.headers = new Headers(options.headers);
2897
+ }
2898
+ this.method = normalizeMethod(options.method || this.method || 'GET');
2899
+ this.mode = options.mode || this.mode || null;
2900
+ this.signal = options.signal || this.signal || (function () {
2901
+ if ('AbortController' in g) {
2902
+ var ctrl = new AbortController();
2903
+ return ctrl.signal;
2904
+ }
2905
+ }());
2906
+ this.referrer = null;
2907
+
2908
+ if ((this.method === 'GET' || this.method === 'HEAD') && body) {
2909
+ throw new TypeError('Body not allowed for GET or HEAD requests')
2910
+ }
2911
+ this._initBody(body);
2912
+
2913
+ if (this.method === 'GET' || this.method === 'HEAD') {
2914
+ if (options.cache === 'no-store' || options.cache === 'no-cache') {
2915
+ // Search for a '_' parameter in the query string
2916
+ var reParamSearch = /([?&])_=[^&]*/;
2917
+ if (reParamSearch.test(this.url)) {
2918
+ // If it already exists then set the value with the current time
2919
+ this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
2920
+ } else {
2921
+ // Otherwise add a new '_' parameter to the end with the current time
2922
+ var reQueryString = /\?/;
2923
+ this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
2924
+ }
2925
+ }
2926
+ }
2927
+ }
2928
+
2929
+ Request.prototype.clone = function() {
2930
+ return new Request(this, {body: this._bodyInit})
2931
+ };
2932
+
2933
+ function decode(body) {
2934
+ var form = new FormData();
2935
+ body
2936
+ .trim()
2937
+ .split('&')
2938
+ .forEach(function(bytes) {
2939
+ if (bytes) {
2940
+ var split = bytes.split('=');
2941
+ var name = split.shift().replace(/\+/g, ' ');
2942
+ var value = split.join('=').replace(/\+/g, ' ');
2943
+ form.append(decodeURIComponent(name), decodeURIComponent(value));
2944
+ }
2945
+ });
2946
+ return form
2947
+ }
2948
+
2949
+ function parseHeaders(rawHeaders) {
2950
+ var headers = new Headers();
2951
+ // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
2952
+ // https://tools.ietf.org/html/rfc7230#section-3.2
2953
+ var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
2954
+ // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
2955
+ // https://github.com/github/fetch/issues/748
2956
+ // https://github.com/zloirock/core-js/issues/751
2957
+ preProcessedHeaders
2958
+ .split('\r')
2959
+ .map(function(header) {
2960
+ return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
2961
+ })
2962
+ .forEach(function(line) {
2963
+ var parts = line.split(':');
2964
+ var key = parts.shift().trim();
2965
+ if (key) {
2966
+ var value = parts.join(':').trim();
2967
+ try {
2968
+ headers.append(key, value);
2969
+ } catch (error) {
2970
+ }
2971
+ }
2972
+ });
2973
+ return headers
2974
+ }
2975
+
2976
+ Body.call(Request.prototype);
2977
+
2978
+ function Response(bodyInit, options) {
2979
+ if (!(this instanceof Response)) {
2980
+ throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
2981
+ }
2982
+ if (!options) {
2983
+ options = {};
2984
+ }
2985
+
2986
+ this.type = 'default';
2987
+ this.status = options.status === undefined ? 200 : options.status;
2988
+ if (this.status < 200 || this.status > 599) {
2989
+ throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
2990
+ }
2991
+ this.ok = this.status >= 200 && this.status < 300;
2992
+ this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
2993
+ this.headers = new Headers(options.headers);
2994
+ this.url = options.url || '';
2995
+ this._initBody(bodyInit);
2996
+ }
2997
+
2998
+ Body.call(Response.prototype);
2999
+
3000
+ Response.prototype.clone = function() {
3001
+ return new Response(this._bodyInit, {
3002
+ status: this.status,
3003
+ statusText: this.statusText,
3004
+ headers: new Headers(this.headers),
3005
+ url: this.url
3006
+ })
3007
+ };
3008
+
3009
+ Response.error = function() {
3010
+ var response = new Response(null, {status: 200, statusText: ''});
3011
+ response.ok = false;
3012
+ response.status = 0;
3013
+ response.type = 'error';
3014
+ return response
3015
+ };
3016
+
3017
+ var redirectStatuses = [301, 302, 303, 307, 308];
3018
+
3019
+ Response.redirect = function(url, status) {
3020
+ if (redirectStatuses.indexOf(status) === -1) {
3021
+ throw new RangeError('Invalid status code')
3022
+ }
3023
+
3024
+ return new Response(null, {status: status, headers: {location: url}})
3025
+ };
3026
+
3027
+ var DOMException = g.DOMException;
3028
+ try {
3029
+ new DOMException();
3030
+ } catch (err) {
3031
+ DOMException = function(message, name) {
3032
+ this.message = message;
3033
+ this.name = name;
3034
+ var error = Error(message);
3035
+ this.stack = error.stack;
3036
+ };
3037
+ DOMException.prototype = Object.create(Error.prototype);
3038
+ DOMException.prototype.constructor = DOMException;
3039
+ }
3040
+
3041
+ function fetch$1(input, init) {
3042
+ return new Promise(function(resolve, reject) {
3043
+ var request = new Request(input, init);
3044
+
3045
+ if (request.signal && request.signal.aborted) {
3046
+ return reject(new DOMException('Aborted', 'AbortError'))
3047
+ }
3048
+
3049
+ var xhr = new XMLHttpRequest();
3050
+
3051
+ function abortXhr() {
3052
+ xhr.abort();
3053
+ }
3054
+
3055
+ xhr.onload = function() {
3056
+ var options = {
3057
+ statusText: xhr.statusText,
3058
+ headers: parseHeaders(xhr.getAllResponseHeaders() || '')
3059
+ };
3060
+ // This check if specifically for when a user fetches a file locally from the file system
3061
+ // Only if the status is out of a normal range
3062
+ if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
3063
+ options.status = 200;
3064
+ } else {
3065
+ options.status = xhr.status;
3066
+ }
3067
+ options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
3068
+ var body = 'response' in xhr ? xhr.response : xhr.responseText;
3069
+ setTimeout(function() {
3070
+ resolve(new Response(body, options));
3071
+ }, 0);
3072
+ };
3073
+
3074
+ xhr.onerror = function() {
3075
+ setTimeout(function() {
3076
+ reject(new TypeError('Network request failed'));
3077
+ }, 0);
3078
+ };
3079
+
3080
+ xhr.ontimeout = function() {
3081
+ setTimeout(function() {
3082
+ reject(new TypeError('Network request timed out'));
3083
+ }, 0);
3084
+ };
3085
+
3086
+ xhr.onabort = function() {
3087
+ setTimeout(function() {
3088
+ reject(new DOMException('Aborted', 'AbortError'));
3089
+ }, 0);
3090
+ };
3091
+
3092
+ function fixUrl(url) {
3093
+ try {
3094
+ return url === '' && g.location.href ? g.location.href : url
3095
+ } catch (e) {
3096
+ return url
3097
+ }
3098
+ }
3099
+
3100
+ xhr.open(request.method, fixUrl(request.url), true);
3101
+
3102
+ if (request.credentials === 'include') {
3103
+ xhr.withCredentials = true;
3104
+ } else if (request.credentials === 'omit') {
3105
+ xhr.withCredentials = false;
3106
+ }
3107
+
3108
+ if ('responseType' in xhr) {
3109
+ if (support.blob) {
3110
+ xhr.responseType = 'blob';
3111
+ } else if (
3112
+ support.arrayBuffer
3113
+ ) {
3114
+ xhr.responseType = 'arraybuffer';
3115
+ }
3116
+ }
3117
+
3118
+ if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
3119
+ var names = [];
3120
+ Object.getOwnPropertyNames(init.headers).forEach(function(name) {
3121
+ names.push(normalizeName(name));
3122
+ xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
3123
+ });
3124
+ request.headers.forEach(function(value, name) {
3125
+ if (names.indexOf(name) === -1) {
3126
+ xhr.setRequestHeader(name, value);
3127
+ }
3128
+ });
3129
+ } else {
3130
+ request.headers.forEach(function(value, name) {
3131
+ xhr.setRequestHeader(name, value);
3132
+ });
3133
+ }
3134
+
3135
+ if (request.signal) {
3136
+ request.signal.addEventListener('abort', abortXhr);
3137
+
3138
+ xhr.onreadystatechange = function() {
3139
+ // DONE (success or failure)
3140
+ if (xhr.readyState === 4) {
3141
+ request.signal.removeEventListener('abort', abortXhr);
3142
+ }
3143
+ };
3144
+ }
3145
+
3146
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
3147
+ })
3148
+ }
3149
+
3150
+ fetch$1.polyfill = true;
3151
+
3152
+ if (!g.fetch) {
3153
+ g.fetch = fetch$1;
3154
+ g.Headers = Headers;
3155
+ g.Request = Request;
3156
+ g.Response = Response;
3157
+ }
3158
+
3159
+ function styleInject(css, ref) {
3160
+ if ( ref === void 0 ) ref = {};
3161
+ var insertAt = ref.insertAt;
3162
+
3163
+ if (typeof document === 'undefined') { return; }
3164
+
3165
+ var head = document.head || document.getElementsByTagName('head')[0];
3166
+ var style = document.createElement('style');
3167
+ style.type = 'text/css';
3168
+
3169
+ if (insertAt === 'top') {
3170
+ if (head.firstChild) {
3171
+ head.insertBefore(style, head.firstChild);
3172
+ } else {
3173
+ head.appendChild(style);
3174
+ }
3175
+ } else {
3176
+ head.appendChild(style);
3177
+ }
3178
+
3179
+ if (style.styleSheet) {
3180
+ style.styleSheet.cssText = css;
3181
+ } else {
3182
+ style.appendChild(document.createTextNode(css));
3183
+ }
3184
+ }
3185
+
3186
+ var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:0 0}75%{background-position:100% -100%}to{background-position:0 0}}";
3187
+ styleInject(css_248z);
3188
+
3189
+ /******************************************************************************
3190
+ Copyright (c) Microsoft Corporation.
3191
+
3192
+ Permission to use, copy, modify, and/or distribute this software for any
3193
+ purpose with or without fee is hereby granted.
3194
+
3195
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3196
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3197
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3198
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3199
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3200
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3201
+ PERFORMANCE OF THIS SOFTWARE.
3202
+ ***************************************************************************** */
3203
+ /* global Reflect, Promise */
3204
+
3205
+ var extendStatics = function(d, b) {
3206
+ extendStatics = Object.setPrototypeOf ||
3207
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3208
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
3209
+ return extendStatics(d, b);
3210
+ };
3211
+
3212
+ function __extends(d, b) {
3213
+ if (typeof b !== "function" && b !== null)
3214
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
3215
+ extendStatics(d, b);
3216
+ function __() { this.constructor = d; }
3217
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3218
+ }
3219
+
3220
+ var __assign = function() {
3221
+ __assign = Object.assign || function __assign(t) {
3222
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
3223
+ s = arguments[i];
3224
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3225
+ }
3226
+ return t;
3227
+ };
3228
+ return __assign.apply(this, arguments);
3229
+ };
3230
+
3231
+ function __awaiter(thisArg, _arguments, P, generator) {
3232
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3233
+ return new (P || (P = Promise))(function (resolve, reject) {
3234
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3235
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3236
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3237
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
3238
+ });
3239
+ }
3240
+
3241
+ function __generator(thisArg, body) {
3242
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
3243
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
3244
+ function verb(n) { return function (v) { return step([n, v]); }; }
3245
+ function step(op) {
3246
+ if (f) throw new TypeError("Generator is already executing.");
3247
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
3248
+ 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;
3249
+ if (y = 0, t) op = [op[0] & 2, t.value];
3250
+ switch (op[0]) {
3251
+ case 0: case 1: t = op; break;
3252
+ case 4: _.label++; return { value: op[1], done: false };
3253
+ case 5: _.label++; y = op[1]; op = [0]; continue;
3254
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
3255
+ default:
3256
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
3257
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
3258
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
3259
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
3260
+ if (t[2]) _.ops.pop();
3261
+ _.trys.pop(); continue;
3262
+ }
3263
+ op = body.call(thisArg, _);
3264
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
3265
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
3266
+ }
3267
+ }
3268
+
3269
+ var convertImage = function (canvas) {
3270
+ return canvas.toDataURL('image/png', 1);
3271
+ };
3272
+ var isFunction = function (value) {
3273
+ return typeof value === 'function';
3274
+ };
3275
+ var isUndefined = function (value) {
3276
+ return value === undefined;
3277
+ };
3278
+ var isString = function (value) {
3279
+ return typeof value === 'string';
3280
+ };
3281
+ var createSVGElement = function (tagName, attrs, namespaceURI) {
3282
+ if (attrs === void 0) { attrs = {}; }
3283
+ if (namespaceURI === void 0) { namespaceURI = 'http://www.w3.org/2000/svg'; }
3284
+ var element = document.createElementNS(namespaceURI, tagName);
3285
+ for (var attr in attrs) {
3286
+ element.setAttribute(attr, attrs[attr]);
3287
+ }
3288
+ return element;
3289
+ };
3290
+ var getMultiLineData = function (ctx, text, maxWidth) {
3291
+ var result = [];
3292
+ var str = '';
3293
+ for (var i = 0, len = text.length; i < len; i++) {
3294
+ str += text.charAt(i);
3295
+ if (ctx.measureText(str).width > maxWidth) {
3296
+ result.push(str.substring(0, str.length - 1));
3297
+ str = '';
3298
+ i--;
3299
+ }
3300
+ }
3301
+ result.push(str);
3302
+ return result;
3303
+ };
3304
+ var createCustomContentSVG = function (ctx, options) { return __awaiter(void 0, void 0, void 0, function () {
3305
+ var svgElement, bodyElement, rect, rectWidth, rectHeight, width, height, foreignObjectElement;
3306
+ var _a;
3307
+ return __generator(this, function (_b) {
3308
+ switch (_b.label) {
3309
+ case 0:
3310
+ svgElement = createSVGElement('svg', {
3311
+ xmlns: 'http://www.w3.org/2000/svg'
3312
+ });
3313
+ bodyElement = document.createElement('div');
3314
+ bodyElement.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
3315
+ 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");
3316
+ bodyElement.innerHTML = "<div class='rich-text-content'>".concat(options.content, "</div>");
3317
+ document.body.appendChild(bodyElement);
3318
+ // convert all images to base64
3319
+ return [4 /*yield*/, convertImgToBase64(bodyElement)];
3320
+ case 1:
3321
+ // convert all images to base64
3322
+ _b.sent();
3323
+ rect = (_a = bodyElement.querySelector('.rich-text-content')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
3324
+ rectWidth = rect === null || rect === void 0 ? void 0 : rect.width;
3325
+ rectHeight = rect === null || rect === void 0 ? void 0 : rect.height;
3326
+ document.body.removeChild(bodyElement);
3327
+ width = options.richTextWidth || rectWidth || options.width;
3328
+ height = options.richTextHeight || rectHeight || options.height;
3329
+ svgElement.setAttribute('width', width.toString());
3330
+ svgElement.setAttribute('height', height.toString());
3331
+ foreignObjectElement = createSVGElement('foreignObject', {
3332
+ width: width.toString(),
3333
+ height: height.toString()
3334
+ });
3335
+ foreignObjectElement.appendChild(bodyElement);
3336
+ svgElement.appendChild(foreignObjectElement);
3337
+ return [2 /*return*/, {
3338
+ element: svgElement,
3339
+ width: width,
3340
+ height: height
3341
+ }];
3342
+ }
3343
+ });
3344
+ }); };
3345
+ function convertImgToBase64(bodyElement) {
3346
+ return __awaiter(this, void 0, void 0, function () {
3347
+ var imgElements, _loop_1, _i, _a, img;
3348
+ return __generator(this, function (_b) {
3349
+ switch (_b.label) {
3350
+ case 0:
3351
+ imgElements = bodyElement.querySelectorAll('img');
3352
+ _loop_1 = function (img) {
3353
+ var src, response, blob_1, imgData, error_1;
3354
+ return __generator(this, function (_c) {
3355
+ switch (_c.label) {
3356
+ case 0:
3357
+ src = img.getAttribute('src');
3358
+ if (!src) return [3 /*break*/, 6];
3359
+ _c.label = 1;
3360
+ case 1:
3361
+ _c.trys.push([1, 5, , 6]);
3362
+ return [4 /*yield*/, fetch(src)];
3363
+ case 2:
3364
+ response = _c.sent();
3365
+ return [4 /*yield*/, response.blob()];
3366
+ case 3:
3367
+ blob_1 = _c.sent();
3368
+ return [4 /*yield*/, new Promise(function (resolve, reject) {
3369
+ var reader = new FileReader();
3370
+ reader.onloadend = function () { return resolve(reader.result); };
3371
+ reader.onerror = reject;
3372
+ reader.readAsDataURL(blob_1);
3373
+ })];
3374
+ case 4:
3375
+ imgData = _c.sent();
3376
+ if (isString(imgData)) {
3377
+ img.setAttribute('src', imgData);
3378
+ }
3379
+ return [3 /*break*/, 6];
3380
+ case 5:
3381
+ error_1 = _c.sent();
3382
+ console.error("Error converting ".concat(src, " to base64:"), error_1);
3383
+ return [3 /*break*/, 6];
3384
+ case 6: return [2 /*return*/];
3385
+ }
3386
+ });
3387
+ };
3388
+ _i = 0, _a = Array.from(imgElements);
3389
+ _b.label = 1;
3390
+ case 1:
3391
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
3392
+ img = _a[_i];
3393
+ return [5 /*yield**/, _loop_1(img)];
3394
+ case 2:
3395
+ _b.sent();
3396
+ _b.label = 3;
3397
+ case 3:
3398
+ _i++;
3399
+ return [3 /*break*/, 1];
3400
+ case 4: return [2 /*return*/];
3401
+ }
3402
+ });
3403
+ });
3404
+ }
3405
+ var convertSVGToImage = function (svg) {
3406
+ var richContent = svg.outerHTML.replace(/<img(.*?)>/g, '<img$1/>').replace(/\n/g, '').replace(/\t/g, '').replace(/#/g, '%23');
3407
+ return "data:image/svg+xml;charset=utf-8,".concat(richContent);
3408
+ };
3409
+ var getValue = function (v1, v2) {
3410
+ if (isUndefined(v1)) {
3411
+ return v2;
3412
+ }
3413
+ else {
3414
+ return v1;
3415
+ }
3416
+ };
3417
+ var loadImage = function (url, width, height) {
3418
+ if (width === void 0) { width = undefined; }
3419
+ if (height === void 0) { height = undefined; }
3420
+ var image = new Image();
3421
+ image.setAttribute('crossOrigin', 'Anonymous');
3422
+ !isUndefined(width) && (image.width = width);
3423
+ !isUndefined(height) && (image.height = height);
3424
+ image.src = url;
3425
+ return new Promise(function (resolve) {
3426
+ image.onload = function () {
3427
+ resolve(image);
3428
+ };
3429
+ });
3430
+ };
3431
+ var generateMatrix = function (rows, columns, value) {
3432
+ return Array.from({ length: rows }, function () { return new Array(columns).fill(value); });
3433
+ };
3434
+
3435
+ var initialOptions = {
3436
+ width: 300,
3437
+ height: 300,
3438
+ rotate: 45,
3439
+ layout: 'default',
3440
+ auxiliaryLine: false,
3441
+ translatePlacement: 'middle',
3442
+ contentType: 'text',
3443
+ content: 'hello watermark-js-plus',
3444
+ textType: 'fill',
3445
+ imageWidth: 0,
3446
+ imageHeight: 0,
3447
+ lineHeight: 30,
3448
+ zIndex: 2147483647,
3449
+ backgroundPosition: '0 0',
3450
+ backgroundRepeat: 'repeat',
3451
+ fontSize: '20px',
3452
+ fontFamily: 'sans-serif',
3453
+ fontStyle: '',
3454
+ fontVariant: '',
3455
+ fontColor: '#000',
3456
+ fontWeight: 'normal',
3457
+ filter: 'none',
3458
+ letterSpacing: '0px',
3459
+ wordSpacing: '0px',
3460
+ globalAlpha: 0.5,
3461
+ mode: 'default',
3462
+ mutationObserve: true,
3463
+ movable: false,
3464
+ parent: 'body',
3465
+ onSuccess: function () { },
3466
+ onBeforeDestroy: function () { },
3467
+ onDestroyed: function () { },
3468
+ onObserveError: function () { }
3469
+ };
3470
+ var generateRecommendOptions = function (canvas, options, args) {
3471
+ var ctx = canvas.getContext('2d');
3472
+ if (ctx === null) {
3473
+ throw new Error('get context error');
3474
+ }
3475
+ ctx.font = "".concat(options.fontStyle, " ").concat(options.fontVariant, " ").concat(options.fontWeight, " ").concat(options.fontSize, " ").concat(options.fontFamily);
3476
+ ctx.filter = options.filter;
3477
+ // @ts-ignore
3478
+ ctx.letterSpacing = options.letterSpacing;
3479
+ ctx.wordSpacing = options.wordSpacing;
3480
+ if (options === null || options === void 0 ? void 0 : options.rotate) {
3481
+ options.rotate = (360 - options.rotate % 360) * (Math.PI / 180);
3482
+ }
3483
+ if (isUndefined(args.textRowMaxWidth)) {
3484
+ options.textRowMaxWidth = options.width;
3485
+ }
3486
+ var result = {
3487
+ image: {
3488
+ rect: {
3489
+ width: options.imageWidth,
3490
+ height: options.imageHeight
3491
+ },
3492
+ position: {
3493
+ x: 0,
3494
+ y: 0
3495
+ }
3496
+ },
3497
+ textLine: {
3498
+ data: [],
3499
+ yOffsetValue: 0
3500
+ },
3501
+ advancedStyleParams: {
3502
+ linear: {
3503
+ x0: 0,
3504
+ x1: 0
3505
+ },
3506
+ radial: {
3507
+ x0: 0,
3508
+ y0: 0,
3509
+ r0: 0,
3510
+ x1: 0,
3511
+ y1: 0,
3512
+ r1: 0
3513
+ },
3514
+ conic: {
3515
+ x: 0,
3516
+ y: 0,
3517
+ startAngle: 0
3518
+ },
3519
+ pattern: {}
3520
+ }
3521
+ };
3522
+ switch (options.contentType) {
3523
+ case 'text':
3524
+ result.textLine.data = [options.content];
3525
+ break;
3526
+ case 'multi-line-text':
3527
+ result.textLine.data = getMultiLineData(ctx, options.content, options.textRowMaxWidth);
3528
+ break;
3529
+ // case 'image':
3530
+ // break
3531
+ // case 'rich-text':
3532
+ // break
3533
+ }
3534
+ var translateX = options.width / 2;
3535
+ var translateY = options.height / 2;
3536
+ var textBaseline = 'middle';
3537
+ var textAlign = 'center';
3538
+ if (!isUndefined(args === null || args === void 0 ? void 0 : args.translateX) && !isUndefined(args === null || args === void 0 ? void 0 : args.translateY)) {
3539
+ translateX = args === null || args === void 0 ? void 0 : args.translateX;
3540
+ translateY = args === null || args === void 0 ? void 0 : args.translateY;
3541
+ textBaseline = 'top';
3542
+ textAlign = 'left';
3543
+ }
3544
+ else {
3545
+ // default middle
3546
+ // translateX = options.width / 2
3547
+ // translateY = options.height / 2
3548
+ // TextBaselineType = 'middle'
3549
+ // textAlign = 'center'
3550
+ result.advancedStyleParams.linear.x0 = -options.width / 2;
3551
+ result.advancedStyleParams.linear.x1 = options.width / 2;
3552
+ // result.advancedStyleParams.radial.x0 = 0
3553
+ // result.advancedStyleParams.radial.y0 = 0
3554
+ result.advancedStyleParams.radial.r0 = 0;
3555
+ // result.advancedStyleParams.radial.x1 = 0
3556
+ // result.advancedStyleParams.radial.y1 = 0
3557
+ result.advancedStyleParams.radial.r1 = options.width / 2;
3558
+ // result.advancedStyleParams.conic.x = 0
3559
+ // result.advancedStyleParams.conic.y = 0
3560
+ }
3561
+ switch (args.translatePlacement) {
3562
+ case 'top':
3563
+ translateX = options.width / 2;
3564
+ translateY = 0;
3565
+ textBaseline = 'top';
3566
+ // textAlign = 'center'
3567
+ result.advancedStyleParams.linear.x0 = -options.width / 2;
3568
+ result.advancedStyleParams.linear.x1 = options.width / 2;
3569
+ // result.advancedStyleParams.radial.x0 = 0
3570
+ result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
3571
+ // result.advancedStyleParams.radial.r0 = 0
3572
+ // result.advancedStyleParams.radial.x1 = 0
3573
+ // result.advancedStyleParams.radial.y1 = 0
3574
+ result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
3575
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3576
+ // result.advancedStyleParams.conic.x = 0
3577
+ result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
3578
+ break;
3579
+ case 'top-start':
3580
+ translateX = 0;
3581
+ translateY = 0;
3582
+ textBaseline = 'top';
3583
+ textAlign = 'start';
3584
+ result.advancedStyleParams.linear.x0 = 0;
3585
+ result.advancedStyleParams.linear.x1 = options.width;
3586
+ result.advancedStyleParams.radial.x0 = options.width / 2;
3587
+ result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
3588
+ // result.advancedStyleParams.radial.r0 = 0
3589
+ result.advancedStyleParams.radial.x1 = options.width / 2;
3590
+ result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
3591
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3592
+ result.advancedStyleParams.conic.x = options.width / 2;
3593
+ result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
3594
+ break;
3595
+ case 'top-end':
3596
+ translateX = options.width;
3597
+ translateY = 0;
3598
+ textBaseline = 'top';
3599
+ textAlign = 'end';
3600
+ result.advancedStyleParams.linear.x0 = 0;
3601
+ result.advancedStyleParams.linear.x1 = -options.width;
3602
+ result.advancedStyleParams.radial.x0 = -options.width / 2;
3603
+ result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
3604
+ // result.advancedStyleParams.radial.r0 = 0
3605
+ result.advancedStyleParams.radial.x1 = -options.width / 2;
3606
+ result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
3607
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3608
+ result.advancedStyleParams.conic.x = -options.width / 2;
3609
+ result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
3610
+ break;
3611
+ case 'bottom':
3612
+ translateX = options.width / 2;
3613
+ translateY = options.height;
3614
+ textBaseline = 'bottom';
3615
+ // textAlign = 'center'
3616
+ result.advancedStyleParams.linear.x0 = -options.width / 2;
3617
+ result.advancedStyleParams.linear.x1 = options.width / 2;
3618
+ // result.advancedStyleParams.radial.x0 = 0
3619
+ result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
3620
+ // result.advancedStyleParams.radial.r0 = 0
3621
+ // result.advancedStyleParams.radial.x1 = 0
3622
+ result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
3623
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3624
+ result.advancedStyleParams.conic.x = 0;
3625
+ result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
3626
+ break;
3627
+ case 'bottom-start':
3628
+ translateX = 0;
3629
+ translateY = options.height;
3630
+ textBaseline = 'bottom';
3631
+ textAlign = 'start';
3632
+ result.advancedStyleParams.linear.x0 = 0;
3633
+ result.advancedStyleParams.linear.x1 = options.width;
3634
+ result.advancedStyleParams.radial.x0 = options.width / 2;
3635
+ result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
3636
+ // result.advancedStyleParams.radial.r0 = 0
3637
+ result.advancedStyleParams.radial.x1 = options.width / 2;
3638
+ result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
3639
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3640
+ result.advancedStyleParams.conic.x = options.width / 2;
3641
+ result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
3642
+ break;
3643
+ case 'bottom-end':
3644
+ translateX = options.width;
3645
+ translateY = options.height;
3646
+ textBaseline = 'bottom';
3647
+ textAlign = 'end';
3648
+ result.advancedStyleParams.linear.x0 = 0;
3649
+ result.advancedStyleParams.linear.x1 = -options.width;
3650
+ result.advancedStyleParams.radial.x0 = -options.width / 2;
3651
+ result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
3652
+ // result.advancedStyleParams.radial.r0 = 0
3653
+ result.advancedStyleParams.radial.x1 = -options.width / 2;
3654
+ result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
3655
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3656
+ result.advancedStyleParams.conic.x = -options.width / 2;
3657
+ result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
3658
+ break;
3659
+ case 'left':
3660
+ translateX = 0;
3661
+ translateY = options.height / 2;
3662
+ // TextBaselineType = 'middle'
3663
+ textAlign = 'start';
3664
+ result.advancedStyleParams.linear.x0 = 0;
3665
+ result.advancedStyleParams.linear.x1 = options.width;
3666
+ result.advancedStyleParams.radial.x0 = options.width / 2;
3667
+ // result.advancedStyleParams.radial.y0 = 0
3668
+ // result.advancedStyleParams.radial.r0 = 0
3669
+ result.advancedStyleParams.radial.x1 = options.width / 2;
3670
+ // result.advancedStyleParams.radial.y1 = 0
3671
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3672
+ result.advancedStyleParams.conic.x = options.width / 2;
3673
+ result.advancedStyleParams.conic.y = 0;
3674
+ break;
3675
+ case 'right':
3676
+ translateX = options.width;
3677
+ translateY = options.height / 2;
3678
+ // TextBaselineType = 'middle'
3679
+ textAlign = 'end';
3680
+ result.advancedStyleParams.linear.x0 = 0;
3681
+ result.advancedStyleParams.linear.x1 = -options.width;
3682
+ result.advancedStyleParams.radial.x0 = -options.width / 2;
3683
+ // result.advancedStyleParams.radial.y0 = 0
3684
+ // result.advancedStyleParams.radial.r0 = 0
3685
+ result.advancedStyleParams.radial.x1 = -options.width / 2;
3686
+ // result.advancedStyleParams.radial.y1 = 0
3687
+ // result.advancedStyleParams.radial.r1 = options.width / 2
3688
+ result.advancedStyleParams.conic.x = -options.width / 2;
3689
+ result.advancedStyleParams.conic.y = 0;
3690
+ break;
3691
+ }
3692
+ options.translateX = translateX;
3693
+ options.translateY = translateY;
3694
+ isUndefined(args === null || args === void 0 ? void 0 : args.textBaseline) && (options.textBaseline = textBaseline);
3695
+ isUndefined(args === null || args === void 0 ? void 0 : args.textAlign) && (options.textAlign = textAlign);
3696
+ if (['text', 'multi-line-text'].includes(options.contentType)) {
3697
+ switch (options.textBaseline) {
3698
+ case 'middle':
3699
+ result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight / 2;
3700
+ break;
3701
+ case 'bottom':
3702
+ case 'alphabetic':
3703
+ case 'ideographic':
3704
+ result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
3705
+ break;
3706
+ case 'top':
3707
+ case 'hanging':
3708
+ result.textLine.yOffsetValue = -options.lineHeight / 2 + parseInt(options.fontSize) / 2;
3709
+ break;
3710
+ }
3711
+ }
3712
+ return result;
3713
+ };
3714
+
3715
+ var bootstrap = (function () {
3716
+ if (typeof window !== 'undefined') {
3717
+ Object.defineProperty(window, 'MutationObserver', {
3718
+ writable: false,
3719
+ configurable: false
3720
+ });
3721
+ Object.defineProperty(window, 'requestAnimationFrame', {
3722
+ writable: false,
3723
+ configurable: false
3724
+ });
3725
+ }
3726
+ });
3727
+
3728
+ var WatermarkCanvas = /** @class */ (function () {
3729
+ function WatermarkCanvas(args, options) {
3730
+ this.props = args;
3731
+ this.options = options;
3732
+ this.canvas = WatermarkCanvas.createCanvas(this.options.width, this.options.height);
3733
+ this.recommendOptions = generateRecommendOptions(this.canvas, this.options, this.props);
3734
+ }
3735
+ /**
3736
+ * Create an HD canvas.
3737
+ * @param width - width of canvas
3738
+ * @param height - height of canvas
3739
+ */
3740
+ WatermarkCanvas.createCanvas = function (width, height) {
3741
+ var _a;
3742
+ var ratio = window.devicePixelRatio || 1;
3743
+ var canvas = document.createElement('canvas');
3744
+ canvas.width = width * ratio; // actual rendered pixel
3745
+ canvas.height = height * ratio; // actual rendered pixel
3746
+ canvas.style.width = "".concat(width, "px"); // control display size
3747
+ canvas.style.height = "".concat(height, "px"); // control display size
3748
+ (_a = canvas.getContext('2d')) === null || _a === void 0 ? void 0 : _a.setTransform(ratio, 0, 0, ratio, 0, 0);
3749
+ return canvas;
3750
+ };
3751
+ /**
3752
+ * Clean the canvas
3753
+ * @param canvas
3754
+ */
3755
+ WatermarkCanvas.clearCanvas = function (canvas) {
3756
+ var ctx = canvas.getContext('2d');
3757
+ if (ctx === null) {
3758
+ throw new Error('get context error');
3759
+ }
3760
+ ctx.restore();
3761
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
3762
+ };
3763
+ WatermarkCanvas.prototype.getCanvas = function () {
3764
+ return this.canvas;
3765
+ };
3766
+ WatermarkCanvas.prototype.clear = function () {
3767
+ WatermarkCanvas.clearCanvas(this.canvas);
3768
+ };
3769
+ WatermarkCanvas.prototype.draw = function () {
3770
+ var _this = this;
3771
+ var ctx = this.canvas.getContext('2d');
3772
+ if (ctx === null) {
3773
+ throw new Error('get context error');
3774
+ }
3775
+ if (this.options.auxiliaryLine) {
3776
+ ctx.beginPath();
3777
+ ctx.rect(0, 0, this.options.width, this.options.height);
3778
+ ctx.lineWidth = 1;
3779
+ ctx.strokeStyle = '#000';
3780
+ ctx.stroke();
3781
+ ctx.closePath();
3782
+ ctx.beginPath();
3783
+ ctx.rect(this.options.translateX, this.options.translateY, 1, 1);
3784
+ ctx.lineWidth = 1;
3785
+ ctx.strokeStyle = '#f00';
3786
+ ctx.stroke();
3787
+ ctx.closePath();
3788
+ }
3789
+ this.setStyle(ctx);
3790
+ ctx.save();
3791
+ ctx.translate(this.options.translateX, this.options.translateY);
3792
+ ctx.rotate(this.options.rotate);
3793
+ return new Promise(function (resolve) {
3794
+ switch (_this.options.contentType) {
3795
+ case 'text':
3796
+ _this.drawText(ctx, resolve);
3797
+ break;
3798
+ case 'image':
3799
+ _this.drawImage(ctx, resolve);
3800
+ break;
3801
+ case 'multi-line-text':
3802
+ _this.drawMultiLineText(ctx, resolve);
3803
+ break;
3804
+ case 'rich-text':
3805
+ _this.drawRichText(ctx, resolve);
3806
+ break;
3807
+ }
3808
+ });
3809
+ };
3810
+ WatermarkCanvas.prototype.setStyle = function (ctx) {
3811
+ var _a;
3812
+ var propName = 'fillStyle';
3813
+ if (this.options.textType === 'stroke') {
3814
+ propName = 'strokeStyle';
3815
+ }
3816
+ var style = this.options.fontColor;
3817
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) {
3818
+ switch (this.options.advancedStyle.type) {
3819
+ case 'linear':
3820
+ style = this.createLinearGradient(ctx);
3821
+ break;
3822
+ case 'radial':
3823
+ style = this.createRadialGradient(ctx);
3824
+ break;
3825
+ case 'conic':
3826
+ style = this.createConicGradient(ctx);
3827
+ break;
3828
+ case 'pattern':
3829
+ style = this.createPattern(ctx);
3830
+ break;
3831
+ }
3832
+ }
3833
+ ctx[propName] && style && (ctx[propName] = style);
3834
+ this.options.textAlign && (ctx.textAlign = this.options.textAlign);
3835
+ this.options.textBaseline && (ctx.textBaseline = this.options.textBaseline);
3836
+ ctx.globalAlpha = this.options.globalAlpha;
3837
+ if (this.options.shadowStyle) {
3838
+ ctx.shadowBlur = getValue(this.options.shadowStyle.shadowBlur, 0);
3839
+ ctx.shadowColor = getValue(this.options.shadowStyle.shadowColor, '#00000000');
3840
+ ctx.shadowOffsetX = getValue(this.options.shadowStyle.shadowOffsetX, 0);
3841
+ ctx.shadowOffsetY = getValue(this.options.shadowStyle.shadowOffsetY, 0);
3842
+ }
3843
+ if (isFunction(this.options.extraDrawFunc)) {
3844
+ this.options.extraDrawFunc(ctx);
3845
+ }
3846
+ };
3847
+ WatermarkCanvas.prototype.createLinearGradient = function (ctx) {
3848
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
3849
+ 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));
3850
+ (_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) {
3851
+ gradient.addColorStop(item.offset, item.color);
3852
+ });
3853
+ return gradient;
3854
+ };
3855
+ WatermarkCanvas.prototype.createConicGradient = function (ctx) {
3856
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
3857
+ 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));
3858
+ (_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) {
3859
+ gradient.addColorStop(item.offset, item.color);
3860
+ });
3861
+ return gradient;
3862
+ };
3863
+ WatermarkCanvas.prototype.createRadialGradient = function (ctx) {
3864
+ 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;
3865
+ 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));
3866
+ (_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) {
3867
+ gradient.addColorStop(item.offset, item.color);
3868
+ });
3869
+ return gradient;
3870
+ };
3871
+ WatermarkCanvas.prototype.createPattern = function (ctx) {
3872
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3873
+ 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) || '');
3874
+ };
3875
+ WatermarkCanvas.prototype.setText = function (ctx, params) {
3876
+ var methodName = 'fillText';
3877
+ if (this.options.textType === 'stroke') {
3878
+ methodName = 'strokeText';
3879
+ }
3880
+ ctx[methodName] && ctx[methodName](params.text, params.x, params.y, params.maxWidth);
3881
+ };
3882
+ WatermarkCanvas.prototype.drawText = function (ctx, resolve) {
3883
+ this.setText(ctx, {
3884
+ text: this.options.content,
3885
+ x: 0,
3886
+ y: 0 - this.recommendOptions.textLine.yOffsetValue,
3887
+ maxWidth: this.options.textRowMaxWidth || this.options.width
3888
+ });
3889
+ resolve(ctx.canvas);
3890
+ };
3891
+ WatermarkCanvas.prototype.drawImage = function (ctx, resolve) {
3892
+ var _this = this;
3893
+ loadImage(this.options.image).then(function (image) {
3894
+ var _a = _this.getImageRect(image), imageWidth = _a.width, imageHeight = _a.height;
3895
+ var imagePosition = _this.getDrawImagePosition(imageWidth, imageHeight);
3896
+ ctx.drawImage(image, imagePosition.x, imagePosition.y, imageWidth, imageHeight);
3897
+ resolve(ctx.canvas);
3898
+ });
3899
+ };
3900
+ WatermarkCanvas.prototype.drawMultiLineText = function (ctx, resolve) {
3901
+ var _this = this;
3902
+ // image.width = this.options.width
3903
+ // image.height = this.options.height
3904
+ // const element = createCustomContentSvg(context, this.options)
3905
+ // image.src = convertSVGToImage(element)
3906
+ // image.onload = () => {
3907
+ // context.translate(this.options.width / 2, this.options.height / 2)
3908
+ // context.rotate(this.options.rotate)
3909
+ // context.drawImage(
3910
+ // image,
3911
+ // -this.options.width / 2,
3912
+ // -this.options.height / 2,
3913
+ // context.canvas.width,
3914
+ // context.canvas.height
3915
+ // )
3916
+ // resolve(canvas)
3917
+ // }
3918
+ var lines = this.recommendOptions.textLine.data;
3919
+ var yOffsetValue = this.recommendOptions.textLine.yOffsetValue;
3920
+ lines.forEach(function (text, index) {
3921
+ _this.setText(ctx, { text: text, x: 0, y: _this.options.lineHeight * index - yOffsetValue, maxWidth: _this.options.textRowMaxWidth || _this.options.width });
3922
+ });
3923
+ resolve(ctx.canvas);
3924
+ };
3925
+ WatermarkCanvas.prototype.drawRichText = function (ctx, resolve) {
3926
+ return __awaiter(this, void 0, void 0, function () {
3927
+ var obj;
3928
+ var _this = this;
3929
+ return __generator(this, function (_a) {
3930
+ switch (_a.label) {
3931
+ case 0: return [4 /*yield*/, createCustomContentSVG(ctx, this.options)];
3932
+ case 1:
3933
+ obj = _a.sent();
3934
+ loadImage(convertSVGToImage(obj.element), obj.width, obj.height).then(function (image) {
3935
+ var imagePosition = _this.getDrawImagePosition(image.width, image.height);
3936
+ ctx.drawImage(image, imagePosition.x, imagePosition.y, image.width, image.height);
3937
+ resolve(ctx.canvas);
3938
+ });
3939
+ return [2 /*return*/];
3940
+ }
3941
+ });
3942
+ });
3943
+ };
3944
+ WatermarkCanvas.prototype.getImageRect = function (image) {
3945
+ var rect = { width: this.options.imageWidth || 0, height: this.options.imageHeight || 0 };
3946
+ switch (true) {
3947
+ case rect.width !== 0 && rect.height === 0:
3948
+ rect.height = rect.width * image.height / image.width;
3949
+ break;
3950
+ case rect.width === 0 && rect.height !== 0:
3951
+ rect.width = rect.height * image.width / image.height;
3952
+ break;
3953
+ case rect.width === 0 && rect.height === 0:
3954
+ rect.width = image.width;
3955
+ rect.height = image.height;
3956
+ break;
3957
+ }
3958
+ return rect;
3959
+ };
3960
+ WatermarkCanvas.prototype.getDrawImagePosition = function (imageWidth, imageHeight) {
3961
+ var _a, _b;
3962
+ var result = {
3963
+ x: -imageWidth / 2,
3964
+ y: -imageHeight / 2
3965
+ };
3966
+ switch (this.options.translatePlacement) {
3967
+ case 'top':
3968
+ result.x = -imageWidth / 2;
3969
+ result.y = 0;
3970
+ break;
3971
+ case 'top-start':
3972
+ result.x = 0;
3973
+ result.y = 0;
3974
+ break;
3975
+ case 'top-end':
3976
+ result.x = -imageWidth;
3977
+ result.y = 0;
3978
+ break;
3979
+ case 'bottom':
3980
+ result.x = -imageWidth / 2;
3981
+ result.y = -imageHeight;
3982
+ break;
3983
+ case 'bottom-start':
3984
+ result.x = 0;
3985
+ result.y = -imageHeight;
3986
+ break;
3987
+ case 'bottom-end':
3988
+ result.x = -imageWidth;
3989
+ result.y = -imageHeight;
3990
+ break;
3991
+ case 'left':
3992
+ result.x = 0;
3993
+ result.y = -imageHeight / 2;
3994
+ break;
3995
+ case 'right':
3996
+ result.x = -imageWidth;
3997
+ result.y = -imageHeight / 2;
3998
+ break;
3999
+ }
4000
+ !isUndefined((_a = this.props) === null || _a === void 0 ? void 0 : _a.translateX) && (result.x = 0);
4001
+ !isUndefined((_b = this.props) === null || _b === void 0 ? void 0 : _b.translateY) && (result.y = 0);
4002
+ return result;
4003
+ };
4004
+ return WatermarkCanvas;
4005
+ }());
4006
+
4007
+ var GridLayout = /** @class */ (function () {
4008
+ function GridLayout(args, partialCanvas) {
4009
+ var _a, _b, _c, _d;
4010
+ this.options = args;
4011
+ this.partialWidth = this.options.width;
4012
+ this.partialHeight = this.options.height;
4013
+ this.rows = ((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.rows) || 1;
4014
+ this.cols = ((_b = this.options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.cols) || 1;
4015
+ this.matrix = ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.matrix) || generateMatrix(this.rows, this.cols, 1);
4016
+ this.gap = ((_d = this.options.gridLayoutOptions) === null || _d === void 0 ? void 0 : _d.gap) || [0, 0];
4017
+ this.partialCanvas = partialCanvas;
4018
+ }
4019
+ GridLayout.prototype.draw = function () {
4020
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4021
+ 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));
4022
+ var layoutContext = layoutCanvas.getContext('2d');
4023
+ if ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.backgroundImage) {
4024
+ 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);
4025
+ }
4026
+ for (var rowIndex = 0; rowIndex < this.rows; rowIndex++) {
4027
+ for (var colIndex = 0; colIndex < this.cols; colIndex++) {
4028
+ if (!((_h = (_g = this.matrix) === null || _g === void 0 ? void 0 : _g[rowIndex]) === null || _h === void 0 ? void 0 : _h[colIndex])) {
4029
+ continue;
4030
+ }
4031
+ 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);
4032
+ }
4033
+ }
4034
+ return layoutCanvas;
4035
+ };
4036
+ return GridLayout;
4037
+ }());
4038
+
4039
+ var renderLayout = function (options, partialCanvas) {
4040
+ switch (options.layout) {
4041
+ case 'grid':
4042
+ return new GridLayout(options, partialCanvas).draw();
4043
+ default:
4044
+ return partialCanvas;
4045
+ }
4046
+ };
4047
+ var generateBackgroundSize = function (options) {
4048
+ var _a, _b, _c;
4049
+ switch (options.layout) {
4050
+ case 'grid':
4051
+ {
4052
+ var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
4053
+ var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
4054
+ var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
4055
+ return [
4056
+ options.width * cols + gap[0] * cols,
4057
+ options.height * rows + gap[1] * rows
4058
+ ];
4059
+ }
4060
+ default:
4061
+ return [
4062
+ options.width,
4063
+ options.height
4064
+ ];
4065
+ }
4066
+ };
4067
+
4068
+ /**
4069
+ * Watermark class
4070
+ */
4071
+ var Watermark = /** @class */ (function () {
4072
+ /**
4073
+ * Watermark constructor
4074
+ * @param args - watermark args
4075
+ */
4076
+ function Watermark(args) {
4077
+ if (args === void 0) { args = {}; }
4078
+ this.parentElement = document.body;
4079
+ this.isCreating = false;
4080
+ this.props = args;
4081
+ this.options = __assign(__assign({}, initialOptions), args);
4082
+ this.changeParentElement(this.options.parent);
4083
+ this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
4084
+ bootstrap();
4085
+ }
4086
+ /**
4087
+ * Change watermark options
4088
+ * @param args
4089
+ * @param mode
4090
+ * @param redraw
4091
+ */
4092
+ Watermark.prototype.changeOptions = function () {
4093
+ return __awaiter(this, arguments, void 0, function (args, mode, redraw) {
4094
+ if (args === void 0) { args = {}; }
4095
+ if (mode === void 0) { mode = 'overwrite'; }
4096
+ if (redraw === void 0) { redraw = true; }
4097
+ return __generator(this, function (_a) {
4098
+ switch (_a.label) {
4099
+ case 0:
4100
+ this.initConfigData(args, mode);
4101
+ if (!redraw) return [3 /*break*/, 2];
4102
+ this.remove();
4103
+ return [4 /*yield*/, this.create()];
4104
+ case 1:
4105
+ _a.sent();
4106
+ _a.label = 2;
4107
+ case 2: return [2 /*return*/];
4108
+ }
4109
+ });
4110
+ });
4111
+ };
4112
+ /**
4113
+ * Creating a watermark.
4114
+ */
4115
+ Watermark.prototype.create = function () {
4116
+ return __awaiter(this, void 0, void 0, function () {
4117
+ var firstDraw, image, watermarkInnerDom, parentElementType, backgroundSize;
4118
+ var _a, _b, _c, _d, _e, _f, _g;
4119
+ return __generator(this, function (_h) {
4120
+ switch (_h.label) {
4121
+ case 0:
4122
+ if (this.isCreating) {
4123
+ return [2 /*return*/];
4124
+ }
4125
+ this.isCreating = true;
4126
+ if (!this.validateUnique()) {
4127
+ this.isCreating = false;
4128
+ return [2 /*return*/];
4129
+ }
4130
+ if (!this.validateContent()) {
4131
+ this.isCreating = false;
4132
+ return [2 /*return*/];
4133
+ }
4134
+ firstDraw = isUndefined(this.watermarkDom);
4135
+ return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
4136
+ case 1:
4137
+ _h.sent();
4138
+ this.layoutCanvas = renderLayout(this.options, (_b = this.watermarkCanvas) === null || _b === void 0 ? void 0 : _b.getCanvas());
4139
+ image = convertImage(this.layoutCanvas);
4140
+ (_c = this.watermarkCanvas) === null || _c === void 0 ? void 0 : _c.clear();
4141
+ this.watermarkDom = document.createElement('div');
4142
+ watermarkInnerDom = document.createElement('div');
4143
+ this.watermarkDom.__WATERMARK__ = 'watermark';
4144
+ this.watermarkDom.__WATERMARK__INSTANCE__ = this;
4145
+ parentElementType = this.checkParentElementType();
4146
+ 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 ");
4147
+ backgroundSize = generateBackgroundSize(this.options);
4148
+ 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(this.options.movable ? 'animation: 200s ease 0s infinite normal none running watermark !important;' : '', "\n ");
4149
+ this.watermarkDom.appendChild(watermarkInnerDom);
4150
+ this.parentElement.appendChild(this.watermarkDom);
4151
+ if (this.options.mutationObserve) {
4152
+ try {
4153
+ this.bindMutationObserve();
4154
+ }
4155
+ catch (e) {
4156
+ (_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
4157
+ }
4158
+ }
4159
+ firstDraw && ((_g = (_f = this.options).onSuccess) === null || _g === void 0 ? void 0 : _g.call(_f));
4160
+ this.isCreating = false;
4161
+ return [2 /*return*/];
4162
+ }
4163
+ });
4164
+ });
4165
+ };
4166
+ /**
4167
+ * Delete this watermark.
4168
+ */
4169
+ Watermark.prototype.destroy = function () {
4170
+ this.remove();
4171
+ this.watermarkDom = undefined;
4172
+ };
4173
+ Watermark.prototype.check = function () {
4174
+ return __awaiter(this, void 0, void 0, function () {
4175
+ return __generator(this, function (_a) {
4176
+ switch (_a.label) {
4177
+ case 0:
4178
+ if (!!this.parentElement.contains(this.watermarkDom)) return [3 /*break*/, 2];
4179
+ this.remove();
4180
+ return [4 /*yield*/, this.create()];
4181
+ case 1:
4182
+ _a.sent();
4183
+ _a.label = 2;
4184
+ case 2: return [2 /*return*/];
4185
+ }
4186
+ });
4187
+ });
4188
+ };
4189
+ Watermark.prototype.remove = function () {
4190
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4191
+ (_b = (_a = this.options).onBeforeDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
4192
+ (_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
4193
+ (_d = this.parentObserve) === null || _d === void 0 ? void 0 : _d.disconnect();
4194
+ this.unbindCheckWatermarkElementEvent();
4195
+ (_f = (_e = this.watermarkDom) === null || _e === void 0 ? void 0 : _e.parentNode) === null || _f === void 0 ? void 0 : _f.removeChild(this.watermarkDom);
4196
+ (_h = (_g = this.options).onDestroyed) === null || _h === void 0 ? void 0 : _h.call(_g);
4197
+ };
4198
+ Watermark.prototype.initConfigData = function (args, mode) {
4199
+ var _this = this;
4200
+ if (mode === void 0) { mode = 'overwrite'; }
4201
+ if (mode === 'append') {
4202
+ Object.keys(args).forEach(function (key) {
4203
+ _this.props && (_this.props[key] = args[key]);
4204
+ });
4205
+ }
4206
+ else {
4207
+ this.props = args;
4208
+ }
4209
+ this.options = __assign(__assign({}, initialOptions), this.props);
4210
+ this.changeParentElement(this.options.parent);
4211
+ this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
4212
+ };
4213
+ Watermark.prototype.changeParentElement = function (parent) {
4214
+ if (typeof parent === 'string') {
4215
+ var parentElement = document.querySelector(parent);
4216
+ parentElement && (this.parentElement = parentElement);
4217
+ }
4218
+ else {
4219
+ this.parentElement = parent;
4220
+ }
4221
+ if (!this.parentElement) {
4222
+ console.error('[WatermarkJsPlus]: please pass a valid parent element.');
4223
+ }
4224
+ };
4225
+ Watermark.prototype.validateUnique = function () {
4226
+ var result = true;
4227
+ Array.from(this.parentElement.childNodes).forEach(function (node) {
4228
+ if (!result) {
4229
+ return;
4230
+ }
4231
+ if (Object.hasOwnProperty.call(node, '__WATERMARK__')) {
4232
+ result = false;
4233
+ // throw new Error('duplicate watermark error')
4234
+ }
4235
+ });
4236
+ return result;
4237
+ };
4238
+ Watermark.prototype.validateContent = function () {
4239
+ switch (this.options.contentType) {
4240
+ case 'image':
4241
+ return Object.hasOwnProperty.call(this.options, 'image');
4242
+ case 'multi-line-text':
4243
+ case 'rich-text':
4244
+ case 'text':
4245
+ return this.options.content.length > 0;
4246
+ }
4247
+ return false;
4248
+ };
4249
+ Watermark.prototype.checkParentElementType = function () {
4250
+ if (['html', 'body'].includes(this.parentElement.tagName.toLocaleLowerCase())) {
4251
+ return 'root';
4252
+ }
4253
+ return 'custom';
4254
+ };
4255
+ Watermark.prototype.checkWatermarkElement = function () {
4256
+ return __awaiter(this, void 0, void 0, function () {
4257
+ return __generator(this, function (_a) {
4258
+ switch (_a.label) {
4259
+ case 0:
4260
+ if (!!this.parentElement.contains(this.watermarkDom)) return [3 /*break*/, 2];
4261
+ this.remove();
4262
+ return [4 /*yield*/, this.create()];
4263
+ case 1:
4264
+ _a.sent();
4265
+ _a.label = 2;
4266
+ case 2:
4267
+ this.bindCheckWatermarkElementEvent();
4268
+ return [2 /*return*/];
4269
+ }
4270
+ });
4271
+ });
4272
+ };
4273
+ Watermark.prototype.bindMutationObserve = function () {
4274
+ var _this = this;
4275
+ if (!this.watermarkDom) {
4276
+ return;
4277
+ }
4278
+ this.bindCheckWatermarkElementEvent();
4279
+ this.observer = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
4280
+ return __generator(this, function (_a) {
4281
+ switch (_a.label) {
4282
+ case 0:
4283
+ if (!(mutationsList.length > 0)) return [3 /*break*/, 2];
4284
+ this.remove();
4285
+ return [4 /*yield*/, this.create()];
4286
+ case 1:
4287
+ _a.sent();
4288
+ _a.label = 2;
4289
+ case 2: return [2 /*return*/];
4290
+ }
4291
+ });
4292
+ }); });
4293
+ this.observer.observe(this.watermarkDom, {
4294
+ attributes: true, // 属性的变动
4295
+ childList: true, // 子节点的变动(指新增,删除或者更改)
4296
+ subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
4297
+ characterData: true // 节点内容或节点文本的变动。
4298
+ });
4299
+ this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
4300
+ var _i, mutationsList_1, item;
4301
+ var _a;
4302
+ return __generator(this, function (_b) {
4303
+ switch (_b.label) {
4304
+ case 0:
4305
+ _i = 0, mutationsList_1 = mutationsList;
4306
+ _b.label = 1;
4307
+ case 1:
4308
+ if (!(_i < mutationsList_1.length)) return [3 /*break*/, 4];
4309
+ item = mutationsList_1[_i];
4310
+ if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
4311
+ ((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
4312
+ (item.type === 'childList' && item.target === this.parentElement && item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
4313
+ this.remove();
4314
+ return [4 /*yield*/, this.create()];
4315
+ case 2:
4316
+ _b.sent();
4317
+ _b.label = 3;
4318
+ case 3:
4319
+ _i++;
4320
+ return [3 /*break*/, 1];
4321
+ case 4: return [2 /*return*/];
4322
+ }
4323
+ });
4324
+ }); });
4325
+ this.parentObserve.observe(this.parentElement, {
4326
+ attributes: true, // 属性的变动
4327
+ childList: true, // 子节点的变动(指新增,删除或者更改)
4328
+ subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
4329
+ characterData: true // 节点内容或节点文本的变动。
4330
+ });
4331
+ };
4332
+ Watermark.prototype.bindCheckWatermarkElementEvent = function () {
4333
+ this.unbindCheckWatermarkElementEvent();
4334
+ this.checkWatermarkElementRequestID = requestAnimationFrame(this.checkWatermarkElement.bind(this));
4335
+ };
4336
+ Watermark.prototype.unbindCheckWatermarkElementEvent = function () {
4337
+ if (!isUndefined(this.checkWatermarkElementRequestID)) {
4338
+ cancelAnimationFrame(this.checkWatermarkElementRequestID);
4339
+ }
4340
+ };
4341
+ return Watermark;
4342
+ }());
4343
+
4344
+ /**
4345
+ * BlindWatermark class
4346
+ */
4347
+ var BlindWatermark = /** @class */ (function (_super) {
4348
+ __extends(BlindWatermark, _super);
4349
+ /**
4350
+ * BlindWatermark constructor
4351
+ * @param props - blind watermark options
4352
+ */
4353
+ function BlindWatermark(props) {
4354
+ if (props === void 0) { props = {}; }
4355
+ var defaultProps = {
4356
+ globalAlpha: 0.005,
4357
+ mode: 'blind'
4358
+ };
4359
+ return _super.call(this, __assign(__assign({}, props), defaultProps)) || this;
4360
+ }
4361
+ /**
4362
+ * Decode blind watermark.
4363
+ * @param props - decode options
4364
+ */
4365
+ BlindWatermark.decode = function (props) {
4366
+ 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;
4367
+ if (!url) {
4368
+ return;
4369
+ }
4370
+ if (mode === 'canvas') {
4371
+ var img_1 = new Image();
4372
+ img_1.src = url;
4373
+ img_1.addEventListener('load', function () {
4374
+ var width = img_1.width, height = img_1.height;
4375
+ var canvas = WatermarkCanvas.createCanvas(width, height);
4376
+ var ctx = canvas.getContext('2d');
4377
+ if (!ctx) {
4378
+ throw new Error('get context error');
4379
+ }
4380
+ ctx.drawImage(img_1, 0, 0, width, height);
4381
+ ctx.globalCompositeOperation = compositeOperation;
4382
+ ctx.fillStyle = fillColor;
4383
+ for (var i = 0; i < compositeTimes; i++) {
4384
+ ctx.fillRect(0, 0, width, height);
4385
+ }
4386
+ var resultImage = convertImage(canvas);
4387
+ if (isFunction(onSuccess)) {
4388
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(resultImage);
4389
+ }
4390
+ });
4391
+ }
4392
+ };
4393
+ return BlindWatermark;
4394
+ }(Watermark));
4395
+
4396
+ /**
4397
+ * ImageWatermark class
4398
+ */
4399
+ var ImageWatermark = /** @class */ (function () {
4400
+ /**
4401
+ * ImageWatermark constructor
4402
+ * @param args - image watermark args
4403
+ */
4404
+ function ImageWatermark(args) {
4405
+ if (args === void 0) { args = {}; }
4406
+ var _a;
4407
+ this.drew = false;
4408
+ this.props = args;
4409
+ this.options = __assign(__assign({}, initialOptions), args);
4410
+ this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
4411
+ this.originalSrc = (_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.src;
4412
+ this.backgroundImage = this.getBackgroundImage();
4413
+ }
4414
+ ImageWatermark.prototype.create = function () {
4415
+ return __awaiter(this, void 0, void 0, function () {
4416
+ var _a, _b, _c, _d, _e;
4417
+ return __generator(this, function (_f) {
4418
+ switch (_f.label) {
4419
+ case 0:
4420
+ if (this.drew) {
4421
+ return [2 /*return*/];
4422
+ }
4423
+ return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
4424
+ case 1:
4425
+ _f.sent();
4426
+ this.options.layout = 'grid';
4427
+ 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 });
4428
+ this.layoutCanvas = renderLayout(this.options, (_d = this.watermarkCanvas) === null || _d === void 0 ? void 0 : _d.getCanvas());
4429
+ this.options.dom.src = convertImage(this.layoutCanvas);
4430
+ (_e = this.watermarkCanvas) === null || _e === void 0 ? void 0 : _e.clear();
4431
+ this.drew = true;
4432
+ return [2 /*return*/];
4433
+ }
4434
+ });
4435
+ });
4436
+ };
4437
+ ImageWatermark.prototype.destroy = function () {
4438
+ this.options.dom.src = this.originalSrc;
4439
+ this.drew = false;
4440
+ };
4441
+ ImageWatermark.prototype.getBackgroundImage = function () {
4442
+ if (this.options.dom) {
4443
+ return this.options.dom;
4444
+ }
4445
+ };
4446
+ return ImageWatermark;
4447
+ }());
4448
+
4449
+ exports.BlindWatermark = BlindWatermark;
4450
+ exports.ImageWatermark = ImageWatermark;
4451
+ exports.Watermark = Watermark;
4452
+
4453
+ return exports;
4454
+
4455
+ })({});
4456
+ //# sourceMappingURL=index.iife.js.map