;
! function() {
    try {
        var e = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof global ? global : "undefined" != typeof window ? window : "undefined" != typeof self ? self : {},
            n = (new e.Error).stack;
        n && ((e._debugIds || (e._debugIds = {}))[n] = "b6ae752e-dfab-c403-213f-c3df8c6118b4")
    } catch (e) {}
}();
(globalThis.TURBOPACK || (globalThis.TURBOPACK = [])).push(["object" == typeof document ? document.currentScript : void 0, 719465, e => {
    "use strict";
    e.s([], 840369), e.i(840369);
    var t, n, r, i, s, o, a, l, c, u, d, g, h, v, f, p, _, y, m, S, b = e.i(274466),
        I = e.i(842183),
        w = e.i(423129),
        C = e.i(974838),
        k = e.i(536323),
        P = e.i(115059),
        E = e.i(119253),
        R = function(e) {
            function t(t) {
                void 0 === t && (t = {});
                var n = e.call(this) || this;
                return n.customHeaders = t, n
            }
            return (0, b.__extends)(t, e), t.prototype.send = function(e, t) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var n, r;
                    return (0, b.__generator)(this, function(i) {
                        switch (i.label) {
                            case 0:
                                if ("u" < typeof fetch) throw Error("FetchTransport is not supported");
                                return [4, fetch(e, {
                                    headers: (0, b.__assign)({
                                        "Content-Type": "application/json",
                                        Accept: "*/*"
                                    }, this.customHeaders),
                                    body: JSON.stringify(t),
                                    method: "POST"
                                })];
                            case 1:
                                return [4, (n = i.sent()).text()];
                            case 2:
                                r = i.sent();
                                try {
                                    return [2, this.buildResponse(JSON.parse(r))]
                                } catch (e) {
                                    return [2, this.buildResponse({
                                        code: n.status
                                    })]
                                }
                        }
                    })
                })
            }, t
        }(E.BaseTransport),
        x = e.i(735886),
        T = e.i(60536),
        M = e.i(776839),
        O = "[Amplitude]",
        L = "".concat(O, " Session Replay ID"),
        A = M.ServerZone.US,
        D = {
            enabled: !0
        },
        F = "".concat(O, " Session Replay Debug"),
        q = "amp-mask",
        N = "amp-unmask",
        U = "https://api-sr.amplitude.com/sessions/v2/track",
        W = "https://api-sr.eu.amplitude.com/sessions/v2/track",
        B = "https://api-sr.stag2.amplitude.com/sessions/v2/track";
    T.AMPLITUDE_PREFIX;
    var j = /payload.*exceed/i,
        z = "amplitude-sr-iframe";
    (t = v || (v = {})).GET_SR_PROPS = "get-sr-props", t.DEBUG_INFO = "debug-info", t.FETCH_REQUEST = "fetch-request", t.METADATA = "metadata", t.TARGETING_DECISION = "targeting-decision";
    var K = function() {
            function e(e) {
                this.logger = e, this.log = this.getSafeMethod("log"), this.warn = this.getSafeMethod("warn"), this.error = this.getSafeMethod("error"), this.debug = this.getSafeMethod("debug")
            }
            return e.prototype.getSafeMethod = function(e) {
                if (!this.logger) return function() {};
                var t, n = this.logger[e];
                return "function" == typeof n ? (null != (t = n.__rrweb_original__) ? t : n).bind(this.logger) : function() {}
            }, e.prototype.enable = function(e) {
                this.logger.enable(e)
            }, e.prototype.disable = function() {
                this.logger.disable()
            }, e
        }(),
        G = "medium",
        H = function(e, t, n) {
            switch (t) {
                case "light":
                    if ("input" !== e) return !0;
                    var r, i, s = n ? (i = (r = n).type, r.hasAttribute("data-rr-is-password") ? "password" : i ? i.toLowerCase() : null) : "";
                    if (!s) return !1;
                    if (["password", "hidden", "email", "tel"].includes(s) || n.autocomplete.startsWith("cc-")) return !0;
                    return !1;
                case "medium":
                case "conservative":
                    return !0;
                default:
                    return H(e, G, n)
            }
        },
        Q = function(e, t) {
            if (e && t.urlMaskLevels) try {
                for (var n, r, i, s = (0, b.__values)(t.urlMaskLevels), o = s.next(); !o.done; o = s.next()) {
                    var a = o.value;
                    if (Y(a.match).test(e)) return a.maskLevel
                }
            } catch (e) {
                n = {
                    error: e
                }
            } finally {
                try {
                    o && !o.done && (r = s.return) && r.call(s)
                } finally {
                    if (n) throw n.error
                }
            }
            return null != (i = t.defaultMaskLevel) ? i : G
        },
        $ = function(e, t, n, r) {
            var i, s;
            if (void 0 === t && (t = {
                    defaultMaskLevel: G
                }), n) {
                if (n.closest("." + q) || (null != (i = t.maskSelector) ? i : []).some(function(e) {
                        return n.closest(e)
                    })) return !0;
                if (n.closest("." + N) || (null != (s = t.unmaskSelector) ? s : []).some(function(e) {
                        return n.closest(e)
                    })) return !1
            }
            return H(e, Q(r, t), n)
        },
        J = function(e, t, n) {
            return function(r, i) {
                return $(e, t, i, null == n ? void 0 : n()) ? r.replace(/[^\s]/g, "*") : r
            }
        },
        X = function() {
            var e = (0, w.getGlobalScope)();
            return (null == e ? void 0 : e.location) ? e.location.href : ""
        },
        V = new Map,
        Y = function(e) {
            var t = V.get(e);
            if (t) return t;
            var n = "\0TRAIL\0",
                r = "\0MID\0",
                i = "\0DS\0",
                s = "\0ST\0",
                o = "\0QU\0",
                a = e;
            a = (a = (a = (a = (a = (a = (a = (a = (a = (a = (a = a.replace(/\/\*\*$/, n)).replace(/\/\*\*\//g, r)).replace(/\*\*/g, i)).replace(/\*/g, s)).replace(/\?/g, o)).replace(/[.+^${}()|[\]\\]/g, "\\$&")).split(n).join("(/.*)?")).split(r).join("/(.*\\/)?")).split(i).join(".*")).split(s).join(".*")).split(o).join(".");
            var l = new RegExp("^".concat(a, "$"));
            return V.set(e, l), l
        },
        Z = function(e) {
            if (!e.every(function(e) {
                    return "string" == typeof e.selector && "string" == typeof e.replacement
                })) throw Error("ugcFilterRules must be an array of objects with selector and replacement properties");
            if (!e.every(function(e) {
                    var t;
                    return "string" == typeof(t = e.selector) && "" !== t.trim() && !!/^\/|^https?:\/\/[^\s]+$/.test(t)
                })) throw Error("ugcFilterRules must be an array of objects with valid globs")
        },
        ee = function(e, t) {
            var n, r;
            try {
                for (var i = (0, b.__values)(t), s = i.next(); !s.done; s = i.next()) {
                    var o = s.value,
                        a = Y(o.selector);
                    if (a.test(e)) return e.replace(a, o.replacement)
                }
            } catch (e) {
                n = {
                    error: e
                }
            } finally {
                try {
                    s && !s.done && (r = i.return) && r.call(i)
                } finally {
                    if (n) throw n.error
                }
            }
            return e
        },
        et = function() {
            return (0, b.__awaiter)(void 0, void 0, void 0, function() {
                var e, t, n, r;
                return (0, b.__generator)(this, function(i) {
                    switch (i.label) {
                        case 0:
                            if (i.trys.push([0, 3, , 4]), !(e = (0, w.getGlobalScope)())) return [3, 2];
                            return [4, e.navigator.storage.estimate()];
                        case 1:
                            return n = (t = i.sent()).usage, r = t.quota, [2, {
                                totalStorageSize: n ? Math.round(n / 1024) : 0,
                                percentOfQuota: n && r ? Math.round((n / r + Number.EPSILON) * 1e3) / 1e3 : 0,
                                usageDetails: JSON.stringify(t.usageDetails)
                            }];
                        case 2:
                            return [3, 4];
                        case 3:
                            return i.sent(), [3, 4];
                        case 4:
                            return [2, {
                                totalStorageSize: 0,
                                percentOfQuota: 0,
                                usageDetails: ""
                            }]
                    }
                })
            })
        },
        en = function(e) {
            var t = (0, b.__assign)({}, e),
                n = t.apiKey;
            return t.apiKey = "****".concat(n.substring(n.length - 4)), t
        },
        er = function() {
            return {
                flushMaxRetries: 2,
                logLevel: x.LogLevel.Warn,
                loggerProvider: new P.Logger,
                transportProvider: new R
            }
        },
        ei = function(e) {
            function t(t, n) {
                var r, i, s, o, a, l, c, u, d, g, h = this,
                    v = er();
                return (h = e.call(this, (0, b.__assign)((0, b.__assign)({
                    transportProvider: v.transportProvider,
                    loggerProvider: new K(n.loggerProvider || v.loggerProvider)
                }, n), {
                    apiKey: t
                })) || this).flushMaxRetries = void 0 !== n.flushMaxRetries && n.flushMaxRetries <= v.flushMaxRetries ? n.flushMaxRetries : v.flushMaxRetries, h.apiKey = t, h.sampleRate = n.sampleRate || 0, h.serverZone = n.serverZone || A, h.configServerUrl = n.configServerUrl, h.trackServerUrl = n.trackServerUrl, h.shouldInlineStylesheet = n.shouldInlineStylesheet, h.version = n.version, h.performanceConfig = n.performanceConfig || D, h.storeType = null != (r = n.storeType) ? r : "memory", h.applyBackgroundColorToBlockedElements = null != (i = n.applyBackgroundColorToBlockedElements) && i, h.enableUrlChangePolling = null != (s = n.enableUrlChangePolling) && s, h.urlChangePollingInterval = null != (o = n.urlChangePollingInterval) ? o : 1e3, h.captureDocumentTitle = null != (a = n.captureDocumentTitle) && a, void 0 !== n.fullSnapshotIntervalMs && (h.fullSnapshotIntervalMs = n.fullSnapshotIntervalMs), h.privacyConfig = (0, b.__assign)((0, b.__assign)({}, null != (l = n.privacyConfig) ? l : {}), {
                    unmaskSelector: Array.from(new Set((0, b.__spreadArray)([".".concat(N)], (0, b.__read)(null != (u = null == (c = n.privacyConfig) ? void 0 : c.unmaskSelector) ? u : []), !1)))
                }), n.interactionConfig && (h.interactionConfig = n.interactionConfig, h.interactionConfig.ugcFilterRules && Z(h.interactionConfig.ugcFilterRules)), n.debugMode && (h.debugMode = n.debugMode), void 0 !== n.useWebWorker ? h.useWebWorker = n.useWebWorker : (null == (d = n.experimental) ? void 0 : d.useWebWorker) !== void 0 && (h.useWebWorker = n.experimental.useWebWorker), h.captureAdoptedStyleSheets = null == (g = n.captureAdoptedStyleSheets) || g, n.crossOriginIframes && (h.crossOriginIframes = n.crossOriginIframes), h
            }
            return (0, b.__extends)(t, e), t
        }(k.Config),
        es = e.i(173625),
        eo = e.i(400475),
        ea = e.i(891307),
        el = e.i(491279),
        ec = e.i(941073),
        eu = e.i(269774),
        ed = ((n = ed || {})[n.DomContentLoaded = 0] = "DomContentLoaded", n[n.Load = 1] = "Load", n[n.FullSnapshot = 2] = "FullSnapshot", n[n.IncrementalSnapshot = 3] = "IncrementalSnapshot", n[n.Meta = 4] = "Meta", n[n.Custom = 5] = "Custom", n[n.Plugin = 6] = "Plugin", n),
        eg = ((r = eg || {})[r.Mutation = 0] = "Mutation", r[r.MouseMove = 1] = "MouseMove", r[r.MouseInteraction = 2] = "MouseInteraction", r[r.Scroll = 3] = "Scroll", r[r.ViewportResize = 4] = "ViewportResize", r[r.Input = 5] = "Input", r[r.TouchMove = 6] = "TouchMove", r[r.MediaInteraction = 7] = "MediaInteraction", r[r.StyleSheetRule = 8] = "StyleSheetRule", r[r.CanvasMutation = 9] = "CanvasMutation", r[r.Font = 10] = "Font", r[r.Log = 11] = "Log", r[r.Drag = 12] = "Drag", r[r.StyleDeclaration = 13] = "StyleDeclaration", r[r.Selection = 14] = "Selection", r[r.AdoptedStyleSheet = 15] = "AdoptedStyleSheet", r[r.CustomElement = 16] = "CustomElement", r),
        eh = ((i = eh || {})[i.MouseUp = 0] = "MouseUp", i[i.MouseDown = 1] = "MouseDown", i[i.Click = 2] = "Click", i[i.ContextMenu = 3] = "ContextMenu", i[i.DblClick = 4] = "DblClick", i[i.Focus = 5] = "Focus", i[i.Blur = 6] = "Blur", i[i.TouchStart = 7] = "TouchStart", i[i.TouchMove_Departed = 8] = "TouchMove_Departed", i[i.TouchEnd = 9] = "TouchEnd", i[i.TouchCancel = 10] = "TouchCancel", i),
        ev = ((s = ev || {})[s.Mouse = 0] = "Mouse", s[s.Pen = 1] = "Pen", s[s.Touch = 2] = "Touch", s),
        ef = ((o = ef || {})[o["2D"] = 0] = "2D", o[o.WebGL = 1] = "WebGL", o[o.WebGL2 = 2] = "WebGL2", o),
        ep = ((a = ep || {})[a.Play = 0] = "Play", a[a.Pause = 1] = "Pause", a[a.Seeked = 2] = "Seeked", a[a.VolumeChange = 3] = "VolumeChange", a[a.RateChange = 4] = "RateChange", a),
        e_ = ((l = e_ || {}).Start = "start", l.Pause = "pause", l.Resume = "resume", l.Resize = "resize", l.Finish = "finish", l.FullsnapshotRebuilded = "fullsnapshot-rebuilded", l.LoadStylesheetStart = "load-stylesheet-start", l.LoadStylesheetEnd = "load-stylesheet-end", l.SkipStart = "skip-start", l.SkipEnd = "skip-end", l.MouseInteraction = "mouse-interaction", l.EventCast = "event-cast", l.CustomEvent = "custom-event", l.Flush = "flush", l.StateChange = "state-change", l.PlayBack = "play-back", l.Destroy = "destroy", l.SeekStart = "seek-start", l.SeekEnd = "seek-end", l),
        ey = ((c = ey || {})[c.Document = 0] = "Document", c[c.DocumentType = 1] = "DocumentType", c[c.Element = 2] = "Element", c[c.Text = 3] = "Text", c[c.CDATA = 4] = "CDATA", c[c.Comment = 5] = "Comment", c),
        em = e.i(820222),
        eS = function(e, t) {
            var n = document.createDocumentFragment(),
                r = function(e) {
                    if (void 0 === e && (e = []), "string" == typeof e && (e = [e]), 0 !== (e = e.filter(function(e) {
                            try {
                                n.querySelector(e)
                            } catch (n) {
                                return t.warn('[session-replay-browser] omitting selector "'.concat(e, '" because it is invalid')), !1
                            }
                            return !0
                        })).length) return e
                };
            return e.blockSelector = r(e.blockSelector), e.maskSelector = r(e.maskSelector), e.unmaskSelector = r(e.unmaskSelector), e
        },
        eb = function() {
            function e(e, t) {
                this.localConfig = t, this.remoteConfigClient = e
            }
            return e.prototype.generateJoinedConfig = function() {
                var e, t, n, r, i, s, o;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var a, l, c, u, d, g, h, v, f, p, _, y, m, S, I, w, C, k = this;
                    return (0, b.__generator)(this, function(P) {
                        switch (P.label) {
                            case 0:
                                (a = (0, b.__assign)({}, this.localConfig)).optOut = this.localConfig.optOut, a.captureEnabled = !0, P.label = 1;
                            case 1:
                                return P.trys.push([1, 3, , 4]), [4, new Promise(function(e, t) {
                                    k.remoteConfigClient.subscribe("configs.sessionReplay", {
                                        timeout: 1500
                                    }, function(n, r) {
                                        if (k.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(r, ":"), JSON.stringify(n, null, 2)), !n) return void t(Error("No remote config received"));
                                        var i, s = n.sr_sampling_config,
                                            o = n.sr_privacy_config,
                                            c = n.sr_targeting_config,
                                            u = null == (i = a.interactionConfig) ? void 0 : i.ugcFilterRules;
                                        a.interactionConfig = n.sr_interaction_config, a.interactionConfig && u && (a.interactionConfig.ugcFilterRules = u), a.loggingConfig = n.sr_logging_config, (s || o || c) && (l = {}, s && (l.sr_sampling_config = s), o && (l.sr_privacy_config = o), c && (l.sr_targeting_config = c)), e()
                                    })
                                })];
                            case 2:
                                return P.sent(), [3, 4];
                            case 3:
                                return c = P.sent(), this.localConfig.loggerProvider.error("Failed to generate joined config: ", c), a.captureEnabled = !1, [2, {
                                    localConfig: this.localConfig,
                                    joinedConfig: a,
                                    remoteConfig: void 0
                                }];
                            case 4:
                                if (!l) return [2, {
                                    localConfig: this.localConfig,
                                    joinedConfig: a,
                                    remoteConfig: l
                                }];
                                if (u = l.sr_sampling_config, d = l.sr_privacy_config, g = l.sr_targeting_config, u && Object.keys(u).length > 0 ? (Object.prototype.hasOwnProperty.call(u, "capture_enabled") ? a.captureEnabled = u.capture_enabled : a.captureEnabled = !1, Object.prototype.hasOwnProperty.call(u, "sample_rate") && (a.sampleRate = u.sample_rate)) : (a.captureEnabled = !0, this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")), d) {
                                    h = null != (e = a.privacyConfig) ? e : {}, v = {
                                        defaultMaskLevel: null != (n = null != (t = d.defaultMaskLevel) ? t : h.defaultMaskLevel) ? n : "medium",
                                        blockSelector: [],
                                        maskSelector: [],
                                        unmaskSelector: [],
                                        maskAttributes: (0, b.__spreadArray)([], (0, b.__read)(new Set((0, b.__spreadArray)((0, b.__spreadArray)([], (0, b.__read)(null != (r = h.maskAttributes) ? r : []), !1), (0, b.__read)(null != (i = d.maskAttributes) ? i : []), !1))), !1),
                                        urlMaskLevels: (0, b.__spreadArray)((0, b.__spreadArray)([], (0, b.__read)(null != (s = d.urlMaskLevels) ? s : []), !1), (0, b.__read)(null != (o = h.urlMaskLevels) ? o : []), !1)
                                    }, f = function(e) {
                                        var t, n, r, i, s, o, a, l, c, u = {};
                                        "string" == typeof e.blockSelector && (e.blockSelector = [e.blockSelector]);
                                        try {
                                            for (var d = (0, b.__values)(null != (a = e.blockSelector) ? a : []), g = d.next(); !g.done; g = d.next()) {
                                                var h = g.value;
                                                u[h] = "block"
                                            }
                                        } catch (e) {
                                            t = {
                                                error: e
                                            }
                                        } finally {
                                            try {
                                                g && !g.done && (n = d.return) && n.call(d)
                                            } finally {
                                                if (t) throw t.error
                                            }
                                        }
                                        try {
                                            for (var v = (0, b.__values)(null != (l = e.maskSelector) ? l : []), f = v.next(); !f.done; f = v.next()) {
                                                var h = f.value;
                                                u[h] = "mask"
                                            }
                                        } catch (e) {
                                            r = {
                                                error: e
                                            }
                                        } finally {
                                            try {
                                                f && !f.done && (i = v.return) && i.call(v)
                                            } finally {
                                                if (r) throw r.error
                                            }
                                        }
                                        try {
                                            for (var p = (0, b.__values)(null != (c = e.unmaskSelector) ? c : []), _ = p.next(); !_.done; _ = p.next()) {
                                                var h = _.value;
                                                u[h] = "unmask"
                                            }
                                        } catch (e) {
                                            s = {
                                                error: e
                                            }
                                        } finally {
                                            try {
                                                _ && !_.done && (o = p.return) && o.call(p)
                                            } finally {
                                                if (s) throw s.error
                                            }
                                        }
                                        return u
                                    }, p = (0, b.__assign)((0, b.__assign)({}, f(h)), f(d));
                                    try {
                                        for (y = (_ = (0, b.__values)(Object.entries(p))).next(); !y.done; y = _.next()) S = (m = (0, b.__read)(y.value, 2))[0], I = m[1], "mask" === I ? v.maskSelector.push(S) : "block" === I ? v.blockSelector.push(S) : "unmask" === I && v.unmaskSelector.push(S)
                                    } catch (e) {
                                        w = {
                                            error: e
                                        }
                                    } finally {
                                        try {
                                            y && !y.done && (C = _.return) && C.call(_)
                                        } finally {
                                            if (w) throw w.error
                                        }
                                    }
                                    a.privacyConfig = eS(v, this.localConfig.loggerProvider)
                                }
                                return g && Object.keys(g).length > 0 && (a.targetingConfig = g), this.localConfig.loggerProvider.debug(JSON.stringify({
                                    name: "session replay joined config",
                                    config: en(a)
                                }, null, 2)), [2, {
                                    localConfig: this.localConfig,
                                    joinedConfig: a,
                                    remoteConfig: l
                                }]
                        }
                    })
                })
            }, e
        }();

    function eI(e, t) {
        return t || ("STAGING" === e ? B : "EU" === e ? W : U)
    }

    function ew(e) {
        if (e.type !== ed.IncrementalSnapshot) return !1;
        var t = e.data;
        return t.source === eg.Mutation && !t.isAttachIframe
    }
    var eC = function() {
            function e(e, t, n, r, i) {
                var s, o = this;
                this.taskQueue = [], this.pendingQueue = [], this.isProcessing = !1, this.compressEvent = function(e) {
                    var t = e.type,
                        n = e.timestamp,
                        r = e.delay,
                        i = e.data;
                    return null != r ? JSON.stringify({
                        type: t,
                        timestamp: n,
                        delay: r,
                        data: i
                    }) : JSON.stringify({
                        type: t,
                        timestamp: n,
                        data: i
                    })
                }, this.addCompressedEventToManager = function(e, t) {
                    var n = new Blob([e]).size;
                    n > 9e6 ? o.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(n / 1024), " KB exceeds maximum allowed event size. If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support.")) : o.eventsManager && o.deviceId && o.eventsManager.addEvent({
                        event: {
                            type: "replay",
                            data: e
                        },
                        sessionId: t,
                        deviceId: o.deviceId
                    })
                }, this.addCompressedEvent = function(e, t) {
                    if (o.worker) try {
                        o.worker.postMessage({
                            event: e,
                            sessionId: t
                        })
                    } catch (n) {
                        "DataCloneError" === n.name ? o.worker.postMessage(JSON.stringify({
                            event: e,
                            sessionId: t
                        })) : o.config.loggerProvider.warn("Unexpected error while posting message to worker:", n)
                    } else {
                        var n = o.compressEvent(e);
                        o.addCompressedEventToManager(n, t)
                    }
                }, this.flushQueue = function() {
                    var e;
                    for (o.pendingQueue.length > 0 && (e = o.taskQueue).push.apply(e, (0, b.__spreadArray)([], (0, b.__read)(o.mergeMutationTasks(o.pendingQueue.splice(0))), !1)); o.taskQueue.length > 0;) {
                        var t = o.taskQueue.shift();
                        if (t) {
                            var n = t.event,
                                r = t.sessionId,
                                i = o.compressEvent(n);
                            o.addCompressedEventToManager(i, r)
                        }
                    }
                    o.isProcessing = !1
                }, this.terminate = function() {
                    var e;
                    null == (e = o.worker) || e.terminate()
                };
                var a = (0, w.getGlobalScope)();
                if (this.canUseIdleCallback = a && "requestIdleCallback" in a, this.eventsManager = e, this.config = t, this.deviceId = n, this.timeout = (null == (s = t.performanceConfig) ? void 0 : s.timeout) || 2e3, this.onFullSnapshotProcessed = i, r) {
                    t.loggerProvider.log("Enabling web worker for compression");
                    try {
                        var l = new Blob([r], {
                                type: "application/javascript"
                            }),
                            c = URL.createObjectURL(l),
                            u = new Worker(c);
                        u.onerror = function(e) {
                            e.preventDefault(), t.loggerProvider.error("Worker failed, falling back to non-worker compression: ".concat(e.message, " (").concat(e.filename, ":").concat(e.lineno, ")")), u.terminate(), o.worker = void 0
                        }, u.onmessage = function(e) {
                            var t = e.data,
                                n = t.compressedEvent,
                                r = t.sessionId;
                            o.addCompressedEventToManager(n, r)
                        }, this.worker = u
                    } catch (e) {
                        t.loggerProvider.error("Failed to create worker, falling back to non-worker compression:", e)
                    }
                }
            }
            return e.prototype.scheduleIdleProcessing = function() {
                var e = this;
                this.isProcessing || (this.isProcessing = !0, requestIdleCallback(function(t) {
                    e.processQueue(t)
                }, {
                    timeout: this.timeout
                }))
            }, e.prototype.enqueueEvent = function(e, t) {
                if (e.type === ed.FullSnapshot) {
                    if (this.config.loggerProvider.debug("Processing full snapshot immediately."), this.taskQueue.length > 0 || this.pendingQueue.length > 0) {
                        var n, r, i, s, o = (0, b.__spreadArray)((0, b.__spreadArray)([], (0, b.__read)(this.taskQueue.splice(0)), !1), (0, b.__read)(this.mergeMutationTasks(this.pendingQueue.splice(0))), !1);
                        try {
                            for (var a = (0, b.__values)(o), l = a.next(); !l.done; l = a.next()) {
                                var c = l.value,
                                    u = this.compressEvent(c.event);
                                this.addCompressedEventToManager(u, c.sessionId)
                            }
                        } catch (e) {
                            n = {
                                error: e
                            }
                        } finally {
                            try {
                                l && !l.done && (r = a.return) && r.call(a)
                            } finally {
                                if (n) throw n.error
                            }
                        }
                        this.isProcessing = !1
                    }
                    var d = this.compressEvent(e);
                    this.addCompressedEventToManager(d, t), null == (i = this.onFullSnapshotProcessed) || i.call(this);
                    return
                }
                this.canUseIdleCallback && (null == (s = this.config.performanceConfig) ? void 0 : s.enabled) ? (this.config.loggerProvider.debug("Enqueuing event for processing during idle time."), this.pendingQueue.push({
                    event: e,
                    sessionId: t
                }), this.scheduleIdleProcessing()) : (this.config.loggerProvider.debug("Processing event without idle callback."), this.addCompressedEvent(e, t))
            }, e.prototype.processQueue = function(e) {
                var t, n = this;
                for (this.pendingQueue.length > 0 && (t = this.taskQueue).push.apply(t, (0, b.__spreadArray)([], (0, b.__read)(this.mergeMutationTasks(this.pendingQueue.splice(0))), !1)); this.taskQueue.length > 0 && (e.timeRemaining() > 0 || e.didTimeout);) {
                    var r = this.taskQueue.shift();
                    if (r) {
                        var i = r.event,
                            s = r.sessionId;
                        this.addCompressedEvent(i, s)
                    }
                }
                this.taskQueue.length > 0 || this.pendingQueue.length > 0 ? requestIdleCallback(function(e) {
                    n.processQueue(e)
                }, {
                    timeout: this.timeout
                }) : this.isProcessing = !1
            }, e.prototype.mergeMutationTasks = function(e) {
                if (!(null == (r = this.config.performanceConfig) ? void 0 : r.mergeMutations) || e.length <= 1) return e;
                for (var t, n, r, i = [], s = 0; s < e.length;) {
                    for (var o = e[s].sessionId, a = s + 1; a < e.length && e[a].sessionId === o;) a++;
                    var l = function(e) {
                        if (e.length <= 1) return e;
                        for (var t = [], n = 0; n < e.length;) {
                            if (!ew(e[n])) {
                                t.push(e[n]), n++;
                                continue
                            }
                            for (var r = n + 1; r < e.length && ew(e[r]);) r++;
                            t.push(r > n + 1 ? function(e) {
                                var t, n, r, i, s = e[0],
                                    o = new Map,
                                    a = new Map,
                                    l = new Map,
                                    c = new Map,
                                    u = new Map;
                                e.forEach(function(e, t) {
                                    var n, r, i, s, d = e.data;
                                    try {
                                        for (var g = (0, b.__values)(d.adds), h = g.next(); !h.done; h = g.next()) {
                                            var v = h.value;
                                            o.has(v.node.id) || o.set(v.node.id, t), a.set(v.node.id, t), u.set(v.node.id, v.parentId)
                                        }
                                    } catch (e) {
                                        n = {
                                            error: e
                                        }
                                    } finally {
                                        try {
                                            h && !h.done && (r = g.return) && r.call(g)
                                        } finally {
                                            if (n) throw n.error
                                        }
                                    }
                                    try {
                                        for (var f = (0, b.__values)(d.removes), p = f.next(); !p.done; p = f.next()) {
                                            var _ = p.value;
                                            l.has(_.id) || l.set(_.id, t), c.set(_.id, t)
                                        }
                                    } catch (e) {
                                        i = {
                                            error: e
                                        }
                                    } finally {
                                        try {
                                            p && !p.done && (s = f.return) && s.call(f)
                                        } finally {
                                            if (i) throw i.error
                                        }
                                    }
                                });
                                var d = new Set,
                                    g = new Set;
                                try {
                                    for (var h = (0, b.__values)(o), v = h.next(); !v.done; v = h.next()) {
                                        var f = (0, b.__read)(v.value, 2),
                                            p = f[0],
                                            _ = f[1],
                                            y = l.get(p);
                                        if (void 0 !== y) {
                                            var m = a.get(p),
                                                S = c.get(p);
                                            !(m >= S) && (_ < y ? d.add(p) : y < _ && g.add(p))
                                        }
                                    }
                                } catch (e) {
                                    t = {
                                        error: e
                                    }
                                } finally {
                                    try {
                                        v && !v.done && (n = h.return) && n.call(h)
                                    } finally {
                                        if (t) throw t.error
                                    }
                                }
                                var I = new Set;
                                if (d.size > 0 || g.size > 0)
                                    for (var w = !0; w;) {
                                        w = !1;
                                        try {
                                            for (var C = (r = void 0, (0, b.__values)(u)), k = C.next(); !k.done; k = C.next()) {
                                                var P = (0, b.__read)(k.value, 2),
                                                    E = P[0],
                                                    R = P[1];
                                                if (!d.has(E) && !g.has(E) && !I.has(E) && (d.has(R) || g.has(R) || I.has(R))) {
                                                    var x = l.get(E),
                                                        T = o.get(E);
                                                    void 0 !== x && void 0 !== T && x < T ? g.add(E) : void 0 !== x && void 0 !== T && x === T ? I.add(E) : d.add(E), w = !0
                                                }
                                            }
                                        } catch (e) {
                                            r = {
                                                error: e
                                            }
                                        } finally {
                                            try {
                                                k && !k.done && (i = C.return) && i.call(C)
                                            } finally {
                                                if (r) throw r.error
                                            }
                                        }
                                    }
                                var M = d.size > 0 || g.size > 0 || I.size > 0,
                                    O = [];
                                e.forEach(function(e, t) {
                                    var n, r;
                                    try {
                                        for (var i = (0, b.__values)(e.data.removes), s = i.next(); !s.done; s = i.next()) {
                                            var a = s.value;
                                            !(d.has(a.id) || g.has(a.id) && t >= o.get(a.id)) && (I.has(a.id) && (d.has(a.parentId) || g.has(a.parentId) || I.has(a.parentId)) || O.push(a))
                                        }
                                    } catch (e) {
                                        n = {
                                            error: e
                                        }
                                    } finally {
                                        try {
                                            s && !s.done && (r = i.return) && r.call(i)
                                        } finally {
                                            if (n) throw n.error
                                        }
                                    }
                                });
                                var L = e.flatMap(function(e) {
                                        return e.data.adds
                                    }),
                                    A = e.flatMap(function(e) {
                                        return e.data.texts
                                    }),
                                    D = e.flatMap(function(e) {
                                        return e.data.attributes
                                    }),
                                    F = {
                                        source: eg.Mutation,
                                        removes: O,
                                        adds: M ? L.filter(function(e) {
                                            return !d.has(e.node.id) && !g.has(e.node.id) && !I.has(e.node.id)
                                        }) : L,
                                        texts: M ? A.filter(function(e) {
                                            return !d.has(e.id) && !g.has(e.id) && !I.has(e.id)
                                        }) : A,
                                        attributes: M ? D.filter(function(e) {
                                            return !d.has(e.id) && !g.has(e.id) && !I.has(e.id)
                                        }) : D
                                    };
                                return (0, b.__assign)((0, b.__assign)({}, s), {
                                    data: F
                                })
                            }(e.slice(n, r)) : e[n]), n = r
                        }
                        return t
                    }(e.slice(s, a).map(function(e) {
                        return e.event
                    }));
                    try {
                        for (var c = (t = void 0, (0, b.__values)(l)), u = c.next(); !u.done; u = c.next()) {
                            var d = u.value;
                            i.push({
                                event: d,
                                sessionId: o
                            })
                        }
                    } catch (e) {
                        t = {
                            error: e
                        }
                    } finally {
                        try {
                            u && !u.done && (n = c.return) && n.call(c)
                        } finally {
                            if (t) throw t.error
                        }
                    }
                    s = a
                }
                return i
            }, e
        }(),
        ek = e.i(499875),
        eP = "Session replay event batch rejected due to exceeded retry count",
        eE = "Failed to store session replay events in IndexedDB",
        eR = "Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session",
        ex = "1.42.3",
        eT = function() {
            function e(e) {
                var t = e.trackServerUrl,
                    n = e.loggerProvider,
                    r = e.payloadBatcher,
                    i = e.workerScript,
                    s = this;
                if (this.storageKey = "", this.retryTimeout = 1e3, this.scheduled = null, this.queue = [], this.sendIdCounter = 0, this.pendingWorkerRequests = new Map, this.flushPauseUntilMs = 0, this.killedSessions = new Set, this.loggerProvider = n, this.payloadBatcher = r || function(e) {
                        return e
                    }, this.trackServerUrl = t, i) try {
                    var o = new Blob([i], {
                            type: "application/javascript"
                        }),
                        a = URL.createObjectURL(o),
                        l = new Worker(a);
                    l.onerror = function(e) {
                        var t, r;
                        e.preventDefault(), n.error("Track destination worker failed, falling back to main-thread sending: ".concat(e.message, " (").concat(e.filename, ":").concat(e.lineno, ")")), l.terminate(), s.worker = void 0;
                        try {
                            for (var i = (0, b.__values)(s.pendingWorkerRequests), o = i.next(); !o.done; o = i.next()) {
                                var a = (0, b.__read)(o.value, 2)[1];
                                n.warn("Session replay event send failed due to worker crash: ".concat(e.message)), a.resolve()
                            }
                        } catch (e) {
                            t = {
                                error: e
                            }
                        } finally {
                            try {
                                o && !o.done && (r = i.return) && r.call(i)
                            } finally {
                                if (t) throw t.error
                            }
                        }
                        s.pendingWorkerRequests.clear()
                    }, l.onmessage = function(e) {
                        var t = e.data;
                        if ("log" === t.type) n.log(t.message);
                        else if ("warn" === t.type) n.warn(t.message);
                        else if ("payload_too_large" === t.type) {
                            var r = s.pendingWorkerRequests.get(t.id);
                            r && (s.handlePayloadTooLargeResponse(r.context, t.isWaf), r.resolve(), s.pendingWorkerRequests.delete(t.id))
                        } else if ("complete" === t.type) {
                            var i = s.pendingWorkerRequests.get(t.id);
                            i && (void 0 !== t.skipCode && s.applyServerDirective(i.context.sessionId, t.skipCode), s.completeRequest({
                                context: i.context
                            }), i.resolve(), s.pendingWorkerRequests.delete(t.id))
                        }
                    }, this.worker = l
                } catch (e) {
                    n.error("Failed to create track destination worker, falling back to main-thread sending:", e)
                }
            }
            return e.prototype.sendEventsList = function(e) {
                this.addToQueue((0, b.__assign)((0, b.__assign)({}, e), {
                    attempts: 0,
                    timeout: 0
                }))
            }, e.prototype.sendBeacon = function(e) {
                var t, n, r = e.events,
                    i = e.sessionId,
                    s = e.deviceId,
                    o = e.apiKey,
                    a = e.serverZone,
                    l = function(e) {
                        return new Blob([e]).size
                    },
                    c = r,
                    u = JSON.stringify({
                        version: 2,
                        events: c
                    });
                if (l(u) > 65536) {
                    for (var d = 0, g = c.length; d < g;) {
                        var h = Math.floor((d + g + 1) / 2);
                        65536 >= l(JSON.stringify({
                            version: 2,
                            events: c.slice(0, h)
                        })) ? d = h : g = h - 1
                    }
                    u = JSON.stringify({
                        version: 2,
                        events: c = c.slice(0, d)
                    }), this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(r.length, " to ").concat(c.length, " events"))
                }
                if (0 !== c.length) {
                    var v = new URLSearchParams({
                            device_id: s,
                            session_id: String(i),
                            type: "replay",
                            api_key: o
                        }),
                        f = "".concat(eI(a, this.trackServerUrl), "?").concat(v.toString()),
                        p = (0, w.getGlobalScope)();
                    try {
                        var _ = new Blob([u], {
                                type: "application/json"
                            }),
                            y = null == (n = null == (t = null == p ? void 0 : p.navigator) ? void 0 : t.sendBeacon) ? void 0 : n.call(t, f, _);
                        !1 === y && this.loggerProvider.warn("sendBeacon failed to queue session replay payload")
                    } catch (e) {}
                }
            }, e.prototype.addToQueue = function() {
                for (var e = this, t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
                t.filter(function(t) {
                    return e.killedSessions.has(t.sessionId) ? (e.completeRequest({
                        context: t,
                        err: eR
                    }), !1) : t.attempts < (t.flushMaxRetries || 0) ? (t.attempts += 1, !0) : (e.completeRequest({
                        context: t,
                        err: eP
                    }), !1)
                }).forEach(function(t) {
                    e.queue = e.queue.concat(t), e.schedule(0)
                })
            }, e.prototype.schedule = function(e) {
                var t = this;
                if (!this.scheduled) {
                    var n = this.flushPauseUntilMs - Date.now(),
                        r = n > e ? n : e;
                    this.scheduled = setTimeout(function() {
                        t.flush(!0).then(function() {
                            t.queue.length > 0 && t.schedule(e)
                        })
                    }, r)
                }
            }, e.prototype.flush = function(e) {
                return void 0 === e && (e = !1), (0, b.__awaiter)(this, void 0, void 0, function() {
                    var t, n, r, i, s, o;
                    return (0, b.__generator)(this, function(a) {
                        switch (a.label) {
                            case 0:
                                t = this.queue, this.queue = [], this.scheduled && (clearTimeout(this.scheduled), this.scheduled = null), a.label = 1;
                            case 1:
                                a.trys.push([1, 6, 7, 8]), r = (n = (0, b.__values)(t)).next(), a.label = 2;
                            case 2:
                                if (r.done) return [3, 5];
                                return i = r.value, [4, this.send(i, e)];
                            case 3:
                                a.sent(), a.label = 4;
                            case 4:
                                return r = n.next(), [3, 2];
                            case 5:
                                return [3, 8];
                            case 6:
                                return s = {
                                    error: a.sent()
                                }, [3, 8];
                            case 7:
                                try {
                                    r && !r.done && (o = n.return) && o.call(n)
                                } finally {
                                    if (s) throw s.error
                                }
                                return [7];
                            case 8:
                                return [2]
                        }
                    })
                })
            }, e.prototype.send = function(e, t) {
                return void 0 === t && (t = !0), (0, b.__awaiter)(this, void 0, void 0, function() {
                    var n, r, i, s;
                    return (0, b.__generator)(this, function(o) {
                        return this.killedSessions.has(e.sessionId) ? [2, this.completeRequest({
                            context: e,
                            err: eR
                        })] : (n = e.apiKey) ? (r = e.deviceId) ? 0 === (i = this.payloadBatcher({
                            version: 1,
                            events: e.events
                        })).events.length ? (this.completeRequest({
                            context: e
                        }), [2]) : (s = this.worker) ? [2, this.sendViaWorker(s, e, i, t)] : [2, this.sendOnMainThread(n, r, e, i, t)] : [2, this.completeRequest({
                            context: e,
                            err: "Session replay event batch not sent due to missing device ID"
                        })] : [2, this.completeRequest({
                            context: e,
                            err: "Session replay event batch not sent due to missing api key"
                        })]
                    })
                })
            }, e.prototype.sendViaWorker = function(e, t, n, r) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var i, s = this;
                    return (0, b.__generator)(this, function(o) {
                        return i = "".concat(++this.sendIdCounter), [2, new Promise(function(o) {
                            var a;
                            s.pendingWorkerRequests.set(i, {
                                context: t,
                                resolve: o
                            }), e.postMessage({
                                type: "send",
                                id: i,
                                payload: n,
                                useRetry: r,
                                context: {
                                    apiKey: t.apiKey,
                                    deviceId: t.deviceId,
                                    sessionId: t.sessionId,
                                    events: t.events,
                                    eventType: t.type,
                                    flushMaxRetries: null != (a = t.flushMaxRetries) ? a : 0,
                                    sampleRate: t.sampleRate,
                                    serverZone: t.serverZone,
                                    trackServerUrl: s.trackServerUrl,
                                    version: t.version,
                                    currentUrl: X(),
                                    sdkVersion: ex
                                }
                            })
                        })]
                    })
                })
            }, e.prototype.sendOnMainThread = function(e, t, n, r, i) {
                var s, o, a, l, c, u, d;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var g, h, v, f, p, _, y, m, S, I, C, k, P, E, R;
                    return (0, b.__generator)(this, function(x) {
                        switch (x.label) {
                            case 0:
                                g = X(), h = ex, v = n.sampleRate, f = new URLSearchParams({
                                    device_id: t,
                                    session_id: "".concat(n.sessionId),
                                    type: "".concat(n.type)
                                }), p = "".concat(null != (o = null == (s = n.version) ? void 0 : s.type) ? o : "standalone", "/").concat(null != (l = null == (a = n.version) ? void 0 : a.version) ? l : h), x.label = 1;
                            case 1:
                                if (x.trys.push([1, 13, , 14]), _ = JSON.stringify(r), !((y = (0, w.getGlobalScope)()) && "CompressionStream" in y)) return [3, 3];
                                return [4, function(e, t) {
                                    return (0, b.__awaiter)(this, void 0, void 0, function() {
                                        var n, r, i, s, o, a, l, c, u, d, g, h, v = this;
                                        return (0, b.__generator)(this, function(f) {
                                            switch (f.label) {
                                                case 0:
                                                    return f.trys.push([0, 4, , 5]), r = (n = new t.CompressionStream("gzip")).writable.getWriter(), i = n.readable.getReader(), s = [], o = (0, b.__awaiter)(v, void 0, void 0, function() {
                                                        var e, t, n;
                                                        return (0, b.__generator)(this, function(r) {
                                                            switch (r.label) {
                                                                case 0:
                                                                    return [4, i.read()];
                                                                case 1:
                                                                    if (t = (e = r.sent()).done, n = e.value, t) return [3, 3];
                                                                    s.push(n), r.label = 2;
                                                                case 2:
                                                                    return [3, 0];
                                                                case 3:
                                                                    return [2]
                                                            }
                                                        })
                                                    }), [4, r.write(new TextEncoder().encode(e))];
                                                case 1:
                                                    return f.sent(), [4, r.close()];
                                                case 2:
                                                    return f.sent(), [4, o];
                                                case 3:
                                                    f.sent(), a = new Uint8Array(s.reduce(function(e, t) {
                                                        return e + t.length
                                                    }, 0)), l = 0;
                                                    try {
                                                        for (u = (c = (0, b.__values)(s)).next(); !u.done; u = c.next()) d = u.value, a.set(d, l), l += d.length
                                                    } catch (e) {
                                                        g = {
                                                            error: e
                                                        }
                                                    } finally {
                                                        try {
                                                            u && !u.done && (h = c.return) && h.call(c)
                                                        } finally {
                                                            if (g) throw g.error
                                                        }
                                                    }
                                                    return [2, a];
                                                case 4:
                                                    return f.sent(), [2, null];
                                                case 5:
                                                    return [2]
                                            }
                                        })
                                    })
                                }(_, y)];
                            case 2:
                                return S = x.sent(), [3, 4];
                            case 3:
                                S = null, x.label = 4;
                            case 4:
                                return I = (m = S) ? m.byteLength : new Blob([_]).size, C = {
                                    headers: (0, b.__assign)({
                                        "Content-Type": "application/json",
                                        Accept: "*/*",
                                        Authorization: "Bearer ".concat(e),
                                        "X-Client-Version": h,
                                        "X-Client-Library": p,
                                        "X-Client-Url": g.substring(0, 1e3),
                                        "X-Client-Sample-Rate": "".concat(v),
                                        "X-Sampling-Hash-Alg": "xxhash32"
                                    }, m ? {
                                        "Content-Encoding": "gzip"
                                    } : {}),
                                    body: null != m ? m : _,
                                    method: "POST",
                                    keepalive: I <= 65536
                                }, [4, fetch("".concat(eI(n.serverZone, this.trackServerUrl), "?").concat(f.toString()), C)];
                            case 5:
                                if (null === (k = x.sent())) return this.completeRequest({
                                    context: n,
                                    err: "Unexpected error occurred"
                                }), [2];
                                if (k.status >= 200 && k.status < 300 && (P = null != (d = null == (u = null == (c = k.headers) ? void 0 : c.get) ? void 0 : u.call(c, "X-Session-Replay-Event-Skipped")) ? d : null, this.applyServerDirective(n.sessionId, P)), i) return [3, 6];
                                E = "";
                                try {
                                    E = JSON.stringify(k.body, null, 2)
                                } catch (e) {}
                                return this.completeRequest({
                                    context: n,
                                    success: "".concat(k.status, ": ").concat(E)
                                }), [3, 12];
                            case 6:
                                if (E = "", 413 !== k.status) return [3, 10];
                                x.label = 7;
                            case 7:
                                return x.trys.push([7, 9, , 10]), [4, k.text()];
                            case 8:
                                return E = x.sent(), [3, 10];
                            case 9:
                                return x.sent(), [3, 10];
                            case 10:
                                return [4, this.handleReponse(k.status, n, E)];
                            case 11:
                                x.sent(), x.label = 12;
                            case 12:
                                return [3, 14];
                            case 13:
                                return R = x.sent(), this.completeRequest({
                                    context: n,
                                    err: R
                                }), [3, 14];
                            case 14:
                                return [2]
                        }
                    })
                })
            }, e.prototype.handleReponse = function(e, t, n) {
                return void 0 === n && (n = ""), (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(r) {
                        switch (r.label) {
                            case 0:
                                switch (new E.BaseTransport().buildStatus(e)) {
                                    case ek.Status.Success:
                                        return [3, 1];
                                    case ek.Status.Failed:
                                    case ek.Status.Timeout:
                                    case ek.Status.RateLimit:
                                        return [3, 2];
                                    case ek.Status.PayloadTooLarge:
                                        return [3, 4]
                                }
                                return [3, 5];
                            case 1:
                                return this.handleSuccessResponse(t), [3, 8];
                            case 2:
                                return [4, this.handleOtherResponse(t)];
                            case 3:
                            case 6:
                                return r.sent(), [3, 8];
                            case 4:
                                return this.handlePayloadTooLargeResponse(t, j.test(n)), [3, 8];
                            case 5:
                                if (499 !== e) return [3, 7];
                                return [4, this.handleOtherResponse(t)];
                            case 7:
                                this.completeRequest({
                                    context: t,
                                    err: "Network error occurred, event batch rejected"
                                }), r.label = 8;
                            case 8:
                                return [2]
                        }
                    })
                })
            }, e.prototype.handlePayloadTooLargeResponse = function(e, t) {
                var n = t ? "WAF (compressed payload too large)" : "server (event too large)",
                    r = Math.round(e.events.reduce(function(e, t) {
                        return e + t.length
                    }, 0) / 1024);
                if (!t) return void this.completeRequest({
                    context: e,
                    err: "Session replay event batch dropped: ".concat(n, " rejected payload (").concat(e.events.length, " events, ").concat(r, " KB) — not retrying non-WAF 413")
                });
                if (1 === e.events.length) return void this.completeRequest({
                    context: e,
                    err: "Session replay event dropped: single event (".concat(r, " KB, 1 event) rejected by ").concat(n, " — cannot split further")
                });
                this.loggerProvider.warn("Session replay event batch rejected by ".concat(n, " (").concat(e.events.length, " events, ").concat(r, " KB total) — splitting and retrying")), e.onComplete();
                var i = function() {
                        return Promise.resolve()
                    },
                    s = Math.floor(e.events.length / 2);
                this.sendEventsList((0, b.__assign)((0, b.__assign)({}, e), {
                    events: e.events.slice(0, s),
                    onComplete: i
                })), this.sendEventsList((0, b.__assign)((0, b.__assign)({}, e), {
                    events: e.events.slice(s),
                    onComplete: i
                }))
            }, e.prototype.handleSuccessResponse = function(e) {
                var t = Math.round(new Blob(e.events).size / 1024);
                this.completeRequest({
                    context: e,
                    success: "Session replay event batch tracked successfully for session id ".concat(e.sessionId, ", size of events: ").concat(t, " KB")
                })
            }, e.prototype.handleOtherResponse = function(e) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var t;
                    return (0, b.__generator)(this, function(n) {
                        switch (n.label) {
                            case 0:
                                if (t = Math.random() * e.attempts * this.retryTimeout, e.attempts++, e.attempts > (e.flushMaxRetries || 0)) return this.completeRequest({
                                    context: e,
                                    err: eP
                                }), [2];
                                return [4, new Promise(function(e) {
                                    return setTimeout(e, t)
                                })];
                            case 1:
                                return n.sent(), [4, this.send(e, !0)];
                            case 2:
                                return n.sent(), [2]
                        }
                    })
                })
            }, e.prototype.completeRequest = function(e) {
                var t = e.context,
                    n = e.err,
                    r = e.success;
                t.onComplete(), n ? this.loggerProvider.warn(n) : r && this.loggerProvider.log(r)
            }, e.prototype.applyServerDirective = function(e, t) {
                if (null === t) {
                    this.flushPauseUntilMs = 0;
                    return
                }
                if ("429" === t) {
                    var n = this.flushPauseUntilMs > Date.now();
                    this.flushPauseUntilMs = Date.now() + 6e4, n || this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(60, "s"));
                    return
                }("4005" === t || "4004" === t) && this.killSession(e, t)
            }, e.prototype.killSession = function(e, t) {
                if (!this.killedSessions.has(e)) {
                    if (this.killedSessions.add(e), this.killedSessions.size > 256) try {
                        for (var n, r, i, s, o = (0, b.__values)(this.killedSessions), a = o.next(); !a.done; a = o.next()) {
                            var l = a.value;
                            this.killedSessions.delete(l);
                            break
                        }
                    } catch (e) {
                        n = {
                            error: e
                        }
                    } finally {
                        try {
                            a && !a.done && (r = o.return) && r.call(o)
                        } finally {
                            if (n) throw n.error
                        }
                    }
                    this.loggerProvider.log("Session replay capture stopped for session ".concat(e, " by server directive ").concat(t, "; remaining events will be dropped"));
                    var c = [];
                    try {
                        for (var u = (0, b.__values)(this.queue), d = u.next(); !d.done; d = u.next()) {
                            var g = d.value;
                            g.sessionId === e ? this.completeRequest({
                                context: g,
                                err: eR
                            }) : c.push(g)
                        }
                    } catch (e) {
                        i = {
                            error: e
                        }
                    } finally {
                        try {
                            d && !d.done && (s = u.return) && s.call(u)
                        } finally {
                            if (i) throw i.error
                        }
                    }
                    this.queue = c
                }
            }, e
        }(),
        eM = e.i(252804),
        eO = function() {
            function e(e) {
                var t, n, r, i = this;
                this.minInterval = 500, this.maxInterval = 1e4, this.maxPersistedEventsSize = 7e5, this.interval = this.minInterval, this._timeAtLastSplit = Date.now(), this.shouldSplitEventsList = function(e, t) {
                    var n = i.getStringSize(t);
                    return i.getEventsArraySize(e) + n >= i.maxPersistedEventsSize || Date.now() - i.timeAtLastSplit > i.interval && !!e.length && (i.interval = Math.min(i.maxInterval, i.interval + i.minInterval), i._timeAtLastSplit = Date.now(), !0)
                }, this.loggerProvider = e.loggerProvider, this.minInterval = null != (t = e.minInterval) ? t : this.minInterval, this.maxInterval = null != (n = e.maxInterval) ? n : this.maxInterval, this.maxPersistedEventsSize = null != (r = e.maxPersistedEventsSize) ? r : this.maxPersistedEventsSize
            }
            return Object.defineProperty(e.prototype, "timeAtLastSplit", {
                get: function() {
                    return this._timeAtLastSplit
                },
                enumerable: !1,
                configurable: !0
            }), e.prototype.getStringSize = function(e) {
                for (var t = 0, n = 0; n < e.length; n++) {
                    var r = e.charCodeAt(n);
                    if (r <= 127) t++;
                    else if (r <= 2047) t += 2;
                    else if (r >= 55296 && r <= 56319) {
                        var i = n + 1 < e.length ? e.charCodeAt(n + 1) : NaN;
                        i >= 56320 && i <= 57343 ? (t += 4, n++) : t += 3
                    } else t += 3
                }
                return t
            }, e.prototype.getEventsArraySize = function(e) {
                var t, n, r = 0;
                try {
                    for (var i = (0, b.__values)(e), s = i.next(); !s.done; s = i.next()) {
                        var o = s.value;
                        r += this.getStringSize(o)
                    }
                } catch (e) {
                    t = {
                        error: e
                    }
                } finally {
                    try {
                        s && !s.done && (n = i.return) && n.call(i)
                    } finally {
                        if (t) throw t.error
                    }
                }
                return r + (2 + Math.max(0, e.length - 1) + 2 * e.length)
            }, e
        }(),
        eL = function(e, t, n) {
            "object" == typeof n && null !== n && "AbortError" === n.name ? e.debug(t) : e.warn(t)
        },
        eA = "sessionCurrentSequence",
        eD = "sequencesToSend";

    function eF(e, t, n) {
        var r = setTimeout(n, t);
        return e.then(function() {
                return clearTimeout(r)
            }, function() {
                return clearTimeout(r)
            }),
            function() {
                return clearTimeout(r)
            }
    }
    var eq = function(e) {
            var t, n;
            return e.objectStoreNames.contains(eA) || (n = e.createObjectStore(eA, {
                keyPath: "sessionId"
            })), e.objectStoreNames.contains(eD) || (t = e.createObjectStore(eD, {
                keyPath: "sequenceId",
                autoIncrement: !0
            })).createIndex("sessionId", "sessionId"), {
                sequencesStore: t,
                currentSequenceStore: n
            }
        },
        eN = function(e) {
            function t(t) {
                var n, r = this;
                return (r = e.call(this, t) || this).consecutiveFailures = 0, r.hasTriggeredFallback = !1, r.getSequencesToSend = function() {
                    return (0, b.__awaiter)(r, void 0, void 0, function() {
                        var e, t, n, r, i, s, o, a, l, c, u = this;
                        return (0, b.__generator)(this, function(d) {
                            switch (d.label) {
                                case 0:
                                    e = !1, t = !1, d.label = 1;
                                case 1:
                                    return d.trys.push([1, 6, , 7]), n = [], (r = this.db.transaction("sequencesToSend")).done.catch(function(n) {
                                        e || t || (eL(u.loggerProvider, "".concat(eE, ": ").concat(n), n), u.recordFailure())
                                    }), i = eF(r.done, 5e3, function() {
                                        e || t || (t = !0, eL(u.loggerProvider, "".concat(eE, ": transaction timed out")), u.recordFailure())
                                    }), [4, r.store.openCursor()];
                                case 2:
                                    s = d.sent(), d.label = 3;
                                case 3:
                                    if (!s) return [3, 5];
                                    return a = (o = s.value).sessionId, l = o.events, n.push({
                                        events: l,
                                        sequenceId: s.key,
                                        sessionId: a
                                    }), [4, s.continue()];
                                case 4:
                                    return s = d.sent(), [3, 3];
                                case 5:
                                    return this.recordSuccess(), i(), [2, n];
                                case 6:
                                    return c = d.sent(), t || (e = !0, eL(this.loggerProvider, "".concat(eE, ": ").concat(c), c), this.recordFailure()), [3, 7];
                                case 7:
                                    return [2, void 0]
                            }
                        })
                    })
                }, r.storeCurrentSequence = function(e) {
                    return (0, b.__awaiter)(r, void 0, void 0, function() {
                        var t, n, r, i, s, o, a, l, c = this;
                        return (0, b.__generator)(this, function(u) {
                            switch (u.label) {
                                case 0:
                                    t = !1, n = !1, u.label = 1;
                                case 1:
                                    return u.trys.push([1, 5, , 6]), (r = this.db.transaction([eA, eD], "readwrite")).done.catch(function(e) {
                                        t || n || (eL(c.loggerProvider, "".concat(eE, ": ").concat(e), e), c.recordFailure())
                                    }), i = eF(r.done, 5e3, function() {
                                        t || n || (n = !0, eL(c.loggerProvider, "".concat(eE, ": transaction timed out")), c.recordFailure())
                                    }), [4, r.objectStore(eA).get(e)];
                                case 2:
                                    if (!(s = u.sent()) || s.tabId && s.tabId !== this.tabId || 0 === s.events.length) return i(), [2, void 0];
                                    return [4, r.objectStore(eD).put({
                                        sessionId: e,
                                        events: s.events,
                                        tabId: this.tabId
                                    })];
                                case 3:
                                    return o = u.sent(), [4, r.objectStore(eA).put({
                                        sessionId: e,
                                        events: [],
                                        tabId: this.tabId
                                    })];
                                case 4:
                                    return u.sent(), this.recordSuccess(), i(), s.tabId, a = (0, b.__rest)(s, ["tabId"]), [2, (0, b.__assign)((0, b.__assign)({}, a), {
                                        sessionId: e,
                                        sequenceId: o
                                    })];
                                case 5:
                                    return l = u.sent(), n || (t = !0, eL(this.loggerProvider, "".concat(eE, ": ").concat(l), l), this.recordFailure()), [3, 6];
                                case 6:
                                    return [2, void 0]
                            }
                        })
                    })
                }, r.addEventToCurrentSequence = function(e, t) {
                    return (0, b.__awaiter)(r, void 0, void 0, function() {
                        var n, r, i, s, o, a, l, c, u, d = this;
                        return (0, b.__generator)(this, function(g) {
                            switch (g.label) {
                                case 0:
                                    n = !1, r = !1, g.label = 1;
                                case 1:
                                    return g.trys.push([1, 13, , 14]), (i = this.db.transaction([eA, eD], "readwrite")).done.catch(function(e) {
                                        n || r || (eL(d.loggerProvider, "".concat(eE, ": ").concat(e), e), d.recordFailure())
                                    }), s = eF(i.done, 5e3, function() {
                                        n || r || (r = !0, eL(d.loggerProvider, "".concat(eE, ": transaction timed out")), d.recordFailure())
                                    }), [4, i.objectStore(eA).get(e)];
                                case 2:
                                    if (!((null == (o = g.sent()) ? void 0 : o.tabId) && o.tabId !== this.tabId)) return [3, 6];
                                    if (!(o.events.length > 0)) return [3, 4];
                                    return [4, i.objectStore(eD).put({
                                        sessionId: e,
                                        events: o.events,
                                        tabId: o.tabId
                                    })];
                                case 3:
                                    g.sent(), g.label = 4;
                                case 4:
                                    return [4, i.objectStore(eA).put({
                                        sessionId: e,
                                        events: [t],
                                        tabId: this.tabId
                                    })];
                                case 5:
                                case 7:
                                case 9:
                                    return g.sent(), this.recordSuccess(), s(), [2, void 0];
                                case 6:
                                    if (a = o) return [3, 8];
                                    return [4, i.objectStore(eA).put({
                                        sessionId: e,
                                        events: [t],
                                        tabId: this.tabId
                                    })];
                                case 8:
                                    if (this.shouldSplitEventsList(a.events, t)) return [3, 10];
                                    return [4, i.objectStore(eA).put({
                                        sessionId: e,
                                        events: a.events.concat(t),
                                        tabId: this.tabId
                                    })];
                                case 10:
                                    return l = a.events, [4, i.objectStore(eA).put({
                                        sessionId: e,
                                        events: [t],
                                        tabId: this.tabId
                                    })];
                                case 11:
                                    return g.sent(), [4, i.objectStore(eD).put({
                                        sessionId: e,
                                        events: l,
                                        tabId: this.tabId
                                    })];
                                case 12:
                                    return c = g.sent(), this.recordSuccess(), s(), [2, {
                                        events: l,
                                        sessionId: e,
                                        sequenceId: c
                                    }];
                                case 13:
                                    return u = g.sent(), r || (n = !0, eL(this.loggerProvider, "".concat(eE, ": ").concat(u), u), this.recordFailure()), [3, 14];
                                case 14:
                                    return [2, void 0]
                            }
                        })
                    })
                }, r.storeSendingEvents = function(e, t) {
                    return (0, b.__awaiter)(r, void 0, void 0, function() {
                        var n, r;
                        return (0, b.__generator)(this, function(i) {
                            switch (i.label) {
                                case 0:
                                    return i.trys.push([0, 2, , 3]), [4, this.db.put(eD, {
                                        sessionId: e,
                                        events: t,
                                        tabId: this.tabId
                                    })];
                                case 1:
                                    return n = i.sent(), this.recordSuccess(), [2, n];
                                case 2:
                                    return r = i.sent(), eL(this.loggerProvider, "".concat(eE, ": ").concat(r), r), this.recordFailure(), [3, 3];
                                case 3:
                                    return [2, void 0]
                            }
                        })
                    })
                }, r.cleanUpSessionEventsStore = function(e, t) {
                    return (0, b.__awaiter)(r, void 0, void 0, function() {
                        var e;
                        return (0, b.__generator)(this, function(n) {
                            switch (n.label) {
                                case 0:
                                    if (!t) return [2];
                                    n.label = 1;
                                case 1:
                                    return n.trys.push([1, 3, , 4]), [4, this.db.delete(eD, t)];
                                case 2:
                                    return n.sent(), this.recordSuccess(), [3, 4];
                                case 3:
                                    return e = n.sent(), eL(this.loggerProvider, "".concat(eE, ": ").concat(e), e), this.recordFailure(), [3, 4];
                                case 4:
                                    return [2]
                            }
                        })
                    })
                }, r.db = t.db, r.tabId = t.tabId, r.onPersistentFailure = t.onPersistentFailure, r.consecutiveFailureThreshold = null != (n = t.consecutiveFailureThreshold) ? n : 1, r
            }
            return (0, b.__extends)(t, e), t.prototype.recordFailure = function() {
                var e;
                this.consecutiveFailures++, !this.hasTriggeredFallback && this.consecutiveFailures >= this.consecutiveFailureThreshold && (this.hasTriggeredFallback = !0, null == (e = this.onPersistentFailure) || e.call(this))
            }, t.prototype.recordSuccess = function() {
                this.consecutiveFailures = 0
            }, t.new = function(e, n) {
                var r;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var i, s, o, a;
                    return (0, b.__generator)(this, function(l) {
                        switch (l.label) {
                            case 0:
                                var c;
                                return l.trys.push([0, 2, , 3]), i = "replay" === e ? "" : "_".concat(e), [4, (c = "".concat(n.apiKey.substring(0, 10), "_amp_session_replay_events").concat(i), (0, b.__awaiter)(void 0, void 0, void 0, function() {
                                    return (0, b.__generator)(this, function(e) {
                                        switch (e.label) {
                                            case 0:
                                                var t;
                                                return [4, (t = (0, eM.openDB)(c, 1, {
                                                    upgrade: eq
                                                }), new Promise(function(e, n) {
                                                    var r = setTimeout(function() {
                                                        return n(Error("".concat("IDB openDB timed out", " after ").concat(2e3, "ms")))
                                                    }, 2e3);
                                                    t.then(function(t) {
                                                        clearTimeout(r), e(t)
                                                    }, function(e) {
                                                        clearTimeout(r), n(e)
                                                    })
                                                }))];
                                            case 1:
                                                return [2, e.sent()]
                                        }
                                    })
                                }))];
                            case 1:
                                return s = l.sent(), o = null != (r = n.tabId) ? r : function() {
                                    try {
                                        return crypto.randomUUID()
                                    } catch (e) {
                                        return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
                                            var t = 16 * Math.random() | 0;
                                            return ("x" === e ? t : 3 & t | 8).toString(16)
                                        })
                                    }
                                }(), [2, new t((0, b.__assign)((0, b.__assign)({}, n), {
                                    db: s,
                                    tabId: o
                                }))];
                            case 2:
                                return a = l.sent(), eL(n.loggerProvider, "".concat(eE, ": ").concat(a), a), [3, 3];
                            case 3:
                                return [2]
                        }
                    })
                })
            }, t.prototype.getCurrentSequenceEvents = function(e) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var t, n, r, i, s, o, a;
                    return (0, b.__generator)(this, function(l) {
                        switch (l.label) {
                            case 0:
                                if (!e) return [3, 2];
                                return [4, this.db.get("sessionCurrentSequence", e)];
                            case 1:
                                if (!(t = l.sent()) || t.tabId && t.tabId !== this.tabId) return [2, void 0];
                                return t.tabId, [2, [n = (0, b.__rest)(t, ["tabId"])]];
                            case 2:
                                r = [], l.label = 3;
                            case 3:
                                return l.trys.push([3, 8, 9, 10]), [4, this.db.getAll("sessionCurrentSequence")];
                            case 4:
                                s = (i = b.__values.apply(void 0, [l.sent()])).next(), l.label = 5;
                            case 5:
                                if (s.done) return [3, 7];
                                if ((t = s.value).tabId && t.tabId !== this.tabId) return [3, 6];
                                t.tabId, n = (0, b.__rest)(t, ["tabId"]), r.push(n), l.label = 6;
                            case 6:
                                return s = i.next(), [3, 5];
                            case 7:
                                return [3, 10];
                            case 8:
                                return o = {
                                    error: l.sent()
                                }, [3, 10];
                            case 9:
                                try {
                                    s && !s.done && (a = i.return) && a.call(i)
                                } finally {
                                    if (o) throw o.error
                                }
                                return [7];
                            case 10:
                                return [2, r]
                        }
                    })
                })
            }, t
        }(eO),
        eU = function(e) {
            function t() {
                var t = null !== e && e.apply(this, arguments) || this;
                return t.finalizedSequences = {}, t.sequences = {}, t.sequenceId = 0, t
            }
            return (0, b.__extends)(t, e), t.prototype.resetCurrentSequence = function(e) {
                this.sequences[e] = []
            }, t.prototype.addSequence = function(e) {
                var t = this.sequenceId++,
                    n = (0, b.__spreadArray)([], (0, b.__read)(this.sequences[e]), !1);
                return this.finalizedSequences[t] = {
                    sessionId: e,
                    events: n
                }, this.resetCurrentSequence(e), {
                    sequenceId: t,
                    events: n,
                    sessionId: e
                }
            }, t.prototype.getSequencesToSend = function() {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(e) {
                        return [2, Object.entries(this.finalizedSequences).map(function(e) {
                            var t = (0, b.__read)(e, 2),
                                n = t[0],
                                r = t[1],
                                i = r.sessionId,
                                s = r.events;
                            return {
                                sequenceId: Number(n),
                                sessionId: i,
                                events: s
                            }
                        })]
                    })
                })
            }, t.prototype.storeCurrentSequence = function(e) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(t) {
                        return this.sequences[e] ? [2, this.addSequence(e)] : [2, void 0]
                    })
                })
            }, t.prototype.addEventToCurrentSequence = function(e, t) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var n;
                    return (0, b.__generator)(this, function(r) {
                        return this.sequences[e] || this.resetCurrentSequence(e), this.shouldSplitEventsList(this.sequences[e], t) && (n = this.addSequence(e)), this.sequences[e].push(t), [2, n]
                    })
                })
            }, t.prototype.storeSendingEvents = function(e, t) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(n) {
                        return this.finalizedSequences[this.sequenceId] = {
                            sessionId: e,
                            events: t
                        }, [2, this.sequenceId++]
                    })
                })
            }, t.prototype.cleanUpSessionEventsStore = function(e, t) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(e) {
                        return void 0 !== t && delete this.finalizedSequences[t], [2]
                    })
                })
            }, t
        }(eO),
        eW = function(e) {
            var t = e.config,
                n = e.minInterval,
                r = e.maxInterval,
                i = e.type,
                s = e.payloadBatcher,
                o = e.storeType,
                a = e.trackDestinationWorkerScript;
            return (0, b.__awaiter)(void 0, void 0, void 0, function() {
                var e, l, c, u, d, g, h, v, f, p;

                function _(t) {
                    return void 0 === t && (t = !1), (0, b.__awaiter)(this, void 0, void 0, function() {
                        return (0, b.__generator)(this, function(n) {
                            return [2, e.flush(t)]
                        })
                    })
                }
                return (0, b.__generator)(this, function(y) {
                    switch (y.label) {
                        case 0:
                            if (e = new eT((0, b.__assign)((0, b.__assign)({}, t), {
                                    loggerProvider: t.loggerProvider,
                                    payloadBatcher: s,
                                    workerScript: a
                                })), l = function() {
                                    return new eU({
                                        loggerProvider: t.loggerProvider,
                                        maxInterval: r,
                                        minInterval: n
                                    })
                                }, u = !1, "idb" !== o) return [3, 2];
                            return [4, (0, b.__awaiter)(void 0, void 0, void 0, function() {
                                var e;
                                return (0, b.__generator)(this, function(s) {
                                    switch (s.label) {
                                        case 0:
                                            return [4, eN.new(i, {
                                                loggerProvider: t.loggerProvider,
                                                minInterval: n,
                                                maxInterval: r,
                                                apiKey: t.apiKey,
                                                onPersistentFailure: function() {
                                                    (0, b.__awaiter)(void 0, void 0, void 0, function() {
                                                        var e, n, r;
                                                        return (0, b.__generator)(this, function(i) {
                                                            switch (i.label) {
                                                                case 0:
                                                                    if (!u) return [2];
                                                                    if (u = !1, t.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."), !c) return [3, 2];
                                                                    return [4, d.getSequencesToSend()];
                                                                case 1:
                                                                    return n = i.sent(), [3, 3];
                                                                case 2:
                                                                    n = void 0, i.label = 3;
                                                                case 3:
                                                                    return e = n, d = l(), e && c && (r = c, e.forEach(function(e) {
                                                                        p({
                                                                            sequenceId: e.sequenceId,
                                                                            events: e.events,
                                                                            sessionId: e.sessionId,
                                                                            deviceId: r
                                                                        })
                                                                    })), [2]
                                                            }
                                                        })
                                                    })
                                                }
                                            })];
                                        case 1:
                                            if (!(e = s.sent())) return t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."), [2, l()];
                                            return u = !0, [2, e]
                                    }
                                })
                            })];
                        case 1:
                            return g = y.sent(), [3, 3];
                        case 2:
                            g = l(), y.label = 3;
                        case 3:
                            return d = g, h = [], v = 0, f = function(e) {
                                if (!(e <= v)) {
                                    var t = Math.min(e - v, h.length);
                                    t > 0 && (h.splice(0, t), v = e)
                                }
                            }, p = function(n) {
                                var r = n.events,
                                    s = n.sessionId,
                                    o = n.deviceId,
                                    a = n.sequenceId,
                                    l = r.map(function(e) {
                                        return {
                                            event: e,
                                            bytes: new Blob([e]).size
                                        }
                                    }),
                                    c = l.filter(function(e) {
                                        return e.bytes > 9e6
                                    });
                                c.length > 0 && t.loggerProvider.warn("Dropping ".concat(c.length, " oversized event(s) from session replay sequence before send. Sizes: ").concat(c.map(function(e) {
                                    return "".concat(Math.round(e.bytes / 1024), " KB")
                                }).join(", "), ". If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support."));
                                var u = c.length > 0 ? l.filter(function(e) {
                                    return e.bytes <= 9e6
                                }).map(function(e) {
                                    return e.event
                                }) : r;
                                0 === u.length ? d.cleanUpSessionEventsStore(s, a).catch(function(e) {
                                    t.loggerProvider.warn("Failed to clean up session replay events store:", e)
                                }) : (t.debugMode && et().then(function(e) {
                                    var n = e.totalStorageSize,
                                        r = e.percentOfQuota,
                                        i = e.usageDetails;
                                    t.loggerProvider.debug("Total storage size: ".concat(n, " KB, percentage of quota: ").concat(r, "%, usage details: ").concat(i))
                                }).catch(function() {}), e.sendEventsList({
                                    events: u,
                                    sessionId: s,
                                    flushMaxRetries: t.flushMaxRetries,
                                    apiKey: t.apiKey,
                                    deviceId: o,
                                    sampleRate: t.sampleRate,
                                    serverZone: t.serverZone,
                                    version: t.version,
                                    type: i,
                                    onComplete: function() {
                                        return (0, b.__awaiter)(void 0, void 0, void 0, function() {
                                            return (0, b.__generator)(this, function(e) {
                                                switch (e.label) {
                                                    case 0:
                                                        return [4, d.cleanUpSessionEventsStore(s, a)];
                                                    case 1:
                                                        return e.sent(), [2]
                                                }
                                            })
                                        })
                                    }
                                }))
                            }, [2, {
                                sendCurrentSequenceEvents: function(e) {
                                    var n = e.sessionId,
                                        r = e.deviceId;
                                    c = r;
                                    var i = v + h.length;
                                    d.storeCurrentSequence(n).then(function(e) {
                                        e && (f(i), p({
                                            sequenceId: e.sequenceId,
                                            events: e.events,
                                            sessionId: e.sessionId,
                                            deviceId: r
                                        }))
                                    }).catch(function(e) {
                                        t.loggerProvider.warn("Failed to get current sequence of session replay events for session:", e)
                                    })
                                },
                                addEvent: function(e) {
                                    var n = e.event,
                                        r = e.sessionId,
                                        i = e.deviceId;
                                    c = i;
                                    var s = v + h.length;
                                    h.push(n.data), d.addEventToCurrentSequence(r, n.data).then(function(e) {
                                        e && (f(s), p({
                                            sequenceId: e.sequenceId,
                                            events: e.events,
                                            sessionId: e.sessionId,
                                            deviceId: i
                                        }))
                                    }).catch(function(e) {
                                        t.loggerProvider.warn("Failed to add event to session replay capture:", e)
                                    })
                                },
                                sendStoredEvents: function(e) {
                                    var n = e.deviceId;
                                    return (0, b.__awaiter)(void 0, void 0, void 0, function() {
                                        var e;
                                        return (0, b.__generator)(this, function(r) {
                                            switch (r.label) {
                                                case 0:
                                                    return c = n, [4, d.getSequencesToSend()];
                                                case 1:
                                                    if (!(null == (e = r.sent()) ? void 0 : e.length)) return [2];
                                                    return t.loggerProvider.log("Draining ".concat(e.length, " stored sequence(s) from previous session.")), e.forEach(function(e) {
                                                        p({
                                                            sequenceId: e.sequenceId,
                                                            events: e.events,
                                                            sessionId: e.sessionId,
                                                            deviceId: n
                                                        })
                                                    }), [2]
                                            }
                                        })
                                    })
                                },
                                flush: _,
                                getBeaconEvents: function() {
                                    return (0, b.__spreadArray)([], (0, b.__read)(h), !1)
                                },
                                trackDestination: e
                            }]
                    }
                })
            })
        },
        eB = function() {
            function e() {
                for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
                var n = new Map;
                e.forEach(function(e) {
                    n.set(e.name, e.manager)
                }), this.managers = n
            }
            return e.prototype.sendStoredEvents = function(e) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var t;
                    return (0, b.__generator)(this, function(n) {
                        switch (n.label) {
                            case 0:
                                return t = [], this.managers.forEach(function(n) {
                                    t.push(n.sendStoredEvents(e))
                                }), [4, Promise.all(t)];
                            case 1:
                                return n.sent(), [2]
                        }
                    })
                })
            }, e.prototype.addEvent = function(e) {
                var t, n = e.sessionId,
                    r = e.event,
                    i = e.deviceId;
                null == (t = this.managers.get(r.type)) || t.addEvent({
                    sessionId: n,
                    event: r,
                    deviceId: i
                })
            }, e.prototype.sendCurrentSequenceEvents = function(e) {
                var t = e.sessionId,
                    n = e.deviceId;
                this.managers.forEach(function(e) {
                    e.sendCurrentSequenceEvents({
                        sessionId: t,
                        deviceId: n
                    })
                })
            }, e.prototype.flush = function(e) {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var t;
                    return (0, b.__generator)(this, function(n) {
                        switch (n.label) {
                            case 0:
                                return t = [], this.managers.forEach(function(n) {
                                    t.push(n.flush(e))
                                }), [4, Promise.all(t)];
                            case 1:
                                return n.sent(), [2]
                        }
                    })
                })
            }, e
        }();

    function ej(e, t, n) {
        for (var r = null, i = [], s = e, o = 0; s && "break" !== function() {
                var e, a, l, c, u = new Date().getTime() - _.getTime();
                if (void 0 !== f.timeoutMs && u > f.timeoutMs) throw Error("Timeout: Can't find a unique selector after ".concat(u, "ms"));
                var d = eX((e = s.getAttribute("id")) && f.idName(e) ? {
                        name: "#" + CSS.escape(e),
                        penalty: 0
                    } : null) || eX.apply(void 0, (0, b.__spreadArray)([], (0, b.__read)(Array.from(s.attributes).filter(function(e) {
                        return f.attr(e.name, e.value)
                    }).map(function(e) {
                        return {
                            name: "[".concat(CSS.escape(e.name), '="').concat(CSS.escape(e.value), '"]'),
                            penalty: .5
                        }
                    })), !1)) || eX.apply(void 0, (0, b.__spreadArray)([], (0, b.__read)(Array.from(s.classList).filter(f.className).map(function(e) {
                        return {
                            name: "." + CSS.escape(e),
                            penalty: 1
                        }
                    })), !1)) || eX((a = s.tagName.toLowerCase(), f.tagName(a) ? {
                        name: a,
                        penalty: 2
                    } : null)) || [eQ()],
                    g = function(e) {
                        var t = e.parentNode;
                        if (!t) return null;
                        var n = t.firstChild;
                        if (!n) return null;
                        for (var r = 0; n && (n.nodeType === Node.ELEMENT_NODE && r++, n !== e);) n = n.nextSibling;
                        return r
                    }(s);
                if ("all" == t) g && (d = d.concat(d.filter(eJ).map(function(e) {
                    return e$(e, g)
                })));
                else if ("two" == t) d = d.slice(0, 1), g && (d = d.concat(d.filter(eJ).map(function(e) {
                    return e$(e, g)
                })));
                else if ("one" == t) {
                    var h = (0, b.__read)(d = d.slice(0, 1), 1)[0];
                    g && eJ(h) && (d = [e$(h, g)])
                } else "none" == t && (d = [eQ()], g && (d = [e$(d[0], g)]));
                try {
                    for (var v = (l = void 0, (0, b.__values)(d)), p = v.next(); !p.done; p = v.next()) {
                        var h = p.value;
                        h.level = o
                    }
                } catch (e) {
                    l = {
                        error: e
                    }
                } finally {
                    try {
                        p && !p.done && (c = v.return) && c.call(v)
                    } finally {
                        if (l) throw l.error
                    }
                }
                if (i.push(d), i.length >= f.seedMinLength && (r = ez(i, n))) return "break";
                s = s.parentElement, o++
            }(););
        return (r || (r = ez(i, n)), !r && n) ? n() : r
    }

    function ez(e, t) {
        var n, r, i = eY(function e(t, n) {
            var r, i, s, o, a;
            return void 0 === n && (n = []), (0, b.__generator)(this, function(l) {
                switch (l.label) {
                    case 0:
                        if (!(t.length > 0)) return [3, 9];
                        l.label = 1;
                    case 1:
                        l.trys.push([1, 6, 7, 8]), i = (r = (0, b.__values)(t[0])).next(), l.label = 2;
                    case 2:
                        if (i.done) return [3, 5];
                        return s = i.value, [5, (0, b.__values)(e(t.slice(1, t.length), n.concat(s)))];
                    case 3:
                        l.sent(), l.label = 4;
                    case 4:
                        return i = r.next(), [3, 2];
                    case 5:
                        return [3, 8];
                    case 6:
                        return o = {
                            error: l.sent()
                        }, [3, 8];
                    case 7:
                        try {
                            i && !i.done && (a = r.return) && a.call(r)
                        } finally {
                            if (o) throw o.error
                        }
                        return [7];
                    case 8:
                        return [3, 11];
                    case 9:
                        return [4, n];
                    case 10:
                        l.sent(), l.label = 11;
                    case 11:
                        return [2]
                }
            })
        }(e));
        if (i.length > f.threshold) return t ? t() : null;
        try {
            for (var s = (0, b.__values)(i), o = s.next(); !o.done; o = s.next()) {
                var a = o.value;
                if (eH(a)) return a
            }
        } catch (e) {
            n = {
                error: e
            }
        } finally {
            try {
                o && !o.done && (r = s.return) && r.call(s)
            } finally {
                if (n) throw n.error
            }
        }
        return null
    }

    function eK(e) {
        for (var t = e[0], n = t.name, r = 1; r < e.length; r++) {
            var i = e[r].level || 0;
            n = t.level === i - 1 ? "".concat(e[r].name, " > ").concat(n) : "".concat(e[r].name, " ").concat(n), t = e[r]
        }
        return n
    }

    function eG(e) {
        return e.map(function(e) {
            return e.penalty
        }).reduce(function(e, t) {
            return e + t
        }, 0)
    }

    function eH(e) {
        var t = eK(e);
        switch (p.querySelectorAll(t).length) {
            case 0:
                throw Error("Can't select any node with this selector: ".concat(t));
            case 1:
                return !0;
            default:
                return !1
        }
    }

    function eQ() {
        return {
            name: "*",
            penalty: 3
        }
    }

    function e$(e, t) {
        return {
            name: e.name + ":nth-child(".concat(t, ")"),
            penalty: e.penalty + 1
        }
    }

    function eJ(e) {
        return "html" !== e.name && !e.name.startsWith("#")
    }

    function eX() {
        for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
        var n = e.filter(eV);
        return n.length > 0 ? n : null
    }

    function eV(e) {
        return null != e
    }

    function eY(e) {
        return (0, b.__spreadArray)([], (0, b.__read)(e), !1).sort(function(e, t) {
            return eG(e) - eG(t)
        })
    }
    var eZ = function(e) {
            var t = e.version,
                n = e.events,
                r = [];
            return n.forEach(function(e) {
                var t = JSON.parse(e);
                t.count = 1, "click" === t.type && r.push(t)
            }), {
                version: t,
                events: r
            }
        },
        e0 = function(e) {
            var t = e.version,
                n = e.events,
                r = [];
            return n.forEach(function(e) {
                var t = JSON.parse(e);
                "click" === t.type && r.push(t)
            }), {
                version: t,
                events: Object.values(r.reduce(function(e, t) {
                    var n = t.x,
                        r = t.y,
                        i = t.selector,
                        s = t.timestamp,
                        o = s - s % 36e5,
                        a = "".concat(n, ":").concat(r, ":").concat(null != i ? i : "", ":").concat(o);
                    return e[a] ? e[a].count += 1 : e[a] = (0, b.__assign)((0, b.__assign)({}, t), {
                        timestamp: o,
                        count: 1
                    }), e
                }, {}))
            }
        },
        e1 = function(e, t) {
            var n = this;
            this.createHook = function(e) {
                var t = e.eventsManager,
                    r = e.sessionId,
                    i = e.deviceIdFn,
                    s = e.mirror,
                    o = e.ugcFilterRules,
                    a = e.performanceOptions;
                return function(e) {
                    if (e.type !== eh.Click) return;
                    var l, c = (0, w.getGlobalScope)();
                    if (c) {
                        var u = c.location,
                            d = c.innerHeight,
                            g = c.innerWidth;
                        if (u) {
                            var h = e.x,
                                v = e.y;
                            if (void 0 !== h && void 0 !== v) {
                                var y = s.getNode(e.id);
                                if (y) try {
                                    l = function(e, t) {
                                        if (_ = new Date, e.nodeType !== Node.ELEMENT_NODE) throw Error("Can't generate CSS selector for non-element node type.");
                                        if ("html" === e.tagName.toLowerCase()) return "html";
                                        var n, r, i = {
                                            root: document.body,
                                            idName: function(e) {
                                                return !0
                                            },
                                            className: function(e) {
                                                return !0
                                            },
                                            tagName: function(e) {
                                                return !0
                                            },
                                            attr: function(e, t) {
                                                return !1
                                            },
                                            seedMinLength: 1,
                                            optimizedMinLength: 2,
                                            threshold: 1e3,
                                            maxNumberOfTries: 1e4,
                                            timeoutMs: void 0
                                        };
                                        n = (f = (0, b.__assign)((0, b.__assign)({}, i), t)).root, r = i, p = n.nodeType === Node.DOCUMENT_NODE ? n : n === r.root ? n.ownerDocument : n;
                                        var s = ej(e, "all", function() {
                                            return ej(e, "two", function() {
                                                return ej(e, "one", function() {
                                                    return ej(e, "none")
                                                })
                                            })
                                        });
                                        if (s) {
                                            var o = eY(function e(t, n, r) {
                                                var i, s, o;
                                                return void 0 === r && (r = {
                                                    counter: 0,
                                                    visited: new Map
                                                }), (0, b.__generator)(this, function(a) {
                                                    switch (a.label) {
                                                        case 0:
                                                            if (!(t.length > 2 && t.length > f.optimizedMinLength)) return [3, 5];
                                                            i = 1, a.label = 1;
                                                        case 1:
                                                            var l, c;
                                                            if (!(i < t.length - 1)) return [3, 5];
                                                            if (r.counter > f.maxNumberOfTries || (r.counter += 1, (s = (0, b.__spreadArray)([], (0, b.__read)(t), !1)).splice(i, 1), o = eK(s), r.visited.has(o))) return [2];
                                                            if (!(eH(s) && (l = s, c = n, p.querySelector(eK(l)) === c))) return [3, 4];
                                                            return [4, s];
                                                        case 2:
                                                            return a.sent(), r.visited.set(o, !0), [5, (0, b.__values)(e(s, n, r))];
                                                        case 3:
                                                            a.sent(), a.label = 4;
                                                        case 4:
                                                            return i++, [3, 1];
                                                        case 5:
                                                            return [2]
                                                    }
                                                })
                                            }(s, e));
                                            return o.length > 0 && (s = o[0]), eK(s)
                                        }
                                        throw Error("Selector was not found.")
                                    }(y, a)
                                } catch (e) {
                                    n.logger.debug("error resolving selector from finder")
                                }
                                var m = ee(u.href, o),
                                    S = {
                                        x: h + n.scrollWatcher.currentScrollX,
                                        y: v + n.scrollWatcher.currentScrollY,
                                        selector: l,
                                        viewportHeight: d,
                                        viewportWidth: g,
                                        pageUrl: m,
                                        timestamp: Date.now(),
                                        type: "click"
                                    },
                                    I = i();
                                I && t.addEvent({
                                    sessionId: r,
                                    event: {
                                        type: "interaction",
                                        data: JSON.stringify(S)
                                    },
                                    deviceId: I
                                })
                            }
                        }
                    }
                }
            }, this.logger = e, this.scrollWatcher = t
        };

    function e2() {
        var e = (0, w.getGlobalScope)();
        return (null == e ? void 0 : e.innerHeight) || document.documentElement && document.documentElement.clientHeight || 0
    }

    function e3() {
        var e = (0, w.getGlobalScope)();
        return (null == e ? void 0 : e.innerWidth) || document.documentElement && document.documentElement.clientWidth || 0
    }
    var e4 = function() {
            function e(e, t) {
                var n = (0, w.getGlobalScope)();
                n && n.navigator && "function" == typeof n.navigator.sendBeacon ? this.sendBeacon = function(e, t) {
                    try {
                        if (n.navigator.sendBeacon(e, JSON.stringify(t))) return !0
                    } catch (e) {}
                    return !1
                } : this.sendBeacon = function() {
                    return !1
                }, this.sendXhr = function(e, t) {
                    var n = new XMLHttpRequest;
                    return n.open("POST", e, !0), n.setRequestHeader("Accept", "*/*"), n.send(JSON.stringify(t)), !0
                }, this.basePageUrl = eI(t.serverZone, t.trackServerUrl), this.apiKey = t.apiKey, this.context = e
            }
            return e.prototype.send = function(e, t) {
                var n = this.context,
                    r = n.sessionId,
                    i = n.type,
                    s = new URLSearchParams({
                        device_id: e,
                        session_id: String(r),
                        type: String(i),
                        api_key: this.apiKey
                    }),
                    o = "".concat(this.basePageUrl, "?").concat(s.toString());
                this.sendBeacon(o, t) || this.sendXhr(o, t)
            }, e
        }(),
        e6 = function() {
            function e(e, t) {
                var n = this;
                this.timestamp = Date.now(), this.hook = function(e) {
                    n.update(e)
                }, this.send = function(e) {
                    return function(t) {
                        var r, i, s, o, a = e(),
                            l = (0, w.getGlobalScope)();
                        if (l && a) {
                            var c = null != (r = l.scrollX) ? r : 0,
                                u = null != (i = l.scrollY) ? i : 0;
                            (c > 0 || u > 0) && n.update({
                                id: 1,
                                x: c,
                                y: u
                            }), n.transport.send(a, {
                                version: 1,
                                events: [{
                                    maxScrollX: n._maxScrollX,
                                    maxScrollY: n._maxScrollY,
                                    maxScrollWidth: n._maxScrollWidth,
                                    maxScrollHeight: n._maxScrollHeight,
                                    viewportHeight: e2(),
                                    viewportWidth: e3(),
                                    pageUrl: ee(l.location.href, null != (o = null == (s = n.config.interactionConfig) ? void 0 : s.ugcFilterRules) ? o : []),
                                    timestamp: n.timestamp,
                                    type: "scroll"
                                }]
                            })
                        }
                    }
                }, this._maxScrollX = 0, this._maxScrollY = 0, this._currentScrollX = 0, this._currentScrollY = 0, this._maxScrollWidth = e3(), this._maxScrollHeight = e2(), this.config = t, this.transport = e
            }
            return e.default = function(t, n) {
                return new e(new e4(t, n), n)
            }, Object.defineProperty(e.prototype, "maxScrollX", {
                get: function() {
                    return this._maxScrollX
                },
                enumerable: !1,
                configurable: !0
            }), Object.defineProperty(e.prototype, "maxScrollY", {
                get: function() {
                    return this._maxScrollY
                },
                enumerable: !1,
                configurable: !0
            }), Object.defineProperty(e.prototype, "maxScrollWidth", {
                get: function() {
                    return this._maxScrollWidth
                },
                enumerable: !1,
                configurable: !0
            }), Object.defineProperty(e.prototype, "maxScrollHeight", {
                get: function() {
                    return this._maxScrollHeight
                },
                enumerable: !1,
                configurable: !0
            }), Object.defineProperty(e.prototype, "currentScrollX", {
                get: function() {
                    return this._currentScrollX
                },
                enumerable: !1,
                configurable: !0
            }), Object.defineProperty(e.prototype, "currentScrollY", {
                get: function() {
                    return this._currentScrollY
                },
                enumerable: !1,
                configurable: !0
            }), e.prototype.update = function(e) {
                var t = Date.now();
                if (this._currentScrollX = e.x, this._currentScrollY = e.y, e.x > this._maxScrollX) {
                    var n = e3();
                    this._maxScrollX = e.x;
                    var r = e.x + n;
                    r > this._maxScrollWidth && (this._maxScrollWidth = r), this.timestamp = t
                }
                if (e.y > this._maxScrollY) {
                    var i = e2();
                    this._maxScrollY = e.y;
                    var s = e.y + i;
                    s > this._maxScrollHeight && (this._maxScrollHeight = s), this.timestamp = t
                }
            }, e
        }(),
        e5 = function(e) {
            var t = e.sessionId,
                n = e.deviceId;
            this.deviceId = n, this.sessionId = t, t && n && (this.sessionReplayId = "".concat(n, "/").concat(t))
        },
        e7 = new function() {
            var e = this;
            this.dbs = {}, this.createStore = function(t) {
                return (0, b.__awaiter)(e, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(e) {
                        switch (e.label) {
                            case 0:
                                return [4, (0, eM.openDB)(t, 1, {
                                    upgrade: function(e) {
                                        e.objectStoreNames.contains("sessionTargetingMatch") || e.createObjectStore("sessionTargetingMatch", {
                                            keyPath: "sessionId"
                                        })
                                    }
                                })];
                            case 1:
                                return [2, e.sent()]
                        }
                    })
                })
            }, this.openOrCreateDB = function(t) {
                return (0, b.__awaiter)(e, void 0, void 0, function() {
                    var e, n;
                    return (0, b.__generator)(this, function(r) {
                        switch (r.label) {
                            case 0:
                                if (this.dbs && this.dbs[t]) return [2, this.dbs[t]];
                                return e = "".concat(t.substring(0, 10), "_amp_session_replay_targeting"), [4, this.createStore(e)];
                            case 1:
                                return n = r.sent(), this.dbs[t] = n, [2, n]
                        }
                    })
                })
            }, this.getTargetingMatchForSession = function(t) {
                var n = t.loggerProvider,
                    r = t.apiKey,
                    i = t.sessionId;
                return (0, b.__awaiter)(e, void 0, void 0, function() {
                    var e, t, s, o;
                    return (0, b.__generator)(this, function(a) {
                        switch (a.label) {
                            case 0:
                                return a.trys.push([0, 3, , 4]), [4, this.openOrCreateDB(r)];
                            case 1:
                                return e = a.sent(), t = String(i), [4, e.get("sessionTargetingMatch", t)];
                            case 2:
                                return [2, null == (s = a.sent()) ? void 0 : s.targetingMatch];
                            case 3:
                                return o = a.sent(), eL(n, "Failed to get targeting match for session id ".concat(i, ": ").concat(o), o), [3, 4];
                            case 4:
                                return [2, void 0]
                        }
                    })
                })
            }, this.storeTargetingMatchForSession = function(t) {
                var n = t.loggerProvider,
                    r = t.apiKey,
                    i = t.sessionId,
                    s = t.targetingMatch;
                return (0, b.__awaiter)(e, void 0, void 0, function() {
                    var e, t, o;
                    return (0, b.__generator)(this, function(a) {
                        switch (a.label) {
                            case 0:
                                return a.trys.push([0, 3, , 4]), [4, this.openOrCreateDB(r)];
                            case 1:
                                return e = a.sent(), t = String(i), [4, e.put("sessionTargetingMatch", {
                                    targetingMatch: s,
                                    sessionId: t,
                                    lastUpdated: Date.now()
                                })];
                            case 2:
                                return [2, a.sent()];
                            case 3:
                                return o = a.sent(), eL(n, "Failed to store targeting match for session id ".concat(i, ": ").concat(o), o), [3, 4];
                            case 4:
                                return [2, void 0]
                        }
                    })
                })
            }, this.clearStoreOfOldSessions = function(t) {
                var n = t.loggerProvider,
                    r = t.apiKey,
                    i = t.currentSessionId;
                return (0, b.__awaiter)(e, void 0, void 0, function() {
                    var e, t, s, o, a, l, c, u;
                    return (0, b.__generator)(this, function(d) {
                        switch (d.label) {
                            case 0:
                                return d.trys.push([0, 8, , 9]), [4, this.openOrCreateDB(r)];
                            case 1:
                                return e = d.sent(), t = String(i), [4, (s = e.transaction("sessionTargetingMatch", "readwrite")).store.getAll()];
                            case 2:
                                o = d.sent(), a = 0, d.label = 3;
                            case 3:
                                if (!(a < o.length)) return [3, 6];
                                if (l = o[a], c = Date.now() - l.lastUpdated, !(l.sessionId !== t && c > 1728e5)) return [3, 5];
                                return [4, s.store.delete(l.sessionId)];
                            case 4:
                                d.sent(), d.label = 5;
                            case 5:
                                return a++, [3, 3];
                            case 6:
                                return [4, s.done];
                            case 7:
                                return d.sent(), [3, 9];
                            case 8:
                                return u = d.sent(), eL(n, "Failed to clear old targeting matches for sessions: ".concat(u), u), [3, 9];
                            case 9:
                                return [2]
                        }
                    })
                })
            }
        },
        e8 = function(t) {
            var n = t.sessionId,
                r = t.targetingConfig,
                i = t.loggerProvider,
                s = t.apiKey,
                o = t.targetingParams,
                a = t.urlChange,
                l = void 0 !== a && a;
            return (0, b.__awaiter)(void 0, void 0, void 0, function() {
                var t, a, c;
                return (0, b.__generator)(this, function(u) {
                    switch (u.label) {
                        case 0:
                            return [4, e7.clearStoreOfOldSessions({
                                loggerProvider: i,
                                apiKey: s,
                                currentSessionId: n
                            })];
                        case 1:
                            return u.sent(), [4, e7.getTargetingMatchForSession({
                                loggerProvider: i,
                                apiKey: s,
                                sessionId: n
                            })];
                        case 2:
                            if (!0 === u.sent() && !l) return [2, !0];
                            t = !0, u.label = 3;
                        case 3:
                            return u.trys.push([3, 6, , 7]), [4, e.A(560602)];
                        case 4:
                            return [4, (0, u.sent().evaluateTargeting)((0, b.__assign)((0, b.__assign)({}, o), {
                                flag: r,
                                sessionId: "string" == typeof n ? parseInt(n, 10) : n,
                                apiKey: s,
                                loggerProvider: i
                            }))];
                        case 5:
                            return (a = u.sent()) && a.sr_targeting_config && (t = "on" === a.sr_targeting_config.key), e7.storeTargetingMatchForSession({
                                loggerProvider: i,
                                apiKey: s,
                                sessionId: n,
                                targetingMatch: t
                            }), [3, 7];
                        case 6:
                            return c = u.sent(), i.warn(c.message), [3, 7];
                        case 7:
                            return [2, t]
                    }
                })
            })
        };

    function e9(e, t) {
        return (e << t | e >>> 32 - t) >>> 0
    }

    function te(e, t) {
        return Math.imul(e = e9(e = e + Math.imul(t, 0x85ebca77) >>> 0, 13), 0x9e3779b1) >>> 0
    }

    function tt(e, t) {
        return (e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24) >>> 0
    }
    var tn = "__amplitude_url_tracking_patched__",
        tr = new WeakMap;

    function ti(e, t, n) {
        if (void 0 === n && (n = {}), !(null == e ? void 0 : e.location)) return function() {};
        var r = n.enablePolling,
            i = n.pollingInterval;
        if (void 0 !== r && r) {
            var s = function() {
                    var t;
                    return null != (t = e.location.href) ? t : ""
                },
                o = s(),
                a = e.setInterval(function() {
                    var e = s();
                    e !== o && (o = e, t(e))
                }, void 0 === i ? 1e3 : i);
            return function() {
                null != a && e.clearInterval(a)
            }
        }
        var l = tr.get(e);
        if (!l) {
            var c = void 0,
                u = new Set,
                d = function() {
                    var t;
                    return null != (t = e.location.href) ? t : ""
                },
                g = function() {
                    var e = d();
                    (void 0 === c || e !== c) && (c = e, u.forEach(function(t) {
                        return t(e)
                    }))
                },
                h = function(e) {
                    var t = function() {
                        for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
                        var r = e.apply(this, t);
                        return g(), r
                    };
                    return t[tn] = !0, t
                },
                v = e.history;
            if (null == v ? void 0 : v.pushState) {
                var f = Reflect.get(v, "pushState");
                f[tn] || (v.pushState = h(f))
            }
            if (null == v ? void 0 : v.replaceState) {
                var p = Reflect.get(v, "replaceState");
                p[tn] || (v.replaceState = h(p))
            }
            l = {
                callbacks: u,
                notify: g,
                onPopStateOrHashChange: function() {
                    return g()
                },
                listenersAttached: !1
            }, tr.set(e, l)
        }
        var _ = l;
        return _.listenersAttached || (e.addEventListener("popstate", _.onPopStateOrHashChange), e.addEventListener("hashchange", _.onPopStateOrHashChange), _.listenersAttached = !0), _.callbacks.add(t),
            function() {
                _.callbacks.delete(t), 0 === _.callbacks.size && _.listenersAttached && (e.removeEventListener("popstate", _.onPopStateOrHashChange), e.removeEventListener("hashchange", _.onPopStateOrHashChange), _.listenersAttached = !1)
            }
    }

    function ts(e) {
        return void 0 === e && (e = {}), {
            name: "amplitude/url-tracking@1",
            observer: function(t, n, r) {
                var i, s, o, a = (0, b.__assign)((0, b.__assign)({}, e), r),
                    l = a.ugcFilterRules || [],
                    c = null != (i = a.enablePolling) && i,
                    u = null != (s = a.pollingInterval) ? s : 1e3,
                    d = null != (o = a.captureDocumentTitle) && o;
                if (!n) return function() {};
                var g = void 0,
                    h = function() {
                        return n.location && n.location.href || ""
                    },
                    v = function() {
                        var e = n.innerHeight,
                            t = n.innerWidth,
                            r = n.document,
                            i = h(),
                            s = "";
                        return d && (s = (null == r ? void 0 : r.title) || ""), {
                            href: l.length > 0 ? ee(i, l) : i,
                            title: s,
                            viewportHeight: e,
                            viewportWidth: t,
                            type: "url-change-event"
                        }
                    },
                    f = function() {
                        var e = h();
                        (void 0 === g || e !== g) && (g = e, t(v()))
                    },
                    p = ti(n, function() {
                        return f()
                    }, c ? {
                        enablePolling: !0,
                        pollingInterval: u
                    } : {});
                return f(),
                    function() {
                        return p()
                    }
            },
            options: e
        }
    }
    ts();
    var to = function() {
            function e() {
                this.pendingLoadListeners = new Map
            }
            return e.prototype.start = function() {
                var e, t = this;
                null == (e = this.mutationObserver) || e.disconnect(), (0, w.getGlobalScope)() && (this.sendToAllIframes({
                    type: z,
                    action: "start"
                }), this.mutationObserver = new MutationObserver(function(e) {
                    var n, r, i, s, o, a;
                    try {
                        for (var l = (0, b.__values)(e), c = l.next(); !c.done; c = l.next()) {
                            var u = c.value;
                            try {
                                for (var d = (i = void 0, (0, b.__values)(Array.from(u.addedNodes))), g = d.next(); !g.done; g = d.next()) {
                                    var h = g.value;
                                    h instanceof HTMLIFrameElement ? t.sendToIframeAfterLoad(h) : h instanceof Element && h.querySelectorAll("iframe").forEach(function(e) {
                                        t.sendToIframeAfterLoad(e)
                                    })
                                }
                            } catch (e) {
                                i = {
                                    error: e
                                }
                            } finally {
                                try {
                                    g && !g.done && (s = d.return) && s.call(d)
                                } finally {
                                    if (i) throw i.error
                                }
                            }
                            try {
                                for (var v = (o = void 0, (0, b.__values)(Array.from(u.removedNodes))), f = v.next(); !f.done; f = v.next()) {
                                    var h = f.value;
                                    if (h instanceof HTMLIFrameElement) {
                                        var p = t.pendingLoadListeners.get(h);
                                        p && (h.removeEventListener("load", p), t.pendingLoadListeners.delete(h))
                                    }
                                }
                            } catch (e) {
                                o = {
                                    error: e
                                }
                            } finally {
                                try {
                                    f && !f.done && (a = v.return) && a.call(v)
                                } finally {
                                    if (o) throw o.error
                                }
                            }
                        }
                    } catch (e) {
                        n = {
                            error: e
                        }
                    } finally {
                        try {
                            c && !c.done && (r = l.return) && r.call(l)
                        } finally {
                            if (n) throw n.error
                        }
                    }
                }), this.mutationObserver.observe(document.documentElement, {
                    childList: !0,
                    subtree: !0
                }))
            }, e.prototype.stop = function() {
                var e;
                null == (e = this.mutationObserver) || e.disconnect(), this.mutationObserver = void 0, this.pendingLoadListeners.forEach(function(e, t) {
                    t.removeEventListener("load", e)
                }), this.pendingLoadListeners.clear(), this.sendToAllIframes({
                    type: z,
                    action: "stop"
                })
            }, e.prototype.sendToIframeAfterLoad = function(e) {
                var t = this,
                    n = function() {
                        t.pendingLoadListeners.delete(e), t.sendToIframe(e, {
                            type: z,
                            action: "start"
                        })
                    };
                this.pendingLoadListeners.set(e, n), e.addEventListener("load", n, {
                    once: !0
                })
            }, e.prototype.sendToAllIframes = function(e) {
                var t = this;
                document.querySelectorAll("iframe").forEach(function(n) {
                    return t.sendToIframe(n, e)
                })
            }, e.prototype.sendToIframe = function(e, t) {
                var n;
                try {
                    null == (n = e.contentWindow) || n.postMessage(t, "*")
                } catch (e) {}
            }, e
        }(),
        ta = function() {
            function t() {
                var e = this;
                this.name = "@amplitude/session-replay-browser", this.recordCancelCallback = null, this.eventCount = 0, this.sessionTargetingMatch = !1, this.pageLeaveFns = [], this.recordFunction = null, this.recordEventsInFlight = !1, this.pendingEmitEvents = [], this.currentPageUrl = "", this.recordEventsPendingShouldLogMetadata = null, this.urlChangeCleanup = null, this.crossOriginIframeCoordinator = null, this.crossOriginParentSignalCleanup = null, this.latestUrlChangeTargetingEvaluationId = 0, this.teardownEventListeners = function(t) {
                    var n = (0, w.getGlobalScope)();
                    n && (n.removeEventListener("blur", e.blurListener), n.removeEventListener("focus", e.focusListener), t || n.addEventListener("blur", e.blurListener), t || n.addEventListener("focus", e.focusListener), n.self && "onpagehide" in n.self ? (n.removeEventListener("pagehide", e.pageLeaveListener), t || n.addEventListener("pagehide", e.pageLeaveListener)) : (n.removeEventListener("beforeunload", e.pageLeaveListener), t || n.addEventListener("beforeunload", e.pageLeaveListener)))
                }, this.blurListener = function() {
                    e.sendEvents()
                }, this.focusListener = function() {
                    if (e.recordCancelCallback && e.recordFunction) try {
                        e.recordFunction.takeFullSnapshot(!0)
                    } catch (t) {
                        e.loggerProvider.warn("Failed to take full snapshot on focus:", t)
                    } else e.recordEventsInFlight || e.recordEvents(!1)
                }, this.pageLeaveListener = function(t) {
                    var n;
                    null == (n = e.eventCompressor) || n.flushQueue(), e.sendEvents(), e.pageLeaveFns.forEach(function(e) {
                        e(t)
                    })
                }, this.evaluateTargetingAndCapture = function(t, n, r, i) {
                    return void 0 === n && (n = !1), void 0 === r && (r = !1), void 0 === i && (i = !1), (0, b.__awaiter)(e, void 0, void 0, function() {
                        var e, s, o, a, l, c, u, d, g, h, v, f;
                        return (0, b.__generator)(this, function(p) {
                            switch (p.label) {
                                case 0:
                                    if (!this.identifiers || !this.identifiers.sessionId || !this.config) return this.identifiers && !this.identifiers.sessionId ? this.loggerProvider.log("Session ID has not been set yet, cannot evaluate targeting for Session Replay.") : this.loggerProvider.warn("Session replay init has not been called, cannot evaluate targeting."), [2];
                                    if (!this.config.targetingConfig)
                                        if (!n) return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."), [2];
                                        else this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.");
                                    if (this.lastTargetingParams = t, !((e = this.config.targetingConfig) && !this.sessionTargetingMatch)) return [3, 2];
                                    return s = i ? this.latestUrlChangeTargetingEvaluationId : void 0, (o = t.event) && Object.values(I.SpecialEventType).includes(o.event_type) && (o = void 0), a = null != (v = null != (d = null == (u = t.page) ? void 0 : u.url) ? d : null == (h = null == (g = (0, w.getGlobalScope)()) ? void 0 : g.location) ? void 0 : h.href) ? v : "", l = null != (f = t.page) ? f : "" !== a ? {
                                        url: a
                                    } : void 0, [4, e8({
                                        sessionId: this.identifiers.sessionId,
                                        targetingConfig: e,
                                        loggerProvider: this.loggerProvider,
                                        apiKey: this.config.apiKey,
                                        targetingParams: {
                                            userProperties: t.userProperties,
                                            event: o,
                                            page: l
                                        },
                                        urlChange: i
                                    })];
                                case 1:
                                    if (c = p.sent(), i && void 0 !== s && s !== this.latestUrlChangeTargetingEvaluationId) return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(s, "; latest is #").concat(this.latestUrlChangeTargetingEvaluationId, ".")), [2];
                                    this.sessionTargetingMatch = this.sessionTargetingMatch || c, this.loggerProvider.debug(JSON.stringify({
                                        name: "targeted replay capture config",
                                        sessionTargetingMatch: this.sessionTargetingMatch,
                                        event: o,
                                        targetingParams: t
                                    }, null, 2)), p.label = 2;
                                case 2:
                                    if (!n) return [3, 3];
                                    return this.initialize(!0), [3, 5];
                                case 3:
                                    if (!(r || !this.recordCancelCallback)) return [3, 5];
                                    return this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."), [4, this.recordEvents()];
                                case 4:
                                    p.sent(), p.label = 5;
                                case 5:
                                    return [2]
                            }
                        })
                    })
                }, this.addCustomRRWebEvent = function(t, n, r) {
                    return void 0 === n && (n = {}), void 0 === r && (r = !0), (0, b.__awaiter)(e, void 0, void 0, function() {
                        var e, i, s, o;
                        return (0, b.__generator)(this, function(a) {
                            switch (a.label) {
                                case 0:
                                    if (a.trys.push([0, 3, , 4]), e = void 0, !((i = this.config) && t !== v.METADATA) || (e = {
                                            config: en(i),
                                            version: ex
                                        }, !r)) return [3, 2];
                                    return [4, et()];
                                case 1:
                                    s = a.sent(), e = (0, b.__assign)((0, b.__assign)({}, s), e), a.label = 2;
                                case 2:
                                    return this.recordCancelCallback && this.recordFunction ? this.recordFunction.addCustomEvent(t, (0, b.__assign)((0, b.__assign)({}, n), e)) : this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t, " due to no ongoing recording.")), [3, 4];
                                case 3:
                                    return o = a.sent(), this.loggerProvider.debug("Error while adding custom replay capture event: ", o), [3, 4];
                                case 4:
                                    return [2]
                            }
                        })
                    })
                }, this.stopRecordingEvents = function() {
                    var t, n, r;
                    try {
                        e.loggerProvider.log("Session Replay capture stopping."), e.recordCancelCallback && e.recordCancelCallback(), e.recordCancelCallback = null, null == (t = e.networkObservers) || t.stop(), null == (n = e.crossOriginIframeCoordinator) || n.stop(), e.crossOriginIframeCoordinator = null, null == (r = e.crossOriginParentSignalCleanup) || r.call(e), e.crossOriginParentSignalCleanup = null
                    } catch (t) {
                        e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(t.toString()))
                    }
                }, this.loggerProvider = new K(new P.Logger)
            }
            return t.prototype.init = function(e, t) {
                return (0, eo.returnWrapper)(this._init(e, t))
            }, t.prototype.setupUrlChangeListener = function() {
                var e, t, n = this;
                null == (e = this.urlChangeCleanup) || e.call(this);
                var r = (0, w.getGlobalScope)();
                if (null == r ? void 0 : r.location) {
                    var i = !!(null == (t = this.config) ? void 0 : t.targetingConfig),
                        s = ti(r, function(e) {
                            if (n.currentPageUrl = e, i) {
                                var t = ++n.latestUrlChangeTargetingEvaluationId;
                                n.evaluateTargetingAndCapture({
                                    userProperties: {},
                                    event: void 0,
                                    page: {
                                        url: e
                                    }
                                }, !1, !1, !0), n.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(t, " for ").concat(e, "."))
                            }
                        });
                    this.urlChangeCleanup = function() {
                        s(), n.urlChangeCleanup = null
                    }
                }
            }, t.prototype.getCurrentPageForTargeting = function() {
                var e, t, n = null == (t = null == (e = (0, w.getGlobalScope)()) ? void 0 : e.location) ? void 0 : t.href;
                return null != n ? {
                    url: n
                } : void 0
            }, t.prototype._init = function(t, n) {
                var r, i, s, o, a, l, c, u, d, g, h;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var v, f, p, _, y, m, S, I, C, k, E, R, x, T, M, O, L, A, D, F, q, N, U, W, B, j, z, G = this;
                    return (0, b.__generator)(this, function(H) {
                        switch (H.label) {
                            case 0:
                                return null == (r = this.urlChangeCleanup) || r.call(this), this.loggerProvider = new K(n.loggerProvider || new P.Logger), Object.prototype.hasOwnProperty.call(n, "logLevel") && this.loggerProvider.enable(n.logLevel), this.currentPageUrl = X(), this.identifiers = new e5({
                                    sessionId: n.sessionId,
                                    deviceId: n.deviceId
                                }), v = this, [4, (0, b.__awaiter)(void 0, void 0, void 0, function() {
                                    var e;
                                    return (0, b.__generator)(this, function(r) {
                                        return e = new ei(t, n), [2, new eb(new em.RemoteConfigClient(t, e.loggerProvider, e.serverZone, n.configServerUrl), e)]
                                    })
                                })];
                            case 1:
                                return v.joinedConfigGenerator = H.sent(), [4, this.joinedConfigGenerator.generateJoinedConfig()];
                            case 2:
                                if (p = (f = H.sent()).joinedConfig, _ = f.localConfig, y = f.remoteConfig, this.config = p, this.setMetadata(n.sessionId, p, _, y, null == (i = n.version) ? void 0 : i.version, ex, null == (s = n.version) ? void 0 : s.type), this.pageLeaveFns = [], n.sessionId && (null == (o = this.config.interactionConfig) ? void 0 : o.enabled) && (m = e6.default({
                                        sessionId: n.sessionId,
                                        type: "interaction"
                                    }, this.config), this.pageLeaveFns = [m.send(this.getDeviceId.bind(this)).bind(m)], this.scrollHook = m.hook.bind(m), this.clickHandler = new e1(this.loggerProvider, m)), S = [], "idb" !== (I = this.config.storeType) || (null == (a = (0, w.getGlobalScope)()) ? void 0 : a.indexedDB) || (I = "memory", this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")), this.loggerProvider.log("Using ".concat(I, " for event storage.")), E = (0, w.getGlobalScope)(), !(this.config.useWebWorker && E && E.Worker)) return [3, 4];
                                return [4, e.A(946096)];
                            case 3:
                                x = (R = H.sent()).compressionScript, T = R.trackDestinationScript, C = x, k = T, H.label = 4;
                            case 4:
                                return H.trys.push([4, 6, , 7]), [4, eW({
                                    config: this.config,
                                    type: "replay",
                                    storeType: I,
                                    trackDestinationWorkerScript: k
                                })];
                            case 5:
                                return M = H.sent(), S.push({
                                    name: "replay",
                                    manager: M
                                }), [3, 7];
                            case 6:
                                return O = H.sent(), this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(O.toString())), [3, 7];
                            case 7:
                                if (!(null == (l = this.config.interactionConfig) ? void 0 : l.enabled)) return [3, 11];
                                L = this.config.interactionConfig.batch ? e0 : eZ, H.label = 8;
                            case 8:
                                return H.trys.push([8, 10, , 11]), [4, eW({
                                    config: this.config,
                                    type: "interaction",
                                    minInterval: null != (c = this.config.interactionConfig.trackEveryNms) ? c : 3e4,
                                    maxInterval: 6e4,
                                    payloadBatcher: L,
                                    storeType: I,
                                    trackDestinationWorkerScript: k
                                })];
                            case 9:
                                return A = H.sent(), S.push({
                                    name: "interaction",
                                    manager: A
                                }), [3, 11];
                            case 10:
                                return O = H.sent(), this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(O.toString())), [3, 11];
                            case 11:
                                if (this.eventsManager = new(eB.bind.apply(eB, (0, b.__spreadArray)([void 0], (0, b.__read)(S), !1))), this.eventCompressor && this.eventCompressor.terminate(), this.eventCompressor = new eC(this.eventsManager, this.config, this.getDeviceId(), C, function() {
                                        return G.sendEvents()
                                    }), this.pendingEmitEvents.length > 0) {
                                    D = this.pendingEmitEvents.splice(0);
                                    try {
                                        for (q = (F = (0, b.__values)(D)).next(); !q.done; q = F.next()) U = (N = q.value).event, W = N.sessionId, this.eventCompressor.enqueueEvent(U, W)
                                    } catch (e) {
                                        j = {
                                            error: e
                                        }
                                    } finally {
                                        try {
                                            q && !q.done && (z = F.return) && z.call(F)
                                        } finally {
                                            if (j) throw j.error
                                        }
                                    }
                                }
                                return this.pageLeaveFns = (0, b.__spreadArray)((0, b.__spreadArray)([], (0, b.__read)(this.pageLeaveFns), !1), [function() {
                                    if (G.config && (null == (e = G.identifiers) ? void 0 : e.sessionId) && M) {
                                        var e, t = M.getBeaconEvents();
                                        if (t.length) {
                                            var n = G.getDeviceId();
                                            n && M.trackDestination.sendBeacon({
                                                events: t,
                                                sessionId: G.identifiers.sessionId,
                                                deviceId: n,
                                                apiKey: G.config.apiKey,
                                                serverZone: G.config.serverZone
                                            })
                                        }
                                    }
                                }], !1), [4, this.initializeNetworkObservers()];
                            case 12:
                                return H.sent(), (null == (u = (0, w.getGlobalScope)()) ? void 0 : u.opener) && (B = (0, el.getOrCreateWindowMessenger)(), (0, ec.enableBackgroundCapture)(B), B.setup((0, b.__assign)({
                                    logger: this.loggerProvider
                                }, this.config.serverZone && {
                                    endpoint: eu.AMPLITUDE_ORIGINS_MAP[this.config.serverZone]
                                }))), this.loggerProvider.log("Installing @amplitude/session-replay-browser."), this.teardownEventListeners(!1), [4, this.evaluateTargetingAndCapture({
                                    userProperties: n.userProperties,
                                    page: this.getCurrentPageForTargeting()
                                }, !0)];
                            case 13:
                                return H.sent(), (this.config.targetingConfig || (null != (h = null == (g = null == (d = this.config.privacyConfig) ? void 0 : d.urlMaskLevels) ? void 0 : g.length) ? h : 0) > 0) && this.setupUrlChangeListener(), [2]
                        }
                    })
                })
            }, t.prototype.setSessionId = function(e, t) {
                return (0, eo.returnWrapper)(this.asyncSetSessionId(e, t))
            }, t.prototype.asyncSetSessionId = function(e, t, n) {
                var r;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var i, s, o;
                    return (0, b.__generator)(this, function(a) {
                        switch (a.label) {
                            case 0:
                                if (this.latestUrlChangeTargetingEvaluationId++, this.sessionTargetingMatch = !1, this.lastShouldRecordDecision = void 0, (i = this.identifiers && this.identifiers.sessionId) && this.sendEvents(i), s = t || this.getDeviceId(), this.identifiers = new e5({
                                        sessionId: e,
                                        deviceId: s
                                    }), !(this.joinedConfigGenerator && i)) return [3, 2];
                                return [4, this.joinedConfigGenerator.generateJoinedConfig()];
                            case 1:
                                o = a.sent().joinedConfig, this.config = o, a.label = 2;
                            case 2:
                                if (!(null == (r = this.config) ? void 0 : r.targetingConfig)) return [3, 4];
                                return [4, this.evaluateTargetingAndCapture({
                                    userProperties: null == n ? void 0 : n.userProperties,
                                    page: this.getCurrentPageForTargeting()
                                }, !1, !0)];
                            case 3:
                                return a.sent(), [3, 6];
                            case 4:
                                return [4, this.recordEvents()];
                            case 5:
                                a.sent(), a.label = 6;
                            case 6:
                                return [2]
                        }
                    })
                })
            }, t.prototype.getSessionReplayProperties = function() {
                var e, t = this.config,
                    n = this.identifiers;
                if (!t || !n) return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."), {};
                var r = this.getShouldRecord(),
                    i = {};
                return r && ((e = {})[L] = n.sessionReplayId ? n.sessionReplayId : null, i = e, t.debugMode && (i[F] = JSON.stringify({
                    appHash: (0, ea.generateHashCode)(t.apiKey).toString()
                }))), this.addCustomRRWebEvent(v.GET_SR_PROPS, {
                    shouldRecord: r,
                    eventProperties: i
                }, 10 === this.eventCount), 10 === this.eventCount && (this.eventCount = 0), this.eventCount++, i
            }, t.prototype.sendEvents = function(e) {
                var t, n = e || (null == (t = this.identifiers) ? void 0 : t.sessionId),
                    r = this.getDeviceId();
                this.eventsManager && n && r && this.eventsManager.sendCurrentSequenceEvents({
                    sessionId: n,
                    deviceId: r
                })
            }, t.prototype.initialize = function(e) {
                var t;
                return void 0 === e && (e = !1), (0, b.__awaiter)(this, void 0, void 0, function() {
                    var n;
                    return (0, b.__generator)(this, function(r) {
                        return (null == (t = this.identifiers) ? void 0 : t.sessionId) ? (n = this.getDeviceId()) ? (this.eventsManager && e && this.eventsManager.sendStoredEvents({
                            deviceId: n
                        }), [2, this.recordEvents()]) : (this.loggerProvider.log("Session is not being recorded due to lack of device id."), [2, Promise.resolve()]) : (this.loggerProvider.log("Session is not being recorded due to lack of session id."), [2, Promise.resolve()])
                    })
                })
            }, t.prototype.shouldOptOut = function() {
                if (null == (e = this.config) ? void 0 : e.instanceName) {
                    var e, t, n;
                    n = (0, es.getAnalyticsConnector)(this.config.instanceName).identityStore.getIdentity().optOut
                }
                return void 0 !== n ? n : null == (t = this.config) ? void 0 : t.optOut
            }, t.prototype.getShouldRecord = function() {
                if (!this.identifiers || !this.config || !this.identifiers.sessionId) return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."), !1;
                if (!this.config.captureEnabled) return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId, " not being captured due to capture being disabled for project or because the remote config could not be fetched.")), !1;
                if (this.shouldOptOut()) return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId, " out of recording due to optOut config.")), !1;
                var e, t, n = !1,
                    r = "",
                    i = !1;
                return this.config.targetingConfig ? this.sessionTargetingMatch ? (r = "Capturing replays for session ".concat(this.identifiers.sessionId, " due to matching targeting conditions."), this.loggerProvider.log(r), n = !0, i = !0) : (r = "Not capturing replays for session ".concat(this.identifiers.sessionId, " due to not matching targeting conditions."), this.loggerProvider.log(r), n = !1, i = !1) : (e = this.identifiers.sessionId, t = this.config.sampleRate, function(e, t) {
                    void 0 === t && (t = 0);
                    var n, r = function(e) {
                            for (var t = [], n = 0; n < e.length; n++) {
                                var r = e.charCodeAt(n);
                                if (r >= 55296 && r <= 56319 && n + 1 < e.length) {
                                    var i = e.charCodeAt(n + 1);
                                    i >= 56320 && i <= 57343 && (r = (r - 55296 << 10) + (i - 56320) + 65536, n++)
                                }
                                r < 128 ? t.push(r) : r < 2048 ? t.push(192 | r >> 6, 128 | 63 & r) : r < 65536 ? t.push(224 | r >> 12, 128 | r >> 6 & 63, 128 | 63 & r) : t.push(240 | r >> 18, 128 | r >> 12 & 63, 128 | r >> 6 & 63, 128 | 63 & r)
                            }
                            return new Uint8Array(t)
                        }(e),
                        i = r.length,
                        s = 0;
                    if (i >= 16) {
                        for (var o = t + 0x9e3779b1 + 0x85ebca77 >>> 0, a = t + 0x85ebca77 >>> 0, l = t >>> 0, c = t - 0x9e3779b1 >>> 0; s <= i - 16;) o = te(o, tt(r, s)), s += 4, a = te(a, tt(r, s)), s += 4, l = te(l, tt(r, s)), s += 4, c = te(c, tt(r, s)), s += 4;
                        n = e9(o, 1) + e9(a, 7) + e9(l, 12) + e9(c, 18) >>> 0
                    } else n = t + 0x165667b1 >>> 0;
                    for (n = n + i >>> 0; s <= i - 4;) n = Math.imul(e9(n = n + Math.imul(tt(r, s), 0xc2b2ae3d) >>> 0, 17), 0x27d4eb2f) >>> 0, s += 4;
                    for (; s < i;) n = Math.imul(e9(n = n + Math.imul(r[s], 0x165667b1) >>> 0, 11), 0x9e3779b1) >>> 0, s++;
                    return n ^= n >>> 15, n = Math.imul(n, 0x85ebca77) >>> 0, n ^= n >>> 13, n = Math.imul(n, 0xc2b2ae3d) >>> 0, (n ^= n >>> 16) >>> 0
                }(e.toString()) % 1e6 / 1e6 < t) ? (n = !0, i = !0) : (r = "Opting session ".concat(this.identifiers.sessionId, " out of recording due to sample rate."), this.loggerProvider.log(r), n = !1, i = !1), this.lastShouldRecordDecision !== n && this.config.targetingConfig && (this.addCustomRRWebEvent(v.TARGETING_DECISION, {
                    message: r,
                    sessionId: this.identifiers.sessionId,
                    matched: i,
                    targetingParams: this.lastTargetingParams
                }), this.lastShouldRecordDecision = n), n
            }, t.prototype.getBlockSelectors = function() {
                var e, t, n, r = null != (n = null == (t = null == (e = this.config) ? void 0 : e.privacyConfig) ? void 0 : t.blockSelector) ? n : [];
                if (0 !== r.length) return r
            }, t.prototype.getMaskTextSelectors = function() {
                var e, t, n = null == (e = this.config) ? void 0 : e.privacyConfig;
                if ("conservative" === (n ? Q(this.currentPageUrl, n) : void 0) || (null == (t = null == n ? void 0 : n.urlMaskLevels) ? void 0 : t.some(function(e) {
                        return "conservative" === e.maskLevel
                    }))) return "*";
                var r = null == n ? void 0 : n.urlMaskLevels;
                if ((null == n ? void 0 : n.defaultMaskLevel) === "conservative" && r && r.length > 0) return "*";
                var i = null == n ? void 0 : n.maskSelector;
                if (i) return i
            }, t.prototype.getRecordingPlugins = function(t) {
                var n, r, i, s, o, a;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var l, c, u, d;
                    return (0, b.__generator)(this, function(g) {
                        switch (g.label) {
                            case 0:
                                l = [];
                                try {
                                    c = ts({
                                        ugcFilterRules: (null == (r = null == (n = this.config) ? void 0 : n.interactionConfig) ? void 0 : r.ugcFilterRules) || [],
                                        enablePolling: (null == (i = this.config) ? void 0 : i.enableUrlChangePolling) || !1,
                                        pollingInterval: null == (s = this.config) ? void 0 : s.urlChangePollingInterval,
                                        captureDocumentTitle: null == (o = this.config) ? void 0 : o.captureDocumentTitle
                                    }), l.push(c)
                                } catch (e) {
                                    this.loggerProvider.warn("Failed to create URL tracking plugin:", e)
                                }
                                if (!(null == (a = null == t ? void 0 : t.console) ? void 0 : a.enabled)) return [3, 4];
                                g.label = 1;
                            case 1:
                                return g.trys.push([1, 3, , 4]), [4, e.A(555847)];
                            case 2:
                                return u = g.sent().getRecordConsolePlugin, l.push(u({
                                    level: t.console.levels
                                })), [3, 4];
                            case 3:
                                return d = g.sent(), this.loggerProvider.warn("Failed to load console plugin:", d), [3, 4];
                            case 4:
                                return [2, l.length > 0 ? l : void 0]
                        }
                    })
                })
            }, t.prototype.getRecordFunction = function() {
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var t, n;
                    return (0, b.__generator)(this, function(r) {
                        switch (r.label) {
                            case 0:
                                if (this.recordFunction) return [2, this.recordFunction];
                                r.label = 1;
                            case 1:
                                return r.trys.push([1, 3, , 4]), [4, e.A(342960)];
                            case 2:
                                return t = r.sent().record, this.recordFunction = t, [2, t];
                            case 3:
                                return n = r.sent(), this.loggerProvider.warn("Failed to load rrweb-record module:", n), [2, null];
                            case 4:
                                return [2]
                        }
                    })
                })
            }, t.prototype.recordEvents = function(e) {
                return void 0 === e && (e = !0), (0, b.__awaiter)(this, void 0, void 0, function() {
                    var t;
                    return (0, b.__generator)(this, function(n) {
                        switch (n.label) {
                            case 0:
                                if (this.recordEventsInFlight) return this.recordEventsPendingShouldLogMetadata = e, [2];
                                this.recordEventsInFlight = !0, n.label = 1;
                            case 1:
                                return n.trys.push([1, , 6, 7]), [4, this._recordEvents(e)];
                            case 2:
                                n.sent(), n.label = 3;
                            case 3:
                                if (null === this.recordEventsPendingShouldLogMetadata) return [3, 5];
                                return t = this.recordEventsPendingShouldLogMetadata, this.recordEventsPendingShouldLogMetadata = null, [4, this._recordEvents(t)];
                            case 4:
                                return n.sent(), [3, 3];
                            case 5:
                                return [3, 7];
                            case 6:
                                return this.recordEventsInFlight = !1, this.recordEventsPendingShouldLogMetadata = null, [7];
                            case 7:
                                return [2]
                        }
                    })
                })
            }, t.prototype._recordEvents = function(e) {
                var t, n, r, i, s, o, a, l;
                return void 0 === e && (e = !0), (0, b.__awaiter)(this, void 0, void 0, function() {
                    var c, u, d, g, h, f, p, _, y, m, S, I, C, k, P, E, R, x, T = this;
                    return (0, b.__generator)(this, function(M) {
                        switch (M.label) {
                            case 0:
                                if (c = this.config, u = this.getShouldRecord(), d = null == (t = this.identifiers) ? void 0 : t.sessionId, !u || !d || !c) return [2];
                                return this.stopRecordingEvents(), [4, this.getRecordFunction()];
                            case 1:
                                if (!(g = M.sent())) return [2];
                                return [4, this.initializeNetworkObservers()];
                            case 2:
                                M.sent(), h = null == (n = c.loggingConfig) ? void 0 : n.network, f = [U, W, B, eI(c.serverZone, c.trackServerUrl)], null == (r = this.networkObservers) || r.start(function(e) {
                                    f.some(function(t) {
                                        return e.url.startsWith(t)
                                    }) || T.addCustomRRWebEvent(v.FETCH_REQUEST, e)
                                }, h), p = c.interactionConfig, _ = c.loggingConfig, y = (null == p ? void 0 : p.enabled) ? {
                                    mouseInteraction: this.eventsManager && (null == (i = this.clickHandler) ? void 0 : i.createHook({
                                        eventsManager: this.eventsManager,
                                        sessionId: d,
                                        deviceIdFn: this.getDeviceId.bind(this),
                                        mirror: g.mirror,
                                        ugcFilterRules: null != (s = p.ugcFilterRules) ? s : [],
                                        performanceOptions: null == (o = c.performanceConfig) ? void 0 : o.interaction
                                    })),
                                    scroll: this.scrollHook
                                } : {}, m = (null == p ? void 0 : p.enabled) && p.ugcFilterRules ? p.ugcFilterRules : [], this.loggerProvider.log("Session Replay capture beginning for ".concat(d, ".")), M.label = 3;
                            case 3:
                                if (M.trys.push([3, 5, , 6]), S = !!(null == (a = c.crossOriginIframes) ? void 0 : a.enabled), I = (null == (l = c.crossOriginIframes) ? void 0 : l.coordinateChildren) !== !1, (C = S && function() {
                                        try {
                                            var e = (0, w.getGlobalScope)();
                                            if (!e) return !1;
                                            return e.parent !== e
                                        } catch (e) {
                                            return !0
                                        }
                                    }()) && I) return this.crossOriginParentSignalCleanup = function(e) {
                                    var t = (0, w.getGlobalScope)();
                                    if (!t) return function() {};
                                    var n = t.parent;

                                    function r(t) {
                                        if (t.source === n) {
                                            var r = t.data;
                                            (null == r ? void 0 : r.type) === z && ("start" === r.action ? e.onStart() : "stop" === r.action && e.onStop())
                                        }
                                    }
                                    return t.addEventListener("message", r),
                                        function() {
                                            return t.removeEventListener("message", r)
                                        }
                                }({
                                    onStart: function() {
                                        return T._recordEventsInChildMode(g, d, c, y)
                                    },
                                    onStop: function() {
                                        try {
                                            T.recordCancelCallback && T.recordCancelCallback(), T.recordCancelCallback = null
                                        } catch (e) {
                                            T.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(e.toString()))
                                        }
                                    }
                                }), [2];
                                return k = this, P = g, E = [(0, b.__assign)({}, this.buildRRWebRecordOptions(c, y, function(e) {
                                    if (T.shouldOptOut()) {
                                        T.loggerProvider.log("Opting session ".concat(d, " out of recording due to optOut config.")), T.stopRecordingEvents(), T.sendEvents();
                                        return
                                    }
                                    e.type === ed.Meta && (e.data.href = ee(e.data.href, m)), T.eventCompressor ? T.eventCompressor.enqueueEvent(e, d) : T.pendingEmitEvents.push({
                                        event: e,
                                        sessionId: d
                                    })
                                }, "Error while capturing replay: "))], x = {}, [4, this.getRecordingPlugins(_)];
                            case 4:
                                return k.recordCancelCallback = P.apply(void 0, [b.__assign.apply(void 0, E.concat([(x.plugins = M.sent(), x.recordCrossOriginIframes = S, x)]))]), S && !C && I && (this.crossOriginIframeCoordinator || (this.crossOriginIframeCoordinator = new to), this.crossOriginIframeCoordinator.start()), this.addCustomRRWebEvent(v.DEBUG_INFO), e && this.addCustomRRWebEvent(v.METADATA, this.metadata), [3, 6];
                            case 5:
                                return R = M.sent(), this.loggerProvider.warn("Failed to initialize session replay:", R), [3, 6];
                            case 6:
                                return [2]
                        }
                    })
                })
            }, t.prototype.buildRRWebRecordOptions = function(e, t, n, r) {
                var i, s = this,
                    o = e.privacyConfig;
                return (0, b.__assign)((0, b.__assign)({
                    emit: n,
                    inlineStylesheet: e.shouldInlineStylesheet,
                    hooks: t,
                    maskAllInputs: !0,
                    maskTextClass: q,
                    blockClass: "amp-block",
                    blockSelector: this.getBlockSelectors(),
                    applyBackgroundColorToBlockedElements: e.applyBackgroundColorToBlockedElements,
                    maskInputFn: J("input", o, function() {
                        return s.currentPageUrl
                    }),
                    maskTextFn: J("text", o, function() {
                        return s.currentPageUrl
                    }),
                    maskAttributeFn: (i = function() {
                        return s.currentPageUrl
                    }, function(e, t, n) {
                        var r;
                        return "style" !== e && (null != (r = null == o ? void 0 : o.maskAttributes) ? r : []).includes(e) && $("text", o, n, null == i ? void 0 : i()) ? t.replace(/[^\s]/g, "*") : t
                    }),
                    maskTextSelector: this.getMaskTextSelectors()
                }, void 0 !== e.fullSnapshotIntervalMs && {
                    checkoutEveryNms: e.fullSnapshotIntervalMs
                }), {
                    recordCanvas: !1,
                    captureAdoptedStyleSheets: e.captureAdoptedStyleSheets,
                    slimDOMOptions: {
                        script: !0,
                        comment: !0,
                        headFavicon: !0,
                        headWhitespace: !0,
                        headMetaDescKeywords: !0,
                        headMetaSocial: !0,
                        headMetaRobots: !0,
                        headMetaHttpEquiv: !0,
                        headMetaAuthorship: !0,
                        headMetaVerification: !0
                    },
                    errorHandler: function(e) {
                        if (e.message.includes("insertRule") && e.message.includes("CSSStyleSheet") || e._external_) throw e;
                        return s.loggerProvider.warn(r, e.toString()), !0
                    }
                })
            }, t.prototype._recordEventsInChildMode = function(e, t, n, r) {
                try {
                    this.recordCancelCallback && this.recordCancelCallback(), this.recordCancelCallback = null, this.recordCancelCallback = e((0, b.__assign)((0, b.__assign)({}, this.buildRRWebRecordOptions(n, r, function() {}, "Error while capturing replay (child iframe): ")), {
                        recordCrossOriginIframes: !0
                    })), this.loggerProvider.log("Session Replay child iframe capture beginning for session ".concat(t, "."))
                } catch (e) {
                    this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:", e)
                }
            }, t.prototype.getDeviceId = function() {
                var e;
                return null == (e = this.identifiers) ? void 0 : e.deviceId
            }, t.prototype.getSessionId = function() {
                var e;
                return null == (e = this.identifiers) ? void 0 : e.sessionId
            }, t.prototype.flush = function(e) {
                var t;
                return void 0 === e && (e = !1), (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(n) {
                        return [2, null == (t = this.eventsManager) ? void 0 : t.flush(e)]
                    })
                })
            }, t.prototype.shutdown = function() {
                var e, t;
                null == (e = this.urlChangeCleanup) || e.call(this), null == (t = this.crossOriginParentSignalCleanup) || t.call(this), this.crossOriginParentSignalCleanup = null, this.teardownEventListeners(!0), this.stopRecordingEvents(), this.sendEvents()
            }, t.prototype.mapSDKType = function(e) {
                return "plugin" === e ? "@amplitude/plugin-session-replay-browser" : "segment" === e ? "@amplitude/segment-session-replay-plugin" : null
            }, t.prototype.setMetadata = function(e, t, n, r, i, s, o) {
                var a = (null == e ? void 0 : e.toString()) ? (0, ea.generateHashCode)(e.toString()) : void 0;
                this.metadata = {
                    joinedConfig: t,
                    localConfig: n,
                    remoteConfig: r,
                    sessionId: e,
                    hashValue: a,
                    sampleRate: t.sampleRate,
                    replaySDKType: this.mapSDKType(o),
                    replaySDKVersion: i,
                    standaloneSDKType: "@amplitude/session-replay-browser",
                    standaloneSDKVersion: s
                }
            }, t.prototype.initializeNetworkObservers = function() {
                var t, n, r;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var i, s;
                    return (0, b.__generator)(this, function(o) {
                        switch (o.label) {
                            case 0:
                                if (!((null == (r = null == (n = null == (t = this.config) ? void 0 : t.loggingConfig) ? void 0 : n.network) ? void 0 : r.enabled) && !this.networkObservers)) return [3, 4];
                                o.label = 1;
                            case 1:
                                return o.trys.push([1, 3, , 4]), [4, e.A(188281)];
                            case 2:
                                return i = o.sent().NetworkObservers, this.networkObservers = new i, [3, 4];
                            case 3:
                                return s = o.sent(), this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:", s), [3, 4];
                            case 4:
                                return [2]
                        }
                    })
                })
            }, t
        }(),
        tl = function(e) {
            return function() {
                var t = e.config || er();
                return {
                    logger: t.loggerProvider,
                    logLevel: t.logLevel
                }
            }
        };
    let tc = (u = new ta, {
        init: (0, C.debugWrapper)(u.init.bind(u), "init", tl(u)),
        evaluateTargetingAndCapture: (0, C.debugWrapper)(u.evaluateTargetingAndCapture.bind(u), "evaluateTargetingAndRecord", tl(u)),
        setSessionId: (0, C.debugWrapper)(u.setSessionId.bind(u), "setSessionId", tl(u)),
        getSessionId: (0, C.debugWrapper)(u.getSessionId.bind(u), "getSessionId", tl(u)),
        getSessionReplayProperties: (0, C.debugWrapper)(u.getSessionReplayProperties.bind(u), "getSessionReplayProperties", tl(u)),
        flush: (0, C.debugWrapper)(u.flush.bind(u), "flush", tl(u)),
        shutdown: (0, C.debugWrapper)(u.shutdown.bind(u), "shutdown", tl(u))
    });
    var tu = tc.init,
        td = tc.setSessionId,
        tg = tc.getSessionId,
        th = tc.getSessionReplayProperties,
        tv = tc.flush,
        tf = tc.shutdown,
        tp = tc.evaluateTargetingAndCapture,
        t_ = e.i(621108);
    (d = y || (y = {})).SET = "$set", d.SET_ONCE = "$setOnce", d.ADD = "$add", d.APPEND = "$append", d.PREPEND = "$prepend", d.REMOVE = "$remove", d.PREINSERT = "$preInsert", d.POSTINSERT = "$postInsert", d.UNSET = "$unset", d.CLEAR_ALL = "$clearAll", (g = m || (m = {})).REVENUE_PRODUCT_ID = "$productId", g.REVENUE_QUANTITY = "$quantity", g.REVENUE_PRICE = "$price", g.REVENUE_TYPE = "$revenueType", g.REVENUE_CURRENCY = "$currency", g.REVENUE = "$revenue", (h = S || (S = {})).IDENTIFY = "$identify", h.GROUP_IDENTIFY = "$groupidentify", h.REVENUE = "revenue_amount";
    var ty = [y.SET, y.SET_ONCE, y.ADD, y.APPEND, y.PREPEND, y.POSTINSERT],
        tm = function(e) {
            if (e.user_properties) {
                var t = {};
                return Object.keys(e.user_properties).forEach(function(n) {
                    if (ty.includes(n)) {
                        var r = e.user_properties && e.user_properties[n];
                        t = (0, b.__assign)((0, b.__assign)({}, t), r)
                    }
                }), t
            }
        },
        tS = "1.30.3",
        tb = "".concat("[Amplitude]", " Session Replay ID"),
        tI = function() {
            function e(t) {
                this.name = e.pluginName, this.type = "enrichment", this.config = null, this.sessionReplay = {
                    flush: tv,
                    getSessionId: tg,
                    getSessionReplayProperties: th,
                    init: tu,
                    setSessionId: td,
                    shutdown: tf,
                    evaluateTargetingAndCapture: tp
                }, this.options = (0, b.__assign)({
                    forceSessionTracking: !1
                }, t), this.srInitOptions = this.options
            }
            return e.prototype.setup = function(e, t) {
                var n, r, i, s, o, a, l, c;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var t, u;
                    return (0, b.__generator)(this, function(d) {
                        switch (d.label) {
                            case 0:
                                var g;
                                return d.trys.push([0, 2, , 3]), null == e || e.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(tS, ".")), this.config = e, this.options.forceSessionTracking && ("boolean" == typeof e.defaultTracking ? !1 === e.defaultTracking && (e.defaultTracking = {
                                    pageViews: !1,
                                    formInteractions: !1,
                                    fileDownloads: !1,
                                    sessions: !0
                                }) : e.defaultTracking = (0, b.__assign)((0, b.__assign)({}, e.defaultTracking), {
                                    sessions: !0
                                })), t = (void 0 === (g = this.config.instanceName) && (g = "$default_instance"), t_.AnalyticsConnector.getInstance(g)).identityStore.getIdentity().userProperties, this.srInitOptions = {
                                    instanceName: this.config.instanceName,
                                    deviceId: null != (n = this.options.deviceId) ? n : this.config.deviceId,
                                    optOut: this.config.optOut,
                                    sessionId: this.options.customSessionId ? void 0 : this.config.sessionId,
                                    loggerProvider: this.config.loggerProvider,
                                    logLevel: this.config.logLevel,
                                    flushMaxRetries: this.config.flushMaxRetries,
                                    serverZone: this.config.serverZone,
                                    configServerUrl: this.options.configServerUrl || (null == (r = this.config.remoteConfig) ? void 0 : r.serverUrl),
                                    trackServerUrl: this.options.trackServerUrl,
                                    sampleRate: this.options.sampleRate,
                                    privacyConfig: {
                                        blockSelector: null == (i = this.options.privacyConfig) ? void 0 : i.blockSelector,
                                        maskSelector: null == (s = this.options.privacyConfig) ? void 0 : s.maskSelector,
                                        unmaskSelector: null == (o = this.options.privacyConfig) ? void 0 : o.unmaskSelector,
                                        defaultMaskLevel: null == (a = this.options.privacyConfig) ? void 0 : a.defaultMaskLevel
                                    },
                                    debugMode: this.options.debugMode,
                                    shouldInlineStylesheet: this.options.shouldInlineStylesheet,
                                    version: {
                                        type: "plugin",
                                        version: tS
                                    },
                                    performanceConfig: this.options.performanceConfig,
                                    storeType: this.options.storeType,
                                    useWebWorker: null != (l = this.options.useWebWorker) ? l : null == (c = this.options.experimental) ? void 0 : c.useWebWorker,
                                    userProperties: t,
                                    applyBackgroundColorToBlockedElements: this.options.applyBackgroundColorToBlockedElements,
                                    interactionConfig: this.options.interactionConfig,
                                    captureDocumentTitle: this.options.captureDocumentTitle,
                                    enableUrlChangePolling: this.options.enableUrlChangePolling,
                                    urlChangePollingInterval: this.options.urlChangePollingInterval,
                                    captureAdoptedStyleSheets: this.options.captureAdoptedStyleSheets,
                                    crossOriginIframes: this.options.crossOriginIframes
                                }, [4, this.sessionReplay.init(e.apiKey, this.srInitOptions).promise];
                            case 1:
                                return d.sent(), [3, 3];
                            case 2:
                                return u = d.sent(), null == e || e.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(u.message)), [3, 3];
                            case 3:
                                return [2]
                        }
                    })
                })
            }, e.prototype.onSessionIdChanged = function(e) {
                var t;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(n) {
                        switch (n.label) {
                            case 0:
                                return null == (t = this.config) || t.loggerProvider.debug("Analytics session id is changed to ".concat(e, ", SR session id is ").concat(String(this.sessionReplay.getSessionId()), ".")), [4, this.sessionReplay.setSessionId(e).promise];
                            case 1:
                                return n.sent(), [2]
                        }
                    })
                })
            }, e.prototype.onOptOutChanged = function(e) {
                var t;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(n) {
                        switch (n.label) {
                            case 0:
                                if (null == (t = this.config) || t.loggerProvider.debug("optOut is changed to ".concat(String(e), ", calling ").concat(e ? "sessionReplay.shutdown()" : "sessionReplay.init()", ".")), !e) return [3, 1];
                                return this.sessionReplay.shutdown(), [3, 4];
                            case 1:
                                if (null == this.config) return [3, 3];
                                return [4, this.sessionReplay.init(this.config.apiKey, this.srInitOptions).promise];
                            case 2:
                                n.sent(), n.label = 3;
                            case 3:
                                n.label = 4;
                            case 4:
                                return [2]
                        }
                    })
                })
            }, e.prototype.execute = function(e) {
                var t, n, r;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    var i, s, o, a, l;
                    return (0, b.__generator)(this, function(c) {
                        switch (c.label) {
                            case 0:
                                if (c.trys.push([0, 9, , 10]), !this.options.customSessionId) return [3, 4];
                                if (!(i = this.options.customSessionId(e))) return [3, 3];
                                if (i === this.sessionReplay.getSessionId()) return [3, 2];
                                return [4, this.sessionReplay.setSessionId(i).promise];
                            case 1:
                                c.sent(), c.label = 2;
                            case 2:
                                s = this.sessionReplay.getSessionReplayProperties(), e.event_properties = (0, b.__assign)((0, b.__assign)({}, e.event_properties), s), c.label = 3;
                            case 3:
                                return [3, 8];
                            case 4:
                                if (!((i = null == (t = this.config) ? void 0 : t.sessionId) && i !== this.sessionReplay.getSessionId())) return [3, 6];
                                return [4, this.sessionReplay.setSessionId(i).promise];
                            case 5:
                                c.sent(), c.label = 6;
                            case 6:
                                if (!(i && i === e.session_id)) return [3, 8];
                                return o = void 0, e.event_type === I.SpecialEventType.IDENTIFY && (o = tm(e)), a = (0, w.getGlobalScope)(), [4, this.sessionReplay.evaluateTargetingAndCapture({
                                    event: e,
                                    userProperties: o,
                                    page: (null == (n = null == a ? void 0 : a.location) ? void 0 : n.href) != null ? {
                                        url: a.location.href
                                    } : void 0
                                })];
                            case 7:
                                c.sent(), s = this.sessionReplay.getSessionReplayProperties(), e.event_properties = (0, b.__assign)((0, b.__assign)({}, e.event_properties), s), c.label = 8;
                            case 8:
                                return e.event_type === I.SpecialEventType.IDENTIFY && e.event_properties && delete e.event_properties[tb], [2, Promise.resolve(e)];
                            case 9:
                                return l = c.sent(), null == (r = this.config) || r.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(l.message)), [2, Promise.resolve(e)];
                            case 10:
                                return [2]
                        }
                    })
                })
            }, e.prototype.teardown = function() {
                var e;
                return (0, b.__awaiter)(this, void 0, void 0, function() {
                    return (0, b.__generator)(this, function(t) {
                        try {
                            this.sessionReplay.shutdown(), this.config = null
                        } catch (t) {
                            null == (e = this.config) || e.loggerProvider.error("Session Replay: teardown failed due to ".concat(t.message))
                        }
                        return [2]
                    })
                })
            }, e.prototype.getSessionReplayProperties = function() {
                return this.sessionReplay.getSessionReplayProperties()
            }, e.pluginName = "@amplitude/plugin-session-replay-browser", e
        }(),
        tw = function(e) {
            return new tI(e)
        };
    e.s(["SessionReplayPlugin", 0, tI, "plugin", 0, tw, "sessionReplayPlugin", 0, tw], 719465)
}]);

//# debugId=b6ae752e-dfab-c403-213f-c3df8c6118b4