zar 0.5.4 → 0.6.0

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 CHANGED
@@ -14,17 +14,17 @@ var d = (t, e, n) => new Promise((r, i) => {
14
14
  }, c = (u) => u.done ? r(u.value) : Promise.resolve(u.value).then(a, o);
15
15
  c((n = n.apply(t, e)).next());
16
16
  });
17
- function K({ app: t, plugins: e = [] } = {}) {
17
+ function tt({ app: t, plugins: e = [] } = {}) {
18
18
  const n = {
19
19
  app: t,
20
20
  plugins: {},
21
- page: (r = {}) => tt(n, r),
22
- track: (r, i = {}, a) => et(
21
+ page: (r = {}) => nt(n, r),
22
+ track: (r, i = {}, a) => at(
23
23
  n,
24
24
  a ? { event: r, properties: i, options: a } : { event: r, properties: i }
25
25
  ),
26
26
  reset: (...r) => d(this, null, function* () {
27
- return rt(n, ...r);
27
+ return it(n, ...r);
28
28
  })
29
29
  };
30
30
  return e.forEach((r) => {
@@ -42,14 +42,14 @@ function K({ app: t, plugins: e = [] } = {}) {
42
42
  }
43
43
  }), n;
44
44
  }
45
- const Y = /#.*$/;
46
- function Z() {
47
- return typeof window == "undefined" ? "" : window.location.href.replace(Y, "");
45
+ const et = /#.*$/;
46
+ function rt() {
47
+ return typeof window == "undefined" ? "" : window.location.href.replace(et, "");
48
48
  }
49
- function U(t = {}) {
49
+ function J(t = {}) {
50
50
  if (typeof window == "undefined" || typeof document == "undefined")
51
51
  return t;
52
- const { title: e, referrer: n } = document, { innerWidth: r, innerHeight: i } = window, a = Z(), o = {
52
+ const { title: e, referrer: n } = document, { innerWidth: r, innerHeight: i } = window, a = rt(), o = {
53
53
  title: e,
54
54
  url: a,
55
55
  width: r,
@@ -57,9 +57,9 @@ function U(t = {}) {
57
57
  };
58
58
  return n && n !== "" && (o.referrer = n), Object.assign({}, o, t);
59
59
  }
60
- function tt(n) {
60
+ function nt(n) {
61
61
  return d(this, arguments, function* (t, e = {}) {
62
- e.type || (e.type = "page"), e.properties = U(e.properties || {}), Object.values(t.plugins).forEach((r) => {
62
+ e.type || (e.type = "page"), e.properties = J(e.properties || {}), Object.values(t.plugins).forEach((r) => {
63
63
  if (typeof r.pageStart == "function")
64
64
  try {
65
65
  const i = r.pageStart({ payload: e, config: r.config, instance: t });
@@ -76,10 +76,10 @@ function tt(n) {
76
76
  return e;
77
77
  });
78
78
  }
79
- function et(n) {
79
+ function at(n) {
80
80
  return d(this, arguments, function* (t, e = {}) {
81
81
  e.type || (e.type = "track");
82
- const r = U(), i = e.properties || {};
82
+ const r = J(), i = e.properties || {};
83
83
  i.url === void 0 && (i.url = r.url), i.referrer === void 0 && r.referrer !== void 0 && (i.referrer = r.referrer), e.properties = i;
84
84
  const a = e.options || {}, o = a && typeof a.plugins == "object" ? a.plugins : null, c = (u) => o && o[u.name] === !1;
85
85
  Object.values(t.plugins).forEach((u) => {
@@ -104,7 +104,7 @@ function et(n) {
104
104
  return e;
105
105
  });
106
106
  }
107
- function rt(t, ...e) {
107
+ function it(t, ...e) {
108
108
  return d(this, null, function* () {
109
109
  for (const n of Object.values(t.plugins))
110
110
  if (typeof n.reset == "function")
@@ -114,27 +114,27 @@ function rt(t, ...e) {
114
114
  }
115
115
  });
116
116
  }
117
- function nt(t, e, n, r, i, a, o) {
117
+ function ot(t, e, n, r, i, a, o) {
118
118
  t.fbq || (i = t.fbq = function() {
119
119
  i.callMethod ? i.callMethod.apply(i, arguments) : i.queue.push(arguments);
120
120
  }, t._fbq || (t._fbq = i), i.push = i, i.loaded = !0, i.version = "2.0", i.queue = [], a = e.createElement(n), a.async = !0, a.src = r, o = e.getElementsByTagName(n)[0], o.parentNode.insertBefore(a, o));
121
121
  }
122
- function at({ trackingId: t }) {
123
- nt(
122
+ function ut({ trackingId: t }) {
123
+ ot(
124
124
  window,
125
125
  document,
126
126
  "script",
127
127
  "https://connect.facebook.net/en_US/fbevents.js"
128
128
  ), window.fbq("init", t);
129
129
  }
130
- function it(t = {}) {
130
+ function ct(t = {}) {
131
131
  return {
132
132
  name: "facebook",
133
133
  config: t,
134
134
  initialize: function({ config: e, instance: n }) {
135
135
  if (!e.trackingId)
136
136
  throw new Error("No Facebook trackingId defined");
137
- at({ trackingId: e.trackingId });
137
+ ut({ trackingId: e.trackingId });
138
138
  },
139
139
  page: function({ payload: e, config: n, instance: r }) {
140
140
  window.fbq("track", "PageView");
@@ -149,18 +149,18 @@ function it(t = {}) {
149
149
  }
150
150
  };
151
151
  }
152
- function P() {
152
+ function y() {
153
153
  window.dataLayer.push(arguments);
154
154
  }
155
- window.gtag = P;
156
- function ot({ trackingId: t, configParams: e = {}, setParams: n = {} }) {
155
+ window.gtag = y;
156
+ function st({ trackingId: t, configParams: e = {}, setParams: n = {} }) {
157
157
  var r = "ga-gtag";
158
158
  if (!document.getElementById(r)) {
159
159
  var i = document.head, a = document.createElement("script");
160
- a.id = r, a.type = "text/javascript", a.async = !0, a.src = "https://www.googletagmanager.com/gtag/js?id=" + t, i.insertBefore(a, i.firstChild), window.dataLayer = window.dataLayer || [], P("js", /* @__PURE__ */ new Date()), n && P("set", n), P("config", t, e);
160
+ a.id = r, a.type = "text/javascript", a.async = !0, a.src = "https://www.googletagmanager.com/gtag/js?id=" + t, i.insertBefore(a, i.firstChild), window.dataLayer = window.dataLayer || [], y("js", /* @__PURE__ */ new Date()), n && y("set", n), y("config", t, e);
161
161
  }
162
162
  }
163
- function ut(t = {}) {
163
+ function lt(t = {}) {
164
164
  return {
165
165
  name: "google-analytics-4",
166
166
  config: t,
@@ -175,12 +175,12 @@ function ut(t = {}) {
175
175
  }
176
176
  i.custom_map = a;
177
177
  }
178
- ot({ trackingId: e.trackingId, configParams: r, setParams: i });
178
+ st({ trackingId: e.trackingId, configParams: r, setParams: i });
179
179
  },
180
180
  page: function({ payload: e, config: n, instance: r }) {
181
181
  },
182
182
  track: function({ payload: e, config: n, instance: r }) {
183
- P("event", e.event, e.properties);
183
+ y("event", e.event, e.properties);
184
184
  },
185
185
  identify: function({ payload: e, config: n }) {
186
186
  },
@@ -189,18 +189,18 @@ function ut(t = {}) {
189
189
  }
190
190
  };
191
191
  }
192
- var ct = new URLSearchParams(window.location.search), st = ct.get("zdbg"), q = {};
193
- const I = "undefined";
192
+ var ft = new URLSearchParams(window.location.search), dt = ft.get("zdbg"), F = {};
193
+ const S = "undefined";
194
194
  function g() {
195
- st == 1 && console.debug(...arguments);
195
+ dt == 1 && console.debug(...arguments);
196
196
  }
197
- function l(t) {
197
+ function f(t) {
198
198
  console.warn(t), window.Rollbar && window.Rollbar.warning(t);
199
199
  }
200
- function ft(t) {
200
+ function wt(t) {
201
201
  return t && (Object.prototype.toString.call(t) === "[object Function]" || typeof t == "function" || t instanceof Function);
202
202
  }
203
- function j() {
203
+ function A() {
204
204
  try {
205
205
  var t = navigator.userAgent || "", e = new RegExp(
206
206
  [
@@ -218,30 +218,30 @@ function j() {
218
218
  return !1;
219
219
  }
220
220
  }
221
- function lt(t) {
221
+ function vt(t) {
222
222
  document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive" ? t() : window.addEventListener("DOMContentLoaded", t);
223
223
  }
224
- var p = dt();
225
- function dt() {
226
- if (typeof p !== I)
224
+ var p = gt();
225
+ function gt() {
226
+ if (typeof p !== S)
227
227
  return p;
228
228
  p = !0;
229
229
  try {
230
- sessionStorage.setItem(I, I), sessionStorage.removeItem(I);
230
+ sessionStorage.setItem(S, S), sessionStorage.removeItem(S);
231
231
  } catch (t) {
232
232
  p = !1;
233
233
  }
234
234
  return p;
235
235
  }
236
- function J(t) {
237
- var e, n = q[t];
236
+ function C(t) {
237
+ var e, n = F[t];
238
238
  return p ? (e = sessionStorage.getItem(t), !e && n && (e = n, sessionStorage.setItem(t, e))) : e = n, e ? JSON.parse(e) : void 0;
239
239
  }
240
- function wt(t, e) {
240
+ function G(t, e) {
241
241
  var n = JSON.stringify(e);
242
- p && sessionStorage.setItem(t, n), q[t] = n;
242
+ p && sessionStorage.setItem(t, n), F[t] = n;
243
243
  }
244
- function F({ method: t, url: e, data: n, json: r = !0 }) {
244
+ function V({ method: t, url: e, data: n, json: r = !0 }) {
245
245
  return new Promise(function(i, a) {
246
246
  var o = new XMLHttpRequest();
247
247
  o.open(t, e), o.withCredentials = !0, r && (o.setRequestHeader("Accept", "application/json"), o.setRequestHeader("Content-Type", "application/json")), o.onload = function() {
@@ -257,12 +257,12 @@ function F({ method: t, url: e, data: n, json: r = !0 }) {
257
257
  }, n ? o.send(n) : o.send();
258
258
  });
259
259
  }
260
- function vt(t) {
260
+ function pt(t) {
261
261
  return "?" + Object.keys(t).map(function(e) {
262
262
  return e + "=" + encodeURIComponent(t[e]);
263
263
  }).join("&");
264
264
  }
265
- function gt(n) {
265
+ function bt(n) {
266
266
  return d(this, arguments, function* ({ url: t, data: e }) {
267
267
  if (window && window.navigator && typeof window.navigator.sendBeacon == "function" && typeof window.Blob == "function")
268
268
  try {
@@ -271,70 +271,70 @@ function gt(n) {
271
271
  });
272
272
  return !!window.navigator.sendBeacon(t, r);
273
273
  } catch (r) {
274
- return l("postBeacon:"), !1;
274
+ return f("postBeacon:"), !1;
275
275
  }
276
276
  return !1;
277
277
  });
278
278
  }
279
- function pt(r) {
279
+ function ht(r) {
280
280
  return d(this, arguments, function* ({ url: t, params: e = null, json: n = !0 }) {
281
281
  var i = t;
282
- return e && (i = i + vt(e)), yield F({ method: "GET", url: i, json: n });
282
+ return e && (i = i + pt(e)), yield V({ method: "GET", url: i, json: n });
283
283
  });
284
284
  }
285
- function O(i) {
285
+ function _(i) {
286
286
  return d(this, arguments, function* ({ url: t, data: e, json: n = !0, beacon: r = !1 }) {
287
287
  var a = e;
288
288
  if (n && (a = JSON.stringify(a)), r) {
289
- var o = yield gt({ url: t, data: e });
289
+ var o = yield bt({ url: t, data: e });
290
290
  if (o)
291
291
  return;
292
292
  g("Beacon failed");
293
293
  }
294
- return yield F({ method: "POST", url: t, data: a, json: n });
294
+ return yield V({ method: "POST", url: t, data: a, json: n });
295
295
  });
296
296
  }
297
- var D = "__zar_vid", L = "success", m = "error", bt = 30 * 1e3, ht = 10 * 1e3, A = 0, mt = 3, v = {}, R = {}, N = !1;
297
+ var z = "__zar_vid", L = "success", m = "error", mt = 30 * 1e3, yt = 10 * 1e3, $ = "__zar_pool_last_ctx", B = 0, Pt = 3, v = {}, R = {}, N = !1;
298
298
  window.zarPoolData = window.zarPoolData || null;
299
299
  window.zarPoolDLObserverDone = window.zarPoolDLObserverDone || !1;
300
300
  window.zarPoolDataLayer = window.zarPoolDataLayer || [];
301
301
  var b = /* @__PURE__ */ new Map();
302
- function yt() {
302
+ function St() {
303
303
  return Date.now().toString(36) + "." + Math.random().toString(36).substring(2);
304
304
  }
305
- function Pt(t, e, n, r) {
305
+ function _t(t, e, n, r) {
306
306
  var i, a = !1, o, c = null, u = n(t);
307
307
  !u || !u.id ? (i = e(), c = document.referrer, o = Date.now(), a = !0, g("new ID for", t, "-", i)) : (i = u.id, c = u.origReferrer, o = u.t);
308
308
  var s = { id: i, t: o, origReferrer: c, isNew: a };
309
309
  return r(t, s), s;
310
310
  }
311
- function B() {
312
- var t = Pt(
313
- D,
314
- yt,
315
- J,
316
- wt
311
+ function M() {
312
+ var t = _t(
313
+ z,
314
+ St,
315
+ C,
316
+ G
317
317
  );
318
318
  return { vid: t };
319
319
  }
320
- function G() {
320
+ function H() {
321
321
  return window.location.protocol + "://" + window.location.host + "/api/v2";
322
322
  }
323
- function V(t) {
324
- return J(t);
323
+ function W(t) {
324
+ return C(t);
325
325
  }
326
- function $(t) {
327
- var e = V(t);
326
+ function Q(t) {
327
+ var e = W(t);
328
328
  return e ? e.id : null;
329
329
  }
330
- function S() {
330
+ function P() {
331
331
  return {
332
- vid: V(D)
332
+ vid: W(z)
333
333
  };
334
334
  }
335
- function St() {
335
+ function xt() {
336
336
  return {
337
- vid: $(D)
337
+ vid: Q(z)
338
338
  };
339
339
  }
340
340
  function E({ elem: t }) {
@@ -346,7 +346,7 @@ function E({ elem: t }) {
346
346
  var a = t.innerText, o = t.innerHTML, c = i.exec(a);
347
347
  return c && (e = c[0].trim(), n = e.replace("+", "").replace(/-/g, "").replace(/ /g, "").replace("(", "").replace(")", "").replace(/^1/, "")), { text: a, html: o, numberText: e, href: r, number: n };
348
348
  }
349
- function z({ elems: t, number: e, force: n = !1 }) {
349
+ function D({ elems: t, number: e, force: n = !1 }) {
350
350
  var r, i = e;
351
351
  e.startsWith("+1") || (i = "+1" + e);
352
352
  for (var a = 0; a < t.length; a++) {
@@ -358,7 +358,7 @@ function z({ elems: t, number: e, force: n = !1 }) {
358
358
  continue;
359
359
  }
360
360
  var o = E({ elem: t[a] });
361
- if (r ? !n && o.number && r.number && r.number !== o.number && l(
361
+ if (r ? !n && o.number && r.number && r.number !== o.number && f(
362
362
  "overlaying multiple numbers with a single number",
363
363
  r.number,
364
364
  o.number
@@ -378,7 +378,7 @@ function z({ elems: t, number: e, force: n = !1 }) {
378
378
  g("no number text found:", t[a]);
379
379
  }
380
380
  }
381
- function _({ elems: t }) {
381
+ function x({ elems: t }) {
382
382
  for (var e = 0; e < t.length; e++)
383
383
  if (b.has(t[e])) {
384
384
  var n = t[e].innerHTML, r = b.get(t[e]);
@@ -388,14 +388,14 @@ function _({ elems: t }) {
388
388
  } else
389
389
  g("element not in map:", t[e]);
390
390
  }
391
- function H(t) {
391
+ function X(t) {
392
392
  clearInterval(v[t]), delete v[t];
393
393
  }
394
- function W() {
394
+ function K() {
395
395
  for (var t in v)
396
- H(t);
396
+ X(t);
397
397
  }
398
- function Q(i) {
398
+ function Y(i) {
399
399
  return d(this, arguments, function* ({
400
400
  poolId: t,
401
401
  apiUrl: e,
@@ -407,16 +407,16 @@ function Q(i) {
407
407
  number: n,
408
408
  context: r,
409
409
  properties: {
410
- zar: S()
410
+ zar: P()
411
411
  }
412
- }, o = yield O({ url: `${e}/number_pool`, data: a });
412
+ }, o = yield _({ url: `${e}/number_pool`, data: a });
413
413
  return o;
414
414
  });
415
415
  }
416
- function x() {
416
+ function O() {
417
417
  return window.zarPoolData && window.zarPoolData.status === L && window.zarPoolData.number;
418
418
  }
419
- function y() {
419
+ function j() {
420
420
  if (!window.zarPoolDataLayer || !Array.isArray(window.zarPoolDataLayer) || window.zarPoolDataLayer.length === 0)
421
421
  return null;
422
422
  for (var t = {}, e = 0; e < window.zarPoolDataLayer.length; e++) {
@@ -426,6 +426,16 @@ function y() {
426
426
  }
427
427
  return window.zarPoolDataLayer.length = 0, t;
428
428
  }
429
+ function Ot() {
430
+ return C($) || {};
431
+ }
432
+ function It(t) {
433
+ t && typeof t == "object" && G($, t);
434
+ }
435
+ function I({ contextCallback: t = null } = {}) {
436
+ var e = Ot() || {}, n = j() || {}, r = Object.assign({}, e, n);
437
+ return t && (r = t(r) || {}), It(r), r;
438
+ }
429
439
  function T(i) {
430
440
  return d(this, arguments, function* ({
431
441
  apiUrl: t,
@@ -433,8 +443,8 @@ function T(i) {
433
443
  number: n,
434
444
  context: r
435
445
  }) {
436
- if (!x()) {
437
- l("no valid pool data, not updating context");
446
+ if (!O()) {
447
+ f("no valid pool data, not updating context");
438
448
  return;
439
449
  }
440
450
  var a = {
@@ -442,28 +452,28 @@ function T(i) {
442
452
  number: n,
443
453
  context: r,
444
454
  properties: {
445
- zar: S()
455
+ zar: P()
446
456
  }
447
- }, o = yield O({ url: `${t}/update_number`, data: a });
457
+ }, o = yield _({ url: `${t}/update_number`, data: a });
448
458
  return o;
449
459
  });
450
460
  }
451
- function It(r) {
461
+ function kt(r) {
452
462
  return d(this, arguments, function* ({ apiUrl: t, key: e = null, with_contexts: n = !1 }) {
453
463
  var i = {
454
464
  key: e,
455
465
  with_contexts: n
456
- }, a = yield pt({
466
+ }, a = yield ht({
457
467
  url: `${t}/number_pool_stats`,
458
468
  params: i
459
469
  });
460
470
  return a;
461
471
  });
462
472
  }
463
- function C() {
473
+ function U() {
464
474
  return d(this, arguments, function* ({
465
475
  overlayElements: t,
466
- apiUrl: e = G(),
476
+ apiUrl: e = H(),
467
477
  contextCallback: n = null,
468
478
  initCallback: r = null,
469
479
  checkLastRenewal: i = !0
@@ -472,39 +482,38 @@ function C() {
472
482
  return { status: m, msg: "stopped" };
473
483
  const a = window.zarPoolData.pool_id, o = window.zarPoolData.number;
474
484
  var c = Date.now(), u = R[a];
475
- if (i && u && c - u < ht)
485
+ if (i && u && c - u < yt)
476
486
  return { status: L };
477
487
  R[a] = c;
478
- var s = y() || {};
479
- n && (s = n(s) || {});
488
+ var s = I({ contextCallback: n });
480
489
  try {
481
- var f = yield Q({ poolId: a, apiUrl: e, number: o, context: s });
482
- } catch (X) {
483
- var w = "error getting number: " + JSON.stringify(X);
484
- return l(w), A++, A >= mt && (l("max failures, stopping pool"), N = !0, W(), t && _({ elems: t })), { status: m, msg: w };
490
+ var l = yield Y({ poolId: a, apiUrl: e, number: o, context: s });
491
+ } catch (Z) {
492
+ var w = "error getting number: " + JSON.stringify(Z);
493
+ return f(w), B++, B >= Pt && (f("max failures, stopping pool"), N = !0, K(), t && x({ elems: t })), { status: m, msg: w };
485
494
  }
486
- if (f.status === L && f.number) {
495
+ if (l.status === L && l.number) {
487
496
  var h = !1;
488
- f.number !== window.zarPoolData.number && (l(
489
- "number changed from " + window.zarPoolData.number + " to " + f.number
490
- ), window.zarPoolData.number = f.number, h = !0), t && z({
497
+ l.number !== window.zarPoolData.number && (f(
498
+ "number changed from " + window.zarPoolData.number + " to " + l.number
499
+ ), window.zarPoolData.number = l.number, h = !0), t && D({
491
500
  elems: t,
492
- number: f.number,
501
+ number: l.number,
493
502
  force: h
494
503
  });
495
504
  } else
496
- t && _({ elems: t }), v[a] && (clearInterval(v[a]), delete v[a]);
497
- return r && (f.renew = !0, r(f)), f;
505
+ t && x({ elems: t }), v[a] && (clearInterval(v[a]), delete v[a]);
506
+ return r && (l.renew = !0, r(l)), l;
498
507
  });
499
508
  }
500
509
  function k(t) {
501
- return ft(t) ? t() : t;
510
+ return wt(t) ? t() : t;
502
511
  }
503
- function Ot(t) {
504
- if (!window.zarPoolDLObserverDone && x()) {
512
+ function zt(t) {
513
+ if (!window.zarPoolDLObserverDone && O()) {
505
514
  var e = window.zarPoolDataLayer.push;
506
515
  window.zarPoolDataLayer.push = function(...r) {
507
- var i = e.apply(this, r), a = y();
516
+ var i = e.apply(this, r), a = I({ contextCallback: null });
508
517
  return a && T({
509
518
  apiUrl: t,
510
519
  poolId: window.zarPoolData.pool_id,
@@ -512,8 +521,8 @@ function Ot(t) {
512
521
  context: a
513
522
  }), i;
514
523
  };
515
- var n = y();
516
- n && T({
524
+ var n = I({ contextCallback: null });
525
+ n && Object.keys(n).length > 0 && T({
517
526
  apiUrl: t,
518
527
  poolId: window.zarPoolData.pool_id,
519
528
  number: window.zarPoolData.number,
@@ -521,43 +530,44 @@ function Ot(t) {
521
530
  }), window.zarPoolDLObserverDone = !0;
522
531
  }
523
532
  }
524
- function M() {
533
+ function q() {
525
534
  return d(this, arguments, function* ({ poolData: t, poolConfig: e, apiUrl: n } = {}) {
526
535
  var r;
527
536
  if (N = !1, !e || !e.poolId || !e.overlayQuerySelector || !n)
528
- return r = "missing pool config: " + JSON.stringify(e), l(r), e.initCallback && e.initCallback({ status: m, msg: r }), v;
537
+ return r = "missing pool config: " + JSON.stringify(e), f(r), e.initCallback && e.initCallback({ status: m, msg: r }), v;
529
538
  var i = k(e.poolId);
530
539
  if (!i)
531
- return r = "no pool ID", l(r), e.initCallback && e.initCallback({ status: m, msg: r }), v;
540
+ return r = "no pool ID", f(r), e.initCallback && e.initCallback({ status: m, msg: r }), v;
532
541
  if (!t) {
533
- var a = y() || {};
534
- e.contextCallback && (a = e.contextCallback(a) || {});
542
+ var a = I({
543
+ contextCallback: e.contextCallback
544
+ });
535
545
  try {
536
- t = yield Q({ poolId: i, apiUrl: n, number: null, context: a });
546
+ t = yield Y({ poolId: i, apiUrl: n, number: null, context: a });
537
547
  } catch (o) {
538
- return r = "error getting number on init: " + JSON.stringify(o), l(r), e.initCallback && e.initCallback({ status: m, msg: r }), v;
548
+ return r = "error getting number on init: " + JSON.stringify(o), f(r), e.initCallback && e.initCallback({ status: m, msg: r }), v;
539
549
  }
540
550
  }
541
- if (window.zarPoolData = t, x()) {
551
+ if (window.zarPoolData = t, O()) {
542
552
  R[i] = Date.now();
543
553
  try {
544
- Ot(n);
554
+ zt(n);
545
555
  } catch (o) {
546
- l("data layer error: " + JSON.stringify(o));
556
+ f("data layer error: " + JSON.stringify(o));
547
557
  }
548
- lt(function() {
558
+ vt(function() {
549
559
  var o = document.querySelectorAll(
550
560
  e.overlayQuerySelector
551
561
  );
552
562
  if (!o) {
553
563
  var c = "No elems found for:" + e.overlayQuerySelector;
554
- l(c), e.initCallback && e.initCallback({ status: m, msg: c });
564
+ f(c), e.initCallback && e.initCallback({ status: m, msg: c });
555
565
  return;
556
566
  }
557
- z({ elems: o, number: t.number });
558
- var u = e.renewalInterval || bt, s = setInterval(function() {
567
+ D({ elems: o, number: t.number });
568
+ var u = e.renewalInterval || mt, s = setInterval(function() {
559
569
  try {
560
- C({
570
+ U({
561
571
  overlayElements: o,
562
572
  apiUrl: n,
563
573
  contextCallback: e.contextCallback,
@@ -565,34 +575,34 @@ function M() {
565
575
  });
566
576
  } catch (h) {
567
577
  var w = "error on interval: " + JSON.stringify(h);
568
- l(w);
578
+ f(w);
569
579
  }
570
580
  }, u);
571
581
  v[t.pool_id] = s, e.initCallback && e.initCallback(t);
572
- var f = function(w = {}) {
582
+ var l = function(w = {}) {
573
583
  try {
574
- if (!x())
584
+ if (!O())
575
585
  return;
576
- (w.type === "vc" && document.visibilityState === "visible" || w.type === "ps" && w.persisted === !0) && C({
586
+ (w.type === "vc" && document.visibilityState === "visible" || w.type === "ps" && w.persisted === !0) && U({
577
587
  overlayElements: o,
578
588
  apiUrl: n,
579
589
  contextCallback: e.contextCallback,
580
590
  initCallback: e.initCallback
581
591
  });
582
592
  } catch (h) {
583
- l("error on renew: " + JSON.stringify(h));
593
+ f("error on renew: " + JSON.stringify(h));
584
594
  }
585
595
  };
586
596
  document.addEventListener(
587
597
  "visibilitychange",
588
598
  function() {
589
- f({ type: "vc" });
599
+ l({ type: "vc" });
590
600
  },
591
601
  { passive: !0 }
592
602
  ), window.addEventListener(
593
603
  "pageshow",
594
604
  function(w) {
595
- f({ type: "ps", persisted: w && w.persisted });
605
+ l({ type: "ps", persisted: w && w.persisted });
596
606
  },
597
607
  { passive: !0 }
598
608
  );
@@ -601,8 +611,8 @@ function M() {
601
611
  return v;
602
612
  });
603
613
  }
604
- function _t({ apiUrl: t, poolConfig: e }) {
605
- return B(), {
614
+ function Dt({ apiUrl: t, poolConfig: e }) {
615
+ return M(), {
606
616
  name: "zar",
607
617
  config: { apiUrl: t, poolConfig: e },
608
618
  initialize: function({ config: n }) {
@@ -611,16 +621,16 @@ function _t({ apiUrl: t, poolConfig: e }) {
611
621
  return !0;
612
622
  },
613
623
  pageStart: function({ payload: n, config: r, instance: i }) {
614
- n.properties.zar = S(), n.properties.referrer = document.referrer, n.properties.is_bot = j();
624
+ n.properties.zar = P(), n.properties.referrer = document.referrer, n.properties.is_bot = A();
615
625
  try {
616
626
  var a = r.poolConfig;
617
627
  if (a && a.poolId) {
618
628
  n.properties.pool_id = k(a.poolId);
619
- var o = y() || {};
629
+ var o = j() || {};
620
630
  a.contextCallback && (n.properties.pool_context = a.contextCallback(o) || {});
621
631
  }
622
632
  } catch (c) {
623
- l("error getting pool id: " + JSON.stringify(c));
633
+ f("error getting pool id: " + JSON.stringify(c));
624
634
  }
625
635
  return n;
626
636
  },
@@ -629,14 +639,14 @@ function _t({ apiUrl: t, poolConfig: e }) {
629
639
  g("page", n, r, a);
630
640
  for (var c = 0, u = 3, s; c < u; )
631
641
  try {
632
- s = yield O({ url: `${a.apiUrl}/page`, data: n });
642
+ s = yield _({ url: `${a.apiUrl}/page`, data: n });
633
643
  break;
634
- } catch (f) {
644
+ } catch (l) {
635
645
  if (c++, c >= u)
636
- throw l("error posting page: " + JSON.stringify(f)), f;
646
+ throw f("error posting page: " + JSON.stringify(l)), l;
637
647
  yield new Promise((w) => setTimeout(w, 1e3));
638
648
  }
639
- s && s.pool_data && M({
649
+ s && s.pool_data && q({
640
650
  poolData: s.pool_data,
641
651
  poolConfig: a.poolConfig,
642
652
  apiUrl: a.apiUrl
@@ -644,10 +654,10 @@ function _t({ apiUrl: t, poolConfig: e }) {
644
654
  });
645
655
  },
646
656
  trackStart: function({ payload: n, config: r, instance: i }) {
647
- return n.properties.zar = S(), n.properties.url = window.location.href, n.properties.referrer = document.referrer, n;
657
+ return n.properties.zar = P(), n.properties.url = window.location.href, n.properties.referrer = document.referrer, n;
648
658
  },
649
659
  track: function({ payload: n, options: r, instance: i, config: a }) {
650
- g("track", n), O({ url: `${a.apiUrl}/track`, data: n, beacon: !0 });
660
+ g("track", n), _({ url: `${a.apiUrl}/track`, data: n, beacon: !0 });
651
661
  },
652
662
  methods: {
653
663
  apiUrl() {
@@ -657,23 +667,23 @@ function _t({ apiUrl: t, poolConfig: e }) {
657
667
  return e;
658
668
  },
659
669
  initIDs() {
660
- return B();
670
+ return M();
661
671
  },
662
672
  getIDs() {
663
- return St();
673
+ return xt();
664
674
  },
665
675
  getStorage() {
666
- return S();
676
+ return P();
667
677
  },
668
678
  getVID() {
669
- return $(D);
679
+ return Q(z);
670
680
  },
671
681
  isBot() {
672
- return j();
682
+ return A();
673
683
  },
674
684
  initTrackingPool({ poolConfig: n }) {
675
685
  var r = this.instance.plugins.zar;
676
- return M({
686
+ return q({
677
687
  poolData: null,
678
688
  poolConfig: Object.assign(r.poolConfig(), n || {}),
679
689
  apiUrl: r.apiUrl()
@@ -692,10 +702,10 @@ function _t({ apiUrl: t, poolConfig: e }) {
692
702
  return v;
693
703
  },
694
704
  clearPoolInterval({ poolId: n }) {
695
- H(n);
705
+ X(n);
696
706
  },
697
707
  clearPoolIntervals() {
698
- W();
708
+ K();
699
709
  },
700
710
  extractPhoneNumbers({ elems: n }) {
701
711
  for (var r = [], i = 0; i < n.length; i++) {
@@ -705,13 +715,13 @@ function _t({ apiUrl: t, poolConfig: e }) {
705
715
  return r;
706
716
  },
707
717
  overlayPhoneNumber({ overlayElements: n, number: r }) {
708
- z({ elems: n, number: r });
718
+ D({ elems: n, number: r });
709
719
  },
710
720
  revertOverlayNumbers({ overlayElements: n }) {
711
- _({ elems: n });
721
+ x({ elems: n });
712
722
  },
713
723
  getPoolStats({ key: n = null, with_contexts: r = !1 }) {
714
- return It({
724
+ return kt({
715
725
  apiUrl: this.instance.plugins.zar.apiUrl(),
716
726
  key: n,
717
727
  with_contexts: r
@@ -720,28 +730,31 @@ function _t({ apiUrl: t, poolConfig: e }) {
720
730
  }
721
731
  };
722
732
  }
723
- function kt({
733
+ function Rt({
724
734
  app: t,
725
735
  ga4Config: e = null,
726
736
  facebookConfig: n = null,
727
737
  apiUrl: r = null,
728
738
  poolConfig: i = null
729
739
  }) {
730
- r || (r = G());
731
- var a = [_t({ apiUrl: r, poolConfig: i })];
732
- return e && a.push(ut(e)), n && a.push(it(n)), K({ app: t, plugins: a });
740
+ r || (r = H());
741
+ var a = [Dt({ apiUrl: r, poolConfig: i })];
742
+ return e && a.push(lt(e)), n && a.push(ct(n)), tt({ app: t, plugins: a });
733
743
  }
734
- const Dt = {
744
+ const Nt = {
735
745
  extractPhoneNumber: E,
736
- overlayPhoneNumber: z,
737
- revertOverlayNumbers: _,
738
- drainPoolDataLayer: y,
746
+ overlayPhoneNumber: D,
747
+ revertOverlayNumbers: x,
748
+ drainPoolDataLayer: j,
739
749
  getPoolId: k
740
750
  };
741
751
  export {
742
- K as Analytics,
743
- Dt as __test__,
744
- kt as init,
745
- _t as zar
752
+ tt as Analytics,
753
+ Nt as __test__,
754
+ vt as afterDOMContentLoaded,
755
+ C as getSessionStorage,
756
+ Rt as init,
757
+ G as setSessionStorage,
758
+ Dt as zar
746
759
  };
747
760
  //# sourceMappingURL=zar.es.js.map