UNPKG

@sprig-technologies/sprig-browser

Version:

npm package for the sprig web sdk

773 lines 63.4 kB
var Pt = Object.defineProperty; var Mt = (r, e, i) => e in r ? Pt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[e] = i; var W = (r, e, i) => Mt(r, typeof e != "symbol" ? e + "" : e, i); import { l as z, g as C, s as pt, e as g, S as u, v as ut, m as S, b as M, h as gt, E as se, a as J, D as P, c as jt, r as G, i as qt, j as Ft, k as Ht, n as Qe, o as Ye, d as zt, p as ht, q as yt } from "./metricsReporter-CNrl9aag.js"; const yr = 360, br = "ul-app", mr = "#e6e6e6", fr = "#bd282a", vr = 1030, Xe = () => { try { return window.parent.Intercom; } catch { return null; } }, Ze = [Object.freeze(Object.defineProperty({ __proto__: null, disable: () => { const r = Xe(); r && (r.ul_wasVisible = !!document.querySelector("iframe.intercom-launcher-frame"), r.ul_wasVisible && r("update", { hide_default_launcher: !0 })); }, enable: () => { const r = Xe(); r && (r.ul_wasVisible && r("update", { hide_default_launcher: !1 }), delete r.ul_wasVisible); } }, Symbol.toStringTag, { value: "Module" }))]; class Vt { static disable() { Ze.forEach((e) => e.disable()); } static enable() { Ze.forEach((e) => e.enable()); } } const et = "ul-view-sdk-script", Nt = /* @__PURE__ */ new Set(["ios", "android"]), F = "visitors", H = "environments"; async function A(r, e) { var s, n, o; const { shouldDropOnRateLimit: i, ...a } = e; a.headers = Object.assign(C(window.UserLeap), a.headers); const t = await pt(r, { ...a, shouldDropOnRateLimit: i }); if (t.ok) { const l = (s = t.headers) == null ? void 0 : s.get("Authorization"), c = l ? l.split(" ") : void 0, d = c && c.length === 2 ? c[1] : void 0, p = (n = t.headers) == null ? void 0 : n.get("x-ul-visitor-id"); if (window.UserLeap.userId && p === window.UserLeap.visitorId) { const y = z.getItemObject("sprig.anon.env.vid.map"); y && y[window.UserLeap.envId] === p && (delete y[window.UserLeap.envId], z.setItemObject("sprig.anon.env.vid.map", y)); } d && p && (p !== window.UserLeap.visitorId || window.UserLeap.token !== d) && (E("token", d), E("vid", p), g.emit(u.VisitorIDUpdated, { visitorId: p }), window.UserLeap.token = d, window.UserLeap.visitorId = p); } return (o = t.json) != null && o.logMessage && console.warn(`[Sprig] ${t.json.logMessage}`), t; } function E(r, e) { const i = z.getItemObject("userleap.ids"); let a = i[window.UserLeap.envId]; a ? a[r] = e : a = { [r]: e }, i[window.UserLeap.envId] = a, z.setItemObject("userleap.ids", i); } function Me() { return window.previewMode ? "0" : window.UserLeap.visitorId ?? ""; } function x(r, e, i) { const a = [window.UserLeap._API_URL, "sdk", r]; return e && e.forEach((t) => { a.push(t), t === H ? a.push(window.UserLeap.envId) : t === F && a.push(Me()); }), i && a.push(i), a.join("/"); } const ee = async (r, e, i) => { var Be, $e, Ge, Ke; const { context: a, delay: t, avatars: s, experimentFlags: n, forceBrandedLogo: o, endCard: l, isFeedback: c = !1, heatmap: d, locale: p, layout: y, previewMode: f, productConfig: h, providerPersona: L, questions: b, responseGroupUid: m, surveyId: v, uuid: T, vid: k, sessionReplay: _, showProviderPersona: I, studyType: V, surveyVisitorAttributes: j } = r, D = C(window.UserLeap), oe = ae(D), Ue = Le(D); if (_) if (oe) g.emit(u.ReplayCapture, { responseGroupUid: m, hasQuestions: !!(b != null && b.length), surveyId: v, uploadId: _.uploadId, replayType: _.replayDurationType ?? "before", seconds: _.replayDurationSeconds, generateVideoUploadUrlPayload: { mediaRecordingUid: ut(), mediaType: "screen", questionId: 1, responseGroupUid: m, surveyId: v, updatedAt: (/* @__PURE__ */ new Date()).toISOString(), visitorId: window.UserLeap.visitorId, isReplay: !0 } }); else { if (!S.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" }; S.replay.scheduleOrCaptureReplay({ responseGroupId: m, surveyId: v, visitorId: k, replayParams: _, completeUploadHeaders: D, apiUrl: window.UserLeap._API_URL, triggerTimestamp: Date.now(), isStandalone: b.length === 0 }); } if (d) { if (!S.replay) return window.UserLeap.reportError("displayQuestions", new Error("Replay module not registered")), { success: !1, message: "Replay module not registered", surveyState: "no survey" }; const { eventId: U, replayParams: N, responseGroupUid: Ie, surveyId: ke } = d; await S.replay.initializeReplay({ maxReplayDurationSeconds: 300, maxInflightRequests: window.UserLeap.maxInflightReplayRequests, teardownAfter: !0, apiUrl: window.UserLeap._API_URL, replaySettings: i }), S.replay.tryReplayAction(() => { var Je; return (Je = S.replay) == null ? void 0 : Je.scheduleCapture({ apiUrl: window.UserLeap._API_URL, completeUploadHeaders: D, eventId: U, isHeatmap: !0, replayParams: N, responseGroupId: Ie, surveyId: ke, triggerTimestamp: Date.now(), visitorId: k }); }, "Error in scheduling/capturing replay"); } if (k == null || !(b != null && b.length)) return M.info("CannotDisplaySurvey", { vid: k }), { success: !1, message: "[Sprig] no survey found", surveyState: window.UserLeap.container ? "previous survey ready" : "no survey" }; if (window.UserLeap.container) { M.info("AlreadyDisplayingSurvey"); const U = "[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey"; return console.warn(U), { success: !1, message: U, surveyState: "previous survey ready" }; } if (k !== window.UserLeap.visitorId && T !== window.UserLeap.visitorId && !window.previewMode) { const U = "Attempted to display survey to a different visitor"; return window.UserLeap.reportError("DisplaySurvey", new Error(U)), { success: !1, message: U, surveyState: "no survey" }; } M.info("ShowingSurvey", { surveyId: v }), (Be = S.replay) == null || Be.RecordSurveyShown({ id: v, userAgent: window.navigator.userAgent }), Vt.disable(), g.emit(u.SurveyWillPresent, { name: u.SurveyWillPresent, "survey.id": v, layout: y }); let ne, Y, R, le, de = document.createElement("div"); const ze = (U) => { const { "view.version": N } = U; N !== D["x-ul-sdk-version"] && mt(), g.removeListener("verify.view.version", ze); }; g.on("verify.view.version", ze), window.UserLeap.useMobileStyling = Ue, gt(D) ? (ne = "ul-direct-embeded-frame", Y = document.head, R = window, le = !1, (() => { const U = C(window.UserLeap), N = ae(U), Ie = window.UserLeap.forceDirectEmbed, ke = U["userleap-platform"] === "web"; return N || Ie && ke; })() && (bt(v, c), de.id = ne, window.UserLeap.container.appendChild(de), ft(), g.emit(u.SurveyLifeCycle, { state: "presented" }), g.emit(u.SurveyPresented, { name: u.SurveyPresented, "survey.id": v }))) : { frameId: ne, contentWinDocHead: Y, contentWindow: R, hasOverlay: le, iframe: de } = $t({ productConfig: h, useMobileStyling: Ue, surveyId: v, isFeedback: c, enableCspTrustedTypes: ($e = window.UserLeap._config) == null ? void 0 : $e.enableCspTrustedTypes }), window.UserLeap.frameId = ne; const K = { apiURL: window.UserLeap._API_URL, avatars: s, cards: b, configureExitOnOverlayClick: (U) => { g.once(u.CloseSurveyOnOverlayClick, U); }, context: a, endCard: l, envId: window.UserLeap.envId, eventEmitFn: g.emit.bind(g), experimentFlags: n, fontFamily: window.UserLeap.fontFamily, fontFamilyURL: window.UserLeap.fontFamilyURL, forceBrandedLogo: o, frame: de, headers: D, layout: y, locale: p, mobileSDKVersion: window.UserLeap.mobileSDKVersion, previewKey: J.getItem("sprig.previewKey"), previewMode: f || !!window.previewMode, productConfig: { framePosition: h == null ? void 0 : h.framePosition, desktopDisplay: h == null ? void 0 : h.desktopDisplay, placement: h == null ? void 0 : h.placement }, providerPersona: L, responseGroupUid: m, showProviderPersona: I, startingQuestionIdx: (Ge = window.UserLeap.config) == null ? void 0 : Ge.startingQuestionIdx, studyType: V, styleNonce: window.UserLeap.styleNonce, surveyId: v, tabTitle: document.title, trackPageViewUrl: e, ulEvents: se, upchunkLibraryURL: window.UserLeap.upchunkLibraryURL, useMobileStyling: Ue, userId: T, viewDocument: R == null ? void 0 : R.document, viewWindow: R, visitorAttributes: { externalUserId: window.UserLeap.userId, email: window.UserLeap.email }, surveyVisitorAttributes: j || {}, ...window.UserLeap._config }; (Ke = window.UserLeap._config) != null && Ke.startingQuestionIdx && (window.UserLeap._config = { ...window.UserLeap._config, startingQuestionIdx: null }); const Ct = (c ? window.UserLeap.feedbackCustomStyles : window.UserLeap.customStyles) ?? h.customStyles; K.customStyles = Ct, R && (R.__cfg = K); const Se = window.UserLeap.viewSDKURL ? window.UserLeap.viewSDKURL : K.path, Ve = document.getElementById(et); Ve && Ve.remove(); const Te = function() { const U = document.createElement("script"); return window.UserLeap.isMobileSDK || U.setAttribute("type", "module"), window.UserLeap.nonce && U.setAttribute("nonce", window.UserLeap.nonce), U.id = et, U; }(), Ne = () => { window.UserLeap.container && Object.assign(window.UserLeap.container.style, { display: "flex" }); }; if (K.installationMethod === "web-npm" || K.installationMethod === "web-npm-bundled") { const { default: U } = await import("./view-BFJhGEb5.js").then((N) => N.C); U.configure(K), le && window.UserLeap.container && Ne(); } else Se && (Te.src = `${Se}${window.UserLeap.isMobileSDK ? "" : `?t=${Date.now()}`}`, le && Te.addEventListener("load", () => { window.UserLeap.container && Ne(); }), R == null || R.addEventListener("error", (U) => { U.target instanceof HTMLScriptElement && U.target.src === Se && window.UserLeap.reportError("loadFrameScript", new Error("Frame script failed to load")); }, { capture: !0, once: !0 })); Y == null || Y.appendChild(Te); const We = { success: !0, surveyState: "ready", surveyId: v, responseGroupUid: m }; return window.UserLeap.isMobileSDK && t && (We.delay = t), We; }; function Le(r) { var i; if (window.UserLeap.useMobileStyling !== void 0) return window.UserLeap.useMobileStyling; const e = ((i = window.UserLeap.windowDimensions) == null ? void 0 : i.width) ?? document.body.clientWidth; return ae(r) || e > 10 && e < 500; } function ae(r) { return Nt.has(r["userleap-platform"]); } const tt = /* @__PURE__ */ new WeakMap(), Wt = (r, e) => { try { return ((a) => { var n, o; const t = tt.get(a); if (t) return t; if (!((n = a.trustedTypes) != null && n.createPolicy)) throw new Error("Trusted types not supported"); const s = (o = a.trustedTypes) == null ? void 0 : o.createPolicy("sprig-sdk", { createHTML: (l) => l, createScript: (l) => l, createScriptURL: (l) => l }); return tt.set(a, s), s; })(e).createHTML(r); } catch (i) { return console.warn("Could not create TrustedHTML object", i), r; } }, je = (r, e, i = window) => { var a; return e && ((a = i.trustedTypes) != null && a.createPolicy) ? Wt(r, i) : r; }, qe = "ul-frame"; globalThis.UserLeap && globalThis.Sprig && (globalThis.Sprig._gtm ? globalThis.Sprig = globalThis.UserLeap : globalThis.UserLeap = globalThis.Sprig), globalThis.UserLeap || (globalThis.UserLeap = globalThis.Sprig), globalThis.Sprig || (globalThis.Sprig = globalThis.UserLeap); const Ee = "0px", bt = (r, e, i) => { globalThis.UserLeap.container = document.createElement("div"), globalThis.UserLeap.container.className = "ul-container" + (e ? " ul-container-feedback" : ""), r && (globalThis.UserLeap.container.dataset.studyId = r.toString()); const a = wt(); i && a && !globalThis.UserLeap.useMobileStyling ? a.appendChild(globalThis.UserLeap.container) : document.body.appendChild(globalThis.UserLeap.container); }, mt = (r, e) => { var a; Kt(); const i = globalThis.UserLeap.container; if (i) try { (a = i.parentNode) == null || a.removeChild(i), globalThis.UserLeap.container = null, E("trackStartUrl", null), g.emit(u.SurveyLifeCycle, { state: "dismissed" }), g.emit(u.SurveyClosed, { name: u.SurveyClosed, initiator: r, "survey.id": parseInt(i.dataset.studyId), ...e && { studyType: e } }); } catch (t) { console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${r} ` + i), t instanceof Error && globalThis.UserLeap.reportError("dismissActiveSurvey", t); } }, ft = () => { g.once(u.SurveyWillClose, ({ initiator: r, studyType: e }) => { g.removeAllListeners(u.CloseSurveyOnOverlayClick), mt(r, e); }); }, Bt = (r, e, i, a) => { var d, p; const t = { position: "fixed", bottom: "0px", right: Ee, border: 0, backgroundColor: "rgba(0,0,0,0)", zIndex: 2147483646, transition: "width 0.2s ease-in-out, height 0.2s ease-in-out", maxWidth: "100%" }, s = Object.assign({}, e, globalThis.UserLeap), { desktopDisplay: n } = e || {}, o = n === "center-modal"; let l; o && (s.framePosition = "center"); let c = !1; if (i) (d = globalThis.UserLeap.windowDimensions) != null && d.width ? t.width = `${globalThis.UserLeap.windowDimensions.width}px` : t.width = "100%", (p = globalThis.UserLeap.windowDimensions) != null && p.height ? t.maxHeight = globalThis.UserLeap.windowDimensions.height - 20 + "px" : globalThis.UserLeap.maxHeight ? t.maxHeight = globalThis.UserLeap.maxHeight : t.maxHeight = document.body.clientHeight - 20 + "px", ["light", "dark"].includes(s.overlayStyleMobile) && (c = !0); else { t.width = "360px", t.maxHeight = globalThis.UserLeap.maxHeight || "66vh"; const y = () => { c = !0, l = { margin: "auto", position: "static" }; }; if (a) o ? y() : l = { position: "relative", height: "300px" }; else switch (s.framePosition) { case "bottomLeft": l = { left: Ee }; break; case "topLeft": l = { left: Ee, top: 0 }; break; case "topRight": l = { top: 0 }; break; case "center": y(); } } return c && ((y, f) => { const h = { position: "fixed", overflow: "auto", top: "0px", left: "0px", display: "none", height: "100%", width: "100%", transition: "background-color 0.3s ease-out", zIndex: 2147483646 }, L = f ? y.overlayStyleMobile : y.overlayStyle; h["background-color"] = L === "light" ? "rgba(255,255,255, 0.95)" : "rgba(0,0,0,0.9)", f || (h.margin = "auto"), globalThis.UserLeap.container && Object.assign(globalThis.UserLeap.container.style, h); })(s, i), Object.assign(r.style, t, l), c; }, $t = ({ productConfig: r, useMobileStyling: e, surveyId: i, isFeedback: a, enableCspTrustedTypes: t }) => { var f, h; const s = qe, n = a && r.desktopDisplay === "slider"; bt(i, a, n), Gt(); const o = document.createElement("iframe"); o.id = s, o.setAttribute("title", "Sprig User Feedback Dialog"); const l = Bt(o, r, e, a); ft(); let c = !1; o.setHeight = (L) => { parseInt(o.style.height) == L && c || (c = !0, o.style.height = `${L}px`, g.emit(u.SurveyHeight, { name: u.SurveyHeight, contentFrameHeight: L, "survey.id": i })); }; let d = !1; o.setWidth = (L) => { parseInt(o.style.width) == L && d || (d = !0, o.style.width = `${L}px`, g.emit(u.SurveyWidth, { name: u.SurveyWidth, contentFrameWidth: L, "survey.id": i })); }, (f = globalThis.UserLeap.container) == null || f.appendChild(o), r && (e ? r.exitOnOverlayClickMobile : r.exitOnOverlayClick) && globalThis.UserLeap.container && (globalThis.UserLeap.container.onclick = () => { g.emit(u.CloseSurveyOnOverlayClick); }), g.emit(u.SurveyLifeCycle, { state: "presented" }), g.emit(u.SurveyPresented, { name: u.SurveyPresented, "survey.id": i }); const p = (h = o.contentWindow) == null ? void 0 : h.document; if (p && (p.open("text/html", "replace"), p.write(je("<!doctype html><head></head><body></body></html>", t, o.contentWindow)), p.close(), !e)) { const L = p.body; L.style.display = "flex", L.style.alignItems = "center"; } const y = p == null ? void 0 : p.head; return { frameId: s, contentWinDocHead: y, contentWindow: o.contentWindow, hasOverlay: l, iframe: o }; }, vt = { [u.SurveyFadingOut]: () => { globalThis.UserLeap.container && Object.assign(globalThis.UserLeap.container.style, { "background-color": "rgba(0,0,0,0)" }); } }, Gt = () => { Object.entries(vt).forEach(([r, e]) => { g.on(r, e); }); }, Kt = () => { Object.entries(vt).forEach(([r, e]) => { g.off(r, e); }); }, q = (r) => !!r && r.nodeType === Node.ELEMENT_NODE, rt = (r) => r instanceof HTMLElement || r instanceof SVGElement, ue = ({ document: r, elementId: e, styleString: i, nonce: a }) => { const t = r.getElementById(e); if (t) return void (t.textContent = i); const s = r.createElement("style"); a && (s.nonce = a), s.textContent = i, s.id = e, r.head.appendChild(s); }, it = (r, e) => { const i = e.querySelector(r); if (!q(i)) return 0; const a = getComputedStyle(i); return parseFloat(a.paddingLeft) + parseFloat(a.paddingRight) + (parseFloat(a.marginLeft) + parseFloat(a.marginRight)) + (parseFloat(a.borderLeftWidth) + parseFloat(a.borderRightWidth)); }, Jt = (r, e, i) => { const a = r.querySelector(".ul-card__container"), t = r.querySelector(".ul-app"); let s = 600, n = 360; if (q(a) && q(t)) { const o = a.querySelector(".ul-card--matrix_grid"), l = !o && e && i; try { l && (t.style.width = "360px"), s = a.scrollHeight, s += ((p) => { const y = p.querySelector(".sprig-question-body"), f = p.querySelector(".ul-card"), h = p.querySelector(".ul-card-main-content"), L = p.querySelector(".ul-footer"), b = p.querySelector(".sprig-container"); let m = 0; return q(f) && (m += f.scrollHeight - f.clientHeight), q(h) && (m += h.scrollHeight - h.clientHeight), q(y) && (m += y.scrollHeight - y.clientHeight), q(L) && q(b) && b.clientHeight === 0 && (m += L.clientHeight), m; })(r); const c = getComputedStyle(a), d = parseFloat(c.marginTop) + parseFloat(c.marginBottom); s += d + (parseFloat(c.borderTopWidth) + parseFloat(c.borderBottomWidth)), o && (n = o.scrollWidth, n += it(".ul-card__container", r), n += it(".sprig-question-body", r)); } finally { l && t.style.removeProperty("width"); } } return [s + 2, n]; }, wr = (r) => { const e = r.querySelector(".ul-card__container"); e && (e.scrollTop = 0); }, wt = () => w, Q = () => document.getElementById("sprig-feedback-container"), De = () => document.getElementById("sprig-feedback-loading-animation"), Lt = () => !!document.getElementById(qe); let st = !1, w = null, O = null, Fe = !1, te = null, B = null; const Qt = ["bottom-left", "bottom-right", "center-left", "center-right"], ge = () => { var e; const r = window.UserLeap.container; return ((e = r == null ? void 0 : r.parentElement) == null ? void 0 : e.id) === "sprig-feedback-loading-container"; }, Ut = () => document.getElementById("sprig-feedback-error-container"), St = () => { if (!w) return 0; const r = w == null ? void 0 : w.clientWidth, e = window.getComputedStyle(w); return r + parseInt(e.borderRightWidth || "0") + parseInt(e.borderLeftWidth || "0"); }, he = (r) => { const e = Q(); e && (B != null && B.endsWith("right") ? e.style.right = `${r}px` : B != null && B.endsWith("left") && (e.style.left = `${r}px`)); }, _e = () => { if (w && (ge() || Ut())) { g.off(u.SurveyAppeared, Z), Ae(); const r = St(); return he(-r), !0; } return !1; }, Z = () => { if (!w || !O) return; const r = De(); r && r.remove(), w.style.height = "auto", w.style.width = "auto", O.disabled = !1, Fe = !1; }, Ae = () => { if (w && !De()) { const r = (() => { var i; if (De()) return; const e = document.createElement("div"); 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 = je(` <div class="ul-loading-spinner"> <div class="first"></div> <div class="second"></div> <div class="third"></div> <div class="fourth"></div> </div> `, (i = window.UserLeap._config) == null ? void 0 : i.enableCspTrustedTypes), e; })(); r && (w.style.height = "300px", w.style.width = "360px", w.appendChild(r)); } }, at = () => { w && O && (he(0), O.disabled = !0, Fe = !0); }, Tt = async (r, e, i) => { const { buttonTheme: a, customStyles: t, eventId: s, placement: n, desktopDisplay: o, feedbackLabel: l, surveyUuid: c, surveyId: d } = r; window.UserLeap.feedbackCustomStyles = void 0; let p = Q(); if (p) { if (!e && s === te) return; p.remove(), g.off(se.SURVEY_FADING_OUT, _e); } te = s, ue({ 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 }), ue({ document, elementId: "ul-custom-style", styleString: t ?? "", nonce: window.UserLeap.styleNonce }), st = o === "center-modal", B = n; const [y, f] = n.split("-"); ((m) => { if (Q() || !Qt.includes(m)) return; const [v, T] = m.split("-"), k = document.createElement("div"); k.id = "sprig-feedback-container", k.classList.add(`sprig-feedback-container-${T}`, `sprig-feedback-container-${v}`), document.body.appendChild(k); })(n), p = Q(), O = document.createElement("button"); const h = document.createElement("div"); h.className = "sprig-feedback-button-label", h.innerText = l, O.appendChild(h), O.id = "sprig-feedback-button", O.classList.add(`sprig-feedback-button-${f}`, `sprig-feedback-button-${y}`, `sprig-feedback-button-${a}`, "fade-in-transition"), g.on(se.SURVEY_FADING_OUT, _e), O.addEventListener("click", async () => { const m = document.getElementById("sprig-feedback-error-container"); if (Lt() || Ut()) { if (_e()) { g.emit(u.SurveyCloseRequested, { name: u.SurveyCloseRequested, initiator: P.FeedbackClosed, studyType: "feedbackButton", "survey.id": d }), g.emit(u.SurveyWillClose, { name: u.SurveyWillClose, initiator: P.FeedbackClosed, studyType: "feedbackButton", "survey.id": d }); const T = Q(); m && T && (T.remove(), te = null, w = null); } return; } if (Le(C(window.UserLeap)) || Fe || at(), e) return w && w.classList.add("sprig-feedback-loading-container-previews"), await ee(e), void Z(); const v = await (async (T) => { const k = await A(x("1", [F], "startFeedbackStudy"), { body: JSON.stringify({ surveyUuid: T }), method: "POST" }); return k.ok ? k.json : null; })(c); if (v) g.once(u.SurveyAppeared, Z), ee({ ...v, studyType: "feedbackButton" }, i); else if (w) { const T = Yt(); w.appendChild(T), Z(), w.style.height = "300px", w.style.width = "360px"; } }), p == null || p.appendChild(O), g.emit(u.FeedbackButtonLoaded, { name: u.FeedbackButtonLoaded, "survey.id": d }); const { useMobileStyling: L, _config: { border: b } } = window.UserLeap; if (st || L) he(0); else { const m = document.createElement("div"); m.id = "sprig-feedback-loading-container", m.className = `sprig-feedback-loading-container sprig-feedback-loading-container-${f}`, m.style.setProperty("--feedback-border", b), w = m, Ae(), p == null || p.appendChild(m); const v = St(); he(-v); } window.UserLeap._config.isOnQuestionsTab && e && !ge() && w && (at(), Ae(), w && w.classList.add("sprig-feedback-loading-container-previews"), ee(e), Z()); }, Yt = () => { var i; const r = document.createElement("div"); r.id = "sprig-feedback-error-container", r.innerHTML = je(`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"> <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/> <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/> <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/> </svg>`, (i = window.UserLeap._config) == null ? void 0 : i.enableCspTrustedTypes); const e = document.createElement("h3"); return e.className = "sprig-feedback-error-text", e.innerText = "There was an error while loading the survey", r.appendChild(e), r; }, Oe = new class { constructor() { W(this, "_ldData", {}); } getAllLaunchDarklyVariations() { return this._ldData; } setLDFlagsVariations(r) { try { return !(!r || typeof r != "object" || Array.isArray(r)) && (Object.keys(this._ldData).forEach((e) => { delete this._ldData[e]; }), Object.keys(r).forEach((e) => this._ldData[`!launch_darkly_${e}`] = (r[e] ?? 0) + 1), !0); } catch (e) { return e instanceof Error && window.UserLeap.reportError("setAllLDFlagsVariations", e), console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."), !1; } } }(); Object.freeze(Oe); const pe = new class { constructor() { W(this, "_optimizelyData", {}); } setOptimizelyExperiment(r, e = !0) { if (!r || typeof r != "object") return !1; const { experiments: i } = r; try { return e && Object.keys(this._optimizelyData).map((a) => { delete this._optimizelyData[a]; }), i && i.map((a) => { const { id: t, variation: s } = a, n = this.transformExperimentId(t); s && typeof s == "string" && (this._optimizelyData[n] = s); }), !0; } catch (a) { return a instanceof Error && window.UserLeap.reportError("setOptimizelyExperiment", a), !1; } } getAllOptimizelyExperiments() { return this._optimizelyData; } getOptimizelyVariationName(r) { return this._optimizelyData[this.transformExperimentId(r)]; } transformExperimentId(r) { return "!optimizely_experiments_" + r; } getAndSetWebOptimizelyExperiments() { var r; try { if (window && window.optimizely && typeof window.optimizely.get == "function") { const e = (r = window.optimizely.get("state")) == null ? void 0 : r.getExperimentStates({ isActive: !0 }); if (e) { const i = Object.keys(e).map((a) => { var t, s; return (t = e[a].variation) != null && t.name ? { id: a, variation: (s = e[a].variation) == null ? void 0 : s.name } : { id: a, variation: "Original" }; }); return this.setOptimizelyExperiment({ experiments: i }, !1), !0; } return !1; } return !1; } catch (e) { return e instanceof Error && window.UserLeap.reportError("getAndSetWebOptimizely", e), !1; } } }(); Object.freeze(pe); class Xt { constructor(e, i) { W(this, "paused"); W(this, "queue"); W(this, "ul"); this.ul = e, this.paused = !1, this.queue = [], this.flush(i); } flush(e) { const i = e.length; if (i) for (let a = 0; a < i; a++) this.push(e[a]); } isPaused() { return this.paused; } pause() { this.paused = !0; } unpause() { this.paused = !1; const e = this.queue.slice(); this.empty(), this.flush(e); } push(e) { if (this.paused) this.queue.push(e); else if (e instanceof Function) e(); else { const i = Array.prototype.slice.call(e, 1), a = e[0], t = this.ul[a]; t instanceof Function ? t.apply(this.ul, i) : a && console.warn("[Sprig] (ERR-100) No valid UserLeap action called", a); } } perform(e) { if (this.paused) { let i = () => { }; const a = new Promise(function(t) { i = function() { t(e()); }; }); return this.queue.push(i), a; } return e(); } empty() { this.queue.length = 0; } } let It, kt; const Ce = (r) => { let e = 0, i = r.firstElementChild; for (; i; ) e += Ce(i), i.shadowRoot && (e += Ce(i.shadowRoot)), i = i.nextElementSibling, e++; return e; }, ot = () => { It.report(Ce(document.body)), kt.report(document.documentElement.innerHTML.toString().length); }, Pe = (r, e) => { const i = performance.now(); document.hidden ? setTimeout(() => Pe(r, e), r) : setTimeout(() => { const a = performance.now() - i; e.report(a / 1e3), setTimeout(() => Pe(r, e), r); }, 0); }; let ye, be, me, fe, nt, $ = {}; const ce = (r, e = 1) => { const { name: i } = r; $[i] = ($[i] || 0) + e; }, Et = (r) => { let e = 1; return r.childNodes.forEach((i) => { e += Et(i); }), e; }, lt = (r) => { let e = 0; return r.forEach((i) => { e += Et(i); }), e; }, Zt = (r) => { switch (r.type) { case "childList": return ce(ye, lt(r.addedNodes)), void ce(be, lt(r.removedNodes)); case "attributes": return void ce(me); case "characterData": return void ce(fe); } }, er = (r) => r.forEach(Zt), tr = () => { ye.report($[ye.name] || 0), be.report($[be.name] || 0), me.report($[me.name] || 0), fe.report($[fe.name] || 0), $ = {}; }, rr = (r = 1e3) => { ye = G("sdk_mutations_nodes_added"), be = G("sdk_mutations_nodes_removed"), me = G("sdk_mutations_attributes_changed"), fe = G("sdk_mutations_character_data"), nt = new MutationObserver(er), nt.observe(document, { attributes: !0, attributeOldValue: !0, characterData: !0, characterDataOldValue: !0, childList: !0, subtree: !0 }), setInterval(tr, r); }, ir = ({ isWeb: r, reportingIntervalSeconds: e, thresholds: i, postMetrics: a }) => { qt(i, (t, s) => { var n, o; if ((n = S.replay) != null && n.isReplayRecording()) { const l = `Value: ${t} on ${s.metric} violated threshold of ${s.type} ${s.value}`; (o = S.replay) == null || o.disableRecording("Threshold violated", new Error(l), { reportError: !1 }), window.UserLeap.reportError("Sdk Performance Metric threshold violated", new Error("Sdk Performance Metric threshold violated"), { metricName: s.metric, type: s.type, value: s.value }, { metricName: s.metric }), Ht(); } }), Ft({ reportingIntervalSeconds: e, postMetrics: a }), r && (((t = 1e3) => { const s = G("sdk_event_queue_latency_seconds"); Pe(t, s); })(), ((t = 1e4) => { It = G("sdk_dom_nodes_count"), kt = G("sdk_page_html_characters"), ot(), setInterval(ot, t); })(), rr()); }, sr = "test", ar = ["popState", "pushState", "replaceState"]; let He, re; const ve = {}, X = "!email", _t = "pageUrl"; var ct; let Re = ((ct = globalThis.location) == null ? void 0 : ct.href) || ""; function ie(r) { var o, l; const { pageUrlEvents: e, interactiveEvents: i, dismissOnPageChange: a, platform: t } = globalThis.UserLeap._config; if (t && t !== "web") return; Re !== globalThis.location.href && M.navigation("LocationChange", { from: Re, to: globalThis.location.href }), Re = globalThis.location.href; const s = Dt().trackStartUrl, n = s ? String(s) : null; e && Ot(globalThis.location.href), i && (xt(), or()), wt() && (() => { if (ge()) return; const c = Q(); c && (jt(te) || (c.remove(), te = null, w = null)); })(), J.getItem("sprig.isCapturingHeatmap") && ((l = (o = S.replay) == null ? void 0 : o.checkPendingHeatmapsUrl()) == null || l.then((c) => { var d; c && ((d = S.replay) == null || d.uploadReadyPendingCaptures(!0)); })), !ge() && a && n && n !== globalThis.location.href && r && ar.includes(r.type) && globalThis.UserLeap("dismissActiveSurvey", P.PageChange); } const Rt = { capture: !0 }, or = () => { const r = globalThis.UserLeap._config.interactiveEvents.filter((i) => ht(i, globalThis.location.href)).map((i) => { const { name: a, properties: t } = i, { selector: s, innerText: n } = t; return s ? (o) => { if (rt(o.target)) try { o.target.closest(s) && globalThis.UserLeap("track", a); } catch { } return !1; } : (o) => (rt(o.target) && o.target.innerText === n && globalThis.UserLeap("track", a), !1); }), e = (i) => r.forEach((a) => a(i)); globalThis.UserLeap._config.interactiveEventsHandler = e, globalThis.addEventListener("click", e, Rt); }, xt = () => { globalThis.UserLeap._config.interactiveEventsHandler && globalThis.removeEventListener("click", globalThis.UserLeap._config.interactiveEventsHandler, Rt), delete globalThis.UserLeap._config.interactiveEventsHandler; }; function Dt() { const r = z.getItemObject("userleap.ids"); return (r == null ? void 0 : r[globalThis.UserLeap.envId]) || {}; } function At() { if (globalThis.previewMode) return; const r = z.getItemObject("sprig.anon.env.vid.map") || {}, e = r[globalThis.UserLeap.envId]; globalThis.UserLeap.visitorId = e || ut(), M.info("NewVid", { vid: globalThis.UserLeap.visitorId }), E("vid", globalThis.UserLeap.visitorId), e || (r[globalThis.UserLeap.envId] = globalThis.UserLeap.visitorId, z.setItemObject("sprig.anon.env.vid.map", r)), g.emit(u.VisitorIDUpdated, { visitorId: globalThis.UserLeap.visitorId }); } function Ot(r, e, i, a) { var t, s; try { if (r.endsWith("mock_snippet.html")) return; M.info("PageView", { url: r }); const n = (t = document == null ? void 0 : document.querySelector('meta[name="description"]')) == null ? void 0 : t.getAttribute("content"); (s = S.replay) == null || s.RecordPageView({ ...n && { description: n }, url: r, referrer: document.referrer, pageTitle: document.title }); const o = globalThis.UserLeap._config.pageUrlEvents; let l = !1; if (o && o.length) for (let d = 0; d < o.length && (l = ht(o[d], r), !l); d++) ; if (!l) return; globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig trackPageView", r); const c = { url: r }; a && (c.trackPageView = !0), globalThis.UserLeap._queue.push(["track", _t, e, c, i]); } catch (n) { n instanceof Error && (n.stack = r, globalThis.UserLeap.reportError("trackPageView", n)), console.warn("[Sprig] (ERR-428) Failed to track page view", n); } } function nr() { var e; const r = ((e = globalThis.Backbone) == null ? void 0 : e.history) || globalThis.history; "pushState" in r && (r.pushState = /* @__PURE__ */ ((i) => function(...a) { const t = i.apply(this, a), s = new Event("pushState"); return globalThis.dispatchEvent(s), ie(s), t; })(r.pushState)), "replaceState" in r && (r.replaceState = /* @__PURE__ */ ((i) => function(...a) { const t = i.apply(this, a), s = new Event("replaceState"); return globalThis.dispatchEvent(s), ie(s), t; })(r.replaceState)), ["hashchange", "popstate"].forEach((i) => globalThis.addEventListener(i, ie, !0)); } async function xe(r, e) { const i = Me(); r && !e && (globalThis.UserLeap._config.mode = sr); const a = Le(C(globalThis.UserLeap)), t = await A(function(s) { const n = new URL(x("1", [H], "questions")); return Object.entries(s || {}).forEach(([o, l]) => { l && n.searchParams.append(o, String(l)); }), n.toString(); }({ desktopDisplay: globalThis.UserLeap._config.desktopDisplay, isMobile: a, previewLanguage: globalThis.UserLeap._config.previewLanguage, surveyid: r == null ? void 0 : r.surveyId, surveytemplateid: r == null ? void 0 : r.surveyTemplateId, vid: i }), { shouldDropOnRateLimit: !0 }); if (!t.ok) return t.reportError && t.error && (console.warn("[Sprig] (ERR-414) Failed to request questions from the server", t.error), globalThis.UserLeap.reportError("getQuestions", t.error)), { success: !1, surveyState: "no survey" }; if (t.json.delay && await yt(t.json.delay), !t.json.isFeedback) return ee(t.json, re, He); { const { feedbackLabel: s, productConfig: n, surveyUuid: o, feedbackCustomStyles: l } = t.json, { buttonTheme: c, placement: d, desktopDisplay: p } = n; Tt({ customStyles: l, buttonTheme: c, desktopDisplay: p, eventId: 0, feedbackLabel: s, placement: d, surveyUuid: o, surveyId: r == null ? void 0 : r.surveyId }, t.json); } } function lr(r) { if (!r) return; globalThis.UserLeap._config = r, r.mute && globalThis.UserLeap._queue.pause(); const { interactiveEvents: e, pageUrlEvents: i, dismissOnPageChange: a } = r; e && function(t) { let s = t.length; for (; s; ) { const n = Math.floor(Math.random() * s); s -= 1; const o = t[s]; t[s] = t[n], t[n] = o; } }(e), (e || i || a) && (nr(), ie()); } const dr = function(r) { if (!globalThis.UserLeap) return; const e = async (t = {}) => { var m, v, T, k, _; const { userId: s, anonymousId: n, metadata: o = {}, properties: l, showSurveyCallback: c } = t; let { eventName: d } = t; if (globalThis.UserLeap.debugMode && d !== _t && console.info("[DEBUG] Sprig track", t), r.mode === "test") return; const p = J.getItem("sprig.previewKey") ?? void 0; if (r.requireUserIdForTracking && !globalThis.UserLeap.userId && !s) { const I = "[Sprig] - Skipping tracking without userId"; return console.warn(I), { success: !1, message: I, surveyState: "no survey" }; } if (!d || d.trim().length === 0) { d = d ? String(d) : ""; const I = "[Sprig] - Invalid event name " + d; return console.warn(I), { success: !1, message: I, surveyState: "no survey" }; } const y = re ?? globalThis.location.href; o.url || (o.url = y), E("trackStartUrl", y), (v = (m = globalThis.UserLeap) == null ? void 0 : m._config) != null && v.optimizelyEnabled && (ae(C(globalThis.UserLeap)) || pe.getAndSetWebOptimizelyExperiments(), o.optimizelyExperiments = Object.assign({}, pe.getAllOptimizelyExperiments())), (k = (T = globalThis.UserLeap) == null ? void 0 : T._config) != null && k.launchDarklyEnabled && (o.launchDarklyFlags = Oe.getAllLaunchDarklyVariations()), s && (globalThis.UserLeap.userId = s), n && (globalThis.UserLeap.partnerAnonymousId = n), l && (o.eventProperties = l), (_ = S.replay) == null || _.RecordEvent({ name: d, url: o.url }), M.info("TrackEvent", { eventName: d }); const f = globalThis.UserLeap.delayingSurvey || Lt() ? await A(x("1", [F], "events/batch"), { body: JSON.stringify({ events: [{ event: d, metadata: o }], previewKey: p }), method: "POST", shouldDropOnRateLimit: !0 }) : await A(x("1", [F], "events"), { body: JSON.stringify({ event: d, metadata: o, previewKey: p }), method: "POST", shouldDropOnRateLimit: !0 }); if (!f.ok) { const I = "[Sprig] (ERR-421) Failed to track event"; return f.reportError && (console.warn(I, f.error), f.error && globalThis.UserLeap.reportError("track", f.error)), { success: !1, message: I, error: f.error, surveyState: "no survey" }; } s && E("uid", s), n && E("aid", n); const h = f.json; h.invalidPreviewKey && J.removeItem("sprig.previewKey"); const L = o.trackPageView ? o.url : void 0; return h != null && h.feedbackButton && Tt(h.feedbackButton, void 0, L), await async function(I, V) { var D, oe; let j = !0; return !(V && ((D = I == null ? void 0 : I.json) != null && D.surveyId) && (globalThis.UserLeap.delayingSurvey = !0, j = await V(I.json.surveyId), globalThis.UserLeap.delayingSurvey = !1, !j)) && ((oe = I == null ? void 0 : I.json) != null && oe.delay && !globalThis.UserLeap.isMobileSDK && (globalThis.UserLeap.delayingSurvey = !0, await yt(I.json.delay), globalThis.UserLeap.delayingSurvey = !1), j); }(f, c) ? function(I) { if (!globalThis.UserLeap._config.dismissOnPageChange) return !0; const V = new URL(I), j = new URL(re ?? globalThis.location.href); return V.hostname === j.hostname && V.pathname === j.pathname; }(y) ? ee(h, L, He) : { 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" }; }, i = (t, s) => { var o; const n = (o = t == null ? void 0 : t.querySelector(`[id="${qe}"]`)) == null ? void 0 : o.contentDocument; n && ue({ document: n, elementId: "ul-custom-style", styleString: s }); }, a = { displaySurvey: async (t) => (console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."), globalThis.UserLeap("dismissActiveSurvey", P.Override), xe({ surveyId: t }, !0)), _previewSurvey(t) { globalThis.UserLeap("dismissActiveSurvey", P.Override), xe({ surveyTemplateId: t }, !1); }, _reviewSurvey(t) { globalThis.UserLeap("dismissActiveSurvey", P.Override), xe({ surveyId: t }, !1); }, previewSurvey(t) { a._previewSurvey(t); }, reviewSurvey(t) { a._reviewSurvey(t); }, mute() { globalThis.UserLeap._queue.pause(); }, unmute() { globalThis.UserLeap._queue.unpause(); }, setVisitorToken() { console.warn("[Sprig] setVisitorToken is deprecated."); }, dismissActiveSurvey(t = P.API) { globalThis.UserLeap.container && (t === P.Closed && globalThis.Sprig.trackHistory && globalThis.Sprig.trackHistory({ event: "closed" }), g.emit(u.SurveyCloseRequested, { name: u.SurveyCloseRequested, initiator: t, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) }), g.emit(u.SurveyWillClose, { name: u.SurveyWillClose, initiator: t, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) })); }, async setAttribute(t, s) { if (!t || !s && s !== 0 && s !== !1) { const n = "[Sprig] - Disregarding empty attribute / value provided"; return console.warn(n), { success: !1, message: n }; } return this.setAttributes({ [t]: s }); }, async setAttributes(t) { if (t == null || Object.keys(t).length === 0) { const s = "[Sprig] - Disregarding empty attributes provided"; return console.warn(s), { success: !1, message: s }; } return this.identifyAndSetAttributes({ attributes: t }); }, async identifyAndSetAttributes(t) { if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig identifyAndSetAttributes", t), r.mode === "test") return; if (t === null || typeof t != "object" || !(t.userId || t.anonymousId || t.attributes)) { const d = "[Sprig] - Disregarding empty payload provided"; return console.warn(d), { success: !1, message: d }; } const { userId: s, anonymousId: n, attributes: o } = t; if (r.requireUserIdForTracking && !globalThis.UserLeap.userId && !s) { const d = "[Sprig] - Skipping tracking without userId"; return console.warn(d), { success: !1, message: d }; } if (o) { o.email && !o[X] && (o[X] = o.email, delete o.email); const d = Object.keys(o); for (const p of d) o[p] === ve[p] && delete o[p]; } if (!(o && Object.keys(o).length !== 0 || s && globalThis.UserLeap.userId !== s || n && globalThis.UserLeap.partnerAnonymousId !== n)) return { success: !0 }; const l = {}; let c; return s && (l.userId = globalThis.UserLeap.userId = s), n && (l.partnerAnonymousId = globalThis.UserLeap.partnerAnonymousId = n), o && Object.keys(o).length > 0 ? (c = await A(x("1", [H, F], "attributes"), { body: JSON.stringify(o), method: "PUT" }), c.ok ? Object.assign(ve, o) : c.reportError && (console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed", c.error), c.error && globalThis.UserLeap.reportError("identifyAndSetAttributes", c.error))) : c = await A(x("1", [H, F]), { body: JSON.stringify(l), method: "PUT" }), o && o[X] && (globalThis.UserLeap.email = o[X]), c.ok && (s && E("uid", s), n && E("aid", n)), { success: !!c.ok }; }, async removeAttributes(t) { if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig removeAttributes", t), r.mode === "test") return; if (t == null || t.length === 0) { const n = "[Sprig] - Disregarding empty attributes provided"; return console.warn(n), { success: !1, message: n }; } if (r.requireUserIdForTracking && !globalThis.UserLeap.userId) { const n = "[Sprig] - Skipping tracking without userId"; return console.warn(n), { success: !1, message: n }; } const s = await A(x("1", [H, F], "attributes"), { body: JSON.stringify({ delete: t }), method: "DELETE" }); return !s.ok && s.reportError && (console.warn("[Sprig] (ERR-433) Remove attributes failed", s.error), s.error && globalThis.UserLeap.reportError("removeAttributes", s.error)), { success: !!s.ok }; }, async addSurveyListener(t) { g.on(u.SurveyLifeCycle, t); }, async removeSurveyListener(t) { g.removeListener(u.SurveyLifeCycle, t); }, async addListener(t, s) { g.on(t, s); }, async removeListener(t, s) { g.removeListener(t, s); }, async removeAllListeners() { g.removeAllListeners(); }, setPreviewKey(t) { t && typeof t == "string" && J.isStorageAvailable && t && J.setItem("sprig.previewKey", t); }, async setUserId(t) { var o; if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig setUserId", t), t == null) { const l = `[Sprig] - Invalid userId ${t}`; return console.warn(l), { success: !1, message: l }; } if (r.mode === "test" || t === globalThis.UserLeap.userId) return; globalThis.UserLeap.userId = t; const s = globalThis.UserLeap.visitorId, n = await A(x("1", [H, F]), { body: JSON.stringify({ userId: t }), method: "PUT" }); n.ok ? (s !== globalThis.UserLeap.visitorId && ((o = S.replay) == null || o.clearUserReplayData()), E("uid", t)) : n.reportError && (console.warn("[Sprig] (ERR-420) Failed to set user id", n.error), n.error && globalThis.UserLeap.reportError("setUserId", n.error)); }, async setPartnerAnonymousId(t) { if (globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig setPartnerAnonymousId", t), t == null) { const s = `[Sprig] - Invalid partnerAnonymousId ${t}`; return console.warn(s), { success: !1, message: s }; } return globalThis.UserLeap.partnerAnonymousId = t, E("aid", t), { success: !0 }; }, track: async (t, s, n = {}, o = void 0) => e({ eventName: t, properties: s, metadata: n, showSurveyCallback: o }), identifyAndTrack: async (t) => await e(t), trackPageView(t, s = void 0, n = void 0, o = !0) { re = t, Ot(t, s, n, o); }, applyFeedbackStyles({ button: t = "", view: s = "" }) { globalThis.UserLeap.feedbackCustomStyles = s, document.getElementById("sprig-feedback-style") && ue({ document, elementId: "ul-custom-style", styleString: t, nonce: globalThis.UserLeap.styleNonce }), i(document.querySelector(".ul-container-feedback"), s); }, applyStyles(t) { globalThis.UserLeap.customStyles = t, i(globalThis.UserLeap.container, t); }, setWindowDimensions(t, s) { var y, f; const n = typeof t == "string" ? parseInt(t, 10) : t, o = typeof s == "string" ? parseInt(s, 10) : s; isNaN(n) || isNaN(o) || (globalThis.UserLeap.windowDimensions = { width: n, height: o }); const l = C(globalThis.UserLeap), c = Le(l), d = l["userleap-platform"] === "web"; if (!globalThis.UserLeap.frameId) return; const p = document.getElementById(globalThis.UserLeap.frameId); p && (globalThis.UserLeap.useMobileStyling && ((y = globalThis.UserLeap.windowDimensions) != null && y.width && (p.style.width = `${globalThis.UserLeap.windowDimensions.width}px`), (f = globalThis.UserLeap.windowDimensions) != null && f.height && (p.style.maxHeight = globalThis.UserLeap.windowDimensions.height - 20 + "px"), p.contentDocument && (p.style.height = String(Jt(p.contentDocument, d && !c, gt(l))[0]) + "px")), g.emit(u.SurveyDimensions, { name: u.SurveyDimensions, contentFrameWidth: p.clientWidth, contentFrameHeight: p.clientHeight, "survey.id": parseInt(globalThis.UserLeap.container.dataset.studyId) })); }, logoutUser() { var t; globalThis.UserLeap.debugMode && console.info("[DEBUG] Sprig logout"), M.info("LogOut", { vid: globalThis.UserLeap.visitorId, userId: globalThis.UserLeap.userId }), globalThis.UserLeap.visitorId = null, globalThis.UserLeap.userId = null, globalThis.UserLeap.partnerAnonymousId = null, glob