window.initializeGAnalytics = n => {
    function t() {
        dataLayer.push(arguments)
    }
    window.dataLayer = window.dataLayer || [];
    const u = n.enableAjaxHeaderConsumer !== !1
      , f = n.trackPageView !== !1
      , e = {
        custom_platform: n.platform,
        whitelabel_id: n.wlbId,
        site_template_variation: n.variation,
        site_theme: n.theme,
        internal: !0
    };
    t("js", new Date);
    t("config", n.gaId, {
        send_page_view: !1
    });
    window._GASetUser = n => {
        n && t("set", "user_id", n)
    }
    ;
    window._GAClearUser = () => {
        t("set", "user_id", null)
    }
    ;
    n.userId && window._GASetUser(n.userId);
    window._GASendEvent = (i, r={}, u) => {
        if (!i) {
            typeof u == "function" && u();
            return
        }
        const f = {
            ...e,
            ...(r || {}),
            send_to: n.gaId
        };
        if (typeof u == "function") {
            let n = !1;
            f.event_callback = () => {
                n || (n = !0,
                u())
            }
            ;
            f.event_timeout = 1e3
        }
        t("event", i, f)
    }
    ;
    const o = n => {
        const t = n.querySelector("[title]");
        return {
            banner_rec_id: n.getAttribute("data-banner-rec-id") || "",
            link_url: n.getAttribute("href") || "",
            title: t && t.getAttribute("title") || ""
        }
    }
      , s = (n, t) => {
        if (n.defaultPrevented || n.button !== 0 || n.metaKey || n.ctrlKey || n.shiftKey || n.altKey)
            return !1;
        const i = (t.getAttribute("target") || "").toLowerCase();
        if (i && i !== "_self" || t.hasAttribute("download"))
            return !1;
        const r = (t.getAttribute("href") || "").trim();
        return !r || r.charAt(0) === "#" ? !1 : t.protocol === "http:" || t.protocol === "https:"
    }
      , i = (n, t) => {
        window._GASendEvent("home_banner_click", o(n), t)
    }
      , h = () => {
        window._HomeBannerClickTrackingRegistered || (window._HomeBannerClickTrackingRegistered = !0,
        document.addEventListener("click", n => {
            const r = n.target && n.target.nodeType === 1 ? n.target : n.target && n.target.parentElement;
            if (!r || !r.closest)
                return;
            const t = r.closest("a[data-home-banner]");
            if (!t)
                return;
            if (!s(n, t)) {
                i(t);
                return
            }
            const o = t.href;
            n.preventDefault();
            let f = !1
              , u = null;
            const e = () => {
                f || (f = !0,
                u && window.clearTimeout(u),
                window.location.href = o)
            }
            ;
            u = window.setTimeout(e, 1200);
            i(t, e)
        }
        ))
    }
    ;
    h();
    window.dispatchFootmarkEvents = (n, t) => {
        const i = Array.isArray(n) ? n : [];
        if (!i.length) {
            typeof t == "function" && t();
            return
        }
        let f = i.length
          , e = !1
          , r = null;
        const o = () => {
            e || (e = !0,
            r && window.clearTimeout(r),
            typeof t == "function" && t())
        }
          , u = () => {
            f--,
            f <= 0 && o()
        }
        ;
        typeof t == "function" && (r = window.setTimeout(o, 1500));
        i.forEach(n => {
            if (!n || !n.eventType) {
                u();
                return
            }
            try {
                window._GASendEvent(n.eventType, n.payload || {}, u)
            } catch (t) {
                console.log("Failed to dispatch footmark event:", t);
                u()
            }
        }
        )
    }
    ;
    window.consumeFootmarkEventHeader = n => {
        if (n)
            try {
                const t = JSON.parse(n);
                window.dispatchFootmarkEvents(t)
            } catch (t) {
                console.log("Failed to parse footmark event header:", t)
            }
    }
    ;
    const r = () => {
        if (u && !window._GAFootmarkAjaxHookRegistered) {
            if (!window.jQuery) {
                window.setTimeout(r, 100);
                return
            }
            window._GAFootmarkAjaxHookRegistered = !0;
            window.jQuery(document).ajaxComplete( (n, t) => {
                t && t.getResponseHeader && window.consumeFootmarkEventHeader(t.getResponseHeader("X-Footmark-Events"))
            }
            )
        }
    }
    ;
    r();
    window._GATrackPageView = () => {
        window._GASendEvent("page_view", {
            page_title: document.title,
            page_location: location.href,
            page_path: location.pathname,
            page_referrer: document.referrer || ""
        })
    }
    ;
    f && window.addEventListener("load", () => {
        window._GATrackPageView()
    }
    )
}
;
