@utk09/ui-observability 0.9.2 → 0.9.3

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 (142) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/batch-D5qvsMQ_.cjs +2 -0
  3. package/dist/batch-D5qvsMQ_.cjs.map +1 -0
  4. package/dist/{batch-4xKzzSCj.js → batch-DDgxg16_.js} +7 -4
  5. package/dist/batch-DDgxg16_.js.map +1 -0
  6. package/dist/bus/bus.d.ts +0 -4
  7. package/dist/{bus-DrixwdiX.js → bus-C6RwKzPW.js} +59 -62
  8. package/dist/bus-C6RwKzPW.js.map +1 -0
  9. package/dist/bus-WPVDFw2y.cjs +2 -0
  10. package/dist/bus-WPVDFw2y.cjs.map +1 -0
  11. package/dist/capture/storm.d.ts +2 -7
  12. package/dist/{console-ChfuJlf9.cjs → console-BSusX_M-.cjs} +2 -2
  13. package/dist/{console-ChfuJlf9.cjs.map → console-BSusX_M-.cjs.map} +1 -1
  14. package/dist/{console-B3vGRW5p.js → console-Dv5GfaNn.js} +3 -3
  15. package/dist/{console-B3vGRW5p.js.map → console-Dv5GfaNn.js.map} +1 -1
  16. package/dist/{constants-Be83LICb.cjs → constants-Cb92egPS.cjs} +2 -2
  17. package/dist/constants-Cb92egPS.cjs.map +1 -0
  18. package/dist/{constants-CQ_D7jIW.js → constants-DhH6VI5a.js} +2 -2
  19. package/dist/constants-DhH6VI5a.js.map +1 -0
  20. package/dist/constants.d.ts +2 -3
  21. package/dist/core/breadcrumbs.d.ts +1 -3
  22. package/dist/core/context.d.ts +0 -8
  23. package/dist/core/diagnostics.d.ts +0 -2
  24. package/dist/core/sampling.d.ts +1 -3
  25. package/dist/deadline-CUrH0Hd8.cjs +2 -0
  26. package/dist/deadline-CUrH0Hd8.cjs.map +1 -0
  27. package/dist/deadline-DeqXEliN.js +31 -0
  28. package/dist/deadline-DeqXEliN.js.map +1 -0
  29. package/dist/{errors-BGs5NOrw.js → errors-DCZWcHkd.js} +4 -4
  30. package/dist/{errors-BGs5NOrw.js.map → errors-DCZWcHkd.js.map} +1 -1
  31. package/dist/{errors-BMJm7KZZ.cjs → errors-ERu-su8m.cjs} +3 -3
  32. package/dist/{errors-BMJm7KZZ.cjs.map → errors-ERu-su8m.cjs.map} +1 -1
  33. package/dist/fixed-window-BR0bu32Y.cjs +2 -0
  34. package/dist/fixed-window-BR0bu32Y.cjs.map +1 -0
  35. package/dist/fixed-window-Re7jIRJH.js +9 -0
  36. package/dist/fixed-window-Re7jIRJH.js.map +1 -0
  37. package/dist/{identity-DXyV86o-.cjs → identity-C1WLItSl.cjs} +2 -2
  38. package/dist/{identity-DXyV86o-.cjs.map → identity-C1WLItSl.cjs.map} +1 -1
  39. package/dist/{identity-rpEyjvVg.js → identity-Di-QXGCC.js} +2 -2
  40. package/dist/{identity-rpEyjvVg.js.map → identity-Di-QXGCC.js.map} +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.js +224 -236
  44. package/dist/index.js.map +1 -1
  45. package/dist/indexeddb-storage-DX18p39D.cjs +2 -0
  46. package/dist/indexeddb-storage-DX18p39D.cjs.map +1 -0
  47. package/dist/{indexeddb-storage-Q9fDYlyn.js → indexeddb-storage-T9YIYVYC.js} +39 -50
  48. package/dist/indexeddb-storage-T9YIYVYC.js.map +1 -0
  49. package/dist/{interactions-B8zjCjga.js → interactions-BLH_tX87.js} +2 -2
  50. package/dist/{interactions-B8zjCjga.js.map → interactions-BLH_tX87.js.map} +1 -1
  51. package/dist/{interactions-BAGRmtrv.cjs → interactions-_hfOerfC.cjs} +2 -2
  52. package/dist/{interactions-BAGRmtrv.cjs.map → interactions-_hfOerfC.cjs.map} +1 -1
  53. package/dist/journey-BRUj0hqD.cjs +2 -0
  54. package/dist/journey-BRUj0hqD.cjs.map +1 -0
  55. package/dist/{journey-_dQQ1eMP.js → journey-yALMEWF7.js} +26 -25
  56. package/dist/journey-yALMEWF7.js.map +1 -0
  57. package/dist/{library-request-BIG3Xpx3.cjs → library-request-BcAxuwsf.cjs} +2 -2
  58. package/dist/{library-request-BIG3Xpx3.cjs.map → library-request-BcAxuwsf.cjs.map} +1 -1
  59. package/dist/{library-request-DX6ev9oG.js → library-request-CQD4HUiP.js} +2 -2
  60. package/dist/{library-request-DX6ev9oG.js.map → library-request-CQD4HUiP.js.map} +1 -1
  61. package/dist/{long-frames-Cq2LgNnp.cjs → long-frames-D4Bm3Zkz.cjs} +2 -2
  62. package/dist/{long-frames-Cq2LgNnp.cjs.map → long-frames-D4Bm3Zkz.cjs.map} +1 -1
  63. package/dist/{long-frames-B0tKuChx.js → long-frames-DD_Um9_4.js} +3 -3
  64. package/dist/{long-frames-B0tKuChx.js.map → long-frames-DD_Um9_4.js.map} +1 -1
  65. package/dist/models/batch.d.ts +6 -0
  66. package/dist/{network-CMnEvGJB.js → network--GoE7_Or.js} +3 -3
  67. package/dist/{network-CMnEvGJB.js.map → network--GoE7_Or.js.map} +1 -1
  68. package/dist/{network-C6kJbW6K.cjs → network-DcuS2H1P.cjs} +2 -2
  69. package/dist/{network-C6kJbW6K.cjs.map → network-DcuS2H1P.cjs.map} +1 -1
  70. package/dist/openfin-BwEN0uj4.js +8 -0
  71. package/dist/openfin-BwEN0uj4.js.map +1 -0
  72. package/dist/openfin-DtH2f7zX.cjs +2 -0
  73. package/dist/openfin-DtH2f7zX.cjs.map +1 -0
  74. package/dist/{platform-j0uMPwHi.js → platform-GaM6h7XM.js} +25 -21
  75. package/dist/platform-GaM6h7XM.js.map +1 -0
  76. package/dist/platform-kIL5AZB7.cjs +2 -0
  77. package/dist/platform-kIL5AZB7.cjs.map +1 -0
  78. package/dist/{remote-rules-UggoZqfP.js → remote-rules-6ePq8CrI.js} +19 -21
  79. package/dist/remote-rules-6ePq8CrI.js.map +1 -0
  80. package/dist/remote-rules-CI3gbRCL.cjs +2 -0
  81. package/dist/remote-rules-CI3gbRCL.cjs.map +1 -0
  82. package/dist/sampling-C-M8p3FK.cjs +2 -0
  83. package/dist/sampling-C-M8p3FK.cjs.map +1 -0
  84. package/dist/sampling-Ud_WiuU9.js +65 -0
  85. package/dist/sampling-Ud_WiuU9.js.map +1 -0
  86. package/dist/{sanitize-BqzPc4Jg.cjs → sanitize--_e4oOPX.cjs} +2 -2
  87. package/dist/{sanitize-BqzPc4Jg.cjs.map → sanitize--_e4oOPX.cjs.map} +1 -1
  88. package/dist/{sanitize-BNwgPj_B.js → sanitize-DP0xDPrt.js} +2 -2
  89. package/dist/{sanitize-BNwgPj_B.js.map → sanitize-DP0xDPrt.js.map} +1 -1
  90. package/dist/sender-BESHz6my.cjs +3 -0
  91. package/dist/sender-BESHz6my.cjs.map +1 -0
  92. package/dist/{sender--0_VzPbN.js → sender-BUBWLn5i.js} +202 -207
  93. package/dist/sender-BUBWLn5i.js.map +1 -0
  94. package/dist/storage/gap.d.ts +20 -0
  95. package/dist/storage/indexeddb-storage.d.ts +1 -7
  96. package/dist/storage/keys.d.ts +9 -0
  97. package/dist/storage/local-storage.d.ts +0 -6
  98. package/dist/storage/memory-storage.d.ts +1 -1
  99. package/dist/storm-DhHGHhOc.cjs +2 -0
  100. package/dist/storm-DhHGHhOc.cjs.map +1 -0
  101. package/dist/storm-OD5J6Ylm.js +10 -0
  102. package/dist/storm-OD5J6Ylm.js.map +1 -0
  103. package/dist/utils/fixed-window.d.ts +15 -0
  104. package/dist/utils/guards.d.ts +6 -0
  105. package/dist/utils/openfin.d.ts +48 -0
  106. package/dist/utils/platform.d.ts +5 -0
  107. package/package.json +2 -3
  108. package/dist/batch-4xKzzSCj.js.map +0 -1
  109. package/dist/batch-cys7e53Q.cjs +0 -2
  110. package/dist/batch-cys7e53Q.cjs.map +0 -1
  111. package/dist/bus-B6vzPmQM.cjs +0 -2
  112. package/dist/bus-B6vzPmQM.cjs.map +0 -1
  113. package/dist/bus-DrixwdiX.js.map +0 -1
  114. package/dist/constants-Be83LICb.cjs.map +0 -1
  115. package/dist/constants-CQ_D7jIW.js.map +0 -1
  116. package/dist/deadline-5_PecIl5.js +0 -26
  117. package/dist/deadline-5_PecIl5.js.map +0 -1
  118. package/dist/deadline-XSnm95pg.cjs +0 -2
  119. package/dist/deadline-XSnm95pg.cjs.map +0 -1
  120. package/dist/indexeddb-storage-BXaPVPyG.cjs +0 -2
  121. package/dist/indexeddb-storage-BXaPVPyG.cjs.map +0 -1
  122. package/dist/indexeddb-storage-Q9fDYlyn.js.map +0 -1
  123. package/dist/journey-BGSyy8Es.cjs +0 -2
  124. package/dist/journey-BGSyy8Es.cjs.map +0 -1
  125. package/dist/journey-_dQQ1eMP.js.map +0 -1
  126. package/dist/platform-DNOJjpOm.cjs +0 -2
  127. package/dist/platform-DNOJjpOm.cjs.map +0 -1
  128. package/dist/platform-j0uMPwHi.js.map +0 -1
  129. package/dist/remote-rules-DgoBJxZL.cjs +0 -2
  130. package/dist/remote-rules-DgoBJxZL.cjs.map +0 -1
  131. package/dist/remote-rules-UggoZqfP.js.map +0 -1
  132. package/dist/sampling-BLMD8EGM.js +0 -64
  133. package/dist/sampling-BLMD8EGM.js.map +0 -1
  134. package/dist/sampling-MthcVXXU.cjs +0 -2
  135. package/dist/sampling-MthcVXXU.cjs.map +0 -1
  136. package/dist/sender--0_VzPbN.js.map +0 -1
  137. package/dist/sender-SPGMqZjD.cjs +0 -3
  138. package/dist/sender-SPGMqZjD.cjs.map +0 -1
  139. package/dist/storm-CTy1dfvs.cjs +0 -2
  140. package/dist/storm-CTy1dfvs.cjs.map +0 -1
  141. package/dist/storm-knaj4GUH.js +0 -10
  142. package/dist/storm-knaj4GUH.js.map +0 -1
