@dereekb/browser 12.7.0 → 13.0.1

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.
package/index.esm.js CHANGED
@@ -1,989 +1,153 @@
1
+ import { stringToBoolean } from '@dereekb/util';
1
2
  import { tapFirst, filterMaybe } from '@dereekb/rxjs';
2
3
  import { BehaviorSubject, shareReplay, switchMap, from, firstValueFrom } from 'rxjs';
3
4
 
4
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5
-
6
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
7
- var documentAll = typeof document == 'object' && document.all;
8
-
9
- // `IsCallable` abstract operation
10
- // https://tc39.es/ecma262/#sec-iscallable
11
- // eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing
12
- var isCallable$a = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) {
13
- return typeof argument == 'function' || argument === documentAll;
14
- } : function (argument) {
15
- return typeof argument == 'function';
16
- };
17
-
18
- var objectDefineProperty = {};
19
-
20
- var fails$6 = function (exec) {
21
- try {
22
- return !!exec();
23
- } catch (error) {
24
- return true;
25
- }
26
- };
27
-
28
- var fails$5 = fails$6;
29
-
30
- // Detect IE8's incomplete defineProperty implementation
31
- var descriptors = !fails$5(function () {
32
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
33
- return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7;
34
- });
35
-
36
- var check = function (it) {
37
- return it && it.Math === Math && it;
38
- };
39
-
40
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
41
- var global$9 =
42
- // eslint-disable-next-line es/no-global-this -- safe
43
- check(typeof globalThis == 'object' && globalThis) ||
44
- check(typeof window == 'object' && window) ||
45
- // eslint-disable-next-line no-restricted-globals -- safe
46
- check(typeof self == 'object' && self) ||
47
- check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
48
- check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
49
- // eslint-disable-next-line no-new-func -- fallback
50
- (function () { return this; })() || Function('return this')();
51
-
52
- var isCallable$9 = isCallable$a;
53
-
54
- var isObject$5 = function (it) {
55
- return typeof it == 'object' ? it !== null : isCallable$9(it);
56
- };
57
-
58
- var global$8 = global$9;
59
- var isObject$4 = isObject$5;
60
-
61
- var document$1 = global$8.document;
62
- // typeof document.createElement is 'object' in old IE
63
- var EXISTS$1 = isObject$4(document$1) && isObject$4(document$1.createElement);
64
-
65
- var documentCreateElement = function (it) {
66
- return EXISTS$1 ? document$1.createElement(it) : {};
67
- };
68
-
69
- var DESCRIPTORS$6 = descriptors;
70
- var fails$4 = fails$6;
71
- var createElement = documentCreateElement;
72
-
73
- // Thanks to IE8 for its funny defineProperty
74
- var ie8DomDefine = !DESCRIPTORS$6 && !fails$4(function () {
75
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
76
- return Object.defineProperty(createElement('div'), 'a', {
77
- get: function () { return 7; }
78
- }).a !== 7;
79
- });
80
-
81
- var DESCRIPTORS$5 = descriptors;
82
- var fails$3 = fails$6;
83
-
84
- // V8 ~ Chrome 36-
85
- // https://bugs.chromium.org/p/v8/issues/detail?id=3334
86
- var v8PrototypeDefineBug = DESCRIPTORS$5 && fails$3(function () {
87
- // eslint-disable-next-line es/no-object-defineproperty -- required for testing
88
- return Object.defineProperty(function () { /* empty */ }, 'prototype', {
89
- value: 42,
90
- writable: false
91
- }).prototype !== 42;
92
- });
93
-
94
- var isObject$3 = isObject$5;
95
-
96
- var $String$4 = String;
97
- var $TypeError$6 = TypeError;
98
-
99
- // `Assert: Type(argument) is Object`
100
- var anObject$1 = function (argument) {
101
- if (isObject$3(argument)) return argument;
102
- throw new $TypeError$6($String$4(argument) + ' is not an object');
103
- };
104
-
105
- var fails$2 = fails$6;
106
-
107
- var functionBindNative = !fails$2(function () {
108
- // eslint-disable-next-line es/no-function-prototype-bind -- safe
109
- var test = (function () { /* empty */ }).bind();
110
- // eslint-disable-next-line no-prototype-builtins -- safe
111
- return typeof test != 'function' || test.hasOwnProperty('prototype');
112
- });
113
-
114
- var NATIVE_BIND$1 = functionBindNative;
115
-
116
- var call$3 = Function.prototype.call;
117
-
118
- var functionCall = NATIVE_BIND$1 ? call$3.bind(call$3) : function () {
119
- return call$3.apply(call$3, arguments);
120
- };
121
-
122
- var global$7 = global$9;
123
- var isCallable$8 = isCallable$a;
124
-
125
- var aFunction = function (argument) {
126
- return isCallable$8(argument) ? argument : undefined;
127
- };
128
-
129
- var getBuiltIn$1 = function (namespace, method) {
130
- return arguments.length < 2 ? aFunction(global$7[namespace]) : global$7[namespace] && global$7[namespace][method];
131
- };
132
-
133
- var NATIVE_BIND = functionBindNative;
134
-
135
- var FunctionPrototype$1 = Function.prototype;
136
- var call$2 = FunctionPrototype$1.call;
137
- var uncurryThisWithBind = NATIVE_BIND && FunctionPrototype$1.bind.bind(call$2, call$2);
138
-
139
- var functionUncurryThis = NATIVE_BIND ? uncurryThisWithBind : function (fn) {
140
- return function () {
141
- return call$2.apply(fn, arguments);
142
- };
143
- };
144
-
145
- var uncurryThis$8 = functionUncurryThis;
146
-
147
- var objectIsPrototypeOf = uncurryThis$8({}.isPrototypeOf);
148
-
149
- var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
150
-
151
- var global$6 = global$9;
152
- var userAgent = engineUserAgent;
153
-
154
- var process = global$6.process;
155
- var Deno = global$6.Deno;
156
- var versions = process && process.versions || Deno && Deno.version;
157
- var v8 = versions && versions.v8;
158
- var match, version;
159
-
160
- if (v8) {
161
- match = v8.split('.');
162
- // in old Chrome, versions of V8 isn't V8 = Chrome / 10
163
- // but their correct versions are not interesting for us
164
- version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
165
- }
166
-
167
- // BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0`
168
- // so check `userAgent` even if `.v8` exists, but 0
169
- if (!version && userAgent) {
170
- match = userAgent.match(/Edge\/(\d+)/);
171
- if (!match || match[1] >= 74) {
172
- match = userAgent.match(/Chrome\/(\d+)/);
173
- if (match) version = +match[1];
174
- }
175
- }
176
-
177
- var engineV8Version = version;
178
-
179
- /* eslint-disable es/no-symbol -- required for testing */
180
- var V8_VERSION = engineV8Version;
181
- var fails$1 = fails$6;
182
- var global$5 = global$9;
183
-
184
- var $String$3 = global$5.String;
185
-
186
- // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
187
- var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$1(function () {
188
- var symbol = Symbol('symbol detection');
189
- // Chrome 38 Symbol has incorrect toString conversion
190
- // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
191
- // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will,
192
- // of course, fail.
193
- return !$String$3(symbol) || !(Object(symbol) instanceof Symbol) ||
194
- // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
195
- !Symbol.sham && V8_VERSION && V8_VERSION < 41;
196
- });
197
-
198
- /* eslint-disable es/no-symbol -- required for testing */
199
- var NATIVE_SYMBOL$1 = symbolConstructorDetection;
200
-
201
- var useSymbolAsUid = NATIVE_SYMBOL$1
202
- && !Symbol.sham
203
- && typeof Symbol.iterator == 'symbol';
204
-
205
- var getBuiltIn = getBuiltIn$1;
206
- var isCallable$7 = isCallable$a;
207
- var isPrototypeOf = objectIsPrototypeOf;
208
- var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
209
-
210
- var $Object$2 = Object;
211
-
212
- var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function (it) {
213
- return typeof it == 'symbol';
214
- } : function (it) {
215
- var $Symbol = getBuiltIn('Symbol');
216
- return isCallable$7($Symbol) && isPrototypeOf($Symbol.prototype, $Object$2(it));
217
- };
218
-
219
- var $String$2 = String;
220
-
221
- var tryToString$1 = function (argument) {
222
- try {
223
- return $String$2(argument);
224
- } catch (error) {
225
- return 'Object';
226
- }
227
- };
228
-
229
- var isCallable$6 = isCallable$a;
230
- var tryToString = tryToString$1;
231
-
232
- var $TypeError$5 = TypeError;
233
-
234
- // `Assert: IsCallable(argument) is true`
235
- var aCallable$1 = function (argument) {
236
- if (isCallable$6(argument)) return argument;
237
- throw new $TypeError$5(tryToString(argument) + ' is not a function');
238
- };
239
-
240
- // we can't use just `it == null` since of `document.all` special case
241
- // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec
242
- var isNullOrUndefined$2 = function (it) {
243
- return it === null || it === undefined;
244
- };
245
-
246
- var aCallable = aCallable$1;
247
- var isNullOrUndefined$1 = isNullOrUndefined$2;
248
-
249
- // `GetMethod` abstract operation
250
- // https://tc39.es/ecma262/#sec-getmethod
251
- var getMethod$1 = function (V, P) {
252
- var func = V[P];
253
- return isNullOrUndefined$1(func) ? undefined : aCallable(func);
254
- };
255
-
256
- var call$1 = functionCall;
257
- var isCallable$5 = isCallable$a;
258
- var isObject$2 = isObject$5;
259
-
260
- var $TypeError$4 = TypeError;
261
-
262
- // `OrdinaryToPrimitive` abstract operation
263
- // https://tc39.es/ecma262/#sec-ordinarytoprimitive
264
- var ordinaryToPrimitive$1 = function (input, pref) {
265
- var fn, val;
266
- if (pref === 'string' && isCallable$5(fn = input.toString) && !isObject$2(val = call$1(fn, input))) return val;
267
- if (isCallable$5(fn = input.valueOf) && !isObject$2(val = call$1(fn, input))) return val;
268
- if (pref !== 'string' && isCallable$5(fn = input.toString) && !isObject$2(val = call$1(fn, input))) return val;
269
- throw new $TypeError$4("Can't convert object to primitive value");
270
- };
271
-
272
- var sharedStore = {exports: {}};
273
-
274
- var global$4 = global$9;
275
-
276
- // eslint-disable-next-line es/no-object-defineproperty -- safe
277
- var defineProperty$2 = Object.defineProperty;
278
-
279
- var defineGlobalProperty$2 = function (key, value) {
280
- try {
281
- defineProperty$2(global$4, key, { value: value, configurable: true, writable: true });
282
- } catch (error) {
283
- global$4[key] = value;
284
- } return value;
285
- };
286
-
287
- var globalThis$1 = global$9;
288
- var defineGlobalProperty$1 = defineGlobalProperty$2;
289
-
290
- var SHARED = '__core-js_shared__';
291
- var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$1(SHARED, {});
292
-
293
- (store$3.versions || (store$3.versions = [])).push({
294
- version: '3.36.1',
295
- mode: 'global',
296
- copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
297
- license: 'https://github.com/zloirock/core-js/blob/v3.36.1/LICENSE',
298
- source: 'https://github.com/zloirock/core-js'
299
- });
300
-
301
- var sharedStoreExports = sharedStore.exports;
302
-
303
- var store$2 = sharedStoreExports;
304
-
305
- var shared$3 = function (key, value) {
306
- return store$2[key] || (store$2[key] = value || {});
307
- };
308
-
309
- var isNullOrUndefined = isNullOrUndefined$2;
310
-
311
- var $TypeError$3 = TypeError;
312
-
313
- // `RequireObjectCoercible` abstract operation
314
- // https://tc39.es/ecma262/#sec-requireobjectcoercible
315
- var requireObjectCoercible$1 = function (it) {
316
- if (isNullOrUndefined(it)) throw new $TypeError$3("Can't call method on " + it);
317
- return it;
318
- };
319
-
320
- var requireObjectCoercible = requireObjectCoercible$1;
321
-
322
- var $Object$1 = Object;
323
-
324
- // `ToObject` abstract operation
325
- // https://tc39.es/ecma262/#sec-toobject
326
- var toObject$1 = function (argument) {
327
- return $Object$1(requireObjectCoercible(argument));
328
- };
329
-
330
- var uncurryThis$7 = functionUncurryThis;
331
- var toObject = toObject$1;
332
-
333
- var hasOwnProperty = uncurryThis$7({}.hasOwnProperty);
334
-
335
- // `HasOwnProperty` abstract operation
336
- // https://tc39.es/ecma262/#sec-hasownproperty
337
- // eslint-disable-next-line es/no-object-hasown -- safe
338
- var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
339
- return hasOwnProperty(toObject(it), key);
340
- };
341
-
342
- var uncurryThis$6 = functionUncurryThis;
343
-
344
- var id = 0;
345
- var postfix = Math.random();
346
- var toString$4 = uncurryThis$6(1.0.toString);
347
-
348
- var uid$2 = function (key) {
349
- return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$4(++id + postfix, 36);
350
- };
351
-
352
- var global$3 = global$9;
353
- var shared$2 = shared$3;
354
- var hasOwn$3 = hasOwnProperty_1;
355
- var uid$1 = uid$2;
356
- var NATIVE_SYMBOL = symbolConstructorDetection;
357
- var USE_SYMBOL_AS_UID = useSymbolAsUid;
358
-
359
- var Symbol$1 = global$3.Symbol;
360
- var WellKnownSymbolsStore = shared$2('wks');
361
- var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
362
-
363
- var wellKnownSymbol$3 = function (name) {
364
- if (!hasOwn$3(WellKnownSymbolsStore, name)) {
365
- WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn$3(Symbol$1, name)
366
- ? Symbol$1[name]
367
- : createWellKnownSymbol('Symbol.' + name);
368
- } return WellKnownSymbolsStore[name];
369
- };
370
-
371
- var call = functionCall;
372
- var isObject$1 = isObject$5;
373
- var isSymbol$1 = isSymbol$2;
374
- var getMethod = getMethod$1;
375
- var ordinaryToPrimitive = ordinaryToPrimitive$1;
376
- var wellKnownSymbol$2 = wellKnownSymbol$3;
377
-
378
- var $TypeError$2 = TypeError;
379
- var TO_PRIMITIVE = wellKnownSymbol$2('toPrimitive');
380
-
381
- // `ToPrimitive` abstract operation
382
- // https://tc39.es/ecma262/#sec-toprimitive
383
- var toPrimitive$1 = function (input, pref) {
384
- if (!isObject$1(input) || isSymbol$1(input)) return input;
385
- var exoticToPrim = getMethod(input, TO_PRIMITIVE);
386
- var result;
387
- if (exoticToPrim) {
388
- if (pref === undefined) pref = 'default';
389
- result = call(exoticToPrim, input, pref);
390
- if (!isObject$1(result) || isSymbol$1(result)) return result;
391
- throw new $TypeError$2("Can't convert object to primitive value");
392
- }
393
- if (pref === undefined) pref = 'number';
394
- return ordinaryToPrimitive(input, pref);
395
- };
396
-
397
- var toPrimitive = toPrimitive$1;
398
- var isSymbol = isSymbol$2;
399
-
400
- // `ToPropertyKey` abstract operation
401
- // https://tc39.es/ecma262/#sec-topropertykey
402
- var toPropertyKey$1 = function (argument) {
403
- var key = toPrimitive(argument, 'string');
404
- return isSymbol(key) ? key : key + '';
405
- };
406
-
407
- var DESCRIPTORS$4 = descriptors;
408
- var IE8_DOM_DEFINE = ie8DomDefine;
409
- var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
410
- var anObject = anObject$1;
411
- var toPropertyKey = toPropertyKey$1;
412
-
413
- var $TypeError$1 = TypeError;
414
- // eslint-disable-next-line es/no-object-defineproperty -- safe
415
- var $defineProperty = Object.defineProperty;
416
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
417
- var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
418
- var ENUMERABLE = 'enumerable';
419
- var CONFIGURABLE$1 = 'configurable';
420
- var WRITABLE = 'writable';
421
-
422
- // `Object.defineProperty` method
423
- // https://tc39.es/ecma262/#sec-object.defineproperty
424
- objectDefineProperty.f = DESCRIPTORS$4 ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
425
- anObject(O);
426
- P = toPropertyKey(P);
427
- anObject(Attributes);
428
- if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
429
- var current = $getOwnPropertyDescriptor(O, P);
430
- if (current && current[WRITABLE]) {
431
- O[P] = Attributes.value;
432
- Attributes = {
433
- configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
434
- enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
435
- writable: false
436
- };
437
- }
438
- } return $defineProperty(O, P, Attributes);
439
- } : $defineProperty : function defineProperty(O, P, Attributes) {
440
- anObject(O);
441
- P = toPropertyKey(P);
442
- anObject(Attributes);
443
- if (IE8_DOM_DEFINE) try {
444
- return $defineProperty(O, P, Attributes);
445
- } catch (error) { /* empty */ }
446
- if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$1('Accessors not supported');
447
- if ('value' in Attributes) O[P] = Attributes.value;
448
- return O;
449
- };
450
-
451
- var makeBuiltIn$3 = {exports: {}};
452
-
453
- var DESCRIPTORS$3 = descriptors;
454
- var hasOwn$2 = hasOwnProperty_1;
455
-
456
- var FunctionPrototype = Function.prototype;
457
- // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
458
- var getDescriptor = DESCRIPTORS$3 && Object.getOwnPropertyDescriptor;
459
-
460
- var EXISTS = hasOwn$2(FunctionPrototype, 'name');
461
- // additional protection from minified / mangled / dropped function names
462
- var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
463
- var CONFIGURABLE = EXISTS && (!DESCRIPTORS$3 || (DESCRIPTORS$3 && getDescriptor(FunctionPrototype, 'name').configurable));
464
-
465
- var functionName = {
466
- EXISTS: EXISTS,
467
- PROPER: PROPER,
468
- CONFIGURABLE: CONFIGURABLE
469
- };
470
-
471
- var uncurryThis$5 = functionUncurryThis;
472
- var isCallable$4 = isCallable$a;
473
- var store$1 = sharedStoreExports;
474
-
475
- var functionToString = uncurryThis$5(Function.toString);
476
-
477
- // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
478
- if (!isCallable$4(store$1.inspectSource)) {
479
- store$1.inspectSource = function (it) {
480
- return functionToString(it);
481
- };
482
- }
483
-
484
- var inspectSource$1 = store$1.inspectSource;
485
-
486
- var global$2 = global$9;
487
- var isCallable$3 = isCallable$a;
488
-
489
- var WeakMap$1 = global$2.WeakMap;
490
-
491
- var weakMapBasicDetection = isCallable$3(WeakMap$1) && /native code/.test(String(WeakMap$1));
492
-
493
- var createPropertyDescriptor$1 = function (bitmap, value) {
494
- return {
495
- enumerable: !(bitmap & 1),
496
- configurable: !(bitmap & 2),
497
- writable: !(bitmap & 4),
498
- value: value
499
- };
500
- };
501
-
502
- var DESCRIPTORS$2 = descriptors;
503
- var definePropertyModule$1 = objectDefineProperty;
504
- var createPropertyDescriptor = createPropertyDescriptor$1;
505
-
506
- var createNonEnumerableProperty$1 = DESCRIPTORS$2 ? function (object, key, value) {
507
- return definePropertyModule$1.f(object, key, createPropertyDescriptor(1, value));
508
- } : function (object, key, value) {
509
- object[key] = value;
510
- return object;
511
- };
512
-
513
- var shared$1 = shared$3;
514
- var uid = uid$2;
515
-
516
- var keys = shared$1('keys');
517
-
518
- var sharedKey$1 = function (key) {
519
- return keys[key] || (keys[key] = uid(key));
520
- };
521
-
522
- var NATIVE_WEAK_MAP = weakMapBasicDetection;
523
- var global$1 = global$9;
524
- var isObject = isObject$5;
525
- var createNonEnumerableProperty = createNonEnumerableProperty$1;
526
- var hasOwn$1 = hasOwnProperty_1;
527
- var shared = sharedStoreExports;
528
- var sharedKey = sharedKey$1;
529
-
530
- var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
531
- var TypeError$1 = global$1.TypeError;
532
- var WeakMap = global$1.WeakMap;
533
- var set, get, has;
534
-
535
- var enforce = function (it) {
536
- return has(it) ? get(it) : set(it, {});
537
- };
538
-
539
- var getterFor = function (TYPE) {
540
- return function (it) {
541
- var state;
542
- if (!isObject(it) || (state = get(it)).type !== TYPE) {
543
- throw new TypeError$1('Incompatible receiver, ' + TYPE + ' required');
544
- } return state;
545
- };
546
- };
547
-
548
- if (NATIVE_WEAK_MAP || shared.state) {
549
- var store = shared.state || (shared.state = new WeakMap());
550
- /* eslint-disable no-self-assign -- prototype methods protection */
551
- store.get = store.get;
552
- store.has = store.has;
553
- store.set = store.set;
554
- /* eslint-enable no-self-assign -- prototype methods protection */
555
- set = function (it, metadata) {
556
- if (store.has(it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
557
- metadata.facade = it;
558
- store.set(it, metadata);
559
- return metadata;
560
- };
561
- get = function (it) {
562
- return store.get(it) || {};
563
- };
564
- has = function (it) {
565
- return store.has(it);
566
- };
567
- } else {
568
- var STATE = sharedKey('state');
569
- set = function (it, metadata) {
570
- if (hasOwn$1(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
571
- metadata.facade = it;
572
- createNonEnumerableProperty(it, STATE, metadata);
573
- return metadata;
574
- };
575
- get = function (it) {
576
- return hasOwn$1(it, STATE) ? it[STATE] : {};
577
- };
578
- has = function (it) {
579
- return hasOwn$1(it, STATE);
580
- };
581
- }
582
-
583
- var internalState = {
584
- set: set,
585
- get: get,
586
- has: has,
587
- enforce: enforce,
588
- getterFor: getterFor
589
- };
590
-
591
- var uncurryThis$4 = functionUncurryThis;
592
- var fails = fails$6;
593
- var isCallable$2 = isCallable$a;
594
- var hasOwn = hasOwnProperty_1;
595
- var DESCRIPTORS$1 = descriptors;
596
- var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
597
- var inspectSource = inspectSource$1;
598
- var InternalStateModule = internalState;
599
-
600
- var enforceInternalState = InternalStateModule.enforce;
601
- var getInternalState = InternalStateModule.get;
602
- var $String$1 = String;
603
- // eslint-disable-next-line es/no-object-defineproperty -- safe
604
- var defineProperty$1 = Object.defineProperty;
605
- var stringSlice$1 = uncurryThis$4(''.slice);
606
- var replace = uncurryThis$4(''.replace);
607
- var join = uncurryThis$4([].join);
608
-
609
- var CONFIGURABLE_LENGTH = DESCRIPTORS$1 && !fails(function () {
610
- return defineProperty$1(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
611
- });
612
-
613
- var TEMPLATE = String(String).split('String');
614
-
615
- var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) {
616
- if (stringSlice$1($String$1(name), 0, 7) === 'Symbol(') {
617
- name = '[' + replace($String$1(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']';
618
- }
619
- if (options && options.getter) name = 'get ' + name;
620
- if (options && options.setter) name = 'set ' + name;
621
- if (!hasOwn(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) {
622
- if (DESCRIPTORS$1) defineProperty$1(value, 'name', { value: name, configurable: true });
623
- else value.name = name;
624
- }
625
- if (CONFIGURABLE_LENGTH && options && hasOwn(options, 'arity') && value.length !== options.arity) {
626
- defineProperty$1(value, 'length', { value: options.arity });
627
- }
628
- try {
629
- if (options && hasOwn(options, 'constructor') && options.constructor) {
630
- if (DESCRIPTORS$1) defineProperty$1(value, 'prototype', { writable: false });
631
- // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
632
- } else if (value.prototype) value.prototype = undefined;
633
- } catch (error) { /* empty */ }
634
- var state = enforceInternalState(value);
635
- if (!hasOwn(state, 'source')) {
636
- state.source = join(TEMPLATE, typeof name == 'string' ? name : '');
637
- } return value;
638
- };
639
-
640
- // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
641
- // eslint-disable-next-line no-extend-native -- required
642
- Function.prototype.toString = makeBuiltIn$2(function toString() {
643
- return isCallable$2(this) && getInternalState(this).source || inspectSource(this);
644
- }, 'toString');
645
-
646
- var makeBuiltInExports = makeBuiltIn$3.exports;
647
-
648
- var isCallable$1 = isCallable$a;
649
- var definePropertyModule = objectDefineProperty;
650
- var makeBuiltIn$1 = makeBuiltInExports;
651
- var defineGlobalProperty = defineGlobalProperty$2;
652
-
653
- var defineBuiltIn$2 = function (O, key, value, options) {
654
- if (!options) options = {};
655
- var simple = options.enumerable;
656
- var name = options.name !== undefined ? options.name : key;
657
- if (isCallable$1(value)) makeBuiltIn$1(value, name, options);
658
- if (options.global) {
659
- if (simple) O[key] = value;
660
- else defineGlobalProperty(key, value);
661
- } else {
662
- try {
663
- if (!options.unsafe) delete O[key];
664
- else if (O[key]) simple = true;
665
- } catch (error) { /* empty */ }
666
- if (simple) O[key] = value;
667
- else definePropertyModule.f(O, key, {
668
- value: value,
669
- enumerable: false,
670
- configurable: !options.nonConfigurable,
671
- writable: !options.nonWritable
672
- });
673
- } return O;
674
- };
675
-
676
- var wellKnownSymbol$1 = wellKnownSymbol$3;
677
-
678
- var TO_STRING_TAG$1 = wellKnownSymbol$1('toStringTag');
679
- var test = {};
680
-
681
- test[TO_STRING_TAG$1] = 'z';
682
-
683
- var toStringTagSupport = String(test) === '[object z]';
684
-
685
- var uncurryThis$3 = functionUncurryThis;
686
-
687
- var toString$3 = uncurryThis$3({}.toString);
688
- var stringSlice = uncurryThis$3(''.slice);
689
-
690
- var classofRaw$1 = function (it) {
691
- return stringSlice(toString$3(it), 8, -1);
692
- };
693
-
694
- var TO_STRING_TAG_SUPPORT = toStringTagSupport;
695
- var isCallable = isCallable$a;
696
- var classofRaw = classofRaw$1;
697
- var wellKnownSymbol = wellKnownSymbol$3;
698
-
699
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
700
- var $Object = Object;
701
-
702
- // ES3 wrong here
703
- var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments';
704
-
705
- // fallback for IE11 Script Access Denied error
706
- var tryGet = function (it, key) {
707
- try {
708
- return it[key];
709
- } catch (error) { /* empty */ }
710
- };
711
-
712
- // getting tag from ES6+ `Object.prototype.toString`
713
- var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
714
- var O, tag, result;
715
- return it === undefined ? 'Undefined' : it === null ? 'Null'
716
- // @@toStringTag case
717
- : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
718
- // builtinTag case
719
- : CORRECT_ARGUMENTS ? classofRaw(O)
720
- // ES3 arguments fallback
721
- : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result;
722
- };
723
-
724
- var classof = classof$1;
725
-
726
- var $String = String;
727
-
728
- var toString$2 = function (argument) {
729
- if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
730
- return $String(argument);
731
- };
732
-
733
- var $TypeError = TypeError;
734
-
735
- var validateArgumentsLength$2 = function (passed, required) {
736
- if (passed < required) throw new $TypeError('Not enough arguments');
737
- return passed;
738
- };
739
-
740
- var defineBuiltIn$1 = defineBuiltIn$2;
741
- var uncurryThis$2 = functionUncurryThis;
742
- var toString$1 = toString$2;
743
- var validateArgumentsLength$1 = validateArgumentsLength$2;
744
-
745
- var $URLSearchParams$1 = URLSearchParams;
746
- var URLSearchParamsPrototype$2 = $URLSearchParams$1.prototype;
747
- var append = uncurryThis$2(URLSearchParamsPrototype$2.append);
748
- var $delete = uncurryThis$2(URLSearchParamsPrototype$2['delete']);
749
- var forEach$1 = uncurryThis$2(URLSearchParamsPrototype$2.forEach);
750
- var push = uncurryThis$2([].push);
751
- var params$1 = new $URLSearchParams$1('a=1&a=2&b=3');
752
-
753
- params$1['delete']('a', 1);
754
- // `undefined` case is a Chromium 117 bug
755
- // https://bugs.chromium.org/p/v8/issues/detail?id=14222
756
- params$1['delete']('b', undefined);
757
-
758
- if (params$1 + '' !== 'a=2') {
759
- defineBuiltIn$1(URLSearchParamsPrototype$2, 'delete', function (name /* , value */) {
760
- var length = arguments.length;
761
- var $value = length < 2 ? undefined : arguments[1];
762
- if (length && $value === undefined) return $delete(this, name);
763
- var entries = [];
764
- forEach$1(this, function (v, k) { // also validates `this`
765
- push(entries, { key: k, value: v });
766
- });
767
- validateArgumentsLength$1(length, 1);
768
- var key = toString$1(name);
769
- var value = toString$1($value);
770
- var index = 0;
771
- var dindex = 0;
772
- var found = false;
773
- var entriesLength = entries.length;
774
- var entry;
775
- while (index < entriesLength) {
776
- entry = entries[index++];
777
- if (found || entry.key === key) {
778
- found = true;
779
- $delete(this, entry.key);
780
- } else dindex++;
781
- }
782
- while (dindex < entriesLength) {
783
- entry = entries[dindex++];
784
- if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value);
785
- }
786
- }, { enumerable: true, unsafe: true });
787
- }
788
-
789
- var defineBuiltIn = defineBuiltIn$2;
790
- var uncurryThis$1 = functionUncurryThis;
791
- var toString = toString$2;
792
- var validateArgumentsLength = validateArgumentsLength$2;
793
-
794
- var $URLSearchParams = URLSearchParams;
795
- var URLSearchParamsPrototype$1 = $URLSearchParams.prototype;
796
- var getAll = uncurryThis$1(URLSearchParamsPrototype$1.getAll);
797
- var $has = uncurryThis$1(URLSearchParamsPrototype$1.has);
798
- var params = new $URLSearchParams('a=1');
799
-
800
- // `undefined` case is a Chromium 117 bug
801
- // https://bugs.chromium.org/p/v8/issues/detail?id=14222
802
- if (params.has('a', 2) || !params.has('a', undefined)) {
803
- defineBuiltIn(URLSearchParamsPrototype$1, 'has', function has(name /* , value */) {
804
- var length = arguments.length;
805
- var $value = length < 2 ? undefined : arguments[1];
806
- if (length && $value === undefined) return $has(this, name);
807
- var values = getAll(this, name); // also validates `this`
808
- validateArgumentsLength(length, 1);
809
- var value = toString($value);
810
- var index = 0;
811
- while (index < values.length) {
812
- if (values[index++] === value) return true;
813
- } return false;
814
- }, { enumerable: true, unsafe: true });
815
- }
816
-
817
- var makeBuiltIn = makeBuiltInExports;
818
- var defineProperty = objectDefineProperty;
819
-
820
- var defineBuiltInAccessor$1 = function (target, name, descriptor) {
821
- if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true });
822
- if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true });
823
- return defineProperty.f(target, name, descriptor);
824
- };
825
-
826
- var DESCRIPTORS = descriptors;
827
- var uncurryThis = functionUncurryThis;
828
- var defineBuiltInAccessor = defineBuiltInAccessor$1;
829
-
830
- var URLSearchParamsPrototype = URLSearchParams.prototype;
831
- var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
832
-
833
- // `URLSearchParams.prototype.size` getter
834
- // https://github.com/whatwg/url/pull/734
835
- if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
836
- defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
837
- get: function size() {
838
- var count = 0;
839
- forEach(this, function () { count++; });
840
- return count;
841
- },
842
- configurable: true,
843
- enumerable: true
844
- });
845
- }
846
-
847
5
  /**
848
6
  * Creatse a new BrowserObjectURLRef.
849
7
  */
