@sprig-technologies/sprig-browser 2.40.0 → 2.40.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 (34) hide show
  1. package/dist/conversational-styles-BiL7hMhj.js +4 -0
  2. package/dist/conversational-styles-DlhTFTL6.cjs +1 -0
  3. package/dist/conversational-ui-BYWN-x1R.js +579 -0
  4. package/dist/conversational-ui-N_aaTzqd.cjs +1 -0
  5. package/dist/core-Br8FqGd4.cjs +12 -0
  6. package/dist/{core-CzqULo6b.js → core-Cyu7gofl.js} +451 -458
  7. package/dist/core.cjs +1 -1
  8. package/dist/core.d.ts +11 -0
  9. package/dist/core.js +2 -2
  10. package/dist/debounce-CMb8f7wh.js +9 -0
  11. package/dist/debounce-DsC7462b.cjs +1 -0
  12. package/dist/{getAttributedUrl-C1AsMcwH.cjs → getAttributedUrl-CJJ96Ihj.cjs} +6 -6
  13. package/dist/{getAttributedUrl-DUesmkhh.js → getAttributedUrl-C_5gL6aZ.js} +241 -244
  14. package/dist/index-BSk-C5b7.js +695 -0
  15. package/dist/index-MWKreg7C.cjs +1 -0
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.d.ts +11 -0
  18. package/dist/index.js +2 -2
  19. package/dist/{metricsReporter-BChkCOLD.js → metricsReporter-B-oKhuWk.js} +1 -1
  20. package/dist/{metricsReporter-Bqy_vLyq.cjs → metricsReporter-Dc4CZlRc.cjs} +1 -1
  21. package/dist/replay.cjs +1 -1
  22. package/dist/replay.js +134 -138
  23. package/dist/view-BGlLLPXB.js +1503 -0
  24. package/dist/view-BGzeHt4l.cjs +1 -0
  25. package/package.json +1 -1
  26. package/dist/conversational-styles-CWNea3pP.js +0 -4
  27. package/dist/conversational-styles-CzhxRRD3.cjs +0 -1
  28. package/dist/conversational-ui-D2Y5H9To.js +0 -610
  29. package/dist/conversational-ui-DJlCFQ-6.cjs +0 -1
  30. package/dist/core-CvM2f3CD.cjs +0 -12
  31. package/dist/index-D1_q2uph.cjs +0 -1
  32. package/dist/index-mshAF3wp.js +0 -709
  33. package/dist/view-C7XtFlCN.cjs +0 -1
  34. package/dist/view-afp9mz2J.js +0 -1491
package/dist/replay.js CHANGED
@@ -1,11 +1,12 @@
1
1
  var it = Object.defineProperty;
