@sprig-technologies/sprig-browser 2.33.1 → 2.33.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.
@@ -1,41 +1,41 @@
1
- var Ut = Object.defineProperty;
2
- var St = (t, e, n) => e in t ? Ut(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var $ = (t, e, n) => (St(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- import { g as T, s as Xe, l as R, e as w, S as u, v as Ze, m as k, b as M, h as et, E as re, D as F, c as It, r as B, i as kt, j as Et, k as _t, n as Fe, o as ze, a as xt, p as tt, d as Rt, q as rt } from "./metricsReporter-Dsn4xUH7.js";
5
- const rr = 360, ir = "ul-app", nr = "#e6e6e6", or = "#bd282a", sr = 1030, He = () => {
1
+ var It = Object.defineProperty;
2
+ var kt = (t, e, n) => e in t ? It(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var W = (t, e, n) => kt(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { l as R, g as P, s as et, e as y, S as w, v as tt, m as S, b as q, h as rt, E as re, D as M, c as Et, r as $, i as _t, j as xt, k as Rt, n as He, o as Ve, d as Dt, a as At, p as it, q as nt } from "./metricsReporter-qetrFwEv.js";
5
+ const nr = 360, or = "ul-app", sr = "#e6e6e6", ar = "#bd282a", dr = 1030, We = () => {
6
6
  try {
7
7
  return window.parent.Intercom;
8
8
  } catch {
9
9
  return null;
10
10
  }
11
- }, Ve = [Object.freeze(Object.defineProperty({ __proto__: null, disable: () => {
12
- const t = He();
11
+ }, Be = [Object.freeze(Object.defineProperty({ __proto__: null, disable: () => {
12
+ const t = We();
13
13
  t && (t.ul_wasVisible = !!document.querySelector("iframe.intercom-launcher-frame"), t.ul_wasVisible && t("update", { hide_default_launcher: !0 }));
14
14
  }, enable: () => {
15
- const t = He();
15
+ const t = We();
16
16
  t && (t.ul_wasVisible && t("update", { hide_default_launcher: !1 }), delete t.ul_wasVisible);
17
17
  } }, Symbol.toStringTag, { value: "Module" }))];
18
- class Dt {
18
+ class Ot {
19
19
  static disable() {
20
- Ve.forEach((e) => e.disable());
20
+ Be.forEach((e) => e.disable());
21
21
  }
22
22
  static enable() {
23
- Ve.forEach((e) => e.enable());
23
+ Be.forEach((e) => e.enable());
24
24
  }
25
25
  }
26
- const We = "ul-view-sdk-script", At = ["ios", "android"], q = "visitors", z = "environments";
27
- async function C(t, e) {
26
+ const Ne = "ul-view-sdk-script", Ct = ["ios", "android"], F = "visitors", z = "environments";
27
+ async function O(t, e) {
28
28
  var i, o, a;
29
29
  const { shouldDropOnRateLimit: n, ...s } = e;
30
- s.headers = Object.assign(T(window.UserLeap), s.headers);
31
- const r = await Xe(t, { ...s, shouldDropOnRateLimit: n });
30
+ s.headers = Object.assign(P(window.UserLeap), s.headers);
31
+ const r = await et(t, { ...s, shouldDropOnRateLimit: n });
32
32
  if (r.ok) {
33
33
  const l = (i = r.headers) == null ? void 0 : i.get("Authorization"), p = l ? l.split(" ") : void 0, d = p && p.length === 2 ? p[1] : void 0, c = (o = r.headers) == null ? void 0 : o.get("x-ul-visitor-id");
34
34
  if (window.UserLeap.userId && c === window.UserLeap.visitorId) {
35
- const y = R.getItemObject("sprig.anon.env.vid.map");
36
- y && y[window.UserLeap.envId] === c && (delete y[window.UserLeap.envId], R.setItemObject("sprig.anon.env.vid.map", y));
35
+ const g = R.getItemObject("sprig.anon.env.vid.map");
36
+ g && g[window.UserLeap.envId] === c && (delete g[window.UserLeap.envId], R.setItemObject("sprig.anon.env.vid.map", g));
37
37
  }
38
- d && c && (c !== window.UserLeap.visitorId || window.UserLeap.token !== d) && (x("token", d), x("vid", c), w.emit(u.VisitorIDUpdated, { visitorId: c }), window.UserLeap.token = d, window.UserLeap.visitorId = c);
38
+ d && c && (c !== window.UserLeap.visitorId || window.UserLeap.token !== d) && (x("token", d), x("vid", c), y.emit(w.VisitorIDUpdated, { visitorId: c }), window.UserLeap.token = d, window.UserLeap.visitorId = c);
39
39
  }
40
40
  return (a = r.json) != null && a.logMessage && console.warn(`[Sprig] ${r.json.logMessage}`), r;
41
41
  }
@@ -50,248 +50,231 @@ function Re() {
50
50
  function A(t, e, n) {
51
51
  const s = [window.UserLeap._API_URL, "sdk", t];
52
52
  return e && e.forEach((r) => {
53
- s.push(r), r === z ? s.push(window.UserLeap.envId) : r === q && s.push(Re());
53
+ s.push(r), r === z ? s.push(window.UserLeap.envId) : r === F && s.push(Re());
54
54
  }), n && s.push(n), s.join("/");
55
55
  }
56
- const X = async (t, e) => {
57
- var Te, je, Me;
58
- const { context: n, delay: s, forceBrandedLogo: r, endCard: i, isFeedback: o = !1, heatmap: a, locale: l, previewMode: p, productConfig: d, questions: c, responseGroupUid: y, surveyId: g, uuid: m, vid: I, sessionReplay: _, studyType: f } = t, v = T(window.UserLeap), U = ie(v), S = ge(v);
59
- if (_)
60
- if (U)
61
- w.emit(u.ReplayCapture, { responseGroupUid: y, hasQuestions: !!(c != null && c.length), surveyId: g, uploadId: _.uploadId, replayType: _.replayDurationType ?? "before", seconds: _.replayDurationSeconds, generateVideoUploadUrlPayload: { mediaRecordingUid: Ze(), mediaType: "screen", questionId: 1, responseGroupUid: y, surveyId: g, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), visitorId: window.UserLeap.visitorId, isReplay: !0 } });
62
- else {
63
- if (!k.replay)
64
- return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
65
- k.replay.scheduleOrCaptureReplay({ responseGroupId: y, surveyId: g, visitorId: I, replayParams: _, completeUploadHeaders: v, apiUrl: window.UserLeap._API_URL, triggerTimestamp: Date.now(), isStandalone: c.length === 0 });
66
- }
67
- if (a) {
68
- if (!k.replay)
69
- return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
70
- const { eventId: L, replayParams: J, responseGroupUid: fe, surveyId: ve } = a;
71
- await k.replay.initializeReplay({ maxReplayDurationSeconds: 300, maxInflightRequests: window.UserLeap.maxInflightReplayRequests, teardownAfter: !0, apiUrl: window.UserLeap._API_URL }), k.replay.tryReplayAction(() => {
72
- var qe;
73
- return (qe = k.replay) == null ? void 0 : qe.scheduleCapture({ apiUrl: window.UserLeap._API_URL, completeUploadHeaders: v, eventId: L, isHeatmap: !0, replayParams: J, responseGroupId: fe, surveyId: ve, triggerTimestamp: Date.now(), visitorId: I });
56
+ const X = async (t, e, n) => {
57
+ var Me, qe, Fe;
58
+ const { context: s, delay: r, forceBrandedLogo: i, endCard: o, isFeedback: a = !1, heatmap: l, locale: p, previewMode: d, productConfig: c, questions: g, responseGroupUid: f, surveyId: u, uuid: E, vid: _, sessionReplay: m, studyType: U } = t, b = P(window.UserLeap), I = ie(b), T = ge(b);
59
+ if (m) if (I) y.emit(w.ReplayCapture, { responseGroupUid: f, hasQuestions: !!(g != null && g.length), surveyId: u, uploadId: m.uploadId, replayType: m.replayDurationType ?? "before", seconds: m.replayDurationSeconds, generateVideoUploadUrlPayload: { mediaRecordingUid: tt(), mediaType: "screen", questionId: 1, responseGroupUid: f, surveyId: u, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), visitorId: window.UserLeap.visitorId, isReplay: !0 } });
60
+ else {
61
+ if (!S.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
62
+ S.replay.scheduleOrCaptureReplay({ responseGroupId: f, surveyId: u, visitorId: _, replayParams: m, completeUploadHeaders: b, apiUrl: window.UserLeap._API_URL, triggerTimestamp: Date.now(), isStandalone: g.length === 0 });
63
+ }
64
+ if (l) {
65
+ if (!S.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" };
66
+ const { eventId: L, replayParams: J, responseGroupUid: fe, surveyId: ve } = l;
67
+ await S.replay.initializeReplay({ maxReplayDurationSeconds: 300, maxInflightRequests: window.UserLeap.maxInflightReplayRequests, teardownAfter: !0, apiUrl: window.UserLeap._API_URL, replaySettings: n }), S.replay.tryReplayAction(() => {
68
+ var ze;
69
+ return (ze = S.replay) == null ? void 0 : ze.scheduleCapture({ apiUrl: window.UserLeap._API_URL, completeUploadHeaders: b, eventId: L, isHeatmap: !0, replayParams: J, responseGroupId: fe, surveyId: ve, triggerTimestamp: Date.now(), visitorId: _ });
74
70
  }, "Error in scheduling/capturing replay");
75
71
  }
76
- if (I == null || !(c != null && c.length))
77
- return M.info("CannotDisplaySurvey", { vid: I }), { success: !1, message: "[Sprig] no survey found", surveyState: "no survey" };
72
+ if (_ == null || !(g != null && g.length)) return q.info("CannotDisplaySurvey", { vid: _ }), { success: !1, message: "[Sprig] no survey found", surveyState: "no survey" };
78
73
  if (window.UserLeap.container) {
79
- M.info("AlreadyDisplayingSurvey");
74
+ q.info("AlreadyDisplayingSurvey");
80
75
  const L = "[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";
81
76
  return console.warn(L), { success: !1, message: L, surveyState: "no survey" };
82
77
  }
83
- if (I !== window.UserLeap.visitorId && m !== window.UserLeap.visitorId && !window.previewMode) {
78
+ if (_ !== window.UserLeap.visitorId && E !== window.UserLeap.visitorId && !window.previewMode) {
84
79
  const L = "Attempted to display survey to a different visitor";
85
80
  return window.UserLeap.reportError("DisplaySurvey", new Error(L)), { success: !1, message: L, surveyState: "no survey" };
86
81
  }
87
- M.info("ShowingSurvey", { surveyId: g }), (Te = k.replay) == null || Te.RecordSurveyShown({ id: g, userAgent: window.navigator.userAgent }), Dt.disable(), w.emit(u.SurveyWillPresent, { name: u.SurveyWillPresent, "survey.id": g });
88
- let O, h, E, D, H = document.createElement("div");
89
- const K = (L) => {
82
+ q.info("ShowingSurvey", { surveyId: u }), (Me = S.replay) == null || Me.RecordSurveyShown({ id: u, userAgent: window.navigator.userAgent }), Ot.disable(), y.emit(w.SurveyWillPresent, { name: w.SurveyWillPresent, "survey.id": u });
83
+ let v, D, k, H, V = document.createElement("div");
84
+ const Ce = (L) => {
90
85
  const { "view.version": J } = L;
91
- J !== v["x-ul-sdk-version"] && nt(), w.removeListener("verify.view.version", K);
86
+ J !== b["x-ul-sdk-version"] && st(), y.removeListener("verify.view.version", Ce);
92
87
  };
93
- w.on("verify.view.version", K), window.UserLeap.useMobileStyling = S, et(v) ? (O = "ul-direct-embeded-frame", h = document.head, E = window, D = !1, (() => {
94
- const L = T(window.UserLeap), J = ie(L), fe = window.UserLeap.forceDirectEmbed, ve = L["userleap-platform"] === "web";
88
+ y.on("verify.view.version", Ce), window.UserLeap.useMobileStyling = T, rt(b) ? (v = "ul-direct-embeded-frame", D = document.head, k = window, H = !1, (() => {
89
+ const L = P(window.UserLeap), J = ie(L), fe = window.UserLeap.forceDirectEmbed, ve = L["userleap-platform"] === "web";
95
90
  return J || fe && ve;
96
- })() && (it(g, o), H.id = O, window.UserLeap.container.appendChild(H), ot(), w.emit(u.SurveyLifeCycle, { state: "presented" }), w.emit(u.SurveyPresented, { name: u.SurveyPresented, "survey.id": g }))) : { frameId: O, contentWinDocHead: h, contentWindow: E, hasOverlay: D, iframe: H } = Ct({ productConfig: d, useMobileStyling: S, surveyId: g, isFeedback: o }), window.UserLeap.frameId = O;
97
- const N = { apiURL: window.UserLeap._API_URL, cards: c, configureExitOnOverlayClick: (L) => {
98
- w.once(u.CloseSurveyOnOverlayClick, L);
99
- }, context: n, endCard: i, envId: window.UserLeap.envId, eventEmitFn: w.emit.bind(w), fontFamily: window.UserLeap.fontFamily, fontFamilyURL: window.UserLeap.fontFamilyURL, forceBrandedLogo: r, frame: H, headers: v, locale: l, mobileSDKVersion: window.UserLeap.mobileSDKVersion, previewKey: R.getItem("sprig.previewKey"), previewMode: p, productConfig: { framePosition: d == null ? void 0 : d.framePosition, desktopDisplay: d == null ? void 0 : d.desktopDisplay, placement: d == null ? void 0 : d.placement }, responseGroupUid: y, startingQuestionIdx: (je = window.UserLeap.config) == null ? void 0 : je.startingQuestionIdx, studyType: f, styleNonce: window.UserLeap.styleNonce, surveyId: g, tabTitle: document.title, trackPageViewUrl: e, ulEvents: re, upchunkLibraryURL: window.UserLeap.upchunkLibraryURL, useMobileStyling: S, userId: m, viewDocument: E == null ? void 0 : E.document, viewWindow: E, visitorAttributes: { externalUserId: window.UserLeap.userId, email: window.UserLeap.email }, ...window.UserLeap._config };
100
- (Me = window.UserLeap._config) != null && Me.startingQuestionIdx && (window.UserLeap._config = { ...window.UserLeap._config, startingQuestionIdx: null });
101
- const Lt = (o ? window.UserLeap.feedbackCustomStyles : window.UserLeap.customStyles) ?? d.customStyles;
102
- N.customStyles = Lt, E && (E.__cfg = N);
103
- const ye = window.UserLeap.viewSDKURL ? window.UserLeap.viewSDKURL : N.path, Oe = document.getElementById(We);
104
- Oe && Oe.remove();
91
+ })() && (ot(u, a), V.id = v, window.UserLeap.container.appendChild(V), at(), y.emit(w.SurveyLifeCycle, { state: "presented" }), y.emit(w.SurveyPresented, { name: w.SurveyPresented, "survey.id": u }))) : { frameId: v, contentWinDocHead: D, contentWindow: k, hasOverlay: H, iframe: V } = Tt({ productConfig: c, useMobileStyling: T, surveyId: u, isFeedback: a }), window.UserLeap.frameId = v;
92
+ const G = { apiURL: window.UserLeap._API_URL, cards: g, configureExitOnOverlayClick: (L) => {
93
+ y.once(w.CloseSurveyOnOverlayClick, L);
94
+ }, context: s, endCard: o, envId: window.UserLeap.envId, eventEmitFn: y.emit.bind(y), fontFamily: window.UserLeap.fontFamily, fontFamilyURL: window.UserLeap.fontFamilyURL, forceBrandedLogo: i, frame: V, headers: b, locale: p, mobileSDKVersion: window.UserLeap.mobileSDKVersion, previewKey: R.getItem("sprig.previewKey"), previewMode: d, productConfig: { framePosition: c == null ? void 0 : c.framePosition, desktopDisplay: c == null ? void 0 : c.desktopDisplay, placement: c == null ? void 0 : c.placement }, responseGroupUid: f, startingQuestionIdx: (qe = window.UserLeap.config) == null ? void 0 : qe.startingQuestionIdx, studyType: U, styleNonce: window.UserLeap.styleNonce, surveyId: u, tabTitle: document.title, trackPageViewUrl: e, ulEvents: re, upchunkLibraryURL: window.UserLeap.upchunkLibraryURL, useMobileStyling: T, userId: E, viewDocument: k == null ? void 0 : k.document, viewWindow: k, visitorAttributes: { externalUserId: window.UserLeap.userId, email: window.UserLeap.email }, ...window.UserLeap._config };
95
+ (Fe = window.UserLeap._config) != null && Fe.startingQuestionIdx && (window.UserLeap._config = { ...window.UserLeap._config, startingQuestionIdx: null });
96
+ const St = (a ? window.UserLeap.feedbackCustomStyles : window.UserLeap.customStyles) ?? c.customStyles;
97
+ G.customStyles = St, k && (k.__cfg = G);
98
+ const ye = window.UserLeap.viewSDKURL ? window.UserLeap.viewSDKURL : G.path, Pe = document.getElementById(Ne);
99
+ Pe && Pe.remove();
105
100
  const me = function() {
106
101
  const L = document.createElement("script");
107
- return window.UserLeap.nonce && L.setAttribute("nonce", window.UserLeap.nonce), L.id = We, L;
108
- }(), Ce = () => {
102
+ return window.UserLeap.nonce && L.setAttribute("nonce", window.UserLeap.nonce), L.id = Ne, L;
103
+ }(), Te = () => {
109
104
  window.UserLeap.container && Object.assign(window.UserLeap.container.style, { display: "flex" });
110
105
  };
111
- if (N.installationMethod === "web-npm" || N.installationMethod === "web-npm-bundled") {
112
- const { default: L } = await import("./view-CHGRuuXh.js");
113
- L.configure(N), D && window.UserLeap.container && Ce();
114
- } else
115
- ye && (me.src = ye, D && me.addEventListener("load", () => {
116
- window.UserLeap.container && Ce();
117
- }), E == null || E.addEventListener("error", (L) => {
118
- L.target instanceof HTMLScriptElement && L.target.src === ye && window.UserLeap.reportError("loadFrameScript", new Error("Frame script failed to load"));
119
- }, { capture: !0, once: !0 }));
120
- h == null || h.appendChild(me);
121
- const Pe = { success: !0, surveyState: "ready", surveyId: g, responseGroupUid: y };
122
- return window.UserLeap.isMobileSDK && s && (Pe.delay = s), Pe;
106
+ if (G.installationMethod === "web-npm" || G.installationMethod === "web-npm-bundled") {
107
+ const { default: L } = await import("./view-Bml35A_s.js");
108
+ L.configure(G), H && window.UserLeap.container && Te();
109
+ } else ye && (me.src = ye, H && me.addEventListener("load", () => {
110
+ window.UserLeap.container && Te();
111
+ }), k == null || k.addEventListener("error", (L) => {
112
+ L.target instanceof HTMLScriptElement && L.target.src === ye && window.UserLeap.reportError("loadFrameScript", new Error("Frame script failed to load"));
113
+ }, { capture: !0, once: !0 }));
114
+ D == null || D.appendChild(me);
115
+ const je = { success: !0, surveyState: "ready", surveyId: u, responseGroupUid: f };
116
+ return window.UserLeap.isMobileSDK && r && (je.delay = r), je;
123
117
  };
124
118
  function ge(t) {
125
119
  var n;
126
- if (window.UserLeap.useMobileStyling !== void 0)
127
- return window.UserLeap.useMobileStyling;
120
+ if (window.UserLeap.useMobileStyling !== void 0) return window.UserLeap.useMobileStyling;
128
121
  const e = ((n = window.UserLeap.windowDimensions) == null ? void 0 : n.width) ?? document.body.clientWidth;
129
122
  return ie(t) || e > 10 && e < 500;
130
123
  }
131
124
  function ie(t) {
132
- return At.includes(t["userleap-platform"]);
125
+ return Ct.includes(t["userleap-platform"]);
133
126
  }
134
127
  const De = "ul-frame";
135
128
  window.UserLeap && window.Sprig && (window.Sprig._gtm ? window.Sprig = window.UserLeap : window.UserLeap = window.Sprig), window.UserLeap || (window.UserLeap = window.Sprig), window.Sprig || (window.Sprig = window.UserLeap);
136
- const he = "0px", it = (t, e, n) => {
129
+ const he = "0px", ot = (t, e, n) => {
137
130
  window.UserLeap.container = document.createElement("div"), window.UserLeap.container.className = "ul-container" + (e ? " ul-container-feedback" : ""), t && (window.UserLeap.container.dataset.studyId = t.toString());
138
- const s = at();
131
+ const s = lt();
139
132
  n && s && !window.UserLeap.useMobileStyling ? s.appendChild(window.UserLeap.container) : document.body.appendChild(window.UserLeap.container);
140
- }, nt = (t, e) => {
133
+ }, st = (t, e) => {
141
134
  var s;
142
- Tt();
135
+ Mt();
143
136
  const n = window.UserLeap.container;
144
- if (n)
145
- try {
146
- (s = n.parentNode) == null || s.removeChild(n), window.UserLeap.container = null, x("trackStartUrl", null), w.emit(u.SurveyLifeCycle, { state: "dismissed" }), w.emit(u.SurveyClosed, { name: u.SurveyClosed, initiator: t, "survey.id": parseInt(n.dataset.studyId), ...e && { studyType: e } });
147
- } catch (r) {
148
- console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} ` + n), r instanceof Error && window.UserLeap.reportError("dismissActiveSurvey", r);
149
- }
150
- }, ot = () => {
151
- w.once(u.SurveyWillClose, ({ initiator: t, studyType: e }) => {
152
- w.removeAllListeners(u.CloseSurveyOnOverlayClick), nt(t, e);
137
+ if (n) try {
138
+ (s = n.parentNode) == null || s.removeChild(n), window.UserLeap.container = null, x("trackStartUrl", null), y.emit(w.SurveyLifeCycle, { state: "dismissed" }), y.emit(w.SurveyClosed, { name: w.SurveyClosed, initiator: t, "survey.id": parseInt(n.dataset.studyId), ...e && { studyType: e } });
139
+ } catch (r) {
140
+ console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} ` + n), r instanceof Error && window.UserLeap.reportError("dismissActiveSurvey", r);
141
+ }
142
+ }, at = () => {
143
+ y.once(w.SurveyWillClose, ({ initiator: t, studyType: e }) => {
144
+ y.removeAllListeners(w.CloseSurveyOnOverlayClick), st(t, e);
153
145
  });
154
- }, Ot = (t, e, n, s) => {
146
+ }, Pt = (t, e, n, s) => {
155
147
  var d, c;
156
148
  const r = { position: "fixed", bottom: "0px", right: he, border: 0, backgroundColor: "rgba(0,0,0,0)", zIndex: 2147483646, transition: "height 0.2s ease-in-out", maxWidth: "100%" }, i = Object.assign({}, e, window.UserLeap), { desktopDisplay: o } = e || {}, a = o === "center-modal";
157
149
  let l;
158
150
  a && (i.framePosition = "center");
159
151
  let p = !1;
160
- if (n)
161
- (d = window.UserLeap.windowDimensions) != null && d.width ? r.width = `${window.UserLeap.windowDimensions.width}px` : r.width = "100%", (c = window.UserLeap.windowDimensions) != null && c.height ? r.maxHeight = window.UserLeap.windowDimensions.height - 20 + "px" : window.UserLeap.maxHeight ? r.maxHeight = window.UserLeap.maxHeight : r.maxHeight = document.body.clientHeight - 20 + "px", ["light", "dark"].includes(i.overlayStyleMobile) && (p = !0);
152
+ if (n) (d = window.UserLeap.windowDimensions) != null && d.width ? r.width = `${window.UserLeap.windowDimensions.width}px` : r.width = "100%", (c = window.UserLeap.windowDimensions) != null && c.height ? r.maxHeight = window.UserLeap.windowDimensions.height - 20 + "px" : window.UserLeap.maxHeight ? r.maxHeight = window.UserLeap.maxHeight : r.maxHeight = document.body.clientHeight - 20 + "px", ["light", "dark"].includes(i.overlayStyleMobile) && (p = !0);
162
153
  else {
163
154
  r.width = "360px", r.maxHeight = window.UserLeap.maxHeight || "66vh";
164
- const y = () => {
155
+ const g = () => {
165
156
  p = !0, l = { margin: "auto", position: "static" };
166
157
  };
167
- if (s)
168
- a ? y() : l = { position: "relative", height: "300px" };
169
- else
170
- switch (i.framePosition) {
171
- case "bottomLeft":
172
- l = { left: he };
173
- break;
174
- case "topLeft":
175
- l = { left: he, top: 0 };
176
- break;
177
- case "topRight":
178
- l = { top: 0 };
179
- break;
180
- case "center":
181
- y();
182
- }
158
+ if (s) a ? g() : l = { position: "relative", height: "300px" };
159
+ else switch (i.framePosition) {
160
+ case "bottomLeft":
161
+ l = { left: he };
162
+ break;
163
+ case "topLeft":
164
+ l = { left: he, top: 0 };
165
+ break;
166
+ case "topRight":
167
+ l = { top: 0 };
168
+ break;
169
+ case "center":
170
+ g();
171
+ }
183
172
  }
184
- return p && ((y, g) => {
185
- const m = { position: "fixed", overflow: "auto", top: "0px", left: "0px", display: "none", height: "100%", width: "100%", transition: "background-color 0.3s ease-out", zIndex: 2147483646 }, I = g ? y.overlayStyleMobile : y.overlayStyle;
186
- m["background-color"] = I === "light" ? "rgba(255,255,255, 0.95)" : "rgba(0,0,0,0.9)", g || (m.margin = "auto"), window.UserLeap.container && Object.assign(window.UserLeap.container.style, m);
173
+ return p && ((g, f) => {
174
+ const u = { position: "fixed", overflow: "auto", top: "0px", left: "0px", display: "none", height: "100%", width: "100%", transition: "background-color 0.3s ease-out", zIndex: 2147483646 }, E = f ? g.overlayStyleMobile : g.overlayStyle;
175
+ u["background-color"] = E === "light" ? "rgba(255,255,255, 0.95)" : "rgba(0,0,0,0.9)", f || (u.margin = "auto"), window.UserLeap.container && Object.assign(window.UserLeap.container.style, u);
187
176
  })(i, n), Object.assign(t.style, r, l), p;
188
- }, Ct = ({ productConfig: t, useMobileStyling: e, surveyId: n, isFeedback: s }) => {
189
- var y, g;
177
+ }, Tt = ({ productConfig: t, useMobileStyling: e, surveyId: n, isFeedback: s }) => {
178
+ var g, f;
190
179
  const r = De, i = s && t.desktopDisplay === "slider";
191
- it(n, s, i), Pt();
180
+ ot(n, s, i), jt();
192
181
  const o = document.createElement("iframe");
193
182
  o.id = r, o.setAttribute("title", "Sprig User Feedback Dialog");
194
- const a = Ot(o, t, e, s);
195
- ot();
183
+ const a = Pt(o, t, e, s);
184
+ at();
196
185
  let l = !1;
197
- o.setHeight = (m) => {
198
- parseInt(o.style.height) == m && l || (l = !0, o.style.height = `${m}px`, w.emit(u.SurveyHeight, { name: u.SurveyHeight, contentFrameHeight: m, "survey.id": n }));
186
+ o.setHeight = (u) => {
187
+ parseInt(o.style.height) == u && l || (l = !0, o.style.height = `${u}px`, y.emit(w.SurveyHeight, { name: w.SurveyHeight, contentFrameHeight: u, "survey.id": n }));
199
188
  };
200
189
  let p = !1;
201
- o.setWidth = (m) => {
202
- parseInt(o.style.width) == m && p || (p = !0, o.style.width = `${m}px`, w.emit(u.SurveyWidth, { name: u.SurveyWidth, contentFrameWidth: m, "survey.id": n }));
203
- }, (y = window.UserLeap.container) == null || y.appendChild(o), t && (e ? t.exitOnOverlayClickMobile : t.exitOnOverlayClick) && window.UserLeap.container && (window.UserLeap.container.onclick = () => {
204
- w.emit(u.CloseSurveyOnOverlayClick);
205
- }), w.emit(u.SurveyLifeCycle, { state: "presented" }), w.emit(u.SurveyPresented, { name: u.SurveyPresented, "survey.id": n });
206
- const d = (g = o.contentWindow) == null ? void 0 : g.document;
190
+ o.setWidth = (u) => {
191
+ parseInt(o.style.width) == u && p || (p = !0, o.style.width = `${u}px`, y.emit(w.SurveyWidth, { name: w.SurveyWidth, contentFrameWidth: u, "survey.id": n }));
192
+ }, (g = window.UserLeap.container) == null || g.appendChild(o), t && (e ? t.exitOnOverlayClickMobile : t.exitOnOverlayClick) && window.UserLeap.container && (window.UserLeap.container.onclick = () => {
193
+ y.emit(w.CloseSurveyOnOverlayClick);
194
+ }), y.emit(w.SurveyLifeCycle, { state: "presented" }), y.emit(w.SurveyPresented, { name: w.SurveyPresented, "survey.id": n });
195
+ const d = (f = o.contentWindow) == null ? void 0 : f.document;
207
196
  if (d && (d.open("text/html", "replace"), d.write("<!doctype html><head></head><body></body></html>"), d.close(), !e)) {
208
- const m = d.body;
209
- m.style.display = "flex", m.style.alignItems = "center";
197
+ const u = d.body;
198
+ u.style.display = "flex", u.style.alignItems = "center";
210
199
  }
211
200
  const c = d == null ? void 0 : d.head;
212
201
  return { frameId: r, contentWinDocHead: c, contentWindow: o.contentWindow, hasOverlay: a, iframe: o };
213
- }, st = { [u.SurveyFadingOut]: () => {
202
+ }, dt = { [w.SurveyFadingOut]: () => {
214
203
  window.UserLeap.container && Object.assign(window.UserLeap.container.style, { "background-color": "rgba(0,0,0,0)" });
215
- } }, Pt = () => {
216
- Object.entries(st).forEach(([t, e]) => {
217
- w.on(t, e);
204
+ } }, jt = () => {
205
+ Object.entries(dt).forEach(([t, e]) => {
206
+ y.on(t, e);
218
207
  });
219
- }, Tt = () => {
220
- Object.entries(st).forEach(([t, e]) => {
221
- w.off(t, e);
208
+ }, Mt = () => {
209
+ Object.entries(dt).forEach(([t, e]) => {
210
+ y.off(t, e);
222
211
  });
223
- }, j = (t) => !!t && t.nodeType === Node.ELEMENT_NODE, Be = (t) => t instanceof HTMLElement || t instanceof SVGElement, se = ({ document: t, elementId: e, styleString: n, nonce: s }) => {
212
+ }, j = (t) => !!t && t.nodeType === Node.ELEMENT_NODE, $e = (t) => t instanceof HTMLElement || t instanceof SVGElement, se = ({ document: t, elementId: e, styleString: n, nonce: s }) => {
224
213
  const r = t.getElementById(e);
225
- if (r)
226
- return void (r.textContent = n);
214
+ if (r) return void (r.textContent = n);
227
215
  const i = t.createElement("style");
228
216
  s && (i.nonce = s), i.textContent = n, i.id = e, t.head.appendChild(i);
229
- }, jt = (t, e) => {
217
+ }, qt = (t, e) => {
230
218
  const n = e.querySelector(".sprig-question-body");
231
- if (!j(n))
232
- return t;
219
+ if (!j(n)) return t;
233
220
  const s = n.scrollHeight;
234
221
  return s < 100 ? t : t - (s - 100);
235
- }, Ne = (t, e) => {
222
+ }, Ge = (t, e) => {
236
223
  const n = e.querySelector(t);
237
- if (!j(n))
238
- return 0;
224
+ if (!j(n)) return 0;
239
225
  const s = getComputedStyle(n);
240
226
  return parseFloat(s.paddingLeft) + parseFloat(s.paddingRight) + (parseFloat(s.marginLeft) + parseFloat(s.marginRight)) + (parseFloat(s.borderLeftWidth) + parseFloat(s.borderRightWidth));
241
- }, Mt = (t, e, n) => {
227
+ }, Ft = (t, e, n) => {
242
228
  const s = t.querySelector(".ul-card__container"), r = t.querySelector(".ul-app");
243
229
  let i = 600, o = 360, a = 0;
244
230
  if (j(s) && j(r)) {
245
231
  const l = s.querySelector(".ul-card--matrix_grid"), p = !l && e && n;
246
232
  try {
247
- p && (r.style.width = "360px"), i = s.clientHeight, i += ((y) => {
248
- const g = y.querySelector(".sprig-question-body"), m = y.querySelector(".ul-card"), I = y.querySelector(".ul-card-main-content"), _ = y.querySelector(".ul-footer"), f = y.querySelector(".sprig-container");
249
- let v = 0;
250
- return j(m) && (v += m.scrollHeight - m.clientHeight), j(I) && (v += I.scrollHeight - I.clientHeight), j(g) && (v += g.scrollHeight - g.clientHeight), j(_) && j(f) && f.clientHeight === 0 && (v += _.clientHeight), v;
233
+ p && (r.style.width = "360px"), i = s.clientHeight, i += ((g) => {
234
+ const f = g.querySelector(".sprig-question-body"), u = g.querySelector(".ul-card"), E = g.querySelector(".ul-card-main-content"), _ = g.querySelector(".ul-footer"), m = g.querySelector(".sprig-container");
235
+ let U = 0;
236
+ return j(u) && (U += u.scrollHeight - u.clientHeight), j(E) && (U += E.scrollHeight - E.clientHeight), j(f) && (U += f.scrollHeight - f.clientHeight), j(_) && j(m) && m.clientHeight === 0 && (U += _.clientHeight), U;
251
237
  })(t);
252
238
  const d = getComputedStyle(s);
253
239
  a = i;
254
240
  const c = parseFloat(d.marginTop) + parseFloat(d.marginBottom);
255
- i += c + (parseFloat(d.borderTopWidth) + parseFloat(d.borderBottomWidth)), l && (o = l.scrollWidth, o += Ne(".ul-card__container", t), o += Ne(".sprig-question-body", t));
241
+ i += c + (parseFloat(d.borderTopWidth) + parseFloat(d.borderBottomWidth)), l && (o = l.scrollWidth, o += Ge(".ul-card__container", t), o += Ge(".sprig-question-body", t));
256
242
  } finally {
257
243
  p && r.style.removeProperty("width");
258
244
  }
259
245
  }
260
- return [i + 1, o, jt(a, t)];
261
- }, ar = (t) => {
246
+ return [i + 1, o, qt(a, t)];
247
+ }, lr = (t) => {
262
248
  const e = t.querySelector(".ul-card__container");
263
249
  e && (e.scrollTop = 0);
264
- }, at = () => b, G = () => document.getElementById("sprig-feedback-container"), Se = () => document.getElementById("sprig-feedback-loading-animation"), dt = () => !!document.getElementById(De);
265
- let $e = !1, b = null, P = null, Ae = !1, Z = null, V = null;
266
- const qt = ["bottom-left", "bottom-right", "center-left", "center-right"], ae = () => {
250
+ }, lt = () => h, K = () => document.getElementById("sprig-feedback-container"), Se = () => document.getElementById("sprig-feedback-loading-animation"), ct = () => !!document.getElementById(De);
251
+ let Ke = !1, h = null, C = null, Ae = !1, Z = null, B = null;
252
+ const zt = ["bottom-left", "bottom-right", "center-left", "center-right"], ae = () => {
267
253
  var e;
268
254
  const t = window.UserLeap.container;
269
255
  return ((e = t == null ? void 0 : t.parentElement) == null ? void 0 : e.id) === "sprig-feedback-loading-container";
270
- }, lt = () => document.getElementById("sprig-feedback-error-container"), ct = () => {
271
- if (!b)
272
- return 0;
273
- const t = b == null ? void 0 : b.clientWidth, e = window.getComputedStyle(b);
256
+ }, pt = () => document.getElementById("sprig-feedback-error-container"), ut = () => {
257
+ if (!h) return 0;
258
+ const t = h == null ? void 0 : h.clientWidth, e = window.getComputedStyle(h);
274
259
  return t + parseInt(e.borderRightWidth || "0") + parseInt(e.borderLeftWidth || "0");
275
260
  }, de = (t) => {
276
- const e = G();
277
- e && (V != null && V.endsWith("right") ? e.style.right = `${t}px` : V != null && V.endsWith("left") && (e.style.left = `${t}px`));
261
+ const e = K();
262
+ e && (B != null && B.endsWith("right") ? e.style.right = `${t}px` : B != null && B.endsWith("left") && (e.style.left = `${t}px`));
278
263
  }, be = () => {
279
- if (b && (ae() || lt())) {
280
- w.off(u.SurveyAppeared, Y), Ie();
281
- const t = ct();
264
+ if (h && (ae() || pt())) {
265
+ y.off(w.SurveyAppeared, Y), Ie();
266
+ const t = ut();
282
267
  return de(-t), !0;
283
268
  }
284
269
  return !1;
285
270
  }, Y = () => {
286
- if (!b || !P)
287
- return;
271
+ if (!h || !C) return;
288
272
  const t = Se();
289
- t && t.remove(), b.style.height = "auto", b.style.width = "auto", P.disabled = !1, Ae = !1;
273
+ t && t.remove(), h.style.height = "auto", h.style.width = "auto", C.disabled = !1, Ae = !1;
290
274
  }, Ie = () => {
291
- if (b && !Se()) {
275
+ if (h && !Se()) {
292
276
  const t = (() => {
293
- if (Se())
294
- return;
277
+ if (Se()) return;
295
278
  const e = document.createElement("div");
296
279
  return e.className = "ul-loading-spinner-container", e.id = "sprig-feedback-loading-animation", e.role = "progressbar", e.setAttribute("aria-live", "polite"), e.setAttribute("aria-busy", "true"), e.setAttribute("aria-label", "Processing..."), e.innerHTML = `
297
280
  <div class="ul-loading-spinner">
@@ -302,62 +285,57 @@ const qt = ["bottom-left", "bottom-right", "center-left", "center-right"], ae =
302
285
  </div>
303
286
  `, e;
304
287
  })();
305
- t && (b.style.height = "300px", b.style.width = "360px", b.appendChild(t));
288
+ t && (h.style.height = "300px", h.style.width = "360px", h.appendChild(t));
306
289
  }
307
- }, Ge = () => {
308
- b && P && (de(0), P.disabled = !0, Ae = !0);
309
- }, pt = async (t, e, n) => {
290
+ }, Je = () => {
291
+ h && C && (de(0), C.disabled = !0, Ae = !0);
292
+ }, wt = async (t, e, n) => {
310
293
  const { buttonTheme: s, customStyles: r, eventId: i, placement: o, desktopDisplay: a, feedbackLabel: l, surveyUuid: p, surveyId: d } = t;
311
294
  window.UserLeap.feedbackCustomStyles = void 0;
312
- let c = G();
295
+ let c = K();
313
296
  if (c) {
314
- if (!e && i === Z)
315
- return;
316
- c.remove(), w.off(re.SURVEY_FADING_OUT, be);
317
- }
318
- Z = i, se({ document, elementId: "sprig-feedback-style", styleString: '.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}', nonce: window.UserLeap.styleNonce }), se({ document, elementId: "ul-custom-style", styleString: r ?? "", nonce: window.UserLeap.styleNonce }), $e = a === "center-modal", V = o;
319
- const [y, g] = o.split("-");
320
- ((f) => {
321
- if (G() || !qt.includes(f))
322
- return;
323
- const [v, U] = f.split("-"), S = document.createElement("div");
324
- S.id = "sprig-feedback-container", S.classList.add(`sprig-feedback-container-${U}`, `sprig-feedback-container-${v}`), document.body.appendChild(S);
325
- })(o), c = G(), P = document.createElement("button");
326
- const m = document.createElement("div");
327
- m.className = "sprig-feedback-button-label", m.innerText = l, P.appendChild(m), P.id = "sprig-feedback-button", P.classList.add(`sprig-feedback-button-${g}`, `sprig-feedback-button-${y}`, `sprig-feedback-button-${s}`, "fade-in-transition"), w.on(re.SURVEY_FADING_OUT, be), P.addEventListener("click", async () => {
328
- const f = document.getElementById("sprig-feedback-error-container");
329
- if (dt() || lt()) {
297
+ if (!e && i === Z) return;
298
+ c.remove(), y.off(re.SURVEY_FADING_OUT, be);
299
+ }
300
+ Z = i, se({ document, elementId: "sprig-feedback-style", styleString: '.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}', nonce: window.UserLeap.styleNonce }), se({ document, elementId: "ul-custom-style", styleString: r ?? "", nonce: window.UserLeap.styleNonce }), Ke = a === "center-modal", B = o;
301
+ const [g, f] = o.split("-");
302
+ ((m) => {
303
+ if (K() || !zt.includes(m)) return;
304
+ const [U, b] = m.split("-"), I = document.createElement("div");
305
+ I.id = "sprig-feedback-container", I.classList.add(`sprig-feedback-container-${b}`, `sprig-feedback-container-${U}`), document.body.appendChild(I);
306
+ })(o), c = K(), C = document.createElement("button");
307
+ const u = document.createElement("div");
308
+ u.className = "sprig-feedback-button-label", u.innerText = l, C.appendChild(u), C.id = "sprig-feedback-button", C.classList.add(`sprig-feedback-button-${f}`, `sprig-feedback-button-${g}`, `sprig-feedback-button-${s}`, "fade-in-transition"), y.on(re.SURVEY_FADING_OUT, be), C.addEventListener("click", async () => {
309
+ const m = document.getElementById("sprig-feedback-error-container");
310
+ if (ct() || pt()) {
330
311
  if (be()) {
331
- w.emit(u.SurveyCloseRequested, { name: u.SurveyCloseRequested, initiator: F.FeedbackClosed, studyType: "feedbackButton", "survey.id": d }), w.emit(u.SurveyWillClose, { name: u.SurveyWillClose, initiator: F.FeedbackClosed, studyType: "feedbackButton", "survey.id": d });
332
- const U = G();
333
- f && U && (U.remove(), Z = null, b = null);
312
+ y.emit(w.SurveyCloseRequested, { name: w.SurveyCloseRequested, initiator: M.FeedbackClosed, studyType: "feedbackButton", "survey.id": d }), y.emit(w.SurveyWillClose, { name: w.SurveyWillClose, initiator: M.FeedbackClosed, studyType: "feedbackButton", "survey.id": d });
313
+ const b = K();
314
+ m && b && (b.remove(), Z = null, h = null);
334
315
  }
335
316
  return;
336
317
  }
337
- if (ge(T(window.UserLeap)) || Ae || Ge(), e)
338
- return b && b.classList.add("sprig-feedback-loading-container-previews"), await X(e), void Y();
339
- const v = await (async (U) => {
340
- const S = await C(A("1", [q], "startFeedbackStudy"), { body: JSON.stringify({ surveyUuid: U }), method: "POST" });
341
- return S.ok ? S.json : null;
318
+ if (ge(P(window.UserLeap)) || Ae || Je(), e) return h && h.classList.add("sprig-feedback-loading-container-previews"), await X(e), void Y();
319
+ const U = await (async (b) => {
320
+ const I = await O(A("1", [F], "startFeedbackStudy"), { body: JSON.stringify({ surveyUuid: b }), method: "POST" });
321
+ return I.ok ? I.json : null;
342
322
  })(p);
343
- if (v)
344
- w.once(u.SurveyAppeared, Y), X({ ...v, studyType: "feedbackButton" }, n);
345
- else if (b) {
346
- const U = Ft();
347
- b.appendChild(U), Y(), b.style.height = "300px", b.style.width = "360px";
323
+ if (U) y.once(w.SurveyAppeared, Y), X({ ...U, studyType: "feedbackButton" }, n);
324
+ else if (h) {
325
+ const b = Ht();
326
+ h.appendChild(b), Y(), h.style.height = "300px", h.style.width = "360px";
348
327
  }
349
- }), c == null || c.appendChild(P), w.emit(u.FeedbackButtonLoaded, { name: u.FeedbackButtonLoaded, "survey.id": d });
350
- const { useMobileStyling: I, _config: { border: _ } } = window.UserLeap;
351
- if ($e || I)
352
- de(0);
328
+ }), c == null || c.appendChild(C), y.emit(w.FeedbackButtonLoaded, { name: w.FeedbackButtonLoaded, "survey.id": d });
329
+ const { useMobileStyling: E, _config: { border: _ } } = window.UserLeap;
330
+ if (Ke || E) de(0);
353
331
  else {
354
- const f = document.createElement("div");
355
- f.id = "sprig-feedback-loading-container", f.className = `sprig-feedback-loading-container sprig-feedback-loading-container-${g}`, f.style.setProperty("--feedback-border", _), b = f, Ie(), c == null || c.appendChild(f);
356
- const v = ct();
357
- de(-v);
332
+ const m = document.createElement("div");
333
+ m.id = "sprig-feedback-loading-container", m.className = `sprig-feedback-loading-container sprig-feedback-loading-container-${f}`, m.style.setProperty("--feedback-border", _), h = m, Ie(), c == null || c.appendChild(m);
334
+ const U = ut();
335
+ de(-U);
358
336
  }
359
- window.UserLeap._config.isOnQuestionsTab && e && !ae() && b && (Ge(), Ie(), b && b.classList.add("sprig-feedback-loading-container-previews"), X(e), Y());
360
- }, Ft = () => {
337
+ window.UserLeap._config.isOnQuestionsTab && e && !ae() && h && (Je(), Ie(), h && h.classList.add("sprig-feedback-loading-container-previews"), X(e), Y());
338
+ }, Ht = () => {
361
339
  const t = document.createElement("div");
362
340
  t.id = "sprig-feedback-error-container", t.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
363
341
  <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
@@ -368,7 +346,7 @@ const qt = ["bottom-left", "bottom-right", "center-left", "center-right"], ae =
368
346
  return e.className = "sprig-feedback-error-text", e.innerText = "There was an error while loading the survey", t.appendChild(e), t;
369
347
  }, ke = new class {
370
348
  constructor() {
371
- $(this, "_ldData", {});
349
+ W(this, "_ldData", {});
372
350
  }
373
351
  getAllLaunchDarklyVariations() {
374
352
  return this._ldData;
@@ -386,11 +364,10 @@ const qt = ["bottom-left", "bottom-right", "center-left", "center-right"], ae =
386
364
  Object.freeze(ke);
387
365
  const oe = new class {
388
366
  constructor() {
389
- $(this, "_optimizelyData", {});
367
+ W(this, "_optimizelyData", {});
390
368
  }
391
369
  setOptimizelyExperiment(t, e = !0) {
392
- if (!t || typeof t != "object")
393
- return !1;
370
+ if (!t || typeof t != "object") return !1;
394
371
  const { experiments: n } = t;
395
372
  try {
396
373
  return e && Object.keys(this._optimizelyData).map((s) => {
@@ -433,18 +410,16 @@ const oe = new class {
433
410
  }
434
411
  }();
435
412
  Object.freeze(oe);
436
- class zt {
413
+ class Vt {
437
414
  constructor(e, n) {
438
- $(this, "paused");
439
- $(this, "queue");
440
- $(this, "ul");
415
+ W(this, "paused");
416
+ W(this, "queue");
417
+ W(this, "ul");
441
418
  this.ul = e, this.paused = !1, this.queue = [], this.flush(n);
442
419
  }
443
420
  flush(e) {
444
421
  const n = e.length;
445
- if (n)
446
- for (let s = 0; s < n; s++)
447
- this.push(e[s]);
422
+ if (n) for (let s = 0; s < n; s++) this.push(e[s]);
448
423
  }
449
424
  isPaused() {
450
425
  return this.paused;
@@ -458,10 +433,8 @@ class zt {
458
433
  this.empty(), this.flush(e);
459
434
  }
460
435
  push(e) {
461
- if (this.paused)
462
- this.queue.push(e);
463
- else if (e instanceof Function)
464
- e();
436
+ if (this.paused) this.queue.push(e);
437
+ else if (e instanceof Function) e();
465
438
  else {
466
439
  const n = Array.prototype.slice.call(e, 1), s = e[0], r = this.ul[s];
467
440
  r instanceof Function ? r.apply(this.ul, n) : s && console.warn("[Sprig] (ERR-100) No valid UserLeap action called", s);
@@ -484,14 +457,13 @@ class zt {
484
457
  this.queue.length = 0;
485
458
  }
486
459
  }
487
- let ut, wt;
460
+ let gt, yt;
488
461
  const Ee = (t) => {
489
462
  let e = 0, n = t.firstElementChild;
490
- for (; n; )
491
- e += Ee(n), n.shadowRoot && (e += Ee(n.shadowRoot)), n = n.nextElementSibling, e++;
463
+ for (; n; ) e += Ee(n), n.shadowRoot && (e += Ee(n.shadowRoot)), n = n.nextElementSibling, e++;
492
464
  return e;
493
- }, Ke = () => {
494
- ut.report(Ee(document.body)), wt.report(document.documentElement.innerHTML.length);
465
+ }, Qe = () => {
466
+ gt.report(Ee(document.body)), yt.report(document.documentElement.innerHTML.length);
495
467
  }, _e = (t, e) => {
496
468
  const n = performance.now();
497
469
  document.hidden ? setTimeout(() => _e(t, e), t) : setTimeout(() => {
@@ -499,116 +471,108 @@ const Ee = (t) => {
499
471
  e.report(s / 1e3), setTimeout(() => _e(t, e), t);
500
472
  }, 0);
501
473
  };
502
- let le, ce, pe, ue, Je, W = {};
474
+ let le, ce, pe, ue, Ye, N = {};
503
475
  const ne = (t, e = 1) => {
504
476
  const { name: n } = t;
505
- W[n] = (W[n] || 0) + e;
506
- }, gt = (t) => {
477
+ N[n] = (N[n] || 0) + e;
478
+ }, mt = (t) => {
507
479
  let e = 1;
508
480
  return t.childNodes.forEach((n) => {
509
- e += gt(n);
481
+ e += mt(n);
510
482
  }), e;
511
- }, Qe = (t) => {
483
+ }, Xe = (t) => {
512
484
  let e = 0;
513
485
  return t.forEach((n) => {
514
- e += gt(n);
486
+ e += mt(n);
515
487
  }), e;
516
- }, Ht = (t) => {
488
+ }, Wt = (t) => {
517
489
  switch (t.type) {
518
490
  case "childList":
519
- return ne(le, Qe(t.addedNodes)), void ne(ce, Qe(t.removedNodes));
491
+ return ne(le, Xe(t.addedNodes)), void ne(ce, Xe(t.removedNodes));
520
492
  case "attributes":
521
493
  return void ne(pe);
522
494
  case "characterData":
523
495
  return void ne(ue);
524
496
  }
525
- }, Vt = (t) => t.forEach(Ht), Wt = () => {
526
- le.report(W[le.name] || 0), ce.report(W[ce.name] || 0), pe.report(W[pe.name] || 0), ue.report(W[ue.name] || 0), W = {};
527
- }, Bt = (t = 1e3) => {
528
- le = B("sdk_mutations_nodes_added"), ce = B("sdk_mutations_nodes_removed"), pe = B("sdk_mutations_attributes_changed"), ue = B("sdk_mutations_character_data"), Je = new MutationObserver(Vt), Je.observe(document, { attributes: !0, attributeOldValue: !0, characterData: !0, characterDataOldValue: !0, childList: !0, subtree: !0 }), setInterval(Wt, t);
529
- }, Nt = ({ isWeb: t, reportingIntervalSeconds: e, thresholds: n, postMetrics: s }) => {
530
- kt(n, (r, i) => {
497
+ }, Bt = (t) => t.forEach(Wt), Nt = () => {
498
+ le.report(N[le.name] || 0), ce.report(N[ce.name] || 0), pe.report(N[pe.name] || 0), ue.report(N[ue.name] || 0), N = {};
499
+ }, $t = (t = 1e3) => {
500
+ le = $("sdk_mutations_nodes_added"), ce = $("sdk_mutations_nodes_removed"), pe = $("sdk_mutations_attributes_changed"), ue = $("sdk_mutations_character_data"), Ye = new MutationObserver(Bt), Ye.observe(document, { attributes: !0, attributeOldValue: !0, characterData: !0, characterDataOldValue: !0, childList: !0, subtree: !0 }), setInterval(Nt, t);
501
+ }, Gt = ({ isWeb: t, reportingIntervalSeconds: e, thresholds: n, postMetrics: s }) => {
502
+ _t(n, (r, i) => {
531
503
  var o, a;
532
- if ((o = k.replay) != null && o.isReplayRecording()) {
504
+ if ((o = S.replay) != null && o.isReplayRecording()) {
533
505
  const l = `Value: ${r} on ${i.metric} violated threshold of ${i.type} ${i.value}`;
534
- (a = k.replay) == null || a.disableRecording("Threshold violated", new Error(l), { reportError: !1 }), window.UserLeap.reportError("Sdk Performance Metric threshold violated", new Error("Sdk Performance Metric threshold violated"), { metricName: i.metric, type: i.type, value: i.value }, { metricName: i.metric }), _t();
506
+ (a = S.replay) == null || a.disableRecording("Threshold violated", new Error(l), { reportError: !1 }), window.UserLeap.reportError("Sdk Performance Metric threshold violated", new Error("Sdk Performance Metric threshold violated"), { metricName: i.metric, type: i.type, value: i.value }, { metricName: i.metric }), Rt();
535
507
  }
536
- }), Et({ reportingIntervalSeconds: e, postMetrics: s }), t && (((r = 1e3) => {
537
- const i = B("sdk_event_queue_latency_seconds");
508
+ }), xt({ reportingIntervalSeconds: e, postMetrics: s }), t && (((r = 1e3) => {
509
+ const i = $("sdk_event_queue_latency_seconds");
538
510
  _e(r, i);
539
511
  })(), ((r = 1e4) => {
540
- ut = B("sdk_dom_nodes_count"), wt = B("sdk_page_html_characters"), Ke(), setInterval(Ke, r);
541
- })(), Bt());
542
- }, $t = "test", Gt = ["popState", "pushState", "replaceState"];
543
- let ee;
544
- const we = {}, Q = "!email", yt = "pageUrl";
512
+ gt = $("sdk_dom_nodes_count"), yt = $("sdk_page_html_characters"), Qe(), setInterval(Qe, r);
513
+ })(), $t());
514
+ }, Kt = "test", Jt = ["popState", "pushState", "replaceState"];
515
+ let Oe, ee;
516
+ const we = {}, Q = "!email", ft = "pageUrl";
545
517
  let Le = window.location.href;
546
518
  function te(t) {
547
519
  var a, l;
548
520
  const { pageUrlEvents: e, interactiveEvents: n, dismissOnPageChange: s, platform: r } = window.UserLeap._config;
549
- if (r && r !== "web")
550
- return;
551
- Le !== window.location.href && M.navigation("LocationChange", { from: Le, to: window.location.href }), Le = window.location.href;
552
- const i = vt().trackStartUrl, o = i ? String(i) : null;
553
- e && bt(window.location.href), n && (ft(), Kt()), at() && (() => {
554
- if (ae())
555
- return;
556
- const p = G();
557
- p && (It(Z) || (p.remove(), Z = null, b = null));
558
- })(), xt.getItem("sprig.isCapturingHeatmap") && ((l = (a = k.replay) == null ? void 0 : a.checkPendingHeatmapsUrl()) == null || l.then((p) => {
521
+ if (r && r !== "web") return;
522
+ Le !== window.location.href && q.navigation("LocationChange", { from: Le, to: window.location.href }), Le = window.location.href;
523
+ const i = bt().trackStartUrl, o = i ? String(i) : null;
524
+ e && Ut(window.location.href), n && (ht(), Qt()), lt() && (() => {
525
+ if (ae()) return;
526
+ const p = K();
527
+ p && (Et(Z) || (p.remove(), Z = null, h = null));
528
+ })(), At.getItem("sprig.isCapturingHeatmap") && ((l = (a = S.replay) == null ? void 0 : a.checkPendingHeatmapsUrl()) == null || l.then((p) => {
559
529
  var d;
560
- p && ((d = k.replay) == null || d.uploadReadyPendingCaptures(!0));
561
- })), !ae() && s && o && o !== window.location.href && t && Gt.includes(t.type) && window.UserLeap("dismissActiveSurvey", F.PageChange);
530
+ p && ((d = S.replay) == null || d.uploadReadyPendingCaptures(!0));
531
+ })), !ae() && s && o && o !== window.location.href && t && Jt.includes(t.type) && window.UserLeap("dismissActiveSurvey", M.PageChange);
562
532
  }
563
- const mt = { capture: !0 }, Kt = () => {
564
- const t = window.UserLeap._config.interactiveEvents.filter((n) => tt(n, window.location.href)).map((n) => {
533
+ const vt = { capture: !0 }, Qt = () => {
534
+ const t = window.UserLeap._config.interactiveEvents.filter((n) => it(n, window.location.href)).map((n) => {
565
535
  const { name: s, properties: r } = n, { selector: i, innerText: o } = r;
566
536
  return i ? (a) => {
567
- if (Be(a.target))
568
- try {
569
- a.target.closest(i) && window.UserLeap("track", s);
570
- } catch {
571
- }
537
+ if ($e(a.target)) try {
538
+ a.target.closest(i) && window.UserLeap("track", s);
539
+ } catch {
540
+ }
572
541
  return !1;
573
- } : (a) => (Be(a.target) && a.target.innerText === o && window.UserLeap("track", s), !1);
542
+ } : (a) => ($e(a.target) && a.target.innerText === o && window.UserLeap("track", s), !1);
574
543
  }), e = (n) => t.forEach((s) => s(n));
575
- window.UserLeap._config.interactiveEventsHandler = e, window.addEventListener("click", e, mt);
576
- }, ft = () => {
577
- window.UserLeap._config.interactiveEventsHandler && window.removeEventListener("click", window.UserLeap._config.interactiveEventsHandler, mt), delete window.UserLeap._config.interactiveEventsHandler;
544
+ window.UserLeap._config.interactiveEventsHandler = e, window.addEventListener("click", e, vt);
545
+ }, ht = () => {
546
+ window.UserLeap._config.interactiveEventsHandler && window.removeEventListener("click", window.UserLeap._config.interactiveEventsHandler, vt), delete window.UserLeap._config.interactiveEventsHandler;
578
547
  };
579
- function vt() {
548
+ function bt() {
580
549
  const t = R.getItemObject("userleap.ids");
581
550
  return t && t[window.UserLeap.envId] || {};
582
551
  }
583
- function ht() {
584
- if (window.previewMode)
585
- return;
552
+ function Lt() {
553
+ if (window.previewMode) return;
586
554
  const t = R.getItemObject("sprig.anon.env.vid.map") || {}, e = t[window.UserLeap.envId];
587
- window.UserLeap.visitorId = e || Ze(), M.info("NewVid", { vid: window.UserLeap.visitorId }), x("vid", window.UserLeap.visitorId), e || (t[window.UserLeap.envId] = window.UserLeap.visitorId, R.setItemObject("sprig.anon.env.vid.map", t)), w.emit(u.VisitorIDUpdated, { visitorId: window.UserLeap.visitorId });
555
+ window.UserLeap.visitorId = e || tt(), q.info("NewVid", { vid: window.UserLeap.visitorId }), x("vid", window.UserLeap.visitorId), e || (t[window.UserLeap.envId] = window.UserLeap.visitorId, R.setItemObject("sprig.anon.env.vid.map", t)), y.emit(w.VisitorIDUpdated, { visitorId: window.UserLeap.visitorId });
588
556
  }
589
- function bt(t, e, n, s) {
557
+ function Ut(t, e, n, s) {
590
558
  var r, i;
591
559
  try {
592
- if (t.endsWith("mock_snippet.html"))
593
- return;
594
- M.info("PageView", { url: t });
560
+ if (t.endsWith("mock_snippet.html")) return;
561
+ q.info("PageView", { url: t });
595
562
  const o = (r = document == null ? void 0 : document.querySelector('meta[name="description"]')) == null ? void 0 : r.getAttribute("content");
596
- (i = k.replay) == null || i.RecordPageView({ ...o && { description: o }, url: t, referrer: document.referrer, pageTitle: document.title });
563
+ (i = S.replay) == null || i.RecordPageView({ ...o && { description: o }, url: t, referrer: document.referrer, pageTitle: document.title });
597
564
  const a = window.UserLeap._config.pageUrlEvents;
598
565
  let l = !1;
599
- if (a && a.length)
600
- for (let d = 0; d < a.length && (l = tt(a[d], t), !l); d++)
601
- ;
602
- if (!l)
603
- return;
566
+ if (a && a.length) for (let d = 0; d < a.length && (l = it(a[d], t), !l); d++) ;
567
+ if (!l) return;
604
568
  window.UserLeap.debugMode && console.info("[DEBUG] Sprig trackPageView", t);
605
569
  const p = { url: t };
606
- s && (p.trackPageView = !0), window.UserLeap._queue.push(["track", yt, e, p, n]);
570
+ s && (p.trackPageView = !0), window.UserLeap._queue.push(["track", ft, e, p, n]);
607
571
  } catch (o) {
608
572
  o instanceof Error && (o.stack = t, window.UserLeap.reportError("trackPageView", o)), console.warn("[Sprig] (ERR-428) Failed to track page view", o);
609
573
  }
610
574
  }
611
- function Jt() {
575
+ function Yt() {
612
576
  const t = "Backbone" in window && window.Backbone && window.Backbone.history ? window.Backbone.history : window.history;
613
577
  "pushState" in t && (t.pushState = /* @__PURE__ */ ((e) => function(...n) {
614
578
  const s = e.apply(this, n), r = new Event("pushState");
@@ -620,25 +584,22 @@ function Jt() {
620
584
  }
621
585
  async function Ue(t, e) {
622
586
  const n = Re();
623
- t && !e && (window.UserLeap._config.mode = $t);
624
- const s = ge(T(window.UserLeap)), r = await C(function(i) {
587
+ t && !e && (window.UserLeap._config.mode = Kt);
588
+ const s = ge(P(window.UserLeap)), r = await O(function(i) {
625
589
  const o = new URL(A("1", [z], "questions"));
626
590
  return Object.entries(i || {}).forEach(([a, l]) => {
627
591
  l && o.searchParams.append(a, String(l));
628
592
  }), o.toString();
629
593
  }({ desktopDisplay: window.UserLeap._config.desktopDisplay, isMobile: s, previewLanguage: window.UserLeap._config.previewLanguage, surveyid: t == null ? void 0 : t.surveyId, surveytemplateid: t == null ? void 0 : t.surveyTemplateId, vid: n }), { shouldDropOnRateLimit: !0 });
630
- if (!r.ok)
631
- return r.reportError && r.error && (console.warn("[Sprig] (ERR-414) Failed to request questions from the server", r.error), window.UserLeap.reportError("getQuestions", r.error)), { success: !1, surveyState: "no survey" };
632
- if (r.json.delay && await rt(r.json.delay), !r.json.isFeedback)
633
- return X(r.json, ee);
594
+ if (!r.ok) return r.reportError && r.error && (console.warn("[Sprig] (ERR-414) Failed to request questions from the server", r.error), window.UserLeap.reportError("getQuestions", r.error)), { success: !1, surveyState: "no survey" };
595
+ if (r.json.delay && await nt(r.json.delay), !r.json.isFeedback) return X(r.json, ee, Oe);
634
596
  {
635
597
  const { feedbackLabel: i, productConfig: o, surveyUuid: a, feedbackCustomStyles: l } = r.json, { buttonTheme: p, placement: d, desktopDisplay: c } = o;
636
- pt({ customStyles: l, buttonTheme: p, desktopDisplay: c, eventId: 0, feedbackLabel: i, placement: d, surveyUuid: a, surveyId: t == null ? void 0 : t.surveyId }, r.json);
598
+ wt({ customStyles: l, buttonTheme: p, desktopDisplay: c, eventId: 0, feedbackLabel: i, placement: d, surveyUuid: a, surveyId: t == null ? void 0 : t.surveyId }, r.json);
637
599
  }
638
600
  }
639
- function Qt(t) {
640
- if (!t)
641
- return;
601
+ function Xt(t) {
602
+ if (!t) return;
642
603
  window.UserLeap._config = t, t.mute && window.UserLeap._queue.pause();
643
604
  const { interactiveEvents: e, pageUrlEvents: n, dismissOnPageChange: s } = t;
644
605
  e && function(r) {
@@ -649,56 +610,53 @@ function Qt(t) {
649
610
  const a = r[i];
650
611
  r[i] = r[o], r[o] = a;
651
612
  }
652
- }(e), (e || n || s) && (Jt(), te());
613
+ }(e), (e || n || s) && (Yt(), te());
653
614
  }
654
- const Yt = function(t) {
655
- if (!window.UserLeap)
656
- return;
615
+ const Zt = function(t) {
616
+ if (!window.UserLeap) return;
657
617
  const e = async (r = {}) => {
658
- var f, v, U, S, O;
618
+ var m, U, b, I, T;
659
619
  const { userId: i, anonymousId: o, metadata: a = {}, properties: l, showSurveyCallback: p } = r;
660
620
  let { eventName: d } = r;
661
- if (window.UserLeap.debugMode && d !== yt && console.info("[DEBUG] Sprig track", r), t.mode === "test")
662
- return;
621
+ if (window.UserLeap.debugMode && d !== ft && console.info("[DEBUG] Sprig track", r), t.mode === "test") return;
663
622
  const c = R.getItem("sprig.previewKey") ?? void 0;
664
623
  if (t.requireUserIdForTracking && !window.UserLeap.userId && !i) {
665
- const h = "[Sprig] - Skipping tracking without userId";
666
- return console.warn(h), { success: !1, message: h, surveyState: "no survey" };
624
+ const v = "[Sprig] - Skipping tracking without userId";
625
+ return console.warn(v), { success: !1, message: v, surveyState: "no survey" };
667
626
  }
668
627
  if (!d || d.trim().length === 0) {
669
628
  d = d ? String(d) : "";
670
- const h = "[Sprig] - Invalid event name " + d;
671
- return console.warn(h), { success: !1, message: h, surveyState: "no survey" };
629
+ const v = "[Sprig] - Invalid event name " + d;
630
+ return console.warn(v), { success: !1, message: v, surveyState: "no survey" };
672
631
  }
673
- const y = ee ?? window.location.href;
674
- a.url || (a.url = y), x("trackStartUrl", y), (v = (f = window.UserLeap) == null ? void 0 : f._config) != null && v.optimizelyEnabled && (ie(T(window.UserLeap)) || oe.getAndSetWebOptimizelyExperiments(), a.optimizelyExperiments = Object.assign({}, oe.getAllOptimizelyExperiments())), (S = (U = window.UserLeap) == null ? void 0 : U._config) != null && S.launchDarklyEnabled && (a.launchDarklyFlags = ke.getAllLaunchDarklyVariations()), i && (window.UserLeap.userId = i), o && (window.UserLeap.partnerAnonymousId = o), l && (a.eventProperties = l), (O = k.replay) == null || O.RecordEvent({ name: d, url: a.url }), M.info("TrackEvent", { eventName: d });
675
- const g = window.UserLeap.delayingSurvey || dt() ? await C(A("1", [q], "events/batch"), { body: JSON.stringify({ events: [{ event: d, metadata: a }], previewKey: c }), method: "POST", shouldDropOnRateLimit: !0 }) : await C(A("1", [q], "events"), { body: JSON.stringify({ event: d, metadata: a, previewKey: c }), method: "POST", shouldDropOnRateLimit: !0 });
676
- if (!g.ok) {
677
- const h = "[Sprig] (ERR-421) Failed to track event";
678
- return g.reportError && (console.warn(h, g.error), g.error && window.UserLeap.reportError("track", g.error)), { success: !1, message: h, error: g.error, surveyState: "no survey" };
632
+ const g = ee ?? window.location.href;
633
+ a.url || (a.url = g), x("trackStartUrl", g), (U = (m = window.UserLeap) == null ? void 0 : m._config) != null && U.optimizelyEnabled && (ie(P(window.UserLeap)) || oe.getAndSetWebOptimizelyExperiments(), a.optimizelyExperiments = Object.assign({}, oe.getAllOptimizelyExperiments())), (I = (b = window.UserLeap) == null ? void 0 : b._config) != null && I.launchDarklyEnabled && (a.launchDarklyFlags = ke.getAllLaunchDarklyVariations()), i && (window.UserLeap.userId = i), o && (window.UserLeap.partnerAnonymousId = o), l && (a.eventProperties = l), (T = S.replay) == null || T.RecordEvent({ name: d, url: a.url }), q.info("TrackEvent", { eventName: d });
634
+ const f = window.UserLeap.delayingSurvey || ct() ? await O(A("1", [F], "events/batch"), { body: JSON.stringify({ events: [{ event: d, metadata: a }], previewKey: c }), method: "POST", shouldDropOnRateLimit: !0 }) : await O(A("1", [F], "events"), { body: JSON.stringify({ event: d, metadata: a, previewKey: c }), method: "POST", shouldDropOnRateLimit: !0 });
635
+ if (!f.ok) {
636
+ const v = "[Sprig] (ERR-421) Failed to track event";
637
+ return f.reportError && (console.warn(v, f.error), f.error && window.UserLeap.reportError("track", f.error)), { success: !1, message: v, error: f.error, surveyState: "no survey" };
679
638
  }
680
639
  i && x("uid", i), o && x("aid", o);
681
- const m = g.json;
682
- m.invalidPreviewKey && R.removeItem("sprig.previewKey");
683
- const I = a.trackPageView ? a.url : void 0;
684
- return m != null && m.feedbackButton && pt(m.feedbackButton, void 0, I), await async function(h, E) {
685
- var H, K;
686
- let D = !0;
687
- return !(E && ((H = h == null ? void 0 : h.json) != null && H.surveyId) && (window.UserLeap.delayingSurvey = !0, D = await E(h.json.surveyId), window.UserLeap.delayingSurvey = !1, !D)) && ((K = h == null ? void 0 : h.json) != null && K.delay && !window.UserLeap.isMobileSDK && (window.UserLeap.delayingSurvey = !0, await rt(h.json.delay), window.UserLeap.delayingSurvey = !1), D);
688
- }(g, p) ? function(h) {
689
- if (!window.UserLeap._config.dismissOnPageChange)
690
- return !0;
691
- const E = new URL(h), D = new URL(ee ?? window.location.href);
692
- return E.hostname === D.hostname && E.pathname === D.pathname;
693
- }(y) ? X(m, I) : { success: !1, message: "Study should not be displayed after page navigation", surveyState: "no survey" } : { success: !1, message: "[Sprig] Callback returned false, aborting rendering of survey", surveyState: "no survey" };
640
+ const u = f.json;
641
+ u.invalidPreviewKey && R.removeItem("sprig.previewKey");
642
+ const E = a.trackPageView ? a.url : void 0;
643
+ return u != null && u.feedbackButton && wt(u.feedbackButton, void 0, E), await async function(v, D) {
644
+ var H, V;
645
+ let k = !0;
646
+ return !(D && ((H = v == null ? void 0 : v.json) != null && H.surveyId) && (window.UserLeap.delayingSurvey = !0, k = await D(v.json.surveyId), window.UserLeap.delayingSurvey = !1, !k)) && ((V = v == null ? void 0 : v.json) != null && V.delay && !window.UserLeap.isMobileSDK && (window.UserLeap.delayingSurvey = !0, await nt(v.json.delay), window.UserLeap.delayingSurvey = !1), k);
647
+ }(f, p) ? function(v) {
648
+ if (!window.UserLeap._config.dismissOnPageChange) return !0;
649
+ const D = new URL(v), k = new URL(ee ?? window.location.href);
650
+ return D.hostname === k.hostname && D.pathname === k.pathname;
651
+ }(g) ? X(u, E, Oe) : { success: !1, message: "Study should not be displayed after page navigation", surveyState: "no survey" } : { success: !1, message: "[Sprig] Callback returned false, aborting rendering of survey", surveyState: "no survey" };
694
652
  }, n = (r, i) => {
695
653
  var a;
696
654
  const o = (a = r == null ? void 0 : r.querySelector(`[id="${De}"]`)) == null ? void 0 : a.contentDocument;
697
655
  o && se({ document: o, elementId: "ul-custom-style", styleString: i });
698
- }, s = { displaySurvey: async (r) => (console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."), window.UserLeap("dismissActiveSurvey", F.Override), Ue({ surveyId: r }, !0)), _previewSurvey(r) {
699
- window.UserLeap("dismissActiveSurvey", F.Override), Ue({ surveyTemplateId: r }, !1);
656
+ }, s = { displaySurvey: async (r) => (console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."), window.UserLeap("dismissActiveSurvey", M.Override), Ue({ surveyId: r }, !0)), _previewSurvey(r) {
657
+ window.UserLeap("dismissActiveSurvey", M.Override), Ue({ surveyTemplateId: r }, !1);
700
658
  }, _reviewSurvey(r) {
701
- window.UserLeap("dismissActiveSurvey", F.Override), Ue({ surveyId: r }, !1);
659
+ window.UserLeap("dismissActiveSurvey", M.Override), Ue({ surveyId: r }, !1);
702
660
  }, previewSurvey(r) {
703
661
  s._previewSurvey(r);
704
662
  }, reviewSurvey(r) {
@@ -709,8 +667,8 @@ const Yt = function(t) {
709
667
  window.UserLeap._queue.unpause();
710
668
  }, setVisitorToken() {
711
669
  console.warn("[Sprig] setVisitorToken is deprecated.");
712
- }, dismissActiveSurvey(r = F.API) {
713
- window.UserLeap.container && (w.emit(u.SurveyCloseRequested, { name: u.SurveyCloseRequested, initiator: r, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) }), w.emit(u.SurveyWillClose, { name: u.SurveyWillClose, initiator: r, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) }));
670
+ }, dismissActiveSurvey(r = M.API) {
671
+ window.UserLeap.container && (r === M.Closed && window.Sprig.trackHistory && window.Sprig.trackHistory({ event: "closed" }), y.emit(w.SurveyCloseRequested, { name: w.SurveyCloseRequested, initiator: r, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) }), y.emit(w.SurveyWillClose, { name: w.SurveyWillClose, initiator: r, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) }));
714
672
  }, async setAttribute(r, i) {
715
673
  if (!r || !i && i !== 0 && i !== !1) {
716
674
  const o = "[Sprig] - Disregarding empty attribute / value provided";
@@ -724,8 +682,7 @@ const Yt = function(t) {
724
682
  }
725
683
  return this.identifyAndSetAttributes({ attributes: r });
726
684
  }, async identifyAndSetAttributes(r) {
727
- if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig identifyAndSetAttributes", r), t.mode === "test")
728
- return;
685
+ if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig identifyAndSetAttributes", r), t.mode === "test") return;
729
686
  if (r === null || typeof r != "object" || !(r.userId || r.anonymousId || r.attributes)) {
730
687
  const d = "[Sprig] - Disregarding empty payload provided";
731
688
  return console.warn(d), { success: !1, message: d };
@@ -738,17 +695,14 @@ const Yt = function(t) {
738
695
  if (a) {
739
696
  a.email && !a[Q] && (a[Q] = a.email, delete a.email);
740
697
  const d = Object.keys(a);
741
- for (const c of d)
742
- a[c] === we[c] && delete a[c];
698
+ for (const c of d) a[c] === we[c] && delete a[c];
743
699
  }
744
- if (!(a && Object.keys(a).length !== 0 || i && window.UserLeap.userId !== i || o && window.UserLeap.partnerAnonymousId !== o))
745
- return { success: !0 };
700
+ if (!(a && Object.keys(a).length !== 0 || i && window.UserLeap.userId !== i || o && window.UserLeap.partnerAnonymousId !== o)) return { success: !0 };
746
701
  const l = {};
747
702
  let p;
748
- return i && (l.userId = window.UserLeap.userId = i), o && (l.partnerAnonymousId = window.UserLeap.partnerAnonymousId = o), a && Object.keys(a).length > 0 ? (p = await C(A("1", [z, q], "attributes"), { body: JSON.stringify(a), method: "PUT" }), p.ok ? Object.assign(we, a) : p.reportError && (console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed", p.error), p.error && window.UserLeap.reportError("identifyAndSetAttributes", p.error))) : p = await C(A("1", [z, q]), { body: JSON.stringify(l), method: "PUT" }), a && a[Q] && (window.UserLeap.email = a[Q]), p.ok && (i && x("uid", i), o && x("aid", o)), { success: !!p.ok };
703
+ return i && (l.userId = window.UserLeap.userId = i), o && (l.partnerAnonymousId = window.UserLeap.partnerAnonymousId = o), a && Object.keys(a).length > 0 ? (p = await O(A("1", [z, F], "attributes"), { body: JSON.stringify(a), method: "PUT" }), p.ok ? Object.assign(we, a) : p.reportError && (console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed", p.error), p.error && window.UserLeap.reportError("identifyAndSetAttributes", p.error))) : p = await O(A("1", [z, F]), { body: JSON.stringify(l), method: "PUT" }), a && a[Q] && (window.UserLeap.email = a[Q]), p.ok && (i && x("uid", i), o && x("aid", o)), { success: !!p.ok };
749
704
  }, async removeAttributes(r) {
750
- if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig removeAttributes", r), t.mode === "test")
751
- return;
705
+ if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig removeAttributes", r), t.mode === "test") return;
752
706
  if (r == null || r.length === 0) {
753
707
  const o = "[Sprig] - Disregarding empty attributes provided";
754
708
  return console.warn(o), { success: !1, message: o };
@@ -757,18 +711,18 @@ const Yt = function(t) {
757
711
  const o = "[Sprig] - Skipping tracking without userId";
758
712
  return console.warn(o), { success: !1, message: o };
759
713
  }
760
- const i = await C(A("1", [z, q], "attributes"), { body: JSON.stringify({ delete: r }), method: "DELETE" });
714
+ const i = await O(A("1", [z, F], "attributes"), { body: JSON.stringify({ delete: r }), method: "DELETE" });
761
715
  return !i.ok && i.reportError && (console.warn("[Sprig] (ERR-433) Remove attributes failed", i.error), i.error && window.UserLeap.reportError("removeAttributes", i.error)), { success: !!i.ok };
762
716
  }, async addSurveyListener(r) {
763
- w.on(u.SurveyLifeCycle, r);
717
+ y.on(w.SurveyLifeCycle, r);
764
718
  }, async removeSurveyListener(r) {
765
- w.removeListener(u.SurveyLifeCycle, r);
719
+ y.removeListener(w.SurveyLifeCycle, r);
766
720
  }, async addListener(r, i) {
767
- w.on(r, i);
721
+ y.on(r, i);
768
722
  }, async removeListener(r, i) {
769
- w.removeListener(r, i);
723
+ y.removeListener(r, i);
770
724
  }, async removeAllListeners() {
771
- w.removeAllListeners();
725
+ y.removeAllListeners();
772
726
  }, setPreviewKey(r) {
773
727
  r && typeof r == "string" && R.isStorageAvailable && r && R.setItem("sprig.previewKey", r);
774
728
  }, async setUserId(r) {
@@ -777,11 +731,10 @@ const Yt = function(t) {
777
731
  const l = `[Sprig] - Invalid userId ${r}`;
778
732
  return console.warn(l), { success: !1, message: l };
779
733
  }
780
- if (t.mode === "test" || r === window.UserLeap.userId)
781
- return;
734
+ if (t.mode === "test" || r === window.UserLeap.userId) return;
782
735
  window.UserLeap.userId = r;
783
- const i = window.UserLeap.visitorId, o = await C(A("1", [z, q]), { body: JSON.stringify({ userId: r }), method: "PUT" });
784
- o.ok ? (i !== window.UserLeap.visitorId && ((a = k.replay) == null || a.clearUserReplayData()), x("uid", r)) : o.reportError && (console.warn("[Sprig] (ERR-420) Failed to set user id", o.error), o.error && window.UserLeap.reportError("setUserId", o.error));
736
+ const i = window.UserLeap.visitorId, o = await O(A("1", [z, F]), { body: JSON.stringify({ userId: r }), method: "PUT" });
737
+ o.ok ? (i !== window.UserLeap.visitorId && ((a = S.replay) == null || a.clearUserReplayData()), x("uid", r)) : o.reportError && (console.warn("[Sprig] (ERR-420) Failed to set user id", o.error), o.error && window.UserLeap.reportError("setUserId", o.error));
785
738
  }, async setPartnerAnonymousId(r) {
786
739
  if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig setPartnerAnonymousId", r), r == null) {
787
740
  const i = `[Sprig] - Invalid partnerAnonymousId ${r}`;
@@ -789,40 +742,36 @@ const Yt = function(t) {
789
742
  }
790
743
  return window.UserLeap.partnerAnonymousId = r, x("aid", r), { success: !0 };
791
744
  }, track: async (r, i, o = {}, a = void 0) => e({ eventName: r, properties: i, metadata: o, showSurveyCallback: a }), identifyAndTrack: async (r) => await e(r), trackPageView(r, i = void 0, o = void 0, a = !0) {
792
- ee = r, bt(r, i, o, a);
745
+ ee = r, Ut(r, i, o, a);
793
746
  }, applyFeedbackStyles({ button: r = "", view: i = "" }) {
794
747
  window.UserLeap.feedbackCustomStyles = i, document.getElementById("sprig-feedback-style") && se({ document, elementId: "ul-custom-style", styleString: r, nonce: window.UserLeap.styleNonce }), n(document.querySelector(".ul-container-feedback"), i);
795
748
  }, applyStyles(r) {
796
749
  window.UserLeap.customStyles = r, n(window.UserLeap.container, r);
797
750
  }, setWindowDimensions(r, i) {
798
- var y, g;
751
+ var g, f;
799
752
  const o = typeof r == "string" ? parseInt(r, 10) : r, a = typeof i == "string" ? parseInt(i, 10) : i;
800
753
  isNaN(o) || isNaN(a) || (window.UserLeap.windowDimensions = { width: o, height: a });
801
- const l = T(window.UserLeap), p = ge(l), d = l["userleap-platform"] === "web";
802
- if (!window.UserLeap.frameId)
803
- return;
754
+ const l = P(window.UserLeap), p = ge(l), d = l["userleap-platform"] === "web";
755
+ if (!window.UserLeap.frameId) return;
804
756
  const c = document.getElementById(window.UserLeap.frameId);
805
- c && (window.UserLeap.useMobileStyling && ((y = window.UserLeap.windowDimensions) != null && y.width && (c.style.width = `${window.UserLeap.windowDimensions.width}px`), (g = window.UserLeap.windowDimensions) != null && g.height && (c.style.maxHeight = window.UserLeap.windowDimensions.height - 20 + "px"), c.contentDocument && (c.style.height = String(Mt(c.contentDocument, d && !p, et(l))[0]) + "px")), w.emit(u.SurveyDimensions, { name: u.SurveyDimensions, contentFrameWidth: c.clientWidth, contentFrameHeight: c.clientHeight, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) }));
757
+ c && (window.UserLeap.useMobileStyling && ((g = window.UserLeap.windowDimensions) != null && g.width && (c.style.width = `${window.UserLeap.windowDimensions.width}px`), (f = window.UserLeap.windowDimensions) != null && f.height && (c.style.maxHeight = window.UserLeap.windowDimensions.height - 20 + "px"), c.contentDocument && (c.style.height = String(Ft(c.contentDocument, d && !p, rt(l))[0]) + "px")), y.emit(w.SurveyDimensions, { name: w.SurveyDimensions, contentFrameWidth: c.clientWidth, contentFrameHeight: c.clientHeight, "survey.id": parseInt(window.UserLeap.container.dataset.studyId) }));
806
758
  }, logoutUser() {
807
759
  var r;
808
- window.UserLeap.debugMode && console.info("[DEBUG] Sprig logout"), M.info("LogOut", { vid: window.UserLeap.visitorId, userId: window.UserLeap.userId }), window.UserLeap.visitorId = null, window.UserLeap.userId = null, window.UserLeap.partnerAnonymousId = null, window.UserLeap.token = null, window.UserLeap.email = null, R.removeItem("userleap.ids"), window.UserLeap._queue.isPaused() && window.UserLeap._queue.empty(), ht(), (r = k.replay) == null || r.clearUserReplayData(), window.UserLeap._queue.unpause();
760
+ window.UserLeap.debugMode && console.info("[DEBUG] Sprig logout"), q.info("LogOut", { vid: window.UserLeap.visitorId, userId: window.UserLeap.userId }), window.UserLeap.visitorId = null, window.UserLeap.userId = null, window.UserLeap.partnerAnonymousId = null, window.UserLeap.token = null, window.UserLeap.email = null, R.removeItem("userleap.ids"), window.UserLeap._queue.isPaused() && window.UserLeap._queue.empty(), Lt(), (r = S.replay) == null || r.clearUserReplayData(), window.UserLeap._queue.unpause();
809
761
  }, teardown() {
810
- ["hashchange", "popstate"].forEach((r) => window.removeEventListener(r, te, !0)), window.UserLeap._config.interactiveEvents && ft(), window.UserLeap("dismissActiveSurvey", F.API), delete window.UserLeap, delete window.Sprig, delete window._Sprig;
762
+ ["hashchange", "popstate"].forEach((r) => window.removeEventListener(r, te, !0)), window.UserLeap._config.interactiveEvents && ht(), window.UserLeap("dismissActiveSurvey", M.API), delete window.UserLeap, delete window.Sprig, delete window._Sprig;
811
763
  }, integrateOptimizely(r, i = !0) {
812
764
  var o, a;
813
- if ((a = (o = window.UserLeap) == null ? void 0 : o._config) != null && a.optimizelyEnabled)
814
- try {
815
- const l = typeof r == "string" ? JSON.parse(r) : r;
816
- oe.setOptimizelyExperiment(l, i);
817
- } catch (l) {
818
- console.warn("[Sprig] Error with integrating Optimizely data"), l instanceof Error && window.UserLeap.reportError("integrateOptimizely", l);
819
- }
820
- else
821
- console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");
765
+ if ((a = (o = window.UserLeap) == null ? void 0 : o._config) != null && a.optimizelyEnabled) try {
766
+ const l = typeof r == "string" ? JSON.parse(r) : r;
767
+ oe.setOptimizelyExperiment(l, i);
768
+ } catch (l) {
769
+ console.warn("[Sprig] Error with integrating Optimizely data"), l instanceof Error && window.UserLeap.reportError("integrateOptimizely", l);
770
+ }
771
+ else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");
822
772
  }, integrateOptimizelyClient(r) {
823
773
  var i, o;
824
- if (!((o = (i = window.UserLeap) == null ? void 0 : i._config) != null && o.optimizelyEnabled))
825
- return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");
774
+ if (!((o = (i = window.UserLeap) == null ? void 0 : i._config) != null && o.optimizelyEnabled)) return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");
826
775
  r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event", ({ experiment: a, variation: l }) => {
827
776
  const p = { experiments: [{ id: a.id, variation: l.key }] };
828
777
  window.UserLeap("integrateOptimizely", p, !1);
@@ -832,8 +781,7 @@ const Yt = function(t) {
832
781
  (o = (i = window.UserLeap) == null ? void 0 : i._config) != null && o.launchDarklyEnabled ? ke.setLDFlagsVariations(r) : console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");
833
782
  }, setVisitorAttribute: (r, i) => (console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"), s.setAttribute(r, i)), setEmail: async (r) => s.setAttribute(Q, r), setVisitorEmail: async (r) => (console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"), s.setEmail(r)), _generateVideoUploadUrl: async (r) => async function(i) {
834
783
  var a;
835
- if (!i)
836
- return;
784
+ if (!i) return;
837
785
  const o = `${window.UserLeap._API_URL}/2/environments/integrations/upload`;
838
786
  try {
839
787
  const l = await fetch(o, { method: "POST", cache: "no-cache", headers: { "Content-Type": "application/json" }, body: JSON.stringify(i) });
@@ -846,68 +794,59 @@ const Yt = function(t) {
846
794
  console.warn("[Sprig] Error with generating video upload url"), l instanceof Error && window.UserLeap.reportError("generateVideoUploadUrl", l);
847
795
  }
848
796
  }(r), _reportMetric(r, i) {
849
- Rt(r, i);
797
+ Dt(r, i);
850
798
  }, _completeSessionReplay: async ({ surveyId: r, responseGroupUuid: i, eventDigest: o }) => {
851
799
  var a;
852
- return k.replay ? (a = k.replay) == null ? void 0 : a._completeSessionReplay({ surveyId: r, responseGroupUuid: i, eventDigest: o, headers: T(window.UserLeap) }) : (window.UserLeap.reportError("_completeSessionReplay", new Error("Replay module not registered")), !1);
800
+ return S.replay ? (a = S.replay) == null ? void 0 : a._completeSessionReplay({ surveyId: r, responseGroupUuid: i, eventDigest: o, headers: P(window.UserLeap) }) : (window.UserLeap.reportError("_completeSessionReplay", new Error("Replay module not registered")), !1);
853
801
  } };
854
802
  Object.assign(window.UserLeap, s);
855
803
  };
856
- async function Xt(t, e, n = {}, s = {}) {
857
- const r = window.__cfg && window.__cfg.mode, i = Re(), o = window.UserLeap.envId, a = window.document.documentElement, l = { mode: r, screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: a.clientWidth, clientHeight: a.clientHeight, location: ee ?? window.location.href, language: window.navigator.language, ...n }, p = { action: t, breadcrumbs: M.breadcrumbs, err: { message: `${e == null ? void 0 : e.name} - ${e == null ? void 0 : e.message}`, stack: e == null ? void 0 : e.stack }, meta: l, vid: i, envId: o, ...s };
858
- (await C(A("1", null, "errors"), { method: "POST", headers: { "x-ul-error": window.btoa(`userleap-${Date.now()}-error`) }, body: JSON.stringify(p), shouldDropOnRateLimit: !0 })).ok || console.warn("[Sprig] (ERR-444) Failed to report error to API", e);
804
+ async function er(t, e, n = {}, s = {}) {
805
+ const r = window.__cfg && window.__cfg.mode, i = Re(), o = window.UserLeap.envId, a = window.document.documentElement, l = { mode: r, screenWidth: window.screen.width, screenHeight: window.screen.height, clientWidth: a.clientWidth, clientHeight: a.clientHeight, location: ee ?? window.location.href, language: window.navigator.language, ...n }, p = { action: t, breadcrumbs: q.breadcrumbs, err: { message: `${e == null ? void 0 : e.name} - ${e == null ? void 0 : e.message}`, stack: e == null ? void 0 : e.stack }, meta: l, vid: i, envId: o, ...s };
806
+ (await O(A("1", null, "errors"), { method: "POST", headers: { "x-ul-error": window.btoa(`userleap-${Date.now()}-error`) }, body: JSON.stringify(p), shouldDropOnRateLimit: !0 })).ok || console.warn("[Sprig] (ERR-444) Failed to report error to API", e);
859
807
  }
860
- function Zt(t = {}) {
808
+ function tr(t = {}) {
861
809
  var s;
862
810
  (s = window.SprigLoggerCallback) == null || s.call(window, "Initializing Sprig");
863
811
  const e = new URLSearchParams(window.location.search).get("sprigPreviewKey") ?? "";
864
812
  async function n() {
865
- var y, g, m, I, _;
866
- if (window.UserLeap.loaded)
867
- return;
868
- if ((y = window.SprigLoggerCallback) == null || y.call(window, "Loading Sprig"), window.UserLeap.reportError = Xt, window.UserLeap.loaded = !0, window.UserLeap._config = Object.assign({}, t, window.UserLeap.config), window.UserLeap.delayingSurvey = !1, window.UserLeap._config && typeof window.UserLeap._config == "object")
869
- for (const f in window.UserLeap._config)
870
- window.UserLeap[f] = window.UserLeap._config[f];
813
+ var g, f, u, E, _;
814
+ if (window.UserLeap.loaded) return;
815
+ if ((g = window.SprigLoggerCallback) == null || g.call(window, "Loading Sprig"), window.UserLeap.reportError = er, window.UserLeap.loaded = !0, window.UserLeap._config = Object.assign({}, t, window.UserLeap.config), window.UserLeap.delayingSurvey = !1, window.UserLeap._config && typeof window.UserLeap._config == "object") for (const m in window.UserLeap._config) window.UserLeap[m] = window.UserLeap._config[m];
871
816
  if (!window.UserLeap.envId) {
872
- if (!window.UserLeap.appId)
873
- throw new Error("Missing Environment id");
817
+ if (!window.UserLeap.appId) throw new Error("Missing Environment id");
874
818
  window.UserLeap.envId = window.UserLeap.appId;
875
819
  }
876
820
  window.UserLeap.debugMode && console.info("[DEBUG] Sprig debug mode enabled");
877
- const r = vt(), i = window.UserLeap.sampleRate;
821
+ const r = bt(), i = window.UserLeap.sampleRate;
878
822
  let o = r.sampled;
879
823
  if (i) {
880
- if (o === null && (o = Math.random() < i, x("sampled", o)), !o)
881
- return;
882
- } else
883
- o !== null && x("sampled", null);
824
+ if (o === null && (o = Math.random() < i, x("sampled", o)), !o) return;
825
+ } else o !== null && x("sampled", null);
884
826
  window.UserLeap._API_URL || (window.UserLeap._API_URL = "https://api.sprig.com");
885
827
  const a = [...window.UserLeap._queue];
886
- window.UserLeap._queue = new zt(window.UserLeap, []), window.UserLeap._queue.pause();
887
- for (let f = 0; f < a.length; f++)
888
- window.UserLeap._queue.push(a[f]);
828
+ window.UserLeap._queue = new Vt(window.UserLeap, []), window.UserLeap._queue.pause();
829
+ for (let m = 0; m < a.length; m++) window.UserLeap._queue.push(a[m]);
889
830
  const l = r.token;
890
- l ? (window.UserLeap.token = l, window.UserLeap.visitorId = r.vid ?? null, window.UserLeap.userId = r.uid ?? null, window.UserLeap.partnerAnonymousId = r.aid ?? null) : ht();
891
- const p = ie(T(window.UserLeap));
892
- (g = window.SprigLoggerCallback) == null || g.call(window, "Sprig fetching config");
893
- const d = await async function(f) {
894
- var O, h;
895
- const v = T(window.UserLeap);
896
- document.addEventListener("securitypolicyviolation", Fe);
897
- const U = await Xe(A("1", [z], "config"), { headers: v });
898
- if (document.removeEventListener("securitypolicyviolation", Fe), !U.ok)
899
- return (O = window.SprigLoggerCallback) == null || O.call(window, "Sprig config fetch failed"), U.reportError && (console.warn("[Sprig] (ERR-422) Failed to load configuration", U.error), U.error && window.UserLeap.reportError("applyRemoteConfig", U.error)), ze("Disabled: failed to fetch configuration"), f;
900
- const S = U.json;
901
- return S != null && S.disabled ? ((h = window.SprigLoggerCallback) == null || h.call(window, "Sprig config fetch disabled"), ze(`Disabled: ${S.disabled}`), { disabled: S.disabled }) : Object.assign({}, S, f);
831
+ l ? (window.UserLeap.token = l, window.UserLeap.visitorId = r.vid ?? null, window.UserLeap.userId = r.uid ?? null, window.UserLeap.partnerAnonymousId = r.aid ?? null) : Lt();
832
+ const p = ie(P(window.UserLeap));
833
+ (f = window.SprigLoggerCallback) == null || f.call(window, "Sprig fetching config");
834
+ const d = await async function(m) {
835
+ var T, v;
836
+ const U = P(window.UserLeap);
837
+ document.addEventListener("securitypolicyviolation", He);
838
+ const b = await et(A("1", [z], "config"), { headers: U });
839
+ if (document.removeEventListener("securitypolicyviolation", He), !b.ok) return (T = window.SprigLoggerCallback) == null || T.call(window, "Sprig config fetch failed"), b.reportError && (console.warn("[Sprig] (ERR-422) Failed to load configuration", b.error), b.error && window.UserLeap.reportError("applyRemoteConfig", b.error)), Ve("Disabled: failed to fetch configuration"), m;
840
+ const I = b.json;
841
+ return I != null && I.disabled ? ((v = window.SprigLoggerCallback) == null || v.call(window, "Sprig config fetch disabled"), Ve(`Disabled: ${I.disabled}`), { disabled: I.disabled }) : Object.assign({}, I, m);
902
842
  }(t);
903
- (m = window.SprigLoggerCallback) == null || m.call(window, "Sprig fetched config"), Nt({ isWeb: !p, reportingIntervalSeconds: d.metricsReportingEnabled || d.mobileMetricsReportingEnabled ? d.metricsReportingIntervalSeconds : 0, thresholds: d.metricThresholds, postMetrics: async (f) => {
904
- var v;
905
- await C(A("1", [z], "metrics"), { body: f, method: "POST", headers: { "x-ul-replay-enabled": `${!!((v = k.replay) != null && v.isReplayRecording())}` }, shouldDropOnRateLimit: !0 });
843
+ (u = window.SprigLoggerCallback) == null || u.call(window, "Sprig fetched config"), Gt({ isWeb: !p, reportingIntervalSeconds: d.metricsReportingEnabled || d.mobileMetricsReportingEnabled ? d.metricsReportingIntervalSeconds : 0, thresholds: d.metricThresholds, postMetrics: async (m) => {
844
+ var U;
845
+ await O(A("1", [z], "metrics"), { body: m, method: "POST", headers: { "x-ul-replay-enabled": `${!!((U = S.replay) != null && U.isReplayRecording())}` }, shouldDropOnRateLimit: !0 });
906
846
  } });
907
- const c = d.alwaysOnReplay ? { userAgent: window.navigator.userAgent, surveyId: d.alwaysOnReplay.surveyId, responseGroupUuid: d.alwaysOnReplay.responseGroupUuid, sdkVersion: "2.33.1", maxDurationSeconds: d.alwaysOnReplay.maxDurationSeconds } : void 0;
908
- await ((I = k.replay) == null ? void 0 : I.initializeReplay({ maxReplayDurationSeconds: d.maxReplayDurationSeconds, maxInflightRequests: window.UserLeap.maxInflightReplayRequests ?? 2, replaySettings: d.replaySettings, apiUrl: window.UserLeap._API_URL, alwaysOnConfig: c })), Yt(d), await Qt(d), window.UserLeap._queue.unpause(), (_ = window.SprigLoggerCallback) == null || _.call(window, "SdkReady"), w.emit(u.SDKReady, { mobileMetricsReportingEnabled: !!d.mobileMetricsReportingEnabled, metricsReportingInterval: d.metricsReportingIntervalSeconds || 0, metricsThresholds: d.metricThresholds || [], maxMobileReplayDurationSeconds: d.maxMobileReplayDurationSeconds, mobileReplaySettings: d.mobileReplaySettings }), w.emit(u.VisitorIDUpdated, { visitorId: window.UserLeap.visitorId }), w.on(u.VisitorIDUpdated, () => {
909
- for (const f in we)
910
- delete we[f];
847
+ const c = d.alwaysOnReplay ? { userAgent: window.navigator.userAgent, surveyId: d.alwaysOnReplay.surveyId, responseGroupUuid: d.alwaysOnReplay.responseGroupUuid, sdkVersion: "2.33.3", maxDurationSeconds: d.alwaysOnReplay.maxDurationSeconds } : void 0;
848
+ await ((E = S.replay) == null ? void 0 : E.initializeReplay({ maxReplayDurationSeconds: d.maxReplayDurationSeconds, maxInflightRequests: window.UserLeap.maxInflightReplayRequests ?? 2, replaySettings: d.replaySettings, apiUrl: window.UserLeap._API_URL, alwaysOnConfig: c })), Oe = d.replaySettings, Zt(d), await Xt(d), window.UserLeap._queue.unpause(), (_ = window.SprigLoggerCallback) == null || _.call(window, "SdkReady"), y.emit(w.SDKReady, { mobileMetricsReportingEnabled: !!d.mobileMetricsReportingEnabled, metricsReportingInterval: d.metricsReportingIntervalSeconds || 0, metricsThresholds: d.metricThresholds || [], maxMobileReplayDurationSeconds: d.maxMobileReplayDurationSeconds, mobileReplaySettings: d.mobileReplaySettings }), y.emit(w.VisitorIDUpdated, { visitorId: window.UserLeap.visitorId }), y.on(w.VisitorIDUpdated, () => {
849
+ for (const m in we) delete we[m];
911
850
  });
912
851
  }
913
852
  window.UserLeap.UPDATES = re, window.UserLeap("setPreviewKey", e), document.readyState === "complete" ? n() : window.attachEvent ? window.attachEvent("onload", n) : window.addEventListener("load", () => {
@@ -916,7 +855,7 @@ function Zt(t = {}) {
916
855
  }
917
856
  class xe {
918
857
  constructor() {
919
- this.UPDATES = re;
858
+ W(this, "UPDATES", re);
920
859
  }
921
860
  displaySurvey(e) {
922
861
  window.Sprig("displaySurvey", e);
@@ -982,31 +921,29 @@ class xe {
982
921
  window.Sprig("teardown");
983
922
  }
984
923
  }
985
- const Ye = { configure: (t) => {
986
- if (!t.envId && !t.environmentId)
987
- throw new Error("Initialization Error: Sprig configure requires an environmentId");
988
- if (t.envId || (t.envId = t.environmentId ?? ""), t.installationMethod = "web-npm", window.Sprig)
989
- return window.Sprig;
924
+ const Ze = { configure: (t) => {
925
+ if (!t.envId && !t.environmentId) throw new Error("Initialization Error: Sprig configure requires an environmentId");
926
+ if (t.envId || (t.envId = t.environmentId ?? ""), t.installationMethod = "web-npm", window.Sprig) return window.Sprig;
990
927
  window.Sprig = function() {
991
928
  window.Sprig._queue.push(arguments);
992
929
  }, Object.getOwnPropertyNames(xe.prototype).map((n) => {
993
930
  n !== "constructor" && (window.Sprig[n] = xe.prototype[n]);
994
931
  });
995
932
  const e = window.Sprig;
996
- return e.appId = t.envId, e._queue = [], window.UserLeap = e, Zt(t), window.Sprig;
997
- } }, dr = { sprig: Ye, SprigAPI: xe, configure: Ye.configure };
933
+ return e.appId = t.envId, e._queue = [], window.UserLeap = e, tr(t), window.Sprig;
934
+ } }, cr = { sprig: Ze, SprigAPI: xe, configure: Ze.configure };
998
935
  export {
999
- ir as A,
1000
- Dt as C,
1001
- rr as D,
1002
- sr as E,
936
+ or as A,
937
+ Ot as C,
938
+ nr as D,
939
+ dr as E,
1003
940
  xe as S,
1004
- Mt as a,
1005
- or as b,
1006
- dr as c,
1007
- nr as d,
941
+ Ft as a,
942
+ ar as b,
943
+ cr as c,
944
+ sr as d,
1008
945
  se as e,
1009
946
  j as i,
1010
- ar as r,
1011
- Ye as s
947
+ lr as r,
948
+ Ze as s
1012
949
  };