@@ -1,13 +1,15 @@
1
- import { $ as e, B as t, Ct as n, Dt as r, Ft as i, H as a, Ht as o, Jt as s, Lt as c, M as l, N as u, Ot as d, P as f, Pt as p, Q as m, St as ee, U as h, Vt as te, X as g, Xt as _, Y as ne, Yt as v, Z as re, an as ie, bt as ae, d as oe, dn as se, en as y, et as ce, fn as b, gn as x, hn as S, ht as le, ln as ue, on as C, un as de, vt as w, x as T } from "./constants-CQ_D7jIW.js";
2
- import { o as fe, t as pe } from "./sampling-BLMD8EGM.js";
3
- import { o as me, t as E } from "./sanitize-BNwgPj_B.js";
4
- import { i as he } from "./identity-rpEyjvVg.js";
5
- import { i as ge, n as _e, r as D, t as ve } from "./batch-4xKzzSCj.js";
6
- import { i as ye, r as O } from "./library-request-DX6ev9oG.js";
7
- import { n as k, r as A, t as be } from "./deadline-5_PecIl5.js";
8
- import { n as xe, t as Se } from "./remote-rules-UggoZqfP.js";
1
+ import { $ as e, B as t, Ct as n, Dt as r, Ft as i, H as a, Ht as o, Jt as s, Lt as c, M as l, N as u, Ot as d, P as f, Pt as p, Q as m, St as ee, U as h, Vt as te, X as g, Xt as _, Y as ne, Yt as v, Z as re, an as ie, bt as ae, d as oe, dn as se, en as y, et as ce, fn as b, gn as x, hn as S, ht as le, ln as ue, on as C, un as de, vt as w, x as T } from "./constants-DhH6VI5a.js";
2
+ import { n as E, r as D, t as fe } from "./deadline-DeqXEliN.js";
3
+ import { o as pe, t as me } from "./sampling-Ud_WiuU9.js";
4
+ import { o as he, t as O } from "./sanitize-DP0xDPrt.js";
5
+ import { i as ge } from "./identity-Di-QXGCC.js";
6
+ import { t as k } from "./openfin-BwEN0uj4.js";
7
+ import { r as _e } from "./platform-GaM6h7XM.js";
8
+ import { a as ve, i as A, n as j, r as ye, t as be } from "./batch-DDgxg16_.js";
9
+ import { i as xe, r as M } from "./library-request-CQD4HUiP.js";
10
+ import { n as Se, t as Ce } from "./remote-rules-6ePq8CrI.js";
9
11
  //#region src/models/storage.ts
