/**
 * @license
 * Copyright 2025 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const de = () => {};
var x = {};
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const Y = function(t) {
        const e = [];
        let n = 0;
        for (let r = 0; r < t.length; r++) {
            let s = t.charCodeAt(r);
            s < 128 ? e[n++] = s : s < 2048 ? (e[n++] = s >> 6 | 192, e[n++] = s & 63 | 128) : (s & 64512) === 55296 && r + 1 < t.length && (t.charCodeAt(r + 1) & 64512) === 56320 ? (s = 65536 + ((s & 1023) << 10) + (t.charCodeAt(++r) & 1023), e[n++] = s >> 18 | 240, e[n++] = s >> 12 & 63 | 128, e[n++] = s >> 6 & 63 | 128, e[n++] = s & 63 | 128) : (e[n++] = s >> 12 | 224, e[n++] = s >> 6 & 63 | 128, e[n++] = s & 63 | 128)
        }
        return e
    },
    he = function(t) {
        const e = [];
        let n = 0,
            r = 0;
        for (; n < t.length;) {
            const s = t[n++];
            if (s < 128) e[r++] = String.fromCharCode(s);
            else if (s > 191 && s < 224) {
                const i = t[n++];
                e[r++] = String.fromCharCode((s & 31) << 6 | i & 63)
            } else if (s > 239 && s < 365) {
                const i = t[n++],
                    a = t[n++],
                    c = t[n++],
                    o = ((s & 7) << 18 | (i & 63) << 12 | (a & 63) << 6 | c & 63) - 65536;
                e[r++] = String.fromCharCode(55296 + (o >> 10)), e[r++] = String.fromCharCode(56320 + (o & 1023))
            } else {
                const i = t[n++],
                    a = t[n++];
                e[r++] = String.fromCharCode((s & 15) << 12 | (i & 63) << 6 | a & 63)
            }
        }
        return e.join("")
    },
    X = {
        byteToCharMap_: null,
        charToByteMap_: null,
        byteToCharMapWebSafe_: null,
        charToByteMapWebSafe_: null,
        ENCODED_VALS_BASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
        get ENCODED_VALS() {
            return this.ENCODED_VALS_BASE + "+/="
        },
        get ENCODED_VALS_WEBSAFE() {
            return this.ENCODED_VALS_BASE + "-_."
        },
        HAS_NATIVE_SUPPORT: typeof atob == "function",
        encodeByteArray(t, e) {
            if (!Array.isArray(t)) throw Error("encodeByteArray takes an array as a parameter");
            this.init_();
            const n = e ? this.byteToCharMapWebSafe_ : this.byteToCharMap_,
                r = [];
            for (let s = 0; s < t.length; s += 3) {
                const i = t[s],
                    a = s + 1 < t.length,
                    c = a ? t[s + 1] : 0,
                    o = s + 2 < t.length,
                    d = o ? t[s + 2] : 0,
                    v = i >> 2,
                    p = (i & 3) << 4 | c >> 4;
                let D = (c & 15) << 2 | d >> 6,
                    I = d & 63;
                o || (I = 64, a || (D = 64)), r.push(n[v], n[p], n[D], n[I])
            }
            return r.join("")
        },
        encodeString(t, e) {
            return this.HAS_NATIVE_SUPPORT && !e ? btoa(t) : this.encodeByteArray(Y(t), e)
        },
        decodeString(t, e) {
            return this.HAS_NATIVE_SUPPORT && !e ? atob(t) : he(this.decodeStringToByteArray(t, e))
        },
        decodeStringToByteArray(t, e) {
            this.init_();
            const n = e ? this.charToByteMapWebSafe_ : this.charToByteMap_,
                r = [];
            for (let s = 0; s < t.length;) {
                const i = n[t.charAt(s++)],
                    c = s < t.length ? n[t.charAt(s)] : 0;
                ++s;
                const d = s < t.length ? n[t.charAt(s)] : 64;
                ++s;
                const p = s < t.length ? n[t.charAt(s)] : 64;
                if (++s, i == null || c == null || d == null || p == null) throw new fe;
                const D = i << 2 | c >> 4;
                if (r.push(D), d !== 64) {
                    const I = c << 4 & 240 | d >> 2;
                    if (r.push(I), p !== 64) {
                        const le = d << 6 & 192 | p;
                        r.push(le)
                    }
                }
            }
            return r
        },
        init_() {
            if (!this.byteToCharMap_) {
                this.byteToCharMap_ = {}, this.charToByteMap_ = {}, this.byteToCharMapWebSafe_ = {}, this.charToByteMapWebSafe_ = {};
                for (let t = 0; t < this.ENCODED_VALS.length; t++) this.byteToCharMap_[t] = this.ENCODED_VALS.charAt(t), this.charToByteMap_[this.byteToCharMap_[t]] = t, this.byteToCharMapWebSafe_[t] = this.ENCODED_VALS_WEBSAFE.charAt(t), this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]] = t, t >= this.ENCODED_VALS_BASE.length && (this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)] = t, this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)] = t)
            }
        }
    };
class fe extends Error {
    constructor() {
        super(...arguments), this.name = "DecodeBase64StringError"
    }
}
const ue = function(t) {
        const e = Y(t);
        return X.encodeByteArray(e, !0)
    },
    q = function(t) {
        return ue(t).replace(/\./g, "")
    },
    Z = function(t) {
        try {
            return X.decodeString(t, !0)
        } catch {}
        return null
    };
/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function pe() {
    if (typeof self < "u") return self;
    if (typeof window < "u") return window;
    if (typeof global < "u") return global;
    throw new Error("Unable to locate global object.")
}
/**
 * @license
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const me = () => pe().__FIREBASE_DEFAULTS__,
    ge = () => {
        if (typeof process > "u" || typeof x > "u") return;
        const t = x.__FIREBASE_DEFAULTS__;
        if (t) return JSON.parse(t)
    },
    be = () => {
        if (typeof document > "u") return;
        let t;
        try {
            t = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)
        } catch {
            return
        }
        const e = t && Z(t[1]);
        return e && JSON.parse(e)
    },
    _e = () => {
        try {
            return de() || me() || ge() || be()
        } catch {
            return
        }
    },
    Q = () => {
        var t;
        return (t = _e()) === null || t === void 0 ? void 0 : t.config
    };
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class ye {
    constructor() {
        this.reject = () => {}, this.resolve = () => {}, this.promise = new Promise((e, n) => {
            this.resolve = e, this.reject = n
        })
    }
    wrapCallback(e) {
        return (n, r) => {
            n ? this.reject(n) : this.resolve(r), typeof e == "function" && (this.promise.catch(() => {}), e.length === 1 ? e(n) : e(n, r))
        }
    }
}

function Ee() {
    return typeof window < "u" || ee()
}

function ee() {
    return typeof WorkerGlobalScope < "u" && typeof self < "u" && self instanceof WorkerGlobalScope
}

function jt() {
    const t = typeof chrome == "object" ? chrome.runtime : typeof browser == "object" ? browser.runtime : void 0;
    return typeof t == "object" && t.id !== void 0
}

function ve() {
    try {
        return typeof indexedDB == "object"
    } catch {
        return !1
    }
}

function De() {
    return new Promise((t, e) => {
        try {
            let n = !0;
            const r = "validate-browser-context-for-indexeddb-analytics-module",
                s = self.indexedDB.open(r);
            s.onsuccess = () => {
                s.result.close(), n || self.indexedDB.deleteDatabase(r), t(!0)
            }, s.onupgradeneeded = () => {
                n = !1
            }, s.onerror = () => {
                var i;
                e(((i = s.error) === null || i === void 0 ? void 0 : i.message) || "")
            }
        } catch (n) {
            e(n)
        }
    })
}

function Vt() {
    return !(typeof navigator > "u" || !navigator.cookieEnabled)
}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const Ie = "FirebaseError";
class E extends Error {
    constructor(e, n, r) {
        super(n), this.code = e, this.customData = r, this.name = Ie, Object.setPrototypeOf(this, E.prototype), Error.captureStackTrace && Error.captureStackTrace(this, te.prototype.create)
    }
}
class te {
    constructor(e, n, r) {
        this.service = e, this.serviceName = n, this.errors = r
    }
    create(e, ...n) {
        const r = n[0] || {},
            s = `${this.service}/${e}`,
            i = this.errors[e],
            a = i ? Ce(i, r) : "Error",
            c = `${this.serviceName}: ${a} (${s}).`;
        return new E(s, c, r)
    }
}

function Ce(t, e) {
    return t.replace(Se, (n, r) => {
        const s = e[r];
        return s != null ? String(s) : `<${r}?>`
    })
}
const Se = /\{\$([^}]+)}/g;

function R(t, e) {
    if (t === e) return !0;
    const n = Object.keys(t),
        r = Object.keys(e);
    for (const s of n) {
        if (!r.includes(s)) return !1;
        const i = t[s],
            a = e[s];
        if (k(i) && k(a)) {
            if (!R(i, a)) return !1
        } else if (i !== a) return !1
    }
    for (const s of r)
        if (!n.includes(s)) return !1;
    return !0
}

function k(t) {
    return t !== null && typeof t == "object"
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const we = 1e3,
    Ae = 2,
    Be = 14400 * 1e3,
    Oe = .5;

function Ut(t, e = we, n = Ae) {
    const r = e * Math.pow(n, t),
        s = Math.round(Oe * r * (Math.random() - .5) * 2);
    return Math.min(Be, r + s)
}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function Wt(t) {
    return t && t._delegate ? t._delegate : t
}
class S {
    constructor(e, n, r) {
        this.name = e, this.instanceFactory = n, this.type = r, this.multipleInstances = !1, this.serviceProps = {}, this.instantiationMode = "LAZY", this.onInstanceCreated = null
    }
    setInstantiationMode(e) {
        return this.instantiationMode = e, this
    }
    setMultipleInstances(e) {
        return this.multipleInstances = e, this
    }
    setServiceProps(e) {
        return this.serviceProps = e, this
    }
    setInstanceCreatedCallback(e) {
        return this.onInstanceCreated = e, this
    }
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const m = "[DEFAULT]";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class Te {
    constructor(e, n) {
        this.name = e, this.container = n, this.component = null, this.instances = new Map, this.instancesDeferred = new Map, this.instancesOptions = new Map, this.onInitCallbacks = new Map
    }
    get(e) {
        const n = this.normalizeInstanceIdentifier(e);
        if (!this.instancesDeferred.has(n)) {
            const r = new ye;
            if (this.instancesDeferred.set(n, r), this.isInitialized(n) || this.shouldAutoInitialize()) try {
                const s = this.getOrInitializeService({
                    instanceIdentifier: n
                });
                s && r.resolve(s)
            } catch {}
        }
        return this.instancesDeferred.get(n).promise
    }
    getImmediate(e) {
        var n;
        const r = this.normalizeInstanceIdentifier(e == null ? void 0 : e.identifier),
            s = (n = e == null ? void 0 : e.optional) !== null && n !== void 0 ? n : !1;
        if (this.isInitialized(r) || this.shouldAutoInitialize()) try {
            return this.getOrInitializeService({
                instanceIdentifier: r
            })
        } catch (i) {
            if (s) return null;
            throw i
        } else {
            if (s) return null;
            throw Error(`Service ${this.name} is not available`)
        }
    }
    getComponent() {
        return this.component
    }
    setComponent(e) {
        if (e.name !== this.name) throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);
        if (this.component) throw Error(`Component for ${this.name} has already been provided`);
        if (this.component = e, !!this.shouldAutoInitialize()) {
            if (Re(e)) try {
                this.getOrInitializeService({
                    instanceIdentifier: m
                })
            } catch {}
            for (const [n, r] of this.instancesDeferred.entries()) {
                const s = this.normalizeInstanceIdentifier(n);
                try {
                    const i = this.getOrInitializeService({
                        instanceIdentifier: s
                    });
                    r.resolve(i)
                } catch {}
            }
        }
    }
    clearInstance(e = m) {
        this.instancesDeferred.delete(e), this.instancesOptions.delete(e), this.instances.delete(e)
    }
    async delete() {
        const e = Array.from(this.instances.values());
        await Promise.all([...e.filter(n => "INTERNAL" in n).map(n => n.INTERNAL.delete()), ...e.filter(n => "_delete" in n).map(n => n._delete())])
    }
    isComponentSet() {
        return this.component != null
    }
    isInitialized(e = m) {
        return this.instances.has(e)
    }
    getOptions(e = m) {
        return this.instancesOptions.get(e) || {}
    }
    initialize(e = {}) {
        const {
            options: n = {}
        } = e, r = this.normalizeInstanceIdentifier(e.instanceIdentifier);
        if (this.isInitialized(r)) throw Error(`${this.name}(${r}) has already been initialized`);
        if (!this.isComponentSet()) throw Error(`Component ${this.name} has not been registered yet`);
        const s = this.getOrInitializeService({
            instanceIdentifier: r,
            options: n
        });
        for (const [i, a] of this.instancesDeferred.entries()) {
            const c = this.normalizeInstanceIdentifier(i);
            r === c && a.resolve(s)
        }
        return s
    }
    onInit(e, n) {
        var r;
        const s = this.normalizeInstanceIdentifier(n),
            i = (r = this.onInitCallbacks.get(s)) !== null && r !== void 0 ? r : new Set;
        i.add(e), this.onInitCallbacks.set(s, i);
        const a = this.instances.get(s);
        return a && e(a, s), () => {
            i.delete(e)
        }
    }
    invokeOnInitCallbacks(e, n) {
        const r = this.onInitCallbacks.get(n);
        if (r)
            for (const s of r) try {
                s(e, n)
            } catch {}
    }
    getOrInitializeService({
        instanceIdentifier: e,
        options: n = {}
    }) {
        let r = this.instances.get(e);
        if (!r && this.component && (r = this.component.instanceFactory(this.container, {
                instanceIdentifier: Me(e),
                options: n
            }), this.instances.set(e, r), this.instancesOptions.set(e, n), this.invokeOnInitCallbacks(r, e), this.component.onInstanceCreated)) try {
            this.component.onInstanceCreated(this.container, e, r)
        } catch {}
        return r || null
    }
    normalizeInstanceIdentifier(e = m) {
        return this.component ? this.component.multipleInstances ? e : m : e
    }
    shouldAutoInitialize() {
        return !!this.component && this.component.instantiationMode !== "EXPLICIT"
    }
}

function Me(t) {
    return t === m ? void 0 : t
}

function Re(t) {
    return t.instantiationMode === "EAGER"
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class ne {
    constructor(e) {
        this.name = e, this.providers = new Map
    }
    addComponent(e) {
        const n = this.getProvider(e.name);
        if (n.isComponentSet()) throw new Error(`Component ${e.name} has already been registered with ${this.name}`);
        n.setComponent(e)
    }
    addOrOverwriteComponent(e) {
        this.getProvider(e.name).isComponentSet() && this.providers.delete(e.name), this.addComponent(e)
    }
    getProvider(e) {
        if (this.providers.has(e)) return this.providers.get(e);
        const n = new Te(e, this);
        return this.providers.set(e, n), n
    }
    getProviders() {
        return Array.from(this.providers.values())
    }
}
/**
 * @license
 * Copyright 2017 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const H = [];
var l;
(function(t) {
    t[t.DEBUG = 0] = "DEBUG", t[t.VERBOSE = 1] = "VERBOSE", t[t.INFO = 2] = "INFO", t[t.WARN = 3] = "WARN", t[t.ERROR = 4] = "ERROR", t[t.SILENT = 5] = "SILENT"
})(l || (l = {}));
const re = {
        debug: l.DEBUG,
        verbose: l.VERBOSE,
        info: l.INFO,
        warn: l.WARN,
        error: l.ERROR,
        silent: l.SILENT
    },
    Le = l.INFO,
    Ne = {
        [l.DEBUG]: "log",
        [l.VERBOSE]: "log",
        [l.INFO]: "info",
        [l.WARN]: "warn",
        [l.ERROR]: "error"
    },
    $e = (t, e, ...n) => {
        if (e < t.logLevel) return;
        const r = new Date().toISOString(),
            s = Ne[e];
        if (!s) throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)
    };
class Fe {
    constructor(e) {
        this.name = e, this._logLevel = Le, this._logHandler = $e, this._userLogHandler = null, H.push(this)
    }
    get logLevel() {
        return this._logLevel
    }
    set logLevel(e) {
        if (!(e in l)) throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);
        this._logLevel = e
    }
    setLogLevel(e) {
        this._logLevel = typeof e == "string" ? re[e] : e
    }
    get logHandler() {
        return this._logHandler
    }
    set logHandler(e) {
        if (typeof e != "function") throw new TypeError("Value assigned to `logHandler` must be a function");
        this._logHandler = e
    }
    get userLogHandler() {
        return this._userLogHandler
    }
    set userLogHandler(e) {
        this._userLogHandler = e
    }
    debug(...e) {
        this._userLogHandler && this._userLogHandler(this, l.DEBUG, ...e), this._logHandler(this, l.DEBUG, ...e)
    }
    log(...e) {
        this._userLogHandler && this._userLogHandler(this, l.VERBOSE, ...e), this._logHandler(this, l.VERBOSE, ...e)
    }
    info(...e) {
        this._userLogHandler && this._userLogHandler(this, l.INFO, ...e), this._logHandler(this, l.INFO, ...e)
    }
    warn(...e) {
        this._userLogHandler && this._userLogHandler(this, l.WARN, ...e), this._logHandler(this, l.WARN, ...e)
    }
    error(...e) {
        this._userLogHandler && this._userLogHandler(this, l.ERROR, ...e), this._logHandler(this, l.ERROR, ...e)
    }
}

function He(t) {
    H.forEach(e => {
        e.setLogLevel(t)
    })
}

function Pe(t, e) {
    for (const n of H) {
        let r = null;
        e && e.level && (r = re[e.level]), t === null ? n.userLogHandler = null : n.userLogHandler = (s, i, ...a) => {
            const c = a.map(o => {
                if (o == null) return null;
                if (typeof o == "string") return o;
                if (typeof o == "number" || typeof o == "boolean") return o.toString();
                if (o instanceof Error) return o.message;
                try {
                    return JSON.stringify(o)
                } catch {
                    return null
                }
            }).filter(o => o).join(" ");
            i >= (r ? ? s.logLevel) && t({
                level: l[i].toLowerCase(),
                message: c,
                args: a,
                type: s.name
            })
        }
    }
}
const xe = (t, e) => e.some(n => t instanceof n);
let z, j;

function ke() {
    return z || (z = [IDBDatabase, IDBObjectStore, IDBIndex, IDBCursor, IDBTransaction])
}

function ze() {
    return j || (j = [IDBCursor.prototype.advance, IDBCursor.prototype.continue, IDBCursor.prototype.continuePrimaryKey])
}
const se = new WeakMap,
    L = new WeakMap,
    ie = new WeakMap,
    B = new WeakMap,
    P = new WeakMap;

function je(t) {
    const e = new Promise((n, r) => {
        const s = () => {
                t.removeEventListener("success", i), t.removeEventListener("error", a)
            },
            i = () => {
                n(f(t.result)), s()
            },
            a = () => {
                r(t.error), s()
            };
        t.addEventListener("success", i), t.addEventListener("error", a)
    });
    return e.then(n => {
        n instanceof IDBCursor && se.set(n, t)
    }).catch(() => {}), P.set(e, t), e
}

function Ve(t) {
    if (L.has(t)) return;
    const e = new Promise((n, r) => {
        const s = () => {
                t.removeEventListener("complete", i), t.removeEventListener("error", a), t.removeEventListener("abort", a)
            },
            i = () => {
                n(), s()
            },
            a = () => {
                r(t.error || new DOMException("AbortError", "AbortError")), s()
            };
        t.addEventListener("complete", i), t.addEventListener("error", a), t.addEventListener("abort", a)
    });
    L.set(t, e)
}
let N = {
    get(t, e, n) {
        if (t instanceof IDBTransaction) {
            if (e === "done") return L.get(t);
            if (e === "objectStoreNames") return t.objectStoreNames || ie.get(t);
            if (e === "store") return n.objectStoreNames[1] ? void 0 : n.objectStore(n.objectStoreNames[0])
        }
        return f(t[e])
    },
    set(t, e, n) {
        return t[e] = n, !0
    },
    has(t, e) {
        return t instanceof IDBTransaction && (e === "done" || e === "store") ? !0 : e in t
    }
};

function Ue(t) {
    N = t(N)
}

function We(t) {
    return t === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype) ? function(e, ...n) {
        const r = t.call(O(this), e, ...n);
        return ie.set(r, e.sort ? e.sort() : [e]), f(r)
    } : ze().includes(t) ? function(...e) {
        return t.apply(O(this), e), f(se.get(this))
    } : function(...e) {
        return f(t.apply(O(this), e))
    }
}

function Ge(t) {
    return typeof t == "function" ? We(t) : (t instanceof IDBTransaction && Ve(t), xe(t, ke()) ? new Proxy(t, N) : t)
}

function f(t) {
    if (t instanceof IDBRequest) return je(t);
    if (B.has(t)) return B.get(t);
    const e = Ge(t);
    return e !== t && (B.set(t, e), P.set(e, t)), e
}
const O = t => P.get(t);

function Je(t, e, {
    blocked: n,
    upgrade: r,
    blocking: s,
    terminated: i
} = {}) {
    const a = indexedDB.open(t, e),
        c = f(a);
    return r && a.addEventListener("upgradeneeded", o => {
        r(f(a.result), o.oldVersion, o.newVersion, f(a.transaction), o)
    }), n && a.addEventListener("blocked", o => n(o.oldVersion, o.newVersion, o)), c.then(o => {
        i && o.addEventListener("close", () => i()), s && o.addEventListener("versionchange", d => s(d.oldVersion, d.newVersion, d))
    }).catch(() => {}), c
}

function Gt(t, {
    blocked: e
} = {}) {
    const n = indexedDB.deleteDatabase(t);
    return e && n.addEventListener("blocked", r => e(r.oldVersion, r)), f(n).then(() => {})
}
const Ke = ["get", "getKey", "getAll", "getAllKeys", "count"],
    Ye = ["put", "add", "delete", "clear"],
    T = new Map;

function V(t, e) {
    if (!(t instanceof IDBDatabase && !(e in t) && typeof e == "string")) return;
    if (T.get(e)) return T.get(e);
    const n = e.replace(/FromIndex$/, ""),
        r = e !== n,
        s = Ye.includes(n);
    if (!(n in (r ? IDBIndex : IDBObjectStore).prototype) || !(s || Ke.includes(n))) return;
    const i = async function(a, ...c) {
        const o = this.transaction(a, s ? "readwrite" : "readonly");
        let d = o.store;
        return r && (d = d.index(c.shift())), (await Promise.all([d[n](...c), s && o.done]))[0]
    };
    return T.set(e, i), i
}
Ue(t => ({ ...t,
    get: (e, n, r) => V(e, n) || t.get(e, n, r),
    has: (e, n) => !!V(e, n) || t.has(e, n)
}));
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class Xe {
    constructor(e) {
        this.container = e
    }
    getPlatformInfoString() {
        return this.container.getProviders().map(n => {
            if (qe(n)) {
                const r = n.getImmediate();
                return `${r.library}/${r.version}`
            } else return null
        }).filter(n => n).join(" ")
    }
}

function qe(t) {
    const e = t.getComponent();
    return (e == null ? void 0 : e.type) === "VERSION"
}
const w = "@firebase/app",
    $ = "0.13.2";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const u = new Fe("@firebase/app"),
    Ze = "@firebase/app-compat",
    Qe = "@firebase/analytics-compat",
    et = "@firebase/analytics",
    tt = "@firebase/app-check-compat",
    nt = "@firebase/app-check",
    rt = "@firebase/auth",
    st = "@firebase/auth-compat",
    it = "@firebase/database",
    at = "@firebase/data-connect",
    ot = "@firebase/database-compat",
    ct = "@firebase/functions",
    lt = "@firebase/functions-compat",
    dt = "@firebase/installations",
    ht = "@firebase/installations-compat",
    ft = "@firebase/messaging",
    ut = "@firebase/messaging-compat",
    pt = "@firebase/performance",
    mt = "@firebase/performance-compat",
    gt = "@firebase/remote-config",
    bt = "@firebase/remote-config-compat",
    _t = "@firebase/storage",
    yt = "@firebase/storage-compat",
    Et = "@firebase/firestore",
    vt = "@firebase/ai",
    Dt = "@firebase/firestore-compat",
    It = "firebase",
    Ct = "11.10.0";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const A = "[DEFAULT]",
    St = {
        [w]: "fire-core",
        [Ze]: "fire-core-compat",
        [et]: "fire-analytics",
        [Qe]: "fire-analytics-compat",
        [nt]: "fire-app-check",
        [tt]: "fire-app-check-compat",
        [rt]: "fire-auth",
        [st]: "fire-auth-compat",
        [it]: "fire-rtdb",
        [at]: "fire-data-connect",
        [ot]: "fire-rtdb-compat",
        [ct]: "fire-fn",
        [lt]: "fire-fn-compat",
        [dt]: "fire-iid",
        [ht]: "fire-iid-compat",
        [ft]: "fire-fcm",
        [ut]: "fire-fcm-compat",
        [pt]: "fire-perf",
        [mt]: "fire-perf-compat",
        [gt]: "fire-rc",
        [bt]: "fire-rc-compat",
        [_t]: "fire-gcs",
        [yt]: "fire-gcs-compat",
        [Et]: "fire-fst",
        [Dt]: "fire-fst-compat",
        [vt]: "fire-vertex",
        "fire-js": "fire-js",
        [It]: "fire-js-all"
    };
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const g = new Map,
    b = new Map,
    _ = new Map;

function U(t, e) {
    try {
        t.container.addComponent(e)
    } catch (n) {
        u.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`, n)
    }
}

function Jt(t, e) {
    t.container.addOrOverwriteComponent(e)
}

function F(t) {
    const e = t.name;
    if (_.has(e)) return u.debug(`There were multiple attempts to register component ${e}.`), !1;
    _.set(e, t);
    for (const n of g.values()) U(n, t);
    for (const n of b.values()) U(n, t);
    return !0
}

function wt(t, e) {
    const n = t.container.getProvider("heartbeat").getImmediate({
        optional: !0
    });
    return n && n.triggerHeartbeat(), t.container.getProvider(e)
}

function Kt(t, e, n = A) {
    wt(t, e).clearInstance(n)
}

function At(t) {
    return t.options !== void 0
}

function Yt(t) {
    return t == null ? !1 : t.settings !== void 0
}

function Xt() {
    _.clear()
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const Bt = {
        "no-app": "No Firebase App '{$appName}' has been created - call initializeApp() first",
        "bad-app-name": "Illegal App name: '{$appName}'",
        "duplicate-app": "Firebase App named '{$appName}' already exists with different options or config",
        "app-deleted": "Firebase App named '{$appName}' already deleted",
        "server-app-deleted": "Firebase Server App has been deleted",
        "no-options": "Need to provide options, when not being deployed to hosting via source.",
        "invalid-app-argument": "firebase.{$appName}() takes either no argument or a Firebase App instance.",
        "invalid-log-argument": "First argument to `onLog` must be null or a function.",
        "idb-open": "Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",
        "idb-get": "Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",
        "idb-set": "Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",
        "idb-delete": "Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.",
        "finalization-registry-not-supported": "FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.",
        "invalid-server-app-environment": "FirebaseServerApp is not for use in browser environments."
    },
    h = new te("app", "Firebase", Bt);
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class ae {
    constructor(e, n, r) {
        this._isDeleted = !1, this._options = Object.assign({}, e), this._config = Object.assign({}, n), this._name = n.name, this._automaticDataCollectionEnabled = n.automaticDataCollectionEnabled, this._container = r, this.container.addComponent(new S("app", () => this, "PUBLIC"))
    }
    get automaticDataCollectionEnabled() {
        return this.checkDestroyed(), this._automaticDataCollectionEnabled
    }
    set automaticDataCollectionEnabled(e) {
        this.checkDestroyed(), this._automaticDataCollectionEnabled = e
    }
    get name() {
        return this.checkDestroyed(), this._name
    }
    get options() {
        return this.checkDestroyed(), this._options
    }
    get config() {
        return this.checkDestroyed(), this._config
    }
    get container() {
        return this._container
    }
    get isDeleted() {
        return this._isDeleted
    }
    set isDeleted(e) {
        this._isDeleted = e
    }
    checkDestroyed() {
        if (this.isDeleted) throw h.create("app-deleted", {
            appName: this._name
        })
    }
}
/**
 * @license
 * Copyright 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function W(t, e) {
    const n = Z(t.split(".")[1]);
    if (n === null || JSON.parse(n).exp === void 0) return;
    const s = JSON.parse(n).exp * 1e3,
        i = new Date().getTime();
    s - i <= 0
}
class Ot extends ae {
    constructor(e, n, r, s) {
        const i = n.automaticDataCollectionEnabled !== void 0 ? n.automaticDataCollectionEnabled : !0,
            a = {
                name: r,
                automaticDataCollectionEnabled: i
            };
        if (e.apiKey !== void 0) super(e, a, s);
        else {
            const c = e;
            super(c.options, a, s)
        }
        this._serverConfig = Object.assign({
            automaticDataCollectionEnabled: i
        }, n), this._serverConfig.authIdToken && W(this._serverConfig.authIdToken, "authIdToken"), this._serverConfig.appCheckToken && W(this._serverConfig.appCheckToken, "appCheckToken"), this._finalizationRegistry = null, typeof FinalizationRegistry < "u" && (this._finalizationRegistry = new FinalizationRegistry(() => {
            this.automaticCleanup()
        })), this._refCount = 0, this.incRefCount(this._serverConfig.releaseOnDeref), this._serverConfig.releaseOnDeref = void 0, n.releaseOnDeref = void 0, C(w, $, "serverapp")
    }
    toJSON() {}
    get refCount() {
        return this._refCount
    }
    incRefCount(e) {
        this.isDeleted || (this._refCount++, e !== void 0 && this._finalizationRegistry !== null && this._finalizationRegistry.register(e, this))
    }
    decRefCount() {
        return this.isDeleted ? 0 : --this._refCount
    }
    automaticCleanup() {
        Mt(this)
    }
    get settings() {
        return this.checkDestroyed(), this._serverConfig
    }
    checkDestroyed() {
        if (this.isDeleted) throw h.create("server-app-deleted")
    }
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const qt = Ct;

function Tt(t, e = {}) {
    let n = t;
    typeof e != "object" && (e = {
        name: e
    });
    const r = Object.assign({
            name: A,
            automaticDataCollectionEnabled: !0
        }, e),
        s = r.name;
    if (typeof s != "string" || !s) throw h.create("bad-app-name", {
        appName: String(s)
    });
    if (n || (n = Q()), !n) throw h.create("no-options");
    const i = g.get(s);
    if (i) {
        if (R(n, i.options) && R(r, i.config)) return i;
        throw h.create("duplicate-app", {
            appName: s
        })
    }
    const a = new ne(s);
    for (const o of _.values()) a.addComponent(o);
    const c = new ae(n, r, a);
    return g.set(s, c), c
}

function Zt(t, e) {
    if (Ee() && !ee()) throw h.create("invalid-server-app-environment");
    e.automaticDataCollectionEnabled === void 0 && (e.automaticDataCollectionEnabled = !0);
    let n;
    At(t) ? n = t.options : n = t;
    const r = Object.assign(Object.assign({}, e), n);
    r.releaseOnDeref !== void 0 && delete r.releaseOnDeref;
    const s = d => [...d].reduce((v, p) => Math.imul(31, v) + p.charCodeAt(0) | 0, 0);
    if (e.releaseOnDeref !== void 0 && typeof FinalizationRegistry > "u") throw h.create("finalization-registry-not-supported", {});
    const i = "" + s(JSON.stringify(r)),
        a = b.get(i);
    if (a) return a.incRefCount(e.releaseOnDeref), a;
    const c = new ne(i);
    for (const d of _.values()) c.addComponent(d);
    const o = new Ot(n, e, i, c);
    return b.set(i, o), o
}

function Qt(t = A) {
    const e = g.get(t);
    if (!e && t === A && Q()) return Tt();
    if (!e) throw h.create("no-app", {
        appName: t
    });
    return e
}

function en() {
    return Array.from(g.values())
}
async function Mt(t) {
    let e = !1;
    const n = t.name;
    g.has(n) ? (e = !0, g.delete(n)) : b.has(n) && t.decRefCount() <= 0 && (b.delete(n), e = !0), e && (await Promise.all(t.container.getProviders().map(r => r.delete())), t.isDeleted = !0)
}

function C(t, e, n) {
    var r;
    let s = (r = St[t]) !== null && r !== void 0 ? r : t;
    n && (s += `-${n}`);
    const i = s.match(/\s|\//),
        a = e.match(/\s|\//);
    if (i || a) {
        const c = [`Unable to register library "${s}" with version "${e}":`];
        i && c.push(`library name "${s}" contains illegal characters (whitespace or "/")`), i && a && c.push("and"), a && c.push(`version name "${e}" contains illegal characters (whitespace or "/")`), u.warn(c.join(" "));
        return
    }
    F(new S(`${s}-version`, () => ({
        library: s,
        version: e
    }), "VERSION"))
}

function tn(t, e) {
    if (t !== null && typeof t != "function") throw h.create("invalid-log-argument");
    Pe(t, e)
}

function nn(t) {
    He(t)
}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const Rt = "firebase-heartbeat-database",
    Lt = 1,
    y = "firebase-heartbeat-store";
let M = null;

function oe() {
    return M || (M = Je(Rt, Lt, {
        upgrade: (t, e) => {
            switch (e) {
                case 0:
                    try {
                        t.createObjectStore(y)
                    } catch {}
            }
        }
    }).catch(t => {
        throw h.create("idb-open", {
            originalErrorMessage: t.message
        })
    })), M
}
async function Nt(t) {
    try {
        const n = (await oe()).transaction(y),
            r = await n.objectStore(y).get(ce(t));
        return await n.done, r
    } catch (e) {
        if (e instanceof E) u.warn(e.message);
        else {
            const n = h.create("idb-get", {
                originalErrorMessage: e == null ? void 0 : e.message
            });
            u.warn(n.message)
        }
    }
}
async function G(t, e) {
    try {
        const r = (await oe()).transaction(y, "readwrite");
        await r.objectStore(y).put(e, ce(t)), await r.done
    } catch (n) {
        if (n instanceof E) u.warn(n.message);
        else {
            const r = h.create("idb-set", {
                originalErrorMessage: n == null ? void 0 : n.message
            });
            u.warn(r.message)
        }
    }
}

function ce(t) {
    return `${t.name}!${t.options.appId}`
}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const $t = 1024,
    Ft = 30;
class Ht {
    constructor(e) {
        this.container = e, this._heartbeatsCache = null;
        const n = this.container.getProvider("app").getImmediate();
        this._storage = new xt(n), this._heartbeatsCachePromise = this._storage.read().then(r => (this._heartbeatsCache = r, r))
    }
    async triggerHeartbeat() {
        var e, n;
        try {
            const s = this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),
                i = J();
            if (((e = this._heartbeatsCache) === null || e === void 0 ? void 0 : e.heartbeats) == null && (this._heartbeatsCache = await this._heartbeatsCachePromise, ((n = this._heartbeatsCache) === null || n === void 0 ? void 0 : n.heartbeats) == null) || this._heartbeatsCache.lastSentHeartbeatDate === i || this._heartbeatsCache.heartbeats.some(a => a.date === i)) return;
            if (this._heartbeatsCache.heartbeats.push({
                    date: i,
                    agent: s
                }), this._heartbeatsCache.heartbeats.length > Ft) {
                const a = kt(this._heartbeatsCache.heartbeats);
                this._heartbeatsCache.heartbeats.splice(a, 1)
            }
            return this._storage.overwrite(this._heartbeatsCache)
        } catch (r) {
            u.warn(r)
        }
    }
    async getHeartbeatsHeader() {
        var e;
        try {
            if (this._heartbeatsCache === null && await this._heartbeatsCachePromise, ((e = this._heartbeatsCache) === null || e === void 0 ? void 0 : e.heartbeats) == null || this._heartbeatsCache.heartbeats.length === 0) return "";
            const n = J(),
                {
                    heartbeatsToSend: r,
                    unsentEntries: s
                } = Pt(this._heartbeatsCache.heartbeats),
                i = q(JSON.stringify({
                    version: 2,
                    heartbeats: r
                }));
            return this._heartbeatsCache.lastSentHeartbeatDate = n, s.length > 0 ? (this._heartbeatsCache.heartbeats = s, await this._storage.overwrite(this._heartbeatsCache)) : (this._heartbeatsCache.heartbeats = [], this._storage.overwrite(this._heartbeatsCache)), i
        } catch (n) {
            return u.warn(n), ""
        }
    }
}

function J() {
    return new Date().toISOString().substring(0, 10)
}

function Pt(t, e = $t) {
    const n = [];
    let r = t.slice();
    for (const s of t) {
        const i = n.find(a => a.agent === s.agent);
        if (i) {
            if (i.dates.push(s.date), K(n) > e) {
                i.dates.pop();
                break
            }
        } else if (n.push({
                agent: s.agent,
                dates: [s.date]
            }), K(n) > e) {
            n.pop();
            break
        }
        r = r.slice(1)
    }
    return {
        heartbeatsToSend: n,
        unsentEntries: r
    }
}
class xt {
    constructor(e) {
        this.app = e, this._canUseIndexedDBPromise = this.runIndexedDBEnvironmentCheck()
    }
    async runIndexedDBEnvironmentCheck() {
        return ve() ? De().then(() => !0).catch(() => !1) : !1
    }
    async read() {
        if (await this._canUseIndexedDBPromise) {
            const n = await Nt(this.app);
            return n != null && n.heartbeats ? n : {
                heartbeats: []
            }
        } else return {
            heartbeats: []
        }
    }
    async overwrite(e) {
        var n;
        if (await this._canUseIndexedDBPromise) {
            const s = await this.read();
            return G(this.app, {
                lastSentHeartbeatDate: (n = e.lastSentHeartbeatDate) !== null && n !== void 0 ? n : s.lastSentHeartbeatDate,
                heartbeats: e.heartbeats
            })
        } else return
    }
    async add(e) {
        var n;
        if (await this._canUseIndexedDBPromise) {
            const s = await this.read();
            return G(this.app, {
                lastSentHeartbeatDate: (n = e.lastSentHeartbeatDate) !== null && n !== void 0 ? n : s.lastSentHeartbeatDate,
                heartbeats: [...s.heartbeats, ...e.heartbeats]
            })
        } else return
    }
}

function K(t) {
    return q(JSON.stringify({
        version: 2,
        heartbeats: t
    })).length
}

function kt(t) {
    if (t.length === 0) return -1;
    let e = 0,
        n = t[0].date;
    for (let r = 1; r < t.length; r++) t[r].date < n && (n = t[r].date, e = r);
    return e
}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function zt(t) {
    F(new S("platform-logger", e => new Xe(e), "PRIVATE")), F(new S("heartbeat", e => new Ht(e), "PRIVATE")), C(w, $, t), C(w, $, "esm2017"), C("fire-js", "")
}
zt("");
export {
    Ut as A, S as C, A as D, te as E, E as F, Fe as L, qt as S, U as _, Jt as a, g as b, Xt as c, _ as d, wt as e, At as f, Yt as g, F as h, Kt as i, b as j, Mt as k, Qt as l, en as m, Tt as n, Zt as o, tn as p, Wt as q, C as r, nn as s, ve as t, Vt as u, De as v, Je as w, Gt as x, R as y, jt as z
};