@sesamy/sesamy-js 1.3.1 → 1.3.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.
Files changed (56) hide show
  1. package/build/dist/index.d.ts +108 -0
  2. package/build/dist/sesamy-js.cjs +6 -0
  3. package/build/dist/sesamy-js.iife.js +6 -0
  4. package/build/dist/sesamy-js.mjs +3082 -0
  5. package/build/package.json +89 -0
  6. package/package.json +4 -1
  7. package/.env +0 -2
  8. package/.env.production +0 -2
  9. package/.eslintignore +0 -4
  10. package/.eslintrc +0 -18
  11. package/.github/workflows/release.yml +0 -23
  12. package/.nvmrc +0 -1
  13. package/.prettierignore +0 -4
  14. package/.prettierrc +0 -5
  15. package/CHANGELOG.md +0 -132
  16. package/article.html +0 -65
  17. package/contracts.html +0 -23
  18. package/dts-bundle-generator.config.ts +0 -11
  19. package/entitlements.html +0 -23
  20. package/index.html +0 -24
  21. package/renovate.json +0 -4
  22. package/src/SesamyContracts.ts +0 -86
  23. package/src/SesamyEntitlements.ts +0 -85
  24. package/src/app.ts +0 -101
  25. package/src/constants.ts +0 -2
  26. package/src/controllers/index.ts +0 -1
  27. package/src/controllers/paywall.ts +0 -14
  28. package/src/entitlementsStyle.css +0 -147
  29. package/src/events/ready.ts +0 -12
  30. package/src/index.ts +0 -36
  31. package/src/javascript-api.ts +0 -84
  32. package/src/services/analytics/element-tracker.ts +0 -117
  33. package/src/services/analytics/index.ts +0 -234
  34. package/src/services/analytics/listeners/index.ts +0 -2
  35. package/src/services/analytics/listeners/route.ts +0 -9
  36. package/src/services/analytics/listeners/scroll.ts +0 -62
  37. package/src/services/analytics/session-id.ts +0 -11
  38. package/src/services/analytics/types/analytics-activity-utils.d.ts +0 -54
  39. package/src/services/analytics/types/analytics-router-utils.d.ts +0 -7
  40. package/src/services/analytics/types/analytics-scroll-utils.d.ts +0 -4
  41. package/src/services/analytics/types/track-event.ts +0 -70
  42. package/src/services/auth/index.ts +0 -74
  43. package/src/services/sesamy/index.ts +0 -160
  44. package/src/state.ts +0 -3
  45. package/src/style.css +0 -99
  46. package/src/types/Bills.ts +0 -12
  47. package/src/types/Config.ts +0 -11
  48. package/src/types/Contracts.ts +0 -12
  49. package/src/types/Entitlement.ts +0 -9
  50. package/src/types/Events.ts +0 -6
  51. package/src/types/Tag.ts +0 -16
  52. package/src/vite-env.d.ts +0 -1
  53. package/tsconfig.json +0 -23
  54. package/vite.config.ts +0 -43
  55. package/vite.dev.config.ts +0 -14
  56. /package/{public → build/dist}/sesamy.png +0 -0
