UNPKG

@sprig-technologies/sprig-browser

Version:

npm package for the sprig web sdk

782 lines 58.9 kB
var It = Object.defineProperty; var kt = (t, e, n) => e in t ? It(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var W = (t, e, n) => kt(t, typeof e != "symbol" ? e + "" : e, n); 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"; const nr = 360, or = "ul-app", sr = "#e6e6e6", ar = "#bd282a", dr = 1030, We = () => { try { return window.parent.Intercom; } catch { return null; } }, Be = [Object.freeze(Object.defineProperty({ __proto__: null, disable: () => { const t = We(); t && (t.ul_wasVisible = !!document.querySelector("iframe.intercom-launcher-frame"), t.ul_wasVisible && t("update", { hide_default_launcher: !0 })); }, enable: () => { const t = We(); t && (t.ul_wasVisible && t("update", { hide_default_launcher: !1 }), delete t.ul_wasVisible); } }, Symbol.toStringTag, { value: "Module" }))]; class Ot { static disable() { Be.forEach((e) => e.disable()); } static enable() { Be.forEach((e) => e.enable()); } } const Ne = "ul-view-sdk-script", Ct = ["ios", "android"], F = "visitors", z = "environments"; async function O(t, e) { var i, o, a; const { shouldDropOnRateLimit: n, ...s } = e; s.headers = Object.assign(P(window.UserLeap), s.headers); const r = await et(t, { ...s, shouldDropOnRateLimit: n }); if (r.ok) { 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"); if (window.UserLeap.userId && c === window.UserLeap.visitorId) { const g = R.getItemObject("sprig.anon.env.vid.map"); g && g[window.UserLeap.envId] === c && (delete g[window.UserLeap.envId], R.setItemObject("sprig.anon.env.vid.map", g)); } 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); } return (a = r.json) != null && a.logMessage && console.warn(`[Sprig] ${r.json.logMessage}`), r; } function x(t, e) { const n = R.getItemObject("userleap.ids"); let s = n[window.UserLeap.envId]; s ? s[t] = e : s = { [t]: e }, n[window.UserLeap.envId] = s, R.setItemObject("userleap.ids", n); } function Re() { return window.previewMode ? "0" : window.UserLeap.visitorId ?? ""; } function A(t, e, n) { const s = [window.UserLeap._API_URL, "sdk", t]; return e && e.forEach((r) => { s.push(r), r === z ? s.push(window.UserLeap.envId) : r === F && s.push(Re()); }), n && s.push(n), s.join("/"); } const X = async (t, e, n) => { var Me, qe, Fe; 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); 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 } }); 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: f, surveyId: u, visitorId: _, replayParams: m, completeUploadHeaders: b, apiUrl: window.UserLeap._API_URL, triggerTimestamp: Date.now(), isStandalone: g.length === 0 }); } if (l) { 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: L, replayParams: J, responseGroupUid: fe, surveyId: ve } = l; await S.replay.initializeReplay({ maxReplayDurationSeconds: 300, maxInflightRequests: window.UserLeap.maxInflightReplayRequests, teardownAfter: !0, apiUrl: window.UserLeap._API_URL, replaySettings: n }), S.replay.tryReplayAction(() => { var ze; 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: _ }); }, "Error in scheduling/capturing replay"); } if (_ == null || !(g != null && g.length)) return q.info("CannotDisplaySurvey", { vid: _ }), { success: !1, message: "[Sprig] no survey found", surveyState: "no survey" }; if (window.UserLeap.container) { q.info("AlreadyDisplayingSurvey"); const L = "[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey"; return console.warn(L), { success: !1, message: L, surveyState: "no survey" }; } if (_ !== window.UserLeap.visitorId && E !== window.UserLeap.visitorId && !window.previewMode) { const L = "Attempted to display survey to a different visitor"; return window.UserLeap.reportError("DisplaySurvey", new Error(L)), { success: !1, message: L, surveyState: "no survey" }; } 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 }); let v, D, k, H, V = document.createElement("div"); const Ce = (L) => { const { "view.version": J } = L; J !== b["x-ul-sdk-version"] && st(), y.removeListener("verify.view.version", Ce); }; y.on("verify.view.version", Ce), window.UserLeap.useMobileStyling = T, rt(b) ? (v = "ul-direct-embeded-frame", D = document.head, k = window, H = !1, (() => { const L = P(window.UserLeap), J = ie(L), fe = window.UserLeap.forceDirectEmbed, ve = L["userleap-platform"] === "web"; return J || fe && ve; })() && (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; const G = { apiURL: window.UserLeap._API_URL, cards: g, configureExitOnOverlayClick: (L) => { y.once(w.CloseSurveyOnOverlayClick, L); }, 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 }; (Fe = window.UserLeap._config) != null && Fe.startingQuestionIdx && (window.UserLeap._config = { ...window.UserLeap._config, startingQuestionIdx: null }); const St = (a ? window.UserLeap.feedbackCustomStyles : window.UserLeap.customStyles) ?? c.customStyles; G.customStyles = St, k && (k.__cfg = G); const ye = window.UserLeap.viewSDKURL ? window.UserLeap.viewSDKURL : G.path, Pe = document.getElementById(Ne); Pe && Pe.remove(); const me = function() { const L = document.createElement("script"); return window.UserLeap.nonce && L.setAttribute("nonce", window.UserLeap.nonce), L.id = Ne, L; }(), Te = () => { window.UserLeap.container && Object.assign(window.UserLeap.container.style, { display: "flex" }); }; if (G.installationMethod === "web-npm" || G.installationMethod === "web-npm-bundled") { const { default: L } = await import("./view-Bml35A_s.js"); L.configure(G), H && window.UserLeap.container && Te(); } else ye && (me.src = ye, H && me.addEventListener("load", () => { window.UserLeap.container && Te(); }), k == null || k.addEventListener("error", (L) => { L.target instanceof HTMLScriptElement && L.target.src === ye && window.UserLeap.reportError("loadFrameScript", new Error("Frame script failed to load")); }, { capture: !0, once: !0 })); D == null || D.appendChild(me); const je = { success: !0, surveyState: "ready", surveyId: u, responseGroupUid: f }; return window.UserLeap.isMobileSDK && r && (je.delay = r), je; }; function ge(t) { var n; if (window.UserLeap.useMobileStyling !== void 0) return window.UserLeap.useMobileStyling; const e = ((n = window.UserLeap.windowDimensions) == null ? void 0 : n.width) ?? document.body.clientWidth; return ie(t) || e > 10 && e < 500; } function ie(t) { return Ct.includes(t["userleap-platform"]); } const De = "ul-frame"; 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); const he = "0px", ot = (t, e, n) => { window.UserLeap.container = document.createElement("div"), window.UserLeap.container.className = "ul-container" + (e ? " ul-container-feedback" : ""), t && (window.UserLeap.container.dataset.studyId = t.toString()); const s = lt(); n && s && !window.UserLeap.useMobileStyling ? s.appendChild(window.UserLeap.container) : document.body.appendChild(window.UserLeap.container); }, st = (t, e) => { var s; Mt(); const n = window.UserLeap.container; if (n) try { (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 } }); } catch (r) { console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} ` + n), r instanceof Error && window.UserLeap.reportError("dismissActiveSurvey", r); } }, at = () => { y.once(w.SurveyWillClose, ({ initiator: t, studyType: e }) => { y.removeAllListeners(w.CloseSurveyOnOverlayClick), st(t, e); }); }, Pt = (t, e, n, s) => { var d, c; 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"; let l; a && (i.framePosition = "center"); let p = !1; 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); else { r.width = "360px", r.maxHeight = window.UserLeap.maxHeight || "66vh"; const g = () => { p = !0, l = { margin: "auto", position: "static" }; }; if (s) a ? g() : l = { position: "relative", height: "300px" }; else switch (i.framePosition) { case "bottomLeft": l = { left: he }; break; case "topLeft": l = { left: he, top: 0 }; break; case "topRight": l = { top: 0 }; break; case "center": g(); } } return p && ((g, f) => { 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; 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); })(i, n), Object.assign(t.style, r, l), p; }, Tt = ({ productConfig: t, useMobileStyling: e, surveyId: n, isFeedback: s }) => { var g, f; const r = De, i = s && t.desktopDisplay === "slider"; ot(n, s, i), jt(); const o = document.createElement("iframe"); o.id = r, o.setAttribute("title", "Sprig User Feedback Dialog"); const a = Pt(o, t, e, s); at(); let l = !1; o.setHeight = (u) => { 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 })); }; let p = !1; o.setWidth = (u) => { 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 })); }, (g = window.UserLeap.container) == null || g.appendChild(o), t && (e ? t.exitOnOverlayClickMobile : t.exitOnOverlayClick) && window.UserLeap.container && (window.UserLeap.container.onclick = () => { y.emit(w.CloseSurveyOnOverlayClick); }), y.emit(w.SurveyLifeCycle, { state: "presented" }), y.emit(w.SurveyPresented, { name: w.SurveyPresented, "survey.id": n }); const d = (f = o.contentWindow) == null ? void 0 : f.document; if (d && (d.open("text/html", "replace"), d.write("<!doctype html><head></head><body></body></html>"), d.close(), !e)) { const u = d.body; u.style.display = "flex", u.style.alignItems = "center"; } const c = d == null ? void 0 : d.head; return { frameId: r, contentWinDocHead: c, contentWindow: o.contentWindow, hasOverlay: a, iframe: o }; }, dt = { [w.SurveyFadingOut]: () => { window.UserLeap.container && Object.assign(window.UserLeap.container.style, { "background-color": "rgba(0,0,0,0)" }); } }, jt = () => { Object.entries(dt).forEach(([t, e]) => { y.on(t, e); }); }, Mt = () => { Object.entries(dt).forEach(([t, e]) => { y.off(t, e); }); }, 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 }) => { const r = t.getElementById(e); if (r) return void (r.textContent = n); const i = t.createElement("style"); s && (i.nonce = s), i.textContent = n, i.id = e, t.head.appendChild(i); }, qt = (t, e) => { const n = e.querySelector(".sprig-question-body"); if (!j(n)) return t; const s = n.scrollHeight; return s < 100 ? t : t - (s - 100); }, Ge = (t, e) => { const n = e.querySelector(t); if (!j(n)) return 0; const s = getComputedStyle(n); return parseFloat(s.paddingLeft) + parseFloat(s.paddingRight) + (parseFloat(s.marginLeft) + parseFloat(s.marginRight)) + (parseFloat(s.borderLeftWidth) + parseFloat(s.borderRightWidth)); }, Ft = (t, e, n) => { const s = t.querySelector(".ul-card__container"), r = t.querySelector(".ul-app"); let i = 600, o = 360, a = 0; if (j(s) && j(r)) { const l = s.querySelector(".ul-card--matrix_grid"), p = !l && e && n; try { p && (r.style.width = "360px"), i = s.clientHeight, i += ((g) => { 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"); let U = 0; 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; })(t); const d = getComputedStyle(s); a = i; const c = parseFloat(d.marginTop) + parseFloat(d.marginBottom); i += c + (parseFloat(d.borderTopWidth) + parseFloat(d.borderBottomWidth)), l && (o = l.scrollWidth, o += Ge(".ul-card__container", t), o += Ge(".sprig-question-body", t)); } finally { p && r.style.removeProperty("width"); } } return [i + 1, o, qt(a, t)]; }, lr = (t) => { const e = t.querySelector(".ul-card__container"); e && (e.scrollTop = 0); }, lt = () => h, K = () => document.getElementById("sprig-feedback-container"), Se = () => document.getElementById("sprig-feedback-loading-animation"), ct = () => !!document.getElementById(De); let Ke = !1, h = null, C = null, Ae = !1, Z = null, B = null; const zt = ["bottom-left", "bottom-right", "center-left", "center-right"], ae = () => { var e; const t = window.UserLeap.container; return ((e = t == null ? void 0 : t.parentElement) == null ? void 0 : e.id) === "sprig-feedback-loading-container"; }, pt = () => document.getElementById("sprig-feedback-error-container"), ut = () => { if (!h) return 0; const t = h == null ? void 0 : h.clientWidth, e = window.getComputedStyle(h); return t + parseInt(e.borderRightWidth || "0") + parseInt(e.borderLeftWidth || "0"); }, de = (t) => { const e = K(); e && (B != null && B.endsWith("right") ? e.style.right = `${t}px` : B != null && B.endsWith("left") && (e.style.left = `${t}px`)); }, be = () => { if (h && (ae() || pt())) { y.off(w.SurveyAppeared, Y), Ie(); const t = ut(); return de(-t), !0; } return !1; }, Y = () => { if (!h || !C) return; const t = Se(); t && t.remove(), h.style.height = "auto", h.style.width = "auto", C.disabled = !1, Ae = !1; }, Ie = () => { if (h && !Se()) { const t = (() => { if (Se()) 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 = ` <div class="ul-loading-spinner"> <div class="first"></div> <div class="second"></div> <div class="third"></div> <div class="fourth"></div> </div> `, e; })(); t && (h.style.height = "300px", h.style.width = "360px", h.appendChild(t)); } }, Je = () => { h && C && (de(0), C.disabled = !0, Ae = !0); }, wt = async (t, e, n) => { const { buttonTheme: s, customStyles: r, eventId: i, placement: o, desktopDisplay: a, feedbackLabel: l, surveyUuid: p, surveyId: d } = t; window.UserLeap.feedbackCustomStyles = void 0; let c = K(); if (c) { if (!e && i === Z) return; c.remove(), y.off(re.SURVEY_FADING_OUT, be); } 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; const [g, f] = o.split("-"); ((m) => { if (K() || !zt.includes(m)) return; const [U, b] = m.split("-"), I = document.createElement("div"); I.id = "sprig-feedback-container", I.classList.add(`sprig-feedback-container-${b}`, `sprig-feedback-container-${U}`), document.body.appendChild(I); })(o), c = K(), C = document.createElement("button"); const u = document.createElement("div"); 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 () => { const m = document.getElementById("sprig-feedback-error-container"); if (ct() || pt()) { if (be()) { 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 }); const b = K(); m && b && (b.remove(), Z = null, h = null); } return; } if (ge(P(window.UserLeap)) || Ae || Je(), e) return h && h.classList.add("sprig-feedback-loading-container-previews"), await X(e), void Y(); const U = await (async (b) => { const I = await O(A("1", [F], "startFeedbackStudy"), { body: JSON.stringify({ surveyUuid: b }), method: "POST" }); return I.ok ? I.json : null; })(p); if (U) y.once(w.SurveyAppeared, Y), X({ ...U, studyType: "feedbackButton" }, n); else if (h) { const b = Ht(); h.appendChild(b), Y(), h.style.height = "300px", h.style.width = "360px"; } }), c == null || c.appendChild(C), y.emit(w.FeedbackButtonLoaded, { name: w.FeedbackButtonLoaded, "survey.id": d }); const { useMobileStyling: E, _config: { border: _ } } = window.UserLeap; if (Ke || E) de(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", _), h = m, Ie(), c == null || c.appendChild(m); const U = ut(); de(-U); } window.UserLeap._config.isOnQuestionsTab && e && !ae() && h && (Je(), Ie(), h && h.classList.add("sprig-feedback-loading-container-previews"), X(e), Y()); }, Ht = () => { const t = document.createElement("div"); 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"> <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>`; const e = document.createElement("h3"); return e.className = "sprig-feedback-error-text", e.innerText = "There was an error while loading the survey", t.appendChild(e), t; }, ke = new class { constructor() { W(this, "_ldData", {}); } getAllLaunchDarklyVariations() { return this._ldData; } setLDFlagsVariations(t) { try { return !(!t || typeof t != "object" || Array.isArray(t)) && (Object.keys(this._ldData).forEach((e) => { delete this._ldData[e]; }), Object.keys(t).forEach((e) => this._ldData[`!launch_darkly_${e}`] = (t[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(ke); const oe = new class { constructor() { W(this, "_optimizelyData", {}); } setOptimizelyExperiment(t, e = !0) { if (!t || typeof t != "object") return !1; const { experiments: n } = t; try { return e && Object.keys(this._optimizelyData).map((s) => { delete this._optimizelyData[s]; }), n && n.map((s) => { const { id: r, variation: i } = s, o = this.transformExperimentId(r); i && typeof i == "string" && (this._optimizelyData[o] = i); }), !0; } catch (s) { return s instanceof Error && window.UserLeap.reportError("setOptimizelyExperiment", s), !1; } } getAllOptimizelyExperiments() { return this._optimizelyData; } getOptimizelyVariationName(t) { return this._optimizelyData[this.transformExperimentId(t)]; } transformExperimentId(t) { return "!optimizely_experiments_" + t; } getAndSetWebOptimizelyExperiments() { var t; try { if (window && window.optimizely && typeof window.optimizely.get == "function") { const e = (t = window.optimizely.get("state")) == null ? void 0 : t.getExperimentStates({ isActive: !0 }); if (e) { const n = Object.keys(e).map((s) => { var r, i; return (r = e[s].variation) != null && r.name ? { id: s, variation: (i = e[s].variation) == null ? void 0 : i.name } : { id: s, variation: "Original" }; }); return this.setOptimizelyExperiment({ experiments: n }, !1), !0; } return !1; } return !1; } catch (e) { return e instanceof Error && window.UserLeap.reportError("getAndSetWebOptimizely", e), !1; } } }(); Object.freeze(oe); class Vt { constructor(e, n) { W(this, "paused"); W(this, "queue"); W(this, "ul"); this.ul = e, this.paused = !1, this.queue = [], this.flush(n); } flush(e) { const n = e.length; if (n) for (let s = 0; s < n; s++) this.push(e[s]); } 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 n = Array.prototype.slice.call(e, 1), s = e[0], r = this.ul[s]; r instanceof Function ? r.apply(this.ul, n) : s && console.warn("[Sprig] (ERR-100) No valid UserLeap action called", s); } } perform(e) { if (this.paused) { let n = () => { }; const s = new Promise(function(r) { n = function() { r(e()); }; }); return this.queue.push(n), s; } return e(); } empty() { this.queue.length = 0; } } let gt, yt; const Ee = (t) => { let e = 0, n = t.firstElementChild; for (; n; ) e += Ee(n), n.shadowRoot && (e += Ee(n.shadowRoot)), n = n.nextElementSibling, e++; return e; }, Qe = () => { gt.report(Ee(document.body)), yt.report(document.documentElement.innerHTML.length); }, _e = (t, e) => { const n = performance.now(); document.hidden ? setTimeout(() => _e(t, e), t) : setTimeout(() => { const s = performance.now() - n; e.report(s / 1e3), setTimeout(() => _e(t, e), t); }, 0); }; let le, ce, pe, ue, Ye, N = {}; const ne = (t, e = 1) => { const { name: n } = t; N[n] = (N[n] || 0) + e; }, mt = (t) => { let e = 1; return t.childNodes.forEach((n) => { e += mt(n); }), e; }, Xe = (t) => { let e = 0; return t.forEach((n) => { e += mt(n); }), e; }, Wt = (t) => { switch (t.type) { case "childList": return ne(le, Xe(t.addedNodes)), void ne(ce, Xe(t.removedNodes)); case "attributes": return void ne(pe); case "characterData": return void ne(ue); } }, Bt = (t) => t.forEach(Wt), Nt = () => { 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 = {}; }, $t = (t = 1e3) => { 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); }, Gt = ({ isWeb: t, reportingIntervalSeconds: e, thresholds: n, postMetrics: s }) => { _t(n, (r, i) => { var o, a; if ((o = S.replay) != null && o.isReplayRecording()) { const l = `Value: ${r} on ${i.metric} violated threshold of ${i.type} ${i.value}`; (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(); } }), xt({ reportingIntervalSeconds: e, postMetrics: s }), t && (((r = 1e3) => { const i = $("sdk_event_queue_latency_seconds"); _e(r, i); })(), ((r = 1e4) => { gt = $("sdk_dom_nodes_count"), yt = $("sdk_page_html_characters"), Qe(), setInterval(Qe, r); })(), $t()); }, Kt = "test", Jt = ["popState", "pushState", "replaceState"]; let Oe, ee; const we = {}, Q = "!email", ft = "pageUrl"; let Le = window.location.href; function te(t) { var a, l; const { pageUrlEvents: e, interactiveEvents: n, dismissOnPageChange: s, platform: r } = window.UserLeap._config; if (r && r !== "web") return; Le !== window.location.href && q.navigation("LocationChange", { from: Le, to: window.location.href }), Le = window.location.href; const i = bt().trackStartUrl, o = i ? String(i) : null; e && Ut(window.location.href), n && (ht(), Qt()), lt() && (() => { if (ae()) return; const p = K(); p && (Et(Z) || (p.remove(), Z = null, h = null)); })(), At.getItem("sprig.isCapturingHeatmap") && ((l = (a = S.replay) == null ? void 0 : a.checkPendingHeatmapsUrl()) == null || l.then((p) => { var d; p && ((d = S.replay) == null || d.uploadReadyPendingCaptures(!0)); })), !ae() && s && o && o !== window.location.href && t && Jt.includes(t.type) && window.UserLeap("dismissActiveSurvey", M.PageChange); } const vt = { capture: !0 }, Qt = () => { const t = window.UserLeap._config.interactiveEvents.filter((n) => it(n, window.location.href)).map((n) => { const { name: s, properties: r } = n, { selector: i, innerText: o } = r; return i ? (a) => { if ($e(a.target)) try { a.target.closest(i) && window.UserLeap("track", s); } catch { } return !1; } : (a) => ($e(a.target) && a.target.innerText === o && window.UserLeap("track", s), !1); }), e = (n) => t.forEach((s) => s(n)); window.UserLeap._config.interactiveEventsHandler = e, window.addEventListener("click", e, vt); }, ht = () => { window.UserLeap._config.interactiveEventsHandler && window.removeEventListener("click", window.UserLeap._config.interactiveEventsHandler, vt), delete window.UserLeap._config.interactiveEventsHandler; }; function bt() { const t = R.getItemObject("userleap.ids"); return t && t[window.UserLeap.envId] || {}; } function Lt() { if (window.previewMode) return; const t = R.getItemObject("sprig.anon.env.vid.map") || {}, e = t[window.UserLeap.envId]; 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 }); } function Ut(t, e, n, s) { var r, i; try { if (t.endsWith("mock_snippet.html")) return; q.info("PageView", { url: t }); const o = (r = document == null ? void 0 : document.querySelector('meta[name="description"]')) == null ? void 0 : r.getAttribute("content"); (i = S.replay) == null || i.RecordPageView({ ...o && { description: o }, url: t, referrer: document.referrer, pageTitle: document.title }); const a = window.UserLeap._config.pageUrlEvents; let l = !1; if (a && a.length) for (let d = 0; d < a.length && (l = it(a[d], t), !l); d++) ; if (!l) return; window.UserLeap.debugMode && console.info("[DEBUG] Sprig trackPageView", t); const p = { url: t }; s && (p.trackPageView = !0), window.UserLeap._queue.push(["track", ft, e, p, n]); } catch (o) { o instanceof Error && (o.stack = t, window.UserLeap.reportError("trackPageView", o)), console.warn("[Sprig] (ERR-428) Failed to track page view", o); } } function Yt() { const t = "Backbone" in window && window.Backbone && window.Backbone.history ? window.Backbone.history : window.history; "pushState" in t && (t.pushState = /* @__PURE__ */ ((e) => function(...n) { const s = e.apply(this, n), r = new Event("pushState"); return window.dispatchEvent(r), te(r), s; })(t.pushState)), "replaceState" in t && (t.replaceState = /* @__PURE__ */ ((e) => function(...n) { const s = e.apply(this, n), r = new Event("replaceState"); return window.dispatchEvent(r), te(r), s; })(t.replaceState)), ["hashchange", "popstate"].forEach((e) => window.addEventListener(e, te, !0)); } async function Ue(t, e) { const n = Re(); t && !e && (window.UserLeap._config.mode = Kt); const s = ge(P(window.UserLeap)), r = await O(function(i) { const o = new URL(A("1", [z], "questions")); return Object.entries(i || {}).forEach(([a, l]) => { l && o.searchParams.append(a, String(l)); }), o.toString(); }({ 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 }); 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" }; if (r.json.delay && await nt(r.json.delay), !r.json.isFeedback) return X(r.json, ee, Oe); { const { feedbackLabel: i, productConfig: o, surveyUuid: a, feedbackCustomStyles: l } = r.json, { buttonTheme: p, placement: d, desktopDisplay: c } = o; wt({ customStyles: l, buttonTheme: p, desktopDisplay: c, eventId: 0, feedbackLabel: i, placement: d, surveyUuid: a, surveyId: t == null ? void 0 : t.surveyId }, r.json); } } function Xt(t) { if (!t) return; window.UserLeap._config = t, t.mute && window.UserLeap._queue.pause(); const { interactiveEvents: e, pageUrlEvents: n, dismissOnPageChange: s } = t; e && function(r) { let i = r.length; for (; i; ) { const o = Math.floor(Math.random() * i); i -= 1; const a = r[i]; r[i] = r[o], r[o] = a; } }(e), (e || n || s) && (Yt(), te()); } const Zt = function(t) { if (!window.UserLeap) return; const e = async (r = {}) => { var m, U, b, I, T; const { userId: i, anonymousId: o, metadata: a = {}, properties: l, showSurveyCallback: p } = r; let { eventName: d } = r; if (window.UserLeap.debugMode && d !== ft && console.info("[DEBUG] Sprig track", r), t.mode === "test") return; const c = R.getItem("sprig.previewKey") ?? void 0; if (t.requireUserIdForTracking && !window.UserLeap.userId && !i) { const v = "[Sprig] - Skipping tracking without userId"; return console.warn(v), { success: !1, message: v, surveyState: "no survey" }; } if (!d || d.trim().length === 0) { d = d ? String(d) : ""; const v = "[Sprig] - Invalid event name " + d; return console.warn(v), { success: !1, message: v, surveyState: "no survey" }; } const g = ee ?? window.location.href; 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 }); 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 }); if (!f.ok) { const v = "[Sprig] (ERR-421) Failed to track event"; 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" }; } i && x("uid", i), o && x("aid", o); const u = f.json; u.invalidPreviewKey && R.removeItem("sprig.previewKey"); const E = a.trackPageView ? a.url : void 0; return u != null && u.feedbackButton && wt(u.feedbackButton, void 0, E), await async function(v, D) { var H, V; let k = !0; 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); }(f, p) ? function(v) { if (!window.UserLeap._config.dismissOnPageChange) return !0; const D = new URL(v), k = new URL(ee ?? window.location.href); return D.hostname === k.hostname && D.pathname === k.pathname; }(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" }; }, n = (r, i) => { var a; const o = (a = r == null ? void 0 : r.querySelector(`[id="${De}"]`)) == null ? void 0 : a.contentDocument; o && se({ document: o, elementId: "ul-custom-style", styleString: i }); }, 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) { window.UserLeap("dismissActiveSurvey", M.Override), Ue({ surveyTemplateId: r }, !1); }, _reviewSurvey(r) { window.UserLeap("dismissActiveSurvey", M.Override), Ue({ surveyId: r }, !1); }, previewSurvey(r) { s._previewSurvey(r); }, reviewSurvey(r) { s._reviewSurvey(r); }, mute() { window.UserLeap._queue.pause(); }, unmute() { window.UserLeap._queue.unpause(); }, setVisitorToken() { console.warn("[Sprig] setVisitorToken is deprecated."); }, dismissActiveSurvey(r = M.API) { 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) })); }, async setAttribute(r, i) { if (!r || !i && i !== 0 && i !== !1) { const o = "[Sprig] - Disregarding empty attribute / value provided"; return console.warn(o), { success: !1, message: o }; } return this.setAttributes({ [r]: i }); }, async setAttributes(r) { if (r == null || Object.keys(r).length === 0) { const i = "[Sprig] - Disregarding empty attributes provided"; return console.warn(i), { success: !1, message: i }; } return this.identifyAndSetAttributes({ attributes: r }); }, async identifyAndSetAttributes(r) { if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig identifyAndSetAttributes", r), t.mode === "test") return; if (r === null || typeof r != "object" || !(r.userId || r.anonymousId || r.attributes)) { const d = "[Sprig] - Disregarding empty payload provided"; return console.warn(d), { success: !1, message: d }; } const { userId: i, anonymousId: o, attributes: a } = r; if (t.requireUserIdForTracking && !window.UserLeap.userId && !i) { const d = "[Sprig] - Skipping tracking without userId"; return console.warn(d), { success: !1, message: d }; } if (a) { a.email && !a[Q] && (a[Q] = a.email, delete a.email); const d = Object.keys(a); for (const c of d) a[c] === we[c] && delete a[c]; } if (!(a && Object.keys(a).length !== 0 || i && window.UserLeap.userId !== i || o && window.UserLeap.partnerAnonymousId !== o)) return { success: !0 }; const l = {}; let p; 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 }; }, async removeAttributes(r) { if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig removeAttributes", r), t.mode === "test") return; if (r == null || r.length === 0) { const o = "[Sprig] - Disregarding empty attributes provided"; return console.warn(o), { success: !1, message: o }; } if (t.requireUserIdForTracking && !window.UserLeap.userId) { const o = "[Sprig] - Skipping tracking without userId"; return console.warn(o), { success: !1, message: o }; } const i = await O(A("1", [z, F], "attributes"), { body: JSON.stringify({ delete: r }), method: "DELETE" }); 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 }; }, async addSurveyListener(r) { y.on(w.SurveyLifeCycle, r); }, async removeSurveyListener(r) { y.removeListener(w.SurveyLifeCycle, r); }, async addListener(r, i) { y.on(r, i); }, async removeListener(r, i) { y.removeListener(r, i); }, async removeAllListeners() { y.removeAllListeners(); }, setPreviewKey(r) { r && typeof r == "string" && R.isStorageAvailable && r && R.setItem("sprig.previewKey", r); }, async setUserId(r) { var a; if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig setUserId", r), r == null) { const l = `[Sprig] - Invalid userId ${r}`; return console.warn(l), { success: !1, message: l }; } if (t.mode === "test" || r === window.UserLeap.userId) return; window.UserLeap.userId = r; const i = window.UserLeap.visitorId, o = await O(A("1", [z, F]), { body: JSON.stringify({ userId: r }), method: "PUT" }); 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)); }, async setPartnerAnonymousId(r) { if (window.UserLeap.debugMode && console.info("[DEBUG] Sprig setPartnerAnonymousId", r), r == null) { const i = `[Sprig] - Invalid partnerAnonymousId ${r}`; return console.warn(i), { success: !1, message: i }; } return window.UserLeap.partnerAnonymousId = r, x("aid", r), { success: !0 }; }, 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) { ee = r, Ut(r, i, o, a); }, applyFeedbackStyles({ button: r = "", view: i = "" }) { 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); }, applyStyles(r) { window.UserLeap.customStyles = r, n(window.UserLeap.container, r); }, setWindowDimensions(r, i) { var g, f; const o = typeof r == "string" ? parseInt(r, 10) : r, a = typeof i == "string" ? parseInt(i, 10) : i; isNaN(o) || isNaN(a) || (window.UserLeap.windowDimensions = { width: o, height: a }); const l = P(window.UserLeap), p = ge(l), d = l["userleap-platform"] === "web"; if (!window.UserLeap.frameId) return; const c = document.getElementById(window.UserLeap.frameId); 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) })); }, logoutUser() { var r; 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(); }, teardown() { ["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; }, integrateOptimizely(r, i = !0) { var o, a; if ((a = (o = window.UserLeap) == null ? void 0 : o._config) != null && a.optimizelyEnabled) try { const l = typeof r == "string" ? JSON.parse(r) : r; oe.setOptimizelyExperiment(l, i); } catch (l) { console.warn("[Sprig] Error with integrating Optimizely data"), l instanceof Error && window.UserLeap.reportError("integrateOptimizely", l); } else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product."); }, integrateOptimizelyClient(r) { var i, o; 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."); r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event", ({ experiment: a, variation: l }) => { const p = { experiments: [{ id: a.id, variation: l.key }] }; window.UserLeap("integrateOptimizely", p, !1); }); }, importLaunchDarklyData(r) { var i, o; (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."); }, setVisitorAttribute: (r, i) => (console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"), s.setAttribute(r, i)), setEmail: async (r) => s.setAttribute(Q, r), set