10
- function j(e) {
12
+ function N(e) {
11
13
  let { maxBatches: t } = e;
12
14
  return e.mode === "until-delivered" ? {
13
15
  maxBatches: t,
@@ -21,13 +23,16 @@ function j(e) {
21
23
  }
22
24
  //#endregion
23
25
  //#region src/utils/lock.ts
24
- function M(e, t, n, { skipIfBusy: r = !0 } = {}) {
26
+ function P(e, t, n, { skipIfBusy: r = !0 } = {}) {
25
27
  let i = globalThis.navigator?.locks;
26
28
  return i?.request ? t.guardAsync("storage.degraded", `The library could not get the lock ${e}.`, () => i.request(e, { ifAvailable: r }, (e) => e ? n() : Promise.resolve(void 0))) : n();
27
29
  }
28
30
  //#endregion
29
31
  //#region src/storage/keys.ts
30
- function N(e, t) {
32
+ function F(e, t) {
33
+ return `${e}${String(t.createdAt).padStart(14, "0")}.${t.id}`;
34
+ }
35
+ function I(e, t) {
31
36
  let n = [];
32
37
  return t.guard("storage.unavailable", "The library could not list the localStorage keys.", () => {
33
38
  for (let t = 0; t < localStorage.length; t++) {
@@ -38,39 +43,35 @@ function N(e, t) {
38
43
  }
39
44
  //#endregion
40
45
  //#region src/storage/emergency-queue.ts
41
- function Ce(e) {
42
- let t = String(e.createdAt).padStart(14, "0");
43
- return `${a}${t}.${e.id}`;
44
- }
45
- function P(e, t) {
46
+ function L(e, t) {
46
47
  let n = t.guard("storage.degraded", "An emergency entry is not valid JSON. The library dropped it.", () => JSON.parse(e));
47
- return n === void 0 ? null : D(n) ? n : (t.report("storage.degraded", "An emergency entry is not a batch. The library dropped it."), null);
48
+ return n === void 0 ? null : A(n) ? n : (t.report("storage.degraded", "An emergency entry is not a batch. The library dropped it."), null);
48
49
  }
49
50
  async function we(e, t) {
50
51
  let n = 0;
51
- for (let r of N(a, t)) {
52
+ for (let r of I(a, t)) {
52
53
  let i = t.guard("storage.unavailable", "The library could not read the emergency queue.", () => {
53
54
  let e = localStorage.getItem(r);
54
55
  return localStorage.removeItem(r), e;
55
56
  });
56
57
  if (!i) continue;
57
- let a = P(i, t);
58
+ let a = L(i, t);
58
59
  if (a !== null) try {
59
- await k(e.save(a), C), n++;
60
+ await E(e.save(a), C), n++;
60
61
  } catch (e) {
61
62
  t.report("storage.degraded", "The library could not recover an emergency batch.", { key: r }, e);
62
63
  }
63
64
  }
64
65
  return n;
65
66
  }
66
- function F(e, t, n) {
67
+ function R(e, t, n) {
67
68
  let r = `writing the emergency queue, ${String(e.records.length)} records`, i = [], o = t.guard("storage.quota_exceeded", r, () => {
68
- let n = N(a, t);
69
+ let n = I(a, t);
69
70
  for (let e of n.slice(0, Math.max(0, n.length - 20 + 1))) {
70
- let n = P(String(localStorage.getItem(e)), t);
71
+ let n = L(String(localStorage.getItem(e)), t);
71
72
  n !== null && i.push(n), localStorage.removeItem(e);
72
73
  }
73
- return localStorage.setItem(Ce(e), JSON.stringify(e)), !0;
74
+ return localStorage.setItem(F(a, e), JSON.stringify(e)), !0;
74
75
  });
75
76
  t.guard("pipeline.crashed", "The loss report of the emergency queue failed.", () => {
76
77
  if (i.length > 0) {
@@ -81,14 +82,14 @@ function F(e, t, n) {
81
82
  });
82
83
  }
83
84
  async function Te(e, t) {
84
- return await M("ui-observability.emergency", t, () => we(e, t), { skipIfBusy: !1 }) ?? 0;
85
+ return await P("ui-observability.emergency", t, () => we(e, t), { skipIfBusy: !1 }) ?? 0;
85
86
  }
86
87
  //#endregion
87
88
  //#region src/storage/eviction.ts
88
- function I(e) {
89
- return Array.isArray(e.records) && e.records.some(_e);
89
+ function z(e) {
90
+ return Array.isArray(e.records) && e.records.some(ye);
90
91
  }
91
- var L = class {
92
+ var B = class {
92
93
  howMany;
93
94
  isAudit;
94
95
  plain = [];
@@ -103,22 +104,30 @@ var L = class {
103
104
  return [...this.plain, ...this.audit].slice(0, this.howMany);
104
105
  }
105
106
  };
106
- function R(e, t, n) {
107
- let r = new L(t, n);
107
+ function V(e, t, n) {
108
+ let r = new B(t, n);
108
109
  for (let t of e) if (!r.add(t)) break;
109
110
  return r.picked();
110
111
  }
111
112
  //#endregion
113
+ //#region src/storage/gap.ts
114
+ function H(e, t, n, r) {
115
+ return e.batches += n, e.records += r, e.reason = t, {
116
+ batches: n,
117
+ records: r,
118
+ reason: t
119
+ };
120
+ }
121
+ function U(e, t, n, r) {
122
+ n.batches !== 0 && (e.report("storage.evicted", `The library dropped ${String(n.batches)} stored batches (${String(n.records)} records).`, { ...n }), t?.(n, r));
123
+ }
124
+ //#endregion
112
125
  //#region src/storage/local-storage.ts
113
126
  function Ee(e) {
114
- let t = String(e.createdAt).padStart(14, "0");
115
- return `${T}${t}.${e.id}`;
116
- }
117
- function De(e) {
118
127
  let t = T.length, n = Number(e.slice(t, t + 14));
119
128
  return Number.isFinite(n) ? n : null;
120
129
  }
121
- var Oe = class {
130
+ var De = class {
122
131
  limits;
123
132
  diagnostics;
124
133
  onGap;
@@ -127,11 +136,15 @@ var Oe = class {
127
136
  this.limits = e, this.diagnostics = t, this.onGap = n;
128
137
  }
129
138
  async save(e) {
130
- this.write(e, "localStorage refused a batch, evicting the oldest") ? await this.prune() : (this.evictForQuota(), this.write(e, "localStorage refused a batch even after evicting") || this.reportGap({
131
- batches: 1,
132
- records: e.records.length,
133
- reason: "quota"
134
- }, [e]));
139
+ if (this.write(e, "localStorage refused a batch, evicting the oldest")) await this.prune();
140
+ else if (this.evictForQuota(), !this.write(e, "localStorage refused a batch even after evicting")) {
141
+ let t = {
142
+ batches: 1,
143
+ records: e.records.length,
144
+ reason: "quota"
145
+ };
146
+ U(this.diagnostics, this.onGap, t, [e]);
147
+ }
135
148
  }
136
149
  take(e) {
137
150
  let t = [];
@@ -160,7 +173,7 @@ var Oe = class {
160
173
  reason: "expired"
161
174
  }, n = [], r = [];
162
175
  for (let t of this.keys()) {
163
- let i = De(t);
176
+ let i = Ee(t);
164
177
  i === null || i < e ? n.push(t) : r.push(t);
165
178
  }
166
179
  this.drop(t, "expired", [...this.entries(n)]);
@@ -177,7 +190,7 @@ var Oe = class {
177
190
  return Promise.resolve();
178
191
  }
179
192
  write(e, t) {
180
- return this.diagnostics.guard("storage.quota_exceeded", t, () => (localStorage.setItem(Ee(e), JSON.stringify(e)), !0)) === !0;
193
+ return this.diagnostics.guard("storage.quota_exceeded", t, () => (localStorage.setItem(F(T, e), JSON.stringify(e)), !0)) === !0;
181
194
  }
182
195
  evictForQuota() {
183
196
  let e = this.keys(), t = {
@@ -188,7 +201,7 @@ var Oe = class {
188
201
  this.drop(t, "quota", this.evictable(e, n));
189
202
  }
190
203
  evictable(e, t) {
191
- return R(this.entries(e), t, (e) => e.batch !== null && I(e.batch));
204
+ return V(this.entries(e), t, (e) => e.batch !== null && z(e.batch));
192
205
  }
193
206
  *entries(e) {
194
207
  for (let t of e) yield {
@@ -198,22 +211,16 @@ var Oe = class {
198
211
  }
199
212
  drop(e, t, n) {
200
213
  if (n.length === 0) return;
201
- let r = [], i = 0;
202
- for (let { key: e, batch: t } of n) this.removeKey(e), i += t?.records.length ?? 0, t && r.push(t);
203
- e.batches += n.length, e.records += i, e.reason = t, this.reportGap({
204
- batches: n.length,
205
- records: i,
206
- reason: t
207
- }, r);
208
- }
209
- reportGap(e, t) {
210
- this.diagnostics.report("storage.evicted", `The library dropped ${String(e.batches)} stored batches (${String(e.records)} records).`, { ...e }), this.onGap?.(e, t);
214
+ let r = [];
215
+ for (let { key: e, batch: t } of n) this.removeKey(e), t && r.push(t);
216
+ let i = H(e, t, n.length, j(r));
217
+ U(this.diagnostics, this.onGap, i, r);
211
218
  }
212
219
  read(e) {
213
220
  let t = this.diagnostics.guard("storage.unavailable", "The library could not read a stored batch.", () => localStorage.getItem(e));
214
221
  if (!t) return null;
215
222
  let n = this.diagnostics.guard("storage.degraded", "A stored batch is corrupt. The library removed it.", () => JSON.parse(t));
216
- return n === void 0 ? null : D(n) ? n : (this.diagnostics.report("storage.degraded", "A stored entry is not a batch. The library dropped it."), null);
223
+ return n === void 0 ? null : A(n) ? n : (this.diagnostics.report("storage.degraded", "A stored entry is not a batch. The library dropped it."), null);
217
224
  }
218
225
  keyOf(e) {
219
226
  return this.keys().find((t) => t.endsWith(`.${e}`)) ?? null;
@@ -227,15 +234,9 @@ var Oe = class {
227
234
  });
228
235
  }
229
236
  keys() {
230
- return N(T, this.diagnostics);
237
+ return I(T, this.diagnostics);
231
238
  }
232
- };
233
- //#endregion
234
- //#region src/storage/memory-storage.ts
235
- function ke(e) {
236
- return e.reduce((e, t) => e + t.records.length, 0);
237
- }
238
- var z = class {
239
+ }, W = class {
239
240
  limits;
240
241
  onGap;
241
242
  name = de;
@@ -265,19 +266,15 @@ var z = class {
265
266
  this.batches = this.batches.filter((t) => t.createdAt >= e), this.report(t, "expired", n);
266
267
  let r = this.batches.length - this.limits.maxBatches;
267
268
  if (r > 0) {
268
- let e = R(this.batches, r, I);
269
+ let e = V(this.batches, r, z);
269
270
  this.batches = this.batches.filter((t) => !e.includes(t)), this.report(t, "over_capacity", e);
270
271
  }
271
272
  return Promise.resolve(t);
272
273
  }
273
274
  report(e, t, n) {
274
275
  if (n.length === 0) return;
275
- let r = ke(n);
276
- e.batches += n.length, e.records += r, e.reason = t, this.onGap?.({
277
- batches: n.length,
278
- records: r,
279
- reason: t
280
- }, n);
276
+ let r = H(e, t, n.length, j(n));
277
+ this.onGap?.(r, n);
281
278
  }
282
279
  count() {
283
280
  return Promise.resolve(this.batches.length);
@@ -288,7 +285,7 @@ var z = class {
288
285
  close() {
289
286
  return this.batches = [], Promise.resolve();
290
287
  }
291
- }, Ae = (e) => ({
288
+ }, Oe = (e) => ({
292
289
  name: se,
293
290
  save: (t) => (e?.({
294
291
  batches: 1,
@@ -307,30 +304,30 @@ var z = class {
307
304
  clear: () => Promise.resolve(),
308
305
  close: () => Promise.resolve()
309
306
  });
310
- function je(e) {
307
+ function ke(e) {
311
308
  return e.guard("storage.unavailable", "The library could not read indexedDB.", () => globalThis.indexedDB != null) === !0;
312
309
  }
313
- function Me(e) {
310
+ function Ae(e) {
314
311
  return e.guard("storage.unavailable", "The library could not write a test key to localStorage.", () => (localStorage.setItem(b, "1"), localStorage.removeItem(b), !0)) === !0;
315
312
  }
316
- async function Ne(e, t, n, r, i) {
317
- if (e === "none") return Ae(i);
318
- if (e === "memory") return new z(n, i);
313
+ async function je(e, t, n, r, i) {
314
+ if (e === "none") return Oe(i);
315
+ if (e === "memory") return new W(n, i);
319
316
  if (e === "indexeddb" || e === "auto") {
320
- if (je(r)) {
317
+ if (ke(r)) {
321
318
  let e = await r.guardAsync("storage.unavailable", "The library could not open IndexedDB.", async () => {
322
- let { IndexedDbStorage: e } = await import("./indexeddb-storage-Q9fDYlyn.js"), a = new e(t, n, r, i);
319
+ let { IndexedDbStorage: e } = await import("./indexeddb-storage-T9YIYVYC.js"), a = new e(t, n, r, i);
323
320
  return await a.open(), a;
324
321
  });
325
322
  if (e) return e;
326
323
  }
327
- if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB is not available. The library uses memory storage instead."), new z(n, i);
324
+ if (e === "indexeddb") return r.report("storage.degraded", "IndexedDB is not available. The library uses memory storage instead."), new W(n, i);
328
325
  }
329
- return Me(r) ? new Oe(n, r, i) : (r.report("storage.degraded", "No persistent storage is available. The library keeps undelivered records in memory only."), new z(n, i));
326
+ return Ae(r) ? new De(n, r, i) : (r.report("storage.degraded", "No persistent storage is available. The library keeps undelivered records in memory only."), new W(n, i));
330
327
  }
331
328
  //#endregion
332
329
  //#region src/transport/errors.ts
333
- var B = class extends Error {
330
+ var G = class extends Error {
334
331
  kind;
335
332
  status;
336
333
  retryAfterMs;
@@ -339,7 +336,7 @@ var B = class extends Error {
339
336
  super(t, a === void 0 ? void 0 : { cause: a }), this.kind = e, this.status = n, this.retryAfterMs = r, this.maxBytes = i, this.name = "TransportError";
340
337
  }
341
338
  };
342
- function Pe(e) {
339
+ function Me(e) {
343
340
  if (!e) return;
344
341
  let t = Number(e);
345
342
  if (Number.isFinite(t)) return Math.max(0, t * ae);
@@ -348,36 +345,36 @@ function Pe(e) {
348
345
  }
349
346
  //#endregion
350
347
  //#region src/transport/serializers/ecs.ts
351
- function Fe(e) {
348
+ function Ne(e) {
352
349
  return ee.test(e) ? Number(BigInt(e) / n) : Date.now();
353
350
  }
354
- function Ie(e) {
351
+ function Pe(e) {
355
352
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? e : typeof e == "bigint" ? e.toString() : null;
356
353
  }
357
- function Le(e, t, n) {
354
+ function Fe(e, t, n) {
358
355
  let r = e[t];
359
356
  r === void 0 ? e[t] = n : Array.isArray(r) ? r.push(n) : e[t] = [r, n];
360
357
  }
361
- function V(e, t, n, r) {
362
- let i = Ie(n);
363
- if (i !== null) Le(e, t, i);
358
+ function K(e, t, n, r) {
359
+ let i = Pe(n);
360
+ if (i !== null) Fe(e, t, i);
364
361
  else if (typeof n == "object" && n && !r.has(n)) {
365
- if (r.add(n), Array.isArray(n)) for (let i of n) V(e, t, i, r);
366
- else for (let [i, a] of Object.entries(n)) V(e, `${t}.${i}`, a, r);
362
+ if (r.add(n), Array.isArray(n)) for (let i of n) K(e, t, i, r);
363
+ else for (let [i, a] of Object.entries(n)) K(e, `${t}.${i}`, a, r);
367
364
  r.delete(n);
368
365
  }
369
366
  }
370
- function H(e) {
367
+ function q(e) {
371
368
  let t = Object.create(null), n = /* @__PURE__ */ new WeakSet();
372
- for (let [r, i] of Object.entries(e)) V(t, r, i, n);
369
+ for (let [r, i] of Object.entries(e)) K(t, r, i, n);
373
370
  return t;
374
371
  }
375
- var Re = {
372
+ var Ie = {
376
373
  name: "ecs",
377
374
  serialize(e) {
378
375
  return {
379
376
  body: `${e.map((e) => {
380
- let n = Fe(e.timeUnixNano);
377
+ let n = Ne(e.timeUnixNano);
381
378
  return JSON.stringify({
382
379
  "@timestamp": new Date(n).toISOString(),
383
380
  message: e.body,
@@ -392,8 +389,8 @@ var Re = {
392
389
  user_agent: { original: e.resource[i] },
393
390
  url: { full: e.attributes["url.full"] ?? e.attributes["page.url"] },
394
391
  labels: {
395
- ...H(e.resource),
396
- ...H(e.attributes)
392
+ ...q(e.resource),
393
+ ...q(e.attributes)
397
394
  }
398
395
  });
399
396
  }).join("\n")}\n`,
@@ -403,13 +400,13 @@ var Re = {
403
400
  };
404
401
  //#endregion
405
402
  //#region src/transport/serializers/otlp.ts
406
- function U(e) {
407
- return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isSafeInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(U).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: W(e) } } : null;
403
+ function J(e) {
404
+ return e == null ? null : typeof e == "string" ? { stringValue: e } : typeof e == "boolean" ? { boolValue: e } : typeof e == "number" ? Number.isSafeInteger(e) ? { intValue: String(e) } : { doubleValue: e } : typeof e == "bigint" ? { intValue: e.toString() } : Array.isArray(e) ? { arrayValue: { values: e.map(J).filter((e) => e !== null) } } : typeof e == "object" ? { kvlistValue: { values: Y(e) } } : null;
408
405
  }
409
- function W(e) {
406
+ function Y(e) {
410
407
  let t = [];
411
408
  for (let [n, r] of Object.entries(e)) {
412
- let e = U(r);
409
+ let e = J(r);
413
410
  e && t.push({
414
411
  key: n,
415
412
  value: e
@@ -417,17 +414,17 @@ function W(e) {
417
414
  }
418
415
  return t;
419
416
  }
420
- var G = /* @__PURE__ */ new WeakMap();
421
- function ze(e) {
422
- let t = G.get(e);
417
+ var Le = /* @__PURE__ */ new WeakMap();
418
+ function Re(e) {
419
+ let t = Le.get(e);
423
420
  if (t !== void 0) return t;
424
421
  let n = JSON.stringify(e);
425
- return G.set(e, n), n;
422
+ return Le.set(e, n), n;
426
423
  }
427
- function K(e) {
424
+ function ze(e) {
428
425
  let t = /* @__PURE__ */ new Map();
429
426
  for (let n of e) {
430
- let e = ze(n.resource), r = t.get(e);
427
+ let e = Re(n.resource), r = t.get(e);
431
428
  r ? r.records.push(n) : t.set(e, {
432
429
  resource: n.resource,
433
430
  records: [n]
@@ -438,8 +435,8 @@ function K(e) {
438
435
  var Be = {
439
436
  name: y,
440
437
  serialize(e) {
441
- let t = K(e).map((e) => ({
442
- resource: { attributes: W(e.resource) },
438
+ let t = ze(e).map((e) => ({
439
+ resource: { attributes: Y(e.resource) },
443
440
  scopeLogs: [{
444
441
  scope: {
445
442
  name: S,
@@ -454,7 +451,7 @@ var Be = {
454
451
  traceId: e.traceId,
455
452
  spanId: e.spanId,
456
453
  flags: e.traceFlags,
457
- attributes: W(e.attributes)
454
+ attributes: Y(e.attributes)
458
455
  }))
459
456
  }]
460
457
  }));
@@ -464,14 +461,14 @@ var Be = {
464
461
  };
465
462
  }
466
463
  }, Ve = 1;
467
- function q(e, t) {
464
+ function X(e, t) {
468
465
  let n = e.attributes[t];
469
466
  return typeof n == "number" && Number.isFinite(n) ? n : void 0;
470
467
  }
471
- function J(e) {
468
+ function He(e) {
472
469
  return Array.isArray(e) && e.every((e) => typeof e == "number" && Number.isFinite(e));
473
470
  }
474
- function He(e) {
471
+ function Ue(e) {
475
472
  let t = e.attributes[w.attributeKeys], n = {};
476
473
  if (!Array.isArray(t)) return n;
477
474
  for (let r of t) {
@@ -480,10 +477,10 @@ function He(e) {
480
477
  }
481
478
  return n;
482
479
  }
483
- function Ue(e) {
484
- let t = q(e, w.count);
480
+ function We(e) {
481
+ let t = X(e, w.count);
485
482
  if (t === void 0) {
486
- let t = q(e, "metric.value");
483
+ let t = X(e, "metric.value");
487
484
  return t === void 0 ? null : {
488
485
  count: "1",
489
486
  sum: t < 0 ? void 0 : t,
@@ -494,31 +491,31 @@ function Ue(e) {
494
491
  };
495
492
  }
496
493
  let n = e.attributes[w.bounds], r = e.attributes[w.buckets];
497
- if (!J(n) || !J(r) || r.length !== n.length + 1) return null;
498
- let i = q(e, w.min);
494
+ if (!He(n) || !He(r) || r.length !== n.length + 1) return null;
495
+ let i = X(e, w.min);
499
496
  return {
500
497
  count: String(t),
501
- sum: i !== void 0 && i < 0 ? void 0 : q(e, w.sum),
498
+ sum: i !== void 0 && i < 0 ? void 0 : X(e, w.sum),
502
499
  min: i,
503
- max: q(e, w.max),
500
+ max: X(e, w.max),
504
501
  bucketCounts: r.map(String),
505
502
  explicitBounds: n
506
503
  };
507
504
  }
508
- function We(e) {
509
- let t = q(e, "metric.value");
505
+ function Ge(e) {
506
+ let t = X(e, "metric.value");
510
507
  return t === void 0 ? null : { asDouble: t };
511
508
  }
512
- function Ge(e, t) {
513
- let n = e.attributes[w.start], r = t === "histogram" ? Ue(e) : We(e);
509
+ function Ke(e, t) {
510
+ let n = e.attributes[w.start], r = t === "histogram" ? We(e) : Ge(e);
514
511
  return r === null ? null : {
515
- attributes: W(He(e)),
512
+ attributes: Y(Ue(e)),
516
513
  startTimeUnixNano: typeof n == "string" ? n : e.timeUnixNano,
517
514
  timeUnixNano: e.timeUnixNano,
518
515
  ...r
519
516
  };
520
517
  }
521
- function Ke({ name: e, unit: t, field: n, points: r }) {
518
+ function qe({ name: e, unit: t, field: n, points: r }) {
522
519
  if (n === "gauge") return {
523
520
  name: e,
524
521
  unit: t,
@@ -534,13 +531,13 @@ function Ke({ name: e, unit: t, field: n, points: r }) {
534
531
  [n]: i
535
532
  };
536
533
  }
537
- var qe = {
534
+ var Je = {
538
535
  name: y,
539
536
  serialize(e) {
540
- let t = K(e).map((e) => {
537
+ let t = ze(e).map((e) => {
541
538
  let t = /* @__PURE__ */ new Map();
542
539
  for (let n of e.records) {
543
- let e = n.attributes["metric.type"], r = e === "counter" ? "sum" : e === "histogram" ? "histogram" : "gauge", i = Ge(n, r);
540
+ let e = n.attributes["metric.type"], r = e === "counter" ? "sum" : e === "histogram" ? "histogram" : "gauge", i = Ke(n, r);
544
541
  if (i === null) continue;
545
542
  let a = n.attributes["metric.name"], o = n.attributes["metric.unit"], s = {
546
543
  name: typeof a == "string" ? a : n.body,
@@ -555,13 +552,13 @@ var qe = {
555
552
  l.points.push(i), t.set(c, l);
556
553
  }
557
554
  return {
558
- resource: { attributes: W(e.resource) },
555
+ resource: { attributes: Y(e.resource) },
559
556
  scopeMetrics: [{
560
557
  scope: {
561
558
  name: S,
562
559
  version: x
563
560
  },
564
- metrics: [...t.values()].map(Ke)
561
+ metrics: [...t.values()].map(qe)
565
562
  }]
566
563
  };
567
564
  });
@@ -573,18 +570,18 @@ var qe = {
573
570
  };
574
571
  //#endregion
575
572
  //#region src/transport/serializers/select.ts
576
- function Je(e) {
577
- return e === "otlp" ? Be : e === "ecs" ? Re : e;
573
+ function Ye(e) {
574
+ return e === "otlp" ? Be : e === "ecs" ? Ie : e;
578
575
  }
579
- function Y(e, t) {
580
- return t.metricsEndpoint !== "" && e.records.length > 0 && e.records.every((e) => ve(e, "log.type") === "metric") ? "metrics" : "logs";
576
+ function Z(e, t) {
577
+ return t.metricsEndpoint !== "" && e.records.length > 0 && e.records.every((e) => be(e, "log.type") === "metric") ? "metrics" : "logs";
581
578
  }
582
- function X(e, t) {
579
+ function Xe(e, t) {
583
580
  return e === "metrics" ? t.metricsEndpoint : t.endpoint;
584
581
  }
585
- function Z(e, t, n, r) {
582
+ function Ze(e, t, n, r) {
586
583
  try {
587
- return (Y(t, e) === "metrics" ? qe : Je(e.serializer)).serialize(t.records);
584
+ return (Z(t, e) === "metrics" ? Je : Ye(e.serializer)).serialize(t.records);
588
585
  } catch (e) {
589
586
  n.report("transport.serialize_failed", r, { batchId: t.id }, e);
590
587
  return;
@@ -592,7 +589,7 @@ function Z(e, t, n, r) {
592
589
  }
593
590
  //#endregion
594
591
  //#region src/transport/status-transport.ts
595
- var Ye = class {
592
+ var Qe = class {
596
593
  config;
597
594
  diagnostics;
598
595
  onSampling;
@@ -605,10 +602,10 @@ var Ye = class {
605
602
  this.config = e, this.diagnostics = t, this.onSampling = n, this.onLoss = r;
606
603
  }
607
604
  throttledForMs(e) {
608
- return Math.max(0, this.throttledUntil[Y(e, this.config)] - Date.now());
605
+ return Math.max(0, this.throttledUntil[Z(e, this.config)] - Date.now());
609
606
  }
610
607
  serialize(e) {
611
- let t = Z(this.config, e, this.diagnostics, "The serializer threw an error. The library dropped the batch.");
608
+ let t = Ze(this.config, e, this.diagnostics, "The serializer threw an error. The library dropped the batch.");
612
609
  return t || this.onLoss("unserializable", e.records, [e.id]), t;
613
610
  }
614
611
  accept(e, t) {
@@ -620,23 +617,23 @@ var Ye = class {
620
617
  let t = r.advice === void 0 ? "" : ` ${r.advice}`;
621
618
  return this.diagnostics.report("transport.rejected_credentials", `The server returned ${i}.${t}`, {
622
619
  status: e,
623
- endpoint: X(n, this.config)
624
- }), new B("permanent", `The server rejected the batch with ${i}.`, e);
620
+ endpoint: Xe(n, this.config)
621
+ }), new G("permanent", `The server rejected the batch with ${i}.`, e);
625
622
  }
626
- if (e === 413) return new B("too_large", "The payload is too large.", e, void 0, r.maxBytes);
623
+ if (e === 413) return new G("too_large", "The payload is too large.", e, void 0, r.maxBytes);
627
624
  if (e === 429 || e === 503) {
628
625
  let t = e === 429, i = r.retryAfterMs === void 0 ? void 0 : Math.min(r.retryAfterMs, _);
629
- return this.throttledUntil[n] = Date.now() + (i ?? 2e3), t && this.diagnostics.report("transport.throttled", "The server throttles the requests.", { retryAfterMs: i }), new B("throttled", t ? "The server throttles the requests." : "The service is not available.", e, i);
626
+ return this.throttledUntil[n] = Date.now() + (i ?? 2e3), t && this.diagnostics.report("transport.throttled", "The server throttles the requests.", { retryAfterMs: i }), new G("throttled", t ? "The server throttles the requests." : "The service is not available.", e, i);
630
627
  }
631
- return e === 408 || e >= 500 ? new B("transient", `The server returned the error ${i}.`, e) : (this.diagnostics.report("transport.dropped_permanent", `The server rejected the batch with ${i}. The library dropped it.`, {
628
+ return e === 408 || e >= 500 ? new G("transient", `The server returned the error ${i}.`, e) : (this.diagnostics.report("transport.dropped_permanent", `The server rejected the batch with ${i}. The library dropped it.`, {
632
629
  batchId: t,
633
630
  status: e
634
- }), new B("permanent", `The server rejected the batch with ${i}.`, e));
631
+ }), new G("permanent", `The server rejected the batch with ${i}.`, e));
635
632
  }
636
633
  };
637
634
  //#endregion
638
635
  //#region src/transport/custom-transport.ts
639
- function Xe(e, t, n) {
636
+ function $e(e, t, n) {
640
637
  return {
641
638
  kind: n,
642
639
  body: t.body,
@@ -646,36 +643,36 @@ function Xe(e, t, n) {
646
643
  records: e.records
647
644
  };
648
645
  }
649
- function Ze(e) {
646
+ function et(e) {
650
647
  if (typeof e != "object" || !e) return !1;
651
648
  let t = Reflect.get(e, "status");
652
649
  return typeof t == "number" && Number.isInteger(t) && t >= 100 && t <= 599;
653
650
  }
654
- function Qe(e) {
651
+ function tt(e) {
655
652
  return typeof e == "number" && Number.isFinite(e) ? Math.max(0, e) : void 0;
656
653
  }
657
- var $e = class extends Ye {
654
+ var nt = class extends Qe {
658
655
  async send(e) {
659
656
  let { transport: t } = this.config;
660
657
  if (!t || e.records.length === 0) return;
661
658
  let n = this.serialize(e);
662
659
  if (!n) return;
663
- let r = Y(e, this.config), i = Xe(e, n, r), a;
660
+ let r = Z(e, this.config), i = $e(e, n, r), a;
664
661
  try {
665
- a = await k(ye(() => O(() => me(() => t(i)))), p);
662
+ a = await E(xe(() => M(() => he(() => t(i)))), p);
666
663
  } catch (e) {
667
- let t = e instanceof be ? e : void 0;
668
- throw new B(t ? "timeout" : "transient", t?.message ?? "The custom transport failed.", void 0, void 0, void 0, e);
664
+ let t = e instanceof fe ? e : void 0;
665
+ throw new G(t ? "timeout" : "transient", t?.message ?? "The custom transport failed.", void 0, void 0, void 0, e);
669
666
  }
670
- if (!Ze(a)) throw this.diagnostics.report("transport.http_error", "The custom transport returned no valid status. The library sends the batch again later.", { batchId: e.id }), new B("transient", "The custom transport returned no valid status.");
667
+ if (!et(a)) throw this.diagnostics.report("transport.http_error", "The custom transport returned no valid status. The library sends the batch again later.", { batchId: e.id }), new G("transient", "The custom transport returned no valid status.");
671
668
  let { status: o } = a;
672
669
  if (o >= 200 && o < 300) this.accept(r, a.sampling);
673
670
  else throw this.reject(o, e.id, r, {
674
- retryAfterMs: Qe(a.retryAfterMs),
675
- maxBytes: Qe(a.maxBytes)
671
+ retryAfterMs: tt(a.retryAfterMs),
672
+ maxBytes: tt(a.maxBytes)
676
673
  });
677
674
  }
678
- }, et = class {
675
+ }, rt = class {
679
676
  deps;
680
677
  installed = !1;
681
678
  keepaliveBytes = 0;
@@ -697,7 +694,7 @@ var $e = class extends Ye {
697
694
  install() {
698
695
  if (this.installed || typeof addEventListener > "u") return;
699
696
  this.installed = !0, typeof document < "u" && (document.addEventListener("visibilitychange", this.onVisibility), document.addEventListener("freeze", this.onFreeze)), addEventListener("pagehide", this.onPageHide);
700
- let e = globalThis.fin?.me;
697
+ let e = k()?.me;
701
698
  this.deps.diagnostics.guard("openfin.unavailable", "The library could not subscribe to close-requested.", () => {
702
699
  e?.on?.("close-requested", this.onOpenFinClose);
703
700
  });
@@ -705,7 +702,7 @@ var $e = class extends Ye {
705
702
  uninstall() {
706
703
  if (!this.installed) return;
707
704
  this.installed = !1, typeof document < "u" && (document.removeEventListener("visibilitychange", this.onVisibility), document.removeEventListener("freeze", this.onFreeze)), removeEventListener("pagehide", this.onPageHide);
708
- let e = globalThis.fin?.me;
705
+ let e = k()?.me;
709
706
  this.deps.diagnostics.guard("openfin.unavailable", "The library could not unsubscribe from close-requested.", () => {
710
707
  e?.removeListener?.("close-requested", this.onOpenFinClose);
711
708
  });
@@ -726,7 +723,7 @@ var $e = class extends Ye {
726
723
  if (r !== null) {
727
724
  this.keepaliveBytes = 0;
728
725
  for (let n of this.deps.drainForExit()) {
729
- let i = Y(n, t) === "metrics" ? t.metricsEndpoint : r.href;
726
+ let i = Z(n, t) === "metrics" ? t.metricsEndpoint : r.href;
730
727
  this.flushBatch(n, e, new URL(i));
731
728
  }
732
729
  }
@@ -736,8 +733,8 @@ var $e = class extends Ye {
736
733
  if (e.records.length === 0) return;
737
734
  let o = this.serialize(e, t);
738
735
  if (!o) return;
739
- if (E(o.body) > 6e4) {
740
- F(e, a, this.deps.onLoss);
736
+ if (O(o.body) > 6e4) {
737
+ R(e, a, this.deps.onLoss);
741
738
  return;
742
739
  }
743
740
  n.searchParams.set(r, e.id), n.searchParams.set(d, t);
@@ -750,11 +747,11 @@ var $e = class extends Ye {
750
747
  return;
751
748
  }
752
749
  if (i.headers) {
753
- F(e, a, this.deps.onLoss);
750
+ R(e, a, this.deps.onLoss);
754
751
  return;
755
752
  }
756
753
  let l = this.beacon(s, o.body);
757
- l !== "sent" && (l === "refused" ? F(e, a, this.deps.onLoss) : this.keepaliveFetch(s, e, o.body, t, () => new Headers({ [m]: f })));
754
+ l !== "sent" && (l === "refused" ? R(e, a, this.deps.onLoss) : this.keepaliveFetch(s, e, o.body, t, () => new Headers({ [m]: f })));
758
755
  }
759
756
  flushAlive() {
760
757
  let { diagnostics: e } = this.deps, t = "The flush of the hidden document failed.";
@@ -769,12 +766,12 @@ var $e = class extends Ye {
769
766
  for (let i of this.deps.drainForExit()) {
770
767
  let a = this.serialize(i, e);
771
768
  if (!a) continue;
772
- let o = Xe(i, a, Y(i, n));
773
- (t === void 0 || r.guard("transport.http_error", "The transportOnExit hook threw an error.", () => O(() => t(o))) !== !0) && F(i, r, this.deps.onLoss);
769
+ let o = $e(i, a, Z(i, n));
770
+ (t === void 0 || r.guard("transport.http_error", "The transportOnExit hook threw an error.", () => M(() => t(o))) !== !0) && R(i, r, this.deps.onLoss);
774
771
  }
775
772
  }
776
773
  serialize(e, t) {
777
- let n = Z(this.deps.config, e, this.deps.diagnostics, `The ${t} exit flush could not serialize its batch.`);
774
+ let n = Ze(this.deps.config, e, this.deps.diagnostics, `The ${t} exit flush could not serialize its batch.`);
778
775
  return n || this.deps.onLoss?.("unserializable", e.records, [e.id]), n;
779
776
  }
780
777
  endpointUrl() {
@@ -789,8 +786,8 @@ var $e = class extends Ye {
789
786
  }
790
787
  keepaliveFetch(e, t, n, r, i) {
791
788
  let { config: a, diagnostics: o } = this.deps, s = () => {
792
- F(t, o, this.deps.onLoss);
793
- }, c = E(n);
789
+ R(t, o, this.deps.onLoss);
790
+ }, c = O(n);
794
791
  this.keepaliveBytes + c > 6e4 ? s() : (this.keepaliveBytes += c, o.guard("transport.http_error", "The keepalive fetch failed.", () => (fetch(e, {
795
792
  method: "POST",
796
793
  body: n,
@@ -804,7 +801,7 @@ var $e = class extends Ye {
804
801
  };
805
802
  //#endregion
806
803
  //#region src/transport/compression.ts
807
- async function tt(e) {
804
+ async function it(e) {
808
805
  let t = globalThis.CompressionStream;
809
806
  if (t === void 0) return null;
810
807
  let n = new Blob([e]).stream().pipeThrough(new t(h)), r = await new Response(n).arrayBuffer();
@@ -812,10 +809,10 @@ async function tt(e) {
812
809
  }
813
810
  //#endregion
814
811
  //#region src/transport/http-transport.ts
815
- var nt = "In a cross-origin iframe, the session cookie is a third-party cookie. The browser often blocks it. Forward the records to the platform document. As an alternative, issue the cookie with the Partitioned attribute.", rt = class extends Ye {
812
+ var at = "In a cross-origin iframe, the session cookie is a third-party cookie. The browser often blocks it. Forward the records to the platform document. As an alternative, issue the cookie with the Partitioned attribute.", ot = class extends Qe {
816
813
  cachedHeaders;
817
814
  async send(e, t) {
818
- let { config: n } = this, r = Y(e, n), i = X(r, n);
815
+ let { config: n } = this, r = Z(e, n), i = Xe(r, n);
819
816
  i && e.records.length !== 0 && await this.post(e, r, i, t);
820
817
  }
821
818
  lastHeaders() {
@@ -833,11 +830,11 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
833
830
  this.accept(n, o.headers.get(ce));
834
831
  return;
835
832
  }
836
- let s = o.status, c = Pe(o.headers.get(e)), l = s === 413 ? await this.readMaxBytes(o) : void 0;
833
+ let s = o.status, c = Me(o.headers.get(e)), l = s === 413 ? await this.readMaxBytes(o) : void 0;
837
834
  throw this.reject(s, t.id, n, {
838
835
  retryAfterMs: c,
839
836
  maxBytes: l,
840
- advice: nt
837
+ advice: at
841
838
  });
842
839
  }
843
840
  rejectsCredentials(e) {
@@ -853,26 +850,26 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
853
850
  }
854
851
  async before(e, t, n) {
855
852
  try {
856
- return await k(e, Math.max(0, t - Date.now()));
853
+ return await E(e, Math.max(0, t - Date.now()));
857
854
  } catch {
858
855
  throw this.timeout(n);
859
856
  }
860
857
  }
861
858
  timeout(e) {
862
859
  let t = `The request took longer than ${String(p)} ms.`;
863
- return this.diagnostics.report("transport.timeout", t, { endpoint: e }), new B("timeout", t);
860
+ return this.diagnostics.report("transport.timeout", t, { endpoint: e }), new G("timeout", t);
864
861
  }
865
862
  async encodeBody(e) {
866
863
  let { config: t } = this;
867
- return t.compression !== "gzip" || E(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "The library could not compress the payload.", () => tt(e)) ?? e;
864
+ return t.compression !== "gzip" || O(e) < 1024 ? e : await this.diagnostics.guardAsync("transport.http_error", "The library could not compress the payload.", () => it(e)) ?? e;
868
865
  }
869
866
  async dispatch(e, t, n, r, i) {
870
867
  let { config: a } = this, o = new AbortController(), s = setTimeout(() => {
871
868
  o.abort();
872
869
  }, Math.max(0, r - Date.now()));
873
- A(s);
870
+ D(s);
874
871
  try {
875
- return await O(() => fetch(e, {
872
+ return await M(() => fetch(e, {
876
873
  method: "POST",
877
874
  headers: t,
878
875
  body: n,
@@ -882,15 +879,13 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
882
879
  keepalive: i
883
880
  }));
884
881
  } catch {
885
- if (o.signal.aborted) throw this.timeout(e);
886
- let t = globalThis.navigator?.onLine;
887
- throw new B(t === !1 ? "offline" : "transient", "A network error occurred.");
882
+ throw o.signal.aborted ? this.timeout(e) : new G(_e() ? "transient" : "offline", "A network error occurred.");
888
883
  } finally {
889
884
  clearTimeout(s);
890
885
  }
891
886
  }
892
887
  keepalive(e) {
893
- let t = globalThis.document?.visibilityState === "hidden", n = typeof e == "string" ? E(e) : e.byteLength;
888
+ let t = globalThis.document?.visibilityState === "hidden", n = typeof e == "string" ? O(e) : e.byteLength;
894
889
  return t && n <= 6e4;
895
890
  }
896
891
  async readMaxBytes(e) {
@@ -911,7 +906,7 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
911
906
  headers: r
912
907
  }), r ?? {};
913
908
  }
914
- }, it = class {
909
+ }, st = class {
915
910
  storage;
916
911
  transport;
917
912
  diagnostics;
@@ -927,7 +922,7 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
927
922
  this.attempt = 0, this.schedule(0);
928
923
  };
929
924
  constructor(e, t, n, r, i = 20, a = () => void 0) {
930
- this.storage = e, this.transport = t, this.diagnostics = n, this.config = r, this.batchesPerDrain = i, this.onLoss = a, this.maxAttempts = j(r.retention).maxAttempts;
925
+ this.storage = e, this.transport = t, this.diagnostics = n, this.config = r, this.batchesPerDrain = i, this.onLoss = a, this.maxAttempts = N(r.retention).maxAttempts;
931
926
  }
932
927
  start() {
933
928
  this.stopped = !1, typeof addEventListener < "u" && addEventListener("online", this.onOnline), this.schedule(v);
@@ -949,10 +944,10 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
949
944
  let t = setTimeout(() => {
950
945
  this.drain();
951
946
  }, e);
952
- this.timer = t, A(t);
947
+ this.timer = t, D(t);
953
948
  }
954
949
  bounded(e) {
955
- return k(e, C);
950
+ return E(e, C);
956
951
  }
957
952
  clearTimer() {
958
953
  this.timer !== null && (clearTimeout(this.timer), this.timer = null);
@@ -965,7 +960,7 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
965
960
  if (!this.draining) {
966
961
  this.draining = !0;
967
962
  try {
968
- await M("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(v);
963
+ await P("ui-observability.drain", this.diagnostics, () => this.drainLocked()) !== !0 && this.schedule(v);
969
964
  } finally {
970
965
  this.draining = !1;
971
966
  }
@@ -973,13 +968,13 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
973
968
  }
974
969
  async drainLocked() {
975
970
  try {
976
- if (globalThis.navigator?.onLine === !1) return this.schedule(v), !0;
971
+ if (!_e()) return this.schedule(v), !0;
977
972
  let e = await this.bounded(this.storage.take(this.batchesPerDrain));
978
973
  if (e.length === 0) return this.schedule(v), !0;
979
974
  let t = /* @__PURE__ */ new Set(), n = 0;
980
975
  for (let r of e) {
981
976
  if (this.stopped) return !0;
982
- let e = Y(r, this.config);
977
+ let e = Z(r, this.config);
983
978
  if (t.has(e)) continue;
984
979
  let i = await this.deliver(r);
985
980
  if (i === "stop") return !0;
@@ -998,7 +993,7 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
998
993
  try {
999
994
  return await this.transport.send(e), await this.bounded(this.storage.remove(e.id)), this.attempt = 0, "next";
1000
995
  } catch (t) {
1001
- let n = t instanceof B ? t : void 0;
996
+ let n = t instanceof G ? t : void 0;
1002
997
  return n?.kind === "permanent" || n?.kind === "too_large" ? (await this.replaceStored(e, t), "next") : n?.kind === "offline" ? (this.schedule(v), "stop") : n?.kind === "throttled" ? (this.attempt++, n.retryAfterMs ?? this.backoffMs()) : (await this.bounded(this.storage.bumpAttempts(e.id, e.attempts + 1)), this.attempt++, n?.retryAfterMs ?? this.backoffMs());
1003
998
  }
1004
999
  }
@@ -1008,10 +1003,10 @@ var nt = "In a cross-origin iframe, the session cookie is a third-party cookie.
1008
1003
  for (let e of n) await this.bounded(this.storage.save(e));
1009
1004
  }
1010
1005
  toStorable(e, t) {
1011
- let n = t instanceof B ? t : void 0;
1006
+ let n = t instanceof G ? t : void 0;
1012
1007
  if (n?.kind === "permanent") return this.onLoss("rejected", e.records, [e.id]), [];
1013
1008
  if (n?.kind !== "too_large") return [e];
1014
- let r = ge(e, this.diagnostics);
1009
+ let r = ve(e, this.diagnostics);
1015
1010
  return r ? (this.diagnostics.report("transport.batch_split", "The server refused the batch because it is too large.", {
1016
1011
  from: e.records.length,
1017
1012
  to: r[0].records.length,
@@ -1051,12 +1046,12 @@ var $ = class {
1051
1046
  let e = setTimeout(() => {
1052
1047
  this.timer = null, this.onFlush(this);
1053
1048
  }, this.options.flushIntervalMs);
1054
- this.timer = e, A(e);
1049
+ this.timer = e, D(e);
1055
1050
  }
1056
1051
  clearTimer() {
1057
1052
  this.timer !== null && (clearTimeout(this.timer), this.timer = null);
1058
1053
  }
1059
- }, at = class {
1054
+ }, ct = class {
1060
1055
  transport;
1061
1056
  storage;
1062
1057
  retry;
@@ -1065,7 +1060,7 @@ var $ = class {
1065
1060
  unconfirmed = /* @__PURE__ */ new Map();
1066
1061
  queue = [];
1067
1062
  open = /* @__PURE__ */ new Set();
1068
- ceiling = new pe();
1063
+ ceiling = new me();
1069
1064
  inFlight = 0;
1070
1065
  pumpScheduled = !1;
1071
1066
  stopped = !1;
@@ -1080,7 +1075,7 @@ var $ = class {
1080
1075
  };
1081
1076
  }
1082
1077
  push(e) {
1083
- this.stopped || (e.observedTimeUnixNano = fe(), this.route(e));
1078
+ this.stopped || (e.observedTimeUnixNano = pe(), this.route(e));
1084
1079
  }
1085
1080
  drainForExit() {
1086
1081
  let e = [...this.unconfirmed.values()].flatMap((e) => e.records);
@@ -1098,7 +1093,7 @@ var $ = class {
1098
1093
  }
1099
1094
  toBatch(e) {
1100
1095
  return e.length === 0 ? null : {
1101
- id: he(this.diagnostics),
1096
+ id: ge(this.diagnostics),
1102
1097
  records: e,
1103
1098
  createdAt: Date.now(),
1104
1099
  attempts: 0
@@ -1184,10 +1179,10 @@ var $ = class {
1184
1179
  }
1185
1180
  async store(e) {
1186
1181
  await this.diagnostics.guardAsync("storage.degraded", "The library could not store an undelivered batch.", async () => {
1187
- await k(this.storage.save(e), C), this.retry.nudge();
1182
+ await E(this.storage.save(e), C), this.retry.nudge();
1188
1183
  });
1189
1184
  }
1190
- }, ot = class e {
1185
+ }, lt = class e {
1191
1186
  storage;
1192
1187
  retry;
1193
1188
  pipeline;
@@ -1197,10 +1192,10 @@ var $ = class {
1197
1192
  this.storage = e, this.retry = t, this.pipeline = n, this.exitFlush = r, this.diagnostics = i;
1198
1193
  }
1199
1194
  static async create(t) {
1200
- let { config: n, diagnostics: r } = t, i = await Ne(n.storage, ie, j(n.retention), r, t.onGap), a = (e) => {
1201
- let i = xe(e, r);
1202
- i && Se(t.remote, n, i);
1203
- }, { onLoss: o } = t, s = n.transport ? void 0 : new rt(n, r, a, o), c = s ?? new $e(n, r, a, o), l = new it(i, c, r, n, 20, o), { batching: u } = n, d = new at(c, i, l, r, {
1195
+ let { config: n, diagnostics: r } = t, i = await je(n.storage, ie, N(n.retention), r, t.onGap), a = (e) => {
1196
+ let i = Se(e, r);
1197
+ i && Ce(t.remote, n, i);
1198
+ }, { onLoss: o } = t, s = n.transport ? void 0 : new ot(n, r, a, o), c = s ?? new nt(n, r, a, o), l = new st(i, c, r, n, 20, o), { batching: u } = n, d = new ct(c, i, l, r, {
1204
1199
  logs: {
1205
1200
  flushIntervalMs: u.logFlushIntervalMs,
1206
1201
  batchSize: u.logBatchSize
@@ -1209,7 +1204,7 @@ var $ = class {
1209
1204
  flushIntervalMs: u.metricFlushIntervalMs,
1210
1205
  batchSize: u.metricBatchSize
1211
1206
  }
1212
- }), f = new et({
1207
+ }), f = new rt({
1213
1208
  config: n,
1214
1209
  diagnostics: r,
1215
1210
  drainForExit: () => d.drainForExit(),
@@ -1244,6 +1239,6 @@ var $ = class {
1244
1239
  }
1245
1240
  };
1246
1241
  //#endregion
1247
- export { ot as Sender, I as n, L as t };
1242
+ export { lt as Sender, z as i, U as n, B as r, H as t };
1248
1243
 
1249
- //# sourceMappingURL=sender--0_VzPbN.js.map
1244
+ //# sourceMappingURL=sender-BUBWLn5i.js.map