850
8
  function browserObjectUrlRef() {
851
- let browserUrl;
852
- /**
853
- * Revokes the existing browser object URL, if one exists.
854
- */
855
- function destroy() {
856
- if (browserUrl) {
857
- URL.revokeObjectURL(browserUrl);
9
+ let browserUrl;
10
+ /**
11
+ * Revokes the existing browser object URL, if one exists.
12
+ */
13
+ function destroy() {
14
+ if (browserUrl) {
15
+ URL.revokeObjectURL(browserUrl);
16
+ }
858
17
  }
859
- }
860
- function createBrowserUrl(input) {
861
- destroy();
862
- if (input) {
863
- browserUrl = URL.createObjectURL(input);
18
+ function createBrowserUrl(input) {
19
+ destroy();
20
+ if (input) {
21
+ browserUrl = URL.createObjectURL(input);
22
+ }
23
+ return browserUrl;
864
24
  }
865
- return browserUrl;
866
- }
867
- return {
868
- destroy,
869
- getBrowserUrl: () => browserUrl,
870
- createBrowserUrl: createBrowserUrl
871
- };
25
+ return {
26
+ destroy,
27
+ getBrowserUrl: () => browserUrl,
28
+ createBrowserUrl: createBrowserUrl
29
+ };
872
30
  }
873
31
 
32
+ /*eslint @typescript-eslint/no-explicit-any:"off"*/
33
+ // any is used with intent here. Proper typing with Window requires using the dynamic strings _windowKey and _callbackKey.
874
34
  /**
875
35
  * Used for loading services in the browser that are imported from other scripts, such as Facebook, Segment, Stripe, etc.
876
36
  */
877
37
  class AbstractAsyncWindowLoadedService {
878
- /**
879
- * @param windowKey
880
- * @param callbackKey
881
- */
882
- constructor(windowKey, callbackKey, serviceName, preload) {
883
- this._loading = new BehaviorSubject(undefined);
38
+ _loading = new BehaviorSubject(undefined);
884
39
  /**
885
40
  * Key that is attached to the window for the object that is the service when finished loading.
886
41
  */
887
- this._windowKey = void 0;
42
+ _windowKey;
888
43
  /**
889
44
  * Optional key attached to window that is a function that is executed when the setup is complete.
890
45
  */
891
- this._callbackKey = void 0;
46
+ _callbackKey;
892
47
  /**
893
48
  * Service name used in logging. Defaults to the windowKey.
894
49
  */
895
- this._serviceName = void 0;
896
- this.loading$ = this._loading.pipe(tapFirst(() => this.loadService()), filterMaybe(), shareReplay(1));
897
- this.service$ = this.loading$.pipe(switchMap(x => from(x)), shareReplay(1));
898
- this._windowKey = windowKey;
899
- this._callbackKey = callbackKey;
900
- this._serviceName = serviceName ?? windowKey;
901
- if (preload) {
902
- // Begin loading the service immediately.
903
- setTimeout(() => this.loadService().catch());
50
+ _serviceName;
51
+ loading$ = this._loading.pipe(tapFirst(() => this.loadService()), filterMaybe(), shareReplay(1));
52
+ service$ = this.loading$.pipe(switchMap((x) => from(x)), shareReplay(1));
53
+ /**
54
+ * @param windowKey
55
+ * @param callbackKey
56
+ */
57
+ constructor(windowKey, callbackKey, serviceName, preload) {
58
+ this._windowKey = windowKey;
59
+ this._callbackKey = callbackKey;
60
+ this._serviceName = serviceName ?? windowKey;
61
+ if (stringToBoolean(preload)) {
62
+ // Begin loading the service immediately.
63
+ setTimeout(() => this.loadService().catch());
64
+ }
65
+ }
66
+ destroy() {
67
+ this._loading.complete();
68
+ }
69
+ getService() {
70
+ return firstValueFrom(this.service$);
71
+ }
72
+ // MARK: Loading
73
+ loadService() {
74
+ if (!this._loading.value) {
75
+ const loadingPromise = new Promise((resolve, reject) => {
76
+ let loadTry = 0;
77
+ const rejectWithError = () => {
78
+ reject(new Error(`Service "${this._serviceName}" failed loading with windowKey "${this._windowKey}"`));
79
+ };
80
+ const tryLoad = () => {
81
+ const windowRef = window;
82
+ // Loaded before the promise.
83
+ if (windowRef[this._windowKey]) {
84
+ // Not yet finished loading async. Intercept the function.
85
+ // console.log('Window key.');
86
+ return resolve(this.completeLoadingService());
87
+ }
88
+ else if (this._callbackKey && windowRef[this._callbackKey]) {
89
+ // console.log('Callback key.');
90
+ windowRef[this._callbackKey] = () => resolve(this.completeLoadingService());
91
+ }
92
+ else if (loadTry < 10) {
93
+ loadTry += 1;
94
+ // console.log('Try reload...');
95
+ setTimeout(() => tryLoad(), 1000);
96
+ }
97
+ else {
98
+ const retry = this._onLoadServiceFailure();
99
+ if (retry) {
100
+ retry.then((x) => resolve(x)).catch(() => rejectWithError());
101
+ }
102
+ else {
103
+ rejectWithError();
104
+ }
105
+ }
106
+ };
107
+ tryLoad();
108
+ });
109
+ this._loading.next(loadingPromise);
110
+ }
111
+ return this._loading.value;
112
+ }
113
+ _onLoadServiceFailure() {
114
+ // override in parent if needed.
115
+ }
116
+ async completeLoadingService() {
117
+ await this._prepareCompleteLoadingService();
118
+ const service = window[this._windowKey];
119
+ if (!service) {
120
+ throw new Error(`Service "${this._serviceName}" could not complete loading.`);
121
+ }
122
+ // Init the API
123
+ const initializedService = await this._initService(service);
124
+ return initializedService ?? service;
904
125
  }
905
- }
906
- destroy() {
907
- this._loading.complete();
908
- }
909
- getService() {
910
- return firstValueFrom(this.service$);
911
- }
912
- // MARK: Loading
913
- loadService() {
914
- if (!this._loading.value) {
915
- const loadingPromise = new Promise((resolve, reject) => {
916
- let loadTry = 0;
917
- const rejectWithError = () => {
918
- reject(new Error(`Service "${this._serviceName}" failed loading with windowKey "${this._windowKey}"`));
919
- };
920
- const tryLoad = () => {
921
- const windowRef = window;
922
- // Loaded before the promise.
923
- if (windowRef[this._windowKey]) {
924
- // Not yet finished loading async. Intercept the function.
925
- // console.log('Window key.');
926
- return resolve(this.completeLoadingService());
927
- } else if (this._callbackKey && windowRef[this._callbackKey]) {
928
- // console.log('Callback key.');
929
- windowRef[this._callbackKey] = () => resolve(this.completeLoadingService());
930
- } else if (loadTry < 10) {
931
- loadTry += 1;
932
- // console.log('Try reload...');
933
- setTimeout(() => tryLoad(), 1000);
934
- } else {
935
- const retry = this._onLoadServiceFailure();
936
- if (retry) {
937
- retry.then(x => resolve(x)).catch(() => rejectWithError());
938
- } else {
939
- rejectWithError();
940
- }
941
- }
942
- };
943
- tryLoad();
944
- });
945
- this._loading.next(loadingPromise);
126
+ _prepareCompleteLoadingService() {
127
+ return Promise.resolve();
946
128
  }
947
- return this._loading.value;
948
- }
949
- _onLoadServiceFailure() {
950
- // override in parent if needed.
951
- }
952
- async completeLoadingService() {
953
- await this._prepareCompleteLoadingService();
954
- const service = window[this._windowKey];
955
- if (!service) {
956
- throw new Error(`Service "${this._serviceName}" could not complete loading.`);
129
+ _initService(service) {
130
+ return Promise.resolve(service);
957
131
  }
958
- // Init the API
959
- const initializedService = await this._initService(service);
960
- return initializedService ?? service;
961
- }
962
- _prepareCompleteLoadingService() {
963
- return Promise.resolve();
964
- }
965
- _initService(service) {
966
- return Promise.resolve(service);
967
- }
968
132
  }
969
133
 
970
134
  // https://dev.to/maciejtrzcinski/100vh-problem-with-ios-safari-3ge9
971
135
  const DEFAULT_VH100_VARIABLE_NAME = 'vh100';
972
136
  function refreshVh100Function(cssVariableName = DEFAULT_VH100_VARIABLE_NAME) {
973
- const cssProperty = `--${cssVariableName}`;
974
- return () => {
975
- const doc = document.documentElement;
976
- doc.style.setProperty(cssProperty, `${window.innerHeight}px`);
977
- };
137
+ const cssProperty = `--${cssVariableName}`;
138
+ return () => {
139
+ const doc = document.documentElement;
140
+ doc.style.setProperty(cssProperty, `${window.innerHeight}px`);
141
+ };
978
142
  }
979
143
  /**
980
144
  * Adds window event listeners to populate the css variable `vh100`, or another input variable name, with the current window height.
981
145
  */
982
146
  function watchWindowAndUpdateVh100StyleProperty(cssVariableName) {
983
- const refreshPropertyValue = refreshVh100Function(cssVariableName);
984
- window.addEventListener('resize', refreshPropertyValue);
985
- window.addEventListener('orientationchange', refreshPropertyValue);
986
- refreshPropertyValue();
147
+ const refreshPropertyValue = refreshVh100Function(cssVariableName);
148
+ window.addEventListener('resize', refreshPropertyValue);
149
+ window.addEventListener('orientationchange', refreshPropertyValue);
150
+ refreshPropertyValue();
987
151
  }
988
152
 
989
153
  // MARK: Window Location Utiltiies
@@ -991,17 +155,17 @@ function watchWindowAndUpdateVh100StyleProperty(cssVariableName) {
991
155
  * Whether or not the current host is localhost. Useful for determining local dev environments.
992
156
  */
993
157
  function isLocalhost() {
994
- return window.location.hostname === 'localhost';
158
+ return window.location.hostname === 'localhost';
995
159
  }
996
160
  function makeWindowPath(path) {
997
- return `${getBaseWindowUrl()}${path}`;
161
+ return `${getBaseWindowUrl()}${path}`;
998
162
  }
999
163
  function getBaseWindowUrl() {
1000
- const port = window.location.port ? ':' + window.location.port : '';
1001
- return `${window.location.protocol}//${window.location.hostname}${port}`;
164
+ const port = window.location.port ? ':' + window.location.port : '';
165
+ return `${window.location.protocol}//${window.location.hostname}${port}`;
1002
166
  }
1003
167
  function getWindowPathNameWithQuery() {
1004
- return window.location.pathname + window.location.search;
168
+ return window.location.pathname + window.location.search;
1005
169
  }
1006
170
 
1007
171
  export { AbstractAsyncWindowLoadedService, DEFAULT_VH100_VARIABLE_NAME, browserObjectUrlRef, getBaseWindowUrl, getWindowPathNameWithQuery, isLocalhost, makeWindowPath, refreshVh100Function, watchWindowAndUpdateVh100StyleProperty };