async function lt(o) { const t = await fetch(o, { method: "GET" }); if (!t.ok) throw new Error(`Request returned with status ${t.status}: ${t.statusText}`); return t.json(); } async function ct(o, t) { return await fetch(o, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(t) }); } async function ut(o, t) { return await fetch(o, { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(t) }); } const ht = { GetAsync: lt, PostAsync: ct, PutAsync: ut }; let dt = class { #t = !1; #e = null; #i = !1; #s = /([.]*[^.]+\.(co\.uk|com|net|biz|org|co\.nz|info|jp|edu|mx|com\.br|es|ca|pro|co|au|de|com\.au|fr|eu|com\.ar|us|cl|io|store|tv|fashion|world|coop|at|ch|myshopify\.com|it|fi|sk|cz|pl|ie|com\\.mx)$)|(^localhost$)/gi; #o = !0; constructor(t) { this.#o = t !== void 0 ? t : this.#o; } IsValidCookieDomain() { if (!this.#t) { if (window.location.hostname.toLowerCase() === "localhost") this.#i = !0; else { const t = window.location.host.match(this.#s); t && (t[0].indexOf(".") !== 0 ? this.#e = "." + t[0] : this.#e = t[0]); } this.#t = !0; } return this.#e !== null || this.#i; } GetCookieDomain() { return this.IsValidCookieDomain() ? this.#e : window.location.host; } GetCookie(t) { if (t = t.trim(), document.cookie.length > 0) { const e = document.cookie.indexOf(t + "="); if (e !== -1) { const i = e + t.length + 1; let s = document.cookie.indexOf(";", i); return s === -1 && (s = document.cookie.length), decodeURIComponent(document.cookie.substring(i, s)); } } return ""; } SetCookie(t, e, i, s, n, r) { const a = [t.trim() + "=" + encodeURIComponent(e)]; i && a.push("expires=" + i.toUTCString()), s && a.push("domain=" + s), n && a.push("path=" + n); const c = window.location.protocol === "https:"; (this.#o && c || !this.#o && r) && a.push("secure"); const h = a.join("; "); document.cookie = h; } DeleteCookie(t, e, i, s) { this.SetCookie(t, "deleted", new Date(1970, 1, 1, 0, 0, 0), e, i, s); } AreCookiesEnabled() { const t = /* @__PURE__ */ new Date(); t.setSeconds(t.getSeconds() + 180), this.SetCookie("checkCookies", "enabled", t, void 0, "/", void 0); const e = this.GetCookie("checkCookies") === "enabled"; return e && this.DeleteCookie("checkCookies", void 0, "/", void 0), e; } }, pt = class { constructor() { this.#t = [], this.#e = document, this.#i = null, this.#s = [], this.#o = [], this.focusableSelector = [ "a[href]", "button", "textarea", "input", "select", '[tabindex]:not([tabindex="-1"])' ].join(","); } #t; #e; #i; #s; #o; #n(t) { if (t.target && (t.target instanceof HTMLInputElement || t.target instanceof HTMLSelectElement || t.target instanceof HTMLTextAreaElement || t.target instanceof HTMLButtonElement || t.target instanceof HTMLElement)) { this.#t.push(t.target); return; } const e = t.target; if (e) { this.#t.push(e); return; } } Initialize(t) { t && (this.#e = t), this.#t = [], this.#i && this.#e.removeEventListener("focusin", this.#i), this.#i = (e) => this.#n(e), this.#e.addEventListener("focusin", this.#i), this.#e.activeElement && (this.#e.activeElement instanceof HTMLInputElement || this.#e.activeElement instanceof HTMLSelectElement || this.#e.activeElement instanceof HTMLTextAreaElement || this.#e.activeElement instanceof HTMLButtonElement || this.#e.activeElement instanceof HTMLElement) && this.#t.push(this.#e.activeElement); } #a(t) { for (; this.#t.length > 0; ) { const e = this.#t.pop(); if (e && !t.contains(e) && !(t.shadowRoot && t.shadowRoot.contains(e))) { this.#t.push(e); return; } } } ReturnFocus(t) { for (t && this.#a(t); this.#t.length > 0; ) { const e = this.#t.pop(); if (e && e.parentNode && (!e.checkVisibility || e.checkVisibility())) { e.focus(); return; } } this.#e.body.focus(); } CollectFocusableElements(t, e, i) { const s = Array.from(t.childNodes), n = t; n && n.shadowRoot && this.CollectFocusableElements(n.shadowRoot, e, i); for (const r of s) if (r.nodeType === Node.ELEMENT_NODE) { const a = r; a && (a.matches && a.matches(e) && i.push(a), this.CollectFocusableElements(a, e, i)); } return i; } DrillFocus(t) { return t.activeElement ? t.activeElement.shadowRoot?.activeElement ? this.DrillFocus(t.activeElement.shadowRoot) : t.activeElement : null; } TrapFocus(t) { this.#s.push(t); const e = this.CollectFocusableElements(t, this.focusableSelector, []), i = e[0], s = e[e.length - 1], n = (r) => { const a = r; if (a.key !== "Tab") return; const c = this.DrillFocus(this.#e); a.key === "Tab" && (a.shiftKey ? c === i && (r.preventDefault(), s.focus()) : c === s && (r.preventDefault(), i.focus())); }; this.#o.push(n), t.addEventListener("keydown", n), t.shadowRoot && t.shadowRoot.addEventListener("keydown", n); } UntrapFocus(t) { for (let e = 0; e < this.#s.length; e++) if (this.#s[e] === t) { this.#s[e].removeEventListener("keydown", this.#o[e]), this.#s[e].shadowRoot && this.#s[e].shadowRoot?.removeEventListener("keydown", this.#o[e]), this.#s = this.#s.splice(e, 1), this.#o = this.#o.splice(e, 1); return; } } }; function gt(o) { return o.pageY - window.scrollY; } function mt(o) { return o.pageX - window.scrollX; } function ft(o) { document.addEventListener("mousemove", o); } function yt(o) { document.addEventListener("mouseout", o); } function wt(o) { document.removeEventListener("mousemove", o); } function Ct(o) { document.removeEventListener("mouseout", o); } const St = { GetMouseEventX: mt, GetMouseEventY: gt, AddMouseMoveListener: ft, AddMouseOutListener: yt, RemoveMouseMoveListener: wt, RemoveMouseOutListener: Ct }; function bt() { return navigator.userAgent; } const vt = { GetUserAgent: bt }; function P() { return window.Window1sc ? window.Window1sc : window; } function kt() { return P().location.href; } function Et() { const o = P(); return o.innerWidth ? o.innerWidth : document.documentElement.clientWidth; } function Pt() { const o = P(); return o.innerHeight ? o.innerHeight : document.documentElement.clientHeight; } function xt() { return P().history.length; } function Tt() { return P().location; } const k = { GetPageUrl: kt, GetVisibleWidth: Et, GetVisibleHeight: Pt, GetHistoryLength: xt, GetLocation: Tt }, j = "ltk-osc-session-depth", K = "ltk-osc-source"; function It(o) { window.localStorage.setItem(K, o ? "E" : "S"); } function Dt() { return window.localStorage.getItem(K); } function _(o, t) { window.localStorage.setItem(j, o + "-" + t); } function Z() { const o = window.localStorage.getItem(j); if (o) { const t = o.split("-", 2); return { CurrentDepth: parseInt(t[0]) || 1, HistoryLength: parseInt(t[1]) || null }; } return { CurrentDepth: 1, HistoryLength: null }; } function Ut() { const o = k.GetHistoryLength(), t = Z(); t.HistoryLength !== null && t.HistoryLength < o ? _(t.CurrentDepth + 1, o) : _(t.CurrentDepth, o); } function $t() { return Z().CurrentDepth; } const A = { InitializeSessionDepth: Ut, GetSessionDepth: $t, StoreIsFromListrak: It, GetIsFromListrak: Dt }, Rt = "trk_msg", At = "trk_channel"; function F(o) { return new URLSearchParams(k.GetLocation().search).get(o); } function Ft(o) { return o.test(k.GetLocation().search.toLowerCase()); } function Mt() { F(At) === "sms" ? A.StoreIsFromListrak(!1) : F(Rt) !== null && A.StoreIsFromListrak(!0); } const Bt = { GetString: F, InitializeQueryStrings: Mt, RegexMatchQueryString: Ft }; function Lt() { return Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight ); } function Gt() { return document.referrer; } const X = { GetTotalHeight: Lt, GetReferrer: Gt }, Ot = 769, M = { Desktop: "Desktop", Mobile: "Mobile" }; function Nt() { return k.GetVisibleWidth() < Ot ? M.Mobile : M.Desktop; } const Wt = { Types: M, GetType: Nt }; function _t() { const o = X.GetTotalHeight() - k.GetVisibleHeight(); return window.scrollY / o; } function Ht() { return window.scrollY; } function zt(o) { window.addEventListener("scroll", o); } function Vt(o) { window.removeEventListener("scroll", o); } const Jt = { GetDepthFraction: _t, GetDepthPixels: Ht, AddScrollListener: zt, RemoveScrollListener: Vt }, v = { Http: ht, Mouse: St, QueryString: Bt, Window: k, Document: X, Scroll: Jt, Device: Wt, Cookie: new dt(), Focus: new pt(), Session: A, Navigator: vt }; function Qt(o, t) { return new Promise((e, i) => { const s = (t || document).createElement("img"); s.height = 1, s.width = 1, s.src = o, s.onerror = function(n) { i(n); }, s.onload = function(n) { e(n); }; }); } const qt = { TriggerAsync: Qt }; let jt = class { static GenerateUuid() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) { const e = Math.random() * 16 | 0; return (t === "x" ? e : e & 3 | 8).toString(16); }).toUpperCase(); } }, Kt = class { #t; #e; constructor(t, e) { this.#t = `https://${t}/EX.ashx`, this.#e = e; } async SubmitException(t, e) { if (t == null) return; const i = new URL(this.#t); i.searchParams.append("ctid", this.#e), i.searchParams.append("uid", jt.GenerateUuid()), i.searchParams.append("n", encodeURIComponent(t.name)), i.searchParams.append("m", encodeURIComponent(t.message)), i.searchParams.append("i", encodeURIComponent(e)), i.searchParams.append("h", encodeURIComponent(document.location.href)), await qt.TriggerAsync(i.toString(), document); } }, Y; function Zt(o, t) { Y.SubmitException(o, t); } function Xt(o, t) { Y = new Kt(o, t); } class Yt { #t; constructor(t, e, i) { this.#t = t, e && (this.PopupFlow = e), this.OnsiteContent = i; } OscInit() { this.#t.Init(); } } class te { constructor(t) { this._serviceMediator = t; } // eslint-disable-next-line @typescript-eslint/naming-convention submitException(t, e) { Zt(t, e); } } let ee = class { #t; constructor(t) { this.#t = t; } get #e() { return `offers-${this.#t}`; } get #i() { const t = window.localStorage.getItem(this.#e); if (t === null) return []; const e = JSON.parse(t); return this.#s(e.map(({ Code: i, Expiration: s, Uid: n }) => ({ Code: i, Expiration: new Date(s), Uid: n }))); } get HasOffers() { return this.#i.length > 0; } Cache(t) { const e = this.#i; e.push(t); const i = e.map(({ Code: s, Expiration: n, Uid: r }) => ({ Code: s, Expiration: n.toISOString(), Uid: r })); window.localStorage.setItem( this.#e, JSON.stringify(i) ); } GetCachedOffers() { return this.#i; } Clear() { window.localStorage.removeItem(this.#e); } Dispense(t) { return this.#i.length === 0 ? null : t !== void 0 ? this.#i.find((e) => e.Uid === t) ?? null : this.#i[this.#i.length - 1]; } #s(t) { const e = (/* @__PURE__ */ new Date()).getTime(); return t.filter((i) => i.Expiration.getTime() > e); } }; class ie { #t; #e; constructor(t, e, i, s, n, r) { this.Features = t, this.#t = i, this.#e = e, this.PopupFlow = s, this.Popup = n, this.Subscription = r; } Init() { this.Reload(), this.#i(); } Reload() { this.#t.Session.InitializeSessionDepth(), this.#t.QueryString.InitializeQueryStrings(), this.Features.EnablePopupFlow && this.PopupFlow.Init(); } #i() { const t = new ee(this.#e); document.addEventListener("ltkCheckout", () => t.Clear()), this.Features.EnablePopupFlow && this.#t.Focus.Initialize(); } } let se = class { #t = "ltk-subscribed"; #e = 120; #i; constructor(t) { this.#i = t; } IsSubscribedToList(t) { return this.#i.Cookie.GetCookie(this.#t).split(",").includes(t); } AddList(t, e) { const i = e ?? this.#i.Cookie.GetCookieDomain(), s = this.#i.Cookie.GetCookie(this.#t)?.split(",") ?? []; i && !s.includes(t) && this.#i.Cookie.SetCookie(this.#t, [...s, t].join(","), this.#s(), i, "/"); } RemoveList(t, e) { const i = e ?? this.#i.Cookie.GetCookieDomain(), s = this.#i.Cookie.GetCookie(this.#t)?.split(",") ?? [], n = s.indexOf(t); i && n !== -1 && (s.splice(n, 1), s.length <= 0 ? this.DeleteCookie(i) : this.#i.Cookie.SetCookie(this.#t, s.join(","), this.#s(), i, "/")); } DeleteCookie(t) { const e = t ?? this.#i.Cookie.GetCookieDomain(); e && this.#i.Cookie.DeleteCookie(this.#t, e, "/"); } #s() { const t = /* @__PURE__ */ new Date(); return t.setMonth((/* @__PURE__ */ new Date()).getMonth() + this.#e), t; } }, oe = class { #t = "ltk-subscribed-channel-"; #e; #i = 120; #s; #o = JSON.stringify({ Email: !1, Sms: !1 }); constructor(t, e) { this.#s = t, this.#e = `${this.#t}${e}`; } SetEmailSubscribedChannel(t) { const e = JSON.parse(this.#s.Cookie.GetCookie(this.#e) || this.#o); this.#n({ Email: !0, Sms: e.Sms }, t); } SetSmsSubscribedChannel(t) { const e = JSON.parse(this.#s.Cookie.GetCookie(this.#e) || this.#o); this.#n({ Email: e.Email, Sms: !0 }, t); } #n(t, e) { const i = e ?? this.#s.Cookie.GetCookieDomain(); this.#s.Cookie.SetCookie(this.#e, JSON.stringify(t), this.#a(), i, "/"); } #a() { const t = /* @__PURE__ */ new Date(); return t.setMonth((/* @__PURE__ */ new Date()).getMonth() + this.#i), t; } }, ne = class { #t = "ltk-subscribed-email-"; #e; #i = 120; #s; constructor(t, e) { this.#s = t, this.#e = `${this.#t}${e}`; } SetEmail(t, e) { const i = e ?? this.#s.Cookie.GetCookieDomain(); this.#s.Cookie.SetCookie(this.#e, JSON.stringify(t), this.#o(), i, "/"); } #o() { const t = /* @__PURE__ */ new Date(); return t.setMonth((/* @__PURE__ */ new Date()).getMonth() + this.#i), t; } }; class H { static IsValidEmail(t) { const e = [ "user@example.com", "email@example.com", "customer@example.com", "user@domain.com", "email@domain.com", "customer@domain.com" ], i = /^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; return !e.includes(t) && i.test(t); } static IsValidSMSNumber(t) { return t !== null && /^1?[0-9]{10}$/.test(t.replace(/\D/g, "")); } } function re(o, t) { return new Promise((e, i) => { const s = (t || document).createElement("img"); s.height = 1, s.width = 1, s.src = o, s.onerror = function(n) { i(n); }, s.onload = function(n) { e(n); }; }); } const ae = { TriggerAsync: re }; let le = class { static GenerateUuid() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) { const e = Math.random() * 16 | 0; return (t === "x" ? e : e & 3 | 8).toString(16); }).toUpperCase(); } }, ce; function ue(o, t) { ce.SubmitException(o, t); } let he = class { #t; #e; #i; #s; #o; #n; #a; #l; #r = "Subscription.SubscriptionSubmit"; constructor(t, e, i, s, n, r) { this.#t = t.MerchantTrackingId, this.#e = t.DefaultBaseUrl, this.#i = t.SessionCookieName, this.#s = e, this.#o = i, this.#n = s, this.#a = n, this.#l = r; } async SubmitSubscribeDataAsync(t) { const e = this.#c(t); await this.TriggerSubmissionRequest(e), t.List && t.SubscribeType === "s" ? (this.#s.AddList(t.List), t.SubscribeChannel === "Email" ? (this.#o.SetEmailSubscribedChannel(), this.#n.SetEmail(t.Identifier)) : t.SubscribeChannel === "SMS" && this.#o.SetSmsSubscribedChannel()) : t.List && t.SubscribeType === "u" && this.#s.RemoveList(t.List), this.#h(t.Identifier, t.SubscribeChannel), t.ResetSubscribeState; } async TriggerSubmissionRequest(t) { try { await ae.TriggerAsync(t, this.#l); } catch (e) { ue(e, this.#r); } } // #Reset () { // todo: reset subscriber state // } #c(t) { const e = [ this.#u("ctid", this.#t), this.#u("gsid", this.#i ? this.#a.Cookie.GetCookie(this.#i) : null), this.#u("uid", le.GenerateUuid()), this.#u("_t_0", t.SubscribeType.valueOf()), this.#u("e_0", t.Identifier), this.#u("u_0", t.UpdatedIdentifier), this.#u("l_0", t.List), this.#u("s_0", t.Settings), this.#u("m_0", t.ModalUID), ...this.#d(t.ProfileItems) ]; return "//" + this.#e + "/S.ashx?" + e.filter((i) => i?.split("=")[1]?.length > 0).join("&"); } #d(t) { const e = []; return t.reduce((i, s) => (s.AttributeId != null && s.AttributeValue != null && i.push(encodeURIComponent(s.AttributeId) + "_0=" + encodeURIComponent(s.AttributeValue)), i), e); } #u(t, e) { return e == null ? "" : t + "=" + encodeURIComponent(e); } // #FireCustomEvent (event: string, list: string, Identifier: string, profile: Array) { // todo: implement CustomEvent // } #h(t, e) { switch (e) { case "Email": { if (H.IsValidEmail(t)) { const i = new CustomEvent("onEmailSubscribe", { detail: { email: t } }); this.#l.dispatchEvent(i); } break; } case "SMS": { if (H.IsValidSMSNumber(t)) { const i = new CustomEvent("onSmsSubscribe", { detail: { phone: t } }); this.#l.dispatchEvent(i); } break; } } } }; function de(o, t) { return new Promise((e, i) => { const s = (t || document).createElement("img"); s.height = 1, s.width = 1, s.src = o, s.onerror = function(n) { i(n); }, s.onload = function(n) { e(n); }; }); } const pe = { TriggerAsync: de }; class ge { static GenerateUuid() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) { const e = Math.random() * 16 | 0; return (t === "x" ? e : e & 3 | 8).toString(16); }).toUpperCase(); } } class me { #t; #e; constructor(t, e) { this.#t = `https://${t}/EX.ashx`, this.#e = e; } async SubmitException(t, e) { if (t == null) return; const i = new URL(this.#t); i.searchParams.append("ctid", this.#e), i.searchParams.append("uid", ge.GenerateUuid()), i.searchParams.append("n", encodeURIComponent(t.name)), i.searchParams.append("m", encodeURIComponent(t.message)), i.searchParams.append("i", encodeURIComponent(e)), i.searchParams.append("h", encodeURIComponent(document.location.href)), await pe.TriggerAsync(i.toString(), document); } } let tt; function E(o, t) { tt.SubmitException(o, t); } function fe(o, t) { tt = new me(o, t); } let ye = class { constructor(t, e) { this.PopupElementName = "listrak-popup", window.customElements.get(this.PopupElementName) || window.customElements.define(this.PopupElementName, t), this.#t = t, this.#e = [], this.#i = e; } #t; #e; #i; CreatePopup(t) { const e = new this.#t(), i = { ...t, Doc: this.#i }; return e.Configure(i), this.#e.push(e), this.#i.body.appendChild(e), e; } OpenPopup(t) { this.#s(t)?.Open(); } ClosePopup(t) { this.#s(t)?.Close(); } #s(t) { return this.#e.find((i) => i.Uuid === t) || null; } }; const D = { OnOverlayClick: !0, OnEscKey: !1 }; let we = class { constructor() { this.ZIndexCeiling = 2147483647, this.TemplateSelectors = { ScrollContainer: "#ltkpopup-scroll-container", Container: "#ltkpopup-container", ContainerInner: "#ltkpopup-container-inner", Overlay: "#ltkpopup-overlay", Root: "listrak-popup", Inner: "listrak-popup-inner", Slot: "listrak-popup-stage", CloseElems: ["#ltkmodal-close"] }, this.#t = new AbortController(), this.#e = D.OnEscKey, this.#i = D.OnOverlayClick, this.#s = null, this.#o = new DOMParser(), this.#n = "Popup.PopupWrapper", this.#a = "none"; } #t; #e; #i; #s; #o; #n; #a; Configure(t, e, i) { this.#i = t.OnOverlayClick ?? D.OnOverlayClick, this.#e = t.OnEscKey ?? D.OnEscKey, this.#a = i, this.#s = e; } SetStyleSheet(t, e) { if (!this.#s) { const s = new Error("Document not configured in popup wrapper"); throw E(s, this.#n), s; } const i = this.#s.defaultView; if (i) { const s = new i.CSSStyleSheet(); s.replaceSync(this.GetStyleTemplate(e)), t ? t.adoptedStyleSheets.push(s) : (this.#s.adoptedStyleSheets || (this.#s.adoptedStyleSheets = []), this.#s.adoptedStyleSheets.push(s)); } else { const s = new Error("Document view not found"); throw E(s, this.#n), s; } } BindCloseEvents(t, e) { this.#t = new AbortController(); const i = this.TemplateSelectors.CloseElems.join(", "); t.querySelectorAll(i).forEach((s) => { s.addEventListener("click", () => { e.Close(!0, "closeX"), this.#t.abort(); }, { capture: !1, signal: this.#t.signal }); }), this.#i && t.querySelector(this.TemplateSelectors.Overlay)?.addEventListener("click", () => { e.Close(!0, "overlay"), this.#t.abort(); }, { capture: !1, signal: this.#t.signal }), this.#e; } Render(t, e, i) { if (typeof e == "string") this.InsertHtml(t, e, i); else { const { Html: s = "", Js: n = "" } = e; this.InsertHtml(t, s, i), this.InsertJs(t, n); } this.#s?.dispatchEvent(new CustomEvent("ltk-popup-render-complete", { bubbles: !0, composed: !0 })); } InsertHtml(t, e, i) { const s = t.querySelector(`slot[name="${this.TemplateSelectors.Slot}"]`), { HtmlNodes: n, ScriptNodes: r } = this.#l(e); s ? (n.forEach((a) => { s.appendChild(a), a instanceof HTMLElement && a.querySelectorAll("a").forEach((c) => c.addEventListener("click", () => { i.dispatchEvent(new CustomEvent("link-click", { detail: { Link: c.href } })); }, { capture: !1 })); }), r.forEach((a) => this.InsertJs(t, a.textContent ?? ""))) : E(new Error("Failed to find popup wrapper to insert content."), this.#n); } InsertJs(t, e) { if (!this.#s || e.length === 0) return; const i = t.querySelector(`slot[name="${this.TemplateSelectors.Slot}"]`), s = this.#s.createElement("script"); s.innerHTML = e, i?.appendChild(s); } InsertCustomElement(t, e) { t.querySelector(`slot[name="${this.TemplateSelectors.Slot}"]`)?.appendChild(e); } get Html() { if (this.#s) { const t = this.#a !== "none" ? `class="ltk-animated ltk-${this.#a}"` : "", e = this.#s.createElement("template"); return e.innerHTML = ` <${this.TemplateSelectors.Inner} id='ltk-popup-inner'>
`, e; } else { const t = new Error("Document not configured in popup wrapper"); throw E(t, this.#n), t; } } #l(t) { const e = this.#o.parseFromString(t, "text/html"), i = []; return e.body.querySelectorAll("script").forEach((s) => { i.push(s.cloneNode(!0)), s.remove(); }), { HtmlNodes: Array.from(e.body.childNodes), ScriptNodes: i }; } GetStyleTemplate(t) { const e = this.#c(t), i = e.CloseButtonColor, s = e.CloseButtonLocation, n = e.OverlayColor, r = e.OverlayTransparency; return ` ${this.TemplateSelectors.CloseElems[0]} { height: 50px; width: 50px; display: flex; z-index: var(--override-popup-z-index, ${this.ZIndexCeiling}); position: absolute; color: ${i || "black"}; background-color: transparent; outline: none; border: none; justify-content: center; align-items: center; font-weight: bolder; font-size: 16pt; font-family: var(--override-popup-close-btn-font, Arial, Helvetica Neue, Helvetica, sans-serif); cursor: pointer; ${this.#h(s)} } ${this.TemplateSelectors.Inner}, ${this.TemplateSelectors.Root} { --overlay-color: ${n}; --overlay-opacity: ${r}; display: none; } ${this.TemplateSelectors.Inner}[open], ${this.TemplateSelectors.Root}[open] { display: grid; position: fixed; height: 100vh; height: 100dvh; inset: 0; width: 100%; z-index: calc(var(--override-popup-z-index, ${this.ZIndexCeiling}) - 1); } ${this.TemplateSelectors.Overlay} { background-color: var(--overlay-color); display: grid; height: 100vh; height: 100dvh; inset: 0; opacity: var(--overlay-opacity); position: fixed; width: 100%; z-index: calc(var(--override-popup-z-index, ${this.ZIndexCeiling}) - 65); } ${this.TemplateSelectors.Inner}[open] ${this.TemplateSelectors.ScrollContainer} { overflow-x: hidden; overflow-y: auto; display: grid; z-index: calc(var(--override-popup-z-index, ${this.ZIndexCeiling}) - 64); } ${this.TemplateSelectors.Inner}[open] ${this.TemplateSelectors.Container} { ${this.GetContainerStyles(t)} } ${this.TemplateSelectors.ContainerInner} { ${this.GetContainerInnerStyles(t)} } @media (max-width:768px) { ${this.TemplateSelectors.Inner}[open] ${this.TemplateSelectors.Container} { ${t?.Popup ? "max-width: 340px;" : ""} ${t?.Popup?.Shape === "circle" ? "max-height: 340px" : ""} } } @media (max-width:${t?.Container?.MobileBreakpoint}px) { ${this.TemplateSelectors.Inner}[open] ${this.TemplateSelectors.Container} { max-width: ${t?.Container?.MobileMaxWidth}px; } } `; } #r(t, e, i, s) { const n = ["em", "rem", "vh", "vw", "lh", "rlh", "%", "px", "cm", "mm", "Q", "in", "pc", "pt"]; return i != null && (typeof i == "string" && n.some((r) => i.endsWith(r)) && (s = void 0), t += ` ${e}: ${i}${s ?? ""}; `), t; } #c(t) { const e = {}; return t !== null && (e.OverlayColor = t.Overlay?.Color, e.OverlayTransparency = t.Overlay?.Opacity, e.PagePlacement = t.Container?.PagePlacement, e.CloseButtonColor = t.Container?.CloseButtonColor, e.CloseButtonLocation = t.Container?.CloseButtonLocation, e.Shape = t.Popup?.Shape, e.Width = t.Popup?.Width, e.BorderRadius = t.Popup?.BorderRadius, e.Height = t.Popup?.Height, e.BorderStyle = t.Popup?.BorderStyle, e.BorderColor = t.Popup?.BorderColor, e.BorderWidth = t.Container?.BorderWidth, e.BackgroundColor = t.Container?.TransparentBrackground ? "transparent" : t.Container?.BackgroundColor, e.BackgroundImage = t.Popup?.BackgroundImage, e.BackgroundImageRepeat = t.Popup?.BackgroundImageRepeat, e.BackgroundImagePosition = t.Popup?.BackgroundImagePosition, e.BackgroundImageSize = t.Popup?.BackgroundImageSize, e.ContainerWidth = t.Container?.ContainerWidth || void 0), e; } GetContainerStyles(t) { const e = ` position: relative; z-index: var(--override-popup-z-index, ${this.ZIndexCeiling}); display: grid; max-height: 100vh; max-height: 100dvh;`, i = this.#c(t); if (!t) return e + ` place-self: center; width: 600px;`; let s = e + ` box-sizing: border-box; `; return i.Shape === "circle" ? (s = this.#r(s, "border-radius", "50%"), s = this.#r(s, "height", i.Width ? i.Width : 600, "px")) : (s = this.#r(s, "border-radius", i.BorderRadius, "px"), s = this.#r(s, "height", i.Height, "px")), s = this.#r(s, "place-self", i.PagePlacement ? this.#d(i.PagePlacement) : "center"), s = this.#r(s, "width", i.Width ? this.#u(i.Width) : "600px"), s = this.#r(s, "width", i?.ContainerWidth, "px"), s = this.#r(s, "border-style", i.BorderStyle), s = this.#r(s, "border-width", i.BorderWidth, "px"), s = this.#r(s, "border-color", i.BorderColor), s = this.#r(s, "background-color", i.BackgroundColor), s = this.#r(s, "background-image", i.BackgroundImage), s = this.#r(s, "background-repeat", i.BackgroundImageRepeat), i.BackgroundImagePosition !== "" && (s = this.#r(s, "background-position", i.BackgroundImagePosition)), i.BackgroundImageSize !== "" && (s = this.#r(s, "background-size", i.BackgroundImageSize)), s; } GetContainerInnerStyles(t) { const e = this.#c(t); let i = ` display: grid; width: 100%; height: 100%; overscroll-behavior: contain; `; return e.Shape === "circle" ? (i = this.#r(i, "border-radius", "50%"), i = this.#r(i, "overflow-y", "hidden")) : i = this.#r(i, "border-radius", e.BorderRadius, "px"), i = this.#r(i, "place-self", e.PagePlacement ? this.#d(e.PagePlacement) : "center"), i = this.#r(i, "border-style", e.BorderStyle), i = this.#r(i, "border-width", e.BorderWidth, "px"), i = this.#r(i, "border-color", e.BorderColor), i = this.#r(i, "background-color", e.BackgroundColor), i = this.#r(i, "background-image", e.BackgroundImage), i = this.#r(i, "background-repeat", e.BackgroundImageRepeat), e.BackgroundImagePosition !== "" && (i = this.#r(i, "background-position", e.BackgroundImagePosition)), e.BackgroundImageSize !== "" && (i = this.#r(i, "background-size", e.BackgroundImageSize)), i; } #d(t) { switch (t) { case "top-left": return "start start"; case "top-center": return "start center"; case "top-right": return "start end"; case "left": return "center start"; case "center": return "center center"; case "right": return "center end"; case "bottom-left": return "end start"; case "bottom-center": return "end center"; case "bottom-right": return "end end"; default: return "center"; } } #u(t) { return `clamp(340px, ${t}px, 100vw)`; } #h(t) { switch (t) { case "top-left": return "inset: 0px auto auto 0px;"; default: return "inset: 0px 0px auto auto;"; } } }, Ce = class extends HTMLElement { constructor() { super(), this.Uuid = null, this.#t = null, this.#e = !1, this.#i = !0, this.#o = "Popup.PopupElement", this.#n = null, this.#a = "none", this.#l = null, this.#s = new we(); } #t; #e; #i; #s; #o; #n; #a; #l; // note: these callbacks are not capitalized because they are overriding functions exposed by HTMLElement connectedCallback() { this.Init(), this.#r(); } disconnectedCallback() { this.#c(); } adoptedCallback() { } attributeChangedCallback() { } static get observedAttributes() { return []; } get StylesheetBaseSelector() { return this.#i ? ":host" : "listrak-popup"; } Configure(t) { this.Uuid = t.Uuid, this.#t = t.Doc, this.#i = t.UseShadowDom ?? !1, this.#a = t.Animation ?? "none", this.#s.Configure(t.CloseOptions, this.#t, this.#a), this.#n = t.PopupSettings, this.#l = t.Browser ? t.Browser : null; } Init() { if (this.Uuid === null) { const t = new Error("PopupElement not configured"); throw E(t, this.#o), t; } if (this.#i && !this.shadowRoot && this.attachShadow({ mode: "open", delegatesFocus: !0 }), this.Uuid && this.setAttribute("uuid", this.Uuid), this.setAttribute("aria-hidden", "true"), this.#a !== "none") { const t = "ltk-animation-sheet"; if (this.shadowRoot && this.shadowRoot?.getElementById(t) === null || this.shadowRoot === null && this.#t.getElementById(t) === null) { this.style.display = "none"; const e = document.createElement("link"); e.id = t, e.href = "https://cdn.listrakbi.com/css/animate.min.css", e.rel = "stylesheet", e.onload = () => { this.style.removeProperty("display"); }, this.shadowRoot ? this.shadowRoot.appendChild(e) : this.#t.head.appendChild(e); } } this.shadowRoot ? (this.#s.SetStyleSheet(null, this.#n), this.#s.SetStyleSheet(this.shadowRoot, this.#n), this.shadowRoot.appendChild(this.#s.Html.content.cloneNode(!0))) : (this.#s.SetStyleSheet(null, this.#n), this.appendChild(this.#s.Html.content.cloneNode(!0))); } Open() { if (this.setAttribute("open", ""), this.setAttribute("aria-hidden", "false"), this.shadowRoot) { const t = this.shadowRoot.getElementById("ltk-popup-inner"); t && t.setAttribute("open", ""); } else { const t = this.getElementsByTagName("listrak-popup-inner"); t.length && t[0].setAttribute("open", ""); } this.HandleShowContent(), this.#e = !0, this.Focus(); } Focus() { const t = 'input, select, textarea, a[class*="button"], button'; if (this.shadowRoot) { const i = this.#l?.Focus.CollectFocusableElements(this.shadowRoot, t, []); if (i && i.length > 0) { const s = i[0]; s.focus(); const n = setInterval(() => { s.focus(), (!this.#l || this.#l.Focus.DrillFocus(this.#t ?? this.shadowRoot ?? document) === s) && clearInterval(n); }, 100); this.#l?.Focus.TrapFocus(this); return; } } const e = this.#l?.Focus.CollectFocusableElements(this, t, []); e && e.length > 0 && e[0].focus(), this.#l?.Focus.TrapFocus(this); } Cancel() { this.#e = !1, this.removeAttribute("open"), this.setAttribute("aria-hidden", "true"); } Close(t, e) { this.#t?.activeElement && (this.shadowRoot && this.shadowRoot.contains(this.#t?.activeElement) || this.contains(this.#t?.activeElement) || this.#t?.activeElement == this) && this.#l?.Focus.ReturnFocus(this), this.#l?.Focus.UntrapFocus(this), this.#e = !1, this.removeAttribute("open"), this.setAttribute("aria-hidden", "true"), t && this.dispatchEvent(new CustomEvent("popup-close", { detail: { Source: e } })); } Remove() { } InsertContent(t) { if (t) { const e = typeof t == "string" || !Object.prototype.hasOwnProperty.call(t, "Js") ? null : t.Js; let i = typeof t == "string" ? t : t.Html; if (this.#n && this.#n?.Popup?.Shape === "circle") { const n = this.#n?.Popup?.Width ?? 600, r = n / 2, a = Math.round(r * Math.sqrt(2)); i = `
${i}
`; } const s = { Html: i, ...e ? { Js: e } : {} }; this.#s.Render(this.shadowRoot ?? this, s, this); } } HandleShowContent() { this.#s.BindCloseEvents(this.shadowRoot ?? this, this); } #r() { this.dispatchEvent( new CustomEvent( "listrak-popup-connected", { bubbles: !0, detail: { uuid: this.Uuid, isVisible: this.#e } } ) ); } #c() { this.dispatchEvent( new CustomEvent( "listrak-popup-disconnected", { bubbles: !0, detail: { uuid: this.Uuid, isVisible: this.#e } } ) ); } }, Se = class { static Create(t, e) { return fe(t.DefaultBaseUrl, t.MerchantTrackingId), new ye(Ce, e); } }; var l = /* @__PURE__ */ ((o) => (o.Any = "any", o.InitializeFlow = "init-flow", o.SuppressFlow = "suppress-flow", o.Wait = "process-wait", o.ButtonRender = "process-button-render", o.ButtonClick = "process-button-click", o.WaitComplete = "process-wait-complete", o.PreFetch = "process-prefetch", o.ContentRender = "content-render", o.OpenContent = "open-content", o.CloseContent = "close-content", o.Exit = "process-exit", o.SkipWait = "process-skip-wait", o.FormSubmission = "process-form-submission", o.AssignCoupon = "process-assign-coupon", o.PrefetchFont = "prefetch-font", o.LinkClick = "link-click", o.UrlRedirect = "url-redirect", o.RandomSplit = "split-random", o.GoToStep = "go-to-step", o.ConditionSplit = "split-condition", o.SpinClick = "spin-click", o.SpinComplete = "spin-complete", o.ExitAll = "exit-all", o.ExitAllComplete = "exit-all-complete", o))(l || {}); function be(o, t) { return new Promise((e, i) => { const s = (t || document).createElement("img"); s.height = 1, s.width = 1, s.src = o, s.onerror = function(n) { i(n); }, s.onload = function(n) { e(n); }; }); } const ve = { TriggerAsync: be }; class et { static GenerateUuid() { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) { const e = Math.random() * 16 | 0; return (t === "x" ? e : e & 3 | 8).toString(16); }).toUpperCase(); } } class ke { #t; #e; constructor(t, e) { this.#t = `https://${t}/EX.ashx`, this.#e = e; } async SubmitException(t, e) { if (t == null) return; const i = new URL(this.#t); i.searchParams.append("ctid", this.#e), i.searchParams.append("uid", et.GenerateUuid()), i.searchParams.append("n", encodeURIComponent(t.name)), i.searchParams.append("m", encodeURIComponent(t.message)), i.searchParams.append("i", encodeURIComponent(e)), i.searchParams.append("h", encodeURIComponent(document.location.href)), await ve.TriggerAsync(i.toString(), document); } } let it; function u(o, t) { it.SubmitException(o, t); } function Ee(o, t) { it = new ke(o, t); } function Pe(o) { return /^(?:\+?\d{1,3}[\s-]?)?(?:\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4})$/.test(o); } function xe(o) { return /^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/.test(o); } var g = /* @__PURE__ */ ((o) => (o[o.Any = -1] = "Any", o[o.Exit = 0] = "Exit", o[o.ContentRender = 3] = "ContentRender", o[o.ButtonRender = 4] = "ButtonRender", o[o.SuppressFlow = 6] = "SuppressFlow", o[o.WaitTime = 7] = "WaitTime", o[o.WaitClick = 8] = "WaitClick", o[o.WaitScroll = 9] = "WaitScroll", o[o.WaitManual = 10] = "WaitManual", o[o.WaitExit = 11] = "WaitExit", o[o.PrefetchContent = 12] = "PrefetchContent", o[o.WaitAction = 13] = "WaitAction", o[o.Coupon = 14] = "Coupon", o[o.PrefetchFont = 15] = "PrefetchFont", o[o.RandomSplit = 16] = "RandomSplit", o[o.BranchEntry = 17] = "BranchEntry", o[o.BranchExit = 18] = "BranchExit", o[o.ConditionSplit = 19] = "ConditionSplit", o[o.SpinnerRender = 20] = "SpinnerRender", o))(g || {}), y = /* @__PURE__ */ ((o) => (o[o.Request = 0] = "Request", o[o.Wait = 1] = "Wait", o[o.Behavior = 2] = "Behavior", o[o.Render = 3] = "Render", o[o.Exit = 4] = "Exit", o[o.Suppress = 5] = "Suppress", o[o.Split = 6] = "Split", o[o.Branch = 7] = "Branch", o))(y || {}); class m { #t; #e; constructor(t, e) { this.#t = new BroadcastChannel(t), this.#t.addEventListener("message", (i) => this.Read(i)), this.#e = e; } async Read(t) { const e = t.target; if (!(e && (!(e instanceof BroadcastChannel) || e.name !== this.#t.name)) && (await this.#i(l.Any, g.Any, t), t.data.Type)) { const i = t.data.Payload?.Details?.Type; i ? await this.#i(t.data.Type, i, t) : await this.#i(t.data.Type, g.Any, t); } } async #i(t, e, i) { const s = this.#e[t]; s && (typeof s == "function" ? await s(i) : (await s[e]?.(i), e !== g.Any && await s[g.Any]?.(i))); } PostMessage(t) { this.#t.postMessage(t); } } const z = "ltk-popup-flow-caching"; class Te extends m { #t; #e; #i; #s; #o; #n; #a = 2; #l = 3; #r = "PopupFlow.PopupFlowService"; #c = 0; constructor(t, e, i, s, n, r, a) { super(i, { [l.ExitAllComplete]: async () => await this.#d() }), this.#n = t, this.#t = e, this.#e = r, this.#i = a, this.#s = s, this.#o = n; const c = window.localStorage.getItem(z); c && JSON.parse(c) && this.SetCaching(!0); } Init() { this.#c++, this.PostMessage({ Type: l.ExitAll, Payload: {} }); } async #d() { this.#c <= 0 || (this.#c--, this.#c <= 0 && await this.EvaluateRules()); } async EvaluateRules() { try { const t = await this.#t.GetDataAsync(); if (t !== void 0 && t.length > 0) { const e = this.#n.QueryString.GetString("ltkwebcontent"); if (e) { await this.ManualTrigger(e, !1); return; } const i = this.#n.QueryString.GetString("ltkwebcontenttestmode"), s = this.#u(t, i === "1"); s !== void 0 && this.PostMessage({ Type: l.InitializeFlow, Payload: s }); const n = this.#h(t, i === "1"); n !== void 0 && this.PostMessage({ Type: l.InitializeFlow, Payload: n }); } } catch (t) { u(t, this.#r); } } #u(t, e) { return this.#p(t.filter((i) => i.Trigger !== this.#a && i.Trigger !== this.#l && (!i.TargetingRuleSet?.TestMode || e))); } #h(t, e) { return this.#p(t.filter((i) => i.Trigger === this.#l && (!i.TargetingRuleSet?.TestMode || e))); } #p(t) { if (!this.#s.IsDebugEnabled(l.InitializeFlow)) return this.#o.GetWinner(t); const e = this.#o.DebugWinner(t); return console.log("Rule Evaluation:", e), e.find((i) => i.Passes)?.TargetingDefinition || void 0; } EnableDebug() { this.#s.EnableDebug(); } SetCaching(t) { this.#t.SetCaching(t), this.#i.SetCaching(t), this.#e.SetCaching(t), window.localStorage.setItem(z, JSON.stringify(t)); } async ManualTrigger(t, e) { try { const i = await this.#t.GetDataAsync(); if (i !== void 0 && i.length > 0) { const s = i.find((n) => n.Uid === t); if (s !== void 0) { const n = e ? this.#p([s]) : s; n !== void 0 && (this.PostMessage({ Type: l.SkipWait, Payload: n }), this.PostMessage({ Type: l.InitializeFlow, Payload: n })); } else u(new Error("Error manually triggering flow: uid " + t + " not found."), this.#r); } else u(new Error("Error manually triggering flow: targeting data not found."), this.#r); } catch (i) { u(i, this.#r); } } NextStep(t, e) { this.PostMessage({ Type: l.CloseContent, Payload: e }), this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: t } }); } ClosePopup(t, e) { this.PostMessage({ Type: l.CloseContent, Payload: e }), this.PostMessage({ Type: l.Exit, Payload: { Uid: t } }); } } const st = "ltk-popup-content-"; class Ie { #t; #e = !1; #i = null; #s; constructor(t, e, i) { this.#t = t, this.#i = i, this.#s = e; } SetCaching(t) { this.#e = t; } async GetDataAsync(t, e) { const i = st + e; if (this.#e) { const r = window.sessionStorage.getItem(i); if (r) return JSON.parse(r); } const s = `${this.#t}/pf/${t}/${e}.json`, n = await this.#s.Http.GetAsync(s); return window.sessionStorage.setItem(i, JSON.stringify(n)), n; } async AddFonts(t) { if (!this.#i) throw new Error("Document not configured in popup wrapper"); const e = t.Payload?.Details?.Properties?.Fonts, i = Array.from(this.#i.head.getElementsByTagName("link")); e.forEach((s) => { if (!i.some((n) => n.href === s.Url) && s.Url !== null) { const n = document.createElement("link"); n.rel = "stylesheet", n.href = s.Url, this.#i?.head.appendChild(n); } }); } AddAnimationPreload() { const t = "ltk-animation-sheet"; if (!this.#i) throw new Error("Document not configured in popup wrapper"); if (this.#i.getElementById(t) === null) { const e = document.createElement("link"); e.id = t, e.href = "https://cdn.listrakbi.com/css/animate.min.css", e.rel = "preload", e.as = "style", e.onload = () => { e.rel = "stylesheet"; }, this.#i.head.appendChild(e); } } } const De = "ltk-flow-processing-"; class Ue { #t; #e = !1; #i; constructor(t, e) { this.#t = t, this.#i = e; } SetCaching(t) { this.#e = t; } async GetDataAsync(t) { const e = De + t; if (this.#e) { const n = window.sessionStorage.getItem(e); if (n) return JSON.parse(n); } const i = `${this.#t}/pf/${t}/p.json`, s = await this.#i.Http.GetAsync(i); return window.sessionStorage.setItem(e, JSON.stringify(s)), s; } } const V = "ltk-merchant-flow-targeting"; class $e { #t; #e; #i = !1; #s; constructor(t, e, i) { this.#t = t, this.#e = e, this.#s = i; } SetCaching(t) { this.#i = t; } async GetDataAsync() { if (this.#i) { const i = window.sessionStorage.getItem(V); if (i) return JSON.parse(i); } const t = `${this.#t}/pf/${this.#e}/t.json`, e = await this.#s.Http.GetAsync(t); return window.sessionStorage.setItem(V, JSON.stringify(e)), e; } } class Re extends m { #t; #e = {}; #i = {}; #s = {}; #o = "PopupFlow.FlowProcessingService"; constructor(t, e) { super(t, { [l.InitializeFlow]: async (i) => await this.#a(i), [l.WaitComplete]: async (i) => await this.#l(i), [l.SkipWait]: async (i) => await this.#c(i), [l.ButtonClick]: async (i) => await this.#d(i), [l.Exit]: async (i) => await this.#u(i), [l.GoToStep]: async (i) => await this.#p(i), [l.SpinComplete]: async (i) => await this.#p(i), [l.ExitAll]: async () => await this.#h() }), this.#t = e; } #n(t) { t in this.#e && delete this.#e[t], t in this.#s && delete this.#s[t]; } async #a(t) { const e = t.data.Payload.Uid; if (!e) { u(new Error("An error occurred processing the flow: Message sent without uid."), this.#o); return; } const i = this.#e[e]; i && i !== 0 || (this.#e[e] = 0, await this.#r(e)); } async #l(t) { const e = t.data.Payload.Uid; if (!e) { u(new Error("An error occurred processing the flow: Message sent without uid."), this.#o); return; } await this.#r(e); } async #r(t) { let e = this.#i[t]; if (!e) try { e = await this.#t.GetDataAsync(t), this.#i[t] = e; } catch (n) { u(n, this.#o); return; } let i = this.#e[t]; if (!i && i !== 0) return; let s = e[i]; for (; s; ) { if (s?.Details?.Group !== y.Wait || !this.#s[t]) { const r = this.#m(s.Details); s.FlowUid = t, this.PostMessage({ Type: r, Payload: s }); } const n = s; if (s?.Details?.Next) { if (s?.Details?.Next === s?.Details?.Current) break; i = e.findIndex((r) => s?.Details?.Next === r.Guid), this.#e[t] = i, s = e[i]; } else s = void 0; if (n?.Details?.Group === y.Exit) { this.#n(t); break; } else if (n?.Details?.Group === y.Wait) { if (!this.#s[t]) break; this.#s[t] = !1; } } } async #c(t) { const e = t.data.Payload.Uid; if (!e) { u(new Error("An error occurred skipping wait: Message sent without uid."), this.#o); return; } this.#s[e] = !0; } async #d(t) { const e = t.data.Payload.Uid; if (!e) { u(new Error("An error occurred while reading button click. Cannot process flow event without uid."), this.#o); return; } const i = this.#e[e]; if (i && i !== 0) { const s = this.#i[e]; i > 0 && s && s[i - 1] && s[i - 1].Details?.Group === y.Wait && s[i - 1].Details?.Type === g.WaitClick && await this.#r(e); return; } await this.#c(t), await this.#a(t); } async #u(t) { const e = t.data.Payload.Uid; if (!e) { u(new Error("An error occurred exiting: Message sent without uid."), this.#o); return; } this.#n(e); } async #h() { for (const t in this.#e) try { this.PostMessage({ Type: l.Exit, Payload: { Uid: t } }), this.#n(t); } catch (e) { u(e, this.#o); } this.PostMessage({ Type: l.ExitAllComplete, Payload: {} }); } async #p(t) { const e = t.data.Payload.Uid; if (!e) { u(new Error("An error occurred exiting: Message sent without uid."), this.#o); return; } const i = t.data.Payload.StepUid; if (!i) { u(new Error("An error occurred exiting: Message sent without step uid."), this.#o); return; } this.#e[e] = this.#i[e].findIndex((s) => i === s.Guid), await this.#r(e); } #m(t) { switch (t?.Group) { case y.Wait: return t.Type === g.Coupon ? l.AssignCoupon : l.Wait; case y.Suppress: return l.SuppressFlow; case y.Request: return t.Type === g.PrefetchFont ? l.PrefetchFont : l.PreFetch; case y.Render: return t.Type === g.ContentRender || t.Type === g.SpinnerRender ? l.ContentRender : l.ButtonRender; case y.Exit: return l.Exit; case y.Split: return t.Type === g.RandomSplit ? l.RandomSplit : l.ConditionSplit; default: return null; } } } class Ae extends m { #t; #e = "PopupFlow.PrefetchService"; constructor(t, e) { super(t, { [l.PreFetch]: async (i) => await this.#i(i) }), this.#t = e; } async #i(t) { const e = t.data.Payload?.Details?.Properties?.ContentUids; e ? (this.#t.AddAnimationPreload(), e.forEach(async (i) => { try { await this.#t.GetDataAsync(t.data.Payload?.Details?.Properties?.PopupFlowUid, i); } catch (s) { u(s, this.#e); } })) : u(new Error(`Popup content UID for flow ${t.data.Payload.PopupFlowUid} could not be found`), this.#e); } } class Fe extends m { #t; #e = "PopupFlow.PrefetchFontService"; constructor(t, e) { super(t, { [l.PrefetchFont]: async (i) => await this.#i(i) }), this.#t = e; } async #i(t) { if (t.data.Payload?.Details?.Properties?.Fonts) try { await this.#t.AddFonts(t.data); } catch (e) { u(e, this.#e); } else u(new Error(`Popup fonts for flow ${t.data.Payload.PopupFlowUid} could not be found`), this.#e); } } class Me extends m { #t = {}; constructor(t) { super(t, { [l.Wait]: { [g.WaitTime]: async (e) => await this.#e(e) }, [l.Exit]: async (e) => await this.#i(e) }); } #e(t) { const e = t.data.Payload.Details, i = t.data.Payload.FlowUid; this.#s(i); const s = window.setTimeout(() => { this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: i } }); }, e.Properties?.Delay * 1e3); this.#t[i] = s; } #i(t) { const e = t.data.Payload.Uid; this.#s(e); } #s(t) { if (t in this.#t) { const e = this.#t[t]; window.clearTimeout(e), delete this.#t[t]; } } } class Be extends HTMLElement { constructor() { super(), this.Uuid = null, this.#e = null, this.#i = 600, this.#s = 5, this.#o = 3500, this.#n = 2e3, this.#a = !1, this.#t = this.attachShadow({ mode: "open", delegatesFocus: !0 }); } #t; #e; #i; #s; #o; #n; #a; connectedCallback() { this.#r(), window.IntersectionObserver !== void 0 && new IntersectionObserver( (t, e) => { for (const i of t) i.isIntersecting && (this.incentiveContainerWidth && (this.#i = this.incentiveContainerWidth, this.#r()), e.disconnect()); }, { threshold: 0.1 } ).observe(this); } get incentiveContainerWidth() { return this.#t.querySelector(".spinner-popup__container")?.getBoundingClientRect().width; } set options(t) { this.#e = t, this.Uuid = t?.Spinner?.Uuid, this.setAttribute("uuid", this.Uuid); } get options() { return this.#e; } get incentivesMarkup() { return this.#e?.Spinner?.Incentives?.map((t, e) => { const i = this.#e?.Spinner?.Incentives?.length ?? 2, s = 360 / i, n = e * s, r = this.#i, a = i === 2, c = r / 2, h = s / 2, d = a ? r : Math.ceil(2 * c * Math.tan(h * Math.PI / 180)) + 2, p = a ? "none" : "polygon(50% 100%, 0 0, 100% 0)"; return `
${t.Text}
`; }).join(""); } get incentiveFontSize() { const t = this.#e?.Spinner?.Incentives?.length ?? 2; return t < 4 ? "2rem" : t < 7 ? "1.66rem" : "1.3333rem"; } get dynamicStyles() { const t = this.#e?.Spinner, e = t?.Incentives?.length ?? 2, i = 360 / e, s = ((t?.WinnerIndex ?? 0) + 1 + e) % e * i, n = this.#s * 360, r = this.#e?.Container.BackgroundColor; let a = this.#e?.Container?.BorderWidth; return a > 30 && (a = 30), ` .listrak-spinner-popup { display: block; margin: auto; width: 600px; aspect-ratio: 1; position: relative; } .listrak-spinner-popup__container { height: 100%; width: 100%; box-sizing: border-box; border: ${a}px solid ${r}; background-color: ${r}; display: flex; align-items: center; justify-content: center; position: relative; border-radius: 50%; overflow: hidden; } .triangle { width: 0; height: 0; border-left: 20px solid transparent; border-right: 20px solid transparent; left: 0; right: 0; margin: auto; position: absolute; } .triangle.up { border-bottom: 27px solid ${r}; top: -24px; } .triangle.down { border-top: 27px solid ${r}; top: ${(a ?? 1) - 1}px; z-index: 1; } .listrak-spinner-popup__container__incentives { height: 100%; width: 100%; position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto; transform: rotate(${s}deg); } .listrak-spinner-incentive { padding-top: 9.85%; box-sizing: border-box; width: fit-content; height: 50%; position: absolute; top: 0; left: 0; right: 0; margin: auto; transform-origin: bottom; font-family: var(--ltk-font-family); color: var(--ltk-font-color); font-size: ${this.incentiveFontSize}; } .listrak-spinner-incentive::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: var(--ltk-wedge-width); height: 100%; background: var(--ltk-bg-color); clip-path: var(--ltk-clip-path); z-index: -1; } .listrak-spinner-popup__container__inner { display: flex; align-items: center; justify-content: center; width: 307px; height: 307px; position: absolute; top: 0; bottom: 0; right: 0; left: 0; margin: auto; flex-direction: column; gap: 16px; background-color: ${r}; border-radius: 50%; } .listrak-spinner-popup__container__inner__heading { margin: 0; max-width: 224px; text-align: center; font-size: 1.5rem; font-family: ${t?.Heading?.Font.Name}; color: ${t?.Heading?.FontColor}; } .listrak-spinner-popup__container__inner__action-button { line-height: 35px; font-weight: 700; text-align: center; padding: 11px 21px; min-width: 205px; font-size: 24px; font-family: ${t?.ActionButton?.Font.Name}; color: ${t?.ActionButton?.FontColor}; border-radius: ${t?.ActionButton?.BorderRadius}px; background-color: ${t?.ActionButton?.BackgroundColor}; border: none; transition: 85ms ease-in-out; cursor: pointer; } .listrak-spinner-popup__container__inner__action-button:hover { background-color: ${t?.ActionButton?.BackgroundHoverColor}; } .listrak-spinner-popup__container__inner__dismiss { font-size: 21px; background-color: transparent; color: ${t?.Dismiss?.FontColor}; font-family: ${t?.Dismiss?.Font.Name}; border: none; cursor: pointer; text-decoration: underline; } @keyframes spinWheel { from { transform: rotate(${s}deg); } to { transform: rotate(${n}deg); } } .spin { animation: spinWheel ${this.#o}ms cubic-bezier(0.33, 1, 0.68, 1) forwards; } @media only screen and (max-width: ${this.#e?.Container.MobileBreakpoint}px) { .listrak-spinner-popup { transform: scale(0.53) translate(-44%, -246px); } } `; } #l() { const t = this.#t.querySelector(".listrak-spinner-popup__container__inner__action-button"), e = this.#t.querySelector(".listrak-spinner-popup__container__inner__dismiss"), i = this.Uuid; t?.addEventListener("click", () => { if (this.#a) return; this.#a = !0, this.#t.querySelector(".listrak-spinner-popup__container__incentives")?.classList.add("spin"); const s = new CustomEvent("spin-click", { bubbles: !0, composed: !0, detail: { Source: t } }); this.dispatchEvent(s), t.blur(), setTimeout(() => { const n = new CustomEvent("spin-complete", { bubbles: !0, composed: !0, detail: { value: i } }); this.dispatchEvent(n); }, this.#o + this.#n); }), e?.addEventListener("click", () => { const s = new CustomEvent("spin-cancel", { bubbles: !0, composed: !0, detail: { value: i } }); e.blur(), this.dispatchEvent(s); }); } #r() { this.#t.innerHTML = `
${this.incentivesMarkup}

${this.#e?.Spinner?.Heading?.Text}

`, this.#l(); } } function Le() { customElements.get("listrak-spinner-popup") || customElements.define("listrak-spinner-popup", Be); } function Ge(o) { const t = document.createElement("listrak-spinner-popup"); return t.options = o, t; } class Oe extends m { #t; #e; #i = "PopupFlow.PopupIntegrationService"; #s = null; #o; constructor(t, e, i, s, n) { super(t, { [l.OpenContent]: async (r) => await this.#n(r), [l.CloseContent]: async (r) => await this.#a(r) }), this.#t = e, this.#e = i, this.#s = s, this.#o = n; } async #n(t) { const e = t.data.Payload; if (!e) { console.log("Invalid or empty popup content sent to open content"); return; } const i = { Uuid: e.Uuid ?? e.StepUid, CloseOptions: e.CloseOptions ?? {}, PopupSettings: e.PopupSettings ?? null, Animation: e.Animation ?? "none", UseShadowDom: e.UseShadowDom ?? !0, Browser: this.#o }; if (e.PopupSettings?.Spinner) { const r = i.PopupSettings?.Spinner?.Heading?.Font, a = i.PopupSettings?.Spinner?.Heading?.Font, c = i.PopupSettings?.Spinner?.Dismiss?.Font, h = i.PopupSettings?.Spinner?.Incentives?.[0]?.Font, d = [ r, a, c, h ].filter((p) => p?.Url).map((p) => ({ Url: p?.Url, FontFamily: p?.Family })); d.length && this.PostMessage({ Type: l.PrefetchFont, Payload: { Details: { Properties: { Fonts: d } } } }); } const s = this.#t.CreatePopup(i); e.CustomFonts !== void 0 && e.CustomFonts !== null && e.CustomFonts.length !== 0 && this.#c(s, e.CustomFonts); const n = { Html: e.Content.Html ?? "", ...e.Content.Js ? { Js: e.Content.Js } : {} }; if (e.PopupSettings?.Spinner) { Le(), e.PopupSettings.Spinner.Uuid = s.Uuid; const r = Ge(e.PopupSettings); s.shadowRoot?.querySelector("slot")?.appendChild(r), this.#r(e.FlowUid, s); } else s.InsertContent(n); this.#l(e.FlowUid, s), e.SubscriberFormOptions && this.#e.AttachSubscriptionFormTriggers(e.FlowUid, e.Uuid, s, e.SubscriberFormOptions), this.#t.OpenPopup(e.Uuid ?? e.StepUid); } async #a(t) { const e = t.data.Payload; if (!e) { console.log("Invalid or empty popup uuid sent to close content"); return; } this.#t.ClosePopup(e); } #l(t, e) { e.addEventListener("popup-close", (i) => { this.PostMessage({ Type: l.Exit, Payload: { Uid: t, Source: i?.detail?.Source } }); }), e.addEventListener("link-click", (i) => { this.PostMessage({ Type: l.LinkClick, Payload: { Uid: t, PopupUid: e.Uuid, Url: i?.detail?.Link } }); }); } #r(t, e) { e.addEventListener("spin-click", () => { this.PostMessage({ Type: l.SpinClick, Payload: { Uid: t } }); }), e.addEventListener("spin-complete", (i) => { this.#t.ClosePopup(i?.detail?.value), this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: t } }); }), e.addEventListener("spin-cancel", (i) => { this.#t.ClosePopup(i?.detail?.value); }); } #c(t, e) { let i = 0; if (this.#s?.fonts.forEach((s) => { e.some((n) => n.FontFamily === s.family) && i++; }), i !== e.length) { t.style.opacity = "0"; let s = !1; const n = setTimeout(() => { s || t.style.removeProperty("opacity"); }, 1e3); this.#s?.fonts.addEventListener("loading", () => { s = !0, clearTimeout(n); }), this.#s?.fonts.addEventListener("loadingdone", () => { t.style.removeProperty("opacity"); }), this.#s?.fonts.addEventListener("loadingerror", () => { t.style.removeProperty("opacity"); const r = new Error("Error loading custom font"); throw u(r, this.#i), r; }); } } } const J = "ltk-popup-flow-whitelist"; class Ne extends m { #t; constructor(t) { super(t, { [l.Any]: async (i) => await this.#e(i) }); const e = window.localStorage.getItem(J); this.#t = e ? JSON.parse(e) : null; } #e(t) { this.#t && (this.#t.length === 0 || t.data.Type != null && this.#t.includes(t.data.Type.toString())) && console.log("FlowEngine:", t.lastEventId, t.data.Type, t.data.Payload); } EnableDebug() { this.#t = [], window.localStorage.setItem(J, JSON.stringify(this.#t)); } IsDebugEnabled(t) { return this.#t && this.#t.length === 0 ? !0 : t && this.#t?.includes(t) || !1; } } class We { constructor(t, e) { this.#t = e, this.Container = this.#e(t), this.Overlay = this.#i(t), this.Popup = this.#s(t), this.Spinner = this.#o(t); } #t = !1; #e(t) { if (!t) return { CloseButtonLocation: "top-right", CloseButtonColor: "#000000", PagePlacement: "center", BorderWidth: 0, BackgroundColor: "#FFFFFF", MobileBreakpoint: void 0, MobileMaxWidth: void 0, TransparentBrackground: void 0, ContainerWidth: void 0 }; if (this.#t) return { MobileBreakpoint: 600, MobileMaxWidth: 320, TransparentBrackground: !0, ContainerWidth: 600, ...t.Container }; const { CloseButtonLocation: e = "top-right", CloseButtonColor: i = "#000000", PagePlacement: s = "center", BorderWidth: n = 0, PopupBackgroundColor: r = "#FFFFFF" } = t; return { MobileBreakpoint: void 0, MobileMaxWidth: void 0, TransparentBrackground: void 0, ContainerWidth: void 0, CloseButtonLocation: e, CloseButtonColor: i, PagePlacement: s, BorderWidth: n, BackgroundColor: r }; } #i(t) { if (!t) return { Color: "#000000", Opacity: 0.5 }; if (this.#t) { const { Overlay: e } = t; return { Color: e.OverlayColor, Opacity: e.OverlayTransparency }; } else { const { OverlayColor: e = "#000000", OverlayTransparency: i = 0.5 } = t; return { Color: e, Opacity: i }; } } #s(t) { if (!t || this.#t) return null; const { PopupShape: e, PopupWidth: i, PopupHeight: s, BorderRadius: n, BorderStyle: r, BorderColor: a, PopupBackgroundImage: c, PopupBackgroundImageSize: h, PopupBackgroundImagePosition: d, PopupBackgroundImageRepeat: p } = t; return { Shape: e, Width: i, Height: s, BorderRadius: n, BorderStyle: r, BorderColor: a, BackgroundImage: c, BackgroundImageSize: h, BackgroundImagePosition: d, BackgroundImageRepeat: p }; } #o(t) { if (!t) return null; if (this.#t) { const e = t; return { BackgroundColor: e.Container?.BackgroundColor, Heading: e.Heading, ActionButton: e.ActionButton, Dismiss: e.Dismiss, Incentives: e.Incentives, WinnerIndex: 0, Uuid: e.Uuid }; } return null; } get settings() { return { Container: this.Container, Overlay: this.Overlay, ...this.Popup && { Popup: this.Popup }, ...this.Spinner && { Spinner: this.Spinner } }; } } class _e extends m { #t; #e; constructor(t, e, i) { super(t, { [l.ContentRender]: async (s) => await this.#i(s) }), this.#t = 5, i !== void 0 && (this.#t = i), this.#e = e; } async #i(t) { const e = t.data.Payload?.Details?.Properties?.ContentUid, i = t.data.Payload?.FlowUid, s = t.data.Payload?.Guid, n = st + e, r = this.#e.GetTags(i); if (t.data.Payload?.Details?.Type === g.SpinnerRender) { this.#s(t, i, e, s, g.SpinnerRender); return; } let a = 0; for (; a < this.#t || a === 0; ) { const c = window.sessionStorage.getItem(n); if (c) { const h = JSON.parse(c), d = h.js ?? null; let p = h.html; r && (p = this.#o(p, r)), this.#s(t, i, e, s, g.ContentRender, p, d); break; } else a++, a <= this.#t && await new Promise((h) => setTimeout(h, 2e3)), console.log("Popup content is not available."); } } #s(t, e, i, s, n, r = "", a) { const c = n === g.SpinnerRender ? t.data.Payload?.Details?.Properties?.SpinnerSettings : t.data.Payload?.Details?.Properties?.PopupSettings, h = new We(c, n === g.SpinnerRender).settings, d = { FlowUid: e, StepUid: s, Uuid: i, Content: { Html: r, ...a ? { Js: a } : {} }, CloseOptions: { OnOverlayClick: t.data.Payload?.Details?.Properties?.OverlayClose ?? !1 }, PopupSettings: h, SubscriberFormOptions: { SubscriberFormContent: t.data.Payload?.Details?.Properties.SubscriberFormData ?? [] }, Animation: t.data.Payload?.Details?.Properties?.Animation, CustomFonts: t.data.Payload?.Details?.Properties?.CustomFonts }; this.PostMessage({ Type: l.OpenContent, Payload: d }); } #o(t, e) { for (let i = 0; i < 25; i++) { let s = !1; for (const n in e) t.indexOf(n) !== -1 && (t = t.replace(n, e[n]), s = !0); if (!s) break; } return t; } } var $ = /* @__PURE__ */ ((o) => (o.DefaultShowAgainAfter = "ltk-suppress-", o))($ || {}); class He extends m { #t; constructor(t, e) { super(t, { [l.SuppressFlow]: async (i) => await this.#e(i) }), this.#t = e; } SetSuppression(t, e, i) { const s = /* @__PURE__ */ new Date(), n = /* @__PURE__ */ new Date(); n.setDate(n.getDate() + i), this.#t.Cookie.SetCookie(t + e, s.toUTCString(), n, void 0, "/"); } async #e(t) { const e = t.data.Payload?.Details?.Properties || t.data.Payload; if (!e) { console.log("Invalid or empty request sent to Suppression Service"); return; } const i = e.CookieKey || $.DefaultShowAgainAfter; this.SetSuppression(i, e.FlowUid, e.Days); } } class ze extends m { #t; // desktop trigger settings #e = {}; #i = {}; #s = {}; #o = 0.1; #n = {}; #a = {}; // mobile trigger settings #l = {}; #r = 0.3; #c = {}; constructor(t, e) { super(t, { [l.Wait]: { [g.WaitExit]: async (i) => await this.#d(i) } }), this.#t = e; } #d(t) { const e = t.data.Payload.FlowUid; this.#t.Device.GetType() === this.#t.Device.Types.Desktop ? this.#u(e) : this.#p(e); } #u(t) { this.#h(t), this.#e[t] = !1, this.#i[t] = !1, this.#s[t] = null, this.#n[t] = this.#y(t), this.#a[t] = this.#b(t), this.#t.Mouse.AddMouseMoveListener(this.#n[t]), this.#t.Mouse.AddMouseOutListener(this.#a[t]); } #h(t) { t in this.#n && (this.#t.Mouse.RemoveMouseMoveListener(this.#n[t]), delete this.#n[t]), t in this.#a && (this.#t.Mouse.RemoveMouseOutListener(this.#a[t]), delete this.#a[t]); } #p(t) { this.#m(t), this.#l[t] = !1, this.#c[t] = this.#v(t), this.#t.Scroll.AddScrollListener(this.#c[t]); } #m(t) { t in this.#c && (this.#t.Scroll.RemoveScrollListener(this.#c[t]), delete this.#c[t]); } // desktop trigger methods #w(t, e) { return this.#e[t] = this.#e[t] || e > this.#f(), this.#e[t]; } #f() { return this.#t.Window.GetVisibleHeight() * this.#o; } #y(t) { return (e) => { const i = this.#t.Mouse.GetMouseEventY(e); this.#w(t, i) && this.#C(t, i); }; } #C(t, e) { this.#s[t] ? (this.#g(t, e), this.#s[t] = e) : e >= 0 && (this.#s[t] = e); } #g(t, e) { this.#S(t, e) && (this.#i[t] = !0); } #S(t, e) { const i = this.#s[t]; return i !== null && i < this.#f() && e < i; } #b(t) { return (e) => { if (this.#i[t]) { const i = this.#t.Mouse.GetMouseEventY(e), s = this.#t.Mouse.GetMouseEventX(e), n = this.#t.Window.GetVisibleWidth(); i <= 5 && s < n && (this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: t } }), this.#h(t)); } }; } // mobile trigger methods #v(t) { return (e) => { this.#k(t) && this.#t.Scroll.GetDepthFraction() === 0 && (this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: t } }), this.#m(t)); }; } #k(t) { return this.#l[t] = this.#l[t] || this.#t.Scroll.GetDepthFraction() >= this.#r, this.#l[t]; } } class Ve extends m { #t = {}; #e = "Bottom"; #i = {}; #s; constructor(t, e) { super(t, { [l.Wait]: { [g.WaitScroll]: async (i) => await this.#o(i) } }), this.#s = e; } #o(t) { const e = t.data.Payload.Details, i = t.data.Payload.FlowUid; this.#t[i] = e.Properties?.ScrollDepth === this.#e, this.#n(i); } #n(t) { this.#r() && (this.#a(t), this.#i[t] = this.#l(t), this.#s.Scroll.AddScrollListener(this.#i[t])); } #a(t) { t in this.#i && (this.#s.Scroll.RemoveScrollListener(this.#i[t]), delete this.#i[t]); } #l(t) { return (e) => { const i = this.#s.Scroll.GetDepthFraction(); i >= 0.5 && !this.#t[t] ? (this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: t } }), this.#a(t)) : (i >= 0.99 || this.#c()) && this.#t[t] && (this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: t } }), this.#a(t)); }; } #r() { return this.#s.Document.GetTotalHeight() / this.#s.Window.GetVisibleHeight() >= 2; } #c() { return this.#s.Document.GetTotalHeight() - this.#s.Window.GetVisibleHeight() - this.#s.Scroll.GetDepthPixels() <= 500; } } class Je { #t = []; AddEvaluator(t) { this.#t.push(t); } GetWinner(t) { return t.find((e) => this.#e(e)); } DebugWinner(t) { return t.map((e) => this.#i(e)); } #e(t) { for (let e = 0; e < this.#t.length; e++) if (!this.#t[e].Evaluate(t)) return !1; return !0; } #i(t) { const e = []; for (let i = 0; i < this.#t.length; i++) { const s = this.#t[i].DebugEvaluate(t); if (e.push(s), !s.Passes) return { TargetingDefinition: t, Passes: !1, InnerEvals: e }; } return { TargetingDefinition: t, Passes: !0, InnerEvals: e }; } } class Qe { #t = "Suppression"; #e; constructor(t) { this.#e = t; } GetSuppression(t) { return this.#e.Cookie.GetCookie($.DefaultShowAgainAfter + t) !== ""; } Evaluate(t) { return t.Uid ? !this.GetSuppression(t.Uid) : !0; } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } } class qe { #t = "SessionDepth"; #e; constructor(t) { this.#e = t; } Evaluate(t) { return t.TargetingRuleSet?.SessionDepth ? this.#i(t.TargetingRuleSet?.SessionDepth) : !0; } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } #i(t) { return this.#e.Session.GetSessionDepth() >= t; } } var U = /* @__PURE__ */ ((o) => (o.GoToNextStep = "goToNextStep", o.GoToUrl = "goToUrl", o.ClosePopup = "closePopup", o))(U || {}); class je extends m { #t = 2500; #e = 1; #i = 2; #s; #o = 13; #n = 10; constructor(t, e) { super(t, {}), this.#s = e; } AttachSubscriptionFormTriggers(t, e, i, s) { this.#a(i), this.#l(t, e, i, s); } #a(t) { const e = Array.from(t.getElementsByTagName("input")); if (t.shadowRoot) { const i = t.shadowRoot.getElementById("ltk-popup-inner"); i && e.push(...Array.from(i.getElementsByTagName("input"))); } e.length <= 0 || e.forEach((i) => { i.type === "tel" && (i.addEventListener("keydown", (s) => this.#w(s)), i.addEventListener("keyup", (s) => this.#f(s))); }); } #l(t, e, i, s) { const n = Array.from(i.getElementsByTagName("form")); if (i.shadowRoot) { const a = i.shadowRoot.getElementById("ltk-popup-inner"); a && n.push(...Array.from(a.getElementsByTagName("form"))); } if (n.length <= 0) return; const r = s.SubscriberFormContent; for (let a = 0; a < Math.min(n.length, r.length); a++) { const c = n[a], h = r[a], d = c.querySelector('input[name="phone"]'), p = c.querySelector('input[name="email"]'); d?.addEventListener("input", () => { d?.setCustomValidity(""); }), p?.addEventListener("input", () => { p?.setCustomValidity(""); }), c.addEventListener("submit", async (S) => { await this.#r(S, t, e, h); }); } } async #r(t, e, i, s) { t.preventDefault(); let n = !1; const r = this.#g(s.Channels), a = this.#y(t, 'input[name="email"]'), c = this.#y(t, 'input[name="phone"]'), h = t.target, d = h.querySelector('input[name="email"]'), p = h.querySelector('input[name="phone"]'); if (d && (xe(d.value) ? d.setCustomValidity("") : (d.setCustomValidity("Please enter a valid email address."), n = !0)), p && (!Pe(p.value) && p.value !== "" ? (p.setCustomValidity("Please enter a valid phone number."), n = !0) : p.setCustomValidity("")), r.EmailCode && !n && await this.#c(h, r.EmailCode, s, c, a), r.SmsCode && !n && await this.#d(h, r.SmsCode, s, c, a), n) h.reportValidity(); else { const S = { Email: r.EmailCode !== null, Sms: r.SmsCode !== null }; return this.PostMessage({ Type: l.FormSubmission, Payload: { Uid: e, Channels: S } }), !s.Action || s.Action === U.GoToUrl ? (s.RedirectUrl && (this.PostMessage({ Type: l.UrlRedirect, Payload: { Uid: e, Url: s.RedirectUrl } }), window.setTimeout(function() { window.open(s.RedirectUrl ?? ""); }, this.#t)), this.PostMessage({ Type: l.CloseContent, Payload: i }), this.PostMessage({ Type: l.Exit, Payload: { Uid: e } })) : s.Action === U.ClosePopup ? (this.PostMessage({ Type: l.CloseContent, Payload: i }), this.PostMessage({ Type: l.Exit, Payload: { Uid: e } })) : s.Action === U.GoToNextStep && (this.PostMessage({ Type: l.CloseContent, Payload: i }), this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: e } })), !1; } return !0; } async #c(t, e, i, s, n) { if (n === null || n?.length <= 0) return; const r = { SubscribeChannel: "Email", SubscribeType: "s", ResetSubscribeState: !1, Identifier: n, UpdatedIdentifier: null, List: e, Settings: null, ModalUID: null, ProfileItems: [] }; this.#h(t, this.#e, i).forEach((a) => { r.ProfileItems.push({ AttributeId: a.Name, AttributeValue: a.Value }); }), s && s.length > 0 && i.FieldMappings && this.#u(i.FieldMappings.phone, this.#e) && r.ProfileItems.push({ AttributeId: "phone", AttributeValue: s }), await this.#s.SubmitSubscribeDataAsync(r); } async #d(t, e, i, s, n) { if (!s || s?.length <= 0) return; const r = { SubscribeChannel: "SMS", SubscribeType: "s", ResetSubscribeState: !1, Identifier: s, UpdatedIdentifier: null, List: e, Settings: null, ModalUID: null, ProfileItems: [] }; r.Identifier = s, r.List = e, this.#h(t, this.#i, i).forEach((a) => { r.ProfileItems.push({ AttributeId: a.Name, AttributeValue: a.Value }); }), n && n.length > 0 && i.FieldMappings && this.#u(i.FieldMappings.email, this.#i) && r.ProfileItems.push({ AttributeId: "email", AttributeValue: n }), await this.#s.SubmitSubscribeDataAsync(r); } #u(t, e) { return (t & e) === e; } #h(t, e, i) { const s = []; return (this.#C(t, 'input[name^="Field_"],textarea[name^="Field_"]') ?? []).forEach((n) => { const r = n.name; if (!r || !e || !i.FieldMappings || this.#u(i.FieldMappings[r], e)) { const a = n.type; let c; a === "checkbox" ? c = n.checked ? "on" : null : a === "radio" ? n.checked && (c = n.value) : c = n.value, c != null && c !== "" && s.push({ Name: r, Value: c }); } }), s; } #p(t) { return /^\d$/.test(t.key); } #m(t) { const e = t.key, i = ["Home", "End", "Backspace", "Tab", "Enter", "Delete", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"], s = ["A", "C", "V", "X", "Z"]; return i.includes(e) || t.ctrlKey && s.includes(e.toUpperCase()); } #w(t) { !this.#p(t) && !this.#m(t) && t.preventDefault(); } #f(t) { if (this.#m(t)) return; const e = t.target, i = e.value.replace(/\D/g, "").slice(0, this.#o), s = i.length, n = s > this.#n, r = n ? s - this.#n : 0, a = n ? "+" + i.slice(0, r) : "", c = i.slice(r), h = c.substring(0, 3), d = c.substring(3, 6), p = c.substring(6, 10); i.length > 6 ? e.value = "(" + h + ") " + d + "-" + p : i.length > 3 ? e.value = "(" + h + ") " + d : i.length > 0 && (e.value = "(" + h), a && (e.value = `${a} ${e.value}`); } #y(t, e) { const i = t.target.querySelector(e); return i && i.value.length >= 0 ? i.value : null; } #C(t, e) { return t.querySelectorAll(e); } #g(t) { return { EmailCode: t?.EmailChannel?.SubscriberCode ?? null, SmsCode: t?.SmsChannel?.SubscriberCode ?? null }; } } class Ke extends m { constructor(t, e, i, s) { super(t, { [l.ButtonRender]: async (n) => await this.#o(n), [l.Exit]: async (n) => await this.#l(n) }), this.ButtonElementName = "listrak-button-element", this.#t = null, this.#i = {}, window.customElements.get(this.ButtonElementName) || window.customElements.define(this.ButtonElementName, e), this.#e = e, this.#s = i, this.#t = s; } #t; #e; #i; #s; #o(t) { const e = t.data.Payload?.Details?.Properties, i = t.data.Payload.FlowUid; this.#i[i] || (this.#i[i] = this.#n(i, e)); } #n(t, e) { const i = new this.#e(); return i.Configure(t, e, this.#s, this.#t), i.addEventListener("open-popup", () => { this.#a(t); }), i.addEventListener("button-hidden", () => { e.SuppressionDays && this.PostMessage({ Type: l.SuppressFlow, Payload: { FlowUid: t, Days: e.SuppressionDays } }); }), this.#t?.body.appendChild(i), i; } #a(t) { this.PostMessage({ Type: l.ButtonClick, Payload: { Uid: t } }); } #l(t) { const e = t.data.Payload.Uid, i = this.#i[e]; i && this.#s.Cookie.GetCookie($.DefaultShowAgainAfter + e) === "" && i.SetVisible(!0); } } class Ze extends HTMLElement { constructor() { super(), this.Uuid = null, this.#t = null, this.#e = "ButtonElement", this.#i = null, this.#s = "listrak-button-container", this.#o = null, this.#n = null; } #t; #e; #i; #s; #o; #n; // note: these callbacks are not capitalized because they are overriding functions exposed by HTMLElement connectedCallback() { this.Init(), this.#d(); } disconnectedCallback() { this.#u(); } SetStyleSheet(t) { if (!this.#t) { const i = new Error("Document not configured in button element"); throw u(i, this.#e), i; } const e = this.#t.defaultView; if (e) { const i = new e.CSSStyleSheet(); if (i.replaceSync(this.GetStyleTemplate(t)), this.shadowRoot) this.shadowRoot.adoptedStyleSheets.push(i); else { const s = new Error("Shadow Root not configured in button element"); throw u(s, this.#e), s; } } else { const i = new Error("Document view not found"); throw u(i, this.#e), i; } } GetStyleTemplate(t) { const e = t.Container.Image.Source === "" ? "" : this.#p(t.Container.Image), i = t.Container.Height === null ? "auto" : `${t.Container.Height}px`, s = t.Container.Width === null ? "auto" : `${t.Container.Width}px`; return ` ${this.#s} { --ltk-button-height: ${i}; --ltk-button-width: ${s}; --ltk-button-padding-block: ${t.Container.PaddingBlock}px; --ltk-button-padding-inline: ${t.Container.PaddingInline}px; --ltk-button-inset-block: ${t.Layout.InsetBlock}px; --ltk-button-inset-inline: ${t.Layout.InsetInline}px; --ltk-button-bkg-color: ${t?.Container.Color}; --ltk-button-border-radius: ${t.Container.Border.Radius}px; --ltk-button-border: ${t.Container.Border.Width}px ${t.Container.Border.Style} ${t.Container.Border.Color}; --ltk-button-font-color: ${t.Type.Color}; --ltk-button-font-family: ${t.Type.Font.FontFamily}; --ltk-button-font-size: ${t.Type.Size}px; --ltk-button-font-weight: ${t.Type.Weight}; --ltk-button-letter-spacing: ${t.Type.Spacing}px; --ltk-button-close-color: ${t.Close.Color}; } ${this.#s} { background-color: var(--ltk-button-bkg-color); display: flex; position: fixed; z-index: var(--override-button-z-index, calc(infinity)); pointerEvents: none; border: var(--ltk-button-border); border-radius: var(--ltk-button-border-radius); gap: calc(var(--ltk-button-padding-inline) / 1.5); ${e}; } ${this.#s}.hide { visibility: hidden } ${this.#s}.ltk-position-left:not(.ltk-position-top, .ltk-position-bottom), ${this.#s}.ltk-position-right:not(.ltk-position-top, .ltk-position-bottom) { inset-block-start: 50%; } ${this.#s}.ltk-position-left:not(.ltk-position-top, .ltk-position-bottom) { transform: translate(-50%, -50%) rotate(-90deg) translateY(50%); } ${this.#s}.ltk-position-right:not(.ltk-position-top, .ltk-position-bottom) { transform: translate(50%, -50%) rotate(90deg) translateY(50%); } ${this.#s}.ltk-position-top:not(.ltk-position-left, .ltk-position-right), ${this.#s}.ltk-position-bottom:not(.ltk-position-left, .ltk-position-right) { inset-inline-start: 50%; transform: translateX(-50%); } ${this.#s}.ltk-position-top { inset-block-start: var(--ltk-button-inset-block); } ${this.#s}.ltk-position-left { inset-inline-start: var(--ltk-button-inset-inline); } ${this.#s}.ltk-position-right { inset-inline-end: var(--ltk-button-inset-inline); } ${this.#s}.ltk-position-bottom { inset-block-end: var(--ltk-button-inset-block); } ${this.#s} button { background: transparent; border: none; cursor: pointer; padding-block: var(--ltk-button-padding-block); text-align: var(--ltk-button-text-align); } ${this.#s} button.display { color: var(--ltk-button-font-color); font-family: var(--ltk-button-font-family); font-size: var(--ltk-button-font-size); letter-spacing: var(--ltk-button-letter-spacing); font-weight: var(--ltk-button-font-weight); height: var(--ltk-button-height); width: var(--ltk-button-width); padding-inline: var(--ltk-button-padding-inline); } ${this.#s} button.display.has-close { padding-inline-end: calc(var(--ltk-button-padding-inline) / 2); } ${this.#s} button.close { padding-inline-end: var(--ltk-button-padding-inline); padding-inline-start: calc(var(--ltk-button-padding-inline) / 2); } ${this.#s} button svg { stroke: var(--ltk-button-close-color); stroke-width: 2px; width: calc(var(--ltk-button-font-size) * 1.2); height: calc(var(--ltk-button-font-size) * 1.2); display: block; } `; } Configure(t, e, i, s) { this.Uuid = t, this.setAttribute("uuid", this.Uuid), this.#t = s, this.#i = e, this.#n = i; } Init() { if (this.#i === null) { const i = new Error("Button Settings not configured"); throw u(i, this.#e), i; } if (this.attachShadow({ mode: "open" }), this.shadowRoot === null) { const i = new Error("ShadowRoot failed to initialize"); throw u(i, this.#e), i; } this.#a(this.#i.Type.Font), this.SetStyleSheet(this.#i); const t = this.#l(this.#i); this.#o = t, this.shadowRoot.appendChild(t); const e = this.#r(this.#i); if (t.appendChild(e), this.#i.Close.Enabled) { const i = this.#c(); t.appendChild(i); } } SetVisible(t) { t ? this.#o?.classList.remove("hide") : this.#o?.classList.add("hide"); } #a(t) { if (t.Url !== null) { let e = !1; if (this.#t?.fonts.forEach((i) => { i.family === t.FontFamily && (e = !0); }), !e) { this.style.opacity = "0"; let i = !1; const s = setTimeout(() => { i || this.style.removeProperty("opacity"); }, 1e3); this.#t?.fonts.addEventListener("loading", () => { i = !0, clearTimeout(s); }), this.#t?.fonts.addEventListener("loadingdone", () => { this.style.removeProperty("opacity"); }), this.#t?.fonts.addEventListener("loadingerror", () => { this.style.removeProperty("opacity"); const n = new Error("Error loading custom font"); throw u(n, this.#e), n; }); } } } #l(t) { if (this.#t === null) { const s = new Error("Document not configured"); throw u(s, this.#e), s; } const e = this.#t.createElement(this.#s), i = t.Layout.Position.split("-"); return i.length === 2 && this.#n?.Device.GetType() === this.#n?.Device.Types.Mobile && i.pop(), i.forEach((s) => { e.classList.add(`ltk-position-${s}`); }), e; } #r(t) { if (this.#t === null) { const i = new Error("Document not configured"); throw u(i, this.#e), i; } const e = this.#t.createElement("button"); return e.classList.add("display"), t.Close.Enabled && e.classList.add("has-close"), e.textContent = t.Text, e.onclick = () => { this.SetVisible(!1), this.dispatchEvent( new CustomEvent( "open-popup", { bubbles: !0, detail: { uuid: this.Uuid } } ) ); }, e; } #c() { if (this.#t === null) { const e = new Error("Document not configured"); throw u(e, this.#e), e; } const t = this.#t.createElement("button"); return t.innerHTML = ` Close Closes Web Dialog `, t.classList.add("close"), t.onclick = () => { this.SetVisible(!1), this.dispatchEvent( new CustomEvent( "button-hidden", { bubbles: !0, detail: { uuid: this.Uuid } } ) ); }, t; } #d() { this.dispatchEvent( new CustomEvent( "button-connected", { bubbles: !0, detail: { uuid: this.Uuid } } ) ); } #u() { this.dispatchEvent( new CustomEvent( "button-disconnected", { bubbles: !0, detail: { uuid: this.Uuid } } ) ); } #h(t) { switch (t) { case "top-left": return "0% 0%"; case "bottom-left": return "0% 100%"; case "top-right": return "100% 0%"; case "bottom-right": return "100% 100%"; case "top-center": return "top"; case "bottom-center": return "bottom"; default: return t; } } #p(t) { return ` background-image: ${t.Source}; background-position: ${this.#h(t.Position)}; background-repeat: ${t.Repeat}; background-size: ${t.Size}; `; } } var b = /* @__PURE__ */ ((o) => (o.EntryImpression = "entry-impression", o.Submission = "submission", o.PersistentButtonClick = "persistent-button-click", o.UrlRedirect = "url-redirect", o.LinkClick = "link-click", o.TapToJoin = "tap-to-join", o.ExitClick = "exit-click", o.ContentImpression = "content-impression", o.CouponImpression = "coupon-impression", o.SplitImpression = "split-impression", o.SpinnerClick = "spinner-click", o))(b || {}); class Xe extends m { #t; #e; #i; #s = "PopupFlow.ActivityTracking"; #o = {}; #n; constructor(t, e, i, s, n) { super(t, { [l.FormSubmission]: async (r) => await this.#d(r), [l.ButtonClick]: async (r) => await this.#l(r), [l.LinkClick]: async (r) => await this.#c(r), [l.Exit]: async (r) => await this.#u(r), [l.UrlRedirect]: async (r) => await this.#h(r), [l.SpinClick]: async (r) => await this.#r(r), [l.Any]: async (r) => await this.#a(r) }), this.#t = e, this.#e = i, this.#i = s, this.#n = n; } async #a(t) { const e = t.data.Payload?.Uid ?? t.data.Payload.FlowUid ?? t.data.Payload.ExperienceUid ?? null, i = t.data.Payload?.Details?.Properties?.ActivityUid ?? null, s = t.data.Payload?.Details?.Properties?.ActivityType ?? null; if (i !== null) { if (e === null) { u(new Error("Failed to find experience Uid for activity tracking step."), this.#s); return; } if (s === null) { u(new Error("Failed to find activity type for activity tracking step."), this.#s); return; } this.#o[e] = i, await this.#g(e, i, s); } } async #l(t) { const e = t.data.Payload.Uid; await this.#p(e, this.#o[e]); } async #r(t) { const e = t.data.Payload.Uid; await this.#C(e, this.#o[e]); } async #c(t) { const e = t.data.Payload.Uid; t.data.Payload.Url.startsWith("sms:") ? await this.#f(e, this.#o[e]) : await this.#w(e, this.#o[e]); } async #d(t) { const e = t.data.Payload?.Uid, i = t.data.Payload?.Channels !== void 0 ? { channels: t.data.Payload?.Channels } : void 0; await this.#g(e, this.#o[e], b.Submission, i); } async #u(t) { const e = ["closeX", "overlay"], i = t.data.Payload.Source; if (e.includes(i)) { const s = t.data.Payload.Uid; await this.#y(s, this.#o[s]); } } async #h(t) { const e = t.data.Payload.Uid; await this.#m(e, this.#o[e]); } #p = async (t, e) => await this.#g(t, e, b.PersistentButtonClick); #m = async (t, e) => await this.#g(t, e, b.UrlRedirect); #w = async (t, e) => await this.#g(t, e, b.LinkClick); #f = async (t, e) => await this.#g(t, e, b.TapToJoin); #y = async (t, e) => await this.#g(t, e, b.ExitClick); #C = async (t, e) => await this.#g(t, e, b.SpinnerClick); async #g(t, e, i, s = void 0) { const n = this.#S(t, e, i, s); try { await this.#n.Http.PostAsync(`${this.#e}/${this.#t}`, n); } catch (r) { u(r, this.#s); } } #S(t, e, i, s = void 0) { const n = this.#n.Cookie.GetCookie(`ltk-subscribed-email-${this.#t}`) || null; return { ActivityType: i, ExperienceUid: t, StepUid: e, GlobalSessionUid: this.#n.Cookie.GetCookie(this.#i), TrackingId: this.#t, Email: n, UserAgent: this.#n.Navigator.GetUserAgent(), Url: this.#n.Window.GetPageUrl(), DeviceType: this.#n.Device.GetType()?.toLowerCase(), Referrer: this.#n.Document.GetReferrer(), Properties: s }; } } class Ye extends m { #t = "PopupFlow.LinkClickService"; constructor(t) { super(t, { [l.LinkClick]: async (e) => await this.#e(e) }); } async #e(t) { const e = t.data.Payload.Uid; if (!e) { u(new Error("An error occurred on link click: Message sent without uid."), this.#t); return; } const i = t.data.Payload.Url; if (!i) return; const s = t.data.Payload.PopupUid; if (!s) { u(new Error("An error occurred on link click: Message sent without popup uid."), this.#t); return; } i.startsWith("sms:") && (this.PostMessage({ Type: l.CloseContent, Payload: s }), this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: e } })); } } var f = /* @__PURE__ */ ((o) => (o[o.Url = 0] = "Url", o[o.Coupon = 1] = "Coupon", o[o.SubscribedChannel = 2] = "SubscribedChannel", o[o.DeviceType = 3] = "DeviceType", o[o.Referrer = 4] = "Referrer", o[o.Cart = 5] = "Cart", o[o.Product = 6] = "Product", o[o.ImpressionCount = 7] = "ImpressionCount", o[o.CountryCode = 8] = "CountryCode", o[o.CookieKeyValue = 9] = "CookieKeyValue", o[o.IPAddress = 10] = "IPAddress", o[o.SessionDepth = 11] = "SessionDepth", o[o.ListrakEmail = 12] = "ListrakEmail", o[o.CartTotal = 13] = "CartTotal", o[o.CartQuantity = 14] = "CartQuantity", o[o.CartSku = 15] = "CartSku", o))(f || {}), w = /* @__PURE__ */ ((o) => (o[o.Is = 0] = "Is", o[o.IsNot = 1] = "IsNot", o[o.Contains = 2] = "Contains", o[o.DoesNotContain = 3] = "DoesNotContain", o[o.AtLeast = 4] = "AtLeast", o[o.LessThan = 5] = "LessThan", o[o.GreaterThan = 6] = "GreaterThan", o[o.Exists = 7] = "Exists", o))(w || {}); class ti { #t = "RuleGroup"; #e = {}; constructor(t) { this.#e = t; } Evaluate(t) { return this.#i(t, null); } EvaluateRuleGroup(t) { return this.#s(t, !0, null); } #i(t, e) { const i = t.TargetingRuleSet?.TargetingRules, s = i?.Show, n = i?.Hide; let r = !1, a = !0; if (s) { const c = e !== null ? [] : null; a = this.#s(s, !0, c), e !== null && e.push({ Name: "Show", Passes: a, InnerEvals: c }); } if (n) { const c = e !== null ? [] : null; r = this.#s(n, !1, c), e !== null && e.push({ Name: "Hide", Passes: r, InnerEvals: c }); } return r ? !1 : a; } #s(t, e, i) { const s = t.SubGroups; if (t.Enabled) { if (!s) throw new Error("Error evaluating targeting conditions: Rule group is enabled but sub groups are not defined"); if (s.length === 0) return e; const n = t.Operator, r = i !== null ? [] : null; for (let a = 0; a < s.length; a++) { const c = this.#o(s[a], e, r); if (n === "AND" && c === !1) return i !== null && i.push({ Name: n, Passes: !1, InnerEvals: r }), !1; if (n === "OR" && c === !0) return i !== null && i.push({ Name: n, Passes: !0, InnerEvals: r }), !0; } if (n === "AND") return i !== null && i.push({ Name: n, Passes: !0, InnerEvals: r }), !0; if (n === "OR") return i !== null && i.push({ Name: n, Passes: !1, InnerEvals: r }), !1; } return e; } #o(t, e, i) { const s = t.Rules; if (!s) throw new Error("Error evaluating targeting conditions: Rule group is enabled but sub groups are not defined"); if (s.length === 0) return e; const n = t.Operator; for (let r = 0; r < s.length; r++) { if (s[r].Category === null) throw new Error("Error evaluating targeting conditions: Rule category is not defined"); const a = s[r].Category; if (!(a in this.#e)) throw new Error("Error evaluating targeting conditions: No rule evaluator for " + a); const c = this.#e[a].Evaluate(s[r]); if (i !== null) { const h = s[r].Operator; i.push({ Name: f[a] + " " + w[h] + " " + s[r].Value, Passes: c }); } if (n === "AND" && c === !1) return !1; if (n === "OR" && c === !0) return !0; } return n === "AND" ? !0 : n === "OR" ? !1 : e; } DebugEvaluate(t) { let e = !1; const i = []; return e = this.#i(t, i), { Name: this.#t, Passes: e, InnerEvals: i }; } DebugEvaluateRuleGroup(t) { let e = !1; const i = []; return e = this.#s(t, !0, i), { Name: this.#t, Passes: e, InnerEvals: i }; } } function C() { return /* @__PURE__ */ new Map([ [w.Is, ot], [w.IsNot, ei], [w.Contains, nt], [w.DoesNotContain, ii], [w.AtLeast, () => !0], [w.LessThan, si], [w.GreaterThan, oi], [w.Exists, ni] ]); } function ot(o, t) { return Array.isArray(t) ? Array.isArray(o) ? o.some((e) => t.includes(e)) : t.includes(o) : Array.isArray(o) ? o.includes(t) : o === t; } function ei(o, t) { return !ot(o, t); } function nt(o, t) { return Array.isArray(t) ? Array.isArray(o) ? o.every((e) => t.includes(e)) : t.some((e) => o.includes(e)) : Array.isArray(o) ? o.some((e) => t.includes(e)) : o === t; } function ii(o, t) { return !nt(o, t); } function si(o, t) { return o < t; } function oi(o, t) { return o > t; } function ni(o) { return o != null && o !== ""; } var B = /* @__PURE__ */ ((o) => (o.Email = "Email", o.Sms = "SMS", o))(B || {}); class ri { #t = "ListrakSource"; #e = C(); #i; constructor(t) { this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating Listrak Source rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (e) { let i = this.#i.Session.GetIsFromListrak(); return i === "E" ? i = B.Email : i === "S" && (i = B.Sms), e(t.Value, i); } else throw new Error("Error evaluating Listrak Source rule: Test for operator not found"); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } } class ai { #t = "Url"; #e = C(); #i; constructor(t) { this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating Url rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (e && t.Value !== null) return typeof t.Value == "number" ? e(t.Value, this.#i.Window.GetPageUrl().toLowerCase()) : Array.isArray(t.Value) ? e(t.Value.map((i) => i.toLowerCase()), this.#i.Window.GetPageUrl().toLowerCase()) : e(t.Value.toLowerCase(), this.#i.Window.GetPageUrl().toLowerCase()); throw new Error("Error evaluating Url rule: Test for operator not found"); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } } var L = /* @__PURE__ */ ((o) => (o.Email = "Email", o.Sms = "SMS", o))(L || {}); class li { #t = "Subscription"; #e; #i; #s; constructor(t, e, i) { this.#e = e, this.#i = i, this.#s = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating Subscription rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (!e) throw new Error("Error evaluating Subscription rule: Test for operator not found"); return e(t.Value, this.#o()); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } #o() { const t = JSON.parse(this.#s.Cookie.GetCookie(`ltk-subscribed-channel-${this.#i}`) || "{}"), e = this.#s.Cookie.GetCookie(`subscription_status-${this.#i}`); t.Email = t.Email || !!e; const i = []; return t?.Email && i.push(L.Email), t?.Sms && i.push(L.Sms), i; } } var G = /* @__PURE__ */ ((o) => (o.Paid = "Paid", o.Organic = "Organic", o))(G || {}); const ci = [ { Domains: [/www\.google\.com/], QueryStrings: [/[?&]gclid=/, /[?&]utm_source=google(&|$)/] } ]; class ui { #t = "Referrer"; #e; #i; constructor(t, e) { this.#e = e, this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating Referrer rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (!e) throw new Error("Error evaluating Referrer rule: Test for operator not found"); return e(t.Value, this.#s()); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } #s() { const t = []; return this.#o() ? t.push(G.Paid) : t.push(G.Organic), t; } #o() { const t = this.#i.Document.GetReferrer(); return ci.some((e) => this.#n(t, e)); } #n(t, e) { return !!(e.Domains.some((i) => i.test(t.toLowerCase())) || e.QueryStrings.some((i) => this.#i.QueryString.RegexMatchQueryString(i))); } } class hi { #t = "DeviceType"; #e = C(); #i; constructor(t) { this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating Device Type rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (e) return e(t.Value, this.#i.Device.GetType()); throw new Error("Error evaluating Device Type rule: Test for operator not found"); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } } const Q = "ltk-flow-tags-"; class di { GetTags(t) { const e = window.sessionStorage.getItem(Q + t); return e ? JSON.parse(e) : {}; } SetTag(t, e, i) { const s = this.GetTags(t); s[e] = i, this.#t(t, s); } SetTags(t, e) { const i = this.GetTags(t); for (const s in e) i[s] = e[s]; this.#t(t, i); } #t(t, e) { window.sessionStorage.setItem(Q + t, JSON.stringify(e)); } } class pi { #t; constructor(t) { this.#t = t; } async GetDataAsync(t) { const e = await this.#t.Assign(t); return { Code: e.couponCode, Expiration: new Date(e.couponExpiration), Uid: t }; } } class gi extends m { #t; #e; #i = "PopupFlow.CouponService"; constructor(t, e, i) { super(t, { [l.AssignCoupon]: async (s) => await this.#s(s) }), this.#t = e, this.#e = i; } async #s(t) { const e = t.data.Payload?.Details?.Properties?.CouponPoolUid, i = t.data.Payload?.FlowUid; let s = ""; if (e) try { s = (await this.#t.GetDataAsync(e)).Code; } catch (r) { u(r, this.#i); } else u(new Error(`Coupon Pool UID for flow ${t.data.Payload.PopupFlowUid} could not be found`), this.#i); let n = {}; n = this.#o(n, t, "CouponCodeTagName", s, !0), n = this.#o(n, t, "CouponTitleTagName", "CouponTitle"), n = this.#o(n, t, "CouponDescriptionTagName", "CouponDescription"), n = this.#o(n, t, "CouponExpirationTagName", "CouponExpiration"), n = this.#o(n, t, "CouponDisclaimerTagName", "CouponDisclaimer"), this.#e.SetTags(i, n), this.PostMessage({ Type: l.WaitComplete, Payload: { Uid: i } }); } #o(t, e, i, s, n) { if (!e.data.Payload?.Details?.Properties || !(i in e.data.Payload?.Details?.Properties) || !n && !(s in e.data.Payload?.Details?.Properties)) return t; let r = e.data.Payload?.Details?.Properties[i] ?? "", a = s ?? ""; return !r || (n || (a = e.data.Payload?.Details?.Properties[s]), !a) || (r = "{{Experience:" + r.trim() + "}}", a = a.trim(), t[r] = a), t; } } class rt { #t; constructor(t) { this.#t = t; } get #e() { return `offers-${this.#t}`; } get #i() { const t = window.localStorage.getItem(this.#e); if (t === null) return []; const e = JSON.parse(t); return this.#s(e.map(({ Code: i, Expiration: s, Uid: n }) => ({ Code: i, Expiration: new Date(s), Uid: n }))); } get HasOffers() { return this.#i.length > 0; } Cache(t) { const e = this.#i; e.push(t); const i = e.map(({ Code: s, Expiration: n, Uid: r }) => ({ Code: s, Expiration: n.toISOString(), Uid: r })); window.localStorage.setItem( this.#e, JSON.stringify(i) ); } GetCachedOffers() { return this.#i; } Clear() { window.localStorage.removeItem(this.#e); } Dispense(t) { return this.#i.length === 0 ? null : t !== void 0 ? this.#i.find((e) => e.Uid === t) ?? null : this.#i[this.#i.length - 1]; } #s(t) { const e = (/* @__PURE__ */ new Date()).getTime(); return t.filter((i) => i.Expiration.getTime() > e); } } let mi; function fi(o, t) { mi.SubmitException(o, t); } class yi { #t; #e; #i; #s = "CouponRequest.Dispense"; #o; constructor(t, e) { this.#e = e.DefaultBaseUrl, this.#o = e.MerchantTrackingId, this.#i = new rt(e.MerchantTrackingId), this.#t = t; } async Assign(t) { try { const e = await (await this.#t.Http.PutAsync(`${this.#e}/coupon`, { Uid: t, TrackingId: this.#o })).json(), i = this.#n(e.couponExpiration); return this.#i.Cache({ Code: e.couponCode ?? "", Expiration: new Date(i), Uid: t }), { couponCode: e.couponCode, couponExpiration: i }; } catch (e) { fi(e, this.#s); const i = /* @__PURE__ */ new Date(); return i.setDate(i.getDate() - 30), { couponCode: "", couponExpiration: i.toISOString() }; } } #n(t) { const e = /* @__PURE__ */ new Date(); if (e.setDate(e.getDate() + 30), t === null) return e.toISOString(); const i = typeof t == "string" ? Date.parse(t) : Date.parse(t.toString()); return Number.isNaN(i) ? e.toISOString() : new Date(i).toISOString(); } } class wi { #t = "Coupon"; #e = C(); #i; constructor(t) { this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating Coupon rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (e) { const i = this.#i.GetCachedOffers().map((n) => n.Uid?.toLowerCase()), s = this.SanitizeRuleValues(t.Value); return s.includes("any") ? this.#i.HasOffers : e(s, i); } else throw new Error("Error evaluating Coupon rule: Test for operator not found"); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } SanitizeRuleValues(t) { if (Array.isArray(t)) return t.map((e) => e.toLowerCase()); throw new Error("Error evaluating Coupon rule: Coupon Rule Values not in array format"); } } class Ci { #t = "Cookie"; #e = C(); #i; constructor(t) { this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating Cookie rule: Rule operator is not defined"); if (t.Key === null) throw new Error("Error evaluating Cookie rule: Rule key is not defined"); const e = this.#e.get(t.Operator); if (e) { if (t.Operator === w.Exists) return e(this.#i.Cookie.GetCookie(t.Key), ""); if (t.Value !== null) return e(this.#i.Cookie.GetCookie(t.Key), t.Value); throw new Error("Error evaluating Cookie rule: Test for operator not found"); } else throw new Error("Error evaluating Cookie rule: Rule operator not found"); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } } class Si extends m { #t = "PopupFlow.RandomSplitService"; constructor(t) { super(t, { [l.RandomSplit]: async (e) => await this.#e(e) }); } async #e(t) { if (!t.data.Payload.Details.Properties.BranchDetailsList) { u(new Error("Error retrieving branch details: branch details list is null"), this.#t); return; } const e = t.data.Payload.Details.Properties.BranchDetailsList; if (e.length === 0) { u(new Error("Error retrieving branch details: branch details list is empty"), this.#t); return; } const i = Math.random(); let s = "", n = 0; for (let r = 0; r < e.length; r++) { const a = e[r]; if (n += a.Propensity ?? 0, i <= n) { s = a.StartingGuid; break; } } this.PostMessage({ Type: l.GoToStep, Payload: { Uid: t.data.Payload.FlowUid, StepUid: s } }); } } class bi extends m { #t = "PopupFlow.ConditionSplitService"; #e; #i; constructor(t, e, i) { super(t, { [l.ConditionSplit]: async (s) => await this.#s(s) }), this.#e = e, this.#i = i; } async #s(t) { if (!t.data.Payload.Details.Properties.BranchDetailsList) { u(new Error("Error retrieving branch details: branch details list is null"), this.#t); return; } const e = t.data.Payload.Details.Properties.BranchDetailsList; if (e.length === 0) { u(new Error("Error retrieving branch details: branch details list is empty"), this.#t); return; } let i = ""; const s = this.#i.IsDebugEnabled(l.ConditionSplit); for (let n = 0; n < e.length; n++) { const r = e[n], a = r.FilterCriteria; if (!a) { i = r.StartingGuid; break; } if (!s && this.#e.EvaluateRuleGroup(a)) { i = r.StartingGuid; break; } else if (s) { const c = this.#e.DebugEvaluateRuleGroup(a); if (console.log("Condition Split Rule Evaluation:", r.StartingGuid, c), c.Passes) { i = r.StartingGuid; break; } } } this.PostMessage({ Type: l.GoToStep, Payload: { Uid: t.data.Payload.FlowUid, StepUid: i } }); } } let vi; function q(o, t) { vi.SubmitException(o, t); } class ki { #t; constructor(t) { this.#i(), this.#t = "ltk_cart_data_" + t; } GetCartTotal() { const t = this.#e(); return t ? t.TotalPrice : null; } GetCartQuantity() { const t = this.#e(); return t ? t.TotalQuantity : null; } GetCartSkus() { const t = this.#e(); return t ? t.Skus : null; } #e() { try { const t = window.localStorage.getItem(this.#t); return t ? JSON.parse(t) : null; } catch (t) { return q(t, "Failed to parse cart data from localStorage: " + t), null; } } #i() { document.addEventListener("ltkAddToCart", this.#s.bind(this)), document.addEventListener("ltkClearCart", this.#o.bind(this)); } #s = (t) => { const e = t; if (e.detail && e.detail.items) { const { totalPrice: i, totalQuantity: s, skus: n } = this.#n(e.detail.items); this.#a(s, i, n); } }; #o = () => { this.#l(); }; #n(t) { return t.reduce( (e, i) => ({ totalQuantity: e.totalQuantity + i.Quantity, totalPrice: e.totalPrice + i.Price * i.Quantity, skus: [...e.skus, i.Sku] }), { totalQuantity: 0, totalPrice: 0, skus: [] } ); } #a(t, e, i = []) { try { const s = { TotalQuantity: t, TotalPrice: e, Skus: i }; window.localStorage.setItem(this.#t, JSON.stringify(s)); } catch (s) { q(s, "Failed to update cart data in localStorage: " + s); } } #l() { window.localStorage.removeItem(this.#t); } } class Ei { #t = "CartTotal"; #e = C(); #i; constructor(t) { this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating CartTotal rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (e) { const i = this.#s(t.Value), s = this.#i.GetCartTotal(); return s == null ? !1 : e(s, i); } else throw new Error("Error evaluating CartTotal rule: Test for operator not found"); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } #s(t) { if (typeof t == "number") return [t]; if (typeof t == "string") return [parseFloat(t)]; throw new Error("Error evaluating CartTotal rule: Cart Total Rule Values not in valid format"); } } class Pi { #t = "CartQuantity"; #e = C(); #i; constructor(t) { this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating CartQuantity rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (e) { const i = this.#s(t.Value), s = this.#i.GetCartQuantity(); return s == null ? !1 : e(s, i); } else throw new Error("Error evaluating CartQuantity rule: Test for operator not found"); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } #s(t) { if (typeof t == "number") return t; if (typeof t == "string") return parseInt(t, 10); throw new Error("Error evaluating CartQuantity rule: Cart Quantity Rule Values not in valid format"); } } class xi { #t = "CartSku"; #e = C(); #i; constructor(t) { this.#i = t; } Evaluate(t) { if (t.Operator === null) throw new Error("Error evaluating CartSku rule: Rule operator is not defined"); const e = this.#e.get(t.Operator); if (e) { const i = this.#s(t.Value), s = this.#i.GetCartSkus(); return s == null || s.length === 0 ? !1 : e(s, i); } else throw new Error("Error evaluating CartSku rule: Test for operator not found"); } DebugEvaluate(t) { return { Name: this.#t, Passes: this.Evaluate(t) }; } #s(t) { if (typeof t == "string") return [t]; if (Array.isArray(t)) return t.map((e) => e.toString()); throw new Error("Error evaluating CartSku rule: Cart SKU Rule Values not in valid format"); } } const Ti = "popup-flow-events-channel"; class Ii { static Create(t, e, i, s, n, r) { r = r ?? Ti + et.GenerateUuid(), Ee(t.DefaultBaseUrl, t.MerchantTrackingId); const a = new $e(t.WebContentBaseUrl, t.MerchantTrackingId, i), c = new Ue(t.WebContentBaseUrl, i), h = new Ie(t.WebContentBaseUrl, i, s), d = new yi(i, { MerchantTrackingId: t.MerchantTrackingId, DefaultBaseUrl: t.CouponBaseUrl }), p = new rt(t.MerchantTrackingId), S = new pi(d), x = new di(), T = new Ne(r), O = new je(r, n), R = new ki(t.MerchantTrackingId); new Re(r, c), new Me(r), new Ae(r, h), new Fe(r, h), new Oe(r, e, O, s, i), new Si(r), new _e(r, x), new He(r, i), new ze(r, i), new Ve(r, i), new Ke(r, Ze, i, s), new Xe(r, t.MerchantTrackingId, t.ActivityTrackingBaseUrl, t.SessionCookieName, i), new gi(r, S, x), new Ye(r); const I = new Je(); I.AddEvaluator(new Qe(i)), I.AddEvaluator(new qe(i)); const N = C(), W = new ti({ [f.Url]: new ai(i), [f.DeviceType]: new hi(i), [f.ListrakEmail]: new ri(i), [f.SubscribedChannel]: new li(i, N, t.MerchantTrackingId), [f.Coupon]: new wi(p), [f.Referrer]: new ui(i, N), [f.CartTotal]: new Ei(R), [f.CartQuantity]: new Pi(R), [f.CartSku]: new xi(R), [f.CookieKeyValue]: new Ci(i) }); return I.AddEvaluator(W), new bi(r, W, T), new Te(i, a, r, T, I, h, c); } } class Di { #t; constructor(t) { this.#t = t; } Init() { this.#t.Init(); } EnableDebug() { this.#t.EnableDebug(); } SetCaching(t) { this.#t.SetCaching(t); } async ManualTrigger(t) { await this.#t.ManualTrigger(t, !1); } async ManualEvaluate(t) { await this.#t.ManualTrigger(t, !0); } NextStep(t, e) { this.#t.NextStep(t, e); } ClosePopup(t, e) { this.#t.ClosePopup(t, e); } } class Ui { static Create(t) { const e = {}, i = new Proxy(e, { // eslint-disable-next-line @typescript-eslint/naming-convention get(s, n) { return s[n]; }, // eslint-disable-next-line @typescript-eslint/naming-convention set(s, n, r) { return n === "reload" ? (s.OldReload = r, !0) : n === "OscReload" ? (s.reload = r, !0) : (s[n] = r, !0); } }); return i.OscReload = () => { i.OldReload?.(), t.Reload(); }, i; } } class at { static Create(t, e) { e = e || document, Xt(t.DefaultBaseUrl, t.MerchantTrackingId); const i = { DefaultBaseUrl: t.DefaultBaseUrl, MerchantTrackingId: t.MerchantTrackingId, CouponBaseUrl: t.CouponBaseUrl }, s = Se.Create(i, e), n = new se(v), r = new oe(v, t.MerchantTrackingId), a = new ne(v, t.MerchantTrackingId), c = new he(t, n, r, a, v, e), h = Ii.Create(t, s, v, e, c), d = new ie(t.Features, t.MerchantTrackingId, v, h, s, c), p = new Di(d.PopupFlow), S = Ui.Create(d), x = new Yt(d, t.Features.EnablePopupFlow ? p : void 0, S), T = new te(d); return { Ltk: x, LtkUtil: T, Proxies: { Ltk: { OnsiteContent: S }, LtkUtil: {} } }; } } window !== void 0 && (window.onescript = { Create: at.Create }); const Vi = { Create: at.Create }; export { Vi as default };