zar 0.5.1 → 0.5.2

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