@picked/client 0.0.1-dev.1769554766412 → 0.0.1-dev.1769991916367

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 (35) hide show
  1. package/dist/cjs/index.js +2 -2
  2. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  3. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  4. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  5. package/dist/esm/index.js +939 -221
  6. package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
  7. package/dist/esm/plugins/history-browser-storage/index.js +1 -1
  8. package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
  9. package/dist/esm/plugins/single-page-app/index.js +3 -3
  10. package/dist/esm/plugins/web-components/index.js +1 -1
  11. package/dist/esm/plugins/window-object/index.js +1 -1
  12. package/dist/esm/server/index.js +7 -7
  13. package/dist/{experience-instance-DJCJUe0h.js → experience-instance-CwXYJkRx.js} +7 -7
  14. package/dist/storage-Be5xWNPC.cjs +1 -0
  15. package/dist/storage-Co_LbKr_.js +239 -0
  16. package/dist/{supports-DCSoenK6.js → supports-COb-sl36.js} +10 -10
  17. package/dist/types/utils/events.d.ts +1 -6
  18. package/dist/types/utils/events.d.ts.map +1 -1
  19. package/dist/types/utils/storage.d.ts +357 -1
  20. package/dist/types/utils/storage.d.ts.map +1 -1
  21. package/package.json +1 -7
  22. package/dist/cjs/plugins/data-layer/index.js +0 -1
  23. package/dist/esm/plugins/data-layer/index.js +0 -202
  24. package/dist/storage-BLmAhfhl.js +0 -94
  25. package/dist/storage-YlR83AWP.cjs +0 -1
  26. package/dist/types/plugins/data-layer/custom-event.d.ts +0 -5
  27. package/dist/types/plugins/data-layer/custom-event.d.ts.map +0 -1
  28. package/dist/types/plugins/data-layer/index.d.ts +0 -2
  29. package/dist/types/plugins/data-layer/index.d.ts.map +0 -1
  30. package/dist/types/plugins/data-layer/plugin.d.ts +0 -55
  31. package/dist/types/plugins/data-layer/plugin.d.ts.map +0 -1
  32. package/dist/types/plugins/data-layer/utils.d.ts +0 -39
  33. package/dist/types/plugins/data-layer/utils.d.ts.map +0 -1
  34. package/dist/user-session-DQh0BBTx.cjs +0 -1
  35. package/dist/user-session-XidjAPGf.js +0 -747
