zar 0.0.21 → 0.0.24

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/dist/zar.es.js ADDED
@@ -0,0 +1,4301 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e2) {
7
+ reject(e2);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e2) {
14
+ reject(e2);
15
+ }
16
+ };
17
+ var step = (x2) => x2.done ? resolve(x2.value) : Promise.resolve(x2.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ function dotProp(t2, e2, l2, n2, r2) {
22
+ for (e2 = e2.split ? e2.split(".") : e2, n2 = 0; n2 < e2.length; n2++)
23
+ t2 = t2 ? t2[e2[n2]] : r2;
24
+ return t2 === r2 ? l2 : t2;
25
+ }
26
+ var F$4 = typeof process != "undefined" ? process : {};
27
+ F$4.env && F$4.env.NODE_ENV || "";
28
+ var $$5 = typeof window != "undefined";
29
+ F$4.versions != null && F$4.versions.node != null;
30
+ typeof Deno != "undefined" && Deno.core !== void 0;
31
+ $$5 && window.name === "nodejs" || typeof navigator != "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
32
+ function M$5(n2, t2) {
33
+ return t2.charAt(0)[n2]() + t2.slice(1);
34
+ }
35
+ var U$4 = M$5.bind(null, "toUpperCase"), H$5 = M$5.bind(null, "toLowerCase");
36
+ function J$4(n2) {
37
+ return Y$4(n2) ? U$4("null") : typeof n2 == "object" ? yn$4(n2) : Object.prototype.toString.call(n2).slice(8, -1);
38
+ }
39
+ function R$4(n2, t2) {
40
+ t2 === void 0 && (t2 = true);
41
+ var e2 = J$4(n2);
42
+ return t2 ? H$5(e2) : e2;
43
+ }
44
+ function V$4(n2, t2) {
45
+ return typeof t2 === n2;
46
+ }
47
+ var W$4 = V$4.bind(null, "function"), q$4 = V$4.bind(null, "string");
48
+ V$4.bind(null, "undefined");
49
+ V$4.bind(null, "boolean");
50
+ V$4.bind(null, "symbol");
51
+ function Y$4(n2) {
52
+ return n2 === null;
53
+ }
54
+ function nn$4(n2) {
55
+ return R$4(n2) === "number" && !isNaN(n2);
56
+ }
57
+ function yn$4(n2) {
58
+ return W$4(n2.constructor) ? n2.constructor.name : null;
59
+ }
60
+ function hn$4(n2) {
61
+ return n2 instanceof Error || q$4(n2.message) && n2.constructor && nn$4(n2.constructor.stackTraceLimit);
62
+ }
63
+ function On$4(n2, t2) {
64
+ if (typeof t2 != "object" || Y$4(t2))
65
+ return false;
66
+ if (t2 instanceof n2)
67
+ return true;
68
+ var e2 = R$4(new n2(""));
69
+ if (hn$4(t2))
70
+ for (; t2; ) {
71
+ if (R$4(t2) === e2)
72
+ return true;
73
+ t2 = Object.getPrototypeOf(t2);
74
+ }
75
+ return false;
76
+ }
77
+ On$4.bind(null, TypeError);
78
+ On$4.bind(null, SyntaxError);
79
+ function $n$4(n2, t2) {
80
+ var e2 = n2 instanceof Element || n2 instanceof HTMLDocument;
81
+ return e2 && t2 ? Tn$4(n2, t2) : e2;
82
+ }
83
+ function Tn$4(n2, t2) {
84
+ return t2 === void 0 && (t2 = ""), n2 && n2.nodeName === t2.toUpperCase();
85
+ }
86
+ function _n$4(n2) {
87
+ var t2 = [].slice.call(arguments, 1);
88
+ return function() {
89
+ return n2.apply(void 0, [].slice.call(arguments).concat(t2));
90
+ };
91
+ }
92
+ _n$4($n$4, "form");
93
+ _n$4($n$4, "button");
94
+ _n$4($n$4, "input");
95
+ _n$4($n$4, "select");
96
+ function n$6(e2) {
97
+ try {
98
+ return decodeURIComponent(e2.replace(/\+/g, " "));
99
+ } catch (e3) {
100
+ return null;
101
+ }
102
+ }
103
+ function o$9() {
104
+ if ($$5) {
105
+ var r2 = navigator, t2 = r2.languages;
106
+ return r2.userLanguage || (t2 && t2.length ? t2[0] : r2.language);
107
+ }
108
+ }
109
+ function a$5() {
110
+ try {
111
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
112
+ } catch (e2) {
113
+ }
114
+ }
115
+ function s(r2) {
116
+ return function(e2) {
117
+ for (var r3, t2 = /* @__PURE__ */ Object.create(null), o2 = /([^&=]+)=?([^&]*)/g; r3 = o2.exec(e2); ) {
118
+ var a2 = n$6(r3[1]), i = n$6(r3[2]);
119
+ a2.substring(a2.length - 2) === "[]" ? (t2[a2 = a2.substring(0, a2.length - 2)] || (t2[a2] = [])).push(i) : t2[a2] = i === "" || i;
120
+ }
121
+ for (var u2 in t2) {
122
+ var c2 = u2.split("[");
123
+ c2.length > 1 && (m(t2, c2.map(function(e3) {
124
+ return e3.replace(/[?[\]\\ ]/g, "");
125
+ }), t2[u2]), delete t2[u2]);
126
+ }
127
+ return t2;
128
+ }(function(r3) {
129
+ if (r3) {
130
+ var t2 = r3.match(/\?(.*)/);
131
+ return t2 && t2[1] ? t2[1].split("#")[0] : "";
132
+ }
133
+ return $$5 && window.location.search.substring(1);
134
+ }(r2));
135
+ }
136
+ function m(e2, r2, t2) {
137
+ for (var n2 = r2.length - 1, o2 = 0; o2 < n2; ++o2) {
138
+ var a2 = r2[o2];
139
+ if (a2 === "__proto__" || a2 === "constructor")
140
+ break;
141
+ a2 in e2 || (e2[a2] = {}), e2 = e2[a2];
142
+ }
143
+ e2[r2[n2]] = t2;
144
+ }
145
+ function y$1() {
146
+ for (var e2 = "", r2 = 0, t2 = 4294967295 * Math.random() | 0; r2++ < 36; ) {
147
+ var n2 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[r2 - 1], o2 = 15 & t2;
148
+ e2 += n2 == "-" || n2 == "4" ? n2 : (n2 == "x" ? o2 : 3 & o2 | 8).toString(16), t2 = r2 % 8 == 0 ? 4294967295 * Math.random() | 0 : t2 >> 4;
149
+ }
150
+ return e2;
151
+ }
152
+ var o$8 = "object", j$3 = "__", F$3 = typeof process != "undefined" ? process : {};
153
+ F$3.env && F$3.env.NODE_ENV || "";
154
+ var $$4 = typeof window != "undefined";
155
+ F$3.versions != null && F$3.versions.node != null;
156
+ typeof Deno != "undefined" && Deno.core !== void 0;
157
+ $$4 && window.name === "nodejs" || typeof navigator != "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
158
+ function M$4(n2, t2) {
159
+ return t2.charAt(0)[n2]() + t2.slice(1);
160
+ }
161
+ var U$3 = M$4.bind(null, "toUpperCase"), H$4 = M$4.bind(null, "toLowerCase");
162
+ function J$3(n2) {
163
+ return Y$3(n2) ? U$3("null") : typeof n2 == "object" ? yn$3(n2) : Object.prototype.toString.call(n2).slice(8, -1);
164
+ }
165
+ function R$3(n2, t2) {
166
+ t2 === void 0 && (t2 = true);
167
+ var e2 = J$3(n2);
168
+ return t2 ? H$4(e2) : e2;
169
+ }
170
+ function V$3(n2, t2) {
171
+ return typeof t2 === n2;
172
+ }
173
+ var W$3 = V$3.bind(null, "function"), q$3 = V$3.bind(null, "string");
174
+ V$3.bind(null, "undefined");
175
+ V$3.bind(null, "boolean");
176
+ V$3.bind(null, "symbol");
177
+ function Y$3(n2) {
178
+ return n2 === null;
179
+ }
180
+ function nn$3(n2) {
181
+ return R$3(n2) === "number" && !isNaN(n2);
182
+ }
183
+ function yn$3(n2) {
184
+ return W$3(n2.constructor) ? n2.constructor.name : null;
185
+ }
186
+ function hn$3(n2) {
187
+ return n2 instanceof Error || q$3(n2.message) && n2.constructor && nn$3(n2.constructor.stackTraceLimit);
188
+ }
189
+ function On$3(n2, t2) {
190
+ if (typeof t2 != "object" || Y$3(t2))
191
+ return false;
192
+ if (t2 instanceof n2)
193
+ return true;
194
+ var e2 = R$3(new n2(""));
195
+ if (hn$3(t2))
196
+ for (; t2; ) {
197
+ if (R$3(t2) === e2)
198
+ return true;
199
+ t2 = Object.getPrototypeOf(t2);
200
+ }
201
+ return false;
202
+ }
203
+ On$3.bind(null, TypeError);
204
+ On$3.bind(null, SyntaxError);
205
+ function $n$3(n2, t2) {
206
+ var e2 = n2 instanceof Element || n2 instanceof HTMLDocument;
207
+ return e2 && t2 ? Tn$3(n2, t2) : e2;
208
+ }
209
+ function Tn$3(n2, t2) {
210
+ return t2 === void 0 && (t2 = ""), n2 && n2.nodeName === t2.toUpperCase();
211
+ }
212
+ function _n$3(n2) {
213
+ var t2 = [].slice.call(arguments, 1);
214
+ return function() {
215
+ return n2.apply(void 0, [].slice.call(arguments).concat(t2));
216
+ };
217
+ }
218
+ _n$3($n$3, "form");
219
+ _n$3($n$3, "button");
220
+ _n$3($n$3, "input");
221
+ _n$3($n$3, "select");
222
+ var o$7 = j$3 + "global" + j$3, n$5 = typeof self === o$8 && self.self === self && self || typeof global === o$8 && global.global === global && global || void 0;
223
+ function a$4(t2) {
224
+ return n$5[o$7][t2];
225
+ }
226
+ function f$5(t2, e2) {
227
+ return n$5[o$7][t2] = e2;
228
+ }
229
+ function i$5(t2) {
230
+ delete n$5[o$7][t2];
231
+ }
232
+ n$5[o$7] || (n$5[o$7] = {});
233
+ var n$4, f$4 = "any", l$2 = "*", p = "__", h$1 = typeof process != "undefined" ? process : {};
234
+ ((n$4 = h$1.env) == null ? void 0 : n$4.NODE_ENV) || "";
235
+ var z = typeof window != "undefined";
236
+ h$1.versions != null && h$1.versions.node != null;
237
+ typeof Deno != "undefined" && Deno.core !== void 0;
238
+ z && window.name === "nodejs" || typeof navigator != "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
239
+ function C$1(n2, e2) {
240
+ return typeof e2 === n2;
241
+ }
242
+ var _ = C$1.bind(null, "function"), L$1 = C$1.bind(null, "string"), $$3 = C$1.bind(null, "undefined"), x$1 = C$1.bind(null, "boolean");
243
+ function G(n2) {
244
+ return Object.prototype.toString.call(n2) === "[object Array]";
245
+ }
246
+ function H$3(n2) {
247
+ return n2 && (typeof n2 == "object" || n2 !== null);
248
+ }
249
+ function M$3(n2) {
250
+ if (!H$3(n2))
251
+ return false;
252
+ for (var e2 = n2; Object.getPrototypeOf(e2) !== null; )
253
+ e2 = Object.getPrototypeOf(e2);
254
+ return Object.getPrototypeOf(n2) === e2;
255
+ }
256
+ function _arrayLikeToArray(arr, len) {
257
+ if (len == null || len > arr.length)
258
+ len = arr.length;
259
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
260
+ arr2[i] = arr[i];
261
+ }
262
+ return arr2;
263
+ }
264
+ function _arrayWithoutHoles(arr) {
265
+ if (Array.isArray(arr))
266
+ return _arrayLikeToArray(arr);
267
+ }
268
+ function _iterableToArray(iter) {
269
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
270
+ return Array.from(iter);
271
+ }
272
+ function _unsupportedIterableToArray(o2, minLen) {
273
+ if (!o2)
274
+ return;
275
+ if (typeof o2 === "string")
276
+ return _arrayLikeToArray(o2, minLen);
277
+ var n2 = Object.prototype.toString.call(o2).slice(8, -1);
278
+ if (n2 === "Object" && o2.constructor)
279
+ n2 = o2.constructor.name;
280
+ if (n2 === "Map" || n2 === "Set")
281
+ return Array.from(o2);
282
+ if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2))
283
+ return _arrayLikeToArray(o2, minLen);
284
+ }
285
+ function _nonIterableSpread() {
286
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
287
+ }
288
+ function _toConsumableArray(arr) {
289
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
290
+ }
291
+ function _typeof(obj) {
292
+ "@babel/helpers - typeof";
293
+ return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
294
+ return typeof obj2;
295
+ } : function(obj2) {
296
+ return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
297
+ }, _typeof(obj);
298
+ }
299
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
300
+ try {
301
+ var info = gen[key](arg);
302
+ var value = info.value;
303
+ } catch (error) {
304
+ reject(error);
305
+ return;
306
+ }
307
+ if (info.done) {
308
+ resolve(value);
309
+ } else {
310
+ Promise.resolve(value).then(_next, _throw);
311
+ }
312
+ }
313
+ function _asyncToGenerator(fn) {
314
+ return function() {
315
+ var self2 = this, args = arguments;
316
+ return new Promise(function(resolve, reject) {
317
+ var gen = fn.apply(self2, args);
318
+ function _next(value) {
319
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
320
+ }
321
+ function _throw(err) {
322
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
323
+ }
324
+ _next(void 0);
325
+ });
326
+ };
327
+ }
328
+ function _defineProperty$2(obj, key, value) {
329
+ if (key in obj) {
330
+ Object.defineProperty(obj, key, {
331
+ value,
332
+ enumerable: true,
333
+ configurable: true,
334
+ writable: true
335
+ });
336
+ } else {
337
+ obj[key] = value;
338
+ }
339
+ return obj;
340
+ }
341
+ function ownKeys$1(object, enumerableOnly) {
342
+ var keys = Object.keys(object);
343
+ if (Object.getOwnPropertySymbols) {
344
+ var symbols = Object.getOwnPropertySymbols(object);
345
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
346
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
347
+ })), keys.push.apply(keys, symbols);
348
+ }
349
+ return keys;
350
+ }
351
+ function _objectSpread2$1(target) {
352
+ for (var i = 1; i < arguments.length; i++) {
353
+ var source = arguments[i] != null ? arguments[i] : {};
354
+ i % 2 ? ownKeys$1(Object(source), true).forEach(function(key) {
355
+ _defineProperty$2(target, key, source[key]);
356
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function(key) {
357
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
358
+ });
359
+ }
360
+ return target;
361
+ }
362
+ var runtime = { exports: {} };
363
+ (function(module) {
364
+ var runtime2 = function(exports) {
365
+ var Op = Object.prototype;
366
+ var hasOwn = Op.hasOwnProperty;
367
+ var undefined$1;
368
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
369
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
370
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
371
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
372
+ function define(obj, key, value) {
373
+ Object.defineProperty(obj, key, {
374
+ value,
375
+ enumerable: true,
376
+ configurable: true,
377
+ writable: true
378
+ });
379
+ return obj[key];
380
+ }
381
+ try {
382
+ define({}, "");
383
+ } catch (err) {
384
+ define = function(obj, key, value) {
385
+ return obj[key] = value;
386
+ };
387
+ }
388
+ function wrap(innerFn, outerFn, self2, tryLocsList) {
389
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
390
+ var generator = Object.create(protoGenerator.prototype);
391
+ var context2 = new Context(tryLocsList || []);
392
+ generator._invoke = makeInvokeMethod(innerFn, self2, context2);
393
+ return generator;
394
+ }
395
+ exports.wrap = wrap;
396
+ function tryCatch(fn, obj, arg) {
397
+ try {
398
+ return {
399
+ type: "normal",
400
+ arg: fn.call(obj, arg)
401
+ };
402
+ } catch (err) {
403
+ return {
404
+ type: "throw",
405
+ arg: err
406
+ };
407
+ }
408
+ }
409
+ var GenStateSuspendedStart = "suspendedStart";
410
+ var GenStateSuspendedYield = "suspendedYield";
411
+ var GenStateExecuting = "executing";
412
+ var GenStateCompleted = "completed";
413
+ var ContinueSentinel = {};
414
+ function Generator() {
415
+ }
416
+ function GeneratorFunction() {
417
+ }
418
+ function GeneratorFunctionPrototype() {
419
+ }
420
+ var IteratorPrototype = {};
421
+ define(IteratorPrototype, iteratorSymbol, function() {
422
+ return this;
423
+ });
424
+ var getProto = Object.getPrototypeOf;
425
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
426
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
427
+ IteratorPrototype = NativeIteratorPrototype;
428
+ }
429
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
430
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
431
+ define(Gp, "constructor", GeneratorFunctionPrototype);
432
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
433
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
434
+ function defineIteratorMethods(prototype) {
435
+ ["next", "throw", "return"].forEach(function(method) {
436
+ define(prototype, method, function(arg) {
437
+ return this._invoke(method, arg);
438
+ });
439
+ });
440
+ }
441
+ exports.isGeneratorFunction = function(genFun) {
442
+ var ctor = typeof genFun === "function" && genFun.constructor;
443
+ return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
444
+ };
445
+ exports.mark = function(genFun) {
446
+ if (Object.setPrototypeOf) {
447
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
448
+ } else {
449
+ genFun.__proto__ = GeneratorFunctionPrototype;
450
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
451
+ }
452
+ genFun.prototype = Object.create(Gp);
453
+ return genFun;
454
+ };
455
+ exports.awrap = function(arg) {
456
+ return {
457
+ __await: arg
458
+ };
459
+ };
460
+ function AsyncIterator(generator, PromiseImpl) {
461
+ function invoke(method, arg, resolve, reject) {
462
+ var record = tryCatch(generator[method], generator, arg);
463
+ if (record.type === "throw") {
464
+ reject(record.arg);
465
+ } else {
466
+ var result = record.arg;
467
+ var value = result.value;
468
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
469
+ return PromiseImpl.resolve(value.__await).then(function(value2) {
470
+ invoke("next", value2, resolve, reject);
471
+ }, function(err) {
472
+ invoke("throw", err, resolve, reject);
473
+ });
474
+ }
475
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
476
+ result.value = unwrapped;
477
+ resolve(result);
478
+ }, function(error) {
479
+ return invoke("throw", error, resolve, reject);
480
+ });
481
+ }
482
+ }
483
+ var previousPromise;
484
+ function enqueue(method, arg) {
485
+ function callInvokeWithMethodAndArg() {
486
+ return new PromiseImpl(function(resolve, reject) {
487
+ invoke(method, arg, resolve, reject);
488
+ });
489
+ }
490
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
491
+ }
492
+ this._invoke = enqueue;
493
+ }
494
+ defineIteratorMethods(AsyncIterator.prototype);
495
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
496
+ return this;
497
+ });
498
+ exports.AsyncIterator = AsyncIterator;
499
+ exports.async = function(innerFn, outerFn, self2, tryLocsList, PromiseImpl) {
500
+ if (PromiseImpl === void 0)
501
+ PromiseImpl = Promise;
502
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self2, tryLocsList), PromiseImpl);
503
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
504
+ return result.done ? result.value : iter.next();
505
+ });
506
+ };
507
+ function makeInvokeMethod(innerFn, self2, context2) {
508
+ var state = GenStateSuspendedStart;
509
+ return function invoke(method, arg) {
510
+ if (state === GenStateExecuting) {
511
+ throw new Error("Generator is already running");
512
+ }
513
+ if (state === GenStateCompleted) {
514
+ if (method === "throw") {
515
+ throw arg;
516
+ }
517
+ return doneResult();
518
+ }
519
+ context2.method = method;
520
+ context2.arg = arg;
521
+ while (true) {
522
+ var delegate = context2.delegate;
523
+ if (delegate) {
524
+ var delegateResult = maybeInvokeDelegate(delegate, context2);
525
+ if (delegateResult) {
526
+ if (delegateResult === ContinueSentinel)
527
+ continue;
528
+ return delegateResult;
529
+ }
530
+ }
531
+ if (context2.method === "next") {
532
+ context2.sent = context2._sent = context2.arg;
533
+ } else if (context2.method === "throw") {
534
+ if (state === GenStateSuspendedStart) {
535
+ state = GenStateCompleted;
536
+ throw context2.arg;
537
+ }
538
+ context2.dispatchException(context2.arg);
539
+ } else if (context2.method === "return") {
540
+ context2.abrupt("return", context2.arg);
541
+ }
542
+ state = GenStateExecuting;
543
+ var record = tryCatch(innerFn, self2, context2);
544
+ if (record.type === "normal") {
545
+ state = context2.done ? GenStateCompleted : GenStateSuspendedYield;
546
+ if (record.arg === ContinueSentinel) {
547
+ continue;
548
+ }
549
+ return {
550
+ value: record.arg,
551
+ done: context2.done
552
+ };
553
+ } else if (record.type === "throw") {
554
+ state = GenStateCompleted;
555
+ context2.method = "throw";
556
+ context2.arg = record.arg;
557
+ }
558
+ }
559
+ };
560
+ }
561
+ function maybeInvokeDelegate(delegate, context2) {
562
+ var method = delegate.iterator[context2.method];
563
+ if (method === undefined$1) {
564
+ context2.delegate = null;
565
+ if (context2.method === "throw") {
566
+ if (delegate.iterator["return"]) {
567
+ context2.method = "return";
568
+ context2.arg = undefined$1;
569
+ maybeInvokeDelegate(delegate, context2);
570
+ if (context2.method === "throw") {
571
+ return ContinueSentinel;
572
+ }
573
+ }
574
+ context2.method = "throw";
575
+ context2.arg = new TypeError("The iterator does not provide a 'throw' method");
576
+ }
577
+ return ContinueSentinel;
578
+ }
579
+ var record = tryCatch(method, delegate.iterator, context2.arg);
580
+ if (record.type === "throw") {
581
+ context2.method = "throw";
582
+ context2.arg = record.arg;
583
+ context2.delegate = null;
584
+ return ContinueSentinel;
585
+ }
586
+ var info = record.arg;
587
+ if (!info) {
588
+ context2.method = "throw";
589
+ context2.arg = new TypeError("iterator result is not an object");
590
+ context2.delegate = null;
591
+ return ContinueSentinel;
592
+ }
593
+ if (info.done) {
594
+ context2[delegate.resultName] = info.value;
595
+ context2.next = delegate.nextLoc;
596
+ if (context2.method !== "return") {
597
+ context2.method = "next";
598
+ context2.arg = undefined$1;
599
+ }
600
+ } else {
601
+ return info;
602
+ }
603
+ context2.delegate = null;
604
+ return ContinueSentinel;
605
+ }
606
+ defineIteratorMethods(Gp);
607
+ define(Gp, toStringTagSymbol, "Generator");
608
+ define(Gp, iteratorSymbol, function() {
609
+ return this;
610
+ });
611
+ define(Gp, "toString", function() {
612
+ return "[object Generator]";
613
+ });
614
+ function pushTryEntry(locs) {
615
+ var entry = {
616
+ tryLoc: locs[0]
617
+ };
618
+ if (1 in locs) {
619
+ entry.catchLoc = locs[1];
620
+ }
621
+ if (2 in locs) {
622
+ entry.finallyLoc = locs[2];
623
+ entry.afterLoc = locs[3];
624
+ }
625
+ this.tryEntries.push(entry);
626
+ }
627
+ function resetTryEntry(entry) {
628
+ var record = entry.completion || {};
629
+ record.type = "normal";
630
+ delete record.arg;
631
+ entry.completion = record;
632
+ }
633
+ function Context(tryLocsList) {
634
+ this.tryEntries = [{
635
+ tryLoc: "root"
636
+ }];
637
+ tryLocsList.forEach(pushTryEntry, this);
638
+ this.reset(true);
639
+ }
640
+ exports.keys = function(object) {
641
+ var keys = [];
642
+ for (var key in object) {
643
+ keys.push(key);
644
+ }
645
+ keys.reverse();
646
+ return function next() {
647
+ while (keys.length) {
648
+ var key2 = keys.pop();
649
+ if (key2 in object) {
650
+ next.value = key2;
651
+ next.done = false;
652
+ return next;
653
+ }
654
+ }
655
+ next.done = true;
656
+ return next;
657
+ };
658
+ };
659
+ function values(iterable) {
660
+ if (iterable) {
661
+ var iteratorMethod = iterable[iteratorSymbol];
662
+ if (iteratorMethod) {
663
+ return iteratorMethod.call(iterable);
664
+ }
665
+ if (typeof iterable.next === "function") {
666
+ return iterable;
667
+ }
668
+ if (!isNaN(iterable.length)) {
669
+ var i = -1, next = function next2() {
670
+ while (++i < iterable.length) {
671
+ if (hasOwn.call(iterable, i)) {
672
+ next2.value = iterable[i];
673
+ next2.done = false;
674
+ return next2;
675
+ }
676
+ }
677
+ next2.value = undefined$1;
678
+ next2.done = true;
679
+ return next2;
680
+ };
681
+ return next.next = next;
682
+ }
683
+ }
684
+ return {
685
+ next: doneResult
686
+ };
687
+ }
688
+ exports.values = values;
689
+ function doneResult() {
690
+ return {
691
+ value: undefined$1,
692
+ done: true
693
+ };
694
+ }
695
+ Context.prototype = {
696
+ constructor: Context,
697
+ reset: function(skipTempReset) {
698
+ this.prev = 0;
699
+ this.next = 0;
700
+ this.sent = this._sent = undefined$1;
701
+ this.done = false;
702
+ this.delegate = null;
703
+ this.method = "next";
704
+ this.arg = undefined$1;
705
+ this.tryEntries.forEach(resetTryEntry);
706
+ if (!skipTempReset) {
707
+ for (var name in this) {
708
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
709
+ this[name] = undefined$1;
710
+ }
711
+ }
712
+ }
713
+ },
714
+ stop: function() {
715
+ this.done = true;
716
+ var rootEntry = this.tryEntries[0];
717
+ var rootRecord = rootEntry.completion;
718
+ if (rootRecord.type === "throw") {
719
+ throw rootRecord.arg;
720
+ }
721
+ return this.rval;
722
+ },
723
+ dispatchException: function(exception) {
724
+ if (this.done) {
725
+ throw exception;
726
+ }
727
+ var context2 = this;
728
+ function handle(loc, caught) {
729
+ record.type = "throw";
730
+ record.arg = exception;
731
+ context2.next = loc;
732
+ if (caught) {
733
+ context2.method = "next";
734
+ context2.arg = undefined$1;
735
+ }
736
+ return !!caught;
737
+ }
738
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
739
+ var entry = this.tryEntries[i];
740
+ var record = entry.completion;
741
+ if (entry.tryLoc === "root") {
742
+ return handle("end");
743
+ }
744
+ if (entry.tryLoc <= this.prev) {
745
+ var hasCatch = hasOwn.call(entry, "catchLoc");
746
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
747
+ if (hasCatch && hasFinally) {
748
+ if (this.prev < entry.catchLoc) {
749
+ return handle(entry.catchLoc, true);
750
+ } else if (this.prev < entry.finallyLoc) {
751
+ return handle(entry.finallyLoc);
752
+ }
753
+ } else if (hasCatch) {
754
+ if (this.prev < entry.catchLoc) {
755
+ return handle(entry.catchLoc, true);
756
+ }
757
+ } else if (hasFinally) {
758
+ if (this.prev < entry.finallyLoc) {
759
+ return handle(entry.finallyLoc);
760
+ }
761
+ } else {
762
+ throw new Error("try statement without catch or finally");
763
+ }
764
+ }
765
+ }
766
+ },
767
+ abrupt: function(type, arg) {
768
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
769
+ var entry = this.tryEntries[i];
770
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
771
+ var finallyEntry = entry;
772
+ break;
773
+ }
774
+ }
775
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
776
+ finallyEntry = null;
777
+ }
778
+ var record = finallyEntry ? finallyEntry.completion : {};
779
+ record.type = type;
780
+ record.arg = arg;
781
+ if (finallyEntry) {
782
+ this.method = "next";
783
+ this.next = finallyEntry.finallyLoc;
784
+ return ContinueSentinel;
785
+ }
786
+ return this.complete(record);
787
+ },
788
+ complete: function(record, afterLoc) {
789
+ if (record.type === "throw") {
790
+ throw record.arg;
791
+ }
792
+ if (record.type === "break" || record.type === "continue") {
793
+ this.next = record.arg;
794
+ } else if (record.type === "return") {
795
+ this.rval = this.arg = record.arg;
796
+ this.method = "return";
797
+ this.next = "end";
798
+ } else if (record.type === "normal" && afterLoc) {
799
+ this.next = afterLoc;
800
+ }
801
+ return ContinueSentinel;
802
+ },
803
+ finish: function(finallyLoc) {
804
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
805
+ var entry = this.tryEntries[i];
806
+ if (entry.finallyLoc === finallyLoc) {
807
+ this.complete(entry.completion, entry.afterLoc);
808
+ resetTryEntry(entry);
809
+ return ContinueSentinel;
810
+ }
811
+ }
812
+ },
813
+ "catch": function(tryLoc) {
814
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
815
+ var entry = this.tryEntries[i];
816
+ if (entry.tryLoc === tryLoc) {
817
+ var record = entry.completion;
818
+ if (record.type === "throw") {
819
+ var thrown = record.arg;
820
+ resetTryEntry(entry);
821
+ }
822
+ return thrown;
823
+ }
824
+ }
825
+ throw new Error("illegal catch attempt");
826
+ },
827
+ delegateYield: function(iterable, resultName, nextLoc) {
828
+ this.delegate = {
829
+ iterator: values(iterable),
830
+ resultName,
831
+ nextLoc
832
+ };
833
+ if (this.method === "next") {
834
+ this.arg = undefined$1;
835
+ }
836
+ return ContinueSentinel;
837
+ }
838
+ };
839
+ return exports;
840
+ }(module.exports);
841
+ try {
842
+ regeneratorRuntime = runtime2;
843
+ } catch (accidentalStrictMode) {
844
+ if (typeof globalThis === "object") {
845
+ globalThis.regeneratorRuntime = runtime2;
846
+ } else {
847
+ Function("r", "regeneratorRuntime = r")(runtime2);
848
+ }
849
+ }
850
+ })(runtime);
851
+ var regenerator = runtime.exports;
852
+ var FUNC = "function";
853
+ var UNDEF = "undefined";
854
+ var REDUCER = "reducer";
855
+ var base = "@@redux/";
856
+ var ACTION_INIT = base + "INIT";
857
+ var ACTION_TEST = base + Math.random().toString(36);
858
+ var $$observable = /* @__PURE__ */ function() {
859
+ return (typeof Symbol === "undefined" ? "undefined" : _typeof(Symbol)) === FUNC && Symbol.observable || "@@observable";
860
+ }();
861
+ var msg = " != " + FUNC;
862
+ function createStore(reducer, preloadedState, enhancer) {
863
+ if (_typeof(preloadedState) === FUNC && _typeof(enhancer) === UNDEF) {
864
+ enhancer = preloadedState;
865
+ preloadedState = void 0;
866
+ }
867
+ if (_typeof(enhancer) !== UNDEF) {
868
+ if (_typeof(enhancer) !== FUNC) {
869
+ throw new Error("enhancer" + msg);
870
+ }
871
+ return enhancer(createStore)(reducer, preloadedState);
872
+ }
873
+ if (_typeof(reducer) !== FUNC) {
874
+ throw new Error(REDUCER + msg);
875
+ }
876
+ var currentReducer = reducer;
877
+ var currentState = preloadedState;
878
+ var currentListeners = [];
879
+ var nextListeners = currentListeners;
880
+ var isDispatching = false;
881
+ function ensureCanMutateNextListeners() {
882
+ if (nextListeners === currentListeners) {
883
+ nextListeners = currentListeners.slice();
884
+ }
885
+ }
886
+ function getState() {
887
+ return currentState;
888
+ }
889
+ function subscribe(listener) {
890
+ if (_typeof(listener) !== FUNC) {
891
+ throw new Error("Listener" + msg);
892
+ }
893
+ var isSubscribed = true;
894
+ ensureCanMutateNextListeners();
895
+ nextListeners.push(listener);
896
+ return function unsubscribe() {
897
+ if (!isSubscribed) {
898
+ return;
899
+ }
900
+ isSubscribed = false;
901
+ ensureCanMutateNextListeners();
902
+ var index2 = nextListeners.indexOf(listener);
903
+ nextListeners.splice(index2, 1);
904
+ };
905
+ }
906
+ function dispatch(action) {
907
+ if (!M$3(action)) {
908
+ throw new Error("Act != obj");
909
+ }
910
+ if (_typeof(action.type) === UNDEF) {
911
+ throw new Error("ActType " + UNDEF);
912
+ }
913
+ if (isDispatching) {
914
+ throw new Error("Dispatch in " + REDUCER);
915
+ }
916
+ try {
917
+ isDispatching = true;
918
+ currentState = currentReducer(currentState, action);
919
+ } finally {
920
+ isDispatching = false;
921
+ }
922
+ var listeners = currentListeners = nextListeners;
923
+ for (var i = 0; i < listeners.length; i++) {
924
+ var listener = listeners[i];
925
+ listener();
926
+ }
927
+ return action;
928
+ }
929
+ function replaceReducer(nextReducer) {
930
+ if (_typeof(nextReducer) !== FUNC) {
931
+ throw new Error("next " + REDUCER + msg);
932
+ }
933
+ currentReducer = nextReducer;
934
+ dispatch({
935
+ type: ACTION_INIT
936
+ });
937
+ }
938
+ function observable() {
939
+ var outerSubscribe = subscribe;
940
+ return _defineProperty$2({
941
+ subscribe: function subscribe2(observer) {
942
+ if (_typeof(observer) !== "object") {
943
+ throw new TypeError("Observer != obj");
944
+ }
945
+ function observeState() {
946
+ if (observer.next) {
947
+ observer.next(getState());
948
+ }
949
+ }
950
+ observeState();
951
+ var unsubscribe = outerSubscribe(observeState);
952
+ return {
953
+ unsubscribe
954
+ };
955
+ }
956
+ }, $$observable, function() {
957
+ return this;
958
+ });
959
+ }
960
+ dispatch({
961
+ type: ACTION_INIT
962
+ });
963
+ return _defineProperty$2({
964
+ dispatch,
965
+ subscribe,
966
+ getState,
967
+ replaceReducer
968
+ }, $$observable, observable);
969
+ }
970
+ function getUndefinedStateErrorMessage(key, action) {
971
+ var actionType = action && action.type;
972
+ var actionName = actionType && actionType.toString() || "?";
973
+ return "action " + actionName + REDUCER + " " + key + " returns " + UNDEF;
974
+ }
975
+ function assertReducerShape(reducers) {
976
+ Object.keys(reducers).forEach(function(key) {
977
+ var reducer = reducers[key];
978
+ var initialState2 = reducer(void 0, {
979
+ type: ACTION_INIT
980
+ });
981
+ if (_typeof(initialState2) === UNDEF || _typeof(reducer(void 0, {
982
+ type: ACTION_TEST
983
+ })) === UNDEF) {
984
+ throw new Error(REDUCER + " " + key + " " + UNDEF);
985
+ }
986
+ });
987
+ }
988
+ function combineReducers(reducers) {
989
+ var reducerKeys = Object.keys(reducers);
990
+ var finalReducers = {};
991
+ for (var i = 0; i < reducerKeys.length; i++) {
992
+ var key = reducerKeys[i];
993
+ if (_typeof(reducers[key]) === FUNC) {
994
+ finalReducers[key] = reducers[key];
995
+ }
996
+ }
997
+ var finalReducerKeys = Object.keys(finalReducers);
998
+ var shapeAssertionError;
999
+ try {
1000
+ assertReducerShape(finalReducers);
1001
+ } catch (e2) {
1002
+ shapeAssertionError = e2;
1003
+ }
1004
+ return function combination() {
1005
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1006
+ var action = arguments.length > 1 ? arguments[1] : void 0;
1007
+ if (shapeAssertionError) {
1008
+ throw shapeAssertionError;
1009
+ }
1010
+ var hasChanged = false;
1011
+ var nextState = {};
1012
+ for (var _i = 0; _i < finalReducerKeys.length; _i++) {
1013
+ var _key = finalReducerKeys[_i];
1014
+ var reducer = finalReducers[_key];
1015
+ var previousStateForKey = state[_key];
1016
+ var nextStateForKey = reducer(previousStateForKey, action);
1017
+ if (_typeof(nextStateForKey) === UNDEF) {
1018
+ var errorMessage = getUndefinedStateErrorMessage(_key, action);
1019
+ throw new Error(errorMessage);
1020
+ }
1021
+ nextState[_key] = nextStateForKey;
1022
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
1023
+ }
1024
+ return hasChanged ? nextState : state;
1025
+ };
1026
+ }
1027
+ function compose() {
1028
+ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
1029
+ funcs[_key] = arguments[_key];
1030
+ }
1031
+ if (funcs.length === 0) {
1032
+ return function(arg) {
1033
+ return arg;
1034
+ };
1035
+ }
1036
+ if (funcs.length === 1) {
1037
+ return funcs[0];
1038
+ }
1039
+ return funcs.reduce(function(a2, b2) {
1040
+ return function() {
1041
+ return a2(b2.apply(void 0, arguments));
1042
+ };
1043
+ });
1044
+ }
1045
+ function applyMiddleware() {
1046
+ for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
1047
+ middlewares[_key] = arguments[_key];
1048
+ }
1049
+ return function(createStore2) {
1050
+ return function(reducer, preloadedState, enhancer) {
1051
+ var store = createStore2(reducer, preloadedState, enhancer);
1052
+ var _dispatch = store.dispatch;
1053
+ var chain = [];
1054
+ var middlewareAPI = {
1055
+ getState: store.getState,
1056
+ dispatch: function dispatch(action) {
1057
+ return _dispatch(action);
1058
+ }
1059
+ };
1060
+ chain = middlewares.map(function(middleware) {
1061
+ return middleware(middlewareAPI);
1062
+ });
1063
+ _dispatch = compose.apply(void 0, _toConsumableArray(chain))(store.dispatch);
1064
+ return _objectSpread2$1(_objectSpread2$1({}, store), {}, {
1065
+ dispatch: _dispatch
1066
+ });
1067
+ };
1068
+ };
1069
+ }
1070
+ var ANON_ID = p + "anon_id";
1071
+ var USER_ID = p + "user_id";
1072
+ var USER_TRAITS = p + "user_traits";
1073
+ var LIB_NAME = "analytics";
1074
+ var ID = "userId";
1075
+ var ANONID = "anonymousId";
1076
+ var ERROR_URL = "https://lytics.dev/errors/";
1077
+ var coreEvents = [
1078
+ "bootstrap",
1079
+ "params",
1080
+ "campaign",
1081
+ "initializeStart",
1082
+ "initialize",
1083
+ "initializeEnd",
1084
+ "ready",
1085
+ "resetStart",
1086
+ "reset",
1087
+ "resetEnd",
1088
+ "pageStart",
1089
+ "page",
1090
+ "pageEnd",
1091
+ "pageAborted",
1092
+ "trackStart",
1093
+ "track",
1094
+ "trackEnd",
1095
+ "trackAborted",
1096
+ "identifyStart",
1097
+ "identify",
1098
+ "identifyEnd",
1099
+ "identifyAborted",
1100
+ "userIdChanged",
1101
+ "registerPlugins",
1102
+ "enablePlugin",
1103
+ "disablePlugin",
1104
+ "online",
1105
+ "offline",
1106
+ "setItemStart",
1107
+ "setItem",
1108
+ "setItemEnd",
1109
+ "setItemAborted",
1110
+ "removeItemStart",
1111
+ "removeItem",
1112
+ "removeItemEnd",
1113
+ "removeItemAborted"
1114
+ ];
1115
+ var nonEvents = ["name", "EVENTS", "config", "loaded"];
1116
+ var pluginEvents = {
1117
+ registerPluginType: function registerPluginType(name) {
1118
+ return "registerPlugin:".concat(name);
1119
+ },
1120
+ pluginReadyType: function pluginReadyType(name) {
1121
+ return "ready:".concat(name);
1122
+ }
1123
+ };
1124
+ var EVENTS = coreEvents.reduce(function(acc, curr) {
1125
+ acc[curr] = curr;
1126
+ return acc;
1127
+ }, pluginEvents);
1128
+ var EVENTS$1 = EVENTS;
1129
+ function isReservedAction(type) {
1130
+ return coreEvents.includes(type);
1131
+ }
1132
+ var utmRegex = /^utm_/;
1133
+ var propRegex = /^an_prop_/;
1134
+ var traitRegex = /^an_trait_/;
1135
+ function initializeMiddleware(instance) {
1136
+ var setItem = instance.storage.setItem;
1137
+ return function(store) {
1138
+ return function(next) {
1139
+ return function(action) {
1140
+ if (action.type === EVENTS$1.bootstrap) {
1141
+ var params = action.params, user = action.user, persistedUser = action.persistedUser, initialUser = action.initialUser;
1142
+ var isKnownId = persistedUser.userId === user.userId;
1143
+ if (persistedUser.anonymousId !== user.anonymousId) {
1144
+ setItem(ANON_ID, user.anonymousId);
1145
+ }
1146
+ if (!isKnownId) {
1147
+ setItem(USER_ID, user.userId);
1148
+ }
1149
+ if (initialUser.traits) {
1150
+ setItem(USER_TRAITS, _objectSpread2$1(_objectSpread2$1({}, isKnownId && persistedUser.traits ? persistedUser.traits : {}), initialUser.traits));
1151
+ }
1152
+ var paramsArray = Object.keys(action.params);
1153
+ if (paramsArray.length) {
1154
+ var an_uid = params.an_uid, an_event = params.an_event;
1155
+ var groupedParams = paramsArray.reduce(function(acc, key) {
1156
+ if (key.match(utmRegex) || key.match(/^(d|g)clid/)) {
1157
+ var cleanName = key.replace(utmRegex, "");
1158
+ var keyName = cleanName === "campaign" ? "name" : cleanName;
1159
+ acc.campaign[keyName] = params[key];
1160
+ }
1161
+ if (key.match(propRegex)) {
1162
+ acc.props[key.replace(propRegex, "")] = params[key];
1163
+ }
1164
+ if (key.match(traitRegex)) {
1165
+ acc.traits[key.replace(traitRegex, "")] = params[key];
1166
+ }
1167
+ return acc;
1168
+ }, {
1169
+ campaign: {},
1170
+ props: {},
1171
+ traits: {}
1172
+ });
1173
+ store.dispatch(_objectSpread2$1(_objectSpread2$1({
1174
+ type: EVENTS$1.params,
1175
+ raw: params
1176
+ }, groupedParams), an_uid ? {
1177
+ userId: an_uid
1178
+ } : {}));
1179
+ if (an_uid) {
1180
+ setTimeout(function() {
1181
+ return instance.identify(an_uid, groupedParams.traits);
1182
+ }, 0);
1183
+ }
1184
+ if (an_event) {
1185
+ setTimeout(function() {
1186
+ return instance.track(an_event, groupedParams.props);
1187
+ }, 0);
1188
+ }
1189
+ if (Object.keys(groupedParams.campaign).length) {
1190
+ store.dispatch({
1191
+ type: EVENTS$1.campaign,
1192
+ campaign: groupedParams.campaign
1193
+ });
1194
+ }
1195
+ }
1196
+ }
1197
+ return next(action);
1198
+ };
1199
+ };
1200
+ };
1201
+ }
1202
+ function userReducer(storage2) {
1203
+ return function user() {
1204
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1205
+ var action = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1206
+ if (action.type === EVENTS$1.setItemEnd) {
1207
+ if (action.key === ANON_ID) {
1208
+ return _objectSpread2$1(_objectSpread2$1({}, state), {
1209
+ anonymousId: action.value
1210
+ });
1211
+ }
1212
+ if (action.key === USER_ID) {
1213
+ return _objectSpread2$1(_objectSpread2$1({}, state), {
1214
+ userId: action.value
1215
+ });
1216
+ }
1217
+ }
1218
+ switch (action.type) {
1219
+ case EVENTS$1.identify:
1220
+ return Object.assign({}, state, {
1221
+ userId: action.userId,
1222
+ traits: _objectSpread2$1(_objectSpread2$1({}, state.traits), action.traits)
1223
+ });
1224
+ case EVENTS$1.reset:
1225
+ [USER_ID, ANON_ID, USER_TRAITS].forEach(function(key) {
1226
+ storage2.removeItem(key);
1227
+ });
1228
+ return Object.assign({}, state, {
1229
+ userId: null,
1230
+ anonymousId: null,
1231
+ traits: {}
1232
+ });
1233
+ default:
1234
+ return state;
1235
+ }
1236
+ };
1237
+ }
1238
+ function getPersistedUserData(storage2) {
1239
+ return {
1240
+ userId: storage2.getItem(USER_ID),
1241
+ anonymousId: storage2.getItem(ANON_ID),
1242
+ traits: storage2.getItem(USER_TRAITS)
1243
+ };
1244
+ }
1245
+ var tempKey = function tempKey2(key) {
1246
+ return p + "TEMP" + p + key;
1247
+ };
1248
+ function getUserPropFunc(storage2) {
1249
+ return function getUserProp(key, instance, payload) {
1250
+ var currentId = instance.getState("user")[key];
1251
+ if (currentId) {
1252
+ return currentId;
1253
+ }
1254
+ if (payload && M$3(payload) && payload[key]) {
1255
+ return payload[key];
1256
+ }
1257
+ var persistedInfo = getPersistedUserData(storage2)[key];
1258
+ if (persistedInfo) {
1259
+ return persistedInfo;
1260
+ }
1261
+ return a$4(tempKey(key)) || null;
1262
+ };
1263
+ }
1264
+ function identifyMiddleware(instance) {
1265
+ var _instance$storage = instance.storage, setItem = _instance$storage.setItem, removeItem = _instance$storage.removeItem, getItem = _instance$storage.getItem;
1266
+ return function(store) {
1267
+ return function(next) {
1268
+ return function(action) {
1269
+ var userId = action.userId, traits = action.traits, options = action.options;
1270
+ if (action.type === EVENTS$1.reset) {
1271
+ [USER_ID, USER_TRAITS, ANON_ID].forEach(function(key) {
1272
+ removeItem(key);
1273
+ });
1274
+ [ID, ANONID, "traits"].forEach(function(key) {
1275
+ i$5(tempKey(key));
1276
+ });
1277
+ }
1278
+ if (action.type === EVENTS$1.identify) {
1279
+ if (!getItem(ANON_ID)) {
1280
+ setItem(ANON_ID, y$1());
1281
+ }
1282
+ var currentId = getItem(USER_ID);
1283
+ var currentTraits = getItem(USER_TRAITS) || {};
1284
+ if (currentId && currentId !== userId) {
1285
+ store.dispatch({
1286
+ type: EVENTS$1.userIdChanged,
1287
+ old: {
1288
+ userId: currentId,
1289
+ traits: currentTraits
1290
+ },
1291
+ "new": {
1292
+ userId,
1293
+ traits
1294
+ },
1295
+ options
1296
+ });
1297
+ }
1298
+ if (userId) {
1299
+ setItem(USER_ID, userId);
1300
+ }
1301
+ if (traits) {
1302
+ setItem(USER_TRAITS, _objectSpread2$1(_objectSpread2$1({}, currentTraits), traits));
1303
+ }
1304
+ }
1305
+ return next(action);
1306
+ };
1307
+ };
1308
+ };
1309
+ }
1310
+ var stack = {};
1311
+ function runCallback(id, payload) {
1312
+ if (stack[id] && _(stack[id])) {
1313
+ stack[id](payload);
1314
+ delete stack[id];
1315
+ }
1316
+ }
1317
+ function waitForReady(data, predicate, timeout) {
1318
+ return new Promise(function(resolve, reject) {
1319
+ if (predicate()) {
1320
+ return resolve(data);
1321
+ }
1322
+ if (timeout < 1) {
1323
+ return reject(_objectSpread2$1(_objectSpread2$1({}, data), {}, {
1324
+ queue: true
1325
+ }));
1326
+ }
1327
+ return pause(10).then(function(_2) {
1328
+ return waitForReady(data, predicate, timeout - 10).then(resolve, reject);
1329
+ });
1330
+ });
1331
+ }
1332
+ function pause(ms) {
1333
+ return new Promise(function(resolve) {
1334
+ return setTimeout(resolve, ms);
1335
+ });
1336
+ }
1337
+ function processQueue(store, getPlugins, instance) {
1338
+ var pluginMethods = getPlugins();
1339
+ var _store$getState = store.getState(), plugins = _store$getState.plugins, context2 = _store$getState.context, queue = _store$getState.queue, user = _store$getState.user;
1340
+ var isOnline = !context2.offline;
1341
+ if (isOnline && queue && queue.actions && queue.actions.length) {
1342
+ var pipeline = queue.actions.reduce(function(acc, item, index2) {
1343
+ var isLoaded = plugins[item.plugin].loaded;
1344
+ if (isLoaded) {
1345
+ acc.process.push(item);
1346
+ acc.processIndex.push(index2);
1347
+ } else {
1348
+ acc.requeue.push(item);
1349
+ acc.requeueIndex.push(index2);
1350
+ }
1351
+ return acc;
1352
+ }, {
1353
+ processIndex: [],
1354
+ process: [],
1355
+ requeue: [],
1356
+ requeueIndex: []
1357
+ });
1358
+ if (pipeline.processIndex && pipeline.processIndex.length) {
1359
+ pipeline.processIndex.forEach(function(i) {
1360
+ var processAction = queue.actions[i];
1361
+ var currentPlugin = processAction.plugin;
1362
+ var currentMethod = processAction.payload.type;
1363
+ var method = pluginMethods[currentPlugin][currentMethod];
1364
+ if (method && _(method)) {
1365
+ var enrichedPayload = enrich(processAction.payload, user);
1366
+ method({
1367
+ payload: enrichedPayload,
1368
+ config: plugins[currentPlugin].config,
1369
+ instance
1370
+ });
1371
+ var pluginEvent = "".concat(currentMethod, ":").concat(currentPlugin);
1372
+ store.dispatch(_objectSpread2$1(_objectSpread2$1({}, enrichedPayload), {}, {
1373
+ type: pluginEvent,
1374
+ _: {
1375
+ called: pluginEvent,
1376
+ from: "queueDrain"
1377
+ }
1378
+ }));
1379
+ }
1380
+ });
1381
+ var reQueueActions = queue.actions.filter(function(value, index2) {
1382
+ return !~pipeline.processIndex.indexOf(index2);
1383
+ });
1384
+ queue.actions = reQueueActions;
1385
+ }
1386
+ }
1387
+ }
1388
+ function heartBeat(store, getPlugins, instance) {
1389
+ return setInterval(function() {
1390
+ return processQueue(store, getPlugins, instance);
1391
+ }, 3e3);
1392
+ }
1393
+ function enrich() {
1394
+ var payload = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1395
+ var user = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1396
+ return [ID, ANONID].reduce(function(acc, key) {
1397
+ if (payload.hasOwnProperty(key) && user[key] && user[key] !== payload[key]) {
1398
+ acc[key] = user[key];
1399
+ }
1400
+ return acc;
1401
+ }, payload);
1402
+ }
1403
+ function _arrayWithHoles(arr) {
1404
+ if (Array.isArray(arr))
1405
+ return arr;
1406
+ }
1407
+ function _iterableToArrayLimit(arr, i) {
1408
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1409
+ if (_i == null)
1410
+ return;
1411
+ var _arr = [];
1412
+ var _n2 = true;
1413
+ var _d = false;
1414
+ var _s, _e;
1415
+ try {
1416
+ for (_i = _i.call(arr); !(_n2 = (_s = _i.next()).done); _n2 = true) {
1417
+ _arr.push(_s.value);
1418
+ if (i && _arr.length === i)
1419
+ break;
1420
+ }
1421
+ } catch (err) {
1422
+ _d = true;
1423
+ _e = err;
1424
+ } finally {
1425
+ try {
1426
+ if (!_n2 && _i["return"] != null)
1427
+ _i["return"]();
1428
+ } finally {
1429
+ if (_d)
1430
+ throw _e;
1431
+ }
1432
+ }
1433
+ return _arr;
1434
+ }
1435
+ function _nonIterableRest() {
1436
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1437
+ }
1438
+ function _slicedToArray(arr, i) {
1439
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
1440
+ }
1441
+ function fitlerDisabledPlugins(allPlugins) {
1442
+ var settings = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1443
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1444
+ return Object.keys(allPlugins).filter(function(name) {
1445
+ var fromCallOptions = options.plugins || {};
1446
+ if (x$1(fromCallOptions[name])) {
1447
+ return fromCallOptions[name];
1448
+ }
1449
+ if (fromCallOptions.all === false) {
1450
+ return false;
1451
+ }
1452
+ if (settings[name] && settings[name].enabled === false) {
1453
+ return false;
1454
+ }
1455
+ return true;
1456
+ }).map(function(name) {
1457
+ return allPlugins[name];
1458
+ });
1459
+ }
1460
+ var endsWithStartRegex = /Start$/;
1461
+ var bootstrapRegex = /^bootstrap/;
1462
+ var readyRegex = /^ready/;
1463
+ function runPlugins(_x, _x2, _x3, _x4, _x5) {
1464
+ return _ref.apply(this, arguments);
1465
+ }
1466
+ function _ref() {
1467
+ _ref = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee(action, getPlugins, instance, store, eventsInfo) {
1468
+ var pluginObject, originalType, updatedType, state, activePlugins, allActivePluginKeys, allMatches, actionBefore, actionDuring, afterName, actionAfter;
1469
+ return regenerator.wrap(function _callee$(_context) {
1470
+ while (1) {
1471
+ switch (_context.prev = _context.next) {
1472
+ case 0:
1473
+ pluginObject = _(getPlugins) ? getPlugins() : getPlugins;
1474
+ originalType = action.type;
1475
+ updatedType = originalType.replace(endsWithStartRegex, "");
1476
+ if (!(action._ && action._.called)) {
1477
+ _context.next = 5;
1478
+ break;
1479
+ }
1480
+ return _context.abrupt("return", action);
1481
+ case 5:
1482
+ state = instance.getState();
1483
+ activePlugins = fitlerDisabledPlugins(pluginObject, state.plugins, action.options);
1484
+ if (originalType === EVENTS$1.initializeStart && action.fromEnable) {
1485
+ activePlugins = Object.keys(state.plugins).filter(function(name) {
1486
+ var info = state.plugins[name];
1487
+ return action.plugins.includes(name) && !info.initialized;
1488
+ }).map(function(name) {
1489
+ return pluginObject[name];
1490
+ });
1491
+ }
1492
+ allActivePluginKeys = activePlugins.map(function(p2) {
1493
+ return p2.name;
1494
+ });
1495
+ allMatches = getAllMatchingCalls(originalType, activePlugins);
1496
+ _context.next = 12;
1497
+ return processEvent({
1498
+ action,
1499
+ data: {
1500
+ exact: allMatches.before,
1501
+ namespaced: allMatches.beforeNS
1502
+ },
1503
+ state,
1504
+ allPlugins: pluginObject,
1505
+ allMatches,
1506
+ instance,
1507
+ store,
1508
+ EVENTS: eventsInfo
1509
+ });
1510
+ case 12:
1511
+ actionBefore = _context.sent;
1512
+ if (!shouldAbortAll(actionBefore, allActivePluginKeys.length)) {
1513
+ _context.next = 15;
1514
+ break;
1515
+ }
1516
+ return _context.abrupt("return", actionBefore);
1517
+ case 15:
1518
+ if (!(originalType === updatedType)) {
1519
+ _context.next = 19;
1520
+ break;
1521
+ }
1522
+ actionDuring = actionBefore;
1523
+ _context.next = 22;
1524
+ break;
1525
+ case 19:
1526
+ _context.next = 21;
1527
+ return processEvent({
1528
+ action: _objectSpread2$1(_objectSpread2$1({}, actionBefore), {}, {
1529
+ type: updatedType
1530
+ }),
1531
+ data: {
1532
+ exact: allMatches.during,
1533
+ namespaced: allMatches.duringNS
1534
+ },
1535
+ state,
1536
+ allPlugins: pluginObject,
1537
+ allMatches,
1538
+ instance,
1539
+ store,
1540
+ EVENTS: eventsInfo
1541
+ });
1542
+ case 21:
1543
+ actionDuring = _context.sent;
1544
+ case 22:
1545
+ if (!originalType.match(endsWithStartRegex)) {
1546
+ _context.next = 28;
1547
+ break;
1548
+ }
1549
+ afterName = "".concat(updatedType, "End");
1550
+ _context.next = 26;
1551
+ return processEvent({
1552
+ action: _objectSpread2$1(_objectSpread2$1({}, actionDuring), {}, {
1553
+ type: afterName
1554
+ }),
1555
+ data: {
1556
+ exact: allMatches.after,
1557
+ namespaced: allMatches.afterNS
1558
+ },
1559
+ state,
1560
+ allPlugins: pluginObject,
1561
+ allMatches,
1562
+ instance,
1563
+ store,
1564
+ EVENTS: eventsInfo
1565
+ });
1566
+ case 26:
1567
+ actionAfter = _context.sent;
1568
+ if (actionAfter.meta && actionAfter.meta.hasCallback) {
1569
+ runCallback(actionAfter.meta.rid, {
1570
+ payload: actionAfter
1571
+ });
1572
+ }
1573
+ case 28:
1574
+ return _context.abrupt("return", actionBefore);
1575
+ case 29:
1576
+ case "end":
1577
+ return _context.stop();
1578
+ }
1579
+ }
1580
+ }, _callee);
1581
+ }));
1582
+ return _ref.apply(this, arguments);
1583
+ }
1584
+ function processEvent(_x6) {
1585
+ return _processEvent.apply(this, arguments);
1586
+ }
1587
+ function _processEvent() {
1588
+ _processEvent = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee5(_ref2) {
1589
+ var data, action, instance, state, allPlugins, allMatches, store, EVENTS2, plugins, context2, method, isStartEvent, abortable, makeArgs, queueData, payloads, resolvedAction, endAction;
1590
+ return regenerator.wrap(function _callee5$(_context5) {
1591
+ while (1) {
1592
+ switch (_context5.prev = _context5.next) {
1593
+ case 0:
1594
+ data = _ref2.data, action = _ref2.action, instance = _ref2.instance, state = _ref2.state, allPlugins = _ref2.allPlugins, allMatches = _ref2.allMatches, store = _ref2.store, EVENTS2 = _ref2.EVENTS;
1595
+ plugins = state.plugins, context2 = state.context;
1596
+ method = action.type;
1597
+ isStartEvent = method.match(endsWithStartRegex);
1598
+ abortable = data.exact.map(function(x2) {
1599
+ return x2.pluginName;
1600
+ });
1601
+ if (isStartEvent) {
1602
+ abortable = allMatches.during.map(function(x2) {
1603
+ return x2.pluginName;
1604
+ });
1605
+ }
1606
+ makeArgs = argumentFactory(instance, abortable);
1607
+ queueData = data.exact.reduce(function(acc, thing) {
1608
+ var pluginName = thing.pluginName, methodName = thing.methodName;
1609
+ var addToQueue = false;
1610
+ if (!methodName.match(/^initialize/) && !methodName.match(/^reset/)) {
1611
+ addToQueue = !plugins[pluginName].loaded;
1612
+ }
1613
+ if (context2.offline && methodName.match(/^(page|track|identify)/)) {
1614
+ addToQueue = true;
1615
+ }
1616
+ acc["".concat(pluginName)] = addToQueue;
1617
+ return acc;
1618
+ }, {});
1619
+ _context5.next = 10;
1620
+ return data.exact.reduce(/* @__PURE__ */ function() {
1621
+ var _ref6 = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee3(scoped, curr, i) {
1622
+ var pluginName, curScope, scopedPayload;
1623
+ return regenerator.wrap(function _callee3$(_context3) {
1624
+ while (1) {
1625
+ switch (_context3.prev = _context3.next) {
1626
+ case 0:
1627
+ pluginName = curr.pluginName;
1628
+ _context3.next = 3;
1629
+ return scoped;
1630
+ case 3:
1631
+ curScope = _context3.sent;
1632
+ if (!(data.namespaced && data.namespaced[pluginName])) {
1633
+ _context3.next = 11;
1634
+ break;
1635
+ }
1636
+ _context3.next = 7;
1637
+ return data.namespaced[pluginName].reduce(/* @__PURE__ */ function() {
1638
+ var _ref7 = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee2(acc, p2, count) {
1639
+ var curScopeData, genAbort, val, returnValue;
1640
+ return regenerator.wrap(function _callee2$(_context2) {
1641
+ while (1) {
1642
+ switch (_context2.prev = _context2.next) {
1643
+ case 0:
1644
+ genAbort = function _genAbort(currentAct, pname, otherPlug) {
1645
+ return function(reason, plugins2) {
1646
+ var callsite = otherPlug || pname;
1647
+ return _objectSpread2$1(_objectSpread2$1({}, currentAct), {}, {
1648
+ abort: {
1649
+ reason,
1650
+ plugins: plugins2 || [pname],
1651
+ caller: method,
1652
+ from: callsite
1653
+ }
1654
+ });
1655
+ };
1656
+ };
1657
+ _context2.next = 3;
1658
+ return acc;
1659
+ case 3:
1660
+ curScopeData = _context2.sent;
1661
+ if (!(!p2.method || !_(p2.method))) {
1662
+ _context2.next = 6;
1663
+ break;
1664
+ }
1665
+ return _context2.abrupt("return", curScopeData);
1666
+ case 6:
1667
+ validateMethod(p2.methodName, p2.pluginName);
1668
+ _context2.next = 9;
1669
+ return p2.method({
1670
+ payload: curScopeData,
1671
+ instance,
1672
+ abort: genAbort(curScopeData, pluginName, p2.pluginName),
1673
+ config: getConfig(p2.pluginName, plugins, allPlugins),
1674
+ plugins
1675
+ });
1676
+ case 9:
1677
+ val = _context2.sent;
1678
+ returnValue = M$3(val) ? val : {};
1679
+ return _context2.abrupt("return", Promise.resolve(_objectSpread2$1(_objectSpread2$1({}, curScopeData), returnValue)));
1680
+ case 12:
1681
+ case "end":
1682
+ return _context2.stop();
1683
+ }
1684
+ }
1685
+ }, _callee2);
1686
+ }));
1687
+ return function(_x10, _x11, _x12) {
1688
+ return _ref7.apply(this, arguments);
1689
+ };
1690
+ }(), Promise.resolve(action));
1691
+ case 7:
1692
+ scopedPayload = _context3.sent;
1693
+ curScope[pluginName] = scopedPayload;
1694
+ _context3.next = 12;
1695
+ break;
1696
+ case 11:
1697
+ curScope[pluginName] = action;
1698
+ case 12:
1699
+ return _context3.abrupt("return", Promise.resolve(curScope));
1700
+ case 13:
1701
+ case "end":
1702
+ return _context3.stop();
1703
+ }
1704
+ }
1705
+ }, _callee3);
1706
+ }));
1707
+ return function(_x7, _x8, _x9) {
1708
+ return _ref6.apply(this, arguments);
1709
+ };
1710
+ }(), Promise.resolve({}));
1711
+ case 10:
1712
+ payloads = _context5.sent;
1713
+ _context5.next = 13;
1714
+ return data.exact.reduce(/* @__PURE__ */ function() {
1715
+ var _ref8 = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee4(promise, curr, i) {
1716
+ var lastLoop, pluginName, currentPlugin, currentActionValue, payloadValue, funcArgs, val, returnValue, merged, scopedPayload, nameSpaceEvent, actionDepth, updatedPayload;
1717
+ return regenerator.wrap(function _callee4$(_context4) {
1718
+ while (1) {
1719
+ switch (_context4.prev = _context4.next) {
1720
+ case 0:
1721
+ lastLoop = data.exact.length === i + 1;
1722
+ pluginName = curr.pluginName;
1723
+ currentPlugin = allPlugins[pluginName];
1724
+ _context4.next = 5;
1725
+ return promise;
1726
+ case 5:
1727
+ currentActionValue = _context4.sent;
1728
+ payloadValue = payloads[pluginName] ? payloads[pluginName] : {};
1729
+ if (isStartEvent) {
1730
+ payloadValue = currentActionValue;
1731
+ }
1732
+ if (!shouldAbort(payloadValue, pluginName)) {
1733
+ _context4.next = 11;
1734
+ break;
1735
+ }
1736
+ abortDispatch({
1737
+ data: payloadValue,
1738
+ method,
1739
+ instance,
1740
+ pluginName,
1741
+ store
1742
+ });
1743
+ return _context4.abrupt("return", Promise.resolve(currentActionValue));
1744
+ case 11:
1745
+ if (!shouldAbort(currentActionValue, pluginName)) {
1746
+ _context4.next = 14;
1747
+ break;
1748
+ }
1749
+ if (lastLoop) {
1750
+ abortDispatch({
1751
+ data: currentActionValue,
1752
+ method,
1753
+ instance,
1754
+ store
1755
+ });
1756
+ }
1757
+ return _context4.abrupt("return", Promise.resolve(currentActionValue));
1758
+ case 14:
1759
+ if (!(queueData.hasOwnProperty(pluginName) && queueData[pluginName] === true)) {
1760
+ _context4.next = 17;
1761
+ break;
1762
+ }
1763
+ store.dispatch({
1764
+ type: "queue",
1765
+ plugin: pluginName,
1766
+ payload: payloadValue,
1767
+ _: {
1768
+ called: "queue",
1769
+ from: "queueMechanism"
1770
+ }
1771
+ });
1772
+ return _context4.abrupt("return", Promise.resolve(currentActionValue));
1773
+ case 17:
1774
+ funcArgs = makeArgs(payloads[pluginName], allPlugins[pluginName]);
1775
+ _context4.next = 20;
1776
+ return currentPlugin[method]({
1777
+ abort: funcArgs.abort,
1778
+ payload: payloadValue,
1779
+ instance,
1780
+ config: getConfig(pluginName, plugins, allPlugins),
1781
+ plugins
1782
+ });
1783
+ case 20:
1784
+ val = _context4.sent;
1785
+ returnValue = M$3(val) ? val : {};
1786
+ merged = _objectSpread2$1(_objectSpread2$1({}, currentActionValue), returnValue);
1787
+ scopedPayload = payloads[pluginName];
1788
+ if (shouldAbort(scopedPayload, pluginName)) {
1789
+ abortDispatch({
1790
+ data: scopedPayload,
1791
+ method,
1792
+ instance,
1793
+ pluginName,
1794
+ store
1795
+ });
1796
+ } else {
1797
+ nameSpaceEvent = "".concat(method, ":").concat(pluginName);
1798
+ actionDepth = (nameSpaceEvent.match(/:/g) || []).length;
1799
+ if (actionDepth < 2 && !method.match(bootstrapRegex) && !method.match(readyRegex)) {
1800
+ updatedPayload = isStartEvent ? merged : payloadValue;
1801
+ instance.dispatch(_objectSpread2$1(_objectSpread2$1({}, updatedPayload), {}, {
1802
+ type: nameSpaceEvent,
1803
+ _: {
1804
+ called: nameSpaceEvent,
1805
+ from: "submethod"
1806
+ }
1807
+ }));
1808
+ }
1809
+ }
1810
+ return _context4.abrupt("return", Promise.resolve(merged));
1811
+ case 26:
1812
+ case "end":
1813
+ return _context4.stop();
1814
+ }
1815
+ }
1816
+ }, _callee4);
1817
+ }));
1818
+ return function(_x13, _x14, _x15) {
1819
+ return _ref8.apply(this, arguments);
1820
+ };
1821
+ }(), Promise.resolve(action));
1822
+ case 13:
1823
+ resolvedAction = _context5.sent;
1824
+ if (!(!method.match(endsWithStartRegex) && !method.match(/^registerPlugin/) && !method.match(readyRegex) && !method.match(bootstrapRegex) && !method.match(/^params/) && !method.match(/^userIdChanged/))) {
1825
+ _context5.next = 21;
1826
+ break;
1827
+ }
1828
+ if (EVENTS2.plugins.includes(method))
1829
+ ;
1830
+ if (!(resolvedAction._ && resolvedAction._.originalAction === method)) {
1831
+ _context5.next = 18;
1832
+ break;
1833
+ }
1834
+ return _context5.abrupt("return", resolvedAction);
1835
+ case 18:
1836
+ endAction = _objectSpread2$1(_objectSpread2$1({}, resolvedAction), {
1837
+ _: {
1838
+ originalAction: resolvedAction.type,
1839
+ called: resolvedAction.type,
1840
+ from: "engineEnd"
1841
+ }
1842
+ });
1843
+ if (shouldAbortAll(resolvedAction, data.exact.length) && !method.match(/End$/)) {
1844
+ endAction = _objectSpread2$1(_objectSpread2$1({}, endAction), {
1845
+ type: resolvedAction.type + "Aborted"
1846
+ });
1847
+ }
1848
+ store.dispatch(endAction);
1849
+ case 21:
1850
+ return _context5.abrupt("return", resolvedAction);
1851
+ case 22:
1852
+ case "end":
1853
+ return _context5.stop();
1854
+ }
1855
+ }
1856
+ }, _callee5);
1857
+ }));
1858
+ return _processEvent.apply(this, arguments);
1859
+ }
1860
+ function abortDispatch(_ref3) {
1861
+ var data = _ref3.data, method = _ref3.method;
1862
+ _ref3.instance;
1863
+ var pluginName = _ref3.pluginName, store = _ref3.store;
1864
+ var postFix = pluginName ? ":" + pluginName : "";
1865
+ var abortEvent = method + "Aborted" + postFix;
1866
+ store.dispatch(_objectSpread2$1(_objectSpread2$1({}, data), {}, {
1867
+ type: abortEvent,
1868
+ _: {
1869
+ called: abortEvent,
1870
+ from: "abort"
1871
+ }
1872
+ }));
1873
+ }
1874
+ function getConfig(name, pluginState, allPlugins) {
1875
+ var pluginData = pluginState[name] || allPlugins[name];
1876
+ if (pluginData && pluginData.config) {
1877
+ return pluginData.config;
1878
+ }
1879
+ return {};
1880
+ }
1881
+ function getPluginFunctions(methodName, plugins) {
1882
+ return plugins.reduce(function(arr, plugin) {
1883
+ return !plugin[methodName] ? arr : arr.concat({
1884
+ methodName,
1885
+ pluginName: plugin.name,
1886
+ method: plugin[methodName]
1887
+ });
1888
+ }, []);
1889
+ }
1890
+ function formatMethod(type) {
1891
+ return type.replace(endsWithStartRegex, "");
1892
+ }
1893
+ function getEventNames(eventType, namespace) {
1894
+ var method = formatMethod(eventType);
1895
+ var postFix = namespace ? ":".concat(namespace) : "";
1896
+ var type = "".concat(eventType).concat(postFix);
1897
+ var methodName = "".concat(method).concat(postFix);
1898
+ var end = "".concat(method, "End").concat(postFix);
1899
+ return [type, methodName, end];
1900
+ }
1901
+ function getAllMatchingCalls(eventType, activePlugins, allPlugins) {
1902
+ var eventNames = getEventNames(eventType);
1903
+ var core = eventNames.map(function(word) {
1904
+ return getPluginFunctions(word, activePlugins);
1905
+ });
1906
+ return activePlugins.reduce(function(acc, plugin) {
1907
+ var name = plugin.name;
1908
+ var nameSpacedEvents = getEventNames(eventType, name);
1909
+ var _nameSpacedEvents$map = nameSpacedEvents.map(function(word) {
1910
+ return getPluginFunctions(word, activePlugins);
1911
+ }), _nameSpacedEvents$map2 = _slicedToArray(_nameSpacedEvents$map, 3), beforeFuncs = _nameSpacedEvents$map2[0], duringFuncs = _nameSpacedEvents$map2[1], afterFuncs = _nameSpacedEvents$map2[2];
1912
+ if (beforeFuncs.length) {
1913
+ acc.beforeNS[name] = beforeFuncs;
1914
+ }
1915
+ if (duringFuncs.length) {
1916
+ acc.duringNS[name] = duringFuncs;
1917
+ }
1918
+ if (afterFuncs.length) {
1919
+ acc.afterNS[name] = afterFuncs;
1920
+ }
1921
+ return acc;
1922
+ }, {
1923
+ before: core[0],
1924
+ beforeNS: {},
1925
+ during: core[1],
1926
+ duringNS: {},
1927
+ after: core[2],
1928
+ afterNS: {}
1929
+ });
1930
+ }
1931
+ function shouldAbort(_ref4, pluginName) {
1932
+ var abort = _ref4.abort;
1933
+ if (!abort)
1934
+ return false;
1935
+ if (abort === true)
1936
+ return true;
1937
+ return includes(abort, pluginName) || abort && includes(abort.plugins, pluginName);
1938
+ }
1939
+ function shouldAbortAll(_ref5, pluginsCount) {
1940
+ var abort = _ref5.abort;
1941
+ if (!abort)
1942
+ return false;
1943
+ if (abort === true || L$1(abort))
1944
+ return true;
1945
+ var plugins = abort.plugins;
1946
+ return isArray(abort) && abort.length === pluginsCount || isArray(plugins) && plugins.length === pluginsCount;
1947
+ }
1948
+ function isArray(arr) {
1949
+ return Array.isArray(arr);
1950
+ }
1951
+ function includes(arr, name) {
1952
+ if (!arr || !isArray(arr))
1953
+ return false;
1954
+ return arr.includes(name);
1955
+ }
1956
+ function argumentFactory(instance, abortablePlugins) {
1957
+ return function(action, plugin, otherPlugin) {
1958
+ var config2 = plugin.config, name = plugin.name;
1959
+ var method = "".concat(name, ".").concat(action.type);
1960
+ if (otherPlugin) {
1961
+ method = otherPlugin.event;
1962
+ }
1963
+ var abortF = action.type.match(endsWithStartRegex) ? abortFunction(name, method, abortablePlugins, otherPlugin, action) : notAbortableError(action, method);
1964
+ return {
1965
+ payload: formatPayload(action),
1966
+ instance,
1967
+ config: config2 || {},
1968
+ abort: abortF
1969
+ };
1970
+ };
1971
+ }
1972
+ function abortFunction(pluginName, method, abortablePlugins, otherPlugin, action) {
1973
+ return function(reason, plugins) {
1974
+ var caller = otherPlugin ? otherPlugin.name : pluginName;
1975
+ var pluginsToAbort = plugins && isArray(plugins) ? plugins : abortablePlugins;
1976
+ if (otherPlugin) {
1977
+ pluginsToAbort = plugins && isArray(plugins) ? plugins : [pluginName];
1978
+ if (!pluginsToAbort.includes(pluginName) || pluginsToAbort.length !== 1) {
1979
+ throw new Error("Method ".concat(method, " can only abort ").concat(pluginName, " plugin. ").concat(JSON.stringify(pluginsToAbort), " input valid"));
1980
+ }
1981
+ }
1982
+ return _objectSpread2$1(_objectSpread2$1({}, action), {}, {
1983
+ abort: {
1984
+ reason,
1985
+ plugins: pluginsToAbort,
1986
+ caller: method,
1987
+ _: caller
1988
+ }
1989
+ });
1990
+ };
1991
+ }
1992
+ function notAbortableError(action, method) {
1993
+ return function() {
1994
+ throw new Error(action.type + " action not cancellable. Remove abort in " + method);
1995
+ };
1996
+ }
1997
+ function validateMethod(actionName, pluginName) {
1998
+ var text = getNameSpacedAction(actionName);
1999
+ var methodCallMatchesPluginNamespace = text && text.name === pluginName;
2000
+ if (methodCallMatchesPluginNamespace) {
2001
+ var sub = getNameSpacedAction(text.method);
2002
+ var subText = sub ? "or " + sub.method : "";
2003
+ throw new Error([pluginName + " plugin is calling method " + actionName, "Plugins cant call self", "Use ".concat(text.method, " ").concat(subText, " in ").concat(pluginName, " plugin insteadof ").concat(actionName)].join("\n"));
2004
+ }
2005
+ }
2006
+ function getNameSpacedAction(event) {
2007
+ var split = event.match(/(.*):(.*)/);
2008
+ if (!split) {
2009
+ return false;
2010
+ }
2011
+ return {
2012
+ method: split[1],
2013
+ name: split[2]
2014
+ };
2015
+ }
2016
+ function formatPayload(action) {
2017
+ return Object.keys(action).reduce(function(acc, key) {
2018
+ if (key === "type") {
2019
+ return acc;
2020
+ }
2021
+ if (M$3(action[key])) {
2022
+ acc[key] = Object.assign({}, action[key]);
2023
+ } else {
2024
+ acc[key] = action[key];
2025
+ }
2026
+ return acc;
2027
+ }, {});
2028
+ }
2029
+ function pluginMiddleware(instance, getPlugins, systemEvents) {
2030
+ var isReady = {};
2031
+ return function(store) {
2032
+ return function(next) {
2033
+ return /* @__PURE__ */ function() {
2034
+ var _ref2 = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee(action) {
2035
+ var type, abort, plugins, updatedAction, allPlugins, pluginsArray, allRegisteredPlugins, completed, failed, disabled, waitForPluginsToLoad, updated;
2036
+ return regenerator.wrap(function _callee$(_context) {
2037
+ while (1) {
2038
+ switch (_context.prev = _context.next) {
2039
+ case 0:
2040
+ type = action.type, abort = action.abort, plugins = action.plugins;
2041
+ updatedAction = action;
2042
+ if (!abort) {
2043
+ _context.next = 4;
2044
+ break;
2045
+ }
2046
+ return _context.abrupt("return", next(action));
2047
+ case 4:
2048
+ if (type === EVENTS$1.enablePlugin) {
2049
+ store.dispatch({
2050
+ type: EVENTS$1.initializeStart,
2051
+ plugins,
2052
+ disabled: [],
2053
+ fromEnable: true,
2054
+ meta: action.meta
2055
+ });
2056
+ }
2057
+ if (type === EVENTS$1.disablePlugin) {
2058
+ setTimeout(function() {
2059
+ return runCallback(action.meta.rid, {
2060
+ payload: action
2061
+ });
2062
+ }, 0);
2063
+ }
2064
+ if (type === EVENTS$1.initializeEnd) {
2065
+ allPlugins = getPlugins();
2066
+ pluginsArray = Object.keys(allPlugins);
2067
+ allRegisteredPlugins = pluginsArray.filter(function(name) {
2068
+ return plugins.includes(name);
2069
+ }).map(function(name) {
2070
+ return allPlugins[name];
2071
+ });
2072
+ completed = [];
2073
+ failed = [];
2074
+ disabled = action.disabled;
2075
+ waitForPluginsToLoad = allRegisteredPlugins.map(function(plugin) {
2076
+ var loaded = plugin.loaded, name = plugin.name;
2077
+ return waitForReady(plugin, loaded, 1e4).then(function(d2) {
2078
+ if (!isReady[name]) {
2079
+ store.dispatch({
2080
+ type: EVENTS$1.pluginReadyType(name),
2081
+ name,
2082
+ events: Object.keys(plugin).filter(function(name2) {
2083
+ return !nonEvents.includes(name2);
2084
+ })
2085
+ });
2086
+ isReady[name] = true;
2087
+ }
2088
+ completed = completed.concat(name);
2089
+ return plugin;
2090
+ })["catch"](function(e2) {
2091
+ if (e2 instanceof Error) {
2092
+ throw new Error(e2);
2093
+ }
2094
+ failed = failed.concat(e2.name);
2095
+ return e2;
2096
+ });
2097
+ });
2098
+ Promise.all(waitForPluginsToLoad).then(function(calls) {
2099
+ var payload = {
2100
+ plugins: completed,
2101
+ failed,
2102
+ disabled
2103
+ };
2104
+ setTimeout(function() {
2105
+ if (pluginsArray.length === waitForPluginsToLoad.length + disabled.length) {
2106
+ store.dispatch(_objectSpread2$1(_objectSpread2$1({}, {
2107
+ type: EVENTS$1.ready
2108
+ }), payload));
2109
+ }
2110
+ }, 0);
2111
+ });
2112
+ }
2113
+ if (!(type !== EVENTS$1.bootstrap)) {
2114
+ _context.next = 13;
2115
+ break;
2116
+ }
2117
+ if (/^ready:([^:]*)$/.test(type)) {
2118
+ setTimeout(function() {
2119
+ return processQueue(store, getPlugins, instance);
2120
+ }, 0);
2121
+ }
2122
+ _context.next = 11;
2123
+ return runPlugins(action, getPlugins, instance, store, systemEvents);
2124
+ case 11:
2125
+ updated = _context.sent;
2126
+ return _context.abrupt("return", next(updated));
2127
+ case 13:
2128
+ return _context.abrupt("return", next(updatedAction));
2129
+ case 14:
2130
+ case "end":
2131
+ return _context.stop();
2132
+ }
2133
+ }
2134
+ }, _callee);
2135
+ }));
2136
+ return function(_x) {
2137
+ return _ref2.apply(this, arguments);
2138
+ };
2139
+ }();
2140
+ };
2141
+ };
2142
+ }
2143
+ function storageMiddleware(storage2) {
2144
+ return function(store) {
2145
+ return function(next) {
2146
+ return function(action) {
2147
+ var type = action.type, key = action.key, value = action.value, options = action.options;
2148
+ if (type === EVENTS$1.setItem || type === EVENTS$1.removeItem) {
2149
+ if (action.abort) {
2150
+ return next(action);
2151
+ }
2152
+ if (type === EVENTS$1.setItem) {
2153
+ storage2.setItem(key, value, options);
2154
+ } else {
2155
+ storage2.removeItem(key, options);
2156
+ }
2157
+ }
2158
+ return next(action);
2159
+ };
2160
+ };
2161
+ };
2162
+ }
2163
+ function _defineProperties(target, props) {
2164
+ for (var i = 0; i < props.length; i++) {
2165
+ var descriptor = props[i];
2166
+ descriptor.enumerable = descriptor.enumerable || false;
2167
+ descriptor.configurable = true;
2168
+ if ("value" in descriptor)
2169
+ descriptor.writable = true;
2170
+ Object.defineProperty(target, descriptor.key, descriptor);
2171
+ }
2172
+ }
2173
+ function _createClass(Constructor, protoProps, staticProps) {
2174
+ if (protoProps)
2175
+ _defineProperties(Constructor.prototype, protoProps);
2176
+ if (staticProps)
2177
+ _defineProperties(Constructor, staticProps);
2178
+ Object.defineProperty(Constructor, "prototype", {
2179
+ writable: false
2180
+ });
2181
+ return Constructor;
2182
+ }
2183
+ function _classCallCheck(instance, Constructor) {
2184
+ if (!(instance instanceof Constructor)) {
2185
+ throw new TypeError("Cannot call a class as a function");
2186
+ }
2187
+ }
2188
+ var DynamicMiddleware = /* @__PURE__ */ _createClass(function DynamicMiddleware2() {
2189
+ var _this = this;
2190
+ _classCallCheck(this, DynamicMiddleware2);
2191
+ _defineProperty$2(this, "before", []);
2192
+ _defineProperty$2(this, "after", []);
2193
+ _defineProperty$2(this, "addMiddleware", function(middlewares, position) {
2194
+ _this[position] = _this[position].concat(middlewares);
2195
+ });
2196
+ _defineProperty$2(this, "removeMiddleware", function(middleware, position) {
2197
+ var index2 = _this[position].findIndex(function(d2) {
2198
+ return d2 === middleware;
2199
+ });
2200
+ if (index2 === -1)
2201
+ return;
2202
+ _this[position] = [].concat(_toConsumableArray(_this[position].slice(0, index2)), _toConsumableArray(_this[position].slice(index2 + 1)));
2203
+ });
2204
+ _defineProperty$2(this, "dynamicMiddlewares", function(position) {
2205
+ return function(store) {
2206
+ return function(next) {
2207
+ return function(action) {
2208
+ var middlewareAPI = {
2209
+ getState: store.getState,
2210
+ dispatch: function dispatch(act) {
2211
+ return store.dispatch(act);
2212
+ }
2213
+ };
2214
+ var chain = _this[position].map(function(middleware) {
2215
+ return middleware(middlewareAPI);
2216
+ });
2217
+ return compose.apply(void 0, _toConsumableArray(chain))(next)(action);
2218
+ };
2219
+ };
2220
+ };
2221
+ });
2222
+ });
2223
+ function createReducer(getPlugins) {
2224
+ return function plugins() {
2225
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2226
+ var action = arguments.length > 1 ? arguments[1] : void 0;
2227
+ var newState = {};
2228
+ if (action.type === "initialize:aborted") {
2229
+ return state;
2230
+ }
2231
+ if (/^registerPlugin:([^:]*)$/.test(action.type)) {
2232
+ var name = getNameFromEventType(action.type, "registerPlugin");
2233
+ var plugin = getPlugins()[name];
2234
+ if (!plugin || !name) {
2235
+ return state;
2236
+ }
2237
+ var isEnabled = action.enabled;
2238
+ newState[name] = {
2239
+ enabled: isEnabled,
2240
+ initialized: isEnabled ? Boolean(!plugin.initialize) : false,
2241
+ loaded: isEnabled ? Boolean(plugin.loaded()) : false,
2242
+ config: plugin.config || {}
2243
+ };
2244
+ return _objectSpread2$1(_objectSpread2$1({}, state), newState);
2245
+ }
2246
+ if (/^initialize:([^:]*)$/.test(action.type)) {
2247
+ var _name = getNameFromEventType(action.type, EVENTS$1.initialize);
2248
+ var _plugin = getPlugins()[_name];
2249
+ if (!_plugin || !_name) {
2250
+ return state;
2251
+ }
2252
+ newState[_name] = _objectSpread2$1(_objectSpread2$1({}, state[_name]), {
2253
+ initialized: true,
2254
+ loaded: Boolean(_plugin.loaded())
2255
+ });
2256
+ return _objectSpread2$1(_objectSpread2$1({}, state), newState);
2257
+ }
2258
+ if (/^ready:([^:]*)$/.test(action.type)) {
2259
+ newState[action.name] = _objectSpread2$1(_objectSpread2$1({}, state[action.name]), {
2260
+ loaded: true
2261
+ });
2262
+ return _objectSpread2$1(_objectSpread2$1({}, state), newState);
2263
+ }
2264
+ switch (action.type) {
2265
+ case EVENTS$1.disablePlugin:
2266
+ return _objectSpread2$1(_objectSpread2$1({}, state), togglePluginStatus(action.plugins, false, state));
2267
+ case EVENTS$1.enablePlugin:
2268
+ return _objectSpread2$1(_objectSpread2$1({}, state), togglePluginStatus(action.plugins, true, state));
2269
+ default:
2270
+ return state;
2271
+ }
2272
+ };
2273
+ }
2274
+ function getNameFromEventType(type, baseName) {
2275
+ return type.substring(baseName.length + 1, type.length);
2276
+ }
2277
+ function togglePluginStatus(plugins, status, currentState) {
2278
+ return plugins.reduce(function(acc, pluginKey) {
2279
+ acc[pluginKey] = _objectSpread2$1(_objectSpread2$1({}, currentState[pluginKey]), {
2280
+ enabled: status
2281
+ });
2282
+ return acc;
2283
+ }, currentState);
2284
+ }
2285
+ function serialize(obj) {
2286
+ try {
2287
+ return JSON.parse(JSON.stringify(obj));
2288
+ } catch (err) {
2289
+ }
2290
+ return obj;
2291
+ }
2292
+ var initialState$3 = {
2293
+ last: {},
2294
+ history: []
2295
+ };
2296
+ function trackReducer() {
2297
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : initialState$3;
2298
+ var action = arguments.length > 1 ? arguments[1] : void 0;
2299
+ var type = action.type, event = action.event, properties = action.properties, options = action.options, meta = action.meta;
2300
+ switch (type) {
2301
+ case EVENTS$1.track:
2302
+ var trackEvent = serialize(_objectSpread2$1(_objectSpread2$1({
2303
+ event,
2304
+ properties
2305
+ }, Object.keys(options).length && {
2306
+ options
2307
+ }), {}, {
2308
+ meta
2309
+ }));
2310
+ return _objectSpread2$1(_objectSpread2$1({}, state), {
2311
+ last: trackEvent,
2312
+ history: state.history.concat(trackEvent)
2313
+ });
2314
+ default:
2315
+ return state;
2316
+ }
2317
+ }
2318
+ var initialState$2 = {
2319
+ actions: []
2320
+ };
2321
+ function queueReducer() {
2322
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : initialState$2;
2323
+ var action = arguments.length > 1 ? arguments[1] : void 0;
2324
+ var type = action.type, payload = action.payload;
2325
+ switch (type) {
2326
+ case "queue":
2327
+ var actionChain;
2328
+ if (payload && payload.type && payload.type === EVENTS$1.identify) {
2329
+ actionChain = [action].concat(state.actions);
2330
+ } else {
2331
+ actionChain = state.actions.concat(action);
2332
+ }
2333
+ return _objectSpread2$1(_objectSpread2$1({}, state), {}, {
2334
+ actions: actionChain
2335
+ });
2336
+ case "dequeue":
2337
+ return [];
2338
+ default:
2339
+ return state;
2340
+ }
2341
+ }
2342
+ var hashRegex = /#.*$/;
2343
+ function canonicalUrl() {
2344
+ if (!z)
2345
+ return;
2346
+ var tags = document.getElementsByTagName("link");
2347
+ for (var i = 0, tag; tag = tags[i]; i++) {
2348
+ if (tag.getAttribute("rel") === "canonical") {
2349
+ return tag.getAttribute("href");
2350
+ }
2351
+ }
2352
+ }
2353
+ function urlPath(url) {
2354
+ var regex = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g;
2355
+ var matches = regex.exec(url);
2356
+ var pathMatch = matches && matches[3] ? matches[3].split("?")[0].replace(hashRegex, "") : "";
2357
+ return "/" + pathMatch;
2358
+ }
2359
+ function currentUrl(search) {
2360
+ var canonical = canonicalUrl();
2361
+ if (!canonical)
2362
+ return window.location.href.replace(hashRegex, "");
2363
+ return canonical.match(/\?/) ? canonical : canonical + search;
2364
+ }
2365
+ var getPageData = function getPageData2() {
2366
+ var pageData = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2367
+ if (!z)
2368
+ return pageData;
2369
+ var _document = document, title = _document.title, referrer2 = _document.referrer;
2370
+ var _window = window, location = _window.location, innerWidth = _window.innerWidth, innerHeight = _window.innerHeight;
2371
+ var hash = location.hash, search = location.search;
2372
+ var url = currentUrl(search);
2373
+ var page2 = {
2374
+ title,
2375
+ url,
2376
+ path: urlPath(url),
2377
+ hash,
2378
+ search,
2379
+ width: innerWidth,
2380
+ height: innerHeight
2381
+ };
2382
+ if (referrer2 && referrer2 !== "") {
2383
+ page2.referrer = referrer2;
2384
+ }
2385
+ return _objectSpread2$1(_objectSpread2$1({}, page2), pageData);
2386
+ };
2387
+ var initialState$1 = {
2388
+ last: {},
2389
+ history: []
2390
+ };
2391
+ function page() {
2392
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : initialState$1;
2393
+ var action = arguments.length > 1 ? arguments[1] : void 0;
2394
+ var properties = action.properties, options = action.options, meta = action.meta;
2395
+ switch (action.type) {
2396
+ case EVENTS$1.page:
2397
+ var viewData = serialize(_objectSpread2$1({
2398
+ properties,
2399
+ meta
2400
+ }, Object.keys(options).length && {
2401
+ options
2402
+ }));
2403
+ return _objectSpread2$1(_objectSpread2$1({}, state), {
2404
+ last: viewData,
2405
+ history: state.history.concat(viewData)
2406
+ });
2407
+ default:
2408
+ return state;
2409
+ }
2410
+ }
2411
+ function getBrowserOS() {
2412
+ if (!z)
2413
+ return false;
2414
+ var os = navigator.appVersion;
2415
+ if (~os.indexOf("Win"))
2416
+ return "Windows";
2417
+ if (~os.indexOf("Mac"))
2418
+ return "MacOS";
2419
+ if (~os.indexOf("X11"))
2420
+ return "UNIX";
2421
+ if (~os.indexOf("Linux"))
2422
+ return "Linux";
2423
+ return "Unknown OS";
2424
+ }
2425
+ var osName;
2426
+ var referrer;
2427
+ var locale;
2428
+ var timeZone;
2429
+ {
2430
+ osName = getBrowserOS();
2431
+ referrer = z ? document.referrer : null;
2432
+ locale = o$9();
2433
+ timeZone = a$5();
2434
+ }
2435
+ var initialState = {
2436
+ initialized: false,
2437
+ sessionId: y$1(),
2438
+ app: null,
2439
+ version: null,
2440
+ debug: false,
2441
+ offline: z ? !navigator.onLine : false,
2442
+ os: {
2443
+ name: osName
2444
+ },
2445
+ userAgent: z ? navigator.userAgent : "node",
2446
+ library: {
2447
+ name: LIB_NAME,
2448
+ version: "0.10.22"
2449
+ },
2450
+ timezone: timeZone,
2451
+ locale,
2452
+ campaign: {},
2453
+ referrer
2454
+ };
2455
+ function context() {
2456
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : initialState;
2457
+ var action = arguments.length > 1 ? arguments[1] : void 0;
2458
+ var initialized = state.initialized;
2459
+ var type = action.type, campaign = action.campaign;
2460
+ switch (type) {
2461
+ case EVENTS$1.campaign:
2462
+ return _objectSpread2$1(_objectSpread2$1({}, state), {
2463
+ campaign
2464
+ });
2465
+ case EVENTS$1.offline:
2466
+ return _objectSpread2$1(_objectSpread2$1({}, state), {
2467
+ offline: true
2468
+ });
2469
+ case EVENTS$1.online:
2470
+ return _objectSpread2$1(_objectSpread2$1({}, state), {
2471
+ offline: false
2472
+ });
2473
+ default:
2474
+ if (!initialized) {
2475
+ return _objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, initialState), state), {
2476
+ initialized: true
2477
+ });
2478
+ }
2479
+ return state;
2480
+ }
2481
+ }
2482
+ var excludeItems = ["plugins", "reducers", "storage"];
2483
+ function makeContext(config2) {
2484
+ return Object.keys(config2).reduce(function(acc, current) {
2485
+ if (excludeItems.includes(current)) {
2486
+ return acc;
2487
+ }
2488
+ acc[current] = config2[current];
2489
+ return acc;
2490
+ }, {});
2491
+ }
2492
+ function listen(events, func, toAdd) {
2493
+ if (!z)
2494
+ return;
2495
+ var fn = window[(toAdd ? "add" : "remove") + "EventListener"];
2496
+ events.split(" ").forEach(function(ev) {
2497
+ fn(ev, func);
2498
+ });
2499
+ }
2500
+ function check() {
2501
+ return Promise.resolve(!navigator.onLine);
2502
+ }
2503
+ function watch(cb) {
2504
+ var fn = function fn2(_2) {
2505
+ return check().then(cb);
2506
+ };
2507
+ var listener = listen.bind(null, "online offline", fn);
2508
+ listener(true);
2509
+ return function(_2) {
2510
+ return listener(false);
2511
+ };
2512
+ }
2513
+ function Debug() {
2514
+ f$5(LIB_NAME, []);
2515
+ return function(createStore2) {
2516
+ return function(reducer, preloadedState, enhancer) {
2517
+ var store = createStore2(reducer, preloadedState, enhancer);
2518
+ var origDispatch = store.dispatch;
2519
+ var dispatch = function dispatch2(action) {
2520
+ var a2 = action.action || action;
2521
+ n$5[o$7][LIB_NAME].push(a2);
2522
+ return origDispatch(action);
2523
+ };
2524
+ return Object.assign(store, {
2525
+ dispatch
2526
+ });
2527
+ };
2528
+ };
2529
+ }
2530
+ function composeWithDebug(config2) {
2531
+ return function() {
2532
+ return compose(compose.apply(null, arguments), Debug());
2533
+ };
2534
+ }
2535
+ function ensureArray(singleOrArray) {
2536
+ if (!singleOrArray)
2537
+ return [];
2538
+ if (G(singleOrArray))
2539
+ return singleOrArray;
2540
+ return [singleOrArray];
2541
+ }
2542
+ function getCallbackFromArgs(argArray) {
2543
+ var args = argArray || Array.prototype.slice.call(arguments);
2544
+ var cb;
2545
+ for (var i = 0; i < args.length; i++) {
2546
+ if (_(args[i])) {
2547
+ cb = args[i];
2548
+ break;
2549
+ }
2550
+ }
2551
+ return cb;
2552
+ }
2553
+ function timeStamp() {
2554
+ return new Date().getTime();
2555
+ }
2556
+ function deferredPromiseResolver(resolver, callback) {
2557
+ return function(data) {
2558
+ if (callback)
2559
+ callback(data);
2560
+ resolver(data);
2561
+ };
2562
+ }
2563
+ function generateMeta() {
2564
+ var meta = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2565
+ var resolve = arguments.length > 1 ? arguments[1] : void 0;
2566
+ var possibleCallbacks = arguments.length > 2 ? arguments[2] : void 0;
2567
+ var rid = y$1();
2568
+ if (resolve) {
2569
+ stack[rid] = deferredPromiseResolver(resolve, getCallbackFromArgs(possibleCallbacks));
2570
+ }
2571
+ return _objectSpread2$1(_objectSpread2$1({}, meta), {}, {
2572
+ rid,
2573
+ ts: timeStamp()
2574
+ }, !resolve ? {} : {
2575
+ hasCallback: true
2576
+ });
2577
+ }
2578
+ function analytics() {
2579
+ var config2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2580
+ var customReducers = config2.reducers || {};
2581
+ var initialUser = config2.initialUser || {};
2582
+ var parsedOptions = (config2.plugins || []).reduce(function(acc, plugin) {
2583
+ if (_(plugin)) {
2584
+ acc.middlewares = acc.middlewares.concat(plugin);
2585
+ return acc;
2586
+ }
2587
+ if (plugin.NAMESPACE)
2588
+ plugin.name = plugin.NAMESPACE;
2589
+ if (!plugin.name) {
2590
+ throw new Error(ERROR_URL + "1");
2591
+ }
2592
+ var definedEvents = plugin.EVENTS ? Object.keys(plugin.EVENTS).map(function(k2) {
2593
+ return plugin.EVENTS[k2];
2594
+ }) : [];
2595
+ var enabledFromMerge = !(plugin.enabled === false);
2596
+ var enabledFromPluginConfig = !(plugin.config && plugin.config.enabled === false);
2597
+ acc.pluginEnabled[plugin.name] = enabledFromMerge && enabledFromPluginConfig;
2598
+ delete plugin.enabled;
2599
+ if (plugin.methods) {
2600
+ acc.methods[plugin.name] = Object.keys(plugin.methods).reduce(function(a2, c2) {
2601
+ a2[c2] = appendArguments(plugin.methods[c2]);
2602
+ return a2;
2603
+ }, {});
2604
+ delete plugin.methods;
2605
+ }
2606
+ var methodsToEvents = Object.keys(plugin);
2607
+ var allEvents = methodsToEvents.concat(definedEvents);
2608
+ var allEventsUnique = new Set(acc.events.concat(allEvents));
2609
+ acc.events = Array.from(allEventsUnique);
2610
+ acc.pluginsArray = acc.pluginsArray.concat(plugin);
2611
+ if (acc.plugins[plugin.name]) {
2612
+ throw new Error(plugin.name + "AlreadyLoaded");
2613
+ }
2614
+ acc.plugins[plugin.name] = plugin;
2615
+ if (!acc.plugins[plugin.name].loaded) {
2616
+ acc.plugins[plugin.name].loaded = function() {
2617
+ return true;
2618
+ };
2619
+ }
2620
+ return acc;
2621
+ }, {
2622
+ plugins: {},
2623
+ pluginEnabled: {},
2624
+ methods: {},
2625
+ pluginsArray: [],
2626
+ middlewares: [],
2627
+ events: []
2628
+ });
2629
+ var storage2 = config2.storage ? config2.storage : {
2630
+ getItem: a$4,
2631
+ setItem: f$5,
2632
+ removeItem: i$5
2633
+ };
2634
+ var getUserProp = getUserPropFunc(storage2);
2635
+ var customPlugins = parsedOptions.plugins;
2636
+ var allPluginEvents = parsedOptions.events.filter(function(name) {
2637
+ return !nonEvents.includes(name);
2638
+ }).sort();
2639
+ var uniqueEvents = new Set(allPluginEvents.concat(coreEvents).filter(function(name) {
2640
+ return !nonEvents.includes(name);
2641
+ }));
2642
+ var allSystemEvents = Array.from(uniqueEvents).sort();
2643
+ var getPlugins = function getPlugins2() {
2644
+ return customPlugins;
2645
+ };
2646
+ var _DynamicMiddleware = new DynamicMiddleware(), addMiddleware = _DynamicMiddleware.addMiddleware, removeMiddleware = _DynamicMiddleware.removeMiddleware, dynamicMiddlewares = _DynamicMiddleware.dynamicMiddlewares;
2647
+ var nonAbortable = function nonAbortable2() {
2648
+ throw new Error("Abort disabled inListener");
2649
+ };
2650
+ var params = s();
2651
+ var persistedUser = getPersistedUserData(storage2);
2652
+ var visitorInfo = _objectSpread2$1(_objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, persistedUser), initialUser), !params.an_uid ? {} : {
2653
+ userId: params.an_uid
2654
+ }), !params.an_aid ? {} : {
2655
+ anonymousId: params.an_aid
2656
+ });
2657
+ if (!visitorInfo.anonymousId) {
2658
+ visitorInfo.anonymousId = y$1();
2659
+ }
2660
+ var plugins = _objectSpread2$1({
2661
+ enable: function enable(plugins2, callback) {
2662
+ return new Promise(function(resolve) {
2663
+ store.dispatch({
2664
+ type: EVENTS$1.enablePlugin,
2665
+ plugins: ensureArray(plugins2),
2666
+ _: {
2667
+ originalAction: EVENTS$1.enablePlugin
2668
+ }
2669
+ }, resolve, [callback]);
2670
+ });
2671
+ },
2672
+ disable: function disable(plugins2, callback) {
2673
+ return new Promise(function(resolve) {
2674
+ store.dispatch({
2675
+ type: EVENTS$1.disablePlugin,
2676
+ plugins: ensureArray(plugins2),
2677
+ _: {
2678
+ originalAction: EVENTS$1.disablePlugin
2679
+ }
2680
+ }, resolve, [callback]);
2681
+ });
2682
+ }
2683
+ }, parsedOptions.methods);
2684
+ var instance = {
2685
+ identify: function() {
2686
+ var _identify = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee(userId, traits, options, callback) {
2687
+ var id, data, opts, user, resolvedId;
2688
+ return regenerator.wrap(function _callee$(_context) {
2689
+ while (1) {
2690
+ switch (_context.prev = _context.next) {
2691
+ case 0:
2692
+ id = L$1(userId) ? userId : null;
2693
+ data = M$3(userId) ? userId : traits;
2694
+ opts = options || {};
2695
+ user = instance.user();
2696
+ f$5(tempKey(ID), id);
2697
+ resolvedId = id || data.userId || getUserProp(ID, instance, data);
2698
+ return _context.abrupt("return", new Promise(function(resolve) {
2699
+ store.dispatch(_objectSpread2$1({
2700
+ type: EVENTS$1.identifyStart,
2701
+ userId: resolvedId,
2702
+ traits: data || {},
2703
+ options: opts,
2704
+ anonymousId: user.anonymousId
2705
+ }, user.id && user.id !== id && {
2706
+ previousId: user.id
2707
+ }), resolve, [traits, options, callback]);
2708
+ }));
2709
+ case 7:
2710
+ case "end":
2711
+ return _context.stop();
2712
+ }
2713
+ }
2714
+ }, _callee);
2715
+ }));
2716
+ function identify(_x, _x2, _x3, _x4) {
2717
+ return _identify.apply(this, arguments);
2718
+ }
2719
+ return identify;
2720
+ }(),
2721
+ track: function() {
2722
+ var _track = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee2(eventName, payload, options, callback) {
2723
+ var name, data, opts;
2724
+ return regenerator.wrap(function _callee2$(_context2) {
2725
+ while (1) {
2726
+ switch (_context2.prev = _context2.next) {
2727
+ case 0:
2728
+ name = M$3(eventName) ? eventName.event : eventName;
2729
+ if (!(!name || !L$1(name))) {
2730
+ _context2.next = 3;
2731
+ break;
2732
+ }
2733
+ throw new Error("EventMissing");
2734
+ case 3:
2735
+ data = M$3(eventName) ? eventName : payload || {};
2736
+ opts = M$3(options) ? options : {};
2737
+ return _context2.abrupt("return", new Promise(function(resolve) {
2738
+ store.dispatch({
2739
+ type: EVENTS$1.trackStart,
2740
+ event: name,
2741
+ properties: data,
2742
+ options: opts,
2743
+ userId: getUserProp(ID, instance, payload),
2744
+ anonymousId: getUserProp(ANONID, instance, payload)
2745
+ }, resolve, [payload, options, callback]);
2746
+ }));
2747
+ case 6:
2748
+ case "end":
2749
+ return _context2.stop();
2750
+ }
2751
+ }
2752
+ }, _callee2);
2753
+ }));
2754
+ function track(_x5, _x6, _x7, _x8) {
2755
+ return _track.apply(this, arguments);
2756
+ }
2757
+ return track;
2758
+ }(),
2759
+ page: function() {
2760
+ var _page = _asyncToGenerator(/* @__PURE__ */ regenerator.mark(function _callee3(data, options, callback) {
2761
+ var d2, opts;
2762
+ return regenerator.wrap(function _callee3$(_context3) {
2763
+ while (1) {
2764
+ switch (_context3.prev = _context3.next) {
2765
+ case 0:
2766
+ d2 = M$3(data) ? data : {};
2767
+ opts = M$3(options) ? options : {};
2768
+ return _context3.abrupt("return", new Promise(function(resolve) {
2769
+ store.dispatch({
2770
+ type: EVENTS$1.pageStart,
2771
+ properties: getPageData(d2),
2772
+ options: opts,
2773
+ userId: getUserProp(ID, instance, d2),
2774
+ anonymousId: getUserProp(ANONID, instance, d2)
2775
+ }, resolve, [data, options, callback]);
2776
+ }));
2777
+ case 3:
2778
+ case "end":
2779
+ return _context3.stop();
2780
+ }
2781
+ }
2782
+ }, _callee3);
2783
+ }));
2784
+ function page2(_x9, _x10, _x11) {
2785
+ return _page.apply(this, arguments);
2786
+ }
2787
+ return page2;
2788
+ }(),
2789
+ user: function user(key) {
2790
+ if (key === ID || key === "id") {
2791
+ return getUserProp(ID, instance);
2792
+ }
2793
+ if (key === ANONID || key === "anonId") {
2794
+ return getUserProp(ANONID, instance);
2795
+ }
2796
+ var user2 = instance.getState("user");
2797
+ if (!key)
2798
+ return user2;
2799
+ return dotProp(user2, key);
2800
+ },
2801
+ reset: function reset(callback) {
2802
+ return new Promise(function(resolve) {
2803
+ store.dispatch({
2804
+ type: EVENTS$1.resetStart
2805
+ }, resolve, callback);
2806
+ });
2807
+ },
2808
+ ready: function ready(callback) {
2809
+ return instance.on(EVENTS$1.ready, callback);
2810
+ },
2811
+ on: function on(name, callback) {
2812
+ if (!name || !_(callback)) {
2813
+ return false;
2814
+ }
2815
+ if (name === EVENTS$1.bootstrap) {
2816
+ throw new Error(".on disabled for " + name);
2817
+ }
2818
+ var startRegex = /Start$|Start:/;
2819
+ if (name === "*") {
2820
+ var beforeHandler = function beforeHandler2(store2) {
2821
+ return function(next) {
2822
+ return function(action) {
2823
+ if (action.type.match(startRegex)) {
2824
+ callback({
2825
+ payload: action,
2826
+ instance,
2827
+ plugins: customPlugins
2828
+ });
2829
+ }
2830
+ return next(action);
2831
+ };
2832
+ };
2833
+ };
2834
+ var afterHandler = function afterHandler2(store2) {
2835
+ return function(next) {
2836
+ return function(action) {
2837
+ if (!action.type.match(startRegex)) {
2838
+ callback({
2839
+ payload: action,
2840
+ instance,
2841
+ plugins: customPlugins
2842
+ });
2843
+ }
2844
+ return next(action);
2845
+ };
2846
+ };
2847
+ };
2848
+ addMiddleware(beforeHandler, before);
2849
+ addMiddleware(afterHandler, after);
2850
+ return function() {
2851
+ removeMiddleware(beforeHandler, before);
2852
+ removeMiddleware(afterHandler, after);
2853
+ };
2854
+ }
2855
+ var position = name.match(startRegex) ? before : after;
2856
+ var handler = function handler2(store2) {
2857
+ return function(next) {
2858
+ return function(action) {
2859
+ if (action.type === name) {
2860
+ callback({
2861
+ payload: action,
2862
+ instance,
2863
+ plugins: customPlugins,
2864
+ abort: nonAbortable
2865
+ });
2866
+ }
2867
+ return next(action);
2868
+ };
2869
+ };
2870
+ };
2871
+ addMiddleware(handler, position);
2872
+ return function() {
2873
+ return removeMiddleware(handler, position);
2874
+ };
2875
+ },
2876
+ once: function once(name, callback) {
2877
+ if (!name || !_(callback)) {
2878
+ return false;
2879
+ }
2880
+ if (name === EVENTS$1.bootstrap) {
2881
+ throw new Error(".once disabled for " + name);
2882
+ }
2883
+ var detachListener = instance.on(name, function(_ref2) {
2884
+ var payload = _ref2.payload;
2885
+ callback({
2886
+ payload,
2887
+ instance,
2888
+ plugins: customPlugins,
2889
+ abort: nonAbortable
2890
+ });
2891
+ detachListener();
2892
+ });
2893
+ return detachListener;
2894
+ },
2895
+ getState: function getState(key) {
2896
+ var state = store.getState();
2897
+ if (key)
2898
+ return dotProp(state, key);
2899
+ return Object.assign({}, state);
2900
+ },
2901
+ dispatch: function dispatch(action) {
2902
+ var actionData = L$1(action) ? {
2903
+ type: action
2904
+ } : action;
2905
+ if (isReservedAction(actionData.type)) {
2906
+ throw new Error("reserved action " + actionData.type);
2907
+ }
2908
+ var _private = action._ || {};
2909
+ var dispatchData = _objectSpread2$1(_objectSpread2$1({}, actionData), {}, {
2910
+ _: _objectSpread2$1({
2911
+ originalAction: actionData.type
2912
+ }, _private)
2913
+ });
2914
+ store.dispatch(dispatchData);
2915
+ },
2916
+ enablePlugin: plugins.enable,
2917
+ disablePlugin: plugins.disable,
2918
+ plugins,
2919
+ storage: {
2920
+ getItem: storage2.getItem,
2921
+ setItem: function setItem(key, value, options) {
2922
+ store.dispatch({
2923
+ type: EVENTS$1.setItemStart,
2924
+ key,
2925
+ value,
2926
+ options
2927
+ });
2928
+ },
2929
+ removeItem: function removeItem(key, options) {
2930
+ store.dispatch({
2931
+ type: EVENTS$1.removeItemStart,
2932
+ key,
2933
+ options
2934
+ });
2935
+ }
2936
+ },
2937
+ setAnonymousId: function setAnonymousId(anonymousId, options) {
2938
+ instance.storage.setItem(ANON_ID, anonymousId, options);
2939
+ },
2940
+ events: {
2941
+ all: allSystemEvents,
2942
+ core: coreEvents,
2943
+ plugins: allPluginEvents
2944
+ }
2945
+ };
2946
+ var enrichMiddleware = function enrichMiddleware2(storeAPI) {
2947
+ return function(next) {
2948
+ return function(action) {
2949
+ if (!action.meta) {
2950
+ action.meta = generateMeta();
2951
+ }
2952
+ return next(action);
2953
+ };
2954
+ };
2955
+ };
2956
+ var middlewares = parsedOptions.middlewares.concat([
2957
+ enrichMiddleware,
2958
+ dynamicMiddlewares(before),
2959
+ pluginMiddleware(instance, getPlugins, {
2960
+ all: allSystemEvents,
2961
+ plugins: allPluginEvents
2962
+ }),
2963
+ storageMiddleware(storage2),
2964
+ initializeMiddleware(instance),
2965
+ identifyMiddleware(instance),
2966
+ dynamicMiddlewares(after)
2967
+ ]);
2968
+ var coreReducers = {
2969
+ context,
2970
+ user: userReducer(storage2),
2971
+ page,
2972
+ track: trackReducer,
2973
+ plugins: createReducer(getPlugins),
2974
+ queue: queueReducer
2975
+ };
2976
+ var composeEnhancers = compose;
2977
+ var composeWithGlobalDebug = compose;
2978
+ if (z && config2.debug) {
2979
+ var devTools = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
2980
+ if (devTools) {
2981
+ composeEnhancers = devTools({
2982
+ trace: true,
2983
+ traceLimit: 25
2984
+ });
2985
+ }
2986
+ composeWithGlobalDebug = function composeWithGlobalDebug2() {
2987
+ if (arguments.length === 0)
2988
+ return Debug();
2989
+ if (M$3(_typeof(arguments[0])))
2990
+ return composeWithDebug();
2991
+ return composeWithDebug().apply(null, arguments);
2992
+ };
2993
+ }
2994
+ var initialConfig = makeContext(config2);
2995
+ var intialPluginState = parsedOptions.pluginsArray.reduce(function(acc, plugin) {
2996
+ var name = plugin.name, config3 = plugin.config, loaded = plugin.loaded;
2997
+ var isEnabled = parsedOptions.pluginEnabled[name];
2998
+ acc[name] = {
2999
+ enabled: isEnabled,
3000
+ initialized: isEnabled ? Boolean(!plugin.initialize) : false,
3001
+ loaded: Boolean(loaded()),
3002
+ config: config3 || {}
3003
+ };
3004
+ return acc;
3005
+ }, {});
3006
+ var initialState2 = {
3007
+ context: initialConfig,
3008
+ user: visitorInfo,
3009
+ plugins: intialPluginState
3010
+ };
3011
+ var store = createStore(combineReducers(_objectSpread2$1(_objectSpread2$1({}, coreReducers), customReducers)), initialState2, composeWithGlobalDebug(composeEnhancers(applyMiddleware.apply(void 0, _toConsumableArray(middlewares)))));
3012
+ function enhanceDispatch(fn) {
3013
+ return function(event, resolver, callbacks) {
3014
+ var meta = generateMeta(event.meta, resolver, ensureArray(callbacks));
3015
+ var newEvent = _objectSpread2$1(_objectSpread2$1({}, event), {
3016
+ meta
3017
+ });
3018
+ return fn.apply(null, [newEvent]);
3019
+ };
3020
+ }
3021
+ store.dispatch = enhanceDispatch(store.dispatch);
3022
+ var pluginKeys = Object.keys(customPlugins);
3023
+ store.dispatch({
3024
+ type: EVENTS$1.bootstrap,
3025
+ plugins: pluginKeys,
3026
+ config: initialConfig,
3027
+ params,
3028
+ user: visitorInfo,
3029
+ initialUser,
3030
+ persistedUser
3031
+ });
3032
+ var enabledPlugins = pluginKeys.filter(function(name) {
3033
+ return parsedOptions.pluginEnabled[name];
3034
+ });
3035
+ var disabledPlugins = pluginKeys.filter(function(name) {
3036
+ return !parsedOptions.pluginEnabled[name];
3037
+ });
3038
+ store.dispatch({
3039
+ type: EVENTS$1.registerPlugins,
3040
+ plugins: pluginKeys,
3041
+ enabled: parsedOptions.pluginEnabled
3042
+ });
3043
+ parsedOptions.pluginsArray.map(function(plugin, i) {
3044
+ var bootstrap = plugin.bootstrap, config3 = plugin.config, name = plugin.name;
3045
+ if (bootstrap && _(bootstrap)) {
3046
+ bootstrap({
3047
+ instance,
3048
+ config: config3,
3049
+ payload: plugin
3050
+ });
3051
+ }
3052
+ store.dispatch({
3053
+ type: EVENTS$1.registerPluginType(name),
3054
+ name,
3055
+ enabled: parsedOptions.pluginEnabled[name],
3056
+ plugin
3057
+ });
3058
+ if (parsedOptions.pluginsArray.length === i + 1) {
3059
+ store.dispatch({
3060
+ type: EVENTS$1.initializeStart,
3061
+ plugins: enabledPlugins,
3062
+ disabled: disabledPlugins
3063
+ });
3064
+ }
3065
+ });
3066
+ {
3067
+ watch(function(offline) {
3068
+ store.dispatch({
3069
+ type: offline ? EVENTS$1.offline : EVENTS$1.online
3070
+ });
3071
+ });
3072
+ heartBeat(store, getPlugins, instance);
3073
+ }
3074
+ function appendArguments(fn) {
3075
+ return function() {
3076
+ var args = Array.prototype.slice.call(arguments);
3077
+ var newArgs = new Array(fn.length);
3078
+ for (var i = 0; i < args.length; i++) {
3079
+ newArgs[i] = args[i];
3080
+ }
3081
+ newArgs[newArgs.length] = instance;
3082
+ return fn.apply({
3083
+ instance
3084
+ }, newArgs);
3085
+ };
3086
+ }
3087
+ return instance;
3088
+ }
3089
+ var before = "before";
3090
+ var after = "after";
3091
+ var o$6 = "object", j$2 = "__", F$2 = typeof process != "undefined" ? process : {};
3092
+ F$2.env && F$2.env.NODE_ENV || "";
3093
+ var $$2 = typeof window != "undefined";
3094
+ F$2.versions != null && F$2.versions.node != null;
3095
+ typeof Deno != "undefined" && Deno.core !== void 0;
3096
+ $$2 && window.name === "nodejs" || typeof navigator != "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
3097
+ function M$2(n2, t2) {
3098
+ return t2.charAt(0)[n2]() + t2.slice(1);
3099
+ }
3100
+ var U$2 = M$2.bind(null, "toUpperCase"), H$2 = M$2.bind(null, "toLowerCase");
3101
+ function J$2(n2) {
3102
+ return Y$2(n2) ? U$2("null") : typeof n2 == "object" ? yn$2(n2) : Object.prototype.toString.call(n2).slice(8, -1);
3103
+ }
3104
+ function R$2(n2, t2) {
3105
+ t2 === void 0 && (t2 = true);
3106
+ var e2 = J$2(n2);
3107
+ return t2 ? H$2(e2) : e2;
3108
+ }
3109
+ function V$2(n2, t2) {
3110
+ return typeof t2 === n2;
3111
+ }
3112
+ var W$2 = V$2.bind(null, "function"), q$2 = V$2.bind(null, "string");
3113
+ V$2.bind(null, "undefined");
3114
+ V$2.bind(null, "boolean");
3115
+ V$2.bind(null, "symbol");
3116
+ function Y$2(n2) {
3117
+ return n2 === null;
3118
+ }
3119
+ function nn$2(n2) {
3120
+ return R$2(n2) === "number" && !isNaN(n2);
3121
+ }
3122
+ function yn$2(n2) {
3123
+ return W$2(n2.constructor) ? n2.constructor.name : null;
3124
+ }
3125
+ function hn$2(n2) {
3126
+ return n2 instanceof Error || q$2(n2.message) && n2.constructor && nn$2(n2.constructor.stackTraceLimit);
3127
+ }
3128
+ function On$2(n2, t2) {
3129
+ if (typeof t2 != "object" || Y$2(t2))
3130
+ return false;
3131
+ if (t2 instanceof n2)
3132
+ return true;
3133
+ var e2 = R$2(new n2(""));
3134
+ if (hn$2(t2))
3135
+ for (; t2; ) {
3136
+ if (R$2(t2) === e2)
3137
+ return true;
3138
+ t2 = Object.getPrototypeOf(t2);
3139
+ }
3140
+ return false;
3141
+ }
3142
+ On$2.bind(null, TypeError);
3143
+ On$2.bind(null, SyntaxError);
3144
+ function $n$2(n2, t2) {
3145
+ var e2 = n2 instanceof Element || n2 instanceof HTMLDocument;
3146
+ return e2 && t2 ? Tn$2(n2, t2) : e2;
3147
+ }
3148
+ function Tn$2(n2, t2) {
3149
+ return t2 === void 0 && (t2 = ""), n2 && n2.nodeName === t2.toUpperCase();
3150
+ }
3151
+ function _n$2(n2) {
3152
+ var t2 = [].slice.call(arguments, 1);
3153
+ return function() {
3154
+ return n2.apply(void 0, [].slice.call(arguments).concat(t2));
3155
+ };
3156
+ }
3157
+ _n$2($n$2, "form");
3158
+ _n$2($n$2, "button");
3159
+ _n$2($n$2, "input");
3160
+ _n$2($n$2, "select");
3161
+ var l$1 = "global", o$5 = j$2 + "global" + j$2, n$3 = typeof self === o$6 && self.self === self && self || typeof global === o$6 && global.global === global && global || void 0;
3162
+ function a$3(t2) {
3163
+ return n$3[o$5][t2];
3164
+ }
3165
+ function f$3(t2, e2) {
3166
+ return n$3[o$5][t2] = e2;
3167
+ }
3168
+ function i$4(t2) {
3169
+ delete n$3[o$5][t2];
3170
+ }
3171
+ n$3[o$5] || (n$3[o$5] = {});
3172
+ var o$4 = "object", j$1 = "__", F$1 = typeof process != "undefined" ? process : {};
3173
+ F$1.env && F$1.env.NODE_ENV || "";
3174
+ var $$1 = typeof window != "undefined";
3175
+ F$1.versions != null && F$1.versions.node != null;
3176
+ typeof Deno != "undefined" && Deno.core !== void 0;
3177
+ $$1 && window.name === "nodejs" || typeof navigator != "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
3178
+ function M$1(n2, t2) {
3179
+ return t2.charAt(0)[n2]() + t2.slice(1);
3180
+ }
3181
+ var U$1 = M$1.bind(null, "toUpperCase"), H$1 = M$1.bind(null, "toLowerCase");
3182
+ function J$1(n2) {
3183
+ return Y$1(n2) ? U$1("null") : typeof n2 == "object" ? yn$1(n2) : Object.prototype.toString.call(n2).slice(8, -1);
3184
+ }
3185
+ function R$1(n2, t2) {
3186
+ t2 === void 0 && (t2 = true);
3187
+ var e2 = J$1(n2);
3188
+ return t2 ? H$1(e2) : e2;
3189
+ }
3190
+ function V$1(n2, t2) {
3191
+ return typeof t2 === n2;
3192
+ }
3193
+ var W$1 = V$1.bind(null, "function"), q$1 = V$1.bind(null, "string");
3194
+ V$1.bind(null, "undefined");
3195
+ V$1.bind(null, "boolean");
3196
+ V$1.bind(null, "symbol");
3197
+ function Y$1(n2) {
3198
+ return n2 === null;
3199
+ }
3200
+ function nn$1(n2) {
3201
+ return R$1(n2) === "number" && !isNaN(n2);
3202
+ }
3203
+ function yn$1(n2) {
3204
+ return W$1(n2.constructor) ? n2.constructor.name : null;
3205
+ }
3206
+ function hn$1(n2) {
3207
+ return n2 instanceof Error || q$1(n2.message) && n2.constructor && nn$1(n2.constructor.stackTraceLimit);
3208
+ }
3209
+ function On$1(n2, t2) {
3210
+ if (typeof t2 != "object" || Y$1(t2))
3211
+ return false;
3212
+ if (t2 instanceof n2)
3213
+ return true;
3214
+ var e2 = R$1(new n2(""));
3215
+ if (hn$1(t2))
3216
+ for (; t2; ) {
3217
+ if (R$1(t2) === e2)
3218
+ return true;
3219
+ t2 = Object.getPrototypeOf(t2);
3220
+ }
3221
+ return false;
3222
+ }
3223
+ On$1.bind(null, TypeError);
3224
+ On$1.bind(null, SyntaxError);
3225
+ function $n$1(n2, t2) {
3226
+ var e2 = n2 instanceof Element || n2 instanceof HTMLDocument;
3227
+ return e2 && t2 ? Tn$1(n2, t2) : e2;
3228
+ }
3229
+ function Tn$1(n2, t2) {
3230
+ return t2 === void 0 && (t2 = ""), n2 && n2.nodeName === t2.toUpperCase();
3231
+ }
3232
+ function _n$1(n2) {
3233
+ var t2 = [].slice.call(arguments, 1);
3234
+ return function() {
3235
+ return n2.apply(void 0, [].slice.call(arguments).concat(t2));
3236
+ };
3237
+ }
3238
+ _n$1($n$1, "form");
3239
+ _n$1($n$1, "button");
3240
+ _n$1($n$1, "input");
3241
+ _n$1($n$1, "select");
3242
+ var o$3 = j$1 + "global" + j$1, n$2 = typeof self === o$4 && self.self === self && self || typeof global === o$4 && global.global === global && global || void 0;
3243
+ function a$2(t2) {
3244
+ return n$2[o$3][t2];
3245
+ }
3246
+ function f$2(t2, e2) {
3247
+ return n$2[o$3][t2] = e2;
3248
+ }
3249
+ function i$3(t2) {
3250
+ delete n$2[o$3][t2];
3251
+ }
3252
+ n$2[o$3] || (n$2[o$3] = {});
3253
+ var t = "cookie", i$2 = a$1(), r$1 = d$1, c$1 = d$1;
3254
+ function u$1(o2) {
3255
+ return i$2 ? d$1(o2, "", -1) : i$3(o2);
3256
+ }
3257
+ function a$1() {
3258
+ if (i$2 !== void 0)
3259
+ return i$2;
3260
+ var e2 = "cookiecookie";
3261
+ try {
3262
+ d$1(e2, e2), i$2 = document.cookie.indexOf(e2) !== -1, u$1(e2);
3263
+ } catch (e3) {
3264
+ i$2 = false;
3265
+ }
3266
+ return i$2;
3267
+ }
3268
+ function d$1(e2, t2, r2, c2, u2, a2) {
3269
+ if (typeof window != "undefined") {
3270
+ var d2 = arguments.length > 1;
3271
+ return i$2 === false && (d2 ? f$2(e2, t2) : a$2(e2)), d2 ? document.cookie = e2 + "=" + encodeURIComponent(t2) + (r2 ? "; expires=" + new Date(+new Date() + 1e3 * r2).toUTCString() + (c2 ? "; path=" + c2 : "") + (u2 ? "; domain=" + u2 : "") + (a2 ? "; secure" : "") : "") : decodeURIComponent((("; " + document.cookie).split("; " + e2 + "=")[1] || "").split(";")[0]);
3272
+ }
3273
+ }
3274
+ var e$1 = "undefined", o$2 = "object", j = "__", F = typeof process != "undefined" ? process : {};
3275
+ F.env && F.env.NODE_ENV || "";
3276
+ var $ = typeof window != "undefined";
3277
+ F.versions != null && F.versions.node != null;
3278
+ typeof Deno != "undefined" && Deno.core !== void 0;
3279
+ $ && window.name === "nodejs" || typeof navigator != "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
3280
+ function M(n2, t2) {
3281
+ return t2.charAt(0)[n2]() + t2.slice(1);
3282
+ }
3283
+ var U = M.bind(null, "toUpperCase"), H = M.bind(null, "toLowerCase");
3284
+ function J(n2) {
3285
+ return Y(n2) ? U("null") : typeof n2 == "object" ? yn(n2) : Object.prototype.toString.call(n2).slice(8, -1);
3286
+ }
3287
+ function R(n2, t2) {
3288
+ t2 === void 0 && (t2 = true);
3289
+ var e2 = J(n2);
3290
+ return t2 ? H(e2) : e2;
3291
+ }
3292
+ function V(n2, t2) {
3293
+ return typeof t2 === n2;
3294
+ }
3295
+ var W = V.bind(null, "function"), q = V.bind(null, "string");
3296
+ V.bind(null, "undefined");
3297
+ V.bind(null, "boolean");
3298
+ V.bind(null, "symbol");
3299
+ function Y(n2) {
3300
+ return n2 === null;
3301
+ }
3302
+ function nn(n2) {
3303
+ return R(n2) === "number" && !isNaN(n2);
3304
+ }
3305
+ function yn(n2) {
3306
+ return W(n2.constructor) ? n2.constructor.name : null;
3307
+ }
3308
+ function hn(n2) {
3309
+ return n2 instanceof Error || q(n2.message) && n2.constructor && nn(n2.constructor.stackTraceLimit);
3310
+ }
3311
+ function On(n2, t2) {
3312
+ if (typeof t2 != "object" || Y(t2))
3313
+ return false;
3314
+ if (t2 instanceof n2)
3315
+ return true;
3316
+ var e2 = R(new n2(""));
3317
+ if (hn(t2))
3318
+ for (; t2; ) {
3319
+ if (R(t2) === e2)
3320
+ return true;
3321
+ t2 = Object.getPrototypeOf(t2);
3322
+ }
3323
+ return false;
3324
+ }
3325
+ On.bind(null, TypeError);
3326
+ On.bind(null, SyntaxError);
3327
+ function $n(n2, t2) {
3328
+ var e2 = n2 instanceof Element || n2 instanceof HTMLDocument;
3329
+ return e2 && t2 ? Tn(n2, t2) : e2;
3330
+ }
3331
+ function Tn(n2, t2) {
3332
+ return t2 === void 0 && (t2 = ""), n2 && n2.nodeName === t2.toUpperCase();
3333
+ }
3334
+ function _n(n2) {
3335
+ var t2 = [].slice.call(arguments, 1);
3336
+ return function() {
3337
+ return n2.apply(void 0, [].slice.call(arguments).concat(t2));
3338
+ };
3339
+ }
3340
+ _n($n, "form");
3341
+ _n($n, "button");
3342
+ _n($n, "input");
3343
+ _n($n, "select");
3344
+ var o$1 = j + "global" + j, n$1 = typeof self === o$2 && self.self === self && self || typeof global === o$2 && global.global === global && global || void 0;
3345
+ function a(t2) {
3346
+ return n$1[o$1][t2];
3347
+ }
3348
+ function f$1(t2, e2) {
3349
+ return n$1[o$1][t2] = e2;
3350
+ }
3351
+ function i$1(t2) {
3352
+ delete n$1[o$1][t2];
3353
+ }
3354
+ function u(t2, e2, r2) {
3355
+ var l2;
3356
+ try {
3357
+ if (b$1(t2)) {
3358
+ var o2 = window[t2];
3359
+ l2 = o2[e2].bind(o2);
3360
+ }
3361
+ } catch (t3) {
3362
+ }
3363
+ return l2 || r2;
3364
+ }
3365
+ n$1[o$1] || (n$1[o$1] = {});
3366
+ var c = {};
3367
+ function b$1(t2) {
3368
+ if (typeof c[t2] !== e$1)
3369
+ return c[t2];
3370
+ try {
3371
+ var e2 = window[t2];
3372
+ e2.setItem(e$1, e$1), e2.removeItem(e$1);
3373
+ } catch (e3) {
3374
+ return c[t2] = false;
3375
+ }
3376
+ return c[t2] = true;
3377
+ }
3378
+ var r = "localStorage", g = b$1.bind(null, "localStorage");
3379
+ u("localStorage", "getItem", a);
3380
+ u("localStorage", "setItem", f$1);
3381
+ u("localStorage", "removeItem", i$1);
3382
+ function y(t2) {
3383
+ var o2 = t2;
3384
+ try {
3385
+ if ((o2 = JSON.parse(t2)) === "true")
3386
+ return true;
3387
+ if (o2 === "false")
3388
+ return false;
3389
+ if (M$3(o2))
3390
+ return o2;
3391
+ parseFloat(o2) === o2 && (o2 = parseFloat(o2));
3392
+ } catch (t3) {
3393
+ }
3394
+ if (o2 !== null && o2 !== "")
3395
+ return o2;
3396
+ }
3397
+ var S = g(), k = a$1();
3398
+ function I(o2, r2) {
3399
+ if (o2) {
3400
+ var e2 = L(r2), a2 = !A(e2), l2 = O(e2) ? y(localStorage.getItem(o2)) : void 0;
3401
+ if (a2 && !$$3(l2))
3402
+ return l2;
3403
+ var n2 = b(e2) ? y(r$1(o2)) : void 0;
3404
+ if (a2 && n2)
3405
+ return n2;
3406
+ var u2 = a$3(o2);
3407
+ return a2 ? u2 : { localStorage: l2, cookie: n2, global: u2 };
3408
+ }
3409
+ }
3410
+ function x(e2, a2, u2) {
3411
+ if (e2 && !$$3(a2)) {
3412
+ var c2 = {}, f2 = L(u2), g2 = JSON.stringify(a2), m2 = !A(f2);
3413
+ return O(f2) && (c2[r] = h(r, a2, y(localStorage.getItem(e2))), localStorage.setItem(e2, g2), m2) ? c2[r] : b(f2) && (c2[t] = h(t, a2, y(r$1(e2))), c$1(e2, g2), m2) ? c2[t] : (c2[l$1] = h(l$1, a2, a$3(e2)), f$3(e2, a2), m2 ? c2[l$1] : c2);
3414
+ }
3415
+ }
3416
+ function C(t$1, r$12) {
3417
+ if (t$1) {
3418
+ var a2 = L(r$12), i = I(t$1, l$2), n2 = {};
3419
+ return !$$3(i.localStorage) && O(a2) && (localStorage.removeItem(t$1), n2[r] = i.localStorage), !$$3(i.cookie) && b(a2) && (u$1(t$1), n2[t] = i.cookie), !$$3(i.global) && d(a2, l$1) && (i$4(t$1), n2[l$1] = i.global), n2;
3420
+ }
3421
+ }
3422
+ function L(t2) {
3423
+ return t2 ? L$1(t2) ? t2 : t2.storage : f$4;
3424
+ }
3425
+ function O(t2) {
3426
+ return S && d(t2, r);
3427
+ }
3428
+ function b(t$1) {
3429
+ return k && d(t$1, t);
3430
+ }
3431
+ function A(t2) {
3432
+ return t2 === l$2 || t2 === "all";
3433
+ }
3434
+ function d(t2, o2) {
3435
+ return t2 === f$4 || t2 === o2 || A(t2);
3436
+ }
3437
+ function h(t2, o2, r2) {
3438
+ return { location: t2, current: o2, previous: r2 };
3439
+ }
3440
+ var N = { setItem: x, getItem: I, removeItem: C };
3441
+ var storage = N;
3442
+ function _defineProperty$1(obj, key, value) {
3443
+ if (key in obj) {
3444
+ Object.defineProperty(obj, key, {
3445
+ value,
3446
+ enumerable: true,
3447
+ configurable: true,
3448
+ writable: true
3449
+ });
3450
+ } else {
3451
+ obj[key] = value;
3452
+ }
3453
+ return obj;
3454
+ }
3455
+ var defineProperty = _defineProperty$1;
3456
+ function ownKeys(object, enumerableOnly) {
3457
+ var keys = Object.keys(object);
3458
+ if (Object.getOwnPropertySymbols) {
3459
+ var symbols = Object.getOwnPropertySymbols(object);
3460
+ if (enumerableOnly)
3461
+ symbols = symbols.filter(function(sym) {
3462
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3463
+ });
3464
+ keys.push.apply(keys, symbols);
3465
+ }
3466
+ return keys;
3467
+ }
3468
+ function _objectSpread2(target) {
3469
+ for (var i = 1; i < arguments.length; i++) {
3470
+ var source = arguments[i] != null ? arguments[i] : {};
3471
+ if (i % 2) {
3472
+ ownKeys(source, true).forEach(function(key) {
3473
+ defineProperty(target, key, source[key]);
3474
+ });
3475
+ } else if (Object.getOwnPropertyDescriptors) {
3476
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3477
+ } else {
3478
+ ownKeys(source).forEach(function(key) {
3479
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3480
+ });
3481
+ }
3482
+ }
3483
+ return target;
3484
+ }
3485
+ var objectSpread2 = _objectSpread2;
3486
+ function analyticsLib() {
3487
+ var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3488
+ var defaultSettings = {
3489
+ storage
3490
+ };
3491
+ return analytics(objectSpread2(objectSpread2({}, defaultSettings), opts));
3492
+ }
3493
+ function _defineProperty(obj, key, value) {
3494
+ if (key in obj) {
3495
+ Object.defineProperty(obj, key, {
3496
+ value,
3497
+ enumerable: true,
3498
+ configurable: true,
3499
+ writable: true
3500
+ });
3501
+ } else {
3502
+ obj[key] = value;
3503
+ }
3504
+ return obj;
3505
+ }
3506
+ function _objectSpread(target) {
3507
+ for (var i = 1; i < arguments.length; i++) {
3508
+ var source = arguments[i] != null ? arguments[i] : {};
3509
+ var ownKeys2 = Object.keys(source);
3510
+ if (typeof Object.getOwnPropertySymbols === "function") {
3511
+ ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3512
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3513
+ }));
3514
+ }
3515
+ ownKeys2.forEach(function(key) {
3516
+ _defineProperty(target, key, source[key]);
3517
+ });
3518
+ }
3519
+ return target;
3520
+ }
3521
+ var config = {
3522
+ debug: false,
3523
+ containerId: null,
3524
+ dataLayerName: "dataLayer",
3525
+ dataLayer: void 0,
3526
+ preview: void 0,
3527
+ auth: void 0,
3528
+ execution: "async"
3529
+ };
3530
+ var initializedDataLayerName;
3531
+ function googleTagManager$1() {
3532
+ var pluginConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3533
+ return {
3534
+ name: "google-tag-manager",
3535
+ config: _objectSpread({}, config, pluginConfig),
3536
+ initialize: function initialize(_ref2) {
3537
+ var config2 = _ref2.config;
3538
+ var containerId = config2.containerId, dataLayerName = config2.dataLayerName, customScriptSrc = config2.customScriptSrc, preview = config2.preview, auth = config2.auth, execution = config2.execution;
3539
+ if (!containerId) {
3540
+ throw new Error("No google tag manager containerId defined");
3541
+ }
3542
+ if (preview && !auth) {
3543
+ throw new Error("When enabling preview mode, both preview and auth parameters must be defined");
3544
+ }
3545
+ var scriptSrc = customScriptSrc || "https://www.googletagmanager.com/gtm.js";
3546
+ if (!scriptLoaded(containerId)) {
3547
+ (function(w, d2, s2, l2, i) {
3548
+ w[l2] = w[l2] || [];
3549
+ w[l2].push({
3550
+ "gtm.start": new Date().getTime(),
3551
+ event: "gtm.js"
3552
+ });
3553
+ var f2 = d2.getElementsByTagName(s2)[0], j2 = d2.createElement(s2), dl = l2 != "dataLayer" ? "&l=" + l2 : "", p2 = preview ? "&gtm_preview=" + preview + "&gtm_auth=" + auth + "&gtm_cookies_win=x" : "";
3554
+ if (execution) {
3555
+ j2[execution] = true;
3556
+ }
3557
+ j2.src = "".concat(scriptSrc, "?id=") + i + dl + p2;
3558
+ f2.parentNode.insertBefore(j2, f2);
3559
+ })(window, document, "script", dataLayerName, containerId);
3560
+ initializedDataLayerName = dataLayerName;
3561
+ config2.dataLayer = window[dataLayerName];
3562
+ }
3563
+ },
3564
+ page: function page2(_ref2) {
3565
+ var payload = _ref2.payload;
3566
+ _ref2.options;
3567
+ _ref2.instance;
3568
+ var config2 = _ref2.config;
3569
+ if (typeof config2.dataLayer !== "undefined") {
3570
+ config2.dataLayer.push(payload.properties);
3571
+ }
3572
+ },
3573
+ track: function track(_ref3) {
3574
+ var payload = _ref3.payload;
3575
+ _ref3.options;
3576
+ var config2 = _ref3.config;
3577
+ if (typeof config2.dataLayer !== "undefined") {
3578
+ var anonymousId = payload.anonymousId, userId = payload.userId, properties = payload.properties;
3579
+ var formattedPayload = properties;
3580
+ if (userId) {
3581
+ formattedPayload.userId = userId;
3582
+ }
3583
+ if (anonymousId) {
3584
+ formattedPayload.anonymousId = anonymousId;
3585
+ }
3586
+ if (!properties.category) {
3587
+ formattedPayload.category = "All";
3588
+ }
3589
+ if (config2.debug) {
3590
+ console.log("gtag push", _objectSpread({
3591
+ event: payload.event
3592
+ }, formattedPayload));
3593
+ }
3594
+ config2.dataLayer.push(_objectSpread({
3595
+ event: payload.event
3596
+ }, formattedPayload));
3597
+ }
3598
+ },
3599
+ loaded: function loaded() {
3600
+ var hasDataLayer = !!initializedDataLayerName && !!(window[initializedDataLayerName] && Array.prototype.push !== window[initializedDataLayerName].push);
3601
+ return scriptLoaded(pluginConfig.containerId) && hasDataLayer;
3602
+ }
3603
+ };
3604
+ }
3605
+ var regexCache = {};
3606
+ function scriptLoaded(containerId) {
3607
+ var regex = regexCache[containerId];
3608
+ if (!regex) {
3609
+ regex = new RegExp("googletagmanager\\.com\\/gtm\\.js.*[?&]id=" + containerId);
3610
+ regexCache[containerId] = regex;
3611
+ }
3612
+ var scripts = document.querySelectorAll("script[src]");
3613
+ return !!Object.keys(scripts).filter(function(key) {
3614
+ return (scripts[key].src || "").match(regex);
3615
+ }).length;
3616
+ }
3617
+ var index = googleTagManager$1;
3618
+ function gtag() {
3619
+ window.dataLayer.push(arguments);
3620
+ }
3621
+ window.gtag = gtag;
3622
+ function gtagInit({ trackingId, configParams = {}, setParams = {} }) {
3623
+ var scriptId = "ga-gtag";
3624
+ if (document.getElementById(scriptId))
3625
+ return;
3626
+ var head = document.head;
3627
+ var script = document.createElement("script");
3628
+ script.id = scriptId;
3629
+ script.type = "text/javascript";
3630
+ script.async = true;
3631
+ script.src = "https://www.googletagmanager.com/gtag/js?id=" + trackingId;
3632
+ head.insertBefore(script, head.firstChild);
3633
+ window.dataLayer = window.dataLayer || [];
3634
+ gtag("js", new Date());
3635
+ if (setParams) {
3636
+ gtag("set", setParams);
3637
+ }
3638
+ gtag("config", trackingId, configParams);
3639
+ }
3640
+ function googleAnalytics4(pluginConfig = {}) {
3641
+ return {
3642
+ name: "google-analytics-4",
3643
+ config: pluginConfig,
3644
+ initialize: function({ config: config2, instance }) {
3645
+ if (!config2.trackingId)
3646
+ throw new Error("No GA trackingId defined");
3647
+ var configParams = {};
3648
+ var setParams = {};
3649
+ if (config2.customDimensions) {
3650
+ var customMap = {};
3651
+ for (var i = 0; i < config2.customDimensions.length; i++) {
3652
+ var customDim = config2.customDimensions[i];
3653
+ configParams[customDim.name] = customDim.callback(instance, config2);
3654
+ customMap["dimension" + (i + 1)] = customDim.name;
3655
+ }
3656
+ setParams["custom_map"] = customMap;
3657
+ }
3658
+ gtagInit({ trackingId: config2.trackingId, configParams, setParams });
3659
+ },
3660
+ page: function({ payload, config: config2, instance }) {
3661
+ },
3662
+ track: function({ payload, config: config2, instance }) {
3663
+ gtag("event", payload.event, payload.properties);
3664
+ },
3665
+ identify: function({ payload, config: config2 }) {
3666
+ },
3667
+ loaded: function() {
3668
+ return !!window.gtag;
3669
+ }
3670
+ };
3671
+ }
3672
+ var l = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || void 0, e = "undefined";
3673
+ function o(e2) {
3674
+ return l[e2];
3675
+ }
3676
+ function f(e2, o2) {
3677
+ return l[e2] = o2, o2;
3678
+ }
3679
+ function n(l2) {
3680
+ f(l2);
3681
+ }
3682
+ var urlParams = new URLSearchParams(window.location.search);
3683
+ var DEBUG = urlParams.get("zdbg");
3684
+ function dbg() {
3685
+ if (DEBUG != 1)
3686
+ return;
3687
+ console.debug(...arguments);
3688
+ }
3689
+ function rbWarning(msg2) {
3690
+ if (window.Rollbar) {
3691
+ window.Rollbar.warning(msg2);
3692
+ }
3693
+ }
3694
+ var supportsSessionStorage = hasSessionStorage();
3695
+ function hasSessionStorage() {
3696
+ if (typeof supportsSessionStorage !== e) {
3697
+ return supportsSessionStorage;
3698
+ }
3699
+ supportsSessionStorage = true;
3700
+ try {
3701
+ sessionStorage.setItem(e, e);
3702
+ sessionStorage.removeItem(e);
3703
+ } catch (e2) {
3704
+ supportsSessionStorage = false;
3705
+ }
3706
+ return supportsSessionStorage;
3707
+ }
3708
+ function getSessionStorage(key) {
3709
+ var value;
3710
+ var globalValue = o(key) || void 0;
3711
+ if (supportsSessionStorage) {
3712
+ value = sessionStorage.getItem(key);
3713
+ if (!value && globalValue) {
3714
+ value = globalValue;
3715
+ sessionStorage.setItem(key, value);
3716
+ }
3717
+ } else {
3718
+ value = globalValue;
3719
+ }
3720
+ return value ? JSON.parse(value) : void 0;
3721
+ }
3722
+ function setSessionStorage(key, value) {
3723
+ var value_str = JSON.stringify(value);
3724
+ if (supportsSessionStorage) {
3725
+ sessionStorage.setItem(key, value_str);
3726
+ }
3727
+ f(key, value_str);
3728
+ }
3729
+ function removeSessionStorage(key) {
3730
+ if (supportsSessionStorage) {
3731
+ sessionStorage.removeItem(key);
3732
+ }
3733
+ n(key);
3734
+ }
3735
+ var lut = [];
3736
+ for (var i = 0; i < 256; i++) {
3737
+ lut[i] = (i < 16 ? "0" : "") + i.toString(16);
3738
+ }
3739
+ function uuid() {
3740
+ var d0 = Math.random() * 4294967296 >>> 0;
3741
+ var d1 = Math.random() * 4294967296 >>> 0;
3742
+ var d2 = Math.random() * 4294967296 >>> 0;
3743
+ var d3 = Math.random() * 4294967296 >>> 0;
3744
+ return lut[d0 & 255] + lut[d0 >> 8 & 255] + lut[d0 >> 16 & 255] + lut[d0 >> 24 & 255] + "-" + lut[d1 & 255] + lut[d1 >> 8 & 255] + "-" + lut[d1 >> 16 & 15 | 64] + lut[d1 >> 24 & 255] + "-" + lut[d2 & 63 | 128] + lut[d2 >> 8 & 255] + "-" + lut[d2 >> 16 & 255] + lut[d2 >> 24 & 255] + lut[d3 & 255] + lut[d3 >> 8 & 255] + lut[d3 >> 16 & 255] + lut[d3 >> 24 & 255];
3745
+ }
3746
+ var inBrowser = typeof document !== "undefined";
3747
+ function hasAdBlock() {
3748
+ if (!inBrowser)
3749
+ return false;
3750
+ var fakeAd = document.createElement("div");
3751
+ fakeAd.innerHTML = "&nbsp;";
3752
+ fakeAd.className = "pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links";
3753
+ fakeAd.setAttribute("style", "width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;");
3754
+ try {
3755
+ document.body.appendChild(fakeAd);
3756
+ if (document.body.getAttribute("abp") !== null || fakeAd.offsetHeight === 0 || fakeAd.clientHeight === 0) {
3757
+ return true;
3758
+ }
3759
+ if (typeof getComputedStyle !== "undefined") {
3760
+ var css = window.getComputedStyle(fakeAd, null);
3761
+ if (css && (css.getPropertyValue("display") === "none" || css.getPropertyValue("visibility") === "hidden")) {
3762
+ return true;
3763
+ }
3764
+ }
3765
+ document.body.removeChild(fakeAd);
3766
+ } catch (e2) {
3767
+ }
3768
+ return false;
3769
+ }
3770
+ function makeRequest({ method, url, data, json = true }) {
3771
+ return new Promise(function(resolve, reject) {
3772
+ var xhr = new XMLHttpRequest();
3773
+ xhr.open(method, url);
3774
+ xhr.withCredentials = true;
3775
+ if (json) {
3776
+ xhr.setRequestHeader("Accept", "application/json");
3777
+ xhr.setRequestHeader("Content-Type", "application/json");
3778
+ }
3779
+ xhr.onload = function() {
3780
+ if (this.status >= 200 && this.status < 300) {
3781
+ if (json) {
3782
+ resolve(JSON.parse(xhr.response));
3783
+ } else {
3784
+ resolve(xhr.response);
3785
+ }
3786
+ } else {
3787
+ reject({
3788
+ status: this.status,
3789
+ message: xhr.statusText
3790
+ });
3791
+ }
3792
+ };
3793
+ xhr.onerror = function() {
3794
+ reject({
3795
+ status: this.status,
3796
+ message: "Network Error"
3797
+ });
3798
+ };
3799
+ if (data) {
3800
+ xhr.send(data);
3801
+ } else {
3802
+ xhr.send();
3803
+ }
3804
+ });
3805
+ }
3806
+ function formatParams(params) {
3807
+ return "?" + Object.keys(params).map(function(key) {
3808
+ return key + "=" + encodeURIComponent(params[key]);
3809
+ }).join("&");
3810
+ }
3811
+ function postBeacon(_0) {
3812
+ return __async(this, arguments, function* ({ url, data }) {
3813
+ if (window && window.navigator && typeof window.navigator.sendBeacon === "function" && typeof window.Blob === "function") {
3814
+ try {
3815
+ if (window.navigator.sendBeacon(url, JSON.stringify(data))) {
3816
+ return true;
3817
+ }
3818
+ return false;
3819
+ } catch (e2) {
3820
+ return false;
3821
+ }
3822
+ }
3823
+ return false;
3824
+ });
3825
+ }
3826
+ function httpGet(_0) {
3827
+ return __async(this, arguments, function* ({ url, params = null, json = true }) {
3828
+ var finalUrl = url;
3829
+ if (params) {
3830
+ finalUrl = finalUrl + formatParams(params);
3831
+ }
3832
+ return yield makeRequest({ method: "GET", url: finalUrl, json });
3833
+ });
3834
+ }
3835
+ function httpPost(_0) {
3836
+ return __async(this, arguments, function* ({ url, data, json = true, beacon = false }) {
3837
+ var finalData = data;
3838
+ if (json) {
3839
+ finalData = JSON.stringify(finalData);
3840
+ }
3841
+ if (beacon) {
3842
+ var res = yield postBeacon({ url, data });
3843
+ if (res) {
3844
+ return;
3845
+ }
3846
+ dbg("Beacon failed");
3847
+ }
3848
+ return yield makeRequest({ method: "POST", url, data: finalData, json });
3849
+ });
3850
+ }
3851
+ var CID_KEY = "__zar_cid";
3852
+ var SID_KEY = "__zar_sid";
3853
+ var VID_KEY = "__zar_vid";
3854
+ var NUMBER_POOL_KEY = "__zar_pool";
3855
+ var NUMBER_POOL_SUCCESS = "success";
3856
+ var NUMBER_POOL_ERROR = "error";
3857
+ var NUMBER_POOL_RENEWAL_TIME_MS = 30 * 1e3;
3858
+ var POOL_DEFAULT_URL_FLAG = "pl";
3859
+ var DAY_TTL = 1e3 * 60 * 60 * 24;
3860
+ var POOL_STORAGE_TTL = DAY_TTL * 7;
3861
+ var numberOverlayMap = /* @__PURE__ */ new Map();
3862
+ function generateClientId() {
3863
+ return uuid();
3864
+ }
3865
+ function generateSessionId() {
3866
+ return uuid();
3867
+ }
3868
+ function generateVisitId() {
3869
+ return Date.now().toString(36) + "." + Math.random().toString(36).substring(2);
3870
+ }
3871
+ function initId(key, generator, getter, setter) {
3872
+ var id;
3873
+ var isNew = false;
3874
+ var origReferrer = null;
3875
+ var idObj = getter(key);
3876
+ if (!idObj || !idObj.id) {
3877
+ id = generator();
3878
+ origReferrer = document.referrer;
3879
+ isNew = true;
3880
+ dbg("Generated ID for", key, "-", id);
3881
+ } else {
3882
+ id = idObj.id;
3883
+ origReferrer = idObj.origReferrer;
3884
+ }
3885
+ var result = { id, t: Date.now(), origReferrer, isNew };
3886
+ setter(key, result);
3887
+ return result;
3888
+ }
3889
+ function initIds() {
3890
+ var vidResult = initId(VID_KEY, generateVisitId, getSessionStorage, setSessionStorage);
3891
+ var sidResult = initId(SID_KEY, generateSessionId, getSessionStorage, setSessionStorage);
3892
+ var cidResult = initId(CID_KEY, generateClientId, getSessionStorage, setSessionStorage);
3893
+ return { cid: cidResult.id, sid: sidResult.id, vid: vidResult.id };
3894
+ }
3895
+ function getDefaultApiUrl() {
3896
+ return window.location.host + "/api/v1";
3897
+ }
3898
+ function getIDObj(key) {
3899
+ return getSessionStorage(key);
3900
+ }
3901
+ function getID(key) {
3902
+ var obj = getIDObj(key);
3903
+ return obj ? obj.id : null;
3904
+ }
3905
+ function getStorage() {
3906
+ return {
3907
+ cid: getIDObj(CID_KEY),
3908
+ sid: getIDObj(SID_KEY),
3909
+ vid: getIDObj(VID_KEY)
3910
+ };
3911
+ }
3912
+ function getIds() {
3913
+ return {
3914
+ cid: getID(CID_KEY),
3915
+ sid: getID(SID_KEY),
3916
+ vid: getID(VID_KEY)
3917
+ };
3918
+ }
3919
+ function updateID(key, val) {
3920
+ var obj = getIDObj(key);
3921
+ if (!obj) {
3922
+ console.warn("could not update " + key);
3923
+ return;
3924
+ }
3925
+ obj.id = val;
3926
+ setSessionStorage(key, obj);
3927
+ }
3928
+ function removeID(key) {
3929
+ removeSessionStorage(key);
3930
+ }
3931
+ function removeIds() {
3932
+ removeID(VID_KEY);
3933
+ removeID(SID_KEY);
3934
+ removeID(CID_KEY);
3935
+ }
3936
+ function getPoolNumber(_0) {
3937
+ return __async(this, arguments, function* ({ poolId, apiUrl, number = null, context: context2 = null }) {
3938
+ var payload = {
3939
+ pool_id: poolId,
3940
+ number,
3941
+ context: context2,
3942
+ properties: {
3943
+ zar: getStorage()
3944
+ }
3945
+ };
3946
+ var resp = yield httpPost({ url: `${apiUrl}/number_pool`, data: payload });
3947
+ return resp;
3948
+ });
3949
+ }
3950
+ function getPoolStats(_0) {
3951
+ return __async(this, arguments, function* ({ apiUrl, key = null, with_contexts = false }) {
3952
+ var params = {
3953
+ key,
3954
+ with_contexts
3955
+ };
3956
+ var resp = yield httpGet({ url: `${apiUrl}/number_pool_stats`, params });
3957
+ return resp;
3958
+ });
3959
+ }
3960
+ function extractPhoneNumber({ elem }) {
3961
+ var numberText = null;
3962
+ var number = null;
3963
+ var href = null;
3964
+ var regex = new RegExp("\\+?\\(?\\d*\\)? ?\\(?\\d+\\)?\\d*([\\s./-]?\\d{2,})+", "g");
3965
+ if (elem.href && elem.href.startsWith("tel:")) {
3966
+ href = elem.href;
3967
+ }
3968
+ var text = elem.innerText;
3969
+ var html = elem.innerHTML;
3970
+ var match = regex.exec(text);
3971
+ if (match) {
3972
+ numberText = match[0].trim();
3973
+ number = numberText.replace("+", "").replace(/-/g, "").replace(/ /g, "").replace("(", "").replace(")", "").replace(/^1/, "");
3974
+ }
3975
+ return { text, html, numberText, href, number };
3976
+ }
3977
+ function overlayPhoneNumber({ elems, number }) {
3978
+ var origNum;
3979
+ var overlayNum = number;
3980
+ if (!number.startsWith("+1")) {
3981
+ overlayNum = "+1" + number;
3982
+ }
3983
+ for (var i = 0; i < elems.length; i++) {
3984
+ if (numberOverlayMap.has(elems[i])) {
3985
+ dbg("pool: skipping element already in overlay map:", elems[i]);
3986
+ continue;
3987
+ }
3988
+ var elemNum = extractPhoneNumber({ elem: elems[i] });
3989
+ if (!origNum) {
3990
+ origNum = elemNum;
3991
+ } else if (elemNum.number && origNum.number && origNum.number !== elemNum.number) {
3992
+ console.warn("pool: overlaying multiple phone numbers with a single number!", origNum.number, elemNum.number);
3993
+ }
3994
+ dbg("pool: overlaying number", overlayNum, "on", elems[i]);
3995
+ numberOverlayMap.set(elems[i], elemNum);
3996
+ if (elemNum.href) {
3997
+ elems[i].href = "tel:" + overlayNum;
3998
+ }
3999
+ if (elemNum.numberText) {
4000
+ elems[i].innerHTML = "";
4001
+ if (elemNum.text) {
4002
+ var overlay = overlayNum;
4003
+ if (elemNum.numberText.indexOf("-") > -1) {
4004
+ overlay = overlayNum.slice(2, 5) + "-" + overlayNum.slice(5, 8) + "-" + overlayNum.slice(8, 12);
4005
+ }
4006
+ if (elemNum.html.indexOf("<img") > -1) {
4007
+ var numberHtml = elemNum.html.replace(elemNum.numberText, overlay);
4008
+ elems[i].innerHTML = numberHtml;
4009
+ } else {
4010
+ var numberText = elemNum.text.replace(elemNum.numberText, overlay);
4011
+ elems[i].appendChild(document.createTextNode(numberText));
4012
+ }
4013
+ } else {
4014
+ elems[i].appendChild(document.createTextNode(overlayNum));
4015
+ }
4016
+ } else {
4017
+ dbg("pool: no number text found on", elems[i]);
4018
+ }
4019
+ }
4020
+ }
4021
+ function revertOverlayNumbers({ elems }) {
4022
+ for (var i = 0; i < elems.length; i++) {
4023
+ if (numberOverlayMap.has(elems[i])) {
4024
+ var currentHTML = elems[i].innerHTML;
4025
+ var origElemData = numberOverlayMap.get(elems[i]);
4026
+ dbg("orig:", origElemData);
4027
+ var origHTML = origElemData.html;
4028
+ dbg("pool: reverting", currentHTML, "to", origHTML);
4029
+ elems[i].innerHTML = origHTML;
4030
+ if (origElemData.href) {
4031
+ elems[i].href = origElemData.href;
4032
+ }
4033
+ numberOverlayMap.delete(elems[i]);
4034
+ } else {
4035
+ dbg("pool: element not in map:", elems[i]);
4036
+ }
4037
+ }
4038
+ }
4039
+ function removePoolSession({ overlayElements }) {
4040
+ C(NUMBER_POOL_KEY, l$2);
4041
+ revertOverlayNumbers({ elems: overlayElements });
4042
+ }
4043
+ function clearPoolIntervals(poolData) {
4044
+ if (!poolData || !poolData.poolNumbers) {
4045
+ return;
4046
+ }
4047
+ for (var poolId in poolData.poolNumbers) {
4048
+ clearInterval(poolData.poolNumbers[poolId].interval);
4049
+ }
4050
+ }
4051
+ function poolSessionExpired(obj) {
4052
+ if (obj && obj.t && obj.t + POOL_STORAGE_TTL < Date.now()) {
4053
+ return true;
4054
+ }
4055
+ return false;
4056
+ }
4057
+ function getPoolSession() {
4058
+ return I(NUMBER_POOL_KEY);
4059
+ }
4060
+ function initTrackingPool() {
4061
+ return __async(this, arguments, function* ({
4062
+ poolId,
4063
+ overlayElements,
4064
+ apiUrl = getDefaultApiUrl(),
4065
+ urlParam = POOL_DEFAULT_URL_FLAG,
4066
+ renew = true,
4067
+ renewalInterval = NUMBER_POOL_RENEWAL_TIME_MS,
4068
+ callback = null
4069
+ } = {}) {
4070
+ var poolEnabled = false;
4071
+ var seshData = getPoolSession();
4072
+ var expired = poolSessionExpired(seshData);
4073
+ if (!expired) {
4074
+ if (seshData && seshData.poolEnabled) {
4075
+ poolEnabled = true;
4076
+ } else {
4077
+ if (urlParams.get(urlParam) === "1") {
4078
+ poolEnabled = true;
4079
+ }
4080
+ }
4081
+ } else {
4082
+ clearPoolIntervals(seshData);
4083
+ removePoolSession({ overlayElements });
4084
+ }
4085
+ if (!poolEnabled) {
4086
+ dbg("pool: not enabled");
4087
+ if (callback) {
4088
+ callback(null);
4089
+ }
4090
+ return null;
4091
+ }
4092
+ var seshNumber = null;
4093
+ var seshInterval = null;
4094
+ if (seshData && seshData.poolNumbers && seshData.poolNumbers[poolId]) {
4095
+ var poolResult = seshData.poolNumbers[poolId];
4096
+ seshInterval = poolResult.interval;
4097
+ if (poolResult.status !== NUMBER_POOL_SUCCESS) {
4098
+ dbg("pool: returning cached unsuccessful pool result: " + JSON.stringify(poolResult));
4099
+ if (callback) {
4100
+ callback(poolResult);
4101
+ }
4102
+ return poolResult;
4103
+ }
4104
+ if (poolResult.number) {
4105
+ seshNumber = poolResult.number;
4106
+ dbg("pool: found session number " + seshNumber);
4107
+ }
4108
+ }
4109
+ var resp = {};
4110
+ try {
4111
+ resp = yield getPoolNumber({ poolId, apiUrl, number: seshNumber, context: {} });
4112
+ } catch (e2) {
4113
+ var msg2 = "pool: error getting number: " + JSON.stringify(e2);
4114
+ rbWarning(msg2);
4115
+ console.warn(msg2);
4116
+ var errorRes = { status: NUMBER_POOL_ERROR, msg: e2.message, interval: seshInterval };
4117
+ if (callback) {
4118
+ callback(errorRes);
4119
+ }
4120
+ return errorRes;
4121
+ }
4122
+ if (resp.status === NUMBER_POOL_SUCCESS && resp.number) {
4123
+ if (overlayElements) {
4124
+ overlayPhoneNumber({ elems: overlayElements, number: resp.number });
4125
+ }
4126
+ if (renew) {
4127
+ dbg("pool: setting up renewal");
4128
+ resp.interval = setInterval(function() {
4129
+ try {
4130
+ initTrackingPool({ poolId, overlayElements, apiUrl, urlParam, renew: false });
4131
+ } catch (e2) {
4132
+ var msg3 = "pool: error on interval call: " + JSON.stringify(e2);
4133
+ rbWarning(msg3);
4134
+ console.warn(msg3);
4135
+ }
4136
+ }, renewalInterval);
4137
+ }
4138
+ } else {
4139
+ if (overlayElements) {
4140
+ revertOverlayNumbers({ elems: overlayElements });
4141
+ }
4142
+ if (seshInterval) {
4143
+ clearInterval(seshInterval);
4144
+ }
4145
+ resp.interval = null;
4146
+ }
4147
+ if (seshData) {
4148
+ if (seshData.poolNumbers[poolId]) {
4149
+ Object.assign(seshData.poolNumbers[poolId], resp);
4150
+ } else {
4151
+ seshData.poolNumbers[poolId] = resp;
4152
+ }
4153
+ if (renew) {
4154
+ seshData.t = Date.now();
4155
+ }
4156
+ } else {
4157
+ var poolNumbers = {};
4158
+ poolNumbers[poolId] = resp;
4159
+ seshData = {
4160
+ poolEnabled: true,
4161
+ poolNumbers,
4162
+ t: Date.now()
4163
+ };
4164
+ }
4165
+ x(NUMBER_POOL_KEY, seshData, l$2);
4166
+ dbg("pool: saved session data " + JSON.stringify(seshData));
4167
+ if (callback) {
4168
+ callback(resp);
4169
+ }
4170
+ return resp;
4171
+ });
4172
+ }
4173
+ function zar({ apiUrl }) {
4174
+ return {
4175
+ name: "zar",
4176
+ config: {
4177
+ apiUrl
4178
+ },
4179
+ initialize: function({ config: config2 }) {
4180
+ },
4181
+ loaded: function() {
4182
+ return true;
4183
+ },
4184
+ pageStart: function({ payload, config: config2, instance }) {
4185
+ payload.properties.zar = getStorage();
4186
+ if ("hash" in payload.properties) {
4187
+ delete payload.properties["hash"];
4188
+ }
4189
+ if ("path" in payload.properties) {
4190
+ delete payload.properties["path"];
4191
+ }
4192
+ if ("search" in payload.properties) {
4193
+ delete payload.properties["search"];
4194
+ }
4195
+ return payload;
4196
+ },
4197
+ trackStart: function({ payload, config: config2, instance }) {
4198
+ payload.properties.zar = getStorage();
4199
+ payload.properties.url = window.location.href;
4200
+ return payload;
4201
+ },
4202
+ page: function(_0) {
4203
+ return __async(this, arguments, function* ({ payload, options, instance, config: config2 }) {
4204
+ dbg("page", payload, options, config2);
4205
+ var result = yield httpPost({ url: `${config2.apiUrl}/page`, data: payload });
4206
+ if (result.sid) {
4207
+ updateID(SID_KEY, result.sid);
4208
+ }
4209
+ if (result.cid) {
4210
+ updateID(CID_KEY, result.cid);
4211
+ instance.setAnonymousId(result.cid);
4212
+ }
4213
+ });
4214
+ },
4215
+ track: function({ payload, options, instance, config: config2 }) {
4216
+ dbg("track", payload);
4217
+ httpPost({ url: `${config2.apiUrl}/track`, data: payload, beacon: true });
4218
+ },
4219
+ reset: function({ instance }) {
4220
+ removeIds();
4221
+ },
4222
+ bootstrap: function({ payload, config: config2, instance }) {
4223
+ var result = initIds();
4224
+ instance.setAnonymousId(result.cid);
4225
+ },
4226
+ methods: {
4227
+ apiUrl() {
4228
+ return apiUrl;
4229
+ },
4230
+ initIds() {
4231
+ var result = initIds();
4232
+ this.instance.setAnonymousId(result.cid);
4233
+ return result;
4234
+ },
4235
+ getIds() {
4236
+ return getIds();
4237
+ },
4238
+ getStorage() {
4239
+ return getStorage();
4240
+ },
4241
+ getCID() {
4242
+ return getID(CID_KEY);
4243
+ },
4244
+ getSID() {
4245
+ return getID(SID_KEY);
4246
+ },
4247
+ getVID() {
4248
+ return getID(VID_KEY);
4249
+ },
4250
+ hasAdBlock() {
4251
+ return hasAdBlock();
4252
+ },
4253
+ initTrackingPool({ poolId, overlayElements, urlParam = POOL_DEFAULT_URL_FLAG, renew = true, renewalInterval = NUMBER_POOL_RENEWAL_TIME_MS, callback = null }) {
4254
+ return initTrackingPool({
4255
+ poolId,
4256
+ overlayElements,
4257
+ apiUrl: this.instance.plugins.zar.apiUrl(),
4258
+ urlParam,
4259
+ renew,
4260
+ renewalInterval,
4261
+ callback
4262
+ });
4263
+ },
4264
+ extractPhoneNumbers({ elems }) {
4265
+ var res = [];
4266
+ for (var i = 0; i < elems.length; i++) {
4267
+ var elemRes = extractPhoneNumber({ elem: elems[i] });
4268
+ res.push(elemRes);
4269
+ }
4270
+ return res;
4271
+ },
4272
+ overlayPhoneNumber({ overlayElements, number }) {
4273
+ overlayPhoneNumber({ elems: overlayElements, number });
4274
+ },
4275
+ revertOverlayNumbers({ overlayElements }) {
4276
+ revertOverlayNumbers({ elems: overlayElements });
4277
+ },
4278
+ removePoolSession({ overlayElements }) {
4279
+ removePoolSession({ overlayElements });
4280
+ },
4281
+ getPoolStats({ key = null, with_contexts = false }) {
4282
+ return getPoolStats({ apiUrl: this.instance.plugins.zar.apiUrl(), key, with_contexts });
4283
+ }
4284
+ }
4285
+ };
4286
+ }
4287
+ function init({ app, gtmConfig = null, ga4Config = null, apiUrl = null }) {
4288
+ if (!apiUrl) {
4289
+ apiUrl = getDefaultApiUrl();
4290
+ }
4291
+ var plugins = [zar({ apiUrl })];
4292
+ if (ga4Config) {
4293
+ plugins.push(googleAnalytics4(ga4Config));
4294
+ }
4295
+ if (gtmConfig) {
4296
+ plugins.push(index(gtmConfig));
4297
+ }
4298
+ return analyticsLib({ app, plugins });
4299
+ }
4300
+ export { analyticsLib as Analytics, init, zar };
4301
+ //# sourceMappingURL=zar.es.js.map