2
2
  var dt = (e, t, n) => t in e ? it(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var F = (e, t, n) => dt(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { b as d, s as Q, a as m, v as X, c as ct, g as ut, P as ke, r as Ue, d as lt, e as V, S as Z, f as pt } from "./metricsReporter-BChkCOLD.js";
4
+ import { b as d, s as Q, a as m, v as X, c as ct, g as lt, P as ke, r as Ue, d as ut, e as V, S as Y, f as pt } from "./metricsReporter-B-oKhuWk.js";
5
+ import { d as gt } from "./debounce-CMb8f7wh.js";
5
6
  var B = ((e) => (e[e.DomContentLoaded = 0] = "DomContentLoaded", e[e.Load = 1] = "Load", e[e.FullSnapshot = 2] = "FullSnapshot", e[e.IncrementalSnapshot = 3] = "IncrementalSnapshot", e[e.Meta = 4] = "Meta", e[e.Custom = 5] = "Custom", e[e.Plugin = 6] = "Plugin", e))(B || {}), k = ((e) => (e[e.Mutation = 0] = "Mutation", e[e.MouseMove = 1] = "MouseMove", e[e.MouseInteraction = 2] = "MouseInteraction", e[e.Scroll = 3] = "Scroll", e[e.ViewportResize = 4] = "ViewportResize", e[e.Input = 5] = "Input", e[e.TouchMove = 6] = "TouchMove", e[e.MediaInteraction = 7] = "MediaInteraction", e[e.StyleSheetRule = 8] = "StyleSheetRule", e[e.CanvasMutation = 9] = "CanvasMutation", e[e.Font = 10] = "Font", e[e.Log = 11] = "Log", e[e.Drag = 12] = "Drag", e[e.StyleDeclaration = 13] = "StyleDeclaration", e[e.Selection = 14] = "Selection", e[e.AdoptedStyleSheet = 15] = "AdoptedStyleSheet", e[e.CustomElement = 16] = "CustomElement", e))(k || {});
6
7
  const re = (e, t) => t.some((n) => e instanceof n);
7
8
  let Se, De;
8
- const oe = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap();
9
+ const oe = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap();
9
10
  let se = { get(e, t, n) {
10
11
  if (e instanceof IDBTransaction) {
11
12
  if (t === "done") return oe.get(e);
@@ -16,15 +17,15 @@ let se = { get(e, t, n) {
16
17
  function xe(e) {
17
18
  se = e(se);
18
19
  }
19
- function gt(e) {
20
+ function mt(e) {
20
21
  return (De || (De = [IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey])).includes(e) ? function(...t) {
21
22
  return e.apply(ie(this), t), M(this.request);
22
23
  } : function(...t) {
23
24
  return M(e.apply(ie(this), t));
24
25
  };
25
26
  }
26
- function mt(e) {
27
- return typeof e == "function" ? gt(e) : (e instanceof IDBTransaction && function(t) {
27
+ function wt(e) {
28
+ return typeof e == "function" ? mt(e) : (e instanceof IDBTransaction && function(t) {
28
29
  if (oe.has(t)) return;
29
30
  const n = new Promise((a, r) => {
30
31
  const o = () => {
@@ -48,9 +49,9 @@ function M(e) {
48
49
  });
49
50
  return K.set(a, n), a;
50
51
  }(e);
51
- if (Y.has(e)) return Y.get(e);
52
- const t = mt(e);
53
- return t !== e && (Y.set(e, t), K.set(t, e)), t;
52
+ if (Z.has(e)) return Z.get(e);
53
+ const t = wt(e);
54
+ return t !== e && (Z.set(e, t), K.set(t, e)), t;
54
55
  }
55
56
  const ie = (e) => K.get(e);
56
57
  function de(e, { blocked: t } = {}) {
@@ -58,38 +59,38 @@ function de(e, { blocked: t } = {}) {
58
59
  return t && (n.onblocked = (a) => t(a.oldVersion, a)), M(n).then(() => {
59
60
  });
60
61
  }
61
- const wt = ["get", "getKey", "getAll", "getAllKeys", "count"], yt = ["put", "add", "delete", "clear"], ee = /* @__PURE__ */ new Map();
62
+ const yt = ["get", "getKey", "getAll", "getAllKeys", "count"], ft = ["put", "add", "delete", "clear"], ee = /* @__PURE__ */ new Map();
62
63
  function be(e, t) {
63
64
  if (!(e instanceof IDBDatabase) || t in e || typeof t != "string") return;
64
65
  if (ee.get(t)) return ee.get(t);
65
- const n = t.replace(/FromIndex$/, ""), a = t !== n, r = yt.includes(n);
66
- if (!(n in (a ? IDBIndex : IDBObjectStore).prototype) || !r && !wt.includes(n)) return;
66
+ const n = t.replace(/FromIndex$/, ""), a = t !== n, r = ft.includes(n);
67
+ if (!(n in (a ? IDBIndex : IDBObjectStore).prototype) || !r && !yt.includes(n)) return;
67
68
  const o = async function(s, ...c) {
68
69
  const i = this.transaction(s, r ? "readwrite" : "readonly");
69
- let u = i.store;
70
- return a && (u = u.index(c.shift())), (await Promise.all([u[n](...c), r && i.done]))[0];
70
+ let l = i.store;
71
+ return a && (l = l.index(c.shift())), (await Promise.all([l[n](...c), r && i.done]))[0];
71
72
  };
72
73
  return ee.set(t, o), o;
73
74
  }
74
75
  xe((e) => ({ ...e, get: (t, n, a) => be(t, n) || e.get(t, n, a), has: (t, n) => !!be(t, n) || e.has(t, n) }));
75
- const ft = ["continue", "continuePrimaryKey", "advance"], Ee = {}, ce = /* @__PURE__ */ new WeakMap(), Be = /* @__PURE__ */ new WeakMap(), ht = { get(e, t) {
76
- if (!ft.includes(t)) return e[t];
76
+ const ht = ["continue", "continuePrimaryKey", "advance"], Ee = {}, ce = /* @__PURE__ */ new WeakMap(), Be = /* @__PURE__ */ new WeakMap(), It = { get(e, t) {
77
+ if (!ht.includes(t)) return e[t];
77
78
  let n = Ee[t];
78
79
  return n || (n = Ee[t] = function(...a) {
79
80
  ce.set(this, Be.get(this)[t](...a));
80
81
  }), n;
81
82
  } };
82
- async function* It(...e) {
83
+ async function* vt(...e) {
83
84
  let t = this;
84
85
  if (t instanceof IDBCursor || (t = await t.openCursor(...e)), !t) return;
85
- const n = new Proxy(t, ht);
86
+ const n = new Proxy(t, It);
86
87
  for (Be.set(n, t), K.set(n, ie(t)); t; ) yield n, t = await (ce.get(n) || t.continue()), ce.delete(n);
87
88
  }
88
89
  function Re(e, t) {
89
90
  return t === Symbol.asyncIterator && re(e, [IDBIndex, IDBObjectStore, IDBCursor]) || t === "iterate" && re(e, [IDBIndex, IDBObjectStore]);
90
91
  }
91
- xe((e) => ({ ...e, get: (t, n, a) => Re(t, n) ? It : e.get(t, n, a), has: (t, n) => Re(t, n) || e.has(t, n) }));
92
- const vt = "sprigReplayIframeLoaded", St = "sprigReplayIframeSettings", Dt = "sprigReplayIframeTakeFullSnapshot", bt = "sprigReplayTeardown", fe = [], Me = new class {
92
+ xe((e) => ({ ...e, get: (t, n, a) => Re(t, n) ? vt : e.get(t, n, a), has: (t, n) => Re(t, n) || e.has(t, n) }));
93
+ const St = "sprigReplayIframeLoaded", Dt = "sprigReplayIframeSettings", bt = "sprigReplayIframeTakeFullSnapshot", Et = "sprigReplayTeardown", fe = [], Me = new class {
93
94
  constructor(e) {
94
95
  F(this, "awaitingResolvers", []);
95
96
  F(this, "activeCount", 0);
@@ -119,9 +120,9 @@ const vt = "sprigReplayIframeLoaded", St = "sprigReplayIframeSettings", Dt = "sp
119
120
  var y;
120
121
  if (!i && !n && !a) return void d.error("UploadErr", { isMobile: i, uploadId: n, etags: a });
121
122
  d.info("MarkUploadComplete", { surveyId: t });
122
- const u = await Q(`${e}/sdk/1/completeSessionReplay`, { method: "POST", body: JSON.stringify({ etags: a, uploadId: n, responseGroupUuid: o, surveyId: t, replayDuration: s, eventDigest: c, userAgent: (y = window == null ? void 0 : window.navigator) == null ? void 0 : y.userAgent }), headers: r, shouldRetryRequest: !0 });
123
- return d.info("MarkUploadDone", { surveyId: t }), u;
124
- }, Et = (e) => {
123
+ const l = await Q(`${e}/sdk/1/completeSessionReplay`, { method: "POST", body: JSON.stringify({ etags: a, uploadId: n, responseGroupUuid: o, surveyId: t, replayDuration: s, eventDigest: c, userAgent: (y = window == null ? void 0 : window.navigator) == null ? void 0 : y.userAgent }), headers: r, shouldRetryRequest: !0 });
124
+ return d.info("MarkUploadDone", { surveyId: t }), l;
125
+ }, Rt = (e) => {
125
126
  if (e instanceof Attr) return null;
126
127
  let t = 1;
127
128
  for (let n = e.previousSibling; n; n = n.previousSibling) n.nodeName === e.nodeName && ++t;
@@ -148,10 +149,10 @@ const vt = "sprigReplayIframeLoaded", St = "sprigReplayIframeSettings", Dt = "sp
148
149
  case Node.ELEMENT_NODE:
149
150
  a.name = n.nodeName;
150
151
  }
151
- a.position = Et(n);
152
+ a.position = Rt(n);
152
153
  }
153
154
  return "/" + t.reverse().map((n) => n.position !== null ? `/${n.name}[${n.position}]` : `/${n.name}`).join("");
154
- }, he = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(/\r?\n|\r/g, " ").substring(0, 250), C = { capture: !0, passive: !0 }, Rt = ["a", "button", "input", "option", "li", "link"], Ct = ["Escape", "Enter", "Backspace", "F5", "Tab"];
155
+ }, he = (e) => e && e.trim().substring(0, 500).replace(/\s\s+/g, " ").replace(/\r?\n|\r/g, " ").substring(0, 250), C = { capture: !0, passive: !0 }, Ct = ["a", "button", "input", "option", "li", "link"], Pt = ["Escape", "Enter", "Backspace", "F5", "Tab"];
155
156
  let J = !1, b = null, G = null;
156
157
  const Ce = (e) => {
157
158
  var n;
@@ -166,7 +167,7 @@ const Ce = (e) => {
166
167
  var a;
167
168
  if (!e) return {};
168
169
  const t = { ...Ce(e) }, n = e.parentElement;
169
- if (n && Rt.includes((a = n.tagName) == null ? void 0 : a.toLowerCase())) {
170
+ if (n && Ct.includes((a = n.tagName) == null ? void 0 : a.toLowerCase())) {
170
171
  const r = Ce(n);
171
172
  Object.assign(t, r);
172
173
  }
@@ -178,24 +179,19 @@ const Ce = (e) => {
178
179
  t.target === ((r = window.document) == null ? void 0 : r.body) && window.Sprig.pointerDownTarget && (n = window.Sprig.pointerDownTarget), a = { x: t.x, y: t.y, type: e, elementAttributes: Tt(n), windowHeight: window.innerHeight, windowWidth: window.innerWidth, ...n instanceof HTMLElement || n instanceof SVGElement || n instanceof MathMLElement ? { rect: n == null ? void 0 : n.getBoundingClientRect(), xPath: Ae(n) } : {} }, (o = a == null ? void 0 : a.elementAttributes) != null && o.text && (a.elementAttributes.text = he(a.elementAttributes.text)), b == null || b("Sprig_Click", a);
179
180
  }, Le = (e) => {
180
181
  var t;
181
- Ct.includes(e.key) && (t = { key: e.key }, b == null || b("Sprig_Keystroke", t));
182
- }, Pt = () => {
182
+ Pt.includes(e.key) && (t = { key: e.key }, b == null || b("Sprig_Keystroke", t));
183
+ }, kt = () => {
183
184
  var e;
184
185
  window.performance.getEntriesByType("navigation").map((t) => t.type).includes("reload") && (e = { url: window.location.href, currentPageTitle: document.title }, b == null || b("Sprig_Refresh", e));
185
- }, kt = () => {
186
+ }, Ut = () => {
186
187
  var e;
187
188
  window.performance.getEntriesByType("navigation").map((t) => t.type).includes("back_forward") && ((e = { curUrl: window.location.href, fromUrl: document.referrer, currentPageTitle: document.title }).currentPageTitle && (e.currentPageTitle = he(e.currentPageTitle)), b == null || b("Sprig_BackForward", e));
188
- }, Oe = /* @__PURE__ */ ((e, t) => {
189
- let n;
190
- return (a) => {
191
- clearTimeout(n), n = window.setTimeout(() => e(a), t);
192
- };
193
- })((e) => {
189
+ }, Oe = gt((e) => {
194
190
  if (!(e.target instanceof HTMLElement || e.target instanceof Document)) return;
195
191
  let t = e.target;
196
192
  "scrollTop" in t || (t = t.documentElement), G == null || G({ xPath: Ae(t), x: t.scrollLeft, y: t.scrollTop, elementAttributes: { targetScrollWidth: t.scrollWidth, targetClientWidth: t.clientWidth, targetScrollHeight: t.scrollHeight, targetClientHeight: t.clientHeight } });
197
- }, 750), Fe = (Te = "left_click", (e) => Ne(Te, e));
198
- var Te;
193
+ }, 750), Fe = (Pe = "left_click", (e) => Ne(Pe, e));
194
+ var Pe;
199
195
  const He = (e) => {
200
196
  e.button === 2 && Ne("right_click", e);
201
197
  }, je = (e) => {
@@ -206,26 +202,26 @@ const He = (e) => {
206
202
  if (e) return d.info("SessionIDFound", { savedSessionId: e }), m.removeItem("sprig.sessionId"), e;
207
203
  const t = X();
208
204
  return d.info("GeneratedSessionID", { uuid: t }), t;
209
- })(), ue = () => {
205
+ })(), le = () => {
210
206
  m.setItem("sprig.disableReplayRecording", "disabled");
211
- }, T = () => !!m.getItem("sprig.disableReplayRecording"), z = () => !!m.getItem("sprig.isReplayPaused");
207
+ }, P = () => !!m.getItem("sprig.disableReplayRecording"), z = () => !!m.getItem("sprig.isReplayPaused");
212
208
  window.addEventListener("beforeunload", () => {
213
209
  d.info("BeforeUnload", { sessionId: I }), m.setItem("sprig.sessionId", I);
214
210
  });
215
211
  const U = (e, t) => {
216
212
  var n, a;
217
- if (!T() && g.isRecording && !z()) try {
213
+ if (!P() && g.isRecording && !z()) try {
218
214
  (a = (n = window.rrwebRecord) == null ? void 0 : n.addCustomEvent) == null || a.call(n, e, t);
219
215
  } catch (r) {
220
216
  H("Error recording custom event", r);
221
217
  }
222
- }, Ut = async (e) => {
218
+ }, xt = async (e) => {
223
219
  const { x: t, xPath: n, y: a } = e, r = g.scrollEventUuids[n];
224
220
  if (r) return D(async () => {
225
- var c, i, u, y;
226
- const o = await l.openDB(), s = await o.get("events", r);
221
+ var c, i, l, y;
222
+ const o = await u.openDB(), s = await o.get("events", r);
227
223
  if (s != null && s.event) {
228
- const p = JSON.parse(s.event), h = t > ((i = (c = p.data) == null ? void 0 : c.payload) == null ? void 0 : i.x), w = a > ((y = (u = p.data) == null ? void 0 : u.payload) == null ? void 0 : y.y);
224
+ const p = JSON.parse(s.event), h = t > ((i = (c = p.data) == null ? void 0 : c.payload) == null ? void 0 : i.x), w = a > ((y = (l = p.data) == null ? void 0 : l.payload) == null ? void 0 : y.y);
229
225
  if (!h && !w) return null;
230
226
  h && (p.data.payload.x = t), w && (p.data.payload.y = a), p.data.payload.elementAttributes = e.elementAttributes, s.event = JSON.stringify(p), await o.put("events", s);
231
227
  } else U("Sprig_Scroll", e);
@@ -236,37 +232,37 @@ const U = (e, t) => {
236
232
  g[e] && (clearInterval(g[e]), g[e] = void 0);
237
233
  }), J && (window.removeEventListener("click", Fe, C), window.removeEventListener("pointerdown", je, C), window.removeEventListener("mousedown", He, C), window.removeEventListener("keydown", Le, C), window.removeEventListener("scroll", Oe, C), J = !1), fe.forEach((e) => {
238
234
  var t;
239
- (t = e.source) == null || t.postMessage({ type: bt }, { targetOrigin: e.origin });
235
+ (t = e.source) == null || t.postMessage({ type: Et }, { targetOrigin: e.origin });
240
236
  });
241
- }, xt = ["did not allow mutations", "called in an invalid security context"], Bt = (e, t, { reportError: n = !0, extraInfo: a = {} }) => {
242
- if (!T() && t instanceof Error) {
243
- if (ue(), t.name === "VersionError") return d.error("VersionErr", { message: e }), void l.deleteDB();
237
+ }, Bt = ["did not allow mutations", "called in an invalid security context"], Mt = (e, t, { reportError: n = !0, extraInfo: a = {} }) => {
238
+ if (!P() && t instanceof Error) {
239
+ if (le(), t.name === "VersionError") return d.error("VersionErr", { message: e }), void u.deleteDB();
244
240
  ((r) => {
245
241
  if (!r) return !0;
246
- for (const o of xt) if (r.toLowerCase().includes(o)) return !1;
242
+ for (const o of Bt) if (r.toLowerCase().includes(o)) return !1;
247
243
  return !0;
248
- })(t == null ? void 0 : t.message) && (n && window.UserLeap.reportError(e, t, a), l.clearAll());
244
+ })(t == null ? void 0 : t.message) && (n && window.UserLeap.reportError(e, t, a), u.clearAll());
249
245
  }
250
246
  }, H = (e, t, { reportError: n } = { reportError: !0 }) => {
251
- Ge(), d.error("ReplayErr", { code: t.code, name: t.name }), Bt(e, t, { reportError: n });
247
+ Ge(), d.error("ReplayErr", { code: t.code, name: t.name }), Mt(e, t, { reportError: n });
252
248
  }, D = async (e, t) => {
253
249
  try {
254
250
  return await e();
255
251
  } catch (n) {
256
252
  H(t, n);
257
253
  }
258
- }, le = () => {
254
+ }, ue = () => {
259
255
  g.isRecording && (D(() => {
260
256
  var e, t;
261
257
  return (t = (e = window.rrwebRecord) == null ? void 0 : e.takeFullSnapshot) == null ? void 0 : t.call(e, !0);
262
258
  }, "Error recording full snapshot"), fe.forEach((e) => {
263
259
  var t;
264
- (t = e.source) == null || t.postMessage({ type: Dt }, { targetOrigin: e.origin });
260
+ (t = e.source) == null || t.postMessage({ type: bt }, { targetOrigin: e.origin });
265
261
  }));
266
262
  };
267
263
  let te = 0;
268
264
  (async () => Ve() && Promise.allSettled([de("replayStorage"), de("sprig.replay")]))();
269
- const l = new class {
265
+ const u = new class {
270
266
  constructor() {
271
267
  F(this, "wrapTransactionWithCounter", (e) => {
272
268
  var a, r;
@@ -290,7 +286,7 @@ const l = new class {
290
286
  return a && (s.onupgradeneeded = (i) => {
291
287
  a(M(s.result), i.oldVersion, i.newVersion, M(s.transaction), i);
292
288
  }), n && (s.onblocked = (i) => n(i.oldVersion, i.newVersion, i)), c.then((i) => {
293
- o && (i.onclose = () => o()), r && (i.onversionchange = (u) => r(u.oldVersion, u.newVersion, u));
289
+ o && (i.onclose = () => o()), r && (i.onversionchange = (l) => r(l.oldVersion, l.newVersion, l));
294
290
  }).catch(() => {
295
291
  }), c;
296
292
  }("sprigReplay", 1, { upgrade: (e, t, n) => {
@@ -382,9 +378,9 @@ const l = new class {
382
378
  let j, We, A = [], L = !1, N = 0, W = !1, $e = !1;
383
379
  const Ie = [];
384
380
  let q, Ke, $, Je, ne = !1;
385
- const O = () => W && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, triggerSnapshot: n, forceInit: a = !1 }) => {
386
- W && !a || (m.isStorageAvailable ? (A = [], Ie.splice(0), x.splice(0), N = 0, $ = n, We = e, j = { responseGroupUuid: t.responseGroupUuid, surveyId: t.surveyId, userAgent: t.userAgent, sdkVersion: t.sdkVersion }, Ke = t.maxDurationSeconds, Lt(), W || (Je = window.setInterval(Nt, 500)), W = !0) : L = !0);
387
- }, _t = [k.Drag, k.Input, k.MediaInteraction, k.MouseInteraction, k.MouseMove, k.Scroll, k.Selection, k.TouchMove], At = (e) => e.type === B.Custom || e.type === B.IncrementalSnapshot && _t.includes(e.data.source), ve = (e) => e.some(At), Nt = async () => {
381
+ const O = () => W && !L && Date.now() <= q, _t = ({ apiUrl: e, config: t, triggerSnapshot: n, forceInit: a = !1 }) => {
382
+ W && !a || (m.isStorageAvailable ? (A = [], Ie.splice(0), x.splice(0), N = 0, $ = n, We = e, j = { responseGroupUuid: t.responseGroupUuid, surveyId: t.surveyId, userAgent: t.userAgent, sdkVersion: t.sdkVersion }, Ke = t.maxDurationSeconds, Ot(), W || (Je = window.setInterval(Lt, 500)), W = !0) : L = !0);
383
+ }, At = [k.Drag, k.Input, k.MediaInteraction, k.MouseInteraction, k.MouseMove, k.Scroll, k.Selection, k.TouchMove], Nt = (e) => e.type === B.Custom || e.type === B.IncrementalSnapshot && At.includes(e.data.source), ve = (e) => e.some(Nt), Lt = async () => {
388
384
  if (!O()) return void window.clearInterval(Je);
389
385
  if (ze(), !ve(x)) return;
390
386
  const e = x[0].timestamp;
@@ -392,20 +388,20 @@ const O = () => W && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
392
388
  }, ze = async () => {
393
389
  if (A.length || ne) return;
394
390
  ne = !0;
395
- const e = await Ft();
391
+ const e = await Ht();
396
392
  if (!e) return void (L = !0);
397
393
  Ie.splice(0, e.length).forEach((t) => t(e.shift())), e.forEach((t) => A.push(t)), ne = !1;
398
- }, Lt = () => {
394
+ }, Ot = () => {
399
395
  const e = m.getItem("sprig.alwayson.info");
400
396
  if (e) {
401
397
  d.info("Read stored session state", e);
402
398
  const t = JSON.parse(e);
403
- L = t.disabled, j = t.metadata, A = t.uploadUrls, N = t.currentIndex, q = t.expirationTimestamp, t.pendingEventTimestamp && (d.info(`Uploading with pending timestamp: ${t.pendingEventTimestamp}`), Ot(t.pendingEventTimestamp));
399
+ L = t.disabled, j = t.metadata, A = t.uploadUrls, N = t.currentIndex, q = t.expirationTimestamp, t.pendingEventTimestamp && (d.info(`Uploading with pending timestamp: ${t.pendingEventTimestamp}`), Ft(t.pendingEventTimestamp));
404
400
  } else q = 1e3 * Ke + Date.now();
405
- }, Ot = async (e) => {
406
- const t = Date.now(), n = (await l.getEventsBetween(e, t)).map((r) => JSON.parse(r.event));
401
+ }, Ft = async (e) => {
402
+ const t = Date.now(), n = (await u.getEventsBetween(e, t)).map((r) => JSON.parse(r.event));
407
403
  if (!ve(n)) return;
408
- Ze(n);
404
+ Ye(n);
409
405
  const a = await Xe();
410
406
  a && await Qe(a, n);
411
407
  }, qe = async (e, t) => {
@@ -423,11 +419,11 @@ const O = () => W && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
423
419
  return s.write(c), s.close(), new Uint8Array(await new Response(o.readable).arrayBuffer());
424
420
  })(t);
425
421
  d.info("Uploading always-on events with presigned url"), await qe(() => Q(e, { body: n, method: "PUT" }), "uploading always-on with presigned url");
426
- }, Ft = async () => {
422
+ }, Ht = async () => {
427
423
  if (!O()) return;
428
424
  const { surveyId: e, responseGroupUuid: t } = j, n = { responseGroupUuid: t, surveyId: e, index: N + 1 };
429
425
  d.info("Fetching always-on upload urls", n);
430
- const a = await qe(() => Q(`${We}/sdk/1/replayUrls`, { method: "POST", body: JSON.stringify(n), headers: ut(window.UserLeap) }), "fetching always-on signed urls");
426
+ const a = await qe(() => Q(`${We}/sdk/1/replayUrls`, { method: "POST", body: JSON.stringify(n), headers: lt(window.UserLeap) }), "fetching always-on signed urls");
431
427
  if (!a) return;
432
428
  const r = a.json.signedUrls;
433
429
  return d.info("Fetched more always-on upload urls", { body: n, urls: r }), r;
@@ -437,15 +433,15 @@ const O = () => W && !L && Date.now() <= q, Mt = ({ apiUrl: e, config: t, trigge
437
433
  Ie.push(t);
438
434
  });
439
435
  return ze(), e;
440
- }, Ze = (e) => {
436
+ }, Ye = (e) => {
441
437
  var r, o, s;
442
438
  const t = e.length ? e[e.length - 1].timestamp : Date.now(), n = N, a = ((o = (r = window.UserLeap) == null ? void 0 : r.config) == null ? void 0 : o.customMetadata) ?? ((s = window.__cfg) == null ? void 0 : s.customMetadata);
443
439
  N++, e.push({ timestamp: t, type: B.Custom, data: { tag: "Sprig_Meta", payload: { ...j, index: n, visitorId: window.UserLeap.visitorId ?? "", timestamp: t, customMetadata: a } } });
444
- }, Ht = (e, t) => {
440
+ }, jt = (e, t) => {
445
441
  O() && !$e && (e || x.length) && (e && x.length && (async () => {
446
442
  const n = x.splice(0);
447
443
  if (!ve(n)) return;
448
- d.info("Capturing always-on event array to upload"), Ze(n);
444
+ d.info("Capturing always-on event array to upload"), Ye(n);
449
445
  const a = await Xe();
450
446
  a && await Qe(a, n);
451
447
  })(), x.push(t));
@@ -458,7 +454,7 @@ window.addEventListener("beforeunload", async () => {
458
454
  d.info("Storing session state on unload", t), m.setItem("sprig.alwayson.info", JSON.stringify(t));
459
455
  })());
460
456
  });
461
- const Ye = async (e, t) => {
457
+ const Ze = async (e, t) => {
462
458
  const n = performance.now();
463
459
  let a;
464
460
  try {
@@ -480,33 +476,33 @@ const Ye = async (e, t) => {
480
476
  }
481
477
  };
482
478
  let tt = 5e3, pe = 6e4, ge = 0, _, me = !1, we = [];
483
- const jt = (e) => {
479
+ const Vt = (e) => {
484
480
  var t, n, a, r;
485
481
  if ((t = e.event) != null && t.includes("Sprig_Scroll")) {
486
482
  const o = (r = (a = (n = JSON.parse(e.event)) == null ? void 0 : n.data) == null ? void 0 : a.payload) == null ? void 0 : r.xPath;
487
483
  if (!o) return;
488
484
  g.scrollEventUuids[o] = e.uuid;
489
485
  }
490
- we.push(e), me || Vt();
491
- }, Vt = () => {
486
+ we.push(e), me || Gt();
487
+ }, Gt = () => {
492
488
  me = !0, setTimeout(async () => {
493
- if (T() || z()) return;
489
+ if (P() || z()) return;
494
490
  const e = we;
495
491
  we = [], me = !1, et(async () => {
496
492
  await (async (t) => {
497
493
  const n = t.map((a) => ({ ...a, sessionId: a.sessionId ?? I }));
498
- if (n.length !== 0) return D(() => l.bulkAdd("events", n), "Error storing replay events");
494
+ if (n.length !== 0) return D(() => u.bulkAdd("events", n), "Error storing replay events");
499
495
  })(e);
500
496
  }, "sdk_replay_add_event_batch_seconds");
501
497
  }, 500);
502
- }, Gt = (e, t, n) => {
498
+ }, Wt = (e, t, n) => {
503
499
  g.cleanupInterval = window.setInterval(() => {
504
500
  const a = Date.now();
505
- Ye(() => D(async () => {
506
- T() || await Promise.all([l.deleteRowsBefore("events", a - 1e3 * e, (r) => r.expiredAt === void 0 || r.expiredAt < a - 1e3 * e), l.deleteRowsBefore("chunkUploads", a - 1e3 * t), l.deleteRowsBefore("pendingCaptures", a - 1e3 * n, (r) => !r.canUpload)]);
501
+ Ze(() => D(async () => {
502
+ P() || await Promise.all([u.deleteRowsBefore("events", a - 1e3 * e, (r) => r.expiredAt === void 0 || r.expiredAt < a - 1e3 * e), u.deleteRowsBefore("chunkUploads", a - 1e3 * t), u.deleteRowsBefore("pendingCaptures", a - 1e3 * n, (r) => !r.canUpload)]);
507
503
  }, "Error deleting table rows"), "sdk_replay_cleanup_seconds"), d.debug("CleanupComplete");
508
504
  }, 3e4);
509
- }, Wt = () => {
505
+ }, $t = () => {
510
506
  g.pendingCheckInterval = window.setInterval(async () => {
511
507
  D(async () => {
512
508
  await ye();
@@ -519,21 +515,21 @@ const ye = async (e = !1) => {
519
515
  ae = !0;
520
516
  const t = parseInt(_ ?? "0");
521
517
  if (t === 0) return;
522
- const n = await l.getPendingCaptures({ beforePresent: !0, isBeforeType: e }), a = await l.openDB();
518
+ const n = await u.getPendingCaptures({ beforePresent: !0, isBeforeType: e }), a = await u.openDB();
523
519
  await Promise.all(n.map(async (r) => (await a.delete("pendingCaptures", r.uuid), rt(r.captureParams, r.canUpload)))), _ = (t - n.length).toString(), m.setItem("sprig.pendingCount", _);
524
520
  } finally {
525
521
  ae = !1;
526
522
  }
527
- }, $t = async (e, t, n, a, r) => {
528
- const o = Math.min(e + r, n), s = await Ye(() => l.getEventsBetween(e, o), "sdk_replay_get_events_between_seconds");
523
+ }, Kt = async (e, t, n, a, r) => {
524
+ const o = Math.min(e + r, n), s = await Ze(() => u.getEventsBetween(e, o), "sdk_replay_get_events_between_seconds");
529
525
  if (!(s != null && s.length)) return d.debug("NoEventsFound"), { validStartFound: a, events: [] };
530
526
  if (!a) {
531
527
  d.debug("ValidStartSearch");
532
528
  let c = -1;
533
- return s == null || s.forEach((i, u) => {
529
+ return s == null || s.forEach((i, l) => {
534
530
  if (!i.isValidStart) return;
535
531
  const y = i.timestamp <= t;
536
- (c < 0 || y) && (c = u);
532
+ (c < 0 || y) && (c = l);
537
533
  }), c < 0 ? (d.debug("ValidStartNotFound"), { validStartFound: a, events: [] }) : { validStartFound: !0, events: s == null ? void 0 : s.slice(c) };
538
534
  }
539
535
  return { validStartFound: a, events: s };
@@ -547,95 +543,95 @@ const ye = async (e = !1) => {
547
543
  if (!o) throw new Error(`Upload response did not include etag for upload ${a.uploadId}, part ${a.chunkIndex}`);
548
544
  return o;
549
545
  }))(t);
550
- return await l.updatePartial("chunkUploads", t.uuid, { data: null, etag: n, status: "UploadComplete" }), t.uploadId;
546
+ return await u.updatePartial("chunkUploads", t.uuid, { data: null, etag: n, status: "UploadComplete" }), t.uploadId;
551
547
  })), at = async (e) => {
552
- const t = await l.getChunkUploadsByStatus({ status: "UploadComplete", uploadId: e });
548
+ const t = await u.getChunkUploadsByStatus({ status: "UploadComplete", uploadId: e });
553
549
  if (!(t != null && t.length)) return void d.info("NoChunksForUpload", { uploadId: e });
554
550
  const n = t.reduce((o, s) => (o.find((c) => c.chunkIndex === s.chunkIndex) || o.push(s), o), []);
555
551
  n.sort((o, s) => o.chunkIndex - s.chunkIndex);
556
552
  const a = n.map((o) => ({ ETag: o.etag, PartNumber: o.chunkIndex })).filter((o) => o.ETag !== null), r = n[0];
557
- await _e({ apiUrl: r.apiUrl, surveyId: r.surveyId, uploadId: e, responseGroupUuid: r.responseGroupId, etags: a, headers: r.completeUploadHeaders, replayDuration: r.replayDuration }), await l.deleteChunkUploads("UploadComplete", e);
558
- }, Kt = () => {
553
+ await _e({ apiUrl: r.apiUrl, surveyId: r.surveyId, uploadId: e, responseGroupUuid: r.responseGroupId, etags: a, headers: r.completeUploadHeaders, replayDuration: r.replayDuration }), await u.deleteChunkUploads("UploadComplete", e);
554
+ }, Jt = () => {
559
555
  D(async () => {
560
- const e = await l.getChunkUploadsByStatus({ sessionId: I, status: "ReadyForUpload" });
556
+ const e = await u.getChunkUploadsByStatus({ sessionId: I, status: "ReadyForUpload" });
561
557
  if (!(e != null && e.length)) return;
562
558
  const t = await nt(e);
563
559
  t != null && t.length && await Promise.all(t.map((n) => {
564
560
  if (n) return at(n);
565
561
  }));
566
562
  }, "Error uploading unfinished chunks");
567
- }, Jt = async (e, t) => {
563
+ }, zt = async (e, t) => {
568
564
  const n = t ?? Date.now();
569
565
  return (async (a, r) => {
570
566
  const o = new TextEncoder();
571
567
  let s = null;
572
568
  const c = new CompressionStream("gzip"), i = c.writable.getWriter();
573
- let u = !1, y = !1, [p, h] = [0, 0], w = [];
574
- for (let P = a - 35e3; P < r; P += pe) {
575
- if ({ validStartFound: y, events: w } = await $t(P, a, r, y, pe), !(w != null && w.length)) {
569
+ let l = !1, y = !1, [p, h] = [0, 0], w = [];
570
+ for (let T = a - 35e3; T < r; T += pe) {
571
+ if ({ validStartFound: y, events: w } = await Kt(T, a, r, y, pe), !(w != null && w.length)) {
576
572
  d.debug("NoEventsFound");
577
573
  continue;
578
574
  }
579
575
  p === 0 && (p = w[0].timestamp), h = w[w.length - 1].timestamp;
580
576
  const f = w.map((R) => R.event);
581
577
  f.push(`{"timestamp":${r}}`);
582
- const v = `${u ? "," : "["}${f}`, S = o.encode(v);
578
+ const v = `${l ? "," : "["}${f}`, S = o.encode(v);
583
579
  et(() => {
584
580
  i.write(S);
585
- }, "sdk_replay_compression_seconds"), u = !0;
581
+ }, "sdk_replay_compression_seconds"), l = !0;
586
582
  }
587
583
  if (h - p < tt) return d.debug("ReplayTooShort"), null;
588
584
  const E = o.encode("]");
589
585
  return i.write(E), i.close(), s = new Uint8Array(await new Response(c.readable).arrayBuffer()), s;
590
586
  })(n - e, n);
591
- }, Pe = async (e) => {
592
- const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders: o, replayParams: s, triggerTimestamp: c } = e, i = await Jt(1e3 * s.replayDurationSeconds, c);
587
+ }, Te = async (e) => {
588
+ const { surveyId: t, responseGroupId: n, visitorId: a, apiUrl: r, completeUploadHeaders: o, replayParams: s, triggerTimestamp: c } = e, i = await zt(1e3 * s.replayDurationSeconds, c);
593
589
  if (!(i != null && i.length)) return void d.info("FileDataEmpty", { surveyId: t });
594
- const u = ((p, h, w) => {
595
- const E = p.length, P = 1024 * h * 1024, f = Math.ceil(E / w), v = Math.max(P, f), S = [];
590
+ const l = ((p, h, w) => {
591
+ const E = p.length, T = 1024 * h * 1024, f = Math.ceil(E / w), v = Math.max(T, f), S = [];
596
592
  let R = 0;
597
593
  for (; R < E; ) S.push(p.slice(R, R + v)), R += v;
598
594
  return S;
599
- })(i, s.minimumChunkSizeMb, s.signedUrls.length), y = await Promise.all(u.map(async (p, h) => {
600
- const w = X(), E = { apiUrl: r, chunkIndex: h + 1, completeUploadHeaders: o, etag: null, responseGroupId: n, status: "ReadyForUpload", surveyId: t, timestamp: c, totalChunks: u.length, data: p, uploadId: s.uploadId, uploadUrl: s.signedUrls[h].url, uuid: w, visitorId: a };
601
- return await (await l.openDB()).add("chunkUploads", { ...E, sessionId: E.sessionId ?? I }), E;
595
+ })(i, s.minimumChunkSizeMb, s.signedUrls.length), y = await Promise.all(l.map(async (p, h) => {
596
+ const w = X(), E = { apiUrl: r, chunkIndex: h + 1, completeUploadHeaders: o, etag: null, responseGroupId: n, status: "ReadyForUpload", surveyId: t, timestamp: c, totalChunks: l.length, data: p, uploadId: s.uploadId, uploadUrl: s.signedUrls[h].url, uuid: w, visitorId: a };
597
+ return await (await u.openDB()).add("chunkUploads", { ...E, sessionId: E.sessionId ?? I }), E;
602
598
  }));
603
599
  await (async (p, h) => {
604
600
  await nt(h), await Promise.all(p.map((w) => at(w)));
605
601
  })([s.uploadId], y);
606
602
  }, rt = async (e, t) => {
607
- if (T()) return d.debug("ReplayDisabled-ScheduleOrCapture");
603
+ if (P()) return d.debug("ReplayDisabled-ScheduleOrCapture");
608
604
  const { isHeatmap: n, isStandalone: a, replayParams: r, triggerTimestamp: o, responseGroupId: s } = e, c = async () => {
609
- setTimeout(() => V.removeListener(Z.QuestionAnswered, c), 0), D(async () => {
610
- r.replayDurationType === "before" ? await Pe(e) : await l.markPendingCaptureToCanUpload(s);
605
+ setTimeout(() => V.removeListener(Y.QuestionAnswered, c), 0), D(async () => {
606
+ r.replayDurationType === "before" ? await Te(e) : await u.markPendingCaptureToCanUpload(s);
611
607
  }, "Error in schedule/capture callback");
612
608
  };
613
609
  D(async () => {
614
610
  if (r.replayDurationType === "after" || r.replayDurationType === "beforeAndAfter")
615
- return !a && !n && V.on(Z.QuestionAnswered, c), void await st(e);
616
- if (a || n || t) await Pe(e), n && zt();
611
+ return !a && !n && V.on(Y.QuestionAnswered, c), void await st(e);
612
+ if (a || n || t) await Te(e), n && qt();
617
613
  else {
618
- const i = 35 + r.replayDurationSeconds, u = o - 1e3 * i, y = o;
619
- await l.updateEventsExpiredAt(u, y, r.expirationTimeLimitMinutes), V.on(Z.QuestionAnswered, c);
614
+ const i = 35 + r.replayDurationSeconds, l = o - 1e3 * i, y = o;
615
+ await u.updateEventsExpiredAt(l, y, r.expirationTimeLimitMinutes), V.on(Y.QuestionAnswered, c);
620
616
  }
621
617
  }, "Error in scheduling/capturing replay");
622
- }, zt = async () => {
618
+ }, qt = async () => {
623
619
  parseInt(_ ?? "0") || m.removeItem("sprig.isCapturingHeatmap"), m.getItem("sprig.teardownAfterCapture") && (Ge(), ot(), m.removeItem("sprig.teardownAfterCapture"));
624
- }, ot = async () => T() ? d.debug("ReplayDisabled-ClearData") : Promise.all([l.deleteBySessionId("events", I), l.deleteBySessionId("pendingCaptures", I)]).catch((e) => {
620
+ }, ot = async () => P() ? d.debug("ReplayDisabled-ClearData") : Promise.all([u.deleteBySessionId("events", I), u.deleteBySessionId("pendingCaptures", I)]).catch((e) => {
625
621
  H("Error clearing user replay data", e);
626
622
  }), st = async (e) => {
627
- if (T()) return;
628
- const { isHeatmap: t, surveyId: n } = e, a = await l.getPendingCaptures(), r = a == null ? void 0 : a.filter((i) => i.captureParams.surveyId === n);
623
+ if (P()) return;
624
+ const { isHeatmap: t, surveyId: n } = e, a = await u.getPendingCaptures(), r = a == null ? void 0 : a.filter((i) => i.captureParams.surveyId === n);
629
625
  if (r != null && r.length) return void d.info("PendingCaptureExists", { surveyId: n });
630
- t && (le(), m.setItem("sprig.isCapturingHeatmap", "true"), ge = Date.now(), g.inactivityInterval || (g.inactivityInterval = window.setInterval(() => {
626
+ t && (ue(), m.setItem("sprig.isCapturingHeatmap", "true"), ge = Date.now(), g.inactivityInterval || (g.inactivityInterval = window.setInterval(() => {
631
627
  var i;
632
- i = ge, Date.now() - i >= 3e4 && D(() => l.markPendingHeatmapsReady(), "Error in heatmap inactivity");
628
+ i = ge, Date.now() - i >= 3e4 && D(() => u.markPendingHeatmapsReady(), "Error in heatmap inactivity");
633
629
  }, 1e3)));
634
630
  const o = { ...e, replayParams: { ...e.replayParams } };
635
631
  e.replayParams.replayDurationType === "beforeAndAfter" && (o.replayParams.replayDurationSeconds *= 2), o.replayParams.replayDurationType = "before";
636
632
  const s = e.triggerTimestamp + 1e3 * e.replayParams.replayDurationSeconds;
637
- o.triggerTimestamp = s, _ = (parseInt(_ ?? "0") + 1).toString(), m.setItem("sprig.pendingCount", _), await (await l.openDB()).add("pendingCaptures", { canUpload: !1, captureParams: o, sessionId: I, targetTimestamp: s, timestamp: Date.now(), uuid: X() });
638
- }, qt = Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
633
+ o.triggerTimestamp = s, _ = (parseInt(_ ?? "0") + 1).toString(), m.setItem("sprig.pendingCount", _), await (await u.openDB()).add("pendingCaptures", { canUpload: !1, captureParams: o, sessionId: I, targetTimestamp: s, timestamp: Date.now(), uuid: X() });
634
+ }, Qt = Object.freeze(Object.defineProperty({ __proto__: null, RecordEvent: (e) => {
639
635
  U("Sprig_TrackEvent", e);
640
636
  }, RecordPageView: (e) => {
641
637
  e.description && (e.description = he(e.description)), U("Sprig_PageView", e);
@@ -645,30 +641,30 @@ const ye = async (e = !1) => {
645
641
  if (!e || !t) return !1;
646
642
  const r = window.UserLeap._API_URL, o = await _e({ surveyId: e, responseGroupUuid: t, eventDigest: n, apiUrl: r, headers: a }, !0);
647
643
  return !(o != null && o.error);
648
- }, checkPendingHeatmapsUrl: () => T() ? d.debug("ReplayDisabled-PendingHeatmaps") : D(async () => {
649
- const e = (await l.getPendingCaptures({ isHeatmap: !0 })).map((t) => ({ eventId: t.captureParams.eventId, uuid: t.uuid })).filter(({ eventId: t }) => !ct(t)).map(({ uuid: t }) => t);
650
- return d.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await l.markPendingHeatmapsReady(e), d.info("MarkedPendingHeatmapsReady")), e.length;
644
+ }, checkPendingHeatmapsUrl: () => P() ? d.debug("ReplayDisabled-PendingHeatmaps") : D(async () => {
645
+ const e = (await u.getPendingCaptures({ isHeatmap: !0 })).map((t) => ({ eventId: t.captureParams.eventId, uuid: t.uuid })).filter(({ eventId: t }) => !ct(t)).map(({ uuid: t }) => t);
646
+ return d.info("PendingHeatmapsToComplete", { count: e.length }), e.length && (await u.markPendingHeatmapsReady(e), d.info("MarkedPendingHeatmapsReady")), e.length;
651
647
  }, "Error marking pending heatmaps ready"), clearUserReplayData: ot, disableRecording: H, initializeReplay: async ({ maxReplayDurationSeconds: e, maxInflightRequests: t = 2, replaySettings: n, teardownAfter: a = !1, apiUrl: r, alwaysOnConfig: o }) => {
652
- if (o && Mt({ apiUrl: r, config: o, triggerSnapshot: () => {
653
- le();
648
+ if (o && _t({ apiUrl: r, config: o, triggerSnapshot: () => {
649
+ ue();
654
650
  } }), _ = m.getItem("sprig.pendingCount"), g.isRecording) return;
655
- if (a && m.setItem("sprig.teardownAfterCapture", "true"), T()) return d.debug("ReplayDisabled");
651
+ if (a && m.setItem("sprig.teardownAfterCapture", "true"), P()) return d.debug("ReplayDisabled");
656
652
  if (await (async () => {
657
653
  var i;
658
654
  if (!Ve()) return !0;
659
655
  if ((i = window.navigator.storage) != null && i.estimate) try {
660
- const { quota: u = 0, usage: y = 0 } = await window.navigator.storage.estimate(), p = (u - y) / 1024 ** 3;
656
+ const { quota: l = 0, usage: y = 0 } = await window.navigator.storage.estimate(), p = (l - y) / 1024 ** 3;
661
657
  return d.info("Storage", { availableGb: p }), p < 0.5;
662
658
  } catch {
663
659
  return !0;
664
660
  }
665
661
  return !1;
666
- })()) return d.debug("IDBNotSupported"), ue();
662
+ })()) return d.debug("IDBNotSupported"), le();
667
663
  try {
668
- const i = await l.openDB();
664
+ const i = await u.openDB();
669
665
  d.info("DBVersion", { version: i.version });
670
666
  } catch (i) {
671
- return d.error("ReplayOpenErr", { name: i.name }), i.name === "VersionError" && l.deleteDB(), ue();
667
+ return d.error("ReplayOpenErr", { name: i.name }), i.name === "VersionError" && u.deleteDB(), le();
672
668
  }
673
669
  D(async () => {
674
670
  await ye(!0);
@@ -677,13 +673,13 @@ const ye = async (e = !1) => {
677
673
  if (!c) return d.debug("MissingDuration");
678
674
  d.debug("ReplayInit"), await D(async () => {
679
675
  var i;
680
- n != null && n.minDuration && (tt = n.minDuration), n != null && n.batchDuration && (pe = n.batchDuration), i = t, Me.setLimit(i), Kt(), Gt(c + 35, 1800, c + 35), Wt();
681
- const u = window.UserLeap.replayLibraryURL ?? "https://cdn.sprig.com/dependencies/record.min.js";
676
+ n != null && n.minDuration && (tt = n.minDuration), n != null && n.batchDuration && (pe = n.batchDuration), i = t, Me.setLimit(i), Jt(), Wt(c + 35, 1800, c + 35), $t();
677
+ const l = window.UserLeap.replayLibraryURL ?? "https://cdn.sprig.com/dependencies/record.min.js";
682
678
  if (!window.rrwebRecord) {
683
679
  const { record: f } = await import(
684
680
  /* webpackIgnore: true */
685
681
  /* @vite-ignore */
686
- u
682
+ l
687
683
  );
688
684
  window.rrwebRecord = f;
689
685
  }
@@ -691,29 +687,29 @@ const ye = async (e = !1) => {
691
687
  if (!y) return d.error("RecordScriptFailed");
692
688
  let p = !0, h = 0;
693
689
  const w = { checkoutEveryNms: 3e4, sampling: { input: "last", scroll: 250, media: 800 }, ...n, mutationQueueEnabled: n == null ? void 0 : n.enableMutationQueue };
694
- var E, P;
690
+ var E, T;
695
691
  g.stopRecording = y({ emit: (f, v) => {
696
- if (f.type === B.Custom && (ge = Date.now()), T() || z()) return;
692
+ if (f.type === B.Custom && (ge = Date.now()), P() || z()) return;
697
693
  if (v && f.type === B.Meta) h = performance.now();
698
694
  else if (v && h && f.type === B.FullSnapshot) {
699
695
  const R = performance.now() - h;
700
- lt("sdk_replay_snapshot_seconds", R / 1e3);
696
+ ut("sdk_replay_snapshot_seconds", R / 1e3);
701
697
  }
702
698
  const S = p || !!v && f.type === B.Meta;
703
- p = !1, Ht(S, f), jt({ uuid: X(), event: JSON.stringify(f), isValidStart: S, timestamp: Date.now() });
699
+ p = !1, jt(S, f), Vt({ uuid: X(), event: JSON.stringify(f), isValidStart: S, timestamp: Date.now() });
704
700
  }, ...w }), g.isRecording = !!g.stopRecording, g.isRecording && (((f, v) => {
705
701
  window.addEventListener("message", (S) => {
706
702
  var R;
707
- S.data.type === vt && (fe.push({ source: S.source, origin: S.origin }), (R = S.source) == null || R.postMessage({ type: St, settings: f, replayLibraryUrl: v }, { targetOrigin: S.origin }));
703
+ S.data.type === St && (fe.push({ source: S.source, origin: S.origin }), (R = S.source) == null || R.postMessage({ type: Dt, settings: f, replayLibraryUrl: v }, { targetOrigin: S.origin }));
708
704
  });
709
- })(w, u), V.on("survey.complete", (f) => {
705
+ })(w, l), V.on("survey.complete", (f) => {
710
706
  var v;
711
707
  v = { id: f, userAgent: window.navigator.userAgent }, U("Sprig_SubmitSurvey", v);
712
- }), E = U, P = Ut, J || (b = E, G = P, window.addEventListener("click", Fe, C), window.addEventListener("pointerdown", je, C), window.addEventListener("mousedown", He, C), window.addEventListener("keydown", Le, C), window.addEventListener("scroll", Oe, C), J = !0, Pt(), kt()));
708
+ }), E = U, T = xt, J || (b = E, G = T, window.addEventListener("click", Fe, C), window.addEventListener("pointerdown", je, C), window.addEventListener("mousedown", He, C), window.addEventListener("keydown", Le, C), window.addEventListener("scroll", Oe, C), J = !0, kt(), Ut()));
713
709
  }, "Error initializing replay");
714
- }, isReplayPaused: z, isReplayRecording: () => g.isRecording, recordFullSnapshot: le, recordReplayPaused: () => {
710
+ }, isReplayPaused: z, isReplayRecording: () => g.isRecording, recordFullSnapshot: ue, recordReplayPaused: () => {
715
711
  U("Sprig_ReplayPaused", { timestamp: Date.now() }), m.setItem("sprig.isReplayPaused", "true");
716
712
  }, recordReplayResumed: () => {
717
713
  m.removeItem("sprig.isReplayPaused"), U("Sprig_ReplayResumed", { timestamp: Date.now() });
718
714
  }, scheduleCapture: st, scheduleOrCaptureReplay: rt, tryReplayAction: D, uploadReadyPendingCaptures: ye }, Symbol.toStringTag, { value: "Module" }));
719
- pt(qt);
715
+ pt(Qt);