@@ -1,747 +0,0 @@
1
- import { createDomain as b, createApi as F, createStore as U, createEffect as j, sample as w, attach as q, combine as O, createEvent as V } from "effector";
2
- import { createFactory as k, invoke as h } from "@withease/factories";
3
- import { g as C, t as z, b as G, f as Y, e as L, h as J } from "./experience-instance-DJCJUe0h.js";
4
- import { l as R } from "./logger-C9a75KZn.js";
5
- import { c as B, l as D, s as P } from "./storage-BLmAhfhl.js";
6
- import { g as K } from "./id-BW-g3y32.js";
7
- import { i as Q } from "./object-JwZ58NOH.js";
8
- import { e as W, k as X } from "./supports-DCSoenK6.js";
9
- const _ = b("experience"), Z = k(
10
- ({ client: e, experience: t }) => {
11
- const o = _.store(t), l = F(o, {
12
- merge(i, f) {
13
- return {
14
- ...i,
15
- ...f.experience
16
- };
17
- }
18
- }), d = o.map((i) => ({
19
- name: i.name,
20
- decisionLogic: i.condition ?? i.decide,
21
- targetSelectors: i.targets,
22
- initializeOpenLogic: t.initializeOpen
23
- })), g = e.components.listStore.map(
24
- (i) => i.find((f) => f.name === `experience:${t.id}`) || i.find((f) => f.name === "experience"),
25
- { skipVoid: !1 }
26
- ), s = o.map((i) => ({
27
- steps: i.steps,
28
- nodes: i.nodes,
29
- edges: i.edges,
30
- conditionals: i.conditionals
31
- })), r = t.actions ?? [];
32
- return {
33
- id: t.id,
34
- configStore: d,
35
- treeStore: s,
36
- componentStore: g,
37
- actions: r,
38
- merge: l.merge
39
- };
40
- }
41
- );
42
- function ee(e) {
43
- return h(Z, e);
44
- }
45
- const te = k(({ client: e }) => {
46
- const t = _.store({}), o = F(t, {
47
- register(s, r) {
48
- return {
49
- ...s,
50
- [r.id]: r
51
- };
52
- }
53
- });
54
- function l(s) {
55
- const r = t.getState()[s.id];
56
- if (r) {
57
- r.merge({ experience: s, strategy: "override" });
58
- return;
59
- }
60
- const i = ee({ client: e, experience: s });
61
- o.register(i);
62
- }
63
- const d = t.map((s) => Object.values(s));
64
- function g(s) {
65
- return t.map((r) => r[s], { skipVoid: !1 });
66
- }
67
- return {
68
- register: l,
69
- getById: g,
70
- listStore: d
71
- };
72
- });
73
- function Pe(e) {
74
- return h(te, e);
75
- }
76
- const Me = (e, t) => {
77
- t.register(e);
78
- }, re = (e, t) => {
79
- const { targetSelectors: o } = t.configStore.getState(), l = C(o, t.id);
80
- l.forEach(
81
- ({ elements: g }) => g.forEach((s) => z(s, t.id))
82
- ), G(l, t.id).forEach((g) => {
83
- e.experienceInstances.spawn(t, g);
84
- });
85
- }, Te = async (e) => {
86
- await Promise.all(
87
- e.experiences.listStore.getState().map(async (t) => {
88
- await se(e, t) && re(e, t);
89
- })
90
- );
91
- }, se = async (e, t) => {
92
- const { decisionLogic: o, targetSelectors: l } = t.configStore.getState();
93
- return C(l, t.id).length < 1 || l.length === 0 ? !1 : o && Y(o) ? await L(e, o) === !0 : !0;
94
- }, ne = b("component"), oe = k(
95
- ({ client: e, component: t, name: o }) => {
96
- const l = e.frameworks.getByName(t.frameworkName);
97
- return {
98
- name: o,
99
- component: t,
100
- frameworkStore: l
101
- };
102
- }
103
- );
104
- function ie(e) {
105
- return h(oe, e);
106
- }
107
- const ae = k(({ client: e }) => {
108
- const t = ne.store({}), o = F(t, {
109
- register(s, r) {
110
- return {
111
- ...s,
112
- [r.name]: r
113
- };
114
- }
115
- });
116
- function l(s, r) {
117
- t.getState()[s] && R(
118
- "warn",
119
- `Component '${s}' already registered. Registering again will override the previous registration.`
120
- );
121
- const f = ie({ client: e, name: s, component: r });
122
- o.register(f);
123
- }
124
- const d = t.map((s) => Object.values(s));
125
- function g(s) {
126
- return t.map((r) => r[s], { skipVoid: !1 });
127
- }
128
- return {
129
- register: l,
130
- getByName: g,
131
- listStore: d
132
- };
133
- });
134
- function Ne(e) {
135
- return h(ae, e);
136
- }
137
- const Ue = (e, t, o) => {
138
- o.register(e, t);
139
- }, ce = b("framework"), ue = k(({ client: e }) => {
140
- const t = ce.store({}), o = F(t, {
141
- register(s, r) {
142
- return {
143
- ...s,
144
- [r.name]: r.framework
145
- };
146
- }
147
- });
148
- function l(s, r) {
149
- t.getState()[s] && R(
150
- "warn",
151
- `Framework '${s}' already registered. Registering again will override the previous registration.`
152
- ), o.register({ name: s, framework: r });
153
- }
154
- const d = t.map((s) => Object.values(s));
155
- function g(s) {
156
- return t.map((r) => r[s], { skipVoid: !1 });
157
- }
158
- return {
159
- register: l,
160
- getByName: g,
161
- listStore: d
162
- };
163
- });
164
- function Ce(e) {
165
- return h(ue, e);
166
- }
167
- const Le = (e, t) => {
168
- t.register(e.name, e);
169
- }, le = 6e3, de = B("last_ping", "global"), ge = (e) => `${e}/api/v1/ping`, _e = async (e) => {
170
- try {
171
- const t = Date.now(), o = D.get(de);
172
- let l = 0;
173
- if (o.isSet() && (l = o.json() ?? 0), l && t - l < le)
174
- return !0;
175
- const d = ge(e.apiUrl), g = {
176
- projectId: e.projectId,
177
- path: window.location.pathname
178
- }, s = JSON.stringify(g), r = {
179
- "Content-Type": "application/json"
180
- }, f = document.getElementById("picked_script")?.dataset.verceltoken;
181
- f && (r["x-vercel-protection-bypass"] = f);
182
- const v = (await fetch(d, {
183
- method: "POST",
184
- headers: r,
185
- body: s
186
- })).ok;
187
- return v && o.set(t), v;
188
- } catch (t) {
189
- return R("error", t), !1;
190
- }
191
- };
192
- function fe(e) {
193
- const t = typeof window < "u", o = {
194
- client: e,
195
- responses: e.responses.listStore.getState(),
196
- fields: e.fields.listStore.getState(),
197
- location: t ? window.location : void 0,
198
- document: t ? window.document : void 0,
199
- sessionStorage: t ? window.sessionStorage : void 0,
200
- localStorage: t ? window.localStorage : void 0
201
- };
202
- return Object.freeze(o);
203
- }
204
- const pe = b("predicate"), me = k(({ client: e }) => {
205
- const t = pe.store({}), o = F(t, {
206
- register(r, i) {
207
- return {
208
- ...r,
209
- [i.name]: {
210
- name: i.name,
211
- predicate: i.predicate
212
- }
213
- };
214
- }
215
- });
216
- function l(r, i) {
217
- t.getState()[r] && R(
218
- "warn",
219
- `Predicate '${r}' already registered. Registering again will override the previous registration.`
220
- ), o.register(Object.freeze({ name: r, predicate: i }));
221
- }
222
- const d = t.map((r) => Object.values(r));
223
- function g(r) {
224
- return t.map((i) => i[r]?.predicate, { skipVoid: !1 });
225
- }
226
- function s(r) {
227
- const i = U(() => {
228
- }, {
229
- skipVoid: !1
230
- }), f = j(async () => {
231
- const S = g(r).getState();
232
- if (!S)
233
- return;
234
- const v = fe(e);
235
- return (...p) => S({ ...v, args: p });
236
- });
237
- return w({
238
- source: { responses: e.responses.listStore, fields: e.fields.listStore },
239
- target: f
240
- }), w({
241
- clock: f.doneData,
242
- filter: (S) => S !== void 0,
243
- target: i
244
- }), f(), i;
245
- }
246
- return {
247
- register: l,
248
- getByName: g,
249
- listStore: d,
250
- getEvokablePredicate: s
251
- };
252
- });
253
- function He(e) {
254
- return h(me, e);
255
- }
256
- const qe = (e, t, o) => {
257
- o.register(e, t);
258
- }, M = b("feature"), ye = k(({ client: e }) => {
259
- const t = M.store({}), o = M.store([]), l = F(t, {
260
- register(n, a) {
261
- return {
262
- ...n,
263
- [a.id]: a.feature
264
- };
265
- }
266
- });
267
- function d(n, a) {
268
- t.getState()[n] && R(
269
- "warn",
270
- `Feature '${n}' already registered. Registering again will override the previous registration.`
271
- );
272
- const c = {
273
- id: n,
274
- feature: {
275
- ...a,
276
- id: n
277
- }
278
- };
279
- l.register(
280
- Object.freeze({
281
- id: n,
282
- feature: c
283
- })
284
- );
285
- }
286
- const g = j(
287
- async ({
288
- id: n,
289
- key: a,
290
- storage: u = "local"
291
- }) => {
292
- const c = B(`feature:${n}:${a}`, "global"), y = (u === "session" ? P : D).get(c).boolean();
293
- return y === null ? null : { id: n, key: a, bucket: y, storage: u };
294
- }
295
- ), s = j((n) => {
296
- if (!n)
297
- return null;
298
- const a = B(`feature:${n.id}:${n.key}`, "global");
299
- (n.storage === "session" ? P : D).set(a, n.bucket);
300
- }), r = /* @__PURE__ */ new Map(), i = q({
301
- source: { allFeaturesStore: t, resolvedFeaturesStore: o },
302
- effect: async ({ allFeaturesStore: n, resolvedFeaturesStore: a }, { id: u, decide: c, key: m }) => {
303
- const y = a.find(
304
- ($) => $.id === u && $.key === m
305
- );
306
- if (y)
307
- return y;
308
- const x = n[u];
309
- if (!x)
310
- throw new Error(`Feature with id '${u}' not found`);
311
- const I = r.get(`${u}:${m}`);
312
- if (I !== void 0) {
313
- const $ = await I;
314
- return { id: x.id, bucket: $, key: m, storage: x.feature.storage };
315
- }
316
- const A = c();
317
- r.set(`${u}:${m}`, A);
318
- const H = await A;
319
- return { id: x.id, bucket: H, key: m, storage: x.feature.storage };
320
- }
321
- });
322
- w({
323
- clock: l.register,
324
- fn: (n) => {
325
- const { id: a, feature: u } = n;
326
- return { id: a, key: u.feature.key, storage: u.feature.storage };
327
- },
328
- target: g
329
- }), w({
330
- source: t,
331
- clock: i.doneData,
332
- fn: (n, a) => {
333
- const { id: u, bucket: c, storage: m } = a, y = n[u]?.feature.key;
334
- return y ? { key: y, id: u, bucket: c, storage: m } : null;
335
- },
336
- target: s
337
- });
338
- const f = O({ allFeaturesStore: t, resolvedFeaturesStore: o }).map(
339
- ({
340
- allFeaturesStore: n,
341
- resolvedFeaturesStore: a
342
- }) => Object.values(n).map((u) => {
343
- const c = a.find(
344
- (m) => m.id === u.id && m.key === u.feature.key
345
- );
346
- return c ? {
347
- id: u.id,
348
- name: u.feature.name,
349
- key: u.feature.key,
350
- getBucket: () => ({ id: u.id, bucket: c.bucket }),
351
- isResolved: !0
352
- } : {
353
- id: u.id,
354
- name: u.feature.name,
355
- key: u.feature.key,
356
- getBucket: async () => await i(u.feature),
357
- isResolved: !1
358
- };
359
- })
360
- );
361
- w({
362
- clock: i.doneData,
363
- source: { resolvedFeatures: o },
364
- filter: ({ resolvedFeatures: n }, { id: a, key: u }) => !n.some(
365
- (m) => m.id === a && m.key === u
366
- ),
367
- fn: (n, a) => a,
368
- target: e.eventBus.prepend((n) => ({
369
- type: "feature_decide",
370
- feature: n
371
- }))
372
- }), w({
373
- clock: [g.doneData, i.doneData],
374
- source: o,
375
- fn: (n, a) => !a || n.some(
376
- (c) => c.id === a.id && c.key === a.key
377
- ) ? n : [...n, a],
378
- target: o
379
- });
380
- function S(n) {
381
- return f.map((a) => a.find((u) => u.id === n));
382
- }
383
- function v(n) {
384
- return t.map((a) => a[n], { skipVoid: !1 });
385
- }
386
- function p(n) {
387
- const a = U(
388
- async () => {
389
- },
390
- { skipVoid: !1 }
391
- ), u = j(async () => {
392
- const c = S(n).getState();
393
- if (c)
394
- return async () => (await c.getBucket()).bucket;
395
- });
396
- return w({
397
- source: o,
398
- filter: (c) => c.some((m) => m.id === n),
399
- target: u
400
- }), w({
401
- clock: u.doneData,
402
- filter: (c) => c !== void 0,
403
- target: a
404
- }), u(), a;
405
- }
406
- return {
407
- register: d,
408
- getById: S,
409
- getByName: v,
410
- listStore: f,
411
- getEvokableFeature: p
412
- };
413
- });
414
- function ze(e) {
415
- return h(ye, e);
416
- }
417
- const Ge = (e, t, o) => {
418
- o.register(e, t);
419
- }, E = b("history");
420
- function T(e, t) {
421
- return {
422
- // eslint-disable-next-line sonarjs/pseudo-random
423
- id: K(`history-entry-${Date.now()}-${Math.random()}}`),
424
- node: t,
425
- at: Date.now(),
426
- experienceId: e
427
- };
428
- }
429
- const Se = k(() => {
430
- const e = E.store({ entries: [] }), t = E.event(), o = E.event(), l = E.event(), d = E.event();
431
- e.on(t, (s, r) => ({
432
- entries: [...s.entries, T(r.experienceId, r.node)]
433
- })), e.on(o, (s, r) => ({
434
- entries: [
435
- ...s.entries.slice(0, -1),
436
- T(r.experienceId, r.node)
437
- ]
438
- })), e.on(d, (s, r) => r);
439
- function g(s, r) {
440
- const i = { lastStepIndex: -1, secondLastStepIndex: -1 };
441
- for (let f = s.length - 1; f >= 0; f--) {
442
- const S = s[f], v = S?.node;
443
- if (!(!v || !J(v)) && !(r && S?.experienceId !== r))
444
- if (i.lastStepIndex === -1)
445
- i.lastStepIndex = f;
446
- else {
447
- i.secondLastStepIndex = f;
448
- break;
449
- }
450
- }
451
- return i;
452
- }
453
- return e.on(l, (s, r) => {
454
- const { secondLastStepIndex: i } = g(s.entries, r.experienceId), f = i !== -1 ? s.entries.slice(0, i + 1) : s.entries;
455
- return {
456
- ...s,
457
- entries: f
458
- };
459
- }), {
460
- push: t,
461
- replace: o,
462
- back: l,
463
- restore: d,
464
- entriesStore: e.map((s) => s.entries)
465
- };
466
- });
467
- function Ye() {
468
- return h(Se);
469
- }
470
- const ve = b("field"), ke = k(() => {
471
- const e = ve.store({}), t = F(e, {
472
- register(r, i) {
473
- return {
474
- ...r,
475
- [i.field.id]: i.field
476
- };
477
- }
478
- });
479
- function o(r) {
480
- t.register({ field: r });
481
- }
482
- function l(r, i) {
483
- const f = g(r).getState();
484
- if (!f)
485
- return;
486
- const S = Object.assign({}, f, {
487
- ...i
488
- });
489
- t.register({ field: { ...S } });
490
- }
491
- const d = e.map((r) => Object.values(r));
492
- function g(r) {
493
- return e.map((i) => i[r] || null);
494
- }
495
- function s(r) {
496
- return e.map((i) => Object.values(i).find((f) => f.name === r) || null);
497
- }
498
- return {
499
- register: o,
500
- update: l,
501
- getById: g,
502
- listStore: d,
503
- getByName: s
504
- };
505
- });
506
- function Je() {
507
- return h(ke);
508
- }
509
- const Ke = (e, t) => {
510
- t.register(e);
511
- }, he = b("action"), we = k(() => {
512
- const e = he.store({}), t = F(e, {
513
- register(s, r) {
514
- return {
515
- ...s,
516
- [r.name]: {
517
- name: r.name,
518
- action: r.action
519
- }
520
- };
521
- }
522
- });
523
- function o(s, r) {
524
- t.register({ name: s, action: r });
525
- }
526
- const l = e.map((s) => Object.values(s));
527
- function d(s) {
528
- return e.map((r) => r[s], { skipVoid: !1 });
529
- }
530
- function g(s) {
531
- return e.map(
532
- (r) => {
533
- const i = r[s];
534
- return i ? i.action : void 0;
535
- },
536
- { skipVoid: !1 }
537
- );
538
- }
539
- return {
540
- register: o,
541
- getByName: d,
542
- listStore: l,
543
- getEvokableAction: g
544
- };
545
- });
546
- function Qe() {
547
- return h(we);
548
- }
549
- const We = (e, t, o) => {
550
- o.register(e, t);
551
- };
552
- function N(e) {
553
- return typeof e > "u" || e === null || e === "" || Array.isArray(e) && !e.length;
554
- }
555
- const be = b("response"), Fe = k(({ client: e }) => {
556
- const t = be.store({}), o = V(), l = V(), d = F(t, {
557
- register(p, n) {
558
- return {
559
- ...p,
560
- [n.fieldId]: n.response
561
- };
562
- },
563
- registerBatch(p, n) {
564
- return {
565
- ...p,
566
- ...n
567
- };
568
- },
569
- clear(p, n) {
570
- const { [n]: a, ...u } = p;
571
- return u;
572
- },
573
- clearAll() {
574
- return {};
575
- }
576
- });
577
- function g(p, n) {
578
- if (typeof p == "string") {
579
- if (n === void 0)
580
- throw new Error("Response is required when registering a single field");
581
- d.register({ fieldId: p, response: n });
582
- } else
583
- d.registerBatch(p);
584
- }
585
- async function s(p) {
586
- const n = [];
587
- return await Promise.allSettled(
588
- Object.entries(p).map(async ([a, u]) => {
589
- let c = u;
590
- const m = e.fields.getById(a).getState();
591
- if (!m) {
592
- n.push({
593
- fieldId: a,
594
- userMessage: `Field '${a}' not found`,
595
- systemMessage: `No field with ID '${a}' exists. Available field IDs are: ${Object.keys(e.fields.listStore.getState()).join(",")}.`,
596
- value: c
597
- });
598
- return;
599
- }
600
- if (m.multiple && (typeof c == "string" || typeof c == "number" || typeof c == "boolean") && (c = [c]), m.validation && !Q(m.validation) && !N(c)) {
601
- const y = await L(e, m.validation, {
602
- $input: c
603
- });
604
- if (typeof y == "string") {
605
- n.push({
606
- fieldId: a,
607
- userMessage: y,
608
- systemMessage: `Field validation resulted in an error: ${y}.`,
609
- value: c
610
- });
611
- return;
612
- }
613
- if (y === !1) {
614
- n.push({
615
- fieldId: a,
616
- userMessage: "This field is invalid",
617
- systemMessage: "Field validation resulted in an unspecified error.",
618
- value: c
619
- });
620
- return;
621
- }
622
- }
623
- if (m.required && N(c)) {
624
- n.push({
625
- fieldId: a,
626
- userMessage: "This field is required",
627
- systemMessage: "Field is required.",
628
- value: c
629
- });
630
- return;
631
- }
632
- if (!m.multiple && Array.isArray(c) && c.length > 1) {
633
- n.push({
634
- fieldId: a,
635
- userMessage: "This field expects a single response",
636
- systemMessage: "Field expects a single response.",
637
- value: c
638
- });
639
- return;
640
- }
641
- if (m.options) {
642
- const y = m.options.map((I) => I.value), x = Array.isArray(c) ? c : [c];
643
- Array.isArray(c) && (x.every((I) => y.includes(I)) || n.push({
644
- fieldId: a,
645
- userMessage: "This field expects a valid option",
646
- systemMessage: `Field expects a valid option. Valid options are: ${y.join(", ")}`,
647
- value: c
648
- }));
649
- }
650
- })
651
- ), { responsesToCommit: p, validationErrors: n };
652
- }
653
- async function r(p) {
654
- const { responsesToCommit: n, validationErrors: a } = await s(p);
655
- return a.length ? { errors: a } : (d.registerBatch(n), { errors: [] });
656
- }
657
- const i = t.map((p) => p), f = t.map((p) => Object.keys(p).map((a) => ({
658
- fieldId: a,
659
- value: p[a]
660
- })));
661
- function S(p) {
662
- const n = e.fields.getById(p), a = t.map((u) => u[p] || null);
663
- return O({ f: n, r: a }, ({ f: u, r: c }) => c || (u?.defaultValue ? u.defaultValue : null));
664
- }
665
- function v(p) {
666
- const n = e.fields.getByName(p);
667
- return O({ f: n, s: t }, ({ f: a, s: u }) => {
668
- const c = a && u[a.id] || null;
669
- return c || (a?.defaultValue ? a.defaultValue : null);
670
- });
671
- }
672
- return w({
673
- clock: o,
674
- target: d.clearAll
675
- }), w({
676
- clock: l,
677
- target: d.clear
678
- }), {
679
- register: g,
680
- clearAll: o,
681
- clear: l,
682
- commit: r,
683
- getResponsesToCommit: s,
684
- listStore: f,
685
- getAllStore: i,
686
- getByFieldId: S,
687
- getByFieldName: v
688
- };
689
- });
690
- function Xe(e) {
691
- return h(Fe, e);
692
- }
693
- function xe() {
694
- if (X())
695
- return crypto.randomUUID();
696
- const e = Date.now().toString(36), t = Math.random().toString(36).substring(2, 15), o = Math.random().toString(36).substring(2, 15), l = Math.random().toString(36).substring(2, 15);
697
- return `${e}-${t}-${o}-${l}`;
698
- }
699
- const Ie = B("session", "global"), Ee = () => {
700
- const e = D.get(Ie);
701
- let t;
702
- e.isSet() && (t = e.json());
703
- const o = (d) => e.set({
704
- id: d.id,
705
- isUser: d.isUser,
706
- identifiers: d.identifiers
707
- }), l = {
708
- id: t?.id ?? xe(),
709
- isUser: t?.isUser ?? void 0,
710
- identifiers: t?.identifiers ?? void 0,
711
- setIsUser(d) {
712
- this.isUser = d, o(this);
713
- },
714
- setIdentifier(d, g) {
715
- this.identifiers = { ...this.identifiers, [d]: g }, o(this);
716
- },
717
- removeIdentifier(d) {
718
- this.identifiers && (this.identifiers = Object.fromEntries(
719
- Object.entries(this.identifiers).filter(([g]) => g !== d)
720
- ), this.identifiers = Object.keys(this.identifiers).length ? this.identifiers : void 0, o(this));
721
- }
722
- };
723
- return o(l), l;
724
- }, Ze = () => W() ? Ee() : null;
725
- export {
726
- Ne as a,
727
- Pe as b,
728
- Ye as c,
729
- Ce as d,
730
- He as e,
731
- ze as f,
732
- Xe as g,
733
- Je as h,
734
- Qe as i,
735
- Ze as j,
736
- Ue as k,
737
- Ge as l,
738
- qe as m,
739
- Ke as n,
740
- We as o,
741
- _e as p,
742
- Me as q,
743
- fe as r,
744
- Le as s,
745
- re as t,
746
- Te as u
747
- };