@arsel.sa/web-sdk 1.1.0 → 1.2.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/arsel.js CHANGED
@@ -3,9 +3,9 @@ const S = {
3
3
  events: "events",
4
4
  inAppBeacons: "inapp_beacons"
5
5
  };
6
- let z = null;
6
+ let H = null;
7
7
  function Je() {
8
- return z || (z = new Promise((e, t) => {
8
+ return H || (H = new Promise((e, t) => {
9
9
  const n = indexedDB.open(Ye, 2);
10
10
  n.onupgradeneeded = () => {
11
11
  const i = n.result;
@@ -13,42 +13,42 @@ function Je() {
13
13
  for (const r of Object.values(S))
14
14
  i.objectStoreNames.contains(r) || i.createObjectStore(r, { keyPath: "id", autoIncrement: !0 });
15
15
  }, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
16
- }), z);
16
+ }), H);
17
17
  }
18
- function x(e, t, n) {
18
+ function P(e, t, n) {
19
19
  return Je().then(
20
- (i) => new Promise((r, o) => {
21
- const s = n(i.transaction(e, t).objectStore(e));
22
- s.onsuccess = () => r(s.result), s.onerror = () => o(s.error);
20
+ (i) => new Promise((r, s) => {
21
+ const a = n(i.transaction(e, t).objectStore(e));
22
+ a.onsuccess = () => r(a.result), a.onerror = () => s(a.error);
23
23
  })
24
24
  );
25
25
  }
26
26
  function c(e) {
27
- return x("kv", "readonly", (t) => t.get(e)).then(
27
+ return P("kv", "readonly", (t) => t.get(e)).then(
28
28
  (t) => t ?? null
29
29
  );
30
30
  }
31
- function d(e, t) {
32
- return x("kv", "readwrite", (n) => n.put(t, e));
31
+ function u(e, t) {
32
+ return P("kv", "readwrite", (n) => n.put(t, e));
33
33
  }
34
- function K(e) {
35
- return x("kv", "readwrite", (t) => t.delete(e));
34
+ function L(e) {
35
+ return P("kv", "readwrite", (t) => t.delete(e));
36
36
  }
37
37
  function De(e, t, n = "") {
38
- return x(
38
+ return P(
39
39
  e,
40
40
  "readwrite",
41
41
  (i) => i.add({ body: t, idempotencyKey: n, createdAtMs: Date.now() })
42
42
  );
43
43
  }
44
44
  function le(e) {
45
- return x(e, "readonly", (t) => t.getAll());
45
+ return P(e, "readonly", (t) => t.getAll());
46
46
  }
47
47
  function ue(e, t) {
48
- return x(e, "readwrite", (n) => n.delete(t));
48
+ return P(e, "readwrite", (n) => n.delete(t));
49
49
  }
50
50
  function Oe(e) {
51
- return x(e, "readonly", (t) => t.count());
51
+ return P(e, "readonly", (t) => t.count());
52
52
  }
53
53
  async function Ge(e, t) {
54
54
  const n = await le(e);
@@ -56,7 +56,7 @@ async function Ge(e, t) {
56
56
  for (const i of n.slice(0, n.length - t))
57
57
  i.id !== void 0 && await ue(e, i.id);
58
58
  }
59
- const a = {
59
+ const o = {
60
60
  clientKey: "client_key",
61
61
  baseUrl: "base_url",
62
62
  anonymousId: "anonymous_id",
@@ -68,6 +68,7 @@ const a = {
68
68
  vapidKeyVersion: "vapid_key_version",
69
69
  endpoint: "endpoint",
70
70
  subscriptionStatus: "subscription_status",
71
+ installReported: "install_reported",
71
72
  sessionStartedAt: "session_started_at",
72
73
  backgroundedAt: "backgrounded_at",
73
74
  lastResponseCode: "last_response_code",
@@ -85,40 +86,40 @@ const a = {
85
86
  inAppSession: "inapp_session"
86
87
  };
87
88
  async function X() {
88
- const e = await c(a.anonymousId);
89
+ const e = await c(o.anonymousId);
89
90
  if (e) return e;
90
91
  const t = crypto.randomUUID();
91
- return await d(a.anonymousId, t), t;
92
+ return await u(o.anonymousId, t), t;
92
93
  }
93
94
  async function Ze() {
94
95
  const e = crypto.randomUUID();
95
- return await d(a.anonymousId, e), e;
96
+ return await u(o.anonymousId, e), e;
96
97
  }
97
- const Q = "1.1.0", Me = { "X-Arsel-SDK": `web/${Q}` }, y = {
98
+ const j = "1.2.0", Re = { "X-Arsel-SDK": `web/${j}` }, y = {
98
99
  success: "success",
99
100
  retryable: "retryable",
100
101
  permanent: "permanent",
101
102
  reauth: "reauth"
102
- }, Y = -1;
103
- function Re(e, t) {
103
+ }, J = -1;
104
+ function Me(e, t) {
104
105
  return e >= 200 && e <= 299 ? y.success : e === 408 || e === 429 || e >= 500 && e <= 599 ? y.retryable : t && (e === 401 || e === 403 || e === 404) ? y.reauth : e === 404 ? y.retryable : y.permanent;
105
106
  }
106
- async function J(e, t) {
107
+ async function G(e, t) {
107
108
  try {
108
109
  await Promise.all([
109
- d(a.lastResponseCode, t),
110
- d(a.lastResponsePath, e),
111
- d(a.lastResponseAtMs, Date.now())
110
+ u(o.lastResponseCode, t),
111
+ u(o.lastResponsePath, e),
112
+ u(o.lastResponseAtMs, Date.now())
112
113
  ]);
113
114
  } catch {
114
115
  }
115
116
  }
116
- async function j(e, t, n, i = {}, r = !1) {
117
- let o;
117
+ async function z(e, t, n, i = {}, r = !1) {
118
+ let s;
118
119
  try {
119
- o = await fetch(e + t, {
120
+ s = await fetch(e + t, {
120
121
  method: "POST",
121
- headers: { "Content-Type": "application/json", ...Me, ...i },
122
+ headers: { "Content-Type": "application/json", ...Re, ...i },
122
123
  body: JSON.stringify(n),
123
124
  // The SDK never relies on cookies, and sending them would attach a
124
125
  // first-party session to a cross-origin call for no reason.
@@ -126,41 +127,41 @@ async function j(e, t, n, i = {}, r = !1) {
126
127
  keepalive: !0
127
128
  });
128
129
  } catch {
129
- return await J(t, Y), { result: y.retryable, code: Y, body: null };
130
+ return await G(t, J), { result: y.retryable, code: J, body: null };
130
131
  }
131
- await J(t, o.status);
132
- const s = Re(o.status, r);
132
+ await G(t, s.status);
133
+ const a = Me(s.status, r);
133
134
  let l = null;
134
135
  try {
135
- l = await o.json();
136
+ l = await s.json();
136
137
  } catch {
137
138
  }
138
- return { result: s, code: o.status, body: l };
139
+ return { result: a, code: s.status, body: l };
139
140
  }
140
141
  async function de(e, t, n = {}, i = !1, r = {}) {
141
- let o;
142
+ let s;
142
143
  try {
143
- o = await fetch(e + t, {
144
+ s = await fetch(e + t, {
144
145
  ...r,
145
146
  credentials: "omit",
146
- headers: { ...Me, ...n }
147
+ headers: { ...Re, ...n }
147
148
  });
148
149
  } catch {
149
- return await J(t, Y), { result: y.retryable, code: Y, body: null };
150
+ return await G(t, J), { result: y.retryable, code: J, body: null };
150
151
  }
151
- await J(t, o.status);
152
- let s = null;
152
+ await G(t, s.status);
153
+ let a = null;
153
154
  try {
154
- s = await o.json();
155
+ a = await s.json();
155
156
  } catch {
156
157
  }
157
158
  return {
158
- result: Re(o.status, i),
159
- code: o.status,
160
- body: s
159
+ result: Me(s.status, i),
160
+ code: s.status,
161
+ body: a
161
162
  };
162
163
  }
163
- const Qe = "/v1/events/send", O = "arsel.", et = `${O}session_start`, tt = `${O}session_end`, nt = `${O}identify`, it = `${O}screen`, rt = 80, ot = 128, st = 255, we = 50, at = 8, ve = 64 * 1024;
164
+ const Qe = "/v1/events/send", x = "arsel.", et = `${x}session_start`, tt = `${x}session_end`, nt = `${x}identify`, it = `${x}app_installed`, rt = `${x}screen_view`, ot = 80, st = 128, at = 255, ge = 50, ct = 8, ve = 64 * 1024;
164
165
  function se(e, t) {
165
166
  if (e === null) return null;
166
167
  const n = typeof e;
@@ -169,171 +170,171 @@ function se(e, t) {
169
170
  if (n === "bigint") return String(e);
170
171
  if (e instanceof Date)
171
172
  return Number.isNaN(e.getTime()) ? void 0 : e.toISOString();
172
- if (n !== "object" || t >= at) return;
173
+ if (n !== "object" || t >= ct) return;
173
174
  if (Array.isArray(e))
174
175
  return e.map((r) => se(r, t + 1) ?? null);
175
176
  const i = {};
176
- for (const [r, o] of Object.entries(e)) {
177
+ for (const [r, s] of Object.entries(e)) {
177
178
  if (!r) continue;
178
- const s = se(o, t + 1);
179
- s !== void 0 && (i[r] = s);
179
+ const a = se(s, t + 1);
180
+ a !== void 0 && (i[r] = a);
180
181
  }
181
182
  return i;
182
183
  }
183
- function ct(e) {
184
+ function lt(e) {
184
185
  const t = {};
185
186
  let n = 2, i = !1;
186
- for (const [r, o] of Object.entries(e ?? {})) {
187
+ for (const [r, s] of Object.entries(e ?? {})) {
187
188
  if (!r) continue;
188
- const s = se(o, 0);
189
- if (s === void 0) continue;
190
- const l = r.length + JSON.stringify(s).length + 6;
189
+ const a = se(s, 0);
190
+ if (a === void 0) continue;
191
+ const l = r.length + JSON.stringify(a).length + 6;
191
192
  if (n + l > ve) {
192
193
  i = !0;
193
194
  continue;
194
195
  }
195
- n += l, t[r] = s;
196
+ n += l, t[r] = a;
196
197
  }
197
198
  return i && console.warn(
198
199
  `[arsel] event data exceeded ${ve} serialized bytes — oversized properties were dropped`
199
200
  ), t;
200
201
  }
201
- async function lt(e, t, n) {
202
- const [i, r, o, s] = await Promise.all([
202
+ async function ut(e, t, n) {
203
+ const [i, r, s, a] = await Promise.all([
203
204
  X(),
204
- c(a.externalId),
205
- c(a.email),
206
- c(a.phoneNumber)
205
+ c(o.externalId),
206
+ c(o.email),
207
+ c(o.phoneNumber)
207
208
  ]), l = {
208
- event: e.slice(0, rt),
209
+ event: e.slice(0, ot),
209
210
  // Always sent, even once identified: it is what the backend merges FROM.
210
- anonymous_id: i.slice(0, ot),
211
- data: ct(t),
211
+ anonymous_id: i.slice(0, st),
212
+ data: lt(t),
212
213
  timestamp: new Date(n).toISOString()
213
214
  };
214
- return r && (l.external_id = r.slice(0, st)), o && (l.email = o), s && (l.phone_number = s), JSON.stringify(l);
215
+ return r && (l.external_id = r.slice(0, at)), s && (l.email = s), a && (l.phone_number = a), JSON.stringify(l);
215
216
  }
216
- async function M(e, t, n = Date.now()) {
217
- await De(S.events, await lt(e, t, n), crypto.randomUUID()), V().catch(() => {
217
+ async function k(e, t, n = Date.now()) {
218
+ await De(S.events, await ut(e, t, n), crypto.randomUUID()), V().catch(() => {
218
219
  });
219
220
  }
220
221
  let $ = null;
221
222
  function V() {
222
- return $ || ($ = ft().finally(() => {
223
+ return $ || ($ = pt().finally(() => {
223
224
  $ = null;
224
225
  }), $);
225
226
  }
226
- function ut(e) {
227
+ function dt(e) {
227
228
  const t = e[0].idempotencyKey;
228
229
  return e.length === 1 ? t : `${t}:${e[e.length - 1].idempotencyKey}:${e.length}`;
229
230
  }
230
- function dt(e, t, n) {
231
+ function ft(e, t, n) {
231
232
  e.some(
232
233
  (r) => r.external_id || r.email || r.phone_number
233
234
  ) && console.error(
234
235
  `[arsel] ${e.length} event(s) carrying identifiers were rejected permanently (HTTP ${t}) and dropped. Response: ${JSON.stringify(n)}`
235
236
  );
236
237
  }
237
- async function ft() {
238
+ async function pt() {
238
239
  const [e, t] = await Promise.all([
239
- c(a.clientKey),
240
- c(a.baseUrl)
240
+ c(o.clientKey),
241
+ c(o.baseUrl)
241
242
  ]);
242
243
  if (!(!e || !t))
243
244
  for (; ; ) {
244
245
  const n = await le(S.events);
245
246
  if (n.length === 0) return;
246
- for (let i = 0; i < n.length; i += we) {
247
- const r = n.slice(i, i + we), o = r.map(
247
+ for (let i = 0; i < n.length; i += ge) {
248
+ const r = n.slice(i, i + ge), s = r.map(
248
249
  (l) => JSON.parse(l.body)
249
- ), s = await j(
250
+ ), a = await z(
250
251
  t,
251
252
  Qe,
252
- r.length === 1 ? o[0] : { events: o },
253
+ r.length === 1 ? s[0] : { events: s },
253
254
  {
254
255
  Authorization: `Bearer ${e}`,
255
- "Idempotency-Key": ut(r)
256
+ "Idempotency-Key": dt(r)
256
257
  }
257
258
  );
258
- if (s.result === y.retryable) return;
259
- s.result !== y.success && dt(o, s.code, s.body);
259
+ if (a.result === y.retryable) return;
260
+ a.result !== y.success && ft(s, a.code, a.body);
260
261
  for (const l of r)
261
262
  l.id !== void 0 && await ue(S.events, l.id);
262
263
  }
263
264
  }
264
265
  }
265
- const ee = 1e3, pt = 720 * 60 * 60 * ee, mt = 500, Se = 50, yt = 86400, bt = 900, H = {
266
+ const ee = 1e3, mt = 720 * 60 * 60 * ee, yt = 500, Se = 50, bt = 86400, ht = 900, q = {
266
267
  maxPerSession: 1,
267
268
  maxLifetime: 3,
268
269
  minSecondsBetween: 86400,
269
270
  delaySeconds: 0
270
- }, ht = [
271
+ }, wt = [
271
272
  "MODAL",
272
273
  "BANNER_TOP",
273
274
  "BANNER_BOTTOM",
274
275
  "IMAGE_ONLY"
275
276
  ];
276
- let fe = !1, u = null, h = {}, v = { startedAt: 0, counts: {} }, F = null, L = null, Ue = !1, ie = null, _ = null, Be = !1, Ae = !1;
277
+ let fe = !1, d = null, h = {}, v = { startedAt: 0, counts: {} }, F = null, K = null, Be = !1, ie = null, _ = null, Ue = !1, Ae = !1;
277
278
  function N(e) {
278
- Be && console.info(`[arsel] in-app: ${e}`);
279
+ Ue && console.info(`[arsel] in-app: ${e}`);
279
280
  }
280
281
  async function gt(e) {
281
- fe = !0, Be = e;
282
+ fe = !0, Ue = e;
282
283
  const [t, n, i] = await Promise.all([
283
- c(a.inAppBundle),
284
- c(a.inAppState),
285
- c(a.inAppSession)
284
+ c(o.inAppBundle),
285
+ c(o.inAppState),
286
+ c(o.inAppSession)
286
287
  ]);
287
- u = t, h = n ?? {}, v = i ?? { startedAt: 0, counts: {} }, await Le(), await te();
288
+ d = t, h = n ?? {}, v = i ?? { startedAt: 0, counts: {} }, await Ke(), await te();
288
289
  }
289
- function wt(e) {
290
+ function vt(e) {
290
291
  _ = e;
291
292
  }
292
- function vt(e) {
293
- Ue = e, e && ae();
293
+ function St(e) {
294
+ Be = e, e && ae();
294
295
  }
295
- function St() {
296
+ function At() {
296
297
  return {
297
- messages: (u == null ? void 0 : u.messages.length) ?? 0,
298
- bundleVersion: (u == null ? void 0 : u.bundleVersion) ?? null,
299
- fetchedAtMs: (u == null ? void 0 : u.fetchedAtMs) ?? null
298
+ messages: (d == null ? void 0 : d.messages.length) ?? 0,
299
+ bundleVersion: (d == null ? void 0 : d.bundleVersion) ?? null,
300
+ fetchedAtMs: (d == null ? void 0 : d.fetchedAtMs) ?? null
300
301
  };
301
302
  }
302
- function At() {
303
+ function Et() {
303
304
  return Oe(S.inAppBeacons);
304
305
  }
305
306
  async function Ce() {
306
- u = null, await K(a.inAppBundle), fe && await te(!0);
307
+ d = null, await L(o.inAppBundle), fe && await te(!0);
307
308
  }
308
- function Et() {
309
+ function It() {
309
310
  te(!0);
310
311
  }
311
312
  function te(e = !1) {
312
- return ie ?? (ie = It(e).finally(() => {
313
+ return ie ?? (ie = _t(e).finally(() => {
313
314
  ie = null;
314
315
  })), ie;
315
316
  }
316
- async function It(e) {
317
+ async function _t(e) {
317
318
  if (!fe) return;
318
319
  const t = Date.now();
319
- if (!e && u && t - u.fetchedAtMs < u.ttlSeconds * ee)
320
+ if (!e && d && t - d.fetchedAtMs < d.ttlSeconds * ee)
320
321
  return;
321
322
  const n = await $e();
322
323
  if (!n) return;
323
- const i = _t(n.clientKey, n.installationId), r = {
324
+ const i = Nt(n.clientKey, n.installationId), r = {
324
325
  "X-Arsel-Device-Auth": n.deviceSecret
325
- }, o = !!(u != null && u.bundleVersion);
326
- o && (r["If-None-Match"] = `"${(u == null ? void 0 : u.bundleVersion) ?? ""}"`);
327
- let s = await Ee(n.baseUrl, i, r);
328
- if (s.code === $t && o && Ae && (N("conditional request failed; retrying without If-None-Match"), delete r["If-None-Match"], s = await Ee(n.baseUrl, i, r)), s.code === Kt) {
329
- u && (u = { ...u, fetchedAtMs: t }, await d(a.inAppBundle, u));
326
+ }, s = !!(d != null && d.bundleVersion);
327
+ s && (r["If-None-Match"] = `"${(d == null ? void 0 : d.bundleVersion) ?? ""}"`);
328
+ let a = await Ee(n.baseUrl, i, r);
329
+ if (a.code === Lt && s && Ae && (N("conditional request failed; retrying without If-None-Match"), delete r["If-None-Match"], a = await Ee(n.baseUrl, i, r)), a.code === Kt) {
330
+ d && (d = { ...d, fetchedAtMs: t }, await u(o.inAppBundle, d));
330
331
  return;
331
332
  }
332
- if (s.result !== y.success || !s.body)
333
+ if (a.result !== y.success || !a.body)
333
334
  return;
334
- o || (Ae = !0);
335
- const l = Nt(s.body, t);
336
- l && (u = l, await d(a.inAppBundle, u), await Bt(l, t));
335
+ s || (Ae = !0);
336
+ const l = xt(a.body, t);
337
+ l && (d = l, await u(o.inAppBundle, d), await Ct(l, t));
337
338
  }
338
339
  function Ee(e, t, n) {
339
340
  return de(e, t, n, !0, {
@@ -343,63 +344,63 @@ function Ee(e, t, n) {
343
344
  cache: "no-store"
344
345
  });
345
346
  }
346
- function _t(e, t) {
347
+ function Nt(e, t) {
347
348
  const n = encodeURIComponent(e), i = encodeURIComponent(t);
348
349
  return `/api/v1/orgs/${n}/in-app/bundle?installationId=${i}`;
349
350
  }
350
351
  async function $e() {
351
352
  const [e, t, n, i] = await Promise.all([
352
- c(a.clientKey),
353
- c(a.baseUrl),
354
- c(a.installationId),
355
- c(a.deviceSecret)
353
+ c(o.clientKey),
354
+ c(o.baseUrl),
355
+ c(o.installationId),
356
+ c(o.deviceSecret)
356
357
  ]);
357
358
  return !e || !t || !n || !i ? null : { clientKey: e, baseUrl: t, installationId: n, deviceSecret: i };
358
359
  }
359
- function Nt(e, t) {
360
+ function xt(e, t) {
360
361
  if (typeof (e == null ? void 0 : e.bundleVersion) != "string")
361
362
  return N("response carried no bundleVersion"), null;
362
363
  e.contractVersion !== void 0 && e.contractVersion !== 1 && N(`unknown contractVersion ${String(e.contractVersion)}; proceeding`);
363
364
  const n = Array.isArray(e.messages) ? e.messages : [], i = [];
364
- for (const o of n) {
365
- const s = xt(o);
366
- s && i.push(s);
365
+ for (const s of n) {
366
+ const a = kt(s);
367
+ a && i.push(a);
367
368
  }
368
369
  n.length !== i.length && N(`dropped ${n.length - i.length} unrenderable message(s)`);
369
- const r = T(e.ttlSeconds);
370
+ const r = O(e.ttlSeconds);
370
371
  return {
371
372
  bundleVersion: e.bundleVersion,
372
- ttlSeconds: r && r > 0 ? r : bt,
373
+ ttlSeconds: r && r > 0 ? r : ht,
373
374
  fetchedAtMs: t,
374
375
  messages: i
375
376
  };
376
377
  }
377
- function xt(e) {
378
- if (!P(e)) return null;
379
- const t = m(e.campaignId), n = m(e.messageId), i = m(e.layout), r = P(e.content) ? e.content : null, o = r ? m(r.headline) : void 0;
380
- if (!t || !n || !i || !r || !o)
378
+ function kt(e) {
379
+ if (!D(e)) return null;
380
+ const t = m(e.campaignId), n = m(e.messageId), i = m(e.layout), r = D(e.content) ? e.content : null, s = r ? m(r.headline) : void 0;
381
+ if (!t || !n || !i || !r || !s)
381
382
  return N("message missing a required field"), null;
382
- if (!ht.includes(i))
383
+ if (!wt.includes(i))
383
384
  return N(`layout ${i} is not renderable on web`), null;
384
- const s = P(e.trigger) ? e.trigger : {}, l = P(e.displayRules) ? e.displayRules : {};
385
+ const a = D(e.trigger) ? e.trigger : {}, l = D(e.displayRules) ? e.displayRules : {};
385
386
  return {
386
387
  campaignId: t,
387
388
  messageId: n,
388
389
  variantKey: m(e.variantKey) ?? "default",
389
- priority: T(e.priority) ?? 0,
390
- expiresAtMs: Ct(e.expiresAt),
391
- triggerType: m(s.type) ?? "APP_OPEN",
392
- triggerEventName: m(s.eventName) ?? null,
393
- triggerProperties: P(s.properties) ? s.properties : null,
390
+ priority: O(e.priority) ?? 0,
391
+ expiresAtMs: $t(e.expiresAt),
392
+ triggerType: m(a.type) ?? "APP_OPEN",
393
+ triggerEventName: m(a.eventName) ?? null,
394
+ triggerProperties: D(a.properties) ? a.properties : null,
394
395
  displayRules: {
395
- maxPerSession: T(l.maxPerSession) ?? H.maxPerSession,
396
- maxLifetime: T(l.maxLifetime) ?? H.maxLifetime,
397
- minSecondsBetween: T(l.minSecondsBetween) ?? H.minSecondsBetween,
398
- delaySeconds: T(l.delaySeconds) ?? H.delaySeconds
396
+ maxPerSession: O(l.maxPerSession) ?? q.maxPerSession,
397
+ maxLifetime: O(l.maxLifetime) ?? q.maxLifetime,
398
+ minSecondsBetween: O(l.minSecondsBetween) ?? q.minSecondsBetween,
399
+ delaySeconds: O(l.delaySeconds) ?? q.delaySeconds
399
400
  },
400
401
  layout: i,
401
402
  content: {
402
- headline: o,
403
+ headline: s,
403
404
  body: m(r.body) ?? "",
404
405
  imageUrl: m(r.imageUrl),
405
406
  backgroundColor: m(r.backgroundColor),
@@ -408,11 +409,11 @@ function xt(e) {
408
409
  showCloseButton: r.showCloseButton !== !1
409
410
  },
410
411
  // `buttons` arrives as null, not [], when a campaign has none.
411
- buttons: Array.isArray(e.buttons) ? e.buttons.map(kt).filter((g) => g !== null) : []
412
+ buttons: Array.isArray(e.buttons) ? e.buttons.map(Pt).filter((w) => w !== null) : []
412
413
  };
413
414
  }
414
- function kt(e) {
415
- if (!P(e)) return null;
415
+ function Pt(e) {
416
+ if (!D(e)) return null;
416
417
  const t = m(e.buttonId), n = m(e.label), i = m(e.action);
417
418
  return !t || !n || !i ? null : {
418
419
  buttonId: t,
@@ -422,21 +423,21 @@ function kt(e) {
422
423
  style: m(e.style) === "SECONDARY" ? "SECONDARY" : "PRIMARY"
423
424
  };
424
425
  }
425
- function Pt(e, t, n, i) {
426
- if (Ue || F !== null || !u) return null;
427
- for (const r of u.messages) {
428
- if (r.triggerType !== t || t !== "APP_OPEN" && r.triggerEventName !== n || !Tt(r.triggerProperties, i)) continue;
429
- const o = h[r.messageId];
426
+ function Tt(e, t, n, i) {
427
+ if (Be || F !== null || !d) return null;
428
+ for (const r of d.messages) {
429
+ if (r.triggerType !== t || t !== "APP_OPEN" && r.triggerEventName !== n || !Dt(r.triggerProperties, i)) continue;
430
+ const s = h[r.messageId];
430
431
  if (r.expiresAtMs !== null && r.expiresAtMs <= e) {
431
432
  Ut(r);
432
433
  continue;
433
434
  }
434
- if (!(((o == null ? void 0 : o.shown) ?? 0) >= r.displayRules.maxLifetime) && !((v.counts[r.messageId] ?? 0) >= r.displayRules.maxPerSession) && !(o && e - o.lastShownAtMs < r.displayRules.minSecondsBetween * ee))
435
+ if (!(((s == null ? void 0 : s.shown) ?? 0) >= r.displayRules.maxLifetime) && !((v.counts[r.messageId] ?? 0) >= r.displayRules.maxPerSession) && !(s && e - s.lastShownAtMs < r.displayRules.minSecondsBetween * ee))
435
436
  return r;
436
437
  }
437
438
  return null;
438
439
  }
439
- function Tt(e, t) {
440
+ function Dt(e, t) {
440
441
  if (!e) return !0;
441
442
  const n = t;
442
443
  for (const [i, r] of Object.entries(e))
@@ -445,37 +446,37 @@ function Tt(e, t) {
445
446
  }
446
447
  function pe(e, t, n = {}) {
447
448
  try {
448
- const i = Pt(Date.now(), e, t, n);
449
+ const i = Tt(Date.now(), e, t, n);
449
450
  if (!i) return;
450
- F = i.messageId, Ke = t;
451
+ F = i.messageId, Le = t;
451
452
  const r = i.displayRules.delaySeconds * ee;
452
453
  if (r <= 0) {
453
454
  _ == null || _(i);
454
455
  return;
455
456
  }
456
- L = setTimeout(() => {
457
- L = null, _ == null || _(i);
457
+ K = setTimeout(() => {
458
+ K = null, _ == null || _(i);
458
459
  }, r);
459
460
  } catch (i) {
460
461
  N(`observe failed: ${i instanceof Error ? i.message : "unknown"}`), F = null;
461
462
  }
462
463
  }
463
- let Ke = null;
464
- function Dt() {
465
- return Ke;
464
+ let Le = null;
465
+ function Ot() {
466
+ return Le;
466
467
  }
467
468
  function Ie() {
468
- Le().then(() => {
469
+ Ke().then(() => {
469
470
  pe("APP_OPEN", null, {});
470
471
  });
471
472
  }
472
473
  function ae() {
473
- L !== null && (clearTimeout(L), L = null, F = null);
474
+ K !== null && (clearTimeout(K), K = null, F = null);
474
475
  }
475
476
  function _e() {
476
477
  F = null;
477
478
  }
478
- async function Ot(e, t) {
479
+ async function Rt(e, t) {
479
480
  const n = Date.now(), i = h[e.messageId] ?? {
480
481
  shown: 0,
481
482
  lastShownAtMs: 0,
@@ -491,18 +492,18 @@ async function Ot(e, t) {
491
492
  [e.messageId]: (v.counts[e.messageId] ?? 0) + 1
492
493
  }
493
494
  }, await Promise.all([
494
- d(a.inAppState, h),
495
- d(a.inAppSession, v)
495
+ u(o.inAppState, h),
496
+ u(o.inAppSession, v)
496
497
  ]), await ne(e, "impression", { triggerEventName: t });
497
498
  }
498
499
  async function Mt(e, t) {
499
500
  await ne(e, "clicked", { buttonId: t });
500
501
  }
501
- async function Rt(e, t) {
502
+ async function Bt(e, t) {
502
503
  await ne(e, "dismissed", {
503
504
  visibleSeconds: Math.max(
504
505
  0,
505
- Math.min(yt, Math.round(t))
506
+ Math.min(bt, Math.round(t))
506
507
  )
507
508
  });
508
509
  }
@@ -516,7 +517,7 @@ function Ut(e) {
516
517
  lastSeenInBundleAtMs: (t == null ? void 0 : t.lastSeenInBundleAtMs) ?? Date.now(),
517
518
  expiredReported: !0
518
519
  }
519
- }, d(a.inAppState, h), ne(e, "expired", {}));
520
+ }, u(o.inAppState, h), ne(e, "expired", {}));
520
521
  }
521
522
  async function ne(e, t, n) {
522
523
  const i = {
@@ -528,9 +529,9 @@ async function ne(e, t, n) {
528
529
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
529
530
  variantKey: e.variantKey
530
531
  };
531
- n.buttonId && (i.buttonId = n.buttonId), n.visibleSeconds !== void 0 && (i.visibleSeconds = n.visibleSeconds), n.triggerEventName && (i.triggerEventName = n.triggerEventName), await De(S.inAppBeacons, JSON.stringify(i)), await Ge(S.inAppBeacons, mt), q();
532
+ n.buttonId && (i.buttonId = n.buttonId), n.visibleSeconds !== void 0 && (i.visibleSeconds = n.visibleSeconds), n.triggerEventName && (i.triggerEventName = n.triggerEventName), await De(S.inAppBeacons, JSON.stringify(i)), await Ge(S.inAppBeacons, yt), Y();
532
533
  }
533
- async function q() {
534
+ async function Y() {
534
535
  const e = await $e();
535
536
  if (!e) return;
536
537
  const t = await le(S.inAppBeacons);
@@ -538,146 +539,146 @@ async function q() {
538
539
  const n = `/api/v1/orgs/${encodeURIComponent(e.clientKey)}/in-app/events`;
539
540
  for (let i = 0; i < t.length; i += Se) {
540
541
  const r = t.slice(i, i + Se);
541
- if ((await j(
542
+ if ((await z(
542
543
  e.baseUrl,
543
544
  n,
544
545
  {
545
546
  installationId: e.installationId,
546
- events: r.map((s) => JSON.parse(s.body))
547
+ events: r.map((a) => JSON.parse(a.body))
547
548
  },
548
549
  { "X-Arsel-Device-Auth": e.deviceSecret },
549
550
  !0
550
551
  )).result === y.retryable) return;
551
- for (const s of r)
552
- s.id !== void 0 && await ue(S.inAppBeacons, s.id);
552
+ for (const a of r)
553
+ a.id !== void 0 && await ue(S.inAppBeacons, a.id);
553
554
  }
554
555
  }
555
- async function Bt(e, t) {
556
+ async function Ct(e, t) {
556
557
  const n = new Set(e.messages.map((r) => r.messageId)), i = {};
557
- for (const [r, o] of Object.entries(h)) {
558
- const s = n.has(r) ? t : o.lastSeenInBundleAtMs;
559
- t - s > pt || (i[r] = { ...o, lastSeenInBundleAtMs: s });
558
+ for (const [r, s] of Object.entries(h)) {
559
+ const a = n.has(r) ? t : s.lastSeenInBundleAtMs;
560
+ t - a > mt || (i[r] = { ...s, lastSeenInBundleAtMs: a });
560
561
  }
561
- h = i, await d(a.inAppState, h);
562
+ h = i, await u(o.inAppState, h);
562
563
  }
563
- async function Le() {
564
- const e = await c(a.sessionStartedAt) ?? 0;
565
- v.startedAt !== e && (v = { startedAt: e, counts: {} }, await d(a.inAppSession, v));
564
+ async function Ke() {
565
+ const e = await c(o.sessionStartedAt) ?? 0;
566
+ v.startedAt !== e && (v = { startedAt: e, counts: {} }, await u(o.inAppSession, v));
566
567
  }
567
- function P(e) {
568
+ function D(e) {
568
569
  return typeof e == "object" && e !== null && !Array.isArray(e);
569
570
  }
570
571
  function m(e) {
571
572
  return typeof e == "string" && e.length > 0 ? e : void 0;
572
573
  }
573
- function T(e) {
574
+ function O(e) {
574
575
  return typeof e == "number" && Number.isFinite(e) ? e : void 0;
575
576
  }
576
- function Ct(e) {
577
+ function $t(e) {
577
578
  if (typeof e != "string") return null;
578
579
  const t = Date.parse(e);
579
580
  return Number.isNaN(t) ? null : t;
580
581
  }
581
- const $t = -1, Kt = 304, Lt = 2147483e3, re = 44, Ne = /^#[0-9a-fA-F]{3,8}$/, Vt = 0.6;
582
- let xe = null, Ft = 0;
583
- function Wt(e, t, n) {
584
- const i = e.layout === "MODAL", r = Date.now(), o = `arsel-iam-${Ft += 1}`, s = document.createElement("div");
585
- s.setAttribute("data-arsel-inapp", "");
586
- const l = s.attachShadow({ mode: "closed" });
587
- en(l), s.style.setProperty("z-index", String(t.zIndex || Lt)), s.style.setProperty("isolation", "isolate"), s.setAttribute("data-layout", e.layout), s.setAttribute("dir", Gt());
588
- const g = document.activeElement instanceof HTMLElement ? document.activeElement : null, f = document.createElement("div");
589
- f.className = "panel", f.tabIndex = -1, i ? (f.setAttribute("role", "dialog"), f.setAttribute("aria-modal", "true"), f.setAttribute("aria-labelledby", `${o}-h`), e.content.body && f.setAttribute("aria-describedby", `${o}-b`)) : (f.setAttribute("role", "status"), f.setAttribute("aria-live", "polite"));
590
- const A = Zt(e);
582
+ const Lt = -1, Kt = 304, Vt = 2147483e3, re = 44, Ne = /^#[0-9a-fA-F]{3,8}$/, Ft = 0.6;
583
+ let xe = null, Wt = 0;
584
+ function Xt(e, t, n) {
585
+ const i = e.layout === "MODAL", r = Date.now(), s = `arsel-iam-${Wt += 1}`, a = document.createElement("div");
586
+ a.setAttribute("data-arsel-inapp", "");
587
+ const l = a.attachShadow({ mode: "closed" });
588
+ tn(l), a.style.setProperty("z-index", String(t.zIndex || Vt)), a.style.setProperty("isolation", "isolate"), a.setAttribute("data-layout", e.layout), a.setAttribute("dir", Zt());
589
+ const w = document.activeElement instanceof HTMLElement ? document.activeElement : null, f = document.createElement("div");
590
+ f.className = "panel", f.tabIndex = -1, i ? (f.setAttribute("role", "dialog"), f.setAttribute("aria-modal", "true"), f.setAttribute("aria-labelledby", `${s}-h`), e.content.body && f.setAttribute("aria-describedby", `${s}-b`)) : (f.setAttribute("role", "status"), f.setAttribute("aria-live", "polite"));
591
+ const A = Qt(e);
591
592
  A.background && f.style.setProperty("background", A.background), A.text && f.style.setProperty("color", A.text);
592
593
  let C = !1;
593
594
  const E = (p) => {
594
- var w, ge;
595
- C || (C = !0, document.removeEventListener("keydown", k, !0), s.remove(), g != null && g.isConnected ? g.focus() : i && ((ge = (w = document.body).focus) == null || ge.call(w)), p === "dismiss" && n.onDismiss((Date.now() - r) / 1e3));
596
- }, k = (p) => {
595
+ var g, we;
596
+ C || (C = !0, document.removeEventListener("keydown", T, !0), a.remove(), w != null && w.isConnected ? w.focus() : i && ((we = (g = document.body).focus) == null || we.call(g)), p === "dismiss" && n.onDismiss((Date.now() - r) / 1e3));
597
+ }, T = (p) => {
597
598
  p.key === "Escape" && (p.stopPropagation(), E("dismiss"));
598
599
  };
599
600
  if (e.layout === "IMAGE_ONLY" && e.content.imageUrl)
600
- f.append(jt(e, () => qe(e)));
601
+ f.append(zt(e, () => qe(e)));
601
602
  else {
602
- e.content.imageUrl && f.append(Xt(e.content.imageUrl, e.content.headline));
603
+ e.content.imageUrl && f.append(jt(e.content.imageUrl, e.content.headline));
603
604
  const p = document.createElement("h2");
604
- if (p.id = `${o}-h`, p.className = "headline", p.textContent = e.content.headline, f.append(p), e.content.body) {
605
- const w = document.createElement("p");
606
- w.id = `${o}-b`, w.className = "body", w.textContent = e.content.body, f.append(w);
605
+ if (p.id = `${s}-h`, p.className = "headline", p.textContent = e.content.headline, f.append(p), e.content.body) {
606
+ const g = document.createElement("p");
607
+ g.id = `${s}-b`, g.className = "body", g.textContent = e.content.body, f.append(g);
607
608
  }
608
609
  }
609
- if (e.buttons.length > 0 && f.append(zt(e, n, E)), (e.content.showCloseButton || !e.buttons.some((p) => p.action === "DISMISS")) && f.append(Yt(t.closeLabel, () => E("dismiss"))), i) {
610
+ if (e.buttons.length > 0 && f.append(Ht(e, n, E)), (e.content.showCloseButton || !e.buttons.some((p) => p.action === "DISMISS")) && f.append(Jt(t.closeLabel, () => E("dismiss"))), i) {
610
611
  const p = document.createElement("div");
611
612
  p.className = "backdrop", e.content.showCloseButton && p.addEventListener("click", () => E("dismiss")), l.append(p);
612
613
  }
613
- l.append(f), document.body.append(s), i ? (f.focus({ preventScroll: !0 }), l.addEventListener("keydown", (p) => {
614
- p instanceof KeyboardEvent && Jt(p, l);
614
+ l.append(f), document.body.append(a), i ? (f.focus({ preventScroll: !0 }), l.addEventListener("keydown", (p) => {
615
+ p instanceof KeyboardEvent && Gt(p, l);
615
616
  })) : (f.textContent, f.setAttribute("aria-busy", "true"), requestAnimationFrame(() => {
616
617
  f.removeAttribute("aria-busy");
617
- })), document.addEventListener("keydown", k, !0), requestAnimationFrame(() => {
618
- C || !s.isConnected || document.visibilityState === "visible" && n.onImpression();
618
+ })), document.addEventListener("keydown", T, !0), requestAnimationFrame(() => {
619
+ C || !a.isConnected || document.visibilityState === "visible" && n.onImpression();
619
620
  });
620
621
  function qe(p) {
621
- const w = p.buttons[0];
622
- if (!w) {
622
+ const g = p.buttons[0];
623
+ if (!g) {
623
624
  E("dismiss");
624
625
  return;
625
626
  }
626
- n.onButton(w), E("button");
627
+ n.onButton(g), E("button");
627
628
  }
628
629
  return { close: E, root: l };
629
630
  }
630
- function Xt(e, t) {
631
+ function jt(e, t) {
631
632
  const n = document.createElement("figure");
632
633
  n.className = "figure";
633
634
  const i = document.createElement("img");
634
635
  return i.src = e, i.alt = t, i.loading = "eager", i.decoding = "async", i.referrerPolicy = "no-referrer", i.addEventListener("error", () => n.remove()), n.append(i), n;
635
636
  }
636
- function jt(e, t) {
637
+ function zt(e, t) {
637
638
  const n = document.createElement("button");
638
639
  n.type = "button", n.className = "image-only";
639
640
  const i = document.createElement("img");
640
641
  return i.src = e.content.imageUrl ?? "", i.alt = e.content.headline, i.loading = "eager", i.decoding = "async", i.referrerPolicy = "no-referrer", n.append(i), n.addEventListener("click", t), n;
641
642
  }
642
- function zt(e, t, n) {
643
+ function Ht(e, t, n) {
643
644
  const i = document.createElement("div");
644
645
  i.className = "buttons";
645
646
  for (const r of e.buttons) {
646
- const o = r.action === "URL" && r.value ? Ht(r) : qt(r);
647
- o.addEventListener("click", () => {
647
+ const s = r.action === "URL" && r.value ? qt(r) : Yt(r);
648
+ s.addEventListener("click", () => {
648
649
  r.action !== "DISMISS" && t.onButton(r), n(r.action === "DISMISS" ? "dismiss" : "button"), r.action === "DEEP_LINK" && r.value && location.assign(r.value);
649
- }), i.append(o);
650
+ }), i.append(s);
650
651
  }
651
652
  return i;
652
653
  }
653
- function Ht(e) {
654
+ function qt(e) {
654
655
  const t = document.createElement("a");
655
656
  return t.href = e.value ?? "#", t.target = "_blank", t.rel = "noopener noreferrer", t.className = `cta ${e.style.toLowerCase()}`, t.textContent = e.label, t;
656
657
  }
657
- function qt(e) {
658
+ function Yt(e) {
658
659
  const t = document.createElement("button");
659
660
  return t.type = "button", t.className = `cta ${e.style.toLowerCase()}`, t.textContent = e.label, t;
660
661
  }
661
- function Yt(e, t) {
662
+ function Jt(e, t) {
662
663
  const n = document.createElement("button");
663
664
  return n.type = "button", n.className = "close", n.setAttribute("aria-label", e), n.textContent = "×", n.addEventListener("click", t), n;
664
665
  }
665
- function Jt(e, t) {
666
+ function Gt(e, t) {
666
667
  if (e.key !== "Tab") return;
667
668
  const n = [
668
669
  ...t.querySelectorAll("button, a[href]")
669
- ].filter((s) => !s.hasAttribute("disabled"));
670
+ ].filter((a) => !a.hasAttribute("disabled"));
670
671
  if (n.length === 0) return;
671
672
  const i = n[0], r = n[n.length - 1];
672
673
  if (!i || !r) return;
673
- const o = t.activeElement;
674
- if (e.shiftKey && o === i) {
674
+ const s = t.activeElement;
675
+ if (e.shiftKey && s === i) {
675
676
  e.preventDefault(), r.focus();
676
677
  return;
677
678
  }
678
- !e.shiftKey && o === r && (e.preventDefault(), i.focus());
679
+ !e.shiftKey && s === r && (e.preventDefault(), i.focus());
679
680
  }
680
- function Gt() {
681
+ function Zt() {
681
682
  const e = document.documentElement.getAttribute("dir");
682
683
  if (e) return e;
683
684
  try {
@@ -686,25 +687,25 @@ function Gt() {
686
687
  return "ltr";
687
688
  }
688
689
  }
689
- function Zt(e) {
690
- const t = Ne.test(e.content.backgroundColor ?? "") ? e.content.backgroundColor : void 0, n = Ne.test(e.content.textColor ?? "") ? e.content.textColor : void 0;
691
- return t && !n ? { background: t, text: Qt(t) > Vt ? "#101010" : "#FFFFFF" } : { background: t, text: n };
692
- }
693
690
  function Qt(e) {
694
- const t = e.slice(1), n = t.length === 3 ? t.split("").map((s) => s + s).join("") : t.slice(0, 6), i = parseInt(n.slice(0, 2), 16) / 255, r = parseInt(n.slice(2, 4), 16) / 255, o = parseInt(n.slice(4, 6), 16) / 255;
695
- return 0.2126 * i + 0.7152 * r + 0.0722 * o;
691
+ const t = Ne.test(e.content.backgroundColor ?? "") ? e.content.backgroundColor : void 0, n = Ne.test(e.content.textColor ?? "") ? e.content.textColor : void 0;
692
+ return t && !n ? { background: t, text: en(t) > Ft ? "#101010" : "#FFFFFF" } : { background: t, text: n };
696
693
  }
697
694
  function en(e) {
695
+ const t = e.slice(1), n = t.length === 3 ? t.split("").map((a) => a + a).join("") : t.slice(0, 6), i = parseInt(n.slice(0, 2), 16) / 255, r = parseInt(n.slice(2, 4), 16) / 255, s = parseInt(n.slice(4, 6), 16) / 255;
696
+ return 0.2126 * i + 0.7152 * r + 0.0722 * s;
697
+ }
698
+ function tn(e) {
698
699
  if ("adoptedStyleSheets" in Document.prototype && typeof CSSStyleSheet == "function")
699
700
  try {
700
- xe ?? (xe = tn()), e.adoptedStyleSheets = [xe];
701
+ xe ?? (xe = nn()), e.adoptedStyleSheets = [xe];
701
702
  return;
702
703
  } catch {
703
704
  }
704
705
  const t = document.createElement("style");
705
706
  t.textContent = Ve, e.append(t);
706
707
  }
707
- function tn() {
708
+ function nn() {
708
709
  const e = new CSSStyleSheet();
709
710
  return e.replaceSync(Ve), e;
710
711
  }
@@ -814,13 +815,27 @@ const Ve = `
814
815
  @media (prefers-reduced-motion: reduce) {
815
816
  .panel { animation: none; transition: none; }
816
817
  }
817
- `, me = "REVOKED";
818
- function nn(e) {
818
+ `;
819
+ async function rn(e) {
820
+ await c(o.installReported) || (await u(o.installReported, !0), !e && await k(it, {
821
+ sdk_version: j,
822
+ platform: "web"
823
+ }));
824
+ }
825
+ async function on() {
826
+ const [e, t] = await Promise.all([
827
+ c(o.anonymousId),
828
+ c(o.installationId)
829
+ ]);
830
+ return !!e || !!t;
831
+ }
832
+ const me = "REVOKED";
833
+ function sn(e) {
819
834
  const t = e.replace(/-/g, "+").replace(/_/g, "/"), n = atob(t + "=".repeat((4 - t.length % 4) % 4)), i = new Uint8Array(n.length);
820
835
  for (let r = 0; r < n.length; r += 1) i[r] = n.charCodeAt(r);
821
836
  return i.buffer;
822
837
  }
823
- function U() {
838
+ function B() {
824
839
  return typeof navigator < "u" && "serviceWorker" in navigator && typeof PushManager < "u" && typeof Notification < "u";
825
840
  }
826
841
  function Fe(e) {
@@ -830,21 +845,21 @@ function ye(e) {
830
845
  return `/api/v1/orgs/${e}/push/subscriptions`;
831
846
  }
832
847
  const We = 1e4;
833
- let R = "none", W = null, G = null;
834
- function rn() {
835
- R = "external";
848
+ let M = "none", W = null, Z = null;
849
+ function an() {
850
+ M = "external";
836
851
  }
837
- async function on(e) {
838
- if (U()) {
839
- R = "managed";
852
+ async function cn(e) {
853
+ if (B()) {
854
+ M = "managed";
840
855
  try {
841
- W = await navigator.serviceWorker.register(e), G = null;
856
+ W = await navigator.serviceWorker.register(e), Z = null;
842
857
  } catch (t) {
843
- W = null, G = `service worker registration failed for '${e}': ${String(t)}. Check that the file is deployed and served with a JavaScript content type.`;
858
+ W = null, Z = `service worker registration failed for '${e}': ${String(t)}. Check that the file is deployed and served with a JavaScript content type.`;
844
859
  }
845
860
  }
846
861
  }
847
- function sn(e, t) {
862
+ function ln(e, t) {
848
863
  return e.active ? Promise.resolve(e) : new Promise((n, i) => {
849
864
  const r = setTimeout(() => {
850
865
  i(
@@ -852,7 +867,7 @@ function sn(e, t) {
852
867
  `service worker did not activate within ${t}ms — check the worker script for load errors in DevTools → Application → Service Workers`
853
868
  )
854
869
  );
855
- }, t), o = (l) => {
870
+ }, t), s = (l) => {
856
871
  l.addEventListener("statechange", () => {
857
872
  l.state === "activated" ? (clearTimeout(r), n(e)) : l.state === "redundant" && (clearTimeout(r), i(
858
873
  new Error(
@@ -860,13 +875,13 @@ function sn(e, t) {
860
875
  )
861
876
  ));
862
877
  });
863
- }, s = e.installing ?? e.waiting;
864
- s ? o(s) : e.addEventListener("updatefound", () => {
865
- e.installing && o(e.installing);
878
+ }, a = e.installing ?? e.waiting;
879
+ a ? s(a) : e.addEventListener("updatefound", () => {
880
+ e.installing && s(e.installing);
866
881
  });
867
882
  });
868
883
  }
869
- function an(e, t, n) {
884
+ function un(e, t, n) {
870
885
  return Promise.race([
871
886
  e,
872
887
  new Promise((i, r) => {
@@ -875,22 +890,22 @@ function an(e, t, n) {
875
890
  ]);
876
891
  }
877
892
  async function be(e = We) {
878
- if (R === "none")
893
+ if (M === "none")
879
894
  throw new Error(
880
895
  "push is not configured — pass serviceWorkerPath to init(), or serviceWorker: 'external' if your own service worker imports arsel-sw.js"
881
896
  );
882
- if (R === "external")
883
- return an(
897
+ if (M === "external")
898
+ return un(
884
899
  navigator.serviceWorker.ready,
885
900
  e,
886
901
  `no service worker became active within ${e}ms — with serviceWorker: 'external', your own worker must be registered and must importScripts arsel-sw.js`
887
902
  );
888
- if (G) throw new Error(G);
903
+ if (Z) throw new Error(Z);
889
904
  if (!W)
890
905
  throw new Error("service worker registration has not completed");
891
- return sn(W, e);
906
+ return ln(W, e);
892
907
  }
893
- async function cn(e = We) {
908
+ async function dn(e = We) {
894
909
  try {
895
910
  return await be(e), null;
896
911
  } catch (t) {
@@ -903,7 +918,7 @@ async function Xe(e, t) {
903
918
  // Non-negotiable: the Push API only accepts a userVisibleOnly subscription
904
919
  // in Chrome, and silent push is what the restriction exists to prevent.
905
920
  userVisibleOnly: !0,
906
- applicationServerKey: nn(t)
921
+ applicationServerKey: sn(t)
907
922
  });
908
923
  } catch (n) {
909
924
  return console.error(
@@ -911,12 +926,12 @@ async function Xe(e, t) {
911
926
  ), null;
912
927
  }
913
928
  }
914
- async function ln() {
929
+ async function fn() {
915
930
  const [e, t] = await Promise.all([
916
- c(a.clientKey),
917
- c(a.baseUrl)
931
+ c(o.clientKey),
932
+ c(o.baseUrl)
918
933
  ]);
919
- if (!e || !t || !U()) return !1;
934
+ if (!e || !t || !B()) return !1;
920
935
  const { body: n } = await de(
921
936
  t,
922
937
  Fe(e)
@@ -925,8 +940,8 @@ async function ln() {
925
940
  let i;
926
941
  try {
927
942
  i = await be();
928
- } catch (o) {
929
- return console.error(`[arsel] ${o instanceof Error ? o.message : o}`), !1;
943
+ } catch (s) {
944
+ return console.error(`[arsel] ${s instanceof Error ? s.message : s}`), !1;
930
945
  }
931
946
  const r = await Xe(i, n.vapidPublicKey);
932
947
  return r ? je(r, n.keyVersion) : !1;
@@ -934,21 +949,21 @@ async function ln() {
934
949
  async function je(e, t) {
935
950
  var f, A;
936
951
  const [n, i, r] = await Promise.all([
937
- c(a.clientKey),
938
- c(a.baseUrl),
952
+ c(o.clientKey),
953
+ c(o.baseUrl),
939
954
  X()
940
955
  ]);
941
956
  if (!n || !i) return !1;
942
- let o = await c(a.installationId);
943
- o || (o = crypto.randomUUID(), await d(a.installationId, o));
944
- const s = e.toJSON(), l = await j(
957
+ let s = await c(o.installationId);
958
+ s || (s = crypto.randomUUID(), await u(o.installationId, s));
959
+ const a = e.toJSON(), l = await z(
945
960
  i,
946
961
  ye(n),
947
962
  {
948
- installationId: o,
963
+ installationId: s,
949
964
  platform: "web",
950
- endpoint: s.endpoint,
951
- keys: s.keys,
965
+ endpoint: a.endpoint,
966
+ keys: a.keys,
952
967
  // The same id the events API sends — it is what binds this subscription
953
968
  // to the contact the browser's events resolve to.
954
969
  anonymousId: r,
@@ -958,30 +973,30 @@ async function je(e, t) {
958
973
  }
959
974
  );
960
975
  if (l.result !== y.success) return !1;
961
- (f = l.body) != null && f.deviceSecret && await d(a.deviceSecret, l.body.deviceSecret), await d(a.vapidKeyVersion, t), await d(a.endpoint, s.endpoint ?? null);
962
- const g = ((A = l.body) == null ? void 0 : A.status) ?? null;
963
- return await d(a.subscriptionStatus, g), g !== me;
976
+ (f = l.body) != null && f.deviceSecret && await u(o.deviceSecret, l.body.deviceSecret), await u(o.vapidKeyVersion, t), await u(o.endpoint, a.endpoint ?? null);
977
+ const w = ((A = l.body) == null ? void 0 : A.status) ?? null;
978
+ return await u(o.subscriptionStatus, w), w !== me;
964
979
  }
965
- async function un() {
980
+ async function pn() {
966
981
  const [e, t, n, i] = await Promise.all([
967
- c(a.clientKey),
968
- c(a.baseUrl),
969
- c(a.installationId),
970
- c(a.deviceSecret)
982
+ c(o.clientKey),
983
+ c(o.baseUrl),
984
+ c(o.installationId),
985
+ c(o.deviceSecret)
971
986
  ]);
972
- return !e || !t || !n || !i || (await j(
987
+ return !e || !t || !n || !i || (await z(
973
988
  t,
974
989
  `${ye(e)}/unsubscribe`,
975
990
  { installationId: n },
976
991
  { "X-Arsel-Device-Auth": i },
977
992
  !0
978
- )).result !== y.success ? !1 : (await d(a.subscriptionStatus, me), !0);
993
+ )).result !== y.success ? !1 : (await u(o.subscriptionStatus, me), !0);
979
994
  }
980
- async function dn() {
981
- if (R === "none" || !U() || Notification.permission !== "granted") return;
995
+ async function mn() {
996
+ if (M === "none" || !B() || Notification.permission !== "granted") return;
982
997
  const [e, t] = await Promise.all([
983
- c(a.clientKey),
984
- c(a.baseUrl)
998
+ c(o.clientKey),
999
+ c(o.baseUrl)
985
1000
  ]);
986
1001
  if (!e || !t) return;
987
1002
  const { body: n } = await de(
@@ -995,40 +1010,40 @@ async function dn() {
995
1010
  } catch {
996
1011
  return;
997
1012
  }
998
- const r = await i.pushManager.getSubscription(), o = await c(a.vapidKeyVersion);
999
- if (r && o === n.keyVersion) return;
1013
+ const r = await i.pushManager.getSubscription(), s = await c(o.vapidKeyVersion);
1014
+ if (r && s === n.keyVersion) return;
1000
1015
  r && await r.unsubscribe().catch(() => !1);
1001
- const s = await Xe(i, n.vapidPublicKey);
1002
- s && await je(s, n.keyVersion);
1016
+ const a = await Xe(i, n.vapidPublicKey);
1017
+ a && await je(a, n.keyVersion);
1003
1018
  }
1004
- async function fn() {
1005
- if (!U() || await c(a.subscriptionStatus) === me)
1019
+ async function yn() {
1020
+ if (!B() || await c(o.subscriptionStatus) === me)
1006
1021
  return !1;
1007
1022
  try {
1008
- const e = R === "managed" ? W : await navigator.serviceWorker.getRegistration();
1023
+ const e = M === "managed" ? W : await navigator.serviceWorker.getRegistration();
1009
1024
  return e ? await e.pushManager.getSubscription() !== null : !1;
1010
1025
  } catch {
1011
1026
  return !1;
1012
1027
  }
1013
1028
  }
1014
- function pn() {
1015
- return oe ?? (oe = mn().finally(() => {
1029
+ function bn() {
1030
+ return oe ?? (oe = hn().finally(() => {
1016
1031
  oe = null;
1017
1032
  })), oe;
1018
1033
  }
1019
1034
  let oe = null;
1020
- async function mn() {
1021
- var o;
1035
+ async function hn() {
1036
+ var s;
1022
1037
  const [e, t, n] = await Promise.all([
1023
- c(a.clientKey),
1024
- c(a.baseUrl),
1038
+ c(o.clientKey),
1039
+ c(o.baseUrl),
1025
1040
  X()
1026
1041
  ]);
1027
1042
  if (!e || !t) return !1;
1028
- if (await c(a.deviceSecret)) return !0;
1029
- let i = await c(a.installationId);
1030
- i || (i = crypto.randomUUID(), await d(a.installationId, i));
1031
- const r = await j(
1043
+ if (await c(o.deviceSecret)) return !0;
1044
+ let i = await c(o.installationId);
1045
+ i || (i = crypto.randomUUID(), await u(o.installationId, i));
1046
+ const r = await z(
1032
1047
  t,
1033
1048
  ye(e),
1034
1049
  {
@@ -1044,45 +1059,45 @@ async function mn() {
1044
1059
  );
1045
1060
  return r.code === 403 ? (console.error(
1046
1061
  "[arsel] this origin is not on the organization's allowed origins list — in-app messaging is disabled"
1047
- ), !1) : r.result !== y.success ? !1 : ((o = r.body) != null && o.deviceSecret && await d(a.deviceSecret, r.body.deviceSecret), !0);
1062
+ ), !1) : r.result !== y.success ? !1 : ((s = r.body) != null && s.deviceSecret && await u(o.deviceSecret, r.body.deviceSecret), !0);
1048
1063
  }
1049
- const yn = 30 * 6e4;
1064
+ const wn = 30 * 6e4;
1050
1065
  async function ze(e = Date.now()) {
1051
- const t = await c(a.sessionStartedAt) ?? 0, n = await c(a.backgroundedAt) ?? 0;
1066
+ const t = await c(o.sessionStartedAt) ?? 0, n = await c(o.backgroundedAt) ?? 0;
1052
1067
  if (t !== 0) {
1053
- if (n === 0 || e - n < yn) return;
1054
- await M(
1068
+ if (n === 0 || e - n < wn) return;
1069
+ await k(
1055
1070
  tt,
1056
1071
  { duration_seconds: Math.round((n - t) / 1e3) },
1057
1072
  n
1058
1073
  );
1059
1074
  }
1060
- await d(a.sessionStartedAt, e), await d(a.backgroundedAt, 0), await M(et, {}, e);
1075
+ await u(o.sessionStartedAt, e), await u(o.backgroundedAt, 0), await k(et, {}, e);
1061
1076
  }
1062
1077
  async function ke(e = Date.now()) {
1063
- (await c(a.sessionStartedAt) ?? 0) !== 0 && await d(a.backgroundedAt, e);
1078
+ (await c(o.sessionStartedAt) ?? 0) !== 0 && await u(o.backgroundedAt, e);
1064
1079
  }
1065
- function bn(e) {
1080
+ function gn(e) {
1066
1081
  typeof document > "u" || (document.addEventListener("visibilitychange", () => {
1067
1082
  document.visibilityState === "visible" ? ze().then(() => e == null ? void 0 : e()) : ke();
1068
1083
  }), window.addEventListener("pagehide", () => void ke()));
1069
1084
  }
1070
- let b = null, ce = !1, D = null;
1085
+ let b = null, ce = !1, R = null;
1071
1086
  function I(e) {
1072
1087
  ce && console.info(`[arsel] ${e}`);
1073
1088
  }
1074
- const hn = /^\+[1-9]\d{6,14}$/, gn = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, Pe = 100;
1075
- let Z = [], Te = !1;
1076
- function wn() {
1089
+ const vn = /^\+[1-9]\d{6,14}$/, Sn = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, Pe = 100;
1090
+ let Q = [], Te = !1;
1091
+ function An() {
1077
1092
  typeof navigator < "u" && navigator.serviceWorker && navigator.serviceWorker.addEventListener("message", (e) => {
1078
1093
  const t = e.data;
1079
- (t == null ? void 0 : t.type) === "arsel_iam_sync" && Et();
1094
+ (t == null ? void 0 : t.type) === "arsel_iam_sync" && It();
1080
1095
  }), typeof window < "u" && (window.addEventListener("online", () => {
1081
1096
  V().catch(() => {
1082
- }), q().catch(() => {
1097
+ }), Y().catch(() => {
1083
1098
  });
1084
1099
  }), window.addEventListener("pagehide", () => {
1085
- ae(), q().catch(() => {
1100
+ ae(), Y().catch(() => {
1086
1101
  });
1087
1102
  })), typeof document < "u" && document.addEventListener("visibilitychange", () => {
1088
1103
  if (document.visibilityState === "visible") {
@@ -1091,14 +1106,14 @@ function wn() {
1091
1106
  });
1092
1107
  return;
1093
1108
  }
1094
- ae(), q().catch(() => {
1109
+ ae(), Y().catch(() => {
1095
1110
  });
1096
1111
  });
1097
1112
  }
1098
- function B() {
1099
- return D === null;
1113
+ function U() {
1114
+ return R === null;
1100
1115
  }
1101
- function vn(e) {
1116
+ function En(e) {
1102
1117
  var n, i;
1103
1118
  if (!((n = e.clientKey) != null && n.trim()))
1104
1119
  return "clientKey is required (the org's publishable pub_… key)";
@@ -1116,28 +1131,30 @@ function vn(e) {
1116
1131
  }
1117
1132
  return null;
1118
1133
  }
1119
- function Sn(e) {
1134
+ function In(e) {
1120
1135
  return b || (b = (async () => {
1121
- if (ce = e.debug ?? !1, D = vn(e), D) {
1122
- console.error(`[arsel] not started — ${D}`);
1136
+ if (ce = e.debug ?? !1, R = En(e), R) {
1137
+ console.error(`[arsel] not started — ${R}`);
1123
1138
  return;
1124
1139
  }
1125
1140
  const t = e.baseUrl.replace(/\/+$/, "");
1126
1141
  await Promise.all([
1127
- d(a.clientKey, e.clientKey),
1128
- d(a.baseUrl, t)
1129
- ]), await X();
1130
- const n = Z;
1131
- Z = [];
1132
- for (const s of n)
1133
- await M(s.name, s.properties, s.timestampMs);
1134
- e.serviceWorker === "external" ? rn() : e.serviceWorkerPath && await on(e.serviceWorkerPath);
1135
- const i = Dn(e.inApp);
1136
- bn(i ? Ie : void 0), wn();
1137
- const r = typeof document < "u" ? document : void 0, o = (r == null ? void 0 : r.visibilityState) === "visible" && r.prerendering !== !0;
1138
- o && await ze(), i && (wt(On(i)), await pn() && (await gt(ce), o && Ie())), V().catch(() => {
1139
- }), dn().catch(() => {
1140
- }), I(`initialized (sdk ${Q})`);
1142
+ u(o.clientKey, e.clientKey),
1143
+ u(o.baseUrl, t)
1144
+ ]);
1145
+ const n = await on();
1146
+ await X(), await rn(n);
1147
+ const i = Q;
1148
+ Q = [];
1149
+ for (const l of i)
1150
+ await k(l.name, l.properties, l.timestampMs);
1151
+ e.serviceWorker === "external" ? an() : e.serviceWorkerPath && await cn(e.serviceWorkerPath);
1152
+ const r = Mn(e.inApp);
1153
+ gn(r ? Ie : void 0), An();
1154
+ const s = typeof document < "u" ? document : void 0, a = (s == null ? void 0 : s.visibilityState) === "visible" && s.prerendering !== !0;
1155
+ a && await ze(), r && (vt(Bn(r)), await bn() && (await gt(ce), a && Ie())), V().catch(() => {
1156
+ }), mn().catch(() => {
1157
+ }), I(`initialized (sdk ${j})`);
1141
1158
  })(), b);
1142
1159
  }
1143
1160
  async function He(e, t = {}) {
@@ -1146,157 +1163,157 @@ async function He(e, t = {}) {
1146
1163
  I("track() called with a blank event name — ignoring");
1147
1164
  return;
1148
1165
  }
1149
- if (n.startsWith(O)) {
1150
- I(`'${O}' is reserved for the SDK — ignoring '${n}'`);
1166
+ if (n.startsWith(x)) {
1167
+ I(`'${x}' is reserved for the SDK — ignoring '${n}'`);
1151
1168
  return;
1152
1169
  }
1153
1170
  if (!b) {
1154
- if (Z.length >= Pe) {
1171
+ if (Q.length >= Pe) {
1155
1172
  Te || (Te = !0, console.warn(
1156
1173
  `[arsel] more than ${Pe} events tracked before init() — dropping the rest. Call init() earlier.`
1157
1174
  ));
1158
1175
  return;
1159
1176
  }
1160
- Z.push({ name: n, properties: t, timestampMs: Date.now() });
1177
+ Q.push({ name: n, properties: t, timestampMs: Date.now() });
1161
1178
  return;
1162
1179
  }
1163
- await b, B() && (await M(n, t), pe("CUSTOM_EVENT", n, t));
1180
+ await b, U() && (await k(n, t), pe("CUSTOM_EVENT", n, t));
1164
1181
  }
1165
- async function An(e, t = {}) {
1182
+ async function _n(e, t = {}) {
1166
1183
  const n = e == null ? void 0 : e.trim();
1167
1184
  if (!n) {
1168
1185
  I("screen() called with a blank name — ignoring");
1169
1186
  return;
1170
1187
  }
1171
- await b, await M(it, { ...t, screen_name: n }), pe("SCREEN_VIEW", n, t);
1188
+ await b, await k(rt, { ...t, screen_name: n }), pe("SCREEN_VIEW", n, t);
1172
1189
  }
1173
- function En(e) {
1174
- vt(e);
1190
+ function Nn(e) {
1191
+ St(e);
1175
1192
  }
1176
- async function In(e) {
1177
- if (await b, !B()) return;
1193
+ async function xn(e) {
1194
+ if (await b, !U()) return;
1178
1195
  let { email: t, phoneNumber: n } = e ?? {};
1179
1196
  const i = e == null ? void 0 : e.externalId;
1180
- if (t && !gn.test(t) && (console.error(`[arsel] identify(): '${t}' is not a valid email address — ignored`), t = void 0), n && !hn.test(n) && (console.error(
1197
+ if (t && !Sn.test(t) && (console.error(`[arsel] identify(): '${t}' is not a valid email address — ignored`), t = void 0), n && !vn.test(n) && (console.error(
1181
1198
  `[arsel] identify(): '${n}' is not E.164 (e.g. +966501234567) — ignored`
1182
1199
  ), n = void 0), !i && !t && !n) {
1183
1200
  I("identify() needs at least one of externalId, email or phoneNumber");
1184
1201
  return;
1185
1202
  }
1186
- i && await d(a.externalId, i), t && await d(a.email, t), n && await d(a.phoneNumber, n), await M(nt, {}), await Ce();
1187
- }
1188
- async function _n() {
1189
- await b, B() && (await Promise.all([
1190
- K(a.externalId),
1191
- K(a.email),
1192
- K(a.phoneNumber),
1193
- K(a.sessionStartedAt)
1203
+ i && await u(o.externalId, i), t && await u(o.email, t), n && await u(o.phoneNumber, n), await k(nt, {}), await Ce();
1204
+ }
1205
+ async function kn() {
1206
+ await b, U() && (await Promise.all([
1207
+ L(o.externalId),
1208
+ L(o.email),
1209
+ L(o.phoneNumber),
1210
+ L(o.sessionStartedAt)
1194
1211
  ]), await Ze(), await Ce(), I("identity reset"));
1195
1212
  }
1196
- async function Nn() {
1197
- if (await b, !B()) return !1;
1198
- const e = await un();
1213
+ async function Pn() {
1214
+ if (await b, !U()) return !1;
1215
+ const e = await pn();
1199
1216
  return I(e ? "push opt-out recorded" : "push opt-out not sent — no registration to revoke"), e;
1200
1217
  }
1201
- async function xn() {
1202
- if (await b, !B() || !U()) return !1;
1203
- const e = await cn();
1218
+ async function Tn() {
1219
+ if (await b, !U() || !B()) return !1;
1220
+ const e = await dn();
1204
1221
  if (e)
1205
1222
  return console.error(`[arsel] promptForPush(): ${e}`), !1;
1206
1223
  const t = await Notification.requestPermission();
1207
- return t !== "granted" ? (I(`notification permission: ${t}`), !1) : ln();
1224
+ return t !== "granted" ? (I(`notification permission: ${t}`), !1) : fn();
1208
1225
  }
1209
- async function kn() {
1226
+ async function Dn() {
1210
1227
  return await b, X();
1211
1228
  }
1212
- async function Pn() {
1229
+ async function On() {
1213
1230
  const [
1214
1231
  e,
1215
1232
  t,
1216
1233
  n,
1217
1234
  i,
1218
1235
  r,
1219
- o,
1220
1236
  s,
1237
+ a,
1221
1238
  l,
1222
- g,
1239
+ w,
1223
1240
  f,
1224
1241
  A,
1225
1242
  C,
1226
1243
  E
1227
1244
  ] = await Promise.all([
1228
- c(a.anonymousId),
1229
- c(a.externalId),
1230
- c(a.email),
1231
- c(a.phoneNumber),
1232
- c(a.installationId),
1233
- c(a.deviceSecret),
1234
- c(a.vapidKeyVersion),
1245
+ c(o.anonymousId),
1246
+ c(o.externalId),
1247
+ c(o.email),
1248
+ c(o.phoneNumber),
1249
+ c(o.installationId),
1250
+ c(o.deviceSecret),
1251
+ c(o.vapidKeyVersion),
1235
1252
  Oe(S.events),
1236
- fn(),
1237
- c(a.subscriptionStatus),
1238
- c(a.lastResponseCode),
1239
- c(a.lastResponsePath),
1240
- c(a.lastResponseAtMs)
1241
- ]), k = St(), he = await At().catch(() => 0);
1253
+ yn(),
1254
+ c(o.subscriptionStatus),
1255
+ c(o.lastResponseCode),
1256
+ c(o.lastResponsePath),
1257
+ c(o.lastResponseAtMs)
1258
+ ]), T = At(), he = await Et().catch(() => 0);
1242
1259
  return {
1243
- sdkVersion: Q,
1244
- initialized: b !== null && D === null,
1245
- configError: D,
1246
- inAppMessages: k.messages,
1247
- inAppBundleVersion: k.bundleVersion,
1248
- inAppFetchedAtMs: k.fetchedAtMs,
1260
+ sdkVersion: j,
1261
+ initialized: b !== null && R === null,
1262
+ configError: R,
1263
+ inAppMessages: T.messages,
1264
+ inAppBundleVersion: T.bundleVersion,
1265
+ inAppFetchedAtMs: T.fetchedAtMs,
1249
1266
  pendingInAppBeacons: he,
1250
1267
  anonymousId: e,
1251
1268
  hasAssertedIdentity: !!(t || n || i),
1252
1269
  installationId: r,
1253
- hasDeviceSecret: !!o,
1270
+ hasDeviceSecret: !!s,
1254
1271
  pendingEvents: l,
1255
- permission: U() ? Notification.permission : "unsupported",
1256
- isSubscribed: g,
1272
+ permission: B() ? Notification.permission : "unsupported",
1273
+ isSubscribed: w,
1257
1274
  subscriptionStatus: f,
1258
- vapidKeyVersion: s,
1275
+ vapidKeyVersion: a,
1259
1276
  lastResponseCode: A,
1260
1277
  lastResponsePath: C,
1261
1278
  lastResponseAtMs: E
1262
1279
  };
1263
1280
  }
1264
- async function Tn() {
1265
- await b, B() && await V();
1281
+ async function Rn() {
1282
+ await b, U() && await V();
1266
1283
  }
1267
- const Rn = {
1268
- init: Sn,
1284
+ const Cn = {
1285
+ init: In,
1269
1286
  track: He,
1270
- screen: An,
1271
- suppressInAppMessages: En,
1272
- identify: In,
1273
- reset: _n,
1274
- optOut: Nn,
1275
- promptForPush: xn,
1276
- getAnonymousId: kn,
1277
- diagnostics: Pn,
1278
- flushNow: Tn,
1279
- SDK_VERSION: Q
1287
+ screen: _n,
1288
+ suppressInAppMessages: Nn,
1289
+ identify: xn,
1290
+ reset: kn,
1291
+ optOut: Pn,
1292
+ promptForPush: Tn,
1293
+ getAnonymousId: Dn,
1294
+ diagnostics: On,
1295
+ flushNow: Rn,
1296
+ SDK_VERSION: j
1280
1297
  };
1281
- function Dn(e) {
1298
+ function Mn(e) {
1282
1299
  if (e === !1) return;
1283
1300
  const t = typeof e == "object" && e !== null ? e : {};
1284
1301
  return {
1285
- zIndex: t.zIndex ?? Mn,
1302
+ zIndex: t.zIndex ?? Un,
1286
1303
  closeLabel: t.closeLabel ?? "Close"
1287
1304
  };
1288
1305
  }
1289
- function On(e) {
1306
+ function Bn(e) {
1290
1307
  return (t) => {
1291
- const n = Dt();
1308
+ const n = Ot();
1292
1309
  try {
1293
- Wt(t, e, {
1294
- onImpression: () => void Ot(t, n),
1310
+ Xt(t, e, {
1311
+ onImpression: () => void Rt(t, n),
1295
1312
  onButton: (i) => {
1296
1313
  Mt(t, i.buttonId), i.action === "CUSTOM_EVENT" && i.value && He(i.value);
1297
1314
  },
1298
1315
  onDismiss: (i) => {
1299
- Rt(t, i), _e();
1316
+ Bt(t, i), _e();
1300
1317
  }
1301
1318
  });
1302
1319
  } catch (i) {
@@ -1304,21 +1321,21 @@ function On(e) {
1304
1321
  }
1305
1322
  };
1306
1323
  }
1307
- const Mn = 2147483e3;
1324
+ const Un = 2147483e3;
1308
1325
  export {
1309
- Rn as Arsel,
1310
- Q as SDK_VERSION,
1311
- Rn as default,
1312
- Pn as diagnostics,
1313
- Tn as flushNow,
1314
- kn as getAnonymousId,
1315
- In as identify,
1316
- Sn as init,
1317
- Nn as optOut,
1318
- xn as promptForPush,
1319
- _n as reset,
1320
- An as screen,
1321
- En as suppressInAppMessages,
1326
+ Cn as Arsel,
1327
+ j as SDK_VERSION,
1328
+ Cn as default,
1329
+ On as diagnostics,
1330
+ Rn as flushNow,
1331
+ Dn as getAnonymousId,
1332
+ xn as identify,
1333
+ In as init,
1334
+ Pn as optOut,
1335
+ Tn as promptForPush,
1336
+ kn as reset,
1337
+ _n as screen,
1338
+ Nn as suppressInAppMessages,
1322
1339
  He as track
1323
1340
  };
1324
1341
  //# sourceMappingURL=arsel.js.map