@@ -0,0 +1,3082 @@
1
+ var gr = Object.defineProperty;
2
+ var yr = (t, e, n) => e in t ? gr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var B = (t, e, n) => (yr(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ function rt(t, e) {
5
+ const n = new CustomEvent(t, {
6
+ detail: e,
7
+ bubbles: !0,
8
+ composed: !0
9
+ });
10
+ dispatchEvent(n);
11
+ }
12
+ function Q(t, e) {
13
+ var n = {};
14
+ for (var r in t)
15
+ Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
16
+ if (t != null && typeof Object.getOwnPropertySymbols == "function") {
17
+ var i = 0;
18
+ for (r = Object.getOwnPropertySymbols(t); i < r.length; i++)
19
+ e.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[i]) && (n[r[i]] = t[r[i]]);
20
+ }
21
+ return n;
22
+ }
23
+ var ce = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
24
+ function Tt(t) {
25
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
26
+ }
27
+ function jt(t, e) {
28
+ return t(e = { exports: {} }, e.exports), e.exports;
29
+ }
30
+ var ae = jt(function(t, e) {
31
+ Object.defineProperty(e, "__esModule", { value: !0 });
32
+ var n = function() {
33
+ function r() {
34
+ var i = this;
35
+ this.locked = /* @__PURE__ */ new Map(), this.addToLocked = function(o, a) {
36
+ var s = i.locked.get(o);
37
+ s === void 0 ? a === void 0 ? i.locked.set(o, []) : i.locked.set(o, [a]) : a !== void 0 && (s.unshift(a), i.locked.set(o, s));
38
+ }, this.isLocked = function(o) {
39
+ return i.locked.has(o);
40
+ }, this.lock = function(o) {
41
+ return new Promise(function(a, s) {
42
+ i.isLocked(o) ? i.addToLocked(o, a) : (i.addToLocked(o), a());
43
+ });
44
+ }, this.unlock = function(o) {
45
+ var a = i.locked.get(o);
46
+ if (a !== void 0 && a.length !== 0) {
47
+ var s = a.pop();
48
+ i.locked.set(o, a), s !== void 0 && setTimeout(s, 0);
49
+ } else
50
+ i.locked.delete(o);
51
+ };
52
+ }
53
+ return r.getInstance = function() {
54
+ return r.instance === void 0 && (r.instance = new r()), r.instance;
55
+ }, r;
56
+ }();
57
+ e.default = function() {
58
+ return n.getInstance();
59
+ };
60
+ });
61
+ Tt(ae);
62
+ var vr = Tt(jt(function(t, e) {
63
+ var n = ce && ce.__awaiter || function(u, c, h, d) {
64
+ return new (h || (h = Promise))(function(w, k) {
65
+ function v(y) {
66
+ try {
67
+ _(d.next(y));
68
+ } catch (l) {
69
+ k(l);
70
+ }
71
+ }
72
+ function I(y) {
73
+ try {
74
+ _(d.throw(y));
75
+ } catch (l) {
76
+ k(l);
77
+ }
78
+ }
79
+ function _(y) {
80
+ y.done ? w(y.value) : new h(function(l) {
81
+ l(y.value);
82
+ }).then(v, I);
83
+ }
84
+ _((d = d.apply(u, c || [])).next());
85
+ });
86
+ }, r = ce && ce.__generator || function(u, c) {
87
+ var h, d, w, k, v = { label: 0, sent: function() {
88
+ if (1 & w[0])
89
+ throw w[1];
90
+ return w[1];
91
+ }, trys: [], ops: [] };
92
+ return k = { next: I(0), throw: I(1), return: I(2) }, typeof Symbol == "function" && (k[Symbol.iterator] = function() {
93
+ return this;
94
+ }), k;
95
+ function I(_) {
96
+ return function(y) {
97
+ return function(l) {
98
+ if (h)
99
+ throw new TypeError("Generator is already executing.");
100
+ for (; v; )
101
+ try {
102
+ if (h = 1, d && (w = 2 & l[0] ? d.return : l[0] ? d.throw || ((w = d.return) && w.call(d), 0) : d.next) && !(w = w.call(d, l[1])).done)
103
+ return w;
104
+ switch (d = 0, w && (l = [2 & l[0], w.value]), l[0]) {
105
+ case 0:
106
+ case 1:
107
+ w = l;
108
+ break;
109
+ case 4:
110
+ return v.label++, { value: l[1], done: !1 };
111
+ case 5:
112
+ v.label++, d = l[1], l = [0];
113
+ continue;
114
+ case 7:
115
+ l = v.ops.pop(), v.trys.pop();
116
+ continue;
117
+ default:
118
+ if (w = v.trys, !((w = w.length > 0 && w[w.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
119
+ v = 0;
120
+ continue;
121
+ }
122
+ if (l[0] === 3 && (!w || l[1] > w[0] && l[1] < w[3])) {
123
+ v.label = l[1];
124
+ break;
125
+ }
126
+ if (l[0] === 6 && v.label < w[1]) {
127
+ v.label = w[1], w = l;
128
+ break;
129
+ }
130
+ if (w && v.label < w[2]) {
131
+ v.label = w[2], v.ops.push(l);
132
+ break;
133
+ }
134
+ w[2] && v.ops.pop(), v.trys.pop();
135
+ continue;
136
+ }
137
+ l = c.call(u, v);
138
+ } catch (b) {
139
+ l = [6, b], d = 0;
140
+ } finally {
141
+ h = w = 0;
142
+ }
143
+ if (5 & l[0])
144
+ throw l[1];
145
+ return { value: l[0] ? l[1] : void 0, done: !0 };
146
+ }([_, y]);
147
+ };
148
+ }
149
+ }, i = ce;
150
+ Object.defineProperty(e, "__esModule", { value: !0 });
151
+ var o = "browser-tabs-lock-key", a = { key: function(u) {
152
+ return n(i, void 0, void 0, function() {
153
+ return r(this, function(c) {
154
+ throw new Error("Unsupported");
155
+ });
156
+ });
157
+ }, getItem: function(u) {
158
+ return n(i, void 0, void 0, function() {
159
+ return r(this, function(c) {
160
+ throw new Error("Unsupported");
161
+ });
162
+ });
163
+ }, clear: function() {
164
+ return n(i, void 0, void 0, function() {
165
+ return r(this, function(u) {
166
+ return [2, window.localStorage.clear()];
167
+ });
168
+ });
169
+ }, removeItem: function(u) {
170
+ return n(i, void 0, void 0, function() {
171
+ return r(this, function(c) {
172
+ throw new Error("Unsupported");
173
+ });
174
+ });
175
+ }, setItem: function(u, c) {
176
+ return n(i, void 0, void 0, function() {
177
+ return r(this, function(h) {
178
+ throw new Error("Unsupported");
179
+ });
180
+ });
181
+ }, keySync: function(u) {
182
+ return window.localStorage.key(u);
183
+ }, getItemSync: function(u) {
184
+ return window.localStorage.getItem(u);
185
+ }, clearSync: function() {
186
+ return window.localStorage.clear();
187
+ }, removeItemSync: function(u) {
188
+ return window.localStorage.removeItem(u);
189
+ }, setItemSync: function(u, c) {
190
+ return window.localStorage.setItem(u, c);
191
+ } };
192
+ function s(u) {
193
+ return new Promise(function(c) {
194
+ return setTimeout(c, u);
195
+ });
196
+ }
197
+ function m(u) {
198
+ for (var c = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", h = "", d = 0; d < u; d++)
199
+ h += c[Math.floor(Math.random() * c.length)];
200
+ return h;
201
+ }
202
+ var p = function() {
203
+ function u(c) {
204
+ this.acquiredIatSet = /* @__PURE__ */ new Set(), this.storageHandler = void 0, this.id = Date.now().toString() + m(15), this.acquireLock = this.acquireLock.bind(this), this.releaseLock = this.releaseLock.bind(this), this.releaseLock__private__ = this.releaseLock__private__.bind(this), this.waitForSomethingToChange = this.waitForSomethingToChange.bind(this), this.refreshLockWhileAcquired = this.refreshLockWhileAcquired.bind(this), this.storageHandler = c, u.waiters === void 0 && (u.waiters = []);
205
+ }
206
+ return u.prototype.acquireLock = function(c, h) {
207
+ return h === void 0 && (h = 5e3), n(this, void 0, void 0, function() {
208
+ var d, w, k, v, I, _, y;
209
+ return r(this, function(l) {
210
+ switch (l.label) {
211
+ case 0:
212
+ d = Date.now() + m(4), w = Date.now() + h, k = o + "-" + c, v = this.storageHandler === void 0 ? a : this.storageHandler, l.label = 1;
213
+ case 1:
214
+ return Date.now() < w ? [4, s(30)] : [3, 8];
215
+ case 2:
216
+ return l.sent(), v.getItemSync(k) !== null ? [3, 5] : (I = this.id + "-" + c + "-" + d, [4, s(Math.floor(25 * Math.random()))]);
217
+ case 3:
218
+ return l.sent(), v.setItemSync(k, JSON.stringify({ id: this.id, iat: d, timeoutKey: I, timeAcquired: Date.now(), timeRefreshed: Date.now() })), [4, s(30)];
219
+ case 4:
220
+ return l.sent(), (_ = v.getItemSync(k)) !== null && (y = JSON.parse(_)).id === this.id && y.iat === d ? (this.acquiredIatSet.add(d), this.refreshLockWhileAcquired(k, d), [2, !0]) : [3, 7];
221
+ case 5:
222
+ return u.lockCorrector(this.storageHandler === void 0 ? a : this.storageHandler), [4, this.waitForSomethingToChange(w)];
223
+ case 6:
224
+ l.sent(), l.label = 7;
225
+ case 7:
226
+ return d = Date.now() + m(4), [3, 1];
227
+ case 8:
228
+ return [2, !1];
229
+ }
230
+ });
231
+ });
232
+ }, u.prototype.refreshLockWhileAcquired = function(c, h) {
233
+ return n(this, void 0, void 0, function() {
234
+ var d = this;
235
+ return r(this, function(w) {
236
+ return setTimeout(function() {
237
+ return n(d, void 0, void 0, function() {
238
+ var k, v, I;
239
+ return r(this, function(_) {
240
+ switch (_.label) {
241
+ case 0:
242
+ return [4, ae.default().lock(h)];
243
+ case 1:
244
+ return _.sent(), this.acquiredIatSet.has(h) ? (k = this.storageHandler === void 0 ? a : this.storageHandler, (v = k.getItemSync(c)) === null ? (ae.default().unlock(h), [2]) : ((I = JSON.parse(v)).timeRefreshed = Date.now(), k.setItemSync(c, JSON.stringify(I)), ae.default().unlock(h), this.refreshLockWhileAcquired(c, h), [2])) : (ae.default().unlock(h), [2]);
245
+ }
246
+ });
247
+ });
248
+ }, 1e3), [2];
249
+ });
250
+ });
251
+ }, u.prototype.waitForSomethingToChange = function(c) {
252
+ return n(this, void 0, void 0, function() {
253
+ return r(this, function(h) {
254
+ switch (h.label) {
255
+ case 0:
256
+ return [4, new Promise(function(d) {
257
+ var w = !1, k = Date.now(), v = !1;
258
+ function I() {
259
+ if (v || (window.removeEventListener("storage", I), u.removeFromWaiting(I), clearTimeout(_), v = !0), !w) {
260
+ w = !0;
261
+ var y = 50 - (Date.now() - k);
262
+ y > 0 ? setTimeout(d, y) : d(null);
263
+ }
264
+ }
265
+ window.addEventListener("storage", I), u.addToWaiting(I);
266
+ var _ = setTimeout(I, Math.max(0, c - Date.now()));
267
+ })];
268
+ case 1:
269
+ return h.sent(), [2];
270
+ }
271
+ });
272
+ });
273
+ }, u.addToWaiting = function(c) {
274
+ this.removeFromWaiting(c), u.waiters !== void 0 && u.waiters.push(c);
275
+ }, u.removeFromWaiting = function(c) {
276
+ u.waiters !== void 0 && (u.waiters = u.waiters.filter(function(h) {
277
+ return h !== c;
278
+ }));
279
+ }, u.notifyWaiters = function() {
280
+ u.waiters !== void 0 && u.waiters.slice().forEach(function(c) {
281
+ return c();
282
+ });
283
+ }, u.prototype.releaseLock = function(c) {
284
+ return n(this, void 0, void 0, function() {
285
+ return r(this, function(h) {
286
+ switch (h.label) {
287
+ case 0:
288
+ return [4, this.releaseLock__private__(c)];
289
+ case 1:
290
+ return [2, h.sent()];
291
+ }
292
+ });
293
+ });
294
+ }, u.prototype.releaseLock__private__ = function(c) {
295
+ return n(this, void 0, void 0, function() {
296
+ var h, d, w, k;
297
+ return r(this, function(v) {
298
+ switch (v.label) {
299
+ case 0:
300
+ return h = this.storageHandler === void 0 ? a : this.storageHandler, d = o + "-" + c, (w = h.getItemSync(d)) === null ? [2] : (k = JSON.parse(w)).id !== this.id ? [3, 2] : [4, ae.default().lock(k.iat)];
301
+ case 1:
302
+ v.sent(), this.acquiredIatSet.delete(k.iat), h.removeItemSync(d), ae.default().unlock(k.iat), u.notifyWaiters(), v.label = 2;
303
+ case 2:
304
+ return [2];
305
+ }
306
+ });
307
+ });
308
+ }, u.lockCorrector = function(c) {
309
+ for (var h = Date.now() - 5e3, d = c, w = [], k = 0; ; ) {
310
+ var v = d.keySync(k);
311
+ if (v === null)
312
+ break;
313
+ w.push(v), k++;
314
+ }
315
+ for (var I = !1, _ = 0; _ < w.length; _++) {
316
+ var y = w[_];
317
+ if (y.includes(o)) {
318
+ var l = d.getItemSync(y);
319
+ if (l !== null) {
320
+ var b = JSON.parse(l);
321
+ (b.timeRefreshed === void 0 && b.timeAcquired < h || b.timeRefreshed !== void 0 && b.timeRefreshed < h) && (d.removeItemSync(y), I = !0);
322
+ }
323
+ }
324
+ }
325
+ I && u.notifyWaiters();
326
+ }, u.waiters = void 0, u;
327
+ }();
328
+ e.default = p;
329
+ }));
330
+ const wr = { timeoutInSeconds: 60 }, En = { name: "auth0-spa-js", version: "2.1.3" }, On = () => Date.now();
331
+ let V = class kt extends Error {
332
+ constructor(e, n) {
333
+ super(n), this.error = e, this.error_description = n, Object.setPrototypeOf(this, kt.prototype);
334
+ }
335
+ static fromPayload({ error: e, error_description: n }) {
336
+ return new kt(e, n);
337
+ }
338
+ }, br = class Pn extends V {
339
+ constructor(e, n, r, i = null) {
340
+ super(e, n), this.state = r, this.appState = i, Object.setPrototypeOf(this, Pn.prototype);
341
+ }
342
+ }, It = class Tn extends V {
343
+ constructor() {
344
+ super("timeout", "Timeout"), Object.setPrototypeOf(this, Tn.prototype);
345
+ }
346
+ }, kr = class jn extends It {
347
+ constructor(e) {
348
+ super(), this.popup = e, Object.setPrototypeOf(this, jn.prototype);
349
+ }
350
+ }, Ir = class xn extends V {
351
+ constructor(e) {
352
+ super("cancelled", "Popup closed"), this.popup = e, Object.setPrototypeOf(this, xn.prototype);
353
+ }
354
+ }, _r = class Cn extends V {
355
+ constructor(e, n, r) {
356
+ super(e, n), this.mfa_token = r, Object.setPrototypeOf(this, Cn.prototype);
357
+ }
358
+ }, $n = class An extends V {
359
+ constructor(e, n) {
360
+ super("missing_refresh_token", `Missing Refresh Token (audience: '${Zt(e, ["default"])}', scope: '${Zt(n)}')`), this.audience = e, this.scope = n, Object.setPrototypeOf(this, An.prototype);
361
+ }
362
+ };
363
+ function Zt(t, e = []) {
364
+ return t && !e.includes(t) ? t : "";
365
+ }
366
+ const Be = () => window.crypto, dt = () => {
367
+ const t = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
368
+ let e = "";
369
+ return Array.from(Be().getRandomValues(new Uint8Array(43))).forEach((n) => e += t[n % t.length]), e;
370
+ }, Wt = (t) => btoa(t), _t = (t) => {
371
+ var { clientId: e } = t, n = Q(t, ["clientId"]);
372
+ return new URLSearchParams(((r) => Object.keys(r).filter((i) => r[i] !== void 0).reduce((i, o) => Object.assign(Object.assign({}, i), { [o]: r[o] }), {}))(Object.assign({ client_id: e }, n))).toString();
373
+ }, Kt = (t) => ((e) => decodeURIComponent(atob(e).split("").map((n) => "%" + ("00" + n.charCodeAt(0).toString(16)).slice(-2)).join("")))(t.replace(/_/g, "/").replace(/-/g, "+")), Sr = async (t, e) => {
374
+ const n = await fetch(t, e);
375
+ return { ok: n.ok, json: await n.json() };
376
+ }, Er = async (t, e, n) => {
377
+ const r = new AbortController();
378
+ let i;
379
+ return e.signal = r.signal, Promise.race([Sr(t, e), new Promise((o, a) => {
380
+ i = setTimeout(() => {
381
+ r.abort(), a(new Error("Timeout when executing 'fetch'"));
382
+ }, n);
383
+ })]).finally(() => {
384
+ clearTimeout(i);
385
+ });
386
+ }, Or = async (t, e, n, r, i, o, a) => {
387
+ return s = { auth: { audience: e, scope: n }, timeout: i, fetchUrl: t, fetchOptions: r, useFormData: a }, m = o, new Promise(function(p, u) {
388
+ const c = new MessageChannel();
389
+ c.port1.onmessage = function(h) {
390
+ h.data.error ? u(new Error(h.data.error)) : p(h.data), c.port1.close();
391
+ }, m.postMessage(s, [c.port2]);
392
+ });
393
+ var s, m;
394
+ }, Pr = async (t, e, n, r, i, o, a = 1e4) => i ? Or(t, e, n, r, a, i, o) : Er(t, r, a);
395
+ async function Tr(t, e) {
396
+ var { baseUrl: n, timeout: r, audience: i, scope: o, auth0Client: a, useFormData: s } = t, m = Q(t, ["baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData"]);
397
+ const p = s ? _t(m) : JSON.stringify(m);
398
+ return await async function(u, c, h, d, w, k, v) {
399
+ let I, _ = null;
400
+ for (let x = 0; x < 3; x++)
401
+ try {
402
+ I = await Pr(u, h, d, w, k, v, c), _ = null;
403
+ break;
404
+ } catch (L) {
405
+ _ = L;
406
+ }
407
+ if (_)
408
+ throw _;
409
+ const y = I.json, { error: l, error_description: b } = y, T = Q(y, ["error", "error_description"]), { ok: P } = I;
410
+ if (!P) {
411
+ const x = b || `HTTP error. Unable to fetch ${u}`;
412
+ throw l === "mfa_required" ? new _r(l, x, T.mfa_token) : l === "missing_refresh_token" ? new $n(h, d) : new V(l || "request_error", x);
413
+ }
414
+ return T;
415
+ }(`${n}/oauth/token`, r, i || "default", o, { method: "POST", body: p, headers: { "Content-Type": s ? "application/x-www-form-urlencoded" : "application/json", "Auth0-Client": btoa(JSON.stringify(a || En)) } }, e, s);
416
+ }
417
+ const Xe = (...t) => {
418
+ return (e = t.filter(Boolean).join(" ").trim().split(/\s+/), Array.from(new Set(e))).join(" ");
419
+ var e;
420
+ };
421
+ let le = class St {
422
+ constructor(e, n = "@@auth0spajs@@", r) {
423
+ this.prefix = n, this.suffix = r, this.clientId = e.clientId, this.scope = e.scope, this.audience = e.audience;
424
+ }
425
+ toKey() {
426
+ return [this.prefix, this.clientId, this.audience, this.scope, this.suffix].filter(Boolean).join("::");
427
+ }
428
+ static fromKey(e) {
429
+ const [n, r, i, o] = e.split("::");
430
+ return new St({ clientId: r, scope: o, audience: i }, n);
431
+ }
432
+ static fromCacheEntry(e) {
433
+ const { scope: n, audience: r, client_id: i } = e;
434
+ return new St({ scope: n, audience: r, clientId: i });
435
+ }
436
+ }, jr = class {
437
+ set(e, n) {
438
+ localStorage.setItem(e, JSON.stringify(n));
439
+ }
440
+ get(e) {
441
+ const n = window.localStorage.getItem(e);
442
+ if (n)
443
+ try {
444
+ return JSON.parse(n);
445
+ } catch {
446
+ return;
447
+ }
448
+ }
449
+ remove(e) {
450
+ localStorage.removeItem(e);
451
+ }
452
+ allKeys() {
453
+ return Object.keys(window.localStorage).filter((e) => e.startsWith("@@auth0spajs@@"));
454
+ }
455
+ }, zn = class {
456
+ constructor() {
457
+ this.enclosedCache = /* @__PURE__ */ function() {
458
+ let e = {};
459
+ return { set(n, r) {
460
+ e[n] = r;
461
+ }, get(n) {
462
+ const r = e[n];
463
+ if (r)
464
+ return r;
465
+ }, remove(n) {
466
+ delete e[n];
467
+ }, allKeys: () => Object.keys(e) };
468
+ }();
469
+ }
470
+ }, xr = class {
471
+ constructor(e, n, r) {
472
+ this.cache = e, this.keyManifest = n, this.nowProvider = r || On;
473
+ }
474
+ async setIdToken(e, n, r) {
475
+ var i;
476
+ const o = this.getIdTokenCacheKey(e);
477
+ await this.cache.set(o, { id_token: n, decodedToken: r }), await ((i = this.keyManifest) === null || i === void 0 ? void 0 : i.add(o));
478
+ }
479
+ async getIdToken(e) {
480
+ const n = await this.cache.get(this.getIdTokenCacheKey(e.clientId));
481
+ if (!n && e.scope && e.audience) {
482
+ const r = await this.get(e);
483
+ return !r || !r.id_token || !r.decodedToken ? void 0 : { id_token: r.id_token, decodedToken: r.decodedToken };
484
+ }
485
+ if (n)
486
+ return { id_token: n.id_token, decodedToken: n.decodedToken };
487
+ }
488
+ async get(e, n = 0) {
489
+ var r;
490
+ let i = await this.cache.get(e.toKey());
491
+ if (!i) {
492
+ const s = await this.getCacheKeys();
493
+ if (!s)
494
+ return;
495
+ const m = this.matchExistingCacheKey(e, s);
496
+ m && (i = await this.cache.get(m));
497
+ }
498
+ if (!i)
499
+ return;
500
+ const o = await this.nowProvider(), a = Math.floor(o / 1e3);
501
+ return i.expiresAt - n < a ? i.body.refresh_token ? (i.body = { refresh_token: i.body.refresh_token }, await this.cache.set(e.toKey(), i), i.body) : (await this.cache.remove(e.toKey()), void await ((r = this.keyManifest) === null || r === void 0 ? void 0 : r.remove(e.toKey()))) : i.body;
502
+ }
503
+ async set(e) {
504
+ var n;
505
+ const r = new le({ clientId: e.client_id, scope: e.scope, audience: e.audience }), i = await this.wrapCacheEntry(e);
506
+ await this.cache.set(r.toKey(), i), await ((n = this.keyManifest) === null || n === void 0 ? void 0 : n.add(r.toKey()));
507
+ }
508
+ async clear(e) {
509
+ var n;
510
+ const r = await this.getCacheKeys();
511
+ r && (await r.filter((i) => !e || i.includes(e)).reduce(async (i, o) => {
512
+ await i, await this.cache.remove(o);
513
+ }, Promise.resolve()), await ((n = this.keyManifest) === null || n === void 0 ? void 0 : n.clear()));
514
+ }
515
+ async wrapCacheEntry(e) {
516
+ const n = await this.nowProvider();
517
+ return { body: e, expiresAt: Math.floor(n / 1e3) + e.expires_in };
518
+ }
519
+ async getCacheKeys() {
520
+ var e;
521
+ return this.keyManifest ? (e = await this.keyManifest.get()) === null || e === void 0 ? void 0 : e.keys : this.cache.allKeys ? this.cache.allKeys() : void 0;
522
+ }
523
+ getIdTokenCacheKey(e) {
524
+ return new le({ clientId: e }, "@@auth0spajs@@", "@@user@@").toKey();
525
+ }
526
+ matchExistingCacheKey(e, n) {
527
+ return n.filter((r) => {
528
+ var i;
529
+ const o = le.fromKey(r), a = new Set(o.scope && o.scope.split(" ")), s = ((i = e.scope) === null || i === void 0 ? void 0 : i.split(" ")) || [], m = o.scope && s.reduce((p, u) => p && a.has(u), !0);
530
+ return o.prefix === "@@auth0spajs@@" && o.clientId === e.clientId && o.audience === e.audience && m;
531
+ })[0];
532
+ }
533
+ }, Cr = class {
534
+ constructor(e, n, r) {
535
+ this.storage = e, this.clientId = n, this.cookieDomain = r, this.storageKey = `a0.spajs.txs.${this.clientId}`;
536
+ }
537
+ create(e) {
538
+ this.storage.save(this.storageKey, e, { daysUntilExpire: 1, cookieDomain: this.cookieDomain });
539
+ }
540
+ get() {
541
+ return this.storage.get(this.storageKey);
542
+ }
543
+ remove() {
544
+ this.storage.remove(this.storageKey, { cookieDomain: this.cookieDomain });
545
+ }
546
+ };
547
+ const ze = (t) => typeof t == "number", $r = ["iss", "aud", "exp", "nbf", "iat", "jti", "azp", "nonce", "auth_time", "at_hash", "c_hash", "acr", "amr", "sub_jwk", "cnf", "sip_from_tag", "sip_date", "sip_callid", "sip_cseq_num", "sip_via_branch", "orig", "dest", "mky", "events", "toe", "txn", "rph", "sid", "vot", "vtm"], Ar = (t) => {
548
+ if (!t.id_token)
549
+ throw new Error("ID token is required but missing");
550
+ const e = ((o) => {
551
+ const a = o.split("."), [s, m, p] = a;
552
+ if (a.length !== 3 || !s || !m || !p)
553
+ throw new Error("ID token could not be decoded");
554
+ const u = JSON.parse(Kt(m)), c = { __raw: o }, h = {};
555
+ return Object.keys(u).forEach((d) => {
556
+ c[d] = u[d], $r.includes(d) || (h[d] = u[d]);
557
+ }), { encoded: { header: s, payload: m, signature: p }, header: JSON.parse(Kt(s)), claims: c, user: h };
558
+ })(t.id_token);
559
+ if (!e.claims.iss)
560
+ throw new Error("Issuer (iss) claim must be a string present in the ID token");
561
+ if (e.claims.iss !== t.iss)
562
+ throw new Error(`Issuer (iss) claim mismatch in the ID token; expected "${t.iss}", found "${e.claims.iss}"`);
563
+ if (!e.user.sub)
564
+ throw new Error("Subject (sub) claim must be a string present in the ID token");
565
+ if (e.header.alg !== "RS256")
566
+ throw new Error(`Signature algorithm of "${e.header.alg}" is not supported. Expected the ID token to be signed with "RS256".`);
567
+ if (!e.claims.aud || typeof e.claims.aud != "string" && !Array.isArray(e.claims.aud))
568
+ throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");
569
+ if (Array.isArray(e.claims.aud)) {
570
+ if (!e.claims.aud.includes(t.aud))
571
+ throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but was not one of "${e.claims.aud.join(", ")}"`);
572
+ if (e.claims.aud.length > 1) {
573
+ if (!e.claims.azp)
574
+ throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");
575
+ if (e.claims.azp !== t.aud)
576
+ throw new Error(`Authorized Party (azp) claim mismatch in the ID token; expected "${t.aud}", found "${e.claims.azp}"`);
577
+ }
578
+ } else if (e.claims.aud !== t.aud)
579
+ throw new Error(`Audience (aud) claim mismatch in the ID token; expected "${t.aud}" but found "${e.claims.aud}"`);
580
+ if (t.nonce) {
581
+ if (!e.claims.nonce)
582
+ throw new Error("Nonce (nonce) claim must be a string present in the ID token");
583
+ if (e.claims.nonce !== t.nonce)
584
+ throw new Error(`Nonce (nonce) claim mismatch in the ID token; expected "${t.nonce}", found "${e.claims.nonce}"`);
585
+ }
586
+ if (t.max_age && !ze(e.claims.auth_time))
587
+ throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");
588
+ if (e.claims.exp == null || !ze(e.claims.exp))
589
+ throw new Error("Expiration Time (exp) claim must be a number present in the ID token");
590
+ if (!ze(e.claims.iat))
591
+ throw new Error("Issued At (iat) claim must be a number present in the ID token");
592
+ const n = t.leeway || 60, r = new Date(t.now || Date.now()), i = /* @__PURE__ */ new Date(0);
593
+ if (i.setUTCSeconds(e.claims.exp + n), r > i)
594
+ throw new Error(`Expiration Time (exp) claim error in the ID token; current time (${r}) is after expiration time (${i})`);
595
+ if (e.claims.nbf != null && ze(e.claims.nbf)) {
596
+ const o = /* @__PURE__ */ new Date(0);
597
+ if (o.setUTCSeconds(e.claims.nbf - n), r < o)
598
+ throw new Error(`Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (${r}) is before ${o}`);
599
+ }
600
+ if (e.claims.auth_time != null && ze(e.claims.auth_time)) {
601
+ const o = /* @__PURE__ */ new Date(0);
602
+ if (o.setUTCSeconds(parseInt(e.claims.auth_time) + t.max_age + n), r > o)
603
+ throw new Error(`Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (${r}) is after last auth at ${o}`);
604
+ }
605
+ if (t.organization) {
606
+ const o = t.organization.trim();
607
+ if (o.startsWith("org_")) {
608
+ const a = o;
609
+ if (!e.claims.org_id)
610
+ throw new Error("Organization ID (org_id) claim must be a string present in the ID token");
611
+ if (a !== e.claims.org_id)
612
+ throw new Error(`Organization ID (org_id) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_id}"`);
613
+ } else {
614
+ const a = o.toLowerCase();
615
+ if (!e.claims.org_name)
616
+ throw new Error("Organization Name (org_name) claim must be a string present in the ID token");
617
+ if (a !== e.claims.org_name)
618
+ throw new Error(`Organization Name (org_name) claim mismatch in the ID token; expected "${a}", found "${e.claims.org_name}"`);
619
+ }
620
+ }
621
+ return e;
622
+ };
623
+ var de = jt(function(t, e) {
624
+ var n = ce && ce.__assign || function() {
625
+ return n = Object.assign || function(m) {
626
+ for (var p, u = 1, c = arguments.length; u < c; u++)
627
+ for (var h in p = arguments[u])
628
+ Object.prototype.hasOwnProperty.call(p, h) && (m[h] = p[h]);
629
+ return m;
630
+ }, n.apply(this, arguments);
631
+ };
632
+ function r(m, p) {
633
+ if (!p)
634
+ return "";
635
+ var u = "; " + m;
636
+ return p === !0 ? u : u + "=" + p;
637
+ }
638
+ function i(m, p, u) {
639
+ return encodeURIComponent(m).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/\(/g, "%28").replace(/\)/g, "%29") + "=" + encodeURIComponent(p).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent) + function(c) {
640
+ if (typeof c.expires == "number") {
641
+ var h = /* @__PURE__ */ new Date();
642
+ h.setMilliseconds(h.getMilliseconds() + 864e5 * c.expires), c.expires = h;
643
+ }
644
+ return r("Expires", c.expires ? c.expires.toUTCString() : "") + r("Domain", c.domain) + r("Path", c.path) + r("Secure", c.secure) + r("SameSite", c.sameSite);
645
+ }(u);
646
+ }
647
+ function o(m) {
648
+ for (var p = {}, u = m ? m.split("; ") : [], c = /(%[\dA-F]{2})+/gi, h = 0; h < u.length; h++) {
649
+ var d = u[h].split("="), w = d.slice(1).join("=");
650
+ w.charAt(0) === '"' && (w = w.slice(1, -1));
651
+ try {
652
+ p[d[0].replace(c, decodeURIComponent)] = w.replace(c, decodeURIComponent);
653
+ } catch {
654
+ }
655
+ }
656
+ return p;
657
+ }
658
+ function a() {
659
+ return o(document.cookie);
660
+ }
661
+ function s(m, p, u) {
662
+ document.cookie = i(m, p, n({ path: "/" }, u));
663
+ }
664
+ e.__esModule = !0, e.encode = i, e.parse = o, e.getAll = a, e.get = function(m) {
665
+ return a()[m];
666
+ }, e.set = s, e.remove = function(m, p) {
667
+ s(m, "", n(n({}, p), { expires: -1 }));
668
+ };
669
+ });
670
+ Tt(de), de.encode, de.parse, de.getAll;
671
+ var zr = de.get, Nn = de.set, Dn = de.remove;
672
+ const we = { get(t) {
673
+ const e = zr(t);
674
+ if (e !== void 0)
675
+ return JSON.parse(e);
676
+ }, save(t, e, n) {
677
+ let r = {};
678
+ window.location.protocol === "https:" && (r = { secure: !0, sameSite: "none" }), n != null && n.daysUntilExpire && (r.expires = n.daysUntilExpire), n != null && n.cookieDomain && (r.domain = n.cookieDomain), Nn(t, JSON.stringify(e), r);
679
+ }, remove(t, e) {
680
+ let n = {};
681
+ e != null && e.cookieDomain && (n.domain = e.cookieDomain), Dn(t, n);
682
+ } }, Nr = { get(t) {
683
+ return we.get(t) || we.get(`_legacy_${t}`);
684
+ }, save(t, e, n) {
685
+ let r = {};
686
+ window.location.protocol === "https:" && (r = { secure: !0 }), n != null && n.daysUntilExpire && (r.expires = n.daysUntilExpire), n != null && n.cookieDomain && (r.domain = n.cookieDomain), Nn(`_legacy_${t}`, JSON.stringify(e), r), we.save(t, e, n);
687
+ }, remove(t, e) {
688
+ let n = {};
689
+ e != null && e.cookieDomain && (n.domain = e.cookieDomain), Dn(t, n), we.remove(t, e), we.remove(`_legacy_${t}`, e);
690
+ } }, Dr = { get(t) {
691
+ if (typeof sessionStorage > "u")
692
+ return;
693
+ const e = sessionStorage.getItem(t);
694
+ return e != null ? JSON.parse(e) : void 0;
695
+ }, save(t, e) {
696
+ sessionStorage.setItem(t, JSON.stringify(e));
697
+ }, remove(t) {
698
+ sessionStorage.removeItem(t);
699
+ } };
700
+ function Lr(t, e, n) {
701
+ var r = e === void 0 ? null : e, i = function(m, p) {
702
+ var u = atob(m);
703
+ if (p) {
704
+ for (var c = new Uint8Array(u.length), h = 0, d = u.length; h < d; ++h)
705
+ c[h] = u.charCodeAt(h);
706
+ return String.fromCharCode.apply(null, new Uint16Array(c.buffer));
707
+ }
708
+ return u;
709
+ }(t, n !== void 0 && n), o = i.indexOf(`
710
+ `, 10) + 1, a = i.substring(o) + (r ? "//# sourceMappingURL=" + r : ""), s = new Blob([a], { type: "application/javascript" });
711
+ return URL.createObjectURL(s);
712
+ }
713
+ var Mt, Xt, Ft, ht, Ur = (Mt = "Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHtlcnJvcjp0LGVycm9yX2Rlc2NyaXB0aW9uOnJ9KXtyZXR1cm4gbmV3IGUodCxyKX19Y2xhc3MgdCBleHRlbmRzIGV7Y29uc3RydWN0b3IoZSxzKXtzdXBlcigibWlzc2luZ19yZWZyZXNoX3Rva2VuIixgTWlzc2luZyBSZWZyZXNoIFRva2VuIChhdWRpZW5jZTogJyR7cihlLFsiZGVmYXVsdCJdKX0nLCBzY29wZTogJyR7cihzKX0nKWApLHRoaXMuYXVkaWVuY2U9ZSx0aGlzLnNjb3BlPXMsT2JqZWN0LnNldFByb3RvdHlwZU9mKHRoaXMsdC5wcm90b3R5cGUpfX1mdW5jdGlvbiByKGUsdD1bXSl7cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+YCR7ZX18JHt0fWA7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jKHtkYXRhOnt0aW1lb3V0OmUsYXV0aDpyLGZldGNoVXJsOmksZmV0Y2hPcHRpb25zOmMsdXNlRm9ybURhdGE6YX0scG9ydHM6W3BdfSk9PntsZXQgZjtjb25zdHthdWRpZW5jZTp1LHNjb3BlOmx9PXJ8fHt9O3RyeXtjb25zdCByPWE/KGU9Pntjb25zdCB0PW5ldyBVUkxTZWFyY2hQYXJhbXMoZSkscj17fTtyZXR1cm4gdC5mb3JFYWNoKCgoZSx0KT0+e3JbdF09ZX0pKSxyfSkoYy5ib2R5KTpKU09OLnBhcnNlKGMuYm9keSk7aWYoIXIucmVmcmVzaF90b2tlbiYmInJlZnJlc2hfdG9rZW4iPT09ci5ncmFudF90eXBlKXtjb25zdCBlPSgoZSx0KT0+b1tuKGUsdCldKSh1LGwpO2lmKCFlKXRocm93IG5ldyB0KHUsbCk7Yy5ib2R5PWE/cyhPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKTpKU09OLnN0cmluZ2lmeShPYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30scikse3JlZnJlc2hfdG9rZW46ZX0pKX1sZXQgaCxnOyJmdW5jdGlvbiI9PXR5cGVvZiBBYm9ydENvbnRyb2xsZXImJihoPW5ldyBBYm9ydENvbnRyb2xsZXIsYy5zaWduYWw9aC5zaWduYWwpO3RyeXtnPWF3YWl0IFByb21pc2UucmFjZShbKGQ9ZSxuZXcgUHJvbWlzZSgoZT0+c2V0VGltZW91dChlLGQpKSkpLGZldGNoKGksT2JqZWN0LmFzc2lnbih7fSxjKSldKX1jYXRjaChlKXtyZXR1cm4gdm9pZCBwLnBvc3RNZXNzYWdlKHtlcnJvcjplLm1lc3NhZ2V9KX1pZighZylyZXR1cm4gaCYmaC5hYm9ydCgpLHZvaWQgcC5wb3N0TWVzc2FnZSh7ZXJyb3I6IlRpbWVvdXQgd2hlbiBleGVjdXRpbmcgJ2ZldGNoJyJ9KTtmPWF3YWl0IGcuanNvbigpLGYucmVmcmVzaF90b2tlbj8oKChlLHQscik9PntvW24odCxyKV09ZX0pKGYucmVmcmVzaF90b2tlbix1LGwpLGRlbGV0ZSBmLnJlZnJlc2hfdG9rZW4pOigoZSx0KT0+e2RlbGV0ZSBvW24oZSx0KV19KSh1LGwpLHAucG9zdE1lc3NhZ2Uoe29rOmcub2ssanNvbjpmfSl9Y2F0Y2goZSl7cC5wb3N0TWVzc2FnZSh7b2s6ITEsanNvbjp7ZXJyb3I6ZS5lcnJvcixlcnJvcl9kZXNjcmlwdGlvbjplLm1lc3NhZ2V9fSl9dmFyIGR9KSl9KCk7Cgo=", Xt = null, Ft = !1, function(t) {
714
+ return ht = ht || Lr(Mt, Xt, Ft), new Worker(ht, t);
715
+ });
716
+ const ft = {};
717
+ let Rr = class {
718
+ constructor(e, n) {
719
+ this.cache = e, this.clientId = n, this.manifestKey = this.createManifestKeyFrom(this.clientId);
720
+ }
721
+ async add(e) {
722
+ var n;
723
+ const r = new Set(((n = await this.cache.get(this.manifestKey)) === null || n === void 0 ? void 0 : n.keys) || []);
724
+ r.add(e), await this.cache.set(this.manifestKey, { keys: [...r] });
725
+ }
726
+ async remove(e) {
727
+ const n = await this.cache.get(this.manifestKey);
728
+ if (n) {
729
+ const r = new Set(n.keys);
730
+ return r.delete(e), r.size > 0 ? await this.cache.set(this.manifestKey, { keys: [...r] }) : await this.cache.remove(this.manifestKey);
731
+ }
732
+ }
733
+ get() {
734
+ return this.cache.get(this.manifestKey);
735
+ }
736
+ clear() {
737
+ return this.cache.remove(this.manifestKey);
738
+ }
739
+ createManifestKeyFrom(e) {
740
+ return `@@auth0spajs@@::${e}`;
741
+ }
742
+ };
743
+ const Zr = { memory: () => new zn().enclosedCache, localstorage: () => new jr() }, Jt = (t) => Zr[t], Ht = (t) => {
744
+ const { openUrl: e, onRedirect: n } = t, r = Q(t, ["openUrl", "onRedirect"]);
745
+ return Object.assign(Object.assign({}, r), { openUrl: e === !1 || e ? e : n });
746
+ }, pt = new vr();
747
+ let Wr = class {
748
+ constructor(e) {
749
+ let n, r;
750
+ if (this.userCache = new zn().enclosedCache, this.defaultOptions = { authorizationParams: { scope: "openid profile email" }, useRefreshTokensFallback: !1, useFormData: !0 }, this._releaseLockOnPageHide = async () => {
751
+ await pt.releaseLock("auth0.lock.getTokenSilently"), window.removeEventListener("pagehide", this._releaseLockOnPageHide);
752
+ }, this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), e), { authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), e.authorizationParams) }), typeof window < "u" && (() => {
753
+ if (!Be())
754
+ throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");
755
+ if (Be().subtle === void 0)
756
+ throw new Error(`
757
+ auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
758
+ `);
759
+ })(), e.cache && e.cacheLocation && console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."), e.cache)
760
+ r = e.cache;
761
+ else {
762
+ if (n = e.cacheLocation || "memory", !Jt(n))
763
+ throw new Error(`Invalid cache location "${n}"`);
764
+ r = Jt(n)();
765
+ }
766
+ this.httpTimeoutMs = e.httpTimeoutInSeconds ? 1e3 * e.httpTimeoutInSeconds : 1e4, this.cookieStorage = e.legacySameSiteCookie === !1 ? we : Nr, this.orgHintCookieName = `auth0.${this.options.clientId}.organization_hint`, this.isAuthenticatedCookieName = ((a) => `auth0.${a}.is.authenticated`)(this.options.clientId), this.sessionCheckExpiryDays = e.sessionCheckExpiryDays || 1;
767
+ const i = e.useCookiesForTransactions ? this.cookieStorage : Dr;
768
+ var o;
769
+ this.scope = Xe("openid", this.options.authorizationParams.scope, this.options.useRefreshTokens ? "offline_access" : ""), this.transactionManager = new Cr(i, this.options.clientId, this.options.cookieDomain), this.nowProvider = this.options.nowProvider || On, this.cacheManager = new xr(r, r.allKeys ? void 0 : new Rr(r, this.options.clientId), this.nowProvider), this.domainUrl = (o = this.options.domain, /^https?:\/\//.test(o) ? o : `https://${o}`), this.tokenIssuer = ((a, s) => a ? a.startsWith("https://") ? a : `https://${a}/` : `${s}/`)(this.options.issuer, this.domainUrl), typeof window < "u" && window.Worker && this.options.useRefreshTokens && n === "memory" && (this.options.workerUrl ? this.worker = new Worker(this.options.workerUrl) : this.worker = new Ur());
770
+ }
771
+ _url(e) {
772
+ const n = encodeURIComponent(btoa(JSON.stringify(this.options.auth0Client || En)));
773
+ return `${this.domainUrl}${e}&auth0Client=${n}`;
774
+ }
775
+ _authorizeUrl(e) {
776
+ return this._url(`/authorize?${_t(e)}`);
777
+ }
778
+ async _verifyIdToken(e, n, r) {
779
+ const i = await this.nowProvider();
780
+ return Ar({ iss: this.tokenIssuer, aud: this.options.clientId, id_token: e, nonce: n, organization: r, leeway: this.options.leeway, max_age: (o = this.options.authorizationParams.max_age, typeof o != "string" ? o : parseInt(o, 10) || void 0), now: i });
781
+ var o;
782
+ }
783
+ _processOrgHint(e) {
784
+ e ? this.cookieStorage.save(this.orgHintCookieName, e, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }) : this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain });
785
+ }
786
+ async _prepareAuthorizeUrl(e, n, r) {
787
+ const i = Wt(dt()), o = Wt(dt()), a = dt(), s = ((u) => {
788
+ const c = new Uint8Array(u);
789
+ return ((h) => {
790
+ const d = { "+": "-", "/": "_", "=": "" };
791
+ return h.replace(/[+/=]/g, (w) => d[w]);
792
+ })(window.btoa(String.fromCharCode(...Array.from(c))));
793
+ })(await (async (u) => await Be().subtle.digest({ name: "SHA-256" }, new TextEncoder().encode(u)))(a)), m = ((u, c, h, d, w, k, v, I) => Object.assign(Object.assign(Object.assign({ client_id: u.clientId }, u.authorizationParams), h), { scope: Xe(c, h.scope), response_type: "code", response_mode: I || "query", state: d, nonce: w, redirect_uri: v || u.authorizationParams.redirect_uri, code_challenge: k, code_challenge_method: "S256" }))(this.options, this.scope, e, i, o, s, e.redirect_uri || this.options.authorizationParams.redirect_uri || r, n == null ? void 0 : n.response_mode), p = this._authorizeUrl(m);
794
+ return { nonce: o, code_verifier: a, scope: m.scope, audience: m.audience || "default", redirect_uri: m.redirect_uri, state: i, url: p };
795
+ }
796
+ async loginWithPopup(e, n) {
797
+ var r;
798
+ if (e = e || {}, !(n = n || {}).popup && (n.popup = ((s) => {
799
+ const m = window.screenX + (window.innerWidth - 400) / 2, p = window.screenY + (window.innerHeight - 600) / 2;
800
+ return window.open(s, "auth0:authorize:popup", `left=${m},top=${p},width=400,height=600,resizable,scrollbars=yes,status=1`);
801
+ })(""), !n.popup))
802
+ throw new Error("Unable to open a popup for loginWithPopup - window.open returned `null`");
803
+ const i = await this._prepareAuthorizeUrl(e.authorizationParams || {}, { response_mode: "web_message" }, window.location.origin);
804
+ n.popup.location.href = i.url;
805
+ const o = await ((s) => new Promise((m, p) => {
806
+ let u;
807
+ const c = setInterval(() => {
808
+ s.popup && s.popup.closed && (clearInterval(c), clearTimeout(h), window.removeEventListener("message", u, !1), p(new Ir(s.popup)));
809
+ }, 1e3), h = setTimeout(() => {
810
+ clearInterval(c), p(new kr(s.popup)), window.removeEventListener("message", u, !1);
811
+ }, 1e3 * (s.timeoutInSeconds || 60));
812
+ u = function(d) {
813
+ if (d.data && d.data.type === "authorization_response") {
814
+ if (clearTimeout(h), clearInterval(c), window.removeEventListener("message", u, !1), s.popup.close(), d.data.response.error)
815
+ return p(V.fromPayload(d.data.response));
816
+ m(d.data.response);
817
+ }
818
+ }, window.addEventListener("message", u);
819
+ }))(Object.assign(Object.assign({}, n), { timeoutInSeconds: n.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || 60 }));
820
+ if (i.state !== o.state)
821
+ throw new V("state_mismatch", "Invalid state");
822
+ const a = ((r = e.authorizationParams) === null || r === void 0 ? void 0 : r.organization) || this.options.authorizationParams.organization;
823
+ await this._requestToken({ audience: i.audience, scope: i.scope, code_verifier: i.code_verifier, grant_type: "authorization_code", code: o.code, redirect_uri: i.redirect_uri }, { nonceIn: i.nonce, organization: a });
824
+ }
825
+ async getUser() {
826
+ var e;
827
+ const n = await this._getIdTokenFromCache();
828
+ return (e = n == null ? void 0 : n.decodedToken) === null || e === void 0 ? void 0 : e.user;
829
+ }
830
+ async getIdTokenClaims() {
831
+ var e;
832
+ const n = await this._getIdTokenFromCache();
833
+ return (e = n == null ? void 0 : n.decodedToken) === null || e === void 0 ? void 0 : e.claims;
834
+ }
835
+ async loginWithRedirect(e = {}) {
836
+ var n;
837
+ const r = Ht(e), { openUrl: i, fragment: o, appState: a } = r, s = Q(r, ["openUrl", "fragment", "appState"]), m = ((n = s.authorizationParams) === null || n === void 0 ? void 0 : n.organization) || this.options.authorizationParams.organization, p = await this._prepareAuthorizeUrl(s.authorizationParams || {}), { url: u } = p, c = Q(p, ["url"]);
838
+ this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, c), { appState: a }), m && { organization: m }));
839
+ const h = o ? `${u}#${o}` : u;
840
+ i ? await i(h) : window.location.assign(h);
841
+ }
842
+ async handleRedirectCallback(e = window.location.href) {
843
+ const n = e.split("?").slice(1);
844
+ if (n.length === 0)
845
+ throw new Error("There are no query params available for parsing.");
846
+ const { state: r, code: i, error: o, error_description: a } = ((c) => {
847
+ c.indexOf("#") > -1 && (c = c.substring(0, c.indexOf("#")));
848
+ const h = new URLSearchParams(c);
849
+ return { state: h.get("state"), code: h.get("code") || void 0, error: h.get("error") || void 0, error_description: h.get("error_description") || void 0 };
850
+ })(n.join("")), s = this.transactionManager.get();
851
+ if (!s)
852
+ throw new V("missing_transaction", "Invalid state");
853
+ if (this.transactionManager.remove(), o)
854
+ throw new br(o, a || o, r, s.appState);
855
+ if (!s.code_verifier || s.state && s.state !== r)
856
+ throw new V("state_mismatch", "Invalid state");
857
+ const m = s.organization, p = s.nonce, u = s.redirect_uri;
858
+ return await this._requestToken(Object.assign({ audience: s.audience, scope: s.scope, code_verifier: s.code_verifier, grant_type: "authorization_code", code: i }, u ? { redirect_uri: u } : {}), { nonceIn: p, organization: m }), { appState: s.appState };
859
+ }
860
+ async checkSession(e) {
861
+ if (!this.cookieStorage.get(this.isAuthenticatedCookieName)) {
862
+ if (!this.cookieStorage.get("auth0.is.authenticated"))
863
+ return;
864
+ this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove("auth0.is.authenticated");
865
+ }
866
+ try {
867
+ await this.getTokenSilently(e);
868
+ } catch {
869
+ }
870
+ }
871
+ async getTokenSilently(e = {}) {
872
+ var n;
873
+ const r = Object.assign(Object.assign({ cacheMode: "on" }, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: Xe(this.scope, (n = e.authorizationParams) === null || n === void 0 ? void 0 : n.scope) }) }), i = await ((o, a) => {
874
+ let s = ft[a];
875
+ return s || (s = o().finally(() => {
876
+ delete ft[a], s = null;
877
+ }), ft[a] = s), s;
878
+ })(() => this._getTokenSilently(r), `${this.options.clientId}::${r.authorizationParams.audience}::${r.authorizationParams.scope}`);
879
+ return e.detailedResponse ? i : i == null ? void 0 : i.access_token;
880
+ }
881
+ async _getTokenSilently(e) {
882
+ const { cacheMode: n } = e, r = Q(e, ["cacheMode"]);
883
+ if (n !== "off") {
884
+ const i = await this._getEntryFromCache({ scope: r.authorizationParams.scope, audience: r.authorizationParams.audience || "default", clientId: this.options.clientId });
885
+ if (i)
886
+ return i;
887
+ }
888
+ if (n !== "cache-only") {
889
+ if (!await (async (i, o = 3) => {
890
+ for (let a = 0; a < o; a++)
891
+ if (await i())
892
+ return !0;
893
+ return !1;
894
+ })(() => pt.acquireLock("auth0.lock.getTokenSilently", 5e3), 10))
895
+ throw new It();
896
+ try {
897
+ if (window.addEventListener("pagehide", this._releaseLockOnPageHide), n !== "off") {
898
+ const p = await this._getEntryFromCache({ scope: r.authorizationParams.scope, audience: r.authorizationParams.audience || "default", clientId: this.options.clientId });
899
+ if (p)
900
+ return p;
901
+ }
902
+ const i = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(r) : await this._getTokenFromIFrame(r), { id_token: o, access_token: a, oauthTokenScope: s, expires_in: m } = i;
903
+ return Object.assign(Object.assign({ id_token: o, access_token: a }, s ? { scope: s } : null), { expires_in: m });
904
+ } finally {
905
+ await pt.releaseLock("auth0.lock.getTokenSilently"), window.removeEventListener("pagehide", this._releaseLockOnPageHide);
906
+ }
907
+ }
908
+ }
909
+ async getTokenWithPopup(e = {}, n = {}) {
910
+ var r;
911
+ const i = Object.assign(Object.assign({}, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: Xe(this.scope, (r = e.authorizationParams) === null || r === void 0 ? void 0 : r.scope) }) });
912
+ return n = Object.assign(Object.assign({}, wr), n), await this.loginWithPopup(i, n), (await this.cacheManager.get(new le({ scope: i.authorizationParams.scope, audience: i.authorizationParams.audience || "default", clientId: this.options.clientId }))).access_token;
913
+ }
914
+ async isAuthenticated() {
915
+ return !!await this.getUser();
916
+ }
917
+ _buildLogoutUrl(e) {
918
+ e.clientId !== null ? e.clientId = e.clientId || this.options.clientId : delete e.clientId;
919
+ const n = e.logoutParams || {}, { federated: r } = n, i = Q(n, ["federated"]), o = r ? "&federated" : "";
920
+ return this._url(`/v2/logout?${_t(Object.assign({ clientId: e.clientId }, i))}`) + o;
921
+ }
922
+ async logout(e = {}) {
923
+ const n = Ht(e), { openUrl: r } = n, i = Q(n, ["openUrl"]);
924
+ e.clientId === null ? await this.cacheManager.clear() : await this.cacheManager.clear(e.clientId || this.options.clientId), this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove(this.isAuthenticatedCookieName, { cookieDomain: this.options.cookieDomain }), this.userCache.remove("@@user@@");
925
+ const o = this._buildLogoutUrl(i);
926
+ r ? await r(o) : r !== !1 && window.location.assign(o);
927
+ }
928
+ async _getTokenFromIFrame(e) {
929
+ const n = Object.assign(Object.assign({}, e.authorizationParams), { prompt: "none" }), r = this.cookieStorage.get(this.orgHintCookieName);
930
+ r && !n.organization && (n.organization = r);
931
+ const { url: i, state: o, nonce: a, code_verifier: s, redirect_uri: m, scope: p, audience: u } = await this._prepareAuthorizeUrl(n, { response_mode: "web_message" }, window.location.origin);
932
+ try {
933
+ if (window.crossOriginIsolated)
934
+ throw new V("login_required", "The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");
935
+ const c = e.timeoutInSeconds || this.options.authorizeTimeoutInSeconds, h = await ((w, k, v = 60) => new Promise((I, _) => {
936
+ const y = window.document.createElement("iframe");
937
+ y.setAttribute("width", "0"), y.setAttribute("height", "0"), y.style.display = "none";
938
+ const l = () => {
939
+ window.document.body.contains(y) && (window.document.body.removeChild(y), window.removeEventListener("message", b, !1));
940
+ };
941
+ let b;
942
+ const T = setTimeout(() => {
943
+ _(new It()), l();
944
+ }, 1e3 * v);
945
+ b = function(P) {
946
+ if (P.origin != k || !P.data || P.data.type !== "authorization_response")
947
+ return;
948
+ const x = P.source;
949
+ x && x.close(), P.data.response.error ? _(V.fromPayload(P.data.response)) : I(P.data.response), clearTimeout(T), window.removeEventListener("message", b, !1), setTimeout(l, 2e3);
950
+ }, window.addEventListener("message", b, !1), window.document.body.appendChild(y), y.setAttribute("src", w);
951
+ }))(i, this.domainUrl, c);
952
+ if (o !== h.state)
953
+ throw new V("state_mismatch", "Invalid state");
954
+ const d = await this._requestToken(Object.assign(Object.assign({}, e.authorizationParams), { code_verifier: s, code: h.code, grant_type: "authorization_code", redirect_uri: m, timeout: e.authorizationParams.timeout || this.httpTimeoutMs }), { nonceIn: a, organization: n.organization });
955
+ return Object.assign(Object.assign({}, d), { scope: p, oauthTokenScope: d.scope, audience: u });
956
+ } catch (c) {
957
+ throw c.error === "login_required" && this.logout({ openUrl: !1 }), c;
958
+ }
959
+ }
960
+ async _getTokenUsingRefreshToken(e) {
961
+ const n = await this.cacheManager.get(new le({ scope: e.authorizationParams.scope, audience: e.authorizationParams.audience || "default", clientId: this.options.clientId }));
962
+ if (!(n && n.refresh_token || this.worker)) {
963
+ if (this.options.useRefreshTokensFallback)
964
+ return await this._getTokenFromIFrame(e);
965
+ throw new $n(e.authorizationParams.audience || "default", e.authorizationParams.scope);
966
+ }
967
+ const r = e.authorizationParams.redirect_uri || this.options.authorizationParams.redirect_uri || window.location.origin, i = typeof e.timeoutInSeconds == "number" ? 1e3 * e.timeoutInSeconds : null;
968
+ try {
969
+ const o = await this._requestToken(Object.assign(Object.assign(Object.assign({}, e.authorizationParams), { grant_type: "refresh_token", refresh_token: n && n.refresh_token, redirect_uri: r }), i && { timeout: i }));
970
+ return Object.assign(Object.assign({}, o), { scope: e.authorizationParams.scope, oauthTokenScope: o.scope, audience: e.authorizationParams.audience || "default" });
971
+ } catch (o) {
972
+ if ((o.message.indexOf("Missing Refresh Token") > -1 || o.message && o.message.indexOf("invalid refresh token") > -1) && this.options.useRefreshTokensFallback)
973
+ return await this._getTokenFromIFrame(e);
974
+ throw o;
975
+ }
976
+ }
977
+ async _saveEntryInCache(e) {
978
+ const { id_token: n, decodedToken: r } = e, i = Q(e, ["id_token", "decodedToken"]);
979
+ this.userCache.set("@@user@@", { id_token: n, decodedToken: r }), await this.cacheManager.setIdToken(this.options.clientId, e.id_token, e.decodedToken), await this.cacheManager.set(i);
980
+ }
981
+ async _getIdTokenFromCache() {
982
+ const e = this.options.authorizationParams.audience || "default", n = await this.cacheManager.getIdToken(new le({ clientId: this.options.clientId, audience: e, scope: this.scope })), r = this.userCache.get("@@user@@");
983
+ return n && n.id_token === (r == null ? void 0 : r.id_token) ? r : (this.userCache.set("@@user@@", n), n);
984
+ }
985
+ async _getEntryFromCache({ scope: e, audience: n, clientId: r }) {
986
+ const i = await this.cacheManager.get(new le({ scope: e, audience: n, clientId: r }), 60);
987
+ if (i && i.access_token) {
988
+ const { access_token: o, oauthTokenScope: a, expires_in: s } = i, m = await this._getIdTokenFromCache();
989
+ return m && Object.assign(Object.assign({ id_token: m.id_token, access_token: o }, a ? { scope: a } : null), { expires_in: s });
990
+ }
991
+ }
992
+ async _requestToken(e, n) {
993
+ const { nonceIn: r, organization: i } = n || {}, o = await Tr(Object.assign({ baseUrl: this.domainUrl, client_id: this.options.clientId, auth0Client: this.options.auth0Client, useFormData: this.options.useFormData, timeout: this.httpTimeoutMs }, e), this.worker), a = await this._verifyIdToken(o.id_token, r, i);
994
+ return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, o), { decodedToken: a, scope: e.scope, audience: e.audience || "default" }), o.scope ? { oauthTokenScope: o.scope } : null), { client_id: this.options.clientId })), this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this._processOrgHint(i || a.claims.org_id), Object.assign(Object.assign({}, o), { decodedToken: a });
995
+ }
996
+ };
997
+ async function Kr(t) {
998
+ const e = new Wr(t);
999
+ return await e.checkSession(), e;
1000
+ }
1001
+ const xt = "sesamy.com", Mr = "https://logs.sesamy.com/events";
1002
+ var pe = /* @__PURE__ */ ((t) => (t.READY = "sesamyReady", t.AUTHENTICATED = "sesamyAuthenticated", t.LOGOUT = "sesamyLogout", t.SOFT_PAYWALL = "sesamySoftPaywall", t))(pe || {});
1003
+ let F;
1004
+ async function Xr({ clientId: t }) {
1005
+ if (F = await Kr({
1006
+ domain: `token.${xt}`,
1007
+ clientId: t,
1008
+ cacheLocation: "localstorage"
1009
+ }), window.location.search.includes("code="))
1010
+ try {
1011
+ await F.handleRedirectCallback();
1012
+ const e = await F.getUser();
1013
+ rt(pe.AUTHENTICATED, e), window.history.replaceState({}, document.title, "/");
1014
+ const n = await F.getTokenSilently();
1015
+ localStorage.setItem("accessToken", n);
1016
+ } catch {
1017
+ }
1018
+ }
1019
+ async function Fr() {
1020
+ if (!F)
1021
+ throw new Error("Auth0 client not initialized");
1022
+ return F.isAuthenticated();
1023
+ }
1024
+ async function Jr() {
1025
+ if (!F)
1026
+ throw new Error("Auth0 client not initialized");
1027
+ return F.getUser();
1028
+ }
1029
+ function Hr() {
1030
+ if (!F)
1031
+ throw new Error("Auth0 client not initialized");
1032
+ return F.loginWithRedirect({
1033
+ authorizationParams: {
1034
+ redirect_uri: window.location.href
1035
+ }
1036
+ });
1037
+ }
1038
+ async function Vr() {
1039
+ if (!F)
1040
+ throw new Error("Auth0 client not initialized");
1041
+ return F.getTokenSilently();
1042
+ }
1043
+ async function Yr() {
1044
+ if (!F)
1045
+ throw new Error("Auth0 client not initialized");
1046
+ return rt(pe.LOGOUT, {}), F.logout({
1047
+ logoutParams: {
1048
+ returnTo: window.location.href
1049
+ }
1050
+ });
1051
+ }
1052
+ const Gr = (t, e) => e.skipDedupe || e.method !== "GET", Br = (t, e) => e.method + "@" + t, qr = (t) => t.clone(), Ln = ({ skip: t = Gr, key: e = Br, resolver: n = qr } = {}) => {
1053
+ const r = /* @__PURE__ */ new Map();
1054
+ return (i) => (o, a) => {
1055
+ if (t(o, a))
1056
+ return i(o, a);
1057
+ const s = e(o, a);
1058
+ if (!r.has(s))
1059
+ r.set(s, []);
1060
+ else
1061
+ return new Promise((m, p) => {
1062
+ r.get(s).push([m, p]);
1063
+ });
1064
+ try {
1065
+ return i(o, a).then((m) => (r.get(s).forEach(([p]) => p(n(m))), r.delete(s), m)).catch((m) => {
1066
+ throw r.get(s).forEach(([p, u]) => u(m)), r.delete(s), m;
1067
+ });
1068
+ } catch (m) {
1069
+ return r.delete(s), Promise.reject(m);
1070
+ }
1071
+ };
1072
+ }, Qr = (t, e) => t * e, ei = (t) => t && t.ok, Un = ({ delayTimer: t = 500, delayRamp: e = Qr, maxAttempts: n = 10, until: r = ei, onRetry: i = null, retryOnNetworkError: o = !1, resolveWithLatestResponse: a = !1, skip: s } = {}) => (m) => (p, u) => {
1073
+ let c = 0;
1074
+ if (s && s(p, u))
1075
+ return m(p, u);
1076
+ const h = (d, w) => Promise.resolve(r(d, w)).then((k) => k ? d && a ? d : w ? Promise.reject(w) : d : (c++, !n || c <= n ? new Promise((v) => {
1077
+ const I = e(t, c);
1078
+ setTimeout(() => {
1079
+ typeof i == "function" ? Promise.resolve(i({
1080
+ response: d,
1081
+ error: w,
1082
+ url: p,
1083
+ options: u
1084
+ })).then((_ = {}) => {
1085
+ var y, l;
1086
+ v(m((y = _ && _.url) !== null && y !== void 0 ? y : p, (l = _ && _.options) !== null && l !== void 0 ? l : u));
1087
+ }) : v(m(p, u));
1088
+ }, I);
1089
+ }).then(h).catch((v) => {
1090
+ if (!o)
1091
+ throw v;
1092
+ return h(null, v);
1093
+ }) : d && a ? d : Promise.reject(w || new Error("Number of attempts exceeded."))));
1094
+ return m(p, u).then(h).catch((d) => {
1095
+ if (!o)
1096
+ throw d;
1097
+ return h(null, d);
1098
+ });
1099
+ }, ti = "application/json", Rn = "Content-Type", ve = Symbol(), Zn = Symbol();
1100
+ function Vt(t = {}) {
1101
+ var e;
1102
+ return (e = Object.entries(t).find(([n]) => n.toLowerCase() === Rn.toLowerCase())) === null || e === void 0 ? void 0 : e[1];
1103
+ }
1104
+ function Yt(t) {
1105
+ return /^application\/.*json.*/.test(t);
1106
+ }
1107
+ const he = function(t, e, n = !1) {
1108
+ return Object.entries(e).reduce((r, [i, o]) => {
1109
+ const a = t[i];
1110
+ return Array.isArray(a) && Array.isArray(o) ? r[i] = n ? [...a, ...o] : o : typeof a == "object" && typeof o == "object" ? r[i] = he(a, o, n) : r[i] = o, r;
1111
+ }, { ...t });
1112
+ }, Ee = {
1113
+ // Default options
1114
+ options: {},
1115
+ // Error type
1116
+ errorType: "text",
1117
+ // Polyfills
1118
+ polyfills: {
1119
+ // fetch: null,
1120
+ // FormData: null,
1121
+ // URLSearchParams: null,
1122
+ // performance: null,
1123
+ // PerformanceObserver: null,
1124
+ // AbortController: null
1125
+ },
1126
+ polyfill(t, e = !0, n = !1, ...r) {
1127
+ const i = this.polyfills[t] || (typeof self < "u" ? self[t] : null) || (typeof global < "u" ? global[t] : null);
1128
+ if (e && !i)
1129
+ throw new Error(t + " is not defined");
1130
+ return n && i ? new i(...r) : i;
1131
+ }
1132
+ };
1133
+ function ni(t, e = !1) {
1134
+ Ee.options = e ? t : he(Ee.options, t);
1135
+ }
1136
+ function ri(t, e = !1) {
1137
+ Ee.polyfills = e ? t : he(Ee.polyfills, t);
1138
+ }
1139
+ function ii(t) {
1140
+ Ee.errorType = t;
1141
+ }
1142
+ const oi = (t) => (e) => t.reduceRight((n, r) => r(n), e) || e;
1143
+ class Wn extends Error {
1144
+ }
1145
+ const ai = (t) => {
1146
+ const e = /* @__PURE__ */ Object.create(null);
1147
+ t = t._addons.reduce((y, l) => l.beforeRequest && l.beforeRequest(y, t._options, e) || y, t);
1148
+ const { _url: n, _options: r, _config: i, _catchers: o, _resolvers: a, _middlewares: s, _addons: m } = t, p = new Map(o), u = he(i.options, r);
1149
+ let c = n;
1150
+ const h = oi(s)((y, l) => (c = y, i.polyfill("fetch")(y, l)))(n, u), d = new Error(), w = h.catch((y) => {
1151
+ throw { [ve]: y };
1152
+ }).then((y) => {
1153
+ if (!y.ok) {
1154
+ const l = new Wn();
1155
+ if (l.cause = d, l.stack = l.stack + `
1156
+ CAUSE: ` + d.stack, l.response = y, l.url = c, y.type === "opaque")
1157
+ throw l;
1158
+ return y.text().then((b) => {
1159
+ var T;
1160
+ if (l.message = b, i.errorType === "json" || ((T = y.headers.get("Content-Type")) === null || T === void 0 ? void 0 : T.split(";")[0]) === "application/json")
1161
+ try {
1162
+ l.json = JSON.parse(b);
1163
+ } catch {
1164
+ }
1165
+ throw l.text = b, l.status = y.status, l;
1166
+ });
1167
+ }
1168
+ return y;
1169
+ }), k = (y) => y.catch((l) => {
1170
+ const b = l.hasOwnProperty(ve), T = b ? l[ve] : l, P = (T == null ? void 0 : T.status) && p.get(T.status) || p.get(T == null ? void 0 : T.name) || b && p.has(ve) && p.get(ve);
1171
+ if (P)
1172
+ return P(T, t);
1173
+ const x = p.get(Zn);
1174
+ if (x)
1175
+ return x(T, t);
1176
+ throw T;
1177
+ }), v = (y) => (l) => /* If a callback is provided, then callback with the body result otherwise return the parsed body itself. */ k(y ? w.then((b) => b && b[y]()).then((b) => l ? l(b) : b) : w.then((b) => l ? l(b) : b)), I = {
1178
+ _wretchReq: t,
1179
+ _fetchReq: h,
1180
+ _sharedState: e,
1181
+ res: v(null),
1182
+ json: v("json"),
1183
+ blob: v("blob"),
1184
+ formData: v("formData"),
1185
+ arrayBuffer: v("arrayBuffer"),
1186
+ text: v("text"),
1187
+ error(y, l) {
1188
+ return p.set(y, l), this;
1189
+ },
1190
+ badRequest(y) {
1191
+ return this.error(400, y);
1192
+ },
1193
+ unauthorized(y) {
1194
+ return this.error(401, y);
1195
+ },
1196
+ forbidden(y) {
1197
+ return this.error(403, y);
1198
+ },
1199
+ notFound(y) {
1200
+ return this.error(404, y);
1201
+ },
1202
+ timeout(y) {
1203
+ return this.error(408, y);
1204
+ },
1205
+ internalError(y) {
1206
+ return this.error(500, y);
1207
+ },
1208
+ fetchError(y) {
1209
+ return this.error(ve, y);
1210
+ }
1211
+ }, _ = m.reduce((y, l) => ({
1212
+ ...y,
1213
+ ...typeof l.resolver == "function" ? l.resolver(y) : l.resolver
1214
+ }), I);
1215
+ return a.reduce((y, l) => l(y, t), _);
1216
+ }, si = {
1217
+ _url: "",
1218
+ _options: {},
1219
+ _config: Ee,
1220
+ _catchers: /* @__PURE__ */ new Map(),
1221
+ _resolvers: [],
1222
+ _deferred: [],
1223
+ _middlewares: [],
1224
+ _addons: [],
1225
+ addon(t) {
1226
+ return { ...this, _addons: [...this._addons, t], ...t.wretch };
1227
+ },
1228
+ errorType(t) {
1229
+ return {
1230
+ ...this,
1231
+ _config: {
1232
+ ...this._config,
1233
+ errorType: t
1234
+ }
1235
+ };
1236
+ },
1237
+ polyfills(t, e = !1) {
1238
+ return {
1239
+ ...this,
1240
+ _config: {
1241
+ ...this._config,
1242
+ polyfills: e ? t : he(this._config.polyfills, t)
1243
+ }
1244
+ };
1245
+ },
1246
+ url(t, e = !1) {
1247
+ if (e)
1248
+ return { ...this, _url: t };
1249
+ const n = this._url.split("?");
1250
+ return {
1251
+ ...this,
1252
+ _url: n.length > 1 ? n[0] + t + "?" + n[1] : this._url + t
1253
+ };
1254
+ },
1255
+ options(t, e = !1) {
1256
+ return { ...this, _options: e ? t : he(this._options, t) };
1257
+ },
1258
+ headers(t) {
1259
+ const e = t ? Array.isArray(t) ? Object.fromEntries(t) : "entries" in t ? Object.fromEntries(t.entries()) : t : {};
1260
+ return { ...this, _options: he(this._options, { headers: e }) };
1261
+ },
1262
+ accept(t) {
1263
+ return this.headers({ Accept: t });
1264
+ },
1265
+ content(t) {
1266
+ return this.headers({ [Rn]: t });
1267
+ },
1268
+ auth(t) {
1269
+ return this.headers({ Authorization: t });
1270
+ },
1271
+ catcher(t, e) {
1272
+ const n = new Map(this._catchers);
1273
+ return n.set(t, e), { ...this, _catchers: n };
1274
+ },
1275
+ catcherFallback(t) {
1276
+ return this.catcher(Zn, t);
1277
+ },
1278
+ resolve(t, e = !1) {
1279
+ return { ...this, _resolvers: e ? [t] : [...this._resolvers, t] };
1280
+ },
1281
+ defer(t, e = !1) {
1282
+ return {
1283
+ ...this,
1284
+ _deferred: e ? [t] : [...this._deferred, t]
1285
+ };
1286
+ },
1287
+ middlewares(t, e = !1) {
1288
+ return {
1289
+ ...this,
1290
+ _middlewares: e ? t : [...this._middlewares, ...t]
1291
+ };
1292
+ },
1293
+ fetch(t = this._options.method, e = "", n = null) {
1294
+ let r = this.url(e).options({ method: t });
1295
+ const i = Vt(r._options.headers), o = typeof n == "object" && (!r._options.headers || !i || Yt(i));
1296
+ return r = n ? o ? r.json(n, i) : r.body(n) : r, ai(r._deferred.reduce((a, s) => s(a, a._url, a._options), r));
1297
+ },
1298
+ get(t = "") {
1299
+ return this.fetch("GET", t);
1300
+ },
1301
+ delete(t = "") {
1302
+ return this.fetch("DELETE", t);
1303
+ },
1304
+ put(t, e = "") {
1305
+ return this.fetch("PUT", e, t);
1306
+ },
1307
+ post(t, e = "") {
1308
+ return this.fetch("POST", e, t);
1309
+ },
1310
+ patch(t, e = "") {
1311
+ return this.fetch("PATCH", e, t);
1312
+ },
1313
+ head(t = "") {
1314
+ return this.fetch("HEAD", t);
1315
+ },
1316
+ opts(t = "") {
1317
+ return this.fetch("OPTIONS", t);
1318
+ },
1319
+ body(t) {
1320
+ return { ...this, _options: { ...this._options, body: t } };
1321
+ },
1322
+ json(t, e) {
1323
+ const n = Vt(this._options.headers);
1324
+ return this.content(e || Yt(n) && n || ti).body(JSON.stringify(t));
1325
+ }
1326
+ };
1327
+ function oe(t = "", e = {}) {
1328
+ return { ...si, _url: t, _options: e };
1329
+ }
1330
+ oe.default = oe;
1331
+ oe.options = ni;
1332
+ oe.errorType = ii;
1333
+ oe.polyfills = ri;
1334
+ oe.WretchError = Wn;
1335
+ const ci = (t) => (e, n) => new Promise(async (r, i) => {
1336
+ try {
1337
+ const o = await Vr(), a = {
1338
+ ...n,
1339
+ headers: {
1340
+ ...n.headers,
1341
+ Authorization: `Bearer ${o}`
1342
+ }
1343
+ };
1344
+ r(t(e, a));
1345
+ } catch (o) {
1346
+ console.error("Error fetching access token:", o), i(o);
1347
+ }
1348
+ }), ui = (t) => (e, n) => {
1349
+ const r = localStorage.getItem("__anon_id"), i = btoa(`${r}:`), o = {
1350
+ ...n,
1351
+ headers: {
1352
+ ...n.headers,
1353
+ Authorization: `Basic ${i}`
1354
+ }
1355
+ };
1356
+ return t(e, o);
1357
+ }, je = oe(`https://api2.${xt}`).headers({ "Content-Type": "application/json" }).middlewares([
1358
+ ci,
1359
+ Ln(),
1360
+ Un({
1361
+ delayTimer: 1e3,
1362
+ delayRamp: (t, e) => t * e,
1363
+ maxAttempts: 3,
1364
+ until: (t) => (t == null ? void 0 : t.ok) || !1,
1365
+ retryOnNetworkError: !1
1366
+ })
1367
+ ]), it = oe(`https://api2.${xt}`).headers({ "Content-Type": "application/json" }).middlewares([
1368
+ ui,
1369
+ Ln(),
1370
+ Un({
1371
+ delayTimer: 1e3,
1372
+ delayRamp: (t, e) => t * e,
1373
+ maxAttempts: 3,
1374
+ until: (t) => (t == null ? void 0 : t.ok) || !1,
1375
+ retryOnNetworkError: !1
1376
+ })
1377
+ ]);
1378
+ async function li() {
1379
+ return je.get("/entitlements").json();
1380
+ }
1381
+ async function di(t) {
1382
+ const e = await je.get("/entitlements").json();
1383
+ return e == null ? void 0 : e.find((n) => n.id === t);
1384
+ }
1385
+ async function hi() {
1386
+ return je.get("/contracts").json();
1387
+ }
1388
+ async function fi(t) {
1389
+ const e = await je.get("/contracts").json();
1390
+ return e == null ? void 0 : e.find((n) => n.id === t);
1391
+ }
1392
+ async function pi() {
1393
+ return je.get("/bills").json();
1394
+ }
1395
+ async function mi(t) {
1396
+ const e = await je.get("/bills").json();
1397
+ return e == null ? void 0 : e.find((n) => n.id === t);
1398
+ }
1399
+ async function gi() {
1400
+ return await it.get("/tags").json();
1401
+ }
1402
+ async function yi(t, e) {
1403
+ return await it.url(`/tags/${t}`).put({
1404
+ value: e
1405
+ }).json();
1406
+ }
1407
+ async function vi(t, e) {
1408
+ return await it.url(`/tags/${t}/push`).put({
1409
+ value: e
1410
+ }).json();
1411
+ }
1412
+ async function wi(t) {
1413
+ const e = localStorage.getItem("__anon_id");
1414
+ if (!e)
1415
+ throw new Error("User id not found");
1416
+ return it.url("/articles/access").post({
1417
+ articleId: t.articleId,
1418
+ userId: e
1419
+ }).json();
1420
+ }
1421
+ async function bi(t) {
1422
+ const e = await wi({ articleId: t });
1423
+ return e.status !== "ok" && rt(pe.SOFT_PAYWALL, {}), e;
1424
+ }
1425
+ const Kn = "@sesamy/sesamy-js", Ct = "1.3.1";
1426
+ function ki() {
1427
+ return Ct;
1428
+ }
1429
+ function Ii(t = "sesamy") {
1430
+ const e = {
1431
+ auth: {
1432
+ getUser: Jr,
1433
+ isAuthenticated: Fr,
1434
+ loginWithRedirect: Hr,
1435
+ logout: Yr
1436
+ },
1437
+ articles: {
1438
+ access: bi
1439
+ },
1440
+ tags: {
1441
+ list: gi,
1442
+ set: yi,
1443
+ push: vi
1444
+ },
1445
+ getEntitlement: di,
1446
+ getEntitlements: li,
1447
+ getContract: fi,
1448
+ getContracts: hi,
1449
+ getBill: mi,
1450
+ getBills: pi,
1451
+ getVersion: ki
1452
+ };
1453
+ return t !== null && (window[t] = e), e;
1454
+ }
1455
+ function Gt(t, e, n, r, i) {
1456
+ for (e = e.split ? e.split(".") : e, r = 0; r < e.length; r++)
1457
+ t = t ? t[e[r]] : i;
1458
+ return t === i ? n : t;
1459
+ }
1460
+ var Fe = "undefined", Bt = "object", _i = function() {
1461
+ }, Mn = "any", Xn = "*", me = "__", Qe = typeof process < "u" ? process : {};
1462
+ Qe.env && Qe.env.NODE_ENV;
1463
+ var Y = typeof document < "u";
1464
+ Qe.versions != null && Qe.versions.node != null;
1465
+ typeof Deno < "u" && Deno.core;
1466
+ Y && window.name === "nodejs" || typeof navigator < "u" && navigator.userAgent !== void 0 && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
1467
+ function Fn(t, e) {
1468
+ return e.charAt(0)[t]() + e.slice(1);
1469
+ }
1470
+ var Si = Fn.bind(null, "toUpperCase"), Ei = Fn.bind(null, "toLowerCase");
1471
+ function Oi(t) {
1472
+ return Jn(t) ? Si("null") : typeof t == "object" ? xi(t) : Object.prototype.toString.call(t).slice(8, -1);
1473
+ }
1474
+ function et(t, e) {
1475
+ e === void 0 && (e = !0);
1476
+ var n = Oi(t);
1477
+ return e ? Ei(n) : n;
1478
+ }
1479
+ function Ke(t, e) {
1480
+ return typeof e === t;
1481
+ }
1482
+ var G = Ke.bind(null, "function"), re = Ke.bind(null, "string"), be = Ke.bind(null, "undefined"), Pi = Ke.bind(null, "boolean");
1483
+ Ke.bind(null, "symbol");
1484
+ function Jn(t) {
1485
+ return t === null;
1486
+ }
1487
+ function Ti(t) {
1488
+ return et(t) === "number" && !isNaN(t);
1489
+ }
1490
+ function Hn(t) {
1491
+ return et(t) === "array";
1492
+ }
1493
+ function X(t) {
1494
+ if (!ji(t))
1495
+ return !1;
1496
+ for (var e = t; Object.getPrototypeOf(e) !== null; )
1497
+ e = Object.getPrototypeOf(e);
1498
+ return Object.getPrototypeOf(t) === e;
1499
+ }
1500
+ function ji(t) {
1501
+ return t && (typeof t == "object" || t !== null);
1502
+ }
1503
+ function xi(t) {
1504
+ return G(t.constructor) ? t.constructor.name : null;
1505
+ }
1506
+ function Ci(t) {
1507
+ return t instanceof Error || re(t.message) && t.constructor && Ti(t.constructor.stackTraceLimit);
1508
+ }
1509
+ function Vn(t, e) {
1510
+ if (typeof e != "object" || Jn(e))
1511
+ return !1;
1512
+ if (e instanceof t)
1513
+ return !0;
1514
+ var n = et(new t(""));
1515
+ if (Ci(e))
1516
+ for (; e; ) {
1517
+ if (et(e) === n)
1518
+ return !0;
1519
+ e = Object.getPrototypeOf(e);
1520
+ }
1521
+ return !1;
1522
+ }
1523
+ Vn.bind(null, TypeError);
1524
+ Vn.bind(null, SyntaxError);
1525
+ function ot(t, e) {
1526
+ var n = t instanceof Element || t instanceof HTMLDocument;
1527
+ return n && e ? $i(t, e) : n;
1528
+ }
1529
+ function $i(t, e) {
1530
+ return e === void 0 && (e = ""), t && t.nodeName === e.toUpperCase();
1531
+ }
1532
+ function at(t) {
1533
+ var e = [].slice.call(arguments, 1);
1534
+ return function() {
1535
+ return t.apply(void 0, [].slice.call(arguments).concat(e));
1536
+ };
1537
+ }
1538
+ at(ot, "form");
1539
+ at(ot, "button");
1540
+ at(ot, "input");
1541
+ at(ot, "select");
1542
+ function Ai(t) {
1543
+ return t ? Hn(t) ? t : [t] : [];
1544
+ }
1545
+ function qt(t) {
1546
+ try {
1547
+ return decodeURIComponent(t.replace(/\+/g, " "));
1548
+ } catch {
1549
+ return null;
1550
+ }
1551
+ }
1552
+ function zi() {
1553
+ if (Y) {
1554
+ var t = navigator, e = t.languages;
1555
+ return t.userLanguage || (e && e.length ? e[0] : t.language);
1556
+ }
1557
+ }
1558
+ function Ni() {
1559
+ try {
1560
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
1561
+ } catch {
1562
+ }
1563
+ }
1564
+ function Di(t) {
1565
+ return function(e) {
1566
+ for (var n, r = /* @__PURE__ */ Object.create(null), i = /([^&=]+)=?([^&]*)/g; n = i.exec(e); ) {
1567
+ var o = qt(n[1]), a = qt(n[2]);
1568
+ o.substring(o.length - 2) === "[]" ? (r[o = o.substring(0, o.length - 2)] || (r[o] = [])).push(a) : r[o] = a === "" || a;
1569
+ }
1570
+ for (var s in r) {
1571
+ var m = s.split("[");
1572
+ m.length > 1 && (Li(r, m.map(function(p) {
1573
+ return p.replace(/[?[\]\\ ]/g, "");
1574
+ }), r[s]), delete r[s]);
1575
+ }
1576
+ return r;
1577
+ }(function(e) {
1578
+ if (e) {
1579
+ var n = e.match(/\?(.*)/);
1580
+ return n && n[1] ? n[1].split("#")[0] : "";
1581
+ }
1582
+ return Y && window.location.search.substring(1);
1583
+ }(t));
1584
+ }
1585
+ function Li(t, e, n) {
1586
+ for (var r = e.length - 1, i = 0; i < r; ++i) {
1587
+ var o = e[i];
1588
+ if (o === "__proto__" || o === "constructor")
1589
+ break;
1590
+ o in t || (t[o] = {}), t = t[o];
1591
+ }
1592
+ t[e[r]] = n;
1593
+ }
1594
+ function st() {
1595
+ for (var t = "", e = 0, n = 4294967295 * Math.random() | 0; e++ < 36; ) {
1596
+ var r = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[e - 1], i = 15 & n;
1597
+ t += r == "-" || r == "4" ? r : (r == "x" ? i : 3 & i | 8).toString(16), n = e % 8 == 0 ? 4294967295 * Math.random() | 0 : n >> 4;
1598
+ }
1599
+ return t;
1600
+ }
1601
+ var Le = "global", Oe = me + "global" + me, Pe = typeof self === Bt && self.self === self && self || typeof global === Bt && global.global === global && global || void 0;
1602
+ function ge(t) {
1603
+ return Pe[Oe][t];
1604
+ }
1605
+ function ye(t, e) {
1606
+ return Pe[Oe][t] = e;
1607
+ }
1608
+ function xe(t) {
1609
+ delete Pe[Oe][t];
1610
+ }
1611
+ function Ce(t, e, n) {
1612
+ var r;
1613
+ try {
1614
+ if ($t(t)) {
1615
+ var i = window[t];
1616
+ r = i[e].bind(i);
1617
+ }
1618
+ } catch {
1619
+ }
1620
+ return r || n;
1621
+ }
1622
+ Pe[Oe] || (Pe[Oe] = {});
1623
+ var Je = {};
1624
+ function $t(t) {
1625
+ if (typeof Je[t] !== Fe)
1626
+ return Je[t];
1627
+ try {
1628
+ var e = window[t];
1629
+ e.setItem(Fe, Fe), e.removeItem(Fe);
1630
+ } catch {
1631
+ return Je[t] = !1;
1632
+ }
1633
+ return Je[t] = !0;
1634
+ }
1635
+ function O() {
1636
+ return O = Object.assign || function(t) {
1637
+ for (var e = 1; e < arguments.length; e++) {
1638
+ var n = arguments[e];
1639
+ for (var r in n)
1640
+ Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
1641
+ }
1642
+ return t;
1643
+ }, O.apply(this, arguments);
1644
+ }
1645
+ var ne = "function", ee = "undefined", Ui = "@@redux/" + Math.random().toString(36), Qt = /* @__PURE__ */ function() {
1646
+ return typeof Symbol === ne && Symbol.observable || "@@observable";
1647
+ }(), He = " != " + ne;
1648
+ function Yn(t, e, n) {
1649
+ var r;
1650
+ if (typeof e === ne && typeof n === ee && (n = e, e = void 0), typeof n !== ee) {
1651
+ if (typeof n !== ne)
1652
+ throw new Error("enhancer" + He);
1653
+ return n(Yn)(t, e);
1654
+ }
1655
+ if (typeof t !== ne)
1656
+ throw new Error("reducer" + He);
1657
+ var i = t, o = e, a = [], s = a, m = !1;
1658
+ function p() {
1659
+ s === a && (s = a.slice());
1660
+ }
1661
+ function u() {
1662
+ return o;
1663
+ }
1664
+ function c(d) {
1665
+ if (typeof d !== ne)
1666
+ throw new Error("Listener" + He);
1667
+ var w = !0;
1668
+ return p(), s.push(d), function() {
1669
+ if (w) {
1670
+ w = !1, p();
1671
+ var k = s.indexOf(d);
1672
+ s.splice(k, 1);
1673
+ }
1674
+ };
1675
+ }
1676
+ function h(d) {
1677
+ if (!X(d))
1678
+ throw new Error("Act != obj");
1679
+ if (typeof d.type === ee)
1680
+ throw new Error("ActType " + ee);
1681
+ if (m)
1682
+ throw new Error("Dispatch in reducer");
1683
+ try {
1684
+ m = !0, o = i(o, d);
1685
+ } finally {
1686
+ m = !1;
1687
+ }
1688
+ for (var w = a = s, k = 0; k < w.length; k++)
1689
+ (0, w[k])();
1690
+ return d;
1691
+ }
1692
+ return h({ type: "@@redux/INIT" }), (r = { dispatch: h, subscribe: c, getState: u, replaceReducer: function(d) {
1693
+ if (typeof d !== ne)
1694
+ throw new Error("next reducer" + He);
1695
+ i = d, h({ type: "@@redux/INIT" });
1696
+ } })[Qt] = function() {
1697
+ var d, w = c;
1698
+ return (d = { subscribe: function(k) {
1699
+ if (typeof k != "object")
1700
+ throw new TypeError("Observer != obj");
1701
+ function v() {
1702
+ k.next && k.next(u());
1703
+ }
1704
+ return v(), { unsubscribe: w(v) };
1705
+ } })[Qt] = function() {
1706
+ return this;
1707
+ }, d;
1708
+ }, r;
1709
+ }
1710
+ function Ri(t, e) {
1711
+ var n = e && e.type;
1712
+ return "action " + (n && n.toString() || "?") + "reducer " + t + " returns " + ee;
1713
+ }
1714
+ function Te() {
1715
+ var t = [].slice.call(arguments);
1716
+ return t.length === 0 ? function(e) {
1717
+ return e;
1718
+ } : t.length === 1 ? t[0] : t.reduce(function(e, n) {
1719
+ return function() {
1720
+ return e(n.apply(void 0, [].slice.call(arguments)));
1721
+ };
1722
+ });
1723
+ }
1724
+ function Zi() {
1725
+ var t = arguments;
1726
+ return function(e) {
1727
+ return function(n, r, i) {
1728
+ var o, a = e(n, r, i), s = a.dispatch, m = { getState: a.getState, dispatch: function(p) {
1729
+ return s(p);
1730
+ } };
1731
+ return o = [].slice.call(t).map(function(p) {
1732
+ return p(m);
1733
+ }), O({}, a, { dispatch: s = Te.apply(void 0, o)(a.dispatch) });
1734
+ };
1735
+ };
1736
+ }
1737
+ var ie = me + "anon_id", fe = me + "user_id", Ie = me + "user_traits", te = "userId", ke = "anonymousId", qe = ["bootstrap", "params", "campaign", "initializeStart", "initialize", "initializeEnd", "ready", "resetStart", "reset", "resetEnd", "pageStart", "page", "pageEnd", "pageAborted", "trackStart", "track", "trackEnd", "trackAborted", "identifyStart", "identify", "identifyEnd", "identifyAborted", "userIdChanged", "registerPlugins", "enablePlugin", "disablePlugin", "online", "offline", "setItemStart", "setItem", "setItemEnd", "setItemAborted", "removeItemStart", "removeItem", "removeItemEnd", "removeItemAborted"], Et = ["name", "EVENTS", "config", "loaded"], E = qe.reduce(function(t, e) {
1738
+ return t[e] = e, t;
1739
+ }, { registerPluginType: function(t) {
1740
+ return "registerPlugin:" + t;
1741
+ }, pluginReadyType: function(t) {
1742
+ return "ready:" + t;
1743
+ } }), en = /^utm_/, tn = /^an_prop_/, nn = /^an_trait_/;
1744
+ function Wi(t) {
1745
+ var e = t.storage.setItem;
1746
+ return function(n) {
1747
+ return function(r) {
1748
+ return function(i) {
1749
+ if (i.type === E.bootstrap) {
1750
+ var o = i.params, a = i.user, s = i.persistedUser, m = i.initialUser, p = s.userId === a.userId;
1751
+ s.anonymousId !== a.anonymousId && e(ie, a.anonymousId), p || e(fe, a.userId), m.traits && e(Ie, O({}, p && s.traits ? s.traits : {}, m.traits));
1752
+ var u = Object.keys(i.params);
1753
+ if (u.length) {
1754
+ var c = o.an_uid, h = o.an_event, d = u.reduce(function(w, k) {
1755
+ if (k.match(en) || k.match(/^(d|g)clid/)) {
1756
+ var v = k.replace(en, "");
1757
+ w.campaign[v === "campaign" ? "name" : v] = o[k];
1758
+ }
1759
+ return k.match(tn) && (w.props[k.replace(tn, "")] = o[k]), k.match(nn) && (w.traits[k.replace(nn, "")] = o[k]), w;
1760
+ }, { campaign: {}, props: {}, traits: {} });
1761
+ n.dispatch(O({ type: E.params, raw: o }, d, c ? { userId: c } : {})), c && setTimeout(function() {
1762
+ return t.identify(c, d.traits);
1763
+ }, 0), h && setTimeout(function() {
1764
+ return t.track(h, d.props);
1765
+ }, 0), Object.keys(d.campaign).length && n.dispatch({ type: E.campaign, campaign: d.campaign });
1766
+ }
1767
+ }
1768
+ return r(i);
1769
+ };
1770
+ };
1771
+ };
1772
+ }
1773
+ function Ki(t) {
1774
+ return function(e, n) {
1775
+ if (e === void 0 && (e = {}), n === void 0 && (n = {}), n.type === E.setItemEnd) {
1776
+ if (n.key === ie)
1777
+ return O({}, e, { anonymousId: n.value });
1778
+ if (n.key === fe)
1779
+ return O({}, e, { userId: n.value });
1780
+ }
1781
+ switch (n.type) {
1782
+ case E.identify:
1783
+ return Object.assign({}, e, { userId: n.userId, traits: O({}, e.traits, n.traits) });
1784
+ case E.reset:
1785
+ return [fe, ie, Ie].forEach(function(r) {
1786
+ t.removeItem(r);
1787
+ }), Object.assign({}, e, { userId: null, anonymousId: null, traits: {} });
1788
+ default:
1789
+ return e;
1790
+ }
1791
+ };
1792
+ }
1793
+ function rn(t) {
1794
+ return { userId: t.getItem(fe), anonymousId: t.getItem(ie), traits: t.getItem(Ie) };
1795
+ }
1796
+ var Ot = function(t) {
1797
+ return me + "TEMP" + me + t;
1798
+ };
1799
+ function Mi(t) {
1800
+ var e = t.storage, n = e.setItem, r = e.removeItem, i = e.getItem;
1801
+ return function(o) {
1802
+ return function(a) {
1803
+ return function(s) {
1804
+ var m = s.userId, p = s.traits, u = s.options;
1805
+ if (s.type === E.reset && ([fe, Ie, ie].forEach(function(d) {
1806
+ r(d);
1807
+ }), [te, ke, "traits"].forEach(function(d) {
1808
+ xe(Ot(d));
1809
+ })), s.type === E.identify) {
1810
+ i(ie) || n(ie, st());
1811
+ var c = i(fe), h = i(Ie) || {};
1812
+ c && c !== m && o.dispatch({ type: E.userIdChanged, old: { userId: c, traits: h }, new: { userId: m, traits: p }, options: u }), m && n(fe, m), p && n(Ie, O({}, h, p));
1813
+ }
1814
+ return a(s);
1815
+ };
1816
+ };
1817
+ };
1818
+ }
1819
+ var De = {};
1820
+ function on(t, e) {
1821
+ De[t] && G(De[t]) && (De[t](e), delete De[t]);
1822
+ }
1823
+ function Gn(t, e, n) {
1824
+ return new Promise(function(r, i) {
1825
+ return e() ? r(t) : n < 1 ? i(O({}, t, { queue: !0 })) : new Promise(function(o) {
1826
+ return setTimeout(o, 10);
1827
+ }).then(function(o) {
1828
+ return Gn(t, e, n - 10).then(r, i);
1829
+ });
1830
+ });
1831
+ }
1832
+ function Xi(t) {
1833
+ return { abort: t };
1834
+ }
1835
+ function Bn(t, e, n) {
1836
+ var r = {}, i = e(), o = t.getState(), a = o.plugins, s = o.queue, m = o.user;
1837
+ if (!o.context.offline && s && s.actions && s.actions.length) {
1838
+ var p = s.actions.reduce(function(c, h, d) {
1839
+ return a[h.plugin].loaded ? (c.process.push(h), c.processIndex.push(d)) : (c.requeue.push(h), c.requeueIndex.push(d)), c;
1840
+ }, { processIndex: [], process: [], requeue: [], requeueIndex: [] });
1841
+ if (p.processIndex && p.processIndex.length) {
1842
+ p.processIndex.forEach(function(c) {
1843
+ var h = s.actions[c], d = h.plugin, w = h.payload.type, k = i[d][w];
1844
+ if (k && G(k)) {
1845
+ var v, I = function(l, b) {
1846
+ return l === void 0 && (l = {}), b === void 0 && (b = {}), [te, ke].reduce(function(T, P) {
1847
+ return l.hasOwnProperty(P) && b[P] && b[P] !== l[P] && (T[P] = b[P]), T;
1848
+ }, l);
1849
+ }(h.payload, m), _ = r[I.meta.rid];
1850
+ if (!_ && (v = k({ payload: I, config: a[d].config, instance: n, abort: Xi })) && X(v) && v.abort)
1851
+ return void (r[I.meta.rid] = !0);
1852
+ if (!_) {
1853
+ var y = w + ":" + d;
1854
+ t.dispatch(O({}, I, { type: y, _: { called: y, from: "queueDrain" } }));
1855
+ }
1856
+ }
1857
+ });
1858
+ var u = s.actions.filter(function(c, h) {
1859
+ return !~p.processIndex.indexOf(h);
1860
+ });
1861
+ s.actions = u;
1862
+ }
1863
+ }
1864
+ }
1865
+ var mt = function(t) {
1866
+ var e = t.data, n = t.action, r = t.instance, i = t.state, o = t.allPlugins, a = t.allMatches, s = t.store, m = t.EVENTS;
1867
+ try {
1868
+ var p = i.plugins, u = i.context, c = n.type, h = c.match(_e), d = e.exact.map(function(v) {
1869
+ return v.pluginName;
1870
+ });
1871
+ h && (d = a.during.map(function(v) {
1872
+ return v.pluginName;
1873
+ }));
1874
+ var w = /* @__PURE__ */ function(v, I) {
1875
+ return function(_, y, l) {
1876
+ var b = y.config, T = y.name, P = T + "." + _.type;
1877
+ l && (P = l.event);
1878
+ var x = _.type.match(_e) ? /* @__PURE__ */ function(L, D, J, U, H) {
1879
+ return function(Z, j) {
1880
+ var K = U ? U.name : L, M = j && We(j) ? j : J;
1881
+ if (U && (!(M = j && We(j) ? j : [L]).includes(L) || M.length !== 1))
1882
+ throw new Error("Method " + D + " can only abort " + L + " plugin. " + JSON.stringify(M) + " input valid");
1883
+ return O({}, H, { abort: { reason: Z, plugins: M, caller: D, _: K } });
1884
+ };
1885
+ }(T, P, I, l, _) : /* @__PURE__ */ function(L, D) {
1886
+ return function() {
1887
+ throw new Error(L.type + " action not cancellable. Remove abort in " + D);
1888
+ };
1889
+ }(_, P);
1890
+ return { payload: Fi(_), instance: v, config: b || {}, abort: x };
1891
+ };
1892
+ }(r, d), k = e.exact.reduce(function(v, I) {
1893
+ var _ = I.pluginName, y = I.methodName, l = !1;
1894
+ return y.match(/^initialize/) || y.match(/^reset/) || (l = !p[_].loaded), u.offline && y.match(/^(page|track|identify)/) && (l = !0), v["" + _] = l, v;
1895
+ }, {});
1896
+ return Promise.resolve(e.exact.reduce(function(v, I, _) {
1897
+ try {
1898
+ var y = I.pluginName;
1899
+ return Promise.resolve(v).then(function(l) {
1900
+ function b() {
1901
+ return Promise.resolve(l);
1902
+ }
1903
+ var T = function() {
1904
+ if (e.namespaced && e.namespaced[y])
1905
+ return Promise.resolve(e.namespaced[y].reduce(function(P, x, L) {
1906
+ try {
1907
+ return Promise.resolve(P).then(function(D) {
1908
+ return x.method && G(x.method) ? (function(Z, j) {
1909
+ var K = hn(Z);
1910
+ if (K && K.name === j) {
1911
+ var M = hn(K.method);
1912
+ throw new Error([j + " plugin is calling method " + Z, "Plugins cant call self", "Use " + K.method + " " + (M ? "or " + M.method : "") + " in " + j + " plugin insteadof " + Z].join(`
1913
+ `));
1914
+ }
1915
+ }(x.methodName, x.pluginName), Promise.resolve(x.method({ payload: D, instance: r, abort: (J = D, U = y, H = x.pluginName, function(Z, j) {
1916
+ return O({}, J, { abort: { reason: Z, plugins: j || [U], caller: c, from: H || U } });
1917
+ }), config: cn(x.pluginName, p, o), plugins: p })).then(function(Z) {
1918
+ var j = X(Z) ? Z : {};
1919
+ return Promise.resolve(O({}, D, j));
1920
+ })) : D;
1921
+ var J, U, H;
1922
+ });
1923
+ } catch (D) {
1924
+ return Promise.reject(D);
1925
+ }
1926
+ }, Promise.resolve(n))).then(function(P) {
1927
+ l[y] = P;
1928
+ });
1929
+ l[y] = n;
1930
+ }();
1931
+ return T && T.then ? T.then(b) : b();
1932
+ });
1933
+ } catch (l) {
1934
+ return Promise.reject(l);
1935
+ }
1936
+ }, Promise.resolve({}))).then(function(v) {
1937
+ return Promise.resolve(e.exact.reduce(function(I, _, y) {
1938
+ try {
1939
+ var l = e.exact.length === y + 1, b = _.pluginName, T = o[b];
1940
+ return Promise.resolve(I).then(function(P) {
1941
+ var x = v[b] ? v[b] : {};
1942
+ if (h && (x = P), yt(x, b))
1943
+ return gt({ data: x, method: c, instance: r, pluginName: b, store: s }), Promise.resolve(P);
1944
+ if (yt(P, b))
1945
+ return l && gt({ data: P, method: c, instance: r, store: s }), Promise.resolve(P);
1946
+ if (k.hasOwnProperty(b) && k[b] === !0)
1947
+ return s.dispatch({ type: "queue", plugin: b, payload: x, _: { called: "queue", from: "queueMechanism" } }), Promise.resolve(P);
1948
+ var L = w(v[b], o[b]);
1949
+ return Promise.resolve(T[c]({ abort: L.abort, payload: x, instance: r, config: cn(b, p, o), plugins: p })).then(function(D) {
1950
+ var J = X(D) ? D : {}, U = O({}, P, J), H = v[b];
1951
+ if (yt(H, b))
1952
+ gt({ data: H, method: c, instance: r, pluginName: b, store: s });
1953
+ else {
1954
+ var Z = c + ":" + b;
1955
+ (Z.match(/:/g) || []).length < 2 && !c.match(an) && !c.match(sn) && r.dispatch(O({}, h ? U : x, { type: Z, _: { called: Z, from: "submethod" } }));
1956
+ }
1957
+ return Promise.resolve(U);
1958
+ });
1959
+ });
1960
+ } catch (P) {
1961
+ return Promise.reject(P);
1962
+ }
1963
+ }, Promise.resolve(n))).then(function(I) {
1964
+ if (!(c.match(_e) || c.match(/^registerPlugin/) || c.match(sn) || c.match(an) || c.match(/^params/) || c.match(/^userIdChanged/))) {
1965
+ if (m.plugins.includes(c), I._ && I._.originalAction === c)
1966
+ return I;
1967
+ var _ = O({}, I, { _: { originalAction: I.type, called: I.type, from: "engineEnd" } });
1968
+ qn(I, e.exact.length) && !c.match(/End$/) && (_ = O({}, _, { type: I.type + "Aborted" })), s.dispatch(_);
1969
+ }
1970
+ return I;
1971
+ });
1972
+ });
1973
+ } catch (v) {
1974
+ return Promise.reject(v);
1975
+ }
1976
+ }, _e = /Start$/, an = /^bootstrap/, sn = /^ready/;
1977
+ function gt(t) {
1978
+ var e = t.pluginName, n = t.method + "Aborted" + (e ? ":" + e : "");
1979
+ t.store.dispatch(O({}, t.data, { type: n, _: { called: n, from: "abort" } }));
1980
+ }
1981
+ function cn(t, e, n) {
1982
+ var r = e[t] || n[t];
1983
+ return r && r.config ? r.config : {};
1984
+ }
1985
+ function un(t, e) {
1986
+ return e.reduce(function(n, r) {
1987
+ return r[t] ? n.concat({ methodName: t, pluginName: r.name, method: r[t] }) : n;
1988
+ }, []);
1989
+ }
1990
+ function ln(t, e) {
1991
+ var n = t.replace(_e, ""), r = e ? ":" + e : "";
1992
+ return ["" + t + r, "" + n + r, n + "End" + r];
1993
+ }
1994
+ function yt(t, e) {
1995
+ var n = t.abort;
1996
+ return !!n && (n === !0 || dn(n, e) || n && dn(n.plugins, e));
1997
+ }
1998
+ function qn(t, e) {
1999
+ var n = t.abort;
2000
+ if (!n)
2001
+ return !1;
2002
+ if (n === !0 || re(n))
2003
+ return !0;
2004
+ var r = n.plugins;
2005
+ return We(n) && n.length === e || We(r) && r.length === e;
2006
+ }
2007
+ function We(t) {
2008
+ return Array.isArray(t);
2009
+ }
2010
+ function dn(t, e) {
2011
+ return !(!t || !We(t)) && t.includes(e);
2012
+ }
2013
+ function hn(t) {
2014
+ var e = t.match(/(.*):(.*)/);
2015
+ return !!e && { method: e[1], name: e[2] };
2016
+ }
2017
+ function Fi(t) {
2018
+ return Object.keys(t).reduce(function(e, n) {
2019
+ return n === "type" || (e[n] = X(t[n]) ? Object.assign({}, t[n]) : t[n]), e;
2020
+ }, {});
2021
+ }
2022
+ function Ji(t, e, n) {
2023
+ var r = {};
2024
+ return function(i) {
2025
+ return function(o) {
2026
+ return function(a) {
2027
+ try {
2028
+ var s, m = function(l) {
2029
+ return s ? l : o(c);
2030
+ }, p = a.type, u = a.plugins, c = a;
2031
+ if (a.abort)
2032
+ return Promise.resolve(o(a));
2033
+ if (p === E.enablePlugin && i.dispatch({ type: E.initializeStart, plugins: u, disabled: [], fromEnable: !0, meta: a.meta }), p === E.disablePlugin && setTimeout(function() {
2034
+ return on(a.meta.rid, { payload: a });
2035
+ }, 0), p === E.initializeEnd) {
2036
+ var h = e(), d = Object.keys(h), w = d.filter(function(l) {
2037
+ return u.includes(l);
2038
+ }).map(function(l) {
2039
+ return h[l];
2040
+ }), k = [], v = [], I = a.disabled, _ = w.map(function(l) {
2041
+ var b = l.loaded, T = l.name, P = l.config;
2042
+ return Gn(l, function() {
2043
+ return b({ config: P });
2044
+ }, 1e4).then(function(x) {
2045
+ return r[T] || (i.dispatch({ type: E.pluginReadyType(T), name: T, events: Object.keys(l).filter(function(L) {
2046
+ return !Et.includes(L);
2047
+ }) }), r[T] = !0), k = k.concat(T), l;
2048
+ }).catch(function(x) {
2049
+ if (x instanceof Error)
2050
+ throw new Error(x);
2051
+ return v = v.concat(x.name), x;
2052
+ });
2053
+ });
2054
+ Promise.all(_).then(function(l) {
2055
+ var b = { plugins: k, failed: v, disabled: I };
2056
+ setTimeout(function() {
2057
+ d.length === _.length + I.length && i.dispatch(O({}, { type: E.ready }, b));
2058
+ }, 0);
2059
+ });
2060
+ }
2061
+ var y = function() {
2062
+ if (p !== E.bootstrap)
2063
+ return /^ready:([^:]*)$/.test(p) && setTimeout(function() {
2064
+ return Bn(i, e, t);
2065
+ }, 0), Promise.resolve(function(l, b, T, P, x) {
2066
+ try {
2067
+ var L = G(b) ? b() : b, D = l.type, J = D.replace(_e, "");
2068
+ if (l._ && l._.called)
2069
+ return Promise.resolve(l);
2070
+ var U = T.getState(), H = (K = L, (M = U.plugins) === void 0 && (M = {}), ($e = l.options) === void 0 && ($e = {}), Object.keys(K).filter(function(f) {
2071
+ var g = $e.plugins || {};
2072
+ return Pi(g[f]) ? g[f] : g.all !== !1 && (!M[f] || M[f].enabled !== !1);
2073
+ }).map(function(f) {
2074
+ return K[f];
2075
+ }));
2076
+ D === E.initializeStart && l.fromEnable && (H = Object.keys(U.plugins).filter(function(f) {
2077
+ var g = U.plugins[f];
2078
+ return l.plugins.includes(f) && !g.initialized;
2079
+ }).map(function(f) {
2080
+ return L[f];
2081
+ }));
2082
+ var Z = H.map(function(f) {
2083
+ return f.name;
2084
+ }), j = function(f, g, S) {
2085
+ var C = ln(f).map(function($) {
2086
+ return un($, g);
2087
+ });
2088
+ return g.reduce(function($, A) {
2089
+ var W = A.name, N = ln(f, W).map(function(Ae) {
2090
+ return un(Ae, g);
2091
+ }), R = N[0], z = N[1], q = N[2];
2092
+ return R.length && ($.beforeNS[W] = R), z.length && ($.duringNS[W] = z), q.length && ($.afterNS[W] = q), $;
2093
+ }, { before: C[0], beforeNS: {}, during: C[1], duringNS: {}, after: C[2], afterNS: {} });
2094
+ }(D, H);
2095
+ return Promise.resolve(mt({ action: l, data: { exact: j.before, namespaced: j.beforeNS }, state: U, allPlugins: L, allMatches: j, instance: T, store: P, EVENTS: x })).then(function(f) {
2096
+ function g() {
2097
+ var $ = function() {
2098
+ if (D.match(_e))
2099
+ return Promise.resolve(mt({ action: O({}, S, { type: J + "End" }), data: { exact: j.after, namespaced: j.afterNS }, state: U, allPlugins: L, allMatches: j, instance: T, store: P, EVENTS: x })).then(function(A) {
2100
+ A.meta && A.meta.hasCallback && on(A.meta.rid, { payload: A });
2101
+ });
2102
+ }();
2103
+ return $ && $.then ? $.then(function() {
2104
+ return f;
2105
+ }) : f;
2106
+ }
2107
+ if (qn(f, Z.length))
2108
+ return f;
2109
+ var S, C = function() {
2110
+ if (D !== J)
2111
+ return Promise.resolve(mt({ action: O({}, f, { type: J }), data: { exact: j.during, namespaced: j.duringNS }, state: U, allPlugins: L, allMatches: j, instance: T, store: P, EVENTS: x })).then(function($) {
2112
+ S = $;
2113
+ });
2114
+ S = f;
2115
+ }();
2116
+ return C && C.then ? C.then(g) : g();
2117
+ });
2118
+ } catch (f) {
2119
+ return Promise.reject(f);
2120
+ }
2121
+ var K, M, $e;
2122
+ }(a, e, t, i, n)).then(function(l) {
2123
+ return s = 1, o(l);
2124
+ });
2125
+ }();
2126
+ return Promise.resolve(y && y.then ? y.then(m) : m(y));
2127
+ } catch (l) {
2128
+ return Promise.reject(l);
2129
+ }
2130
+ };
2131
+ };
2132
+ };
2133
+ }
2134
+ function Hi(t) {
2135
+ return function(e) {
2136
+ return function(n) {
2137
+ return function(r) {
2138
+ var i = r.type, o = r.key, a = r.value, s = r.options;
2139
+ if (i === E.setItem || i === E.removeItem) {
2140
+ if (r.abort)
2141
+ return n(r);
2142
+ i === E.setItem ? t.setItem(o, a, s) : t.removeItem(o, s);
2143
+ }
2144
+ return n(r);
2145
+ };
2146
+ };
2147
+ };
2148
+ }
2149
+ var Vi = function() {
2150
+ var t = this;
2151
+ this.before = [], this.after = [], this.addMiddleware = function(e, n) {
2152
+ t[n] = t[n].concat(e);
2153
+ }, this.removeMiddleware = function(e, n) {
2154
+ var r = t[n].findIndex(function(i) {
2155
+ return i === e;
2156
+ });
2157
+ r !== -1 && (t[n] = [].concat(t[n].slice(0, r), t[n].slice(r + 1)));
2158
+ }, this.dynamicMiddlewares = function(e) {
2159
+ return function(n) {
2160
+ return function(r) {
2161
+ return function(i) {
2162
+ var o = { getState: n.getState, dispatch: function(s) {
2163
+ return n.dispatch(s);
2164
+ } }, a = t[e].map(function(s) {
2165
+ return s(o);
2166
+ });
2167
+ return Te.apply(void 0, a)(r)(i);
2168
+ };
2169
+ };
2170
+ };
2171
+ };
2172
+ };
2173
+ function Yi(t) {
2174
+ return function(e, n) {
2175
+ e === void 0 && (e = {});
2176
+ var r = {};
2177
+ if (n.type === "initialize:aborted")
2178
+ return e;
2179
+ if (/^registerPlugin:([^:]*)$/.test(n.type)) {
2180
+ var i = fn(n.type, "registerPlugin"), o = t()[i];
2181
+ if (!o || !i)
2182
+ return e;
2183
+ var a = n.enabled, s = o.config;
2184
+ return r[i] = { enabled: a, initialized: !!a && !o.initialize, loaded: !!a && !!o.loaded({ config: s }), config: s }, O({}, e, r);
2185
+ }
2186
+ if (/^initialize:([^:]*)$/.test(n.type)) {
2187
+ var m = fn(n.type, E.initialize), p = t()[m];
2188
+ return p && m ? (r[m] = O({}, e[m], { initialized: !0, loaded: !!p.loaded({ config: p.config }) }), O({}, e, r)) : e;
2189
+ }
2190
+ if (/^ready:([^:]*)$/.test(n.type))
2191
+ return r[n.name] = O({}, e[n.name], { loaded: !0 }), O({}, e, r);
2192
+ switch (n.type) {
2193
+ case E.disablePlugin:
2194
+ return O({}, e, pn(n.plugins, !1, e));
2195
+ case E.enablePlugin:
2196
+ return O({}, e, pn(n.plugins, !0, e));
2197
+ default:
2198
+ return e;
2199
+ }
2200
+ };
2201
+ }
2202
+ function fn(t, e) {
2203
+ return t.substring(e.length + 1, t.length);
2204
+ }
2205
+ function pn(t, e, n) {
2206
+ return t.reduce(function(r, i) {
2207
+ return r[i] = O({}, n[i], { enabled: e }), r;
2208
+ }, n);
2209
+ }
2210
+ function Qn(t) {
2211
+ try {
2212
+ return JSON.parse(JSON.stringify(t));
2213
+ } catch {
2214
+ }
2215
+ return t;
2216
+ }
2217
+ var Gi = { last: {}, history: [] };
2218
+ function Bi(t, e) {
2219
+ t === void 0 && (t = Gi);
2220
+ var n = e.options, r = e.meta;
2221
+ if (e.type === E.track) {
2222
+ var i = Qn(O({ event: e.event, properties: e.properties }, Object.keys(n).length && { options: n }, { meta: r }));
2223
+ return O({}, t, { last: i, history: t.history.concat(i) });
2224
+ }
2225
+ return t;
2226
+ }
2227
+ var qi = { actions: [] };
2228
+ function Qi(t, e) {
2229
+ t === void 0 && (t = qi);
2230
+ var n = e.payload;
2231
+ switch (e.type) {
2232
+ case "queue":
2233
+ var r;
2234
+ return r = n && n.type && n.type === E.identify ? [e].concat(t.actions) : t.actions.concat(e), O({}, t, { actions: r });
2235
+ case "dequeue":
2236
+ return [];
2237
+ default:
2238
+ return t;
2239
+ }
2240
+ }
2241
+ var er = /#.*$/;
2242
+ function eo(t) {
2243
+ var e = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(t);
2244
+ return "/" + (e && e[3] ? e[3].split("?")[0].replace(er, "") : "");
2245
+ }
2246
+ var tr, nr, rr, ir, to = function(t) {
2247
+ if (t === void 0 && (t = {}), !Y)
2248
+ return t;
2249
+ var e = document, n = e.title, r = e.referrer, i = window, o = i.location, a = i.innerWidth, s = i.innerHeight, m = o.hash, p = o.search, u = function(h) {
2250
+ var d = function() {
2251
+ if (Y) {
2252
+ for (var w, k = document.getElementsByTagName("link"), v = 0; w = k[v]; v++)
2253
+ if (w.getAttribute("rel") === "canonical")
2254
+ return w.getAttribute("href");
2255
+ }
2256
+ }();
2257
+ return d ? d.match(/\?/) ? d : d + h : window.location.href.replace(er, "");
2258
+ }(p), c = { title: n, url: u, path: eo(u), hash: m, search: p, width: a, height: s };
2259
+ return r && r !== "" && (c.referrer = r), O({}, c, t);
2260
+ }, no = { last: {}, history: [] };
2261
+ function ro(t, e) {
2262
+ t === void 0 && (t = no);
2263
+ var n = e.options;
2264
+ if (e.type === E.page) {
2265
+ var r = Qn(O({ properties: e.properties, meta: e.meta }, Object.keys(n).length && { options: n }));
2266
+ return O({}, t, { last: r, history: t.history.concat(r) });
2267
+ }
2268
+ return t;
2269
+ }
2270
+ tr = function() {
2271
+ if (!Y)
2272
+ return !1;
2273
+ var t = navigator.appVersion;
2274
+ return ~t.indexOf("Win") ? "Windows" : ~t.indexOf("Mac") ? "MacOS" : ~t.indexOf("X11") ? "UNIX" : ~t.indexOf("Linux") ? "Linux" : "Unknown OS";
2275
+ }(), nr = Y ? document.referrer : null, rr = zi(), ir = Ni();
2276
+ var mn = { initialized: !1, sessionId: st(), app: null, version: null, debug: !1, offline: !!Y && !navigator.onLine, os: { name: tr }, userAgent: Y ? navigator.userAgent : "node", library: { name: "analytics", version: "0.12.7" }, timezone: ir, locale: rr, campaign: {}, referrer: nr };
2277
+ function io(t, e) {
2278
+ t === void 0 && (t = mn);
2279
+ var n = t.initialized, r = e.campaign;
2280
+ switch (e.type) {
2281
+ case E.campaign:
2282
+ return O({}, t, { campaign: r });
2283
+ case E.offline:
2284
+ return O({}, t, { offline: !0 });
2285
+ case E.online:
2286
+ return O({}, t, { offline: !1 });
2287
+ default:
2288
+ return n ? t : O({}, mn, t, { initialized: !0 });
2289
+ }
2290
+ }
2291
+ var oo = ["plugins", "reducers", "storage"];
2292
+ function ao(t, e, n) {
2293
+ if (Y) {
2294
+ var r = window[(n ? "add" : "remove") + "EventListener"];
2295
+ t.split(" ").forEach(function(i) {
2296
+ r(i, e);
2297
+ });
2298
+ }
2299
+ }
2300
+ function so(t) {
2301
+ var e = ao.bind(null, "online offline", function(n) {
2302
+ return Promise.resolve(!navigator.onLine).then(t);
2303
+ });
2304
+ return e(!0), function(n) {
2305
+ return e(!1);
2306
+ };
2307
+ }
2308
+ function or() {
2309
+ return ye("analytics", []), function(t) {
2310
+ return function(e, n, r) {
2311
+ var i = t(e, n, r), o = i.dispatch;
2312
+ return Object.assign(i, { dispatch: function(a) {
2313
+ return Pe[Oe].analytics.push(a.action || a), o(a);
2314
+ } });
2315
+ };
2316
+ };
2317
+ }
2318
+ function gn(t) {
2319
+ return function() {
2320
+ return Te(Te.apply(null, arguments), or());
2321
+ };
2322
+ }
2323
+ function vt(t) {
2324
+ return t ? Hn(t) ? t : [t] : [];
2325
+ }
2326
+ function yn(t, e, n) {
2327
+ t === void 0 && (t = {});
2328
+ var r, i, o = st();
2329
+ return e && (De[o] = (r = e, i = function(a) {
2330
+ for (var s, m = a || Array.prototype.slice.call(arguments), p = 0; p < m.length; p++)
2331
+ if (G(m[p])) {
2332
+ s = m[p];
2333
+ break;
2334
+ }
2335
+ return s;
2336
+ }(n), function(a) {
2337
+ i && i(a), r(a);
2338
+ })), O({}, t, { rid: o, ts: (/* @__PURE__ */ new Date()).getTime() }, e ? { hasCallback: !0 } : {});
2339
+ }
2340
+ function co(t) {
2341
+ t === void 0 && (t = {});
2342
+ var e = t.reducers || {}, n = t.initialUser || {}, r = (t.plugins || []).reduce(function(f, g) {
2343
+ if (G(g))
2344
+ return f.middlewares = f.middlewares.concat(g), f;
2345
+ if (g.NAMESPACE && (g.name = g.NAMESPACE), !g.name)
2346
+ throw new Error("https://lytics.dev/errors/1");
2347
+ g.config || (g.config = {});
2348
+ var S = g.EVENTS ? Object.keys(g.EVENTS).map(function(A) {
2349
+ return g.EVENTS[A];
2350
+ }) : [];
2351
+ f.pluginEnabled[g.name] = !(g.enabled === !1 || g.config.enabled === !1), delete g.enabled, g.methods && (f.methods[g.name] = Object.keys(g.methods).reduce(function(A, W) {
2352
+ var N;
2353
+ return A[W] = (N = g.methods[W], function() {
2354
+ for (var R = Array.prototype.slice.call(arguments), z = new Array(N.length), q = 0; q < R.length; q++)
2355
+ z[q] = R[q];
2356
+ return z[z.length] = b, N.apply({ instance: b }, z);
2357
+ }), A;
2358
+ }, {}), delete g.methods);
2359
+ var C = Object.keys(g).concat(S), $ = new Set(f.events.concat(C));
2360
+ if (f.events = Array.from($), f.pluginsArray = f.pluginsArray.concat(g), f.plugins[g.name])
2361
+ throw new Error(g.name + "AlreadyLoaded");
2362
+ return f.plugins[g.name] = g, f.plugins[g.name].loaded || (f.plugins[g.name].loaded = function() {
2363
+ return !0;
2364
+ }), f;
2365
+ }, { plugins: {}, pluginEnabled: {}, methods: {}, pluginsArray: [], middlewares: [], events: [] }), i = t.storage ? t.storage : { getItem: ge, setItem: ye, removeItem: xe }, o = /* @__PURE__ */ function(f) {
2366
+ return function(g, S, C) {
2367
+ return S.getState("user")[g] || (C && X(C) && C[g] ? C[g] : rn(f)[g] || ge(Ot(g)) || null);
2368
+ };
2369
+ }(i), a = r.plugins, s = r.events.filter(function(f) {
2370
+ return !Et.includes(f);
2371
+ }).sort(), m = new Set(s.concat(qe).filter(function(f) {
2372
+ return !Et.includes(f);
2373
+ })), p = Array.from(m).sort(), u = function() {
2374
+ return a;
2375
+ }, c = new Vi(), h = c.addMiddleware, d = c.removeMiddleware, w = c.dynamicMiddlewares, k = function() {
2376
+ throw new Error("Abort disabled inListener");
2377
+ }, v = Di(), I = rn(i), _ = O({}, I, n, v.an_uid ? { userId: v.an_uid } : {}, v.an_aid ? { anonymousId: v.an_aid } : {});
2378
+ _.anonymousId || (_.anonymousId = st());
2379
+ var y = O({ enable: function(f, g) {
2380
+ return new Promise(function(S) {
2381
+ j.dispatch({ type: E.enablePlugin, plugins: vt(f), _: { originalAction: E.enablePlugin } }, S, [g]);
2382
+ });
2383
+ }, disable: function(f, g) {
2384
+ return new Promise(function(S) {
2385
+ j.dispatch({ type: E.disablePlugin, plugins: vt(f), _: { originalAction: E.disablePlugin } }, S, [g]);
2386
+ });
2387
+ } }, r.methods), l = !1, b = { identify: function(f, g, S, C) {
2388
+ try {
2389
+ var $ = re(f) ? f : null, A = X(f) ? f : g, W = S || {}, N = b.user();
2390
+ ye(Ot(te), $);
2391
+ var R = $ || A.userId || o(te, b, A);
2392
+ return Promise.resolve(new Promise(function(z) {
2393
+ j.dispatch(O({ type: E.identifyStart, userId: R, traits: A || {}, options: W, anonymousId: N.anonymousId }, N.id && N.id !== $ && { previousId: N.id }), z, [g, S, C]);
2394
+ }));
2395
+ } catch (z) {
2396
+ return Promise.reject(z);
2397
+ }
2398
+ }, track: function(f, g, S, C) {
2399
+ try {
2400
+ var $ = X(f) ? f.event : f;
2401
+ if (!$ || !re($))
2402
+ throw new Error("EventMissing");
2403
+ var A = X(f) ? f : g || {}, W = X(S) ? S : {};
2404
+ return Promise.resolve(new Promise(function(N) {
2405
+ j.dispatch({ type: E.trackStart, event: $, properties: A, options: W, userId: o(te, b, g), anonymousId: o(ke, b, g) }, N, [g, S, C]);
2406
+ }));
2407
+ } catch (N) {
2408
+ return Promise.reject(N);
2409
+ }
2410
+ }, page: function(f, g, S) {
2411
+ try {
2412
+ var C = X(f) ? f : {}, $ = X(g) ? g : {};
2413
+ return Promise.resolve(new Promise(function(A) {
2414
+ j.dispatch({ type: E.pageStart, properties: to(C), options: $, userId: o(te, b, C), anonymousId: o(ke, b, C) }, A, [f, g, S]);
2415
+ }));
2416
+ } catch (A) {
2417
+ return Promise.reject(A);
2418
+ }
2419
+ }, user: function(f) {
2420
+ if (f === te || f === "id")
2421
+ return o(te, b);
2422
+ if (f === ke || f === "anonId")
2423
+ return o(ke, b);
2424
+ var g = b.getState("user");
2425
+ return f ? Gt(g, f) : g;
2426
+ }, reset: function(f) {
2427
+ return new Promise(function(g) {
2428
+ j.dispatch({ type: E.resetStart }, g, f);
2429
+ });
2430
+ }, ready: function(f) {
2431
+ return l && f({ plugins: y, instance: b }), b.on(E.ready, function(g) {
2432
+ f(g), l = !0;
2433
+ });
2434
+ }, on: function(f, g) {
2435
+ if (!f || !G(g))
2436
+ return !1;
2437
+ if (f === E.bootstrap)
2438
+ throw new Error(".on disabled for " + f);
2439
+ var S = /Start$|Start:/;
2440
+ if (f === "*") {
2441
+ var C = function(N) {
2442
+ return function(R) {
2443
+ return function(z) {
2444
+ return z.type.match(S) && g({ payload: z, instance: b, plugins: a }), R(z);
2445
+ };
2446
+ };
2447
+ }, $ = function(N) {
2448
+ return function(R) {
2449
+ return function(z) {
2450
+ return z.type.match(S) || g({ payload: z, instance: b, plugins: a }), R(z);
2451
+ };
2452
+ };
2453
+ };
2454
+ return h(C, Ve), h($, Ye), function() {
2455
+ d(C, Ve), d($, Ye);
2456
+ };
2457
+ }
2458
+ var A = f.match(S) ? Ve : Ye, W = function(N) {
2459
+ return function(R) {
2460
+ return function(z) {
2461
+ return z.type === f && g({ payload: z, instance: b, plugins: a, abort: k }), R(z);
2462
+ };
2463
+ };
2464
+ };
2465
+ return h(W, A), function() {
2466
+ return d(W, A);
2467
+ };
2468
+ }, once: function(f, g) {
2469
+ if (!f || !G(g))
2470
+ return !1;
2471
+ if (f === E.bootstrap)
2472
+ throw new Error(".once disabled for " + f);
2473
+ var S = b.on(f, function(C) {
2474
+ g({ payload: C.payload, instance: b, plugins: a, abort: k }), S();
2475
+ });
2476
+ return S;
2477
+ }, getState: function(f) {
2478
+ var g = j.getState();
2479
+ return f ? Gt(g, f) : Object.assign({}, g);
2480
+ }, dispatch: function(f) {
2481
+ var g = re(f) ? { type: f } : f;
2482
+ if (qe.includes(g.type))
2483
+ throw new Error("reserved action " + g.type);
2484
+ var S = O({}, g, { _: O({ originalAction: g.type }, f._ || {}) });
2485
+ j.dispatch(S);
2486
+ }, enablePlugin: y.enable, disablePlugin: y.disable, plugins: y, storage: { getItem: i.getItem, setItem: function(f, g, S) {
2487
+ j.dispatch({ type: E.setItemStart, key: f, value: g, options: S });
2488
+ }, removeItem: function(f, g) {
2489
+ j.dispatch({ type: E.removeItemStart, key: f, options: g });
2490
+ } }, setAnonymousId: function(f, g) {
2491
+ b.storage.setItem(ie, f, g);
2492
+ }, events: { core: qe, plugins: s } }, T = r.middlewares.concat([function(f) {
2493
+ return function(g) {
2494
+ return function(S) {
2495
+ return S.meta || (S.meta = yn()), g(S);
2496
+ };
2497
+ };
2498
+ }, w(Ve), Ji(b, u, { all: p, plugins: s }), Hi(i), Wi(b), Mi(b), w(Ye)]), P = { context: io, user: Ki(i), page: ro, track: Bi, plugins: Yi(u), queue: Qi }, x = Te, L = Te;
2499
+ if (Y && t.debug) {
2500
+ var D = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
2501
+ D && (x = D({ trace: !0, traceLimit: 25 })), L = function() {
2502
+ return arguments.length === 0 ? or() : X(typeof arguments[0]) ? gn() : gn().apply(null, arguments);
2503
+ };
2504
+ }
2505
+ var J, U = function(f) {
2506
+ return Object.keys(f).reduce(function(g, S) {
2507
+ return oo.includes(S) || (g[S] = f[S]), g;
2508
+ }, {});
2509
+ }(t), H = r.pluginsArray.reduce(function(f, g) {
2510
+ var S = g.name, C = g.config, $ = g.loaded, A = r.pluginEnabled[S];
2511
+ return f[S] = { enabled: A, initialized: !!A && !g.initialize, loaded: !!$({ config: C }), config: C }, f;
2512
+ }, {}), Z = { context: U, user: _, plugins: H }, j = Yn(function(f) {
2513
+ for (var g = Object.keys(f), S = {}, C = 0; C < g.length; C++) {
2514
+ var $ = g[C];
2515
+ typeof f[$] === ne && (S[$] = f[$]);
2516
+ }
2517
+ var A, W = Object.keys(S);
2518
+ try {
2519
+ (function(N) {
2520
+ Object.keys(N).forEach(function(R) {
2521
+ var z = N[R];
2522
+ if (typeof z(void 0, { type: "@@redux/INIT" }) === ee || typeof z(void 0, { type: Ui }) === ee)
2523
+ throw new Error("reducer " + R + " " + ee);
2524
+ });
2525
+ })(S);
2526
+ } catch (N) {
2527
+ A = N;
2528
+ }
2529
+ return function(N, R) {
2530
+ if (N === void 0 && (N = {}), A)
2531
+ throw A;
2532
+ for (var z = !1, q = {}, Ae = 0; Ae < W.length; Ae++) {
2533
+ var Me = W[Ae], Rt = N[Me], lt = (0, S[Me])(Rt, R);
2534
+ if (typeof lt === ee) {
2535
+ var mr = Ri(Me, R);
2536
+ throw new Error(mr);
2537
+ }
2538
+ q[Me] = lt, z = z || lt !== Rt;
2539
+ }
2540
+ return z ? q : N;
2541
+ };
2542
+ }(O({}, P, e)), Z, L(x(Zi.apply(void 0, T))));
2543
+ j.dispatch = (J = j.dispatch, function(f, g, S) {
2544
+ var C = O({}, f, { meta: yn(f.meta, g, vt(S)) });
2545
+ return J.apply(null, [C]);
2546
+ });
2547
+ var K = Object.keys(a);
2548
+ j.dispatch({ type: E.bootstrap, plugins: K, config: U, params: v, user: _, initialUser: n, persistedUser: I });
2549
+ var M = K.filter(function(f) {
2550
+ return r.pluginEnabled[f];
2551
+ }), $e = K.filter(function(f) {
2552
+ return !r.pluginEnabled[f];
2553
+ });
2554
+ return j.dispatch({ type: E.registerPlugins, plugins: K, enabled: r.pluginEnabled }), r.pluginsArray.map(function(f, g) {
2555
+ var S = f.bootstrap, C = f.config, $ = f.name;
2556
+ S && G(S) && S({ instance: b, config: C, payload: f }), j.dispatch({ type: E.registerPluginType($), name: $, enabled: r.pluginEnabled[$], plugin: f }), r.pluginsArray.length === g + 1 && j.dispatch({ type: E.initializeStart, plugins: M, disabled: $e });
2557
+ }), so(function(f) {
2558
+ j.dispatch({ type: f ? E.offline : E.online });
2559
+ }), function(f, g, S) {
2560
+ setInterval(function() {
2561
+ return Bn(f, g, S);
2562
+ }, 3e3);
2563
+ }(j, u, b), b;
2564
+ }
2565
+ var Ve = "before", Ye = "after", Ue = "cookie", ue = cr(), ar = ct, uo = ct;
2566
+ function sr(t) {
2567
+ return ue ? ct(t, "", -1) : xe(t);
2568
+ }
2569
+ function cr() {
2570
+ if (ue !== void 0)
2571
+ return ue;
2572
+ var t = "cookiecookie";
2573
+ try {
2574
+ ct(t, t), ue = document.cookie.indexOf(t) !== -1, sr(t);
2575
+ } catch {
2576
+ ue = !1;
2577
+ }
2578
+ return ue;
2579
+ }
2580
+ function ct(t, e, n, r, i, o) {
2581
+ if (typeof window < "u") {
2582
+ var a = arguments.length > 1;
2583
+ return ue === !1 && (a ? ye(t, e) : ge(t)), a ? document.cookie = t + "=" + encodeURIComponent(e) + (n ? "; expires=" + new Date(+/* @__PURE__ */ new Date() + 1e3 * n).toUTCString() + (r ? "; path=" + r : "") + (i ? "; domain=" + i : "") + (o ? "; secure" : "") : "") : decodeURIComponent((("; " + document.cookie).split("; " + t + "=")[1] || "").split(";")[0]);
2584
+ }
2585
+ }
2586
+ var Re = "localStorage", lo = $t.bind(null, "localStorage");
2587
+ Ce("localStorage", "getItem", ge);
2588
+ Ce("localStorage", "setItem", ye);
2589
+ Ce("localStorage", "removeItem", xe);
2590
+ var Ze = "sessionStorage", ho = $t.bind(null, "sessionStorage");
2591
+ Ce("sessionStorage", "getItem", ge);
2592
+ Ce("sessionStorage", "setItem", ye);
2593
+ Ce("sessionStorage", "removeItem", xe);
2594
+ function Se(t) {
2595
+ var e = t;
2596
+ try {
2597
+ if ((e = JSON.parse(t)) === "true")
2598
+ return !0;
2599
+ if (e === "false")
2600
+ return !1;
2601
+ if (X(e))
2602
+ return e;
2603
+ parseFloat(e) === e && (e = parseFloat(e));
2604
+ } catch {
2605
+ }
2606
+ if (e !== null && e !== "")
2607
+ return e;
2608
+ }
2609
+ var fo = lo(), po = ho(), mo = cr();
2610
+ function ur(t, e) {
2611
+ if (t) {
2612
+ var n = At(e), r = !Lt(n), i = zt(n) ? Se(localStorage.getItem(t)) : void 0;
2613
+ if (r && !be(i))
2614
+ return i;
2615
+ var o = Nt(n) ? Se(ar(t)) : void 0;
2616
+ if (r && o)
2617
+ return o;
2618
+ var a = Dt(n) ? Se(sessionStorage.getItem(t)) : void 0;
2619
+ if (r && a)
2620
+ return a;
2621
+ var s = ge(t);
2622
+ return r ? s : { localStorage: i, sessionStorage: a, cookie: o, global: s };
2623
+ }
2624
+ }
2625
+ function go(t, e, n) {
2626
+ if (t && !be(e)) {
2627
+ var r = {}, i = At(n), o = JSON.stringify(e), a = !Lt(i);
2628
+ return zt(i) && (r[Re] = Ge(Re, e, Se(localStorage.getItem(t))), localStorage.setItem(t, o), a) ? r[Re] : Nt(i) && (r[Ue] = Ge(Ue, e, Se(ar(t))), uo(t, o), a) ? r[Ue] : Dt(i) && (r[Ze] = Ge(Ze, e, Se(sessionStorage.getItem(t))), sessionStorage.setItem(t, o), a) ? r[Ze] : (r[Le] = Ge(Le, e, ge(t)), ye(t, e), a ? r[Le] : r);
2629
+ }
2630
+ }
2631
+ function yo(t, e) {
2632
+ if (t) {
2633
+ var n = At(e), r = ur(t, Xn), i = {};
2634
+ return !be(r.localStorage) && zt(n) && (localStorage.removeItem(t), i[Re] = r.localStorage), !be(r.cookie) && Nt(n) && (sr(t), i[Ue] = r.cookie), !be(r.sessionStorage) && Dt(n) && (sessionStorage.removeItem(t), i[Ze] = r.sessionStorage), !be(r.global) && ut(n, Le) && (xe(t), i[Le] = r.global), i;
2635
+ }
2636
+ }
2637
+ function At(t) {
2638
+ return t ? re(t) ? t : t.storage : Mn;
2639
+ }
2640
+ function zt(t) {
2641
+ return fo && ut(t, Re);
2642
+ }
2643
+ function Nt(t) {
2644
+ return mo && ut(t, Ue);
2645
+ }
2646
+ function Dt(t) {
2647
+ return po && ut(t, Ze);
2648
+ }
2649
+ function Lt(t) {
2650
+ return t === Xn || t === "all";
2651
+ }
2652
+ function ut(t, e) {
2653
+ return t === Mn || t === e || Lt(t);
2654
+ }
2655
+ function Ge(t, e, n) {
2656
+ return { location: t, current: e, previous: n };
2657
+ }
2658
+ var vo = { setItem: go, getItem: ur, removeItem: yo };
2659
+ function wo(t, e, n) {
2660
+ return e in t ? Object.defineProperty(t, e, {
2661
+ value: n,
2662
+ enumerable: !0,
2663
+ configurable: !0,
2664
+ writable: !0
2665
+ }) : t[e] = n, t;
2666
+ }
2667
+ function vn(t, e) {
2668
+ var n = Object.keys(t);
2669
+ if (Object.getOwnPropertySymbols) {
2670
+ var r = Object.getOwnPropertySymbols(t);
2671
+ e && (r = r.filter(function(i) {
2672
+ return Object.getOwnPropertyDescriptor(t, i).enumerable;
2673
+ })), n.push.apply(n, r);
2674
+ }
2675
+ return n;
2676
+ }
2677
+ function wn(t) {
2678
+ for (var e = 1; e < arguments.length; e++) {
2679
+ var n = arguments[e] != null ? arguments[e] : {};
2680
+ e % 2 ? vn(Object(n), !0).forEach(function(r) {
2681
+ wo(t, r, n[r]);
2682
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : vn(Object(n)).forEach(function(r) {
2683
+ Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
2684
+ });
2685
+ }
2686
+ return t;
2687
+ }
2688
+ function bo() {
2689
+ var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, e = {
2690
+ storage: vo
2691
+ };
2692
+ return co(wn(wn({}, e), t));
2693
+ }
2694
+ function ko(t, e) {
2695
+ e = e || {};
2696
+ var n, r, i = [], o = e.max || 1 / 0;
2697
+ function a() {
2698
+ clearInterval(n), t(i.splice(0, o)), s();
2699
+ }
2700
+ function s() {
2701
+ n = setInterval(a, e.interval || 1e4);
2702
+ }
2703
+ return s(), {
2704
+ flush: a,
2705
+ push: function(m) {
2706
+ return r = i.push(m), r >= o && a(), r;
2707
+ },
2708
+ size: function() {
2709
+ return i.length;
2710
+ },
2711
+ end: function(m) {
2712
+ m && a(), clearInterval(n);
2713
+ }
2714
+ };
2715
+ }
2716
+ function Io(t) {
2717
+ if (!(typeof window > "u")) {
2718
+ var e = window, n = e.addEventListener, r = e.history, i = e.location, o = i.pathname;
2719
+ n("popstate", function() {
2720
+ return t(i.pathname);
2721
+ }), ["push", "replace"].map(function(a) {
2722
+ var s = "".concat(a, "State"), m = r[s];
2723
+ r[s] = function() {
2724
+ var p = arguments, u = So(arguments[2]);
2725
+ return o !== u && (o = u, setTimeout(function() {
2726
+ return t(p[2]);
2727
+ }, 0)), m.apply(r, arguments);
2728
+ };
2729
+ });
2730
+ }
2731
+ }
2732
+ function _o(t, e) {
2733
+ var n = t.indexOf(e);
2734
+ return n > -1 ? t.slice(0, n) : t;
2735
+ }
2736
+ function So(t) {
2737
+ return ["#", "?"].forEach(function(e) {
2738
+ return t = _o(t, e);
2739
+ }), t;
2740
+ }
2741
+ function Eo() {
2742
+ Io(() => {
2743
+ se.page();
2744
+ });
2745
+ }
2746
+ var bn = "EventListener";
2747
+ function Oo(t) {
2748
+ return function(e, n, r, i) {
2749
+ var o = r || _i, a = i || !1;
2750
+ if (!Y)
2751
+ return o;
2752
+ var s = tt(n), m = tt(e, !0);
2753
+ if (!m.length)
2754
+ throw new Error("noElements");
2755
+ if (!s.length)
2756
+ throw new Error("noEvent");
2757
+ var p = [];
2758
+ return function u(c) {
2759
+ c && (p = []);
2760
+ for (var h = c ? "add" + bn : "remove" + bn, d = 0; d < m.length; d++) {
2761
+ var w = m[d];
2762
+ p[d] = c ? a && a.once ? Po(o) : o : p[d] || o;
2763
+ for (var k = 0; k < s.length; k++)
2764
+ w[h] ? w["on" + s[k]] = c ? p[d] : null : w[h](s[k], p[d], a);
2765
+ }
2766
+ return u.bind(null, !c);
2767
+ }(t);
2768
+ };
2769
+ }
2770
+ function tt(t, e) {
2771
+ if (re(t))
2772
+ return e ? tt(document.querySelectorAll(t)) : (n = t).split(n.indexOf(",") > -1 ? "," : " ").map(function(a) {
2773
+ return a.trim();
2774
+ });
2775
+ var n;
2776
+ if (NodeList.prototype.isPrototypeOf(t)) {
2777
+ for (var r = [], i = t.length >>> 0; i--; )
2778
+ r[i] = t[i];
2779
+ return r;
2780
+ }
2781
+ var o = Ai(t);
2782
+ return e ? o.map(function(a) {
2783
+ return re(a) ? tt(a, !0) : a;
2784
+ }).flat() : o;
2785
+ }
2786
+ function Po(t, e) {
2787
+ var n;
2788
+ return function() {
2789
+ return t && (n = t.apply(e || this, arguments), t = null), n;
2790
+ };
2791
+ }
2792
+ var wt = Oo("Event");
2793
+ function lr(t, e) {
2794
+ return Y && G(window[t]) ? (n = window[t], r = e, (i = window) === void 0 && (i = null), G(n) ? function() {
2795
+ n.apply(i, arguments), r.apply(i, arguments);
2796
+ } : r) : window[t] = e;
2797
+ var n, r, i;
2798
+ }
2799
+ lr.bind(null, "onerror");
2800
+ lr.bind(null, "onload");
2801
+ var dr = typeof window > "u", kn = "hidden";
2802
+ function To(t) {
2803
+ if (dr)
2804
+ return !1;
2805
+ var e = jo(), n = "".concat(e.replace(/[H|h]idden/, ""), "visibilitychange"), r = function() {
2806
+ return t(!!document[e]);
2807
+ }, i = function() {
2808
+ return document.addEventListener(n, r);
2809
+ };
2810
+ return i(), function() {
2811
+ return document.removeEventListener(n, r), i;
2812
+ };
2813
+ }
2814
+ function jo() {
2815
+ var t = ["webkit", "moz", "ms", "o"];
2816
+ return dr || kn in document ? kn : t.reduce(function(e, n) {
2817
+ var r = n + "Hidden";
2818
+ return !e && r in document ? r : e;
2819
+ }, null);
2820
+ }
2821
+ var xo = ["mousemove", "mousedown", "touchmove", "touchstart", "touchend", "keydown"];
2822
+ function Co(t, e) {
2823
+ e === void 0 && (e = {});
2824
+ var n = /* @__PURE__ */ function(a, s) {
2825
+ var m = this, p = !1;
2826
+ return function(u) {
2827
+ p || (a.call(m, u), p = !0, setTimeout(function() {
2828
+ return p = !1;
2829
+ }, s));
2830
+ };
2831
+ }(t, e.throttle || 1e4), r = [];
2832
+ function i() {
2833
+ var a = To(function(s) {
2834
+ s || n({ type: "tabVisible" });
2835
+ });
2836
+ return r = [a].concat(xo.map(function(s) {
2837
+ return wt(document, s, n);
2838
+ })).concat(wt(window, "load", n)).concat(wt(window, "scroll", n, { capture: !0, passive: !0 })), o;
2839
+ }
2840
+ function o() {
2841
+ r.map(function(a) {
2842
+ return a();
2843
+ });
2844
+ }
2845
+ return i(), function() {
2846
+ return o(), i;
2847
+ };
2848
+ }
2849
+ function $o(t) {
2850
+ var e, n, r = t.onIdle, i = t.onWakeUp, o = t.onHeartbeat, a = t.timeout, s = a === void 0 ? 1e4 : a, m = t.throttle, p = m === void 0 ? 2e3 : m, u = !1, c = !1, h = /* @__PURE__ */ new Date(), d = function() {
2851
+ return clearTimeout(e);
2852
+ };
2853
+ function w(v) {
2854
+ d(), o && !u && o(Ne(h), v), i && u && (u = !1, i(Ne(n), v), h = /* @__PURE__ */ new Date()), e = setTimeout(function() {
2855
+ u = !0, r && (n = /* @__PURE__ */ new Date(), r(Ne(h), v));
2856
+ }, s);
2857
+ }
2858
+ var k = Co(w, { throttle: p });
2859
+ return { disable: function() {
2860
+ c = !0, u = !1, d();
2861
+ var v = k();
2862
+ return function() {
2863
+ return c = !1, h = /* @__PURE__ */ new Date(), w({ type: "load" }), v();
2864
+ };
2865
+ }, getStatus: function() {
2866
+ return { isIdle: u, isDisabled: c, active: u ? 0 : Ne(h, c), idle: u ? Ne(n, c) : 0 };
2867
+ } };
2868
+ }
2869
+ function Ne(t, e) {
2870
+ return e ? 0 : Math.round((/* @__PURE__ */ new Date() - t) / 1e3);
2871
+ }
2872
+ const In = 5e3;
2873
+ class Ao {
2874
+ constructor(e) {
2875
+ B(this, "element");
2876
+ B(this, "isInViewport", !1);
2877
+ B(this, "isAwake", !1);
2878
+ B(this, "isFlushing");
2879
+ B(this, "observer");
2880
+ B(this, "lastEventAt", Date.now());
2881
+ B(this, "registeredView", !1);
2882
+ B(this, "viewCallback");
2883
+ B(this, "activeDurationCallback");
2884
+ B(this, "idleDurationCallback");
2885
+ this.element = e.element, this.viewCallback = e.viewCallback, this.activeDurationCallback = e.activeDurationCallback, this.idleDurationCallback = e.idleDurationCallback, this.observer = new IntersectionObserver(
2886
+ (n) => {
2887
+ n.forEach((r) => {
2888
+ this.handleInViewPort(r.isIntersecting);
2889
+ });
2890
+ },
2891
+ {
2892
+ threshold: 0
2893
+ }
2894
+ ), this.observer.observe(this.element), $o({
2895
+ onIdle: (n) => this.handleAwake(!1, n),
2896
+ onWakeUp: (n) => this.handleAwake(!0, n),
2897
+ timeout: In
2898
+ });
2899
+ }
2900
+ /**
2901
+ * Flush the awake timer in case the page is unloading
2902
+ */
2903
+ flush() {
2904
+ this.isFlushing = !0, this.handleAwake(!this.isAwake, Math.round((Date.now() - this.lastEventAt) / 1e3));
2905
+ }
2906
+ handleInViewPort(e) {
2907
+ e ? (this.isAwake = !0, this.trackInViewport()) : this.handleAwake(!1, Math.round((Date.now() - this.lastEventAt) / 1e3)), this.isInViewport = e;
2908
+ }
2909
+ handleAwake(e, n) {
2910
+ this.isAwake = e, this.lastEventAt = e ? Date.now() - n * In : Date.now(), this.isInViewport && this.trackAwake(e, n);
2911
+ }
2912
+ trackAwake(e, n) {
2913
+ !e && this.activeDurationCallback && this.activeDurationCallback(n, this.isFlushing), e && this.idleDurationCallback && this.idleDurationCallback(n, this.isFlushing);
2914
+ }
2915
+ trackInViewport() {
2916
+ this.registeredView || (this.registeredView = !0, this.viewCallback && this.viewCallback());
2917
+ }
2918
+ }
2919
+ const _n = "sesamy_session_id";
2920
+ function zo() {
2921
+ let t = sessionStorage.getItem(_n);
2922
+ return t || (t = Math.random().toString(36).slice(2, 9), sessionStorage.setItem(_n, t)), t;
2923
+ }
2924
+ let hr = !1, Pt, Sn, nt;
2925
+ function No({ clientId: t, enabled: e = !0, endpoint: n = Mr }) {
2926
+ if (Pt = t, Sn = e, nt = n, !Sn)
2927
+ return;
2928
+ Eo();
2929
+ const r = new Ao({
2930
+ element: document.body,
2931
+ viewCallback: () => {
2932
+ se.page();
2933
+ },
2934
+ activeDurationCallback: (i, o) => {
2935
+ se.track("activeDuration", {
2936
+ duration: i,
2937
+ flushing: o
2938
+ });
2939
+ },
2940
+ idleDurationCallback: (i, o) => {
2941
+ se.track("idleDuration", {
2942
+ duration: i,
2943
+ flushing: o
2944
+ });
2945
+ }
2946
+ });
2947
+ Lo(document.body, () => {
2948
+ r.flush();
2949
+ }), window.addEventListener(pe.AUTHENTICATED, async (i) => {
2950
+ const o = i;
2951
+ await se.identify(o.detail.sub);
2952
+ }), window.addEventListener(pe.LOGOUT, async () => {
2953
+ await se.track("logout", {}), Ut.flush(), await se.reset();
2954
+ });
2955
+ }
2956
+ function fr(t) {
2957
+ return JSON.stringify(
2958
+ t.map((e) => ({
2959
+ ...e,
2960
+ clientId: Pt,
2961
+ requestId: Math.random().toString(36).slice(2, 9),
2962
+ sessionId: zo(),
2963
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2964
+ version: Ct,
2965
+ event: e.event,
2966
+ context: {
2967
+ page: {
2968
+ url: window.location.hostname,
2969
+ path: window.location.pathname,
2970
+ title: document.title,
2971
+ search: window.location.search,
2972
+ referrer: document.referrer
2973
+ },
2974
+ locale: navigator.language,
2975
+ library: Kn,
2976
+ userAgent: navigator.userAgent,
2977
+ clientId: Pt
2978
+ }
2979
+ }))
2980
+ );
2981
+ }
2982
+ const Ut = ko(
2983
+ async (t) => {
2984
+ if (t.length > 0) {
2985
+ const e = fr(t);
2986
+ hr ? navigator.sendBeacon(nt, e) : (await fetch(nt, {
2987
+ method: "POST",
2988
+ body: e,
2989
+ headers: {
2990
+ "Content-Type": "text/plain"
2991
+ }
2992
+ })).ok;
2993
+ }
2994
+ },
2995
+ {
2996
+ max: 10,
2997
+ // limit
2998
+ interval: 3e3
2999
+ // 3s
3000
+ }
3001
+ );
3002
+ function bt(t) {
3003
+ var e;
3004
+ if (t.anonymousId)
3005
+ if ((e = t.properties) != null && e.flushing) {
3006
+ const n = { ...t };
3007
+ delete n.properties.flushing, navigator.sendBeacon(nt, fr([n]));
3008
+ } else
3009
+ Ut.push(t);
3010
+ }
3011
+ const se = bo({
3012
+ app: Kn,
3013
+ version: Ct,
3014
+ plugins: [
3015
+ {
3016
+ name: "custom-analytics-plugin",
3017
+ page: ({ payload: t }) => {
3018
+ const { properties: e, anonymousId: n, userId: r, event: i } = t;
3019
+ bt({
3020
+ anonymousId: n,
3021
+ userId: r,
3022
+ properties: e,
3023
+ event: i,
3024
+ type: "page"
3025
+ });
3026
+ },
3027
+ track: ({ payload: t }) => {
3028
+ const { properties: e, anonymousId: n, userId: r, event: i } = t;
3029
+ bt({
3030
+ anonymousId: n,
3031
+ userId: r,
3032
+ properties: e,
3033
+ event: i,
3034
+ type: "track"
3035
+ });
3036
+ },
3037
+ identify: ({ payload: t }) => {
3038
+ const { properties: e, anonymousId: n, userId: r } = t;
3039
+ bt({
3040
+ anonymousId: n,
3041
+ userId: r,
3042
+ properties: e,
3043
+ type: "identify"
3044
+ });
3045
+ }
3046
+ }
3047
+ ]
3048
+ });
3049
+ function Do() {
3050
+ return hr = !0, Ut.flush();
3051
+ }
3052
+ const pr = /* @__PURE__ */ new Map();
3053
+ function Lo(t, e) {
3054
+ pr.set(t, e);
3055
+ }
3056
+ window.addEventListener("beforeunload", () => {
3057
+ pr.forEach((t, e) => {
3058
+ t.bind(e)();
3059
+ }), Do();
3060
+ });
3061
+ async function Uo(t) {
3062
+ No({
3063
+ clientId: t.clientId,
3064
+ // The default client id can be overridden by the config
3065
+ ...t.analytics
3066
+ }), await Xr(t);
3067
+ const e = Ii(t.namespace);
3068
+ return rt(pe.READY, {}), e;
3069
+ }
3070
+ if (typeof document < "u") {
3071
+ const t = document.getElementById("sesamy-js");
3072
+ if (t != null && t.textContent)
3073
+ try {
3074
+ const e = JSON.parse(t.textContent);
3075
+ Uo(e);
3076
+ } catch (e) {
3077
+ console.error("Failed to parse config", e);
3078
+ }
3079
+ }
3080
+ export {
3081
+ Uo as init
3082
+ };