//#region \0rolldown/runtime.js (function() { try { var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}; e.SENTRY_RELEASE = { id: "dc25092aee8a66b8f0868046d641f9fd9dcc8ff0" }; e._sentryModuleMetadata = e._sentryModuleMetadata || {}, e._sentryModuleMetadata[new e.Error().stack] = function(e) { for (var n = 1; n < arguments.length; n++) { var a = arguments[n]; if (null != a) for (var t in a) a.hasOwnProperty(t) && (e[t] = a[t]); } return e; }({}, e._sentryModuleMetadata[new e.Error().stack], { "version": "2.0.5", "appHost": "management" }); var n = new e.Error().stack; n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "3b9064b2-6d41-43f1-b15a-febe9fc7d6de", e._sentryDebugIdIdentifier = "sentry-dbid-3b9064b2-6d41-43f1-b15a-febe9fc7d6de"); } catch (e) {} })(); var __create$2 = Object.create; var __defProp$2 = Object.defineProperty; var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor; var __getOwnPropNames$2 = Object.getOwnPropertyNames; var __getProtoOf$2 = Object.getPrototypeOf; var __hasOwnProp$2 = Object.prototype.hasOwnProperty; var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports); var __exportAll = (all, no_symbols) => { let target = {}; for (var name in all) __defProp$2(target, name, { get: all[name], enumerable: true }); if (!no_symbols) __defProp$2(target, Symbol.toStringTag, { value: "Module" }); return target; }; var __copyProps$2 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$2(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp$2.call(to, key) && key !== except) __defProp$2(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc$2(from, key)) || desc.enumerable }); } return to; }; var __toESM$2 = (mod, isNodeMode, target) => (target = mod != null ? __create$2(__getProtoOf$2(mod)) : {}, __copyProps$2(isNodeMode || !mod || !mod.__esModule ? __defProp$2(target, "default", { value: mod, enumerable: true }) : target, mod)); var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details."); }); //#endregion //#region \0vite/modulepreload-polyfill.js (function polyfill() { const relList = document.createElement("link").relList; if (relList && relList.supports && relList.supports("modulepreload")) return; for (const link of document.querySelectorAll("link[rel=\"modulepreload\"]")) processPreload(link); new MutationObserver((mutations) => { for (const mutation of mutations) { if (mutation.type !== "childList") continue; for (const node of mutation.addedNodes) if (node.tagName === "LINK" && node.rel === "modulepreload") processPreload(node); } }).observe(document, { childList: true, subtree: true }); function getFetchOpts(link) { const fetchOpts = {}; if (link.integrity) fetchOpts.integrity = link.integrity; if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy; if (link.crossOrigin === "use-credentials") fetchOpts.credentials = "include"; else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit"; else fetchOpts.credentials = "same-origin"; return fetchOpts; } function processPreload(link) { if (link.ep) return; link.ep = true; const fetchOpts = getFetchOpts(link); fetch(link.href, fetchOpts); } })(); //#endregion //#region ../send/frontend/src/lib/logger.ts var version$1 = "2.0.5"; var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 }; var originalConsole = { ...console }; var originalLog = originalConsole.log; var originalWarn = originalConsole.warn; var originalError = originalConsole.error; var getConfiguredLevel = () => { return LOG_LEVELS.warn; }; var shouldLog = (messageLevel) => { const configuredLevel = getConfiguredLevel(); return LOG_LEVELS[messageLevel] >= configuredLevel; }; console.debug = (...args) => { if (shouldLog("debug")) originalLog(`[${version$1}]`, ...args); }; console.log = (...args) => { if (shouldLog("info")) originalLog(`[${version$1}]`, ...args); }; console.info = (...args) => { if (shouldLog("info")) originalLog(`[${version$1}]`, ...args); }; console.warn = (...args) => { if (shouldLog("warn")) originalWarn(`[${version$1}]`, ...args); }; console.error = (...args) => { if (shouldLog("error")) originalError(`[${version$1}]`, ...args); }; //#endregion //#region ../../node_modules/.pnpm/posthog-js@1.372.5/node_modules/posthog-js/dist/module.js var t = "undefined" != typeof window ? window : void 0, e = "undefined" != typeof globalThis ? globalThis : t; "undefined" == typeof self && (e.self = e), "undefined" == typeof File && (e.File = function() {}); var i$1 = null == e ? void 0 : e.navigator, r$1 = null == e ? void 0 : e.document, s$1 = null == e ? void 0 : e.location, n$2 = null == e ? void 0 : e.fetch, o$1 = null != e && e.XMLHttpRequest && "withCredentials" in new e.XMLHttpRequest() ? e.XMLHttpRequest : void 0, a$1 = null == e ? void 0 : e.AbortController, l$1 = null == e ? void 0 : e.CompressionStream, u$1 = null == i$1 ? void 0 : i$1.userAgent, h$3 = null != t ? t : {}, d$2 = "1.372.5", v$1 = { DEBUG: !1, LIB_VERSION: d$2, LIB_NAME: "web", JS_SDK_VERSION: d$2 }; function c$2(t, e, i, r, s, n, o) { try { var a = t[n](o), l = a.value; } catch (t) { i(t); return; } a.done ? e(l) : Promise.resolve(l).then(r, s); } function p$2(t) { return function() { var e = this, i = arguments; return new Promise((function(r, s) { var n = t.apply(e, i); function o(t) { c$2(n, r, s, o, a, "next", t); } function a(t) { c$2(n, r, s, o, a, "throw", t); } o(void 0); })); }; } function f$1() { return f$1 = Object.assign ? Object.assign.bind() : function(t) { for (var e = 1; arguments.length > e; e++) { var i = arguments[e]; for (var r in i) ({}).hasOwnProperty.call(i, r) && (t[r] = i[r]); } return t; }, f$1.apply(null, arguments); } function _$1(t, e) { if (null == t) return {}; var i = {}; for (var r in t) if ({}.hasOwnProperty.call(t, r)) { if (-1 !== e.indexOf(r)) continue; i[r] = t[r]; } return i; } function g$2() { return g$2 = p$2((function* (t, e, i) { void 0 === e && (e = !0); try { var r = new CompressionStream("gzip"), s = r.writable.getWriter(), n = s.write(new TextEncoder().encode(t)).then((() => s.close())).catch(function() { var t = p$2((function* (t) { try { yield s.abort(t); } catch (t) {} throw t; })); return function(e) { return t.apply(this, arguments); }; }()), o = new Response(r.readable).blob(), [a] = yield Promise.all([o, n]); return a; } catch (t) { if (null != i && i.rethrow) throw t; return e && console.error("Failed to gzip compress data", t), null; } })), g$2.apply(this, arguments); } var m$2 = [ "amazonbot", "amazonproductbot", "app.hypefactors.com", "applebot", "archive.org_bot", "awariobot", "backlinksextendedbot", "baiduspider", "bingbot", "bingpreview", "chrome-lighthouse", "dataforseobot", "deepscan", "duckduckbot", "facebookexternal", "facebookcatalog", "http://yandex.com/bots", "hubspot", "ia_archiver", "leikibot", "linkedinbot", "meta-externalagent", "mj12bot", "msnbot", "nessus", "petalbot", "pinterest", "prerender", "rogerbot", "screaming frog", "sebot-wa", "sitebulb", "slackbot", "slurp", "trendictionbot", "turnitin", "twitterbot", "vercel-screenshot", "vercelbot", "yahoo! slurp", "yandexbot", "zoombot", "bot.htm", "bot.php", "(bot;", "bot/", "crawler", "ahrefsbot", "ahrefssiteaudit", "semrushbot", "siteauditbot", "splitsignalbot", "gptbot", "oai-searchbot", "chatgpt-user", "perplexitybot", "better uptime bot", "sentryuptimebot", "uptimerobot", "headlesschrome", "cypress", "google-hoteladsverifier", "adsbot-google", "apis-google", "duplexweb-google", "feedfetcher-google", "google favicon", "google web preview", "google-read-aloud", "googlebot", "googleother", "google-cloudvertexbot", "googleweblight", "mediapartners-google", "storebot-google", "google-inspectiontool", "bytespider" ], b$2 = function(t, e) { if (void 0 === e && (e = []), !t) return !1; var i = t.toLowerCase(); return m$2.concat(e).some(((t) => { var e = t.toLowerCase(); return -1 !== i.indexOf(e); })); }, y$2 = [ "$snapshot", "$pageview", "$pageleave", "$set", "survey dismissed", "survey sent", "survey shown", "$identify", "$groupidentify", "$create_alias", "$$client_ingestion_warning", "$web_experiment_applied", "$feature_enrollment_update", "$feature_flag_called" ]; function w$1(t, e) { return -1 !== t.indexOf(e); } var x$2 = function(t) { return t.trim(); }, E$2 = function(t) { return t.replace(/^\$/, ""); }, S$2 = Object.prototype, T$1 = S$2.hasOwnProperty, k$1 = S$2.toString, R$2 = Array.isArray || function(t) { return "[object Array]" === k$1.call(t); }, P$1 = (t) => "function" == typeof t, O$1 = (t) => t === Object(t) && !R$2(t), I = (t) => { if (O$1(t)) { for (var e in t) if (T$1.call(t, e)) return !1; return !0; } return !1; }, C$2 = (t) => void 0 === t, F$1 = (t) => "[object String]" == k$1.call(t), A$2 = (t) => F$1(t) && 0 === t.trim().length, M = (t) => null === t, D$1 = (t) => C$2(t) || M(t), L$1 = (t) => "[object Number]" == k$1.call(t) && t == t, U$1 = (t) => L$1(t) && t > 0, N = (t) => "[object Boolean]" === k$1.call(t), j$1 = (t) => t instanceof FormData, z$2 = (t) => w$1(y$2, t); function B$3(t) { return null === t || "object" != typeof t; } function H$4(t, e) { return {}.toString.call(t) === "[object " + e + "]"; } function q$3(t) { return "undefined" != typeof Event && function(t, e) { try { return t instanceof e; } catch (t) { return !1; } }(t, Event); } var V = [ !0, "true", 1, "1", "yes" ], W$2 = (t) => w$1(V, t), G$3 = [ !1, "false", 0, "0", "no" ]; function Y$1(t, e, i, r, s) { return e > i && (r.warn("min cannot be greater than max."), e = i), L$1(t) ? t > i ? (r.warn(" cannot be greater than max: " + i + ". Using max value instead."), i) : e > t ? (r.warn(" cannot be less than min: " + e + ". Using min value instead."), e) : t : (r.warn(" must be a number. using max or fallback. max: " + i + ", fallback: " + s), Y$1(s || i, e, i, r)); } var J = class { constructor(t) { this.$t = {}, this.zt = t.zt, this.Ut = Y$1(t.bucketSize, 0, 100, t.Gt), this.Wt = Y$1(t.refillRate, 0, this.Ut, t.Gt), this.Xt = Y$1(t.refillInterval, 0, 864e5, t.Gt); } Jt(t, e) { var i = Math.floor((e - t.lastAccess) / this.Xt); i > 0 && (t.tokens = Math.min(t.tokens + i * this.Wt, this.Ut), t.lastAccess = t.lastAccess + i * this.Xt); } consumeRateLimit(t) { var e, i = Date.now(), r = String(t), s = this.$t[r]; return s ? this.Jt(s, i) : this.$t[r] = s = { tokens: this.Ut, lastAccess: i }, 0 === s.tokens || (s.tokens--, 0 === s.tokens && (null == (e = this.zt) || e.call(this, t)), 0 === s.tokens); } stop() { this.$t = {}; } }; var K$2, X$3, Q$1, Z$3 = "Mobile", tt$3 = "iOS", et$2 = "Android", it$1 = "Tablet", rt$2 = et$2 + " " + it$1, st$2 = "iPad", nt$2 = "Apple", ot$2 = nt$2 + " Watch", at$1 = "Safari", lt$1 = "BlackBerry", ut = "Samsung", ht$2 = ut + "Browser", dt$1 = ut + " Internet", vt$1 = "Chrome", ct$1 = vt$1 + " OS", pt$2 = vt$1 + " " + tt$3, ft$1 = "Internet Explorer", _t$2 = ft$1 + " " + Z$3, gt$1 = "Opera", mt$2 = gt$1 + " Mini", bt$1 = "Edge", yt$1 = "Microsoft " + bt$1, wt$1 = "Firefox", xt$1 = wt$1 + " " + tt$3, Et$1 = "Nintendo", St$2 = "PlayStation", $t$1 = "Xbox", Tt$2 = et$2 + " " + Z$3, kt$2 = Z$3 + " " + at$1, Rt$1 = "Windows", Pt$1 = Rt$1 + " Phone", Ot$2 = "Nokia", It$1 = "Ouya", Ct$2 = "Generic", Ft$2 = Ct$2 + " " + Z$3.toLowerCase(), At$1 = Ct$2 + " " + it$1.toLowerCase(), Mt$1 = "Konqueror", Dt$1 = "(\\d+(\\.\\d+)?)", Lt$1 = new RegExp("Version/" + Dt$1), Ut = new RegExp($t$1, "i"), Nt$1 = new RegExp(St$2 + " \\w+", "i"), jt$1 = new RegExp(Et$1 + " \\w+", "i"), zt = new RegExp(lt$1 + "|PlayBook|BB10", "i"), Bt$1 = { "NT3.51": "NT 3.11", "NT4.0": "NT 4.0", "5.0": "2000", 5.1: "XP", 5.2: "XP", "6.0": "Vista", 6.1: "7", 6.2: "8", 6.3: "8.1", 6.4: "10", "10.0": "10" }, Ht$1 = function(t, e) { return e = e || "", w$1(t, " OPR/") && w$1(t, "Mini") ? mt$2 : w$1(t, " OPR/") ? gt$1 : zt.test(t) ? lt$1 : w$1(t, "IE" + Z$3) || w$1(t, "WPDesktop") ? _t$2 : w$1(t, ht$2) ? dt$1 : w$1(t, bt$1) || w$1(t, "Edg/") ? yt$1 : w$1(t, "FBIOS") ? "Facebook " + Z$3 : w$1(t, "UCWEB") || w$1(t, "UCBrowser") ? "UC Browser" : w$1(t, "CriOS") ? pt$2 : w$1(t, "CrMo") || w$1(t, vt$1) ? vt$1 : w$1(t, et$2) && w$1(t, at$1) ? Tt$2 : w$1(t, "FxiOS") ? xt$1 : w$1(t.toLowerCase(), Mt$1.toLowerCase()) ? Mt$1 : ((t, e) => e && w$1(e, nt$2) || function(t) { return w$1(t, at$1) && !w$1(t, vt$1) && !w$1(t, et$2); }(t))(t, e) ? w$1(t, Z$3) ? kt$2 : at$1 : w$1(t, wt$1) ? wt$1 : w$1(t, "MSIE") || w$1(t, "Trident/") ? ft$1 : w$1(t, "Gecko") ? wt$1 : ""; }, qt = { [_t$2]: [new RegExp("rv:" + Dt$1)], [yt$1]: [new RegExp(bt$1 + "?\\/" + Dt$1)], [vt$1]: [new RegExp("(" + vt$1 + "|CrMo)\\/" + Dt$1)], [pt$2]: [new RegExp("CriOS\\/" + Dt$1)], "UC Browser": [new RegExp("(UCBrowser|UCWEB)\\/" + Dt$1)], [at$1]: [Lt$1], [kt$2]: [Lt$1], [gt$1]: [new RegExp("(Opera|OPR)\\/" + Dt$1)], [wt$1]: [new RegExp(wt$1 + "\\/" + Dt$1)], [xt$1]: [new RegExp("FxiOS\\/" + Dt$1)], [Mt$1]: [new RegExp("Konqueror[:/]?" + Dt$1, "i")], [lt$1]: [new RegExp(lt$1 + " " + Dt$1), Lt$1], [Tt$2]: [new RegExp("android\\s" + Dt$1, "i")], [dt$1]: [new RegExp(ht$2 + "\\/" + Dt$1)], [ft$1]: [new RegExp("(rv:|MSIE )" + Dt$1)], Mozilla: [new RegExp("rv:" + Dt$1)] }, Vt$1 = function(t, e) { var r = qt[Ht$1(t, e)]; if (C$2(r)) return null; for (var s = 0; r.length > s; s++) { var n = t.match(r[s]); if (n) return parseFloat(n[n.length - 2]); } return null; }, Wt$1 = [ [new RegExp($t$1 + "; " + $t$1 + " (.*?)[);]", "i"), (t) => [$t$1, t && t[1] || ""]], [new RegExp(Et$1, "i"), [Et$1, ""]], [new RegExp(St$2, "i"), [St$2, ""]], [zt, [lt$1, ""]], [new RegExp(Rt$1, "i"), (t, e) => { if (/Phone/.test(e) || /WPDesktop/.test(e)) return [Pt$1, ""]; if (new RegExp(Z$3).test(e) && !/IEMobile\b/.test(e)) return [Rt$1 + " " + Z$3, ""]; var i = /Windows NT ([0-9.]+)/i.exec(e); if (i && i[1]) { var r = Bt$1[i[1]] || ""; return /arm/i.test(e) && (r = "RT"), [Rt$1, r]; } return [Rt$1, ""]; }], [/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/, (t) => t && t[3] ? [tt$3, [ t[3], t[4], t[5] || "0" ].join(".")] : [tt$3, ""]], [/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i, (t) => { var e = ""; return t && t.length >= 3 && (e = C$2(t[2]) ? t[3] : t[2]), ["watchOS", e]; }], [new RegExp("(" + et$2 + " (\\d+)\\.(\\d+)\\.?(\\d+)?|" + et$2 + ")", "i"), (t) => t && t[2] ? [et$2, [ t[2], t[3], t[4] || "0" ].join(".")] : [et$2, ""]], [/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i, (t) => { var e = ["Mac OS X", ""]; return t && t[1] && (e[1] = [ t[1], t[2], t[3] || "0" ].join(".")), e; }], [/Mac/i, ["Mac OS X", ""]], [/CrOS/, [ct$1, ""]], [/Linux|debian/i, ["Linux", ""]] ], Gt$1 = function(t) { return jt$1.test(t) ? Et$1 : Nt$1.test(t) ? St$2 : Ut.test(t) ? $t$1 : new RegExp(It$1, "i").test(t) ? It$1 : new RegExp("(" + Pt$1 + "|WPDesktop)", "i").test(t) ? Pt$1 : /iPad/.test(t) ? st$2 : /iPod/.test(t) ? "iPod Touch" : /iPhone/.test(t) ? "iPhone" : /(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t) ? ot$2 : zt.test(t) ? lt$1 : /(kobo)\s(ereader|touch)/i.test(t) ? "Kobo" : new RegExp(Ot$2, "i").test(t) ? Ot$2 : /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t) || /(kf[a-z]+)( bui|\)).+silk\//i.test(t) ? "Kindle Fire" : /(Android|ZTE)/i.test(t) ? new RegExp(Z$3).test(t) && !/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t) || /pixel[\daxl ]{1,6}/i.test(t) && !/pixel c/i.test(t) || /(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t) || /lmy47v/i.test(t) && !/QTAQZ3/i.test(t) ? et$2 : rt$2 : new RegExp("(pda|" + Z$3 + ")", "i").test(t) ? Ft$2 : new RegExp(it$1, "i").test(t) && !new RegExp(it$1 + " pc", "i").test(t) ? At$1 : ""; }, Yt = (t) => t instanceof Error, Jt = { trace: { text: "TRACE", number: 1 }, debug: { text: "DEBUG", number: 5 }, info: { text: "INFO", number: 9 }, warn: { text: "WARN", number: 13 }, error: { text: "ERROR", number: 17 }, fatal: { text: "FATAL", number: 21 } }, Kt = Jt.info; function Xt(t) { if (N(t)) return { boolValue: t }; if ("number" == typeof t) return Number.isFinite(t) ? Number.isInteger(t) ? { intValue: t } : { doubleValue: t } : { stringValue: String(t) }; if ("string" == typeof t) return { stringValue: t }; if (R$2(t)) return { arrayValue: { values: t.map(((t) => Xt(t))) } }; try { return { stringValue: JSON.stringify(t) }; } catch (e) { return { stringValue: String(t) }; } } function Qt(t) { var e = []; for (var i in t) { var r = t[i]; M(r) || C$2(r) || e.push({ key: i, value: Xt(r) }); } return e; } function Zt(t) { var e = globalThis._posthogChunkIds; if (e) { var i = Object.keys(e); return Q$1 && i.length === X$3 || (X$3 = i.length, Q$1 = i.reduce(((i, r) => { K$2 || (K$2 = {}); var s = K$2[r]; if (s) i[s[0]] = s[1]; else for (var n = t(r), o = n.length - 1; o >= 0; o--) { var a = n[o], l = null == a ? void 0 : a.filename, u = e[r]; if (l && u) { i[l] = u, K$2[r] = [l, u]; break; } } return i; }), {})), Q$1; } } var te$1 = class { constructor(t, e, i) { void 0 === i && (i = []), this.coercers = t, this.stackParser = e, this.modifiers = i; } buildFromUnknown(t, e) { void 0 === e && (e = {}); var i = e && e.mechanism || { handled: !0, type: "generic" }, r = this.buildCoercingContext(i, e, 0).apply(t), s = this.buildParsingContext(e), n = this.parseStacktrace(r, s); return { $exception_list: this.convertToExceptionList(n, i), $exception_level: "error" }; } modifyFrames(t) { var e = this; return p$2((function* () { for (var i of t) i.stacktrace && i.stacktrace.frames && R$2(i.stacktrace.frames) && (i.stacktrace.frames = yield e.applyModifiers(i.stacktrace.frames)); return t; }))(); } coerceFallback(t) { var e; return { type: "Error", value: "Unknown error", stack: null == (e = t.syntheticException) ? void 0 : e.stack, synthetic: !0 }; } parseStacktrace(t, e) { var i, r; return null != t.cause && (i = this.parseStacktrace(t.cause, e)), "" != t.stack && null != t.stack && (r = this.applyChunkIds(this.stackParser(t.stack, t.synthetic ? e.skipFirstLines : 0), e.chunkIdMap)), f$1({}, t, { cause: i, stack: r }); } applyChunkIds(t, e) { return t.map(((t) => (t.filename && e && (t.chunk_id = e[t.filename]), t))); } applyCoercers(t, e) { for (var i of this.coercers) if (i.match(t)) return i.coerce(t, e); return this.coerceFallback(e); } applyModifiers(t) { var e = this; return p$2((function* () { var i = t; for (var r of e.modifiers) i = yield r(i); return i; }))(); } convertToExceptionList(t, e) { var i, r, s, n = { type: t.type, value: t.value, mechanism: { type: null !== (i = e.type) && void 0 !== i ? i : "generic", handled: null === (r = e.handled) || void 0 === r || r, synthetic: null !== (s = t.synthetic) && void 0 !== s && s } }; t.stack && (n.stacktrace = { type: "raw", frames: t.stack }); var o = [n]; return null != t.cause && o.push(...this.convertToExceptionList(t.cause, f$1({}, e, { handled: !0 }))), o; } buildParsingContext(t) { var e; return { chunkIdMap: Zt(this.stackParser), skipFirstLines: null !== (e = t.skipFirstLines) && void 0 !== e ? e : 1 }; } buildCoercingContext(t, e, i) { void 0 === i && (i = 0); var r = (i, r) => { if (4 >= r) { var s = this.buildCoercingContext(t, e, r); return this.applyCoercers(i, s); } }; return f$1({}, e, { syntheticException: 0 == i ? e.syntheticException : void 0, mechanism: t, apply: (t) => r(t, i), next: (t) => r(t, i + 1) }); } }; var ee$2 = "?"; function ie$1(t, e, i, r, s) { var n = { platform: t, filename: e, function: "" === i ? ee$2 : i, in_app: !0 }; return C$2(r) || (n.lineno = r), C$2(s) || (n.colno = s), n; } var re$1 = (t, e) => { var i = -1 !== t.indexOf("safari-extension"), r = -1 !== t.indexOf("safari-web-extension"); return i || r ? [-1 !== t.indexOf("@") ? t.split("@")[0] : ee$2, i ? "safari-extension:" + e : "safari-web-extension:" + e] : [t, e]; }, se$1 = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i, ne$1 = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, oe$3 = /\((\S*)(?::(\d+))(?::(\d+))\)/, ae$1 = (t, e) => { var i = se$1.exec(t); if (i) { var [, r, s, n] = i; return ie$1(e, r, ee$2, +s, +n); } var o = ne$1.exec(t); if (o) { if (o[2] && 0 === o[2].indexOf("eval")) { var a = oe$3.exec(o[2]); a && (o[2] = a[1], o[3] = a[2], o[4] = a[3]); } var [l, u] = re$1(o[1] || ee$2, o[2]); return ie$1(e, u, l, o[3] ? +o[3] : void 0, o[4] ? +o[4] : void 0); } }, le$2 = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i, ue$1 = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i, he$1 = (t, e) => { var i = le$2.exec(t); if (i) { if (i[3] && i[3].indexOf(" > eval") > -1) { var r = ue$1.exec(i[3]); r && (i[1] = i[1] || "eval", i[3] = r[1], i[4] = r[2], i[5] = ""); } var s = i[3], n = i[1] || ee$2; return [n, s] = re$1(n, s), ie$1(e, s, n, i[4] ? +i[4] : void 0, i[5] ? +i[5] : void 0); } }, de$2 = /\(error: (.*)\)/; var ve$1 = class { match(t) { return this.isDOMException(t) || this.isDOMError(t); } coerce(t, e) { var i = F$1(t.stack); return { type: this.getType(t), value: this.getValue(t), stack: i ? t.stack : void 0, cause: t.cause ? e.next(t.cause) : void 0, synthetic: !1 }; } getType(t) { return this.isDOMError(t) ? "DOMError" : "DOMException"; } getValue(t) { var e = t.name || (this.isDOMError(t) ? "DOMError" : "DOMException"); return t.message ? e + ": " + t.message : e; } isDOMException(t) { return H$4(t, "DOMException"); } isDOMError(t) { return H$4(t, "DOMError"); } }; var ce$2 = class { match(t) { return ((t) => t instanceof Error)(t); } coerce(t, e) { return { type: this.getType(t), value: this.getMessage(t, e), stack: this.getStack(t), cause: t.cause ? e.next(t.cause) : void 0, synthetic: !1 }; } getType(t) { return t.name || t.constructor.name; } getMessage(t, e) { var i = t.message; return String(i.error && "string" == typeof i.error.message ? i.error.message : i); } getStack(t) { return t.stacktrace || t.stack || void 0; } }; var pe$2 = class { constructor() {} match(t) { return H$4(t, "ErrorEvent") && null != t.error; } coerce(t, e) { var i; return e.apply(t.error) || { type: "ErrorEvent", value: t.message, stack: null == (i = e.syntheticException) ? void 0 : i.stack, synthetic: !0 }; } }; var fe$3 = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i; var _e$1 = class { match(t) { return "string" == typeof t; } coerce(t, e) { var i, [r, s] = this.getInfos(t); return { type: null != r ? r : "Error", value: null != s ? s : t, stack: null == (i = e.syntheticException) ? void 0 : i.stack, synthetic: !0 }; } getInfos(t) { var e = "Error", i = t, r = t.match(fe$3); return r && (e = r[1], i = r[2]), [e, i]; } }; var ge$1 = [ "fatal", "error", "warning", "log", "info", "debug" ]; function me$2(t, e) { void 0 === e && (e = 40); var i = Object.keys(t); if (i.sort(), !i.length) return "[object has no keys]"; for (var r = i.length; r > 0; r--) { var s = i.slice(0, r).join(", "); if (e >= s.length) return r === i.length ? s : s.length > e ? s.slice(0, e) + "..." : s; } return ""; } var be$2 = class { match(t) { return "object" == typeof t && null !== t; } coerce(t, e) { var i, r = this.getErrorPropertyFromObject(t); return r ? e.apply(r) : { type: this.getType(t), value: this.getValue(t), stack: null == (i = e.syntheticException) ? void 0 : i.stack, level: this.isSeverityLevel(t.level) ? t.level : "error", synthetic: !0 }; } getType(t) { return q$3(t) ? t.constructor.name : "Error"; } getValue(t) { if ("name" in t && "string" == typeof t.name) { var e = "'" + t.name + "' captured as exception"; return "message" in t && "string" == typeof t.message && (e += " with message: '" + t.message + "'"), e; } if ("message" in t && "string" == typeof t.message) return t.message; var i = this.getObjectClassName(t); return (i && "Object" !== i ? "'" + i + "'" : "Object") + " captured as exception with keys: " + me$2(t); } isSeverityLevel(t) { return F$1(t) && !A$2(t) && ge$1.indexOf(t) >= 0; } getErrorPropertyFromObject(t) { for (var e in t) if ({}.hasOwnProperty.call(t, e)) { var i = t[e]; if (Yt(i)) return i; } } getObjectClassName(t) { try { var e = Object.getPrototypeOf(t); return e ? e.constructor.name : void 0; } catch (t) { return; } } }; var ye$2 = class { match(t) { return q$3(t); } coerce(t, e) { var i, r = t.constructor.name; return { type: r, value: r + " captured as exception with keys: " + me$2(t), stack: null == (i = e.syntheticException) ? void 0 : i.stack, synthetic: !0 }; } }; var we$2 = class { match(t) { return B$3(t); } coerce(t, e) { var i; return { type: "Error", value: "Primitive value captured as exception: " + String(t), stack: null == (i = e.syntheticException) ? void 0 : i.stack, synthetic: !0 }; } }; var xe = class { match(t) { return H$4(t, "PromiseRejectionEvent") || this.isCustomEventWrappingRejection(t); } isCustomEventWrappingRejection(t) { if (!q$3(t)) return !1; try { var e = t.detail; return null != e && "object" == typeof e && "reason" in e; } catch (t) { return !1; } } coerce(t, e) { var i, r = this.getUnhandledRejectionReason(t); return B$3(r) ? { type: "UnhandledRejection", value: "Non-Error promise rejection captured with value: " + String(r), stack: null == (i = e.syntheticException) ? void 0 : i.stack, synthetic: !0 } : e.apply(r); } getUnhandledRejectionReason(t) { try { if ("reason" in t) return t.reason; if ("detail" in t && null != t.detail && "object" == typeof t.detail && "reason" in t.detail) return t.detail.reason; } catch (t) {} return t; } }; var Ee = "$message", Se$2 = "$timestamp", $e = new Set([Ee, Se$2]), Te$2 = { enabled: !0, max_bytes: 32768 }; function ke$1(t) { var e; return t ? { enabled: null !== (e = t.enabled) && void 0 !== e ? e : Te$2.enabled, max_bytes: Pe$2(t.max_bytes, Te$2.max_bytes) } : f$1({}, Te$2); } var Re$1 = class { constructor(t) { this.Kt = [], this.Qt = 0, this.Bt = ke$1(t); } setConfig(t) { this.Bt = ke$1(t), this.er(); } add(t) { var e = function(t) { var e = function(t) { var e = /* @__PURE__ */ new WeakSet(); try { return JSON.stringify(t, ((t, i) => { if ("bigint" == typeof i) return i.toString(); if ("function" != typeof i && "symbol" != typeof i) { if (i instanceof Date) return i.toISOString(); if (i instanceof Error) return { name: i.name, message: i.message, stack: i.stack }; if (i && "object" == typeof i) { if (e.has(i)) return "[Circular]"; e.add(i); } return i; } })); } catch (t) { return; } }(t); if (e) try { var i = JSON.parse(e); if (!O$1(i)) return; var r = i, s = r[Ee], n = r[Se$2]; if (!F$1(s) || 0 === s.trim().length) return; if (!F$1(n) && !L$1(n)) return; return { step: r, json: e }; } catch (t) { return; } }(t); if (e) { var i = function(t) { if ("undefined" != typeof TextEncoder) return new TextEncoder().encode(t).length; for (var e = encodeURIComponent(t), i = 0, r = 0; e.length > r; r++) "%" === e[r] ? (i += 1, r += 2) : i += 1; return i; }(e.json); i > this.Bt.max_bytes || (this.Kt.push({ step: e.step, bytes: i }), this.Qt += i, this.er()); } } getAttachable() { return this.Kt.map(((t) => t.step)); } clear() { this.Kt = [], this.Qt = 0; } size() { return this.Kt.length; } er() { for (; this.Qt > this.Bt.max_bytes && this.Kt.length > 0;) { var t = this.Kt.shift(); t && (this.Qt -= t.bytes); } } }; function Pe$2(t, e) { if (!L$1(t) || t === Infinity || t === -Infinity) return e; var i = Math.floor(t); return 0 > i ? e : i; } var Oe$3 = function(e, i) { var { debugEnabled: r } = void 0 === i ? {} : i, s = { C(i) { if (t && (v$1.DEBUG || h$3.POSTHOG_DEBUG || r) && !C$2(t.console) && t.console) { for (var s = ("__rrweb_original__" in t.console[i]) ? t.console[i].__rrweb_original__ : t.console[i], n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), a = 1; n > a; a++) o[a - 1] = arguments[a]; s(e, ...o); } }, info() { for (var t = arguments.length, e = new Array(t), i = 0; t > i; i++) e[i] = arguments[i]; s.C("log", ...e); }, warn() { for (var t = arguments.length, e = new Array(t), i = 0; t > i; i++) e[i] = arguments[i]; s.C("warn", ...e); }, error() { for (var t = arguments.length, e = new Array(t), i = 0; t > i; i++) e[i] = arguments[i]; s.C("error", ...e); }, critical() { for (var t = arguments.length, i = new Array(t), r = 0; t > r; r++) i[r] = arguments[r]; console.error(e, ...i); }, uninitializedWarning(t) { s.error("You must initialize PostHog before calling " + t); }, createLogger: (t, i) => Oe$3(e + " " + t, i) }; return s; }, Ie = Oe$3("[PostHog.js]"), Ce$2 = Ie.createLogger, Fe = Ce$2("[ExternalScriptsLoader]"), Ae$2 = (t, e, i) => { if (t.config.disable_external_dependency_loading) return Fe.warn(e + " was requested but loading of external scripts is disabled."), i("Loading of external scripts is disabled"); var s = null == r$1 ? void 0 : r$1.querySelectorAll("script"); if (s) { for (var n, o = function() { if (s[a].src === e) { var t = s[a]; return t.__posthog_loading_callback_fired ? { v: i() } : (t.addEventListener("load", ((e) => { t.__posthog_loading_callback_fired = !0, i(void 0, e); })), t.onerror = (t) => i(t), { v: void 0 }); } }, a = 0; s.length > a; a++) if (n = o()) return n.v; } var l = () => { if (!r$1) return i("document not found"); var s = r$1.createElement("script"); if (s.type = "text/javascript", s.crossOrigin = "anonymous", s.src = e, s.onload = (t) => { s.__posthog_loading_callback_fired = !0, i(void 0, t); }, s.onerror = (t) => i(t), t.config.prepare_external_dependency_script && (s = t.config.prepare_external_dependency_script(s)), !s) return i("prepare_external_dependency_script returned null"); if ("head" === t.config.external_scripts_inject_target) r$1.head.appendChild(s); else { var n, o = r$1.querySelectorAll("body > script"); o.length > 0 ? null == (n = o[0].parentNode) || n.insertBefore(s, o[0]) : r$1.body.appendChild(s); } }; null != r$1 && r$1.body ? l() : r$1?.addEventListener("DOMContentLoaded", l); }; h$3.__PosthogExtensions__ = h$3.__PosthogExtensions__ || {}, h$3.__PosthogExtensions__.loadExternalDependency = (t, e, i) => { if ("remote-config" !== e) { var r; if (t.config.__preview_external_dependency_versioned_paths) r = t.requestRouter.endpointFor("assets", "/static/" + t.version + "/" + e + ".js"); else { var s = "/static/" + e + ".js?v=" + t.version; if ("toolbar" === e) { var n = 3e5; s = s + "&t=" + Math.floor(Date.now() / n) * n; } r = t.requestRouter.endpointFor("assets", s); } Ae$2(t, r, i); } else Ae$2(t, t.requestRouter.endpointFor("assets", "/array/" + t.config.token + "/config.js"), i); }, h$3.__PosthogExtensions__.loadSiteApp = (t, e, i) => { Ae$2(t, t.requestRouter.endpointFor("api", e), i); }; var Me$2 = "$people_distinct_id", De$1 = "$device_id", Le$1 = "__alias", Ue = "__timers", Ne$3 = "$autocapture_disabled_server_side", je$2 = "$heatmaps_enabled_server_side", ze$1 = "$exception_capture_enabled_server_side", Be$1 = "$error_tracking_suppression_rules", He$3 = "$error_tracking_capture_extension_exceptions", qe = "$web_vitals_enabled_server_side", Ve = "$dead_clicks_enabled_server_side", We$1 = "$product_tours_enabled_server_side", Ge = "$web_vitals_allowed_metrics", Ye$1 = "$session_recording_remote_config", Je = "$replay_override_sampling", Ke = "$replay_override_linked_flag", Xe = "$replay_override_url_trigger", Qe$1 = "$replay_override_event_trigger", Ze$2 = "$sesid", ti$1 = "$session_is_sampled", ei$1 = "$enabled_feature_flags", ii$1 = "$active_feature_flags", ri$1 = "$early_access_features", si$1 = "$feature_flag_details", ni = "$feature_flag_payloads", oi$1 = "$feature_flag_request_id", ai$1 = "$override_feature_flags", li$1 = "$override_feature_flag_payloads", ui$1 = "$stored_person_properties", hi$1 = "$stored_group_properties", di$1 = "$surveys", vi$1 = "$surveys_activated", ci$1 = "ph_product_tours", pi = "$flag_call_reported", fi$1 = "$flag_call_reported_session_id", _i$1 = "$feature_flag_errors", gi$1 = "$feature_flag_evaluated_at", mi$1 = "$user_state", bi$1 = "$client_session_props", yi$1 = "$capture_rate_limit", wi = "$initial_campaign_params", xi = "$initial_referrer_info", Ei$1 = "$initial_person_info", Si = "$epp", $i = "__POSTHOG_TOOLBAR__", Ti$1 = "$posthog_cookieless", ki$1 = "$sdk_debug_extensions_init_method", Ri = "$sdk_debug_extensions_init_time_ms", Pi = "$sdk_debug_recording_script_not_loaded", Oi$1 = "PostHog loadExternalDependency extension not found.", Ii = "on_reject", Ci$1 = "always", Fi = "anonymous", Ai = "identified", Mi = "identified_only", Di = "visibilitychange", Li$1 = "beforeunload", Ui = "$pageview", Ni$1 = "$pageleave", ji = "$identify", zi = "$groupidentify"; function Bi(t, e) { R$2(t) && t.forEach(e); } function Hi(t, e) { if (!D$1(t)) if (R$2(t)) t.forEach(e); else if (j$1(t)) t.forEach(((t, i) => e(t, i))); else for (var i in t) T$1.call(t, i) && e(t[i], i); } var qi = function(t) { for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), r = 1; e > r; r++) i[r - 1] = arguments[r]; for (var s of i) for (var n in s) void 0 !== s[n] && (t[n] = s[n]); return t; }; function Vi(t) { for (var e = Object.keys(t), i = e.length, r = new Array(i); i--;) r[i] = [e[i], t[e[i]]]; return r; } var Wi = function(t) { try { return t(); } catch (t) { return; } }, Gi = function(t) { return function() { try { for (var e = arguments.length, i = new Array(e), r = 0; e > r; r++) i[r] = arguments[r]; return t.apply(this, i); } catch (t) { Ie.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."), Ie.critical(t); } }; }, Yi = function(t) { var e = {}; return Hi(t, (function(t, i) { (F$1(t) && t.length > 0 || L$1(t)) && (e[i] = t); })), e; }; var Ji = [ "herokuapp.com", "vercel.app", "netlify.app" ]; function Ki(t) { var e = null == t ? void 0 : t.hostname; if (!F$1(e)) return !1; var i = e.split(".").slice(-2).join("."); for (var r of Ji) if (i === r) return !1; return !0; } function Xi(t, e, i, r) { var { capture: s = !1, passive: n = !0 } = null != r ? r : {}; t?.addEventListener(e, i, { capture: s, passive: n }); } function Qi(t) { return "ph_toolbar_internal" === t.name; } Math.trunc || (Math.trunc = function(t) { return 0 > t ? Math.ceil(t) : Math.floor(t); }), Number.isInteger || (Number.isInteger = function(t) { return L$1(t) && isFinite(t) && Math.floor(t) === t; }); var Zi = class Zi { constructor(t) { if (this.bytes = t, 16 !== t.length) throw new TypeError("not 128-bit length"); } static fromFieldsV7(t, e, i, r) { if (!Number.isInteger(t) || !Number.isInteger(e) || !Number.isInteger(i) || !Number.isInteger(r) || 0 > t || 0 > e || 0 > i || 0 > r || t > 0xffffffffffff || e > 4095 || i > 1073741823 || r > 4294967295) throw new RangeError("invalid field value"); var s = new Uint8Array(16); return s[0] = t / Math.pow(2, 40), s[1] = t / Math.pow(2, 32), s[2] = t / Math.pow(2, 24), s[3] = t / Math.pow(2, 16), s[4] = t / Math.pow(2, 8), s[5] = t, s[6] = 112 | e >>> 8, s[7] = e, s[8] = 128 | i >>> 24, s[9] = i >>> 16, s[10] = i >>> 8, s[11] = i, s[12] = r >>> 24, s[13] = r >>> 16, s[14] = r >>> 8, s[15] = r, new Zi(s); } toString() { for (var t = "", e = 0; this.bytes.length > e; e++) t = t + (this.bytes[e] >>> 4).toString(16) + (15 & this.bytes[e]).toString(16), 3 !== e && 5 !== e && 7 !== e && 9 !== e || (t += "-"); if (36 !== t.length) throw new Error("Invalid UUIDv7 was generated"); return t; } clone() { return new Zi(this.bytes.slice(0)); } equals(t) { return 0 === this.compareTo(t); } compareTo(t) { for (var e = 0; 16 > e; e++) { var i = this.bytes[e] - t.bytes[e]; if (0 !== i) return Math.sign(i); } return 0; } }; var tr$1 = class { constructor() { this.I = 0, this.S = 0, this.k = new rr$1(); } generate() { var t = this.generateOrAbort(); if (C$2(t)) { this.I = 0; var e = this.generateOrAbort(); if (C$2(e)) throw new Error("Could not generate UUID after timestamp reset"); return e; } return t; } generateOrAbort() { var t = Date.now(); if (t > this.I) this.I = t, this.A(); else { if (this.I >= t + 1e4) return; this.S++, this.S > 4398046511103 && (this.I++, this.A()); } return Zi.fromFieldsV7(this.I, Math.trunc(this.S / Math.pow(2, 30)), this.S & Math.pow(2, 30) - 1, this.k.nextUint32()); } A() { this.S = 1024 * this.k.nextUint32() + (1023 & this.k.nextUint32()); } }; var er$1, ir$1 = (t) => { if ("undefined" != typeof UUIDV7_DENY_WEAK_RNG && UUIDV7_DENY_WEAK_RNG) throw new Error("no cryptographically strong RNG available"); for (var e = 0; t.length > e; e++) t[e] = 65536 * Math.trunc(65536 * Math.random()) + Math.trunc(65536 * Math.random()); return t; }; t && !C$2(t.crypto) && crypto.getRandomValues && (ir$1 = (t) => crypto.getRandomValues(t)); var rr$1 = class { constructor() { this.T = new Uint32Array(8), this.N = Infinity; } nextUint32() { return this.T.length > this.N || (ir$1(this.T), this.N = 0), this.T[this.N++]; } }; var sr$1 = () => nr$1().toString(), nr$1 = () => (er$1 || (er$1 = new tr$1())).generate(), or$1 = "", ar$1 = /[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i; var lr$1 = { R: () => !!r$1, B(t) { Ie.error("cookieStore error: " + t); }, O(t) { if (r$1) { try { for (var e = t + "=", i = r$1.cookie.split(";").filter(((t) => t.length)), s = 0; i.length > s; s++) { for (var n = i[s]; " " == n.charAt(0);) n = n.substring(1, n.length); if (0 === n.indexOf(e)) return decodeURIComponent(n.substring(e.length, n.length)); } } catch (t) {} return null; } }, Z(t) { var e; try { e = JSON.parse(lr$1.O(t)) || {}; } catch (t) {} return e; }, M(t, e, i, s, n) { if (r$1) try { var o = "", a = "", l = function(t, e) { if (e) { var i = function(t, e) { if (void 0 === e && (e = r$1), or$1) return or$1; if (!e) return ""; if (["localhost", "127.0.0.1"].includes(t)) return ""; for (var i = t.split("."), s = Math.min(i.length, 8), n = "dmn_chk_" + sr$1(); !or$1 && s--;) { var o = i.slice(s).join("."), a = n + "=1;domain=." + o + ";path=/"; e.cookie = a + ";max-age=3", e.cookie.includes(n) && (e.cookie = a + ";max-age=0", or$1 = o); } return or$1; }(t); if (!i) { var s = ((t) => { var e = t.match(ar$1); return e ? e[0] : ""; })(t); s !== i && Ie.info("Warning: cookie subdomain discovery mismatch", s, i), i = s; } return i ? "; domain=." + i : ""; } return ""; }(r$1.location.hostname, s); if (i) { var u = /* @__PURE__ */ new Date(); u.setTime(u.getTime() + 864e5 * i), o = "; expires=" + u.toUTCString(); } n && (a = "; secure"); var h = t + "=" + encodeURIComponent(JSON.stringify(e)) + o + "; SameSite=Lax; path=/" + l + a; return h.length > 3686.4 && Ie.warn("cookieStore warning: large cookie, len=" + h.length), r$1.cookie = h, h; } catch (t) { return; } }, F(t, e) { if (null != r$1 && r$1.cookie) try { lr$1.M(t, "", -1, e); } catch (t) { return; } } }, ur = null, hr$1 = { R() { if (!M(ur)) return ur; var e = !0; if (C$2(t)) e = !1; else try { var i = "__mplssupport__"; hr$1.M(i, "xyz"), "\"xyz\"" !== hr$1.O(i) && (e = !1), hr$1.F(i); } catch (t) { e = !1; } return e || Ie.error("localStorage unsupported; falling back to cookie store"), ur = e, e; }, B(t) { Ie.error("localStorage error: " + t); }, O(e) { try { return null == t ? void 0 : t.localStorage.getItem(e); } catch (t) { hr$1.B(t); } return null; }, Z(t) { try { return JSON.parse(hr$1.O(t)) || {}; } catch (t) {} return null; }, M(e, i) { try { t?.localStorage.setItem(e, JSON.stringify(i)); } catch (t) { hr$1.B(t); } }, F(e) { try { t?.localStorage.removeItem(e); } catch (t) { hr$1.B(t); } } }, dr$1 = [ De$1, "distinct_id", Ze$2, ti$1, Si, Ei$1, mi$1 ], vr$1 = {}, cr = { R: () => !0, B(t) { Ie.error("memoryStorage error: " + t); }, O: (t) => vr$1[t] || null, Z: (t) => vr$1[t] || null, M(t, e) { vr$1[t] = e; }, F(t) { delete vr$1[t]; } }, pr$1 = null, fr$1 = { R() { if (!M(pr$1)) return pr$1; if (pr$1 = !0, C$2(t)) pr$1 = !1; else try { var e = "__support__"; fr$1.M(e, "xyz"), "\"xyz\"" !== fr$1.O(e) && (pr$1 = !1), fr$1.F(e); } catch (t) { pr$1 = !1; } return pr$1; }, B(t) { Ie.error("sessionStorage error: ", t); }, O(e) { try { return null == t ? void 0 : t.sessionStorage.getItem(e); } catch (t) { fr$1.B(t); } return null; }, Z(t) { try { return JSON.parse(fr$1.O(t)) || null; } catch (t) {} return null; }, M(e, i) { try { t?.sessionStorage.setItem(e, JSON.stringify(i)); } catch (t) { fr$1.B(t); } }, F(e) { try { t?.sessionStorage.removeItem(e); } catch (t) { fr$1.B(t); } } }; var _r$1 = class { constructor(t) { this._instance = t; } get Bt() { return this._instance.config; } get consent() { return this.rr() ? 0 : this.ir; } isOptedOut() { return this.Bt.cookieless_mode === Ci$1 || this.isRejected() || -1 === this.consent && this.Bt.cookieless_mode === Ii; } isOptedIn() { return !this.isOptedOut(); } isExplicitlyOptedOut() { return 0 === this.consent; } isRejected() { return 0 === this.consent || -1 === this.consent && this.Bt.opt_out_capturing_by_default; } optInOut(t) { this.nr.M(this.sr, t ? 1 : 0, this.Bt.cookie_expiration, this.Bt.cross_subdomain_cookie, this.Bt.secure_cookie); } reset() { this.nr.F(this.sr, this.Bt.cross_subdomain_cookie); } get sr() { var { token: t, opt_out_capturing_cookie_prefix: e, consent_persistence_name: i } = this._instance.config; return i || (e ? e + t : "__ph_opt_in_out_" + t); } get ir() { var t = this.nr.O(this.sr); return W$2(t) ? 1 : w$1(G$3, t) ? 0 : -1; } get nr() { var t = this.Bt.opt_out_capturing_persistence_type, e = "localStorage" === t ? hr$1 : lr$1; if (!this.ar || this.ar !== e) { this.ar = e; var i = "localStorage" === t ? lr$1 : hr$1; i.O(this.sr) && (this.ar.O(this.sr) || this.optInOut(W$2(i.O(this.sr))), i.F(this.sr, this.Bt.cross_subdomain_cookie)); } return this.ar; } rr() { return !!this.Bt.respect_dnt && [ null == i$1 ? void 0 : i$1.doNotTrack, null == i$1 ? void 0 : i$1.msDoNotTrack, h$3.doNotTrack ].some(((t) => W$2(t))); } }; var gr$1 = Ce$2("[Dead Clicks]"), mr$1 = () => !0, br$1 = (t) => { var e, i = !(null == (e = t.instance.persistence) || !e.get_property(Ve)), r = t.instance.config.capture_dead_clicks; return N(r) ? r : !!O$1(r) || i; }; var yr$1 = class { get lazyLoadedDeadClicksAutocapture() { return this.lr; } constructor(t, e, i) { this.instance = t, this.isEnabled = e, this.onCapture = i, this.startIfEnabledOrStop(); } onRemoteConfig(t) { "captureDeadClicks" in t && (this.instance.persistence && this.instance.persistence.register({ [Ve]: t.captureDeadClicks }), this.startIfEnabledOrStop()); } startIfEnabledOrStop() { this.isEnabled(this) ? this.ur((() => { this.hr(); })) : this.stop(); } ur(t) { var e, i; null != (e = h$3.__PosthogExtensions__) && e.initDeadClicksAutocapture && t(), null == (i = h$3.__PosthogExtensions__) || null == i.loadExternalDependency || i.loadExternalDependency(this.instance, "dead-clicks-autocapture", ((e) => { e ? gr$1.error("failed to load script", e) : t(); })); } hr() { var t; if (r$1) { if (!this.lr && null != (t = h$3.__PosthogExtensions__) && t.initDeadClicksAutocapture) { var e = O$1(this.instance.config.capture_dead_clicks) ? this.instance.config.capture_dead_clicks : {}; e.__onCapture = this.onCapture, this.lr = h$3.__PosthogExtensions__.initDeadClicksAutocapture(this.instance, e), this.lr.start(r$1), gr$1.info("starting..."); } } else gr$1.error("`document` not found. Cannot start."); } stop() { this.lr && (this.lr.stop(), this.lr = void 0, gr$1.info("stopping...")); } }; var wr$1 = Ce$2("[SegmentIntegration]"); var xr$1 = "posthog-js"; function Er$1(t, e) { var { organization: i, projectId: r, prefix: s, severityAllowList: n = ["error"], sendExceptionsToPostHog: o = !0 } = void 0 === e ? {} : e; return (e) => { var a, l, u, h, d; if ("*" !== n && !n.includes(e.level) || !t.__loaded) return e; e.tags || (e.tags = {}); var v = t.requestRouter.endpointFor("ui", "/project/" + t.config.token + "/person/" + t.get_distinct_id()); e.tags["PostHog Person URL"] = v, t.sessionRecordingStarted() && (e.tags["PostHog Recording URL"] = t.get_session_replay_url({ withTimestamp: !0 })); var c, p = (null == (a = e.exception) ? void 0 : a.values) || [], _ = p.map(((t) => f$1({}, t, { stacktrace: t.stacktrace ? f$1({}, t.stacktrace, { type: "raw", frames: (t.stacktrace.frames || []).map(((t) => f$1({}, t, { platform: "web:javascript" }))) }) : void 0 }))), g = { $exception_message: (null == (l = p[0]) ? void 0 : l.value) || e.message, $exception_type: null == (u = p[0]) ? void 0 : u.type, $exception_level: e.level, $exception_list: _, $sentry_event_id: e.event_id, $sentry_exception: e.exception, $sentry_exception_message: (null == (h = p[0]) ? void 0 : h.value) || e.message, $sentry_exception_type: null == (d = p[0]) ? void 0 : d.type, $sentry_tags: e.tags }; return i && r && (g.$sentry_url = (s || "https://sentry.io/organizations/") + i + "/issues/?project=" + r + "&query=" + e.event_id), o && (null == (c = t.exceptions) || c.sendExceptionEvent(g)), e; }; } var Sr$1 = class { constructor(t, e, i, r, s, n) { this.name = xr$1, this.setupOnce = function(o) { o(Er$1(t, { organization: e, projectId: i, prefix: r, severityAllowList: s, sendExceptionsToPostHog: null == n || n })); }; } }; var $r = class { constructor(t) { this.cr = (t, e, i) => { i && (i.noSessionId || i.activityTimeout || i.sessionPastMaximumLength) && (Ie.info("[PageViewManager] Session rotated, clearing pageview state", { sessionId: t, changeReason: i }), this.dr = void 0, this._instance.scrollManager.resetContext()); }, this._instance = t, this.vr(); } vr() { var t; this.pr = null == (t = this._instance.sessionManager) ? void 0 : t.onSessionId(this.cr); } destroy() { var t; null == (t = this.pr) || t.call(this), this.pr = void 0; } doPageView(e, i) { var r, s = this.gr(e, i); return this.dr = { pathname: null !== (r = null == t ? void 0 : t.location.pathname) && void 0 !== r ? r : "", pageViewId: i, timestamp: e }, this._instance.scrollManager.resetContext(), s; } doPageLeave(t) { var e; return this.gr(t, null == (e = this.dr) ? void 0 : e.pageViewId); } doEvent() { var t; return { $pageview_id: null == (t = this.dr) ? void 0 : t.pageViewId }; } gr(t, e) { var i = this.dr; if (!i) return { $pageview_id: e }; var r = { $pageview_id: e, $prev_pageview_id: i.pageViewId }, s = this._instance.scrollManager.getContext(); if (s && !this._instance.config.disable_scroll_properties) { var { maxScrollHeight: n, lastScrollY: o, maxScrollY: a, maxContentHeight: l, lastContentY: u, maxContentY: h } = s; if (!(C$2(n) || C$2(o) || C$2(a) || C$2(l) || C$2(u) || C$2(h))) { n = Math.ceil(n), o = Math.ceil(o), a = Math.ceil(a), l = Math.ceil(l), u = Math.ceil(u), h = Math.ceil(h); var d = n > 1 ? Y$1(o / n, 0, 1, Ie) : 1, v = n > 1 ? Y$1(a / n, 0, 1, Ie) : 1, c = l > 1 ? Y$1(u / l, 0, 1, Ie) : 1, p = l > 1 ? Y$1(h / l, 0, 1, Ie) : 1; r = qi(r, { $prev_pageview_last_scroll: o, $prev_pageview_last_scroll_percentage: d, $prev_pageview_max_scroll: a, $prev_pageview_max_scroll_percentage: v, $prev_pageview_last_content: u, $prev_pageview_last_content_percentage: c, $prev_pageview_max_content: h, $prev_pageview_max_content_percentage: p }); } } return i.pathname && (r.$prev_pageview_pathname = i.pathname), i.timestamp && (r.$prev_pageview_duration = (t.getTime() - i.timestamp.getTime()) / 1e3), r; } }; var Tr$1 = { [Me$2]: { exposure: "hidden" }, [Le$1]: { exposure: "hidden" }, __cmpns: { exposure: "hidden" }, [Ue]: { exposure: "hidden" }, [Ne$3]: { exposure: "event" }, [je$2]: { exposure: "hidden" }, [ze$1]: { exposure: "event" }, [Be$1]: { exposure: "hidden" }, [He$3]: { exposure: "event" }, [qe]: { exposure: "event" }, [Ve]: { exposure: "event" }, [We$1]: { exposure: "hidden" }, [Ge]: { exposure: "event" }, [Ye$1]: { exposure: "hidden" }, $session_recording_enabled_server_side: { exposure: "hidden" }, [Ze$2]: { exposure: "hidden" }, [ti$1]: { exposure: "event" }, $session_past_minimum_duration: { exposure: "event" }, $session_recording_url_trigger_activated_session: { exposure: "event" }, $session_recording_event_trigger_activated_session: { exposure: "event" }, $debug_first_full_snapshot_timestamp: { exposure: "event" }, [ei$1]: { exposure: "derived", shouldSkipFromEventProperties: (t, e) => e(), transformToEventProperties(t) { if (!O$1(t)) return {}; for (var e = {}, i = Object.keys(t), r = 0; i.length > r; r++) e["$feature/" + i[r]] = t[i[r]]; return e; } }, [ii$1]: { exposure: "event" }, [ri$1]: { exposure: "hidden" }, [si$1]: { exposure: "hidden" }, [ni]: { exposure: "event" }, [oi$1]: { exposure: "event" }, [ai$1]: { exposure: "event" }, [li$1]: { exposure: "hidden" }, [ui$1]: { exposure: "hidden" }, [hi$1]: { exposure: "hidden" }, [di$1]: { exposure: "hidden" }, [vi$1]: { exposure: "event" }, [ci$1]: { exposure: "hidden" }, $product_tours_activated: { exposure: "hidden" }, $conversations_widget_session_id: { exposure: "event" }, $conversations_ticket_id: { exposure: "event" }, $conversations_widget_state: { exposure: "event" }, $conversations_user_traits: { exposure: "event" }, [pi]: { exposure: "hidden" }, [fi$1]: { exposure: "hidden" }, [_i$1]: { exposure: "hidden" }, [gi$1]: { exposure: "hidden" }, [mi$1]: { exposure: "hidden" }, [bi$1]: { exposure: "hidden" }, [yi$1]: { exposure: "hidden" }, [wi]: { exposure: "hidden" }, [xi]: { exposure: "hidden" }, [Ei$1]: { exposure: "hidden" }, [Si]: { exposure: "hidden" }, [Je]: { exposure: "event" }, [Ke]: { exposure: "event" }, [Xe]: { exposure: "event" }, [Qe$1]: { exposure: "event" }, [ki$1]: { exposure: "event" }, [Ri]: { exposure: "event" }, [Pi]: { exposure: "event" }, $sdk_debug_replay_event_trigger_status: { exposure: "event" }, $sdk_debug_replay_linked_flag_trigger_status: { exposure: "event" }, $sdk_debug_replay_matched_recording_trigger_groups: { exposure: "event" }, $sdk_debug_replay_remote_trigger_matching_config: { exposure: "event" }, $sdk_debug_replay_trigger_groups_count: { exposure: "event" }, $sdk_debug_replay_url_trigger_status: { exposure: "event" }, $session_recording_start_reason: { exposure: "event" } }, kr = [ ["$posthog_sr_group_event_trigger_", { exposure: "hidden" }], ["$posthog_sr_group_url_trigger_", { exposure: "hidden" }], ["$posthog_sr_group_sampling_", { exposure: "hidden" }] ], Rr$1 = (t) => { var e = null == r$1 ? void 0 : r$1.createElement("a"); return C$2(e) ? null : (e.href = t, e); }, Pr$1 = function(t, e) { for (var i, r = ((t.split("#")[0] || "").split(/\?(.*)/)[1] || "").replace(/^\?+/g, "").split("&"), s = 0; r.length > s; s++) { var n = r[s].split("="); if (n[0] === e) { i = n; break; } } if (!R$2(i) || 2 > i.length) return ""; var o = i[1]; try { o = decodeURIComponent(o); } catch (t) { Ie.error("Skipping decoding for malformed query param: " + o); } return o.replace(/\+/g, " "); }, Or$1 = function(t, e, i) { if (!t || !e || !e.length) return t; for (var r = t.split("#"), s = r[1], n = (r[0] || "").split("?"), o = n[1], a = n[0], l = (o || "").split("&"), u = [], h = 0; l.length > h; h++) { var d = l[h].split("="); R$2(d) && (e.includes(d[0]) ? u.push(d[0] + "=" + i) : u.push(l[h])); } var v = a; return null != o && (v += "?" + u.join("&")), null != s && (v += "#" + s), v; }, Ir = function(t, e) { var i = t.match(new RegExp(e + "=([^&]*)")); return i ? i[1] : null; }, Cr$1 = "https?://(.*)", Fr$1 = [ "gclid", "gclsrc", "dclid", "gbraid", "wbraid", "fbclid", "msclkid", "twclid", "li_fat_id", "igshid", "ttclid", "rdt_cid", "epik", "qclid", "sccid", "irclid", "_kx" ], Ar$1 = [ "utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term", "gad_source", "mc_cid", ...Fr$1 ], Mr$1 = "", Dr$1 = ["li_fat_id"]; function Lr$1(t, e, i) { if (!r$1) return {}; var s, n = e ? [...Fr$1, ...i || []] : [], o = Ur$1(Or$1(r$1.URL, n, Mr$1), t); return qi((s = {}, Hi(Dr$1, (function(t) { var e = lr$1.O(t); s[t] = e || null; })), s), o); } function Ur$1(t, e) { var i = Ar$1.concat(e || []), r = {}; return Hi(i, (function(e) { r[e] = Pr$1(t, e) || null; })), r; } function Nr$1(t) { var e = function(t) { return t ? 0 === t.search(Cr$1 + "google.([^/?]*)") ? "google" : 0 === t.search(Cr$1 + "bing.com") ? "bing" : 0 === t.search(Cr$1 + "yahoo.com") ? "yahoo" : 0 === t.search(Cr$1 + "duckduckgo.com") ? "duckduckgo" : null : null; }(t), i = "yahoo" != e ? "q" : "p", s = {}; if (!M(e)) { s.$search_engine = e; var n = r$1 ? Pr$1(r$1.referrer, i) : ""; n.length && (s.ph_keyword = n); } return s; } function jr$1() { return navigator.language || navigator.userLanguage; } var zr$1 = "$direct"; function Br$1() { return (null == r$1 ? void 0 : r$1.referrer) || zr$1; } function Hr$1(t, e) { var i = t ? [...Fr$1, ...e || []] : [], r = null == s$1 ? void 0 : s$1.href.substring(0, 1e3); return { r: Br$1().substring(0, 1e3), u: r ? Or$1(r, i, Mr$1) : void 0 }; } function qr$1(t) { var e, { r: i, u: r } = t, s = { $referrer: i, $referring_domain: null == i ? void 0 : i == zr$1 ? zr$1 : null == (e = Rr$1(i)) ? void 0 : e.host }; if (r) { s.$current_url = r; var n = Rr$1(r); s.$host = null == n ? void 0 : n.host, s.$pathname = null == n ? void 0 : n.pathname; qi(s, Ur$1(r)); } if (i) qi(s, Nr$1(i)); return s; } function Vr$1() { try { return Intl.DateTimeFormat().resolvedOptions().timeZone; } catch (t) { return; } } function Wr$1() { try { return (/* @__PURE__ */ new Date()).getTimezoneOffset(); } catch (t) { return; } } var Gr$1 = [ "cookie", "localstorage", "localstorage+cookie", "sessionstorage", "memory" ]; var Yr$1 = class { constructor(t, e) { this.Bt = t, this.props = {}, this.mr = !1, this.yr = ((t) => { var e = ""; return t.token && (e = t.token.replace(/\+/g, "PL").replace(/\//g, "SL").replace(/=/g, "EQ")), t.persistence_name ? "ph_" + t.persistence_name : "ph_" + e + "_posthog"; })(t), this.nr = this.br(t), this.load(), t.debug && Ie.info("Persistence loaded", t.persistence, f$1({}, this.props)), this.update_config(t, t, e), this.save(); } isDisabled() { return !!this._r; } br(e) { -1 === Gr$1.indexOf(e.persistence.toLowerCase()) && (Ie.critical("Unknown persistence type " + e.persistence + "; falling back to localStorage+cookie"), e.persistence = "localStorage+cookie"); var i = function(e) { void 0 === e && (e = []); var i = [...dr$1, ...e]; return f$1({}, hr$1, { Z(t) { try { var e = {}; try { e = lr$1.Z(t) || {}; } catch (t) {} var i = qi(e, JSON.parse(hr$1.O(t) || "{}")); return hr$1.M(t, i), i; } catch (t) {} return null; }, M(t, e, r, s, n, o) { try { hr$1.M(t, e, void 0, void 0, o); var a = {}; i.forEach(((t) => { e[t] && (a[t] = e[t]); })), Object.keys(a).length && lr$1.M(t, a, r, s, n, o); } catch (t) { hr$1.B(t); } }, F(e, i) { try { t?.localStorage.removeItem(e), lr$1.F(e, i); } catch (t) { hr$1.B(t); } } }); }(e.cookie_persisted_properties || []), r = e.persistence.toLowerCase(); return "localstorage" === r && hr$1.R() ? hr$1 : "localstorage+cookie" === r && i.R() ? i : "sessionstorage" === r && fr$1.R() ? fr$1 : "memory" === r ? cr : "cookie" === r ? lr$1 : i.R() ? i : lr$1; } wr(t) { var e = null != t ? t : this.Bt.feature_flag_cache_ttl_ms; if (!e || 0 >= e) return !1; var i = this.props[gi$1]; return !i || "number" != typeof i || Date.now() - i > e; } properties() { var t = {}; return Hi(this.props, ((e, i) => { var r = ((t) => { var e = Tr$1[t]; if (e) return e; for (var [i, r] of kr) if (0 === t.indexOf(i)) return r; })(i); if ("derived" === (null == r ? void 0 : r.exposure)) { if (null != r.shouldSkipFromEventProperties && r.shouldSkipFromEventProperties(e, i === ei$1 ? () => this.wr() : () => !1)) return; r.transformToEventProperties && qi(t, r.transformToEventProperties(e)); } else r && "event" !== r.exposure || (t[i] = e); })), t; } load() { if (!this._r) { var t = this.nr.Z(this.yr); t && (this.props = qi({}, t)); } } save() { this._r || this.nr.M(this.yr, this.props, this.Ir, this.Cr, this.Sr, this.Bt.debug); } remove() { this.nr.F(this.yr, !1), this.nr.F(this.yr, !0); } clear() { this.remove(), this.props = {}; } register_once(t, e, i) { if (O$1(t)) { C$2(e) && (e = "None"), this.Ir = C$2(i) ? this.kr : i; var r = !1; if (Hi(t, ((t, i) => { this.props.hasOwnProperty(i) && this.props[i] !== e || (this.Tr(i, t), r = !0); })), r) return this.save(), !0; } return !1; } register(t, e) { if (O$1(t)) { this.Ir = C$2(e) ? this.kr : e; var i = !1; if (Hi(t, ((e, r) => { t.hasOwnProperty(r) && this.props[r] !== e && (this.Tr(r, e), i = !0); })), i) return this.save(), !0; } return !1; } unregister(t) { t in this.props && (this.Ar(t), this.save()); } update_campaign_params() { if (!this.mr) { var t = Lr$1(this.Bt.custom_campaign_params, this.Bt.mask_personal_data_properties, this.Bt.custom_personal_data_properties); I(Yi(t)) || this.register(t), this.mr = !0; } } update_search_keyword() { var t; this.register((t = null == r$1 ? void 0 : r$1.referrer) ? Nr$1(t) : {}); } update_referrer_info() { var t; this.register_once({ $referrer: Br$1(), $referring_domain: null != r$1 && r$1.referrer && (null == (t = Rr$1(r$1.referrer)) ? void 0 : t.host) || zr$1 }, void 0); } set_initial_person_info() { this.props[wi] || this.props[xi] || this.register_once({ [Ei$1]: Hr$1(this.Bt.mask_personal_data_properties, this.Bt.custom_personal_data_properties) }, void 0); } get_initial_props() { var t = {}; Hi([xi, wi], ((e) => { var i = this.props[e]; i && Hi(i, (function(e, i) { t["$initial_" + E$2(i)] = e; })); })); var e, i, r = this.props[Ei$1]; if (r) qi(t, (e = qr$1(r), i = {}, Hi(e, (function(t, e) { i["$initial_" + E$2(e)] = t; })), i)); return t; } safe_merge(t) { return Hi(this.props, (function(e, i) { i in t || (t[i] = e); })), t; } update_config(t, e, i) { if (this.kr = this.Ir = t.cookie_expiration, this.set_disabled(t.disable_persistence || !!i), this.set_cross_subdomain(t.cross_subdomain_cookie), this.set_secure(t.secure_cookie), t.persistence !== e.persistence || !((t, e) => { if (t.length !== e.length) return !1; var i = [...t].sort(), r = [...e].sort(); return i.every(((t, e) => t === r[e])); })(t.cookie_persisted_properties || [], e.cookie_persisted_properties || [])) { var r = this.br(t), s = this.props; this.clear(), this.nr = r, this.props = s, this.save(); } } set_disabled(t) { this._r = t, this._r ? this.remove() : this.save(); } set_cross_subdomain(t) { t !== this.Cr && (this.Cr = t, this.remove(), this.save()); } set_secure(t) { t !== this.Sr && (this.Sr = t, this.remove(), this.save()); } set_event_timer(t, e) { var i = this.props[Ue] || {}; i[t] = e, this.Tr(Ue, i), this.save(); } remove_event_timer(t) { var e = this.props[Ue] || {}, i = e[t]; return C$2(i) || (delete e[t], this.Tr(Ue, e), this.save()), i; } get_property(t) { return this.props[t]; } set_property(t, e) { this.Tr(t, e), this.save(); } Tr(t, e) { this.props[t] = e; } Ar(t) { delete this.props[t]; } }, Jr$1 = { Activation: "events", Cancellation: "cancelEvents" }, Zr = { Popover: "popover", API: "api", Widget: "widget", ExternalSurvey: "external_survey" }, rs$1 = { SHOWN: "survey shown", DISMISSED: "survey dismissed", SENT: "survey sent", ABANDONED: "survey abandoned" }, ss = { SURVEY_ID: "$survey_id", SURVEY_NAME: "$survey_name", SURVEY_RESPONSE: "$survey_response", SURVEY_ITERATION: "$survey_iteration", SURVEY_ITERATION_START_DATE: "$survey_iteration_start_date", SURVEY_PARTIALLY_COMPLETED: "$survey_partially_completed", SURVEY_SUBMISSION_ID: "$survey_submission_id", SURVEY_QUESTIONS: "$survey_questions", SURVEY_COMPLETED: "$survey_completed", PRODUCT_TOUR_ID: "$product_tour_id", SURVEY_LAST_SEEN_DATE: "$survey_last_seen_date", SURVEY_LANGUAGE: "$survey_language" }, ns = { Popover: "popover", Inline: "inline" }, as = { SHOWN: "product tour shown", DISMISSED: "product tour dismissed", COMPLETED: "product tour completed", STEP_SHOWN: "product tour step shown", STEP_COMPLETED: "product tour step completed", BUTTON_CLICKED: "product tour button clicked", STEP_SELECTOR_FAILED: "product tour step selector failed", BANNER_CONTAINER_SELECTOR_FAILED: "product tour banner container selector failed", BANNER_ACTION_CLICKED: "product tour banner action clicked" }, ls$1 = { TOUR_ID: "$product_tour_id", TOUR_NAME: "$product_tour_name", TOUR_ITERATION: "$product_tour_iteration", TOUR_RENDER_REASON: "$product_tour_render_reason", TOUR_STEP_ID: "$product_tour_step_id", TOUR_STEP_ORDER: "$product_tour_step_order", TOUR_STEP_TYPE: "$product_tour_step_type", TOUR_DISMISS_REASON: "$product_tour_dismiss_reason", TOUR_BUTTON_TEXT: "$product_tour_button_text", TOUR_BUTTON_ACTION: "$product_tour_button_action", TOUR_BUTTON_LINK: "$product_tour_button_link", TOUR_BUTTON_TOUR_ID: "$product_tour_button_tour_id", TOUR_STEPS_COUNT: "$product_tour_steps_count", TOUR_STEP_SELECTOR: "$product_tour_step_selector", TOUR_STEP_SELECTOR_FOUND: "$product_tour_step_selector_found", TOUR_STEP_ELEMENT_TAG: "$product_tour_step_element_tag", TOUR_STEP_ELEMENT_ID: "$product_tour_step_element_id", TOUR_STEP_ELEMENT_CLASSES: "$product_tour_step_element_classes", TOUR_STEP_ELEMENT_TEXT: "$product_tour_step_element_text", TOUR_ERROR: "$product_tour_error", TOUR_MATCHES_COUNT: "$product_tour_matches_count", TOUR_FAILURE_PHASE: "$product_tour_failure_phase", TOUR_WAITED_FOR_ELEMENT: "$product_tour_waited_for_element", TOUR_WAIT_DURATION_MS: "$product_tour_wait_duration_ms", TOUR_BANNER_SELECTOR: "$product_tour_banner_selector", TOUR_LINKED_SURVEY_ID: "$product_tour_linked_survey_id", USE_MANUAL_SELECTOR: "$use_manual_selector", INFERENCE_DATA_PRESENT: "$inference_data_present", TOUR_LAST_SEEN_DATE: "$product_tour_last_seen_date", TOUR_TYPE: "$product_tour_type" }, us = Ce$2("[RateLimiter]"); var hs = class { constructor(t) { this.serverLimits = {}, this.lastEventRateLimited = !1, this.checkForLimiting = (t) => { var e = t.text; if (e && e.length) try { (JSON.parse(e).quota_limited || []).forEach(((t) => { us.info((t || "events") + " is quota limited."), this.serverLimits[t] = (/* @__PURE__ */ new Date()).getTime() + 6e4; })); } catch (t) { us.warn("could not rate limit - continuing. Error: \"" + (null == t ? void 0 : t.message) + "\"", { text: e }); return; } }, this.instance = t, this.lastEventRateLimited = this.clientRateLimitContext(!0).isRateLimited; } get captureEventsPerSecond() { var t; return (null == (t = this.instance.config.rate_limiting) ? void 0 : t.events_per_second) || 10; } get captureEventsBurstLimit() { var t; return Math.max((null == (t = this.instance.config.rate_limiting) ? void 0 : t.events_burst_limit) || 10 * this.captureEventsPerSecond, this.captureEventsPerSecond); } clientRateLimitContext(t) { var e, i, r; void 0 === t && (t = !1); var { captureEventsBurstLimit: s, captureEventsPerSecond: n } = this, o = (/* @__PURE__ */ new Date()).getTime(), a = null !== (e = null == (i = this.instance.persistence) ? void 0 : i.get_property(yi$1)) && void 0 !== e ? e : { tokens: s, last: o }; a.tokens += (o - a.last) / 1e3 * n, a.last = o, a.tokens > s && (a.tokens = s); var l = 1 > a.tokens; return l || t || (a.tokens = Math.max(0, a.tokens - 1)), !l || this.lastEventRateLimited || t || this.instance.capture("$$client_ingestion_warning", { $$client_ingestion_warning_message: "posthog-js client rate limited. Config is set to " + n + " events per second and " + s + " events burst limit." }, { skip_client_rate_limiting: !0 }), this.lastEventRateLimited = l, null == (r = this.instance.persistence) || r.set_property(yi$1, a), { isRateLimited: l, remainingTokens: a.tokens }; } isServerRateLimited(t) { var e = this.serverLimits[t || "events"] || !1; return !1 !== e && (/* @__PURE__ */ new Date()).getTime() < e; } }; var ds = Ce$2("[RemoteConfig]"); var vs = class { constructor(t) { this._instance = t; } get remoteConfig() { var t; return null == (t = h$3._POSTHOG_REMOTE_CONFIG) || null == (t = t[this._instance.config.token]) ? void 0 : t.config; } Er(t) { var e, i; null != (e = h$3.__PosthogExtensions__) && e.loadExternalDependency ? null == (i = h$3.__PosthogExtensions__) || null == i.loadExternalDependency || i.loadExternalDependency(this._instance, "remote-config", (() => t(this.remoteConfig))) : t(); } Rr(t) { this._instance._send_request({ method: "GET", url: this._instance.requestRouter.endpointFor("assets", "/array/" + this._instance.config.token + "/config"), callback(e) { t(e.json); } }); } load() { try { if (this.remoteConfig) return ds.info("Using preloaded remote config", this.remoteConfig), this.Nr(this.remoteConfig), void this.Mr(); if (this._instance.Fr()) return void ds.warn("Remote config is disabled. Falling back to local config."); this.Er(((t) => { if (!t) return ds.info("No config found after loading remote JS config. Falling back to JSON."), void this.Rr(((t) => { this.Nr(t), this.Mr(); })); this.Nr(t), this.Mr(); })); } catch (t) { ds.error("Error loading remote config", t); } } stop() { this.Or && (clearInterval(this.Or), this.Or = void 0); } refresh() { this._instance.Fr() || "hidden" === (null == r$1 ? void 0 : r$1.visibilityState) || this._instance.reloadFeatureFlags(); } Mr() { var t; if (!this.Or) { var e = null !== (t = this._instance.config.remote_config_refresh_interval_ms) && void 0 !== t ? t : 3e5; 0 !== e && (this.Or = setInterval((() => { this.refresh(); }), e)); } } Nr(t) { var e; t || ds.error("Failed to fetch remote config from PostHog."), this._instance.Nr(null != t ? t : {}), !1 !== (null == t ? void 0 : t.hasFeatureFlags) && (this._instance.config.advanced_disable_feature_flags_on_first_load || null == (e = this._instance.featureFlags) || e.ensureFlagsLoaded()); } }, ps = { GZipJS: "gzip-js", Base64: "base64" }, fs = Uint8Array, _s = Uint16Array, gs = Uint32Array, ms = new fs([ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0 ]), bs = new fs([ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0 ]), ys = new fs([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]), ws$1 = function(t, e) { for (var i = new _s(31), r = 0; 31 > r; ++r) i[r] = e += 1 << t[r - 1]; var s = new gs(i[30]); for (r = 1; 30 > r; ++r) for (var n = i[r]; i[r + 1] > n; ++n) s[n] = n - i[r] << 5 | r; return [i, s]; }, xs$1 = ws$1(ms, 2), Es = xs$1[1]; xs$1[0][28] = 258, Es[258] = 28; for (var Ss$1 = ws$1(bs, 0)[1], $s$1 = new _s(32768), Ts = 0; 32768 > Ts; ++Ts) { var ks = (43690 & Ts) >>> 1 | (21845 & Ts) << 1; $s$1[Ts] = ((65280 & (ks = (61680 & (ks = (52428 & ks) >>> 2 | (13107 & ks) << 2)) >>> 4 | (3855 & ks) << 4)) >>> 8 | (255 & ks) << 8) >>> 1; } var Rs$1 = function(t, e, i) { for (var r = t.length, s = 0, n = new _s(e); r > s; ++s) ++n[t[s] - 1]; var o, a = new _s(e); for (s = 0; e > s; ++s) a[s] = a[s - 1] + n[s - 1] << 1; if (i) { o = new _s(1 << e); var l = 15 - e; for (s = 0; r > s; ++s) if (t[s]) for (var u = s << 4 | t[s], h = e - t[s], d = a[t[s] - 1]++ << h, v = d | (1 << h) - 1; v >= d; ++d) o[$s$1[d] >>> l] = u; } else for (o = new _s(r), s = 0; r > s; ++s) o[s] = $s$1[a[t[s] - 1]++] >>> 15 - t[s]; return o; }, Ps$1 = new fs(288); for (Ts = 0; 144 > Ts; ++Ts) Ps$1[Ts] = 8; for (Ts = 144; 256 > Ts; ++Ts) Ps$1[Ts] = 9; for (Ts = 256; 280 > Ts; ++Ts) Ps$1[Ts] = 7; for (Ts = 280; 288 > Ts; ++Ts) Ps$1[Ts] = 8; var Os$1 = new fs(32); for (Ts = 0; 32 > Ts; ++Ts) Os$1[Ts] = 5; var Is = Rs$1(Ps$1, 9, 0), Cs = Rs$1(Os$1, 5, 0), Fs$1 = function(t) { return (t / 8 >> 0) + (7 & t && 1); }, As$1 = function(t, e, i) { (null == i || i > t.length) && (i = t.length); var r = new (t instanceof _s ? _s : t instanceof gs ? gs : fs)(i - e); return r.set(t.subarray(e, i)), r; }, Ms = function(t, e, i) { var r = e / 8 >> 0; t[r] |= i <<= 7 & e, t[r + 1] |= i >>> 8; }, Ds$1 = function(t, e, i) { var r = e / 8 >> 0; t[r] |= i <<= 7 & e, t[r + 1] |= i >>> 8, t[r + 2] |= i >>> 16; }, Ls = function(t, e) { for (var i = [], r = 0; t.length > r; ++r) t[r] && i.push({ s: r, f: t[r] }); var s = i.length, n = i.slice(); if (!s) return [new fs(0), 0]; if (1 == s) { var o = new fs(i[0].s + 1); return o[i[0].s] = 1, [o, 1]; } i.sort((function(t, e) { return t.f - e.f; })), i.push({ s: -1, f: 25001 }); var a = i[0], l = i[1], u = 0, h = 1, d = 2; for (i[0] = { s: -1, f: a.f + l.f, l: a, r: l }; h != s - 1;) a = i[i[d].f > i[u].f ? u++ : d++], l = i[u != h && i[d].f > i[u].f ? u++ : d++], i[h++] = { s: -1, f: a.f + l.f, l: a, r: l }; var v = n[0].s; for (r = 1; s > r; ++r) n[r].s > v && (v = n[r].s); var c = new _s(v + 1), p = Us(i[h - 1], c, 0); if (p > e) { r = 0; var f = 0, _ = p - e, g = 1 << _; for (n.sort((function(t, e) { return c[e.s] - c[t.s] || t.f - e.f; })); s > r; ++r) { var m = n[r].s; if (e >= c[m]) break; f += g - (1 << p - c[m]), c[m] = e; } for (f >>>= _; f > 0;) { var b = n[r].s; e > c[b] ? f -= 1 << e - c[b]++ - 1 : ++r; } for (; r >= 0 && f; --r) { var y = n[r].s; c[y] == e && (--c[y], ++f); } p = e; } return [new fs(c), p]; }, Us = function(t, e, i) { return -1 == t.s ? Math.max(Us(t.l, e, i + 1), Us(t.r, e, i + 1)) : e[t.s] = i; }, Ns = function(t) { for (var e = t.length; e && !t[--e];); for (var i = new _s(++e), r = 0, s = t[0], n = 1, o = function(t) { i[r++] = t; }, a = 1; e >= a; ++a) if (t[a] == s && a != e) ++n; else { if (!s && n > 2) { for (; n > 138; n -= 138) o(32754); n > 2 && (o(n > 10 ? n - 11 << 5 | 28690 : n - 3 << 5 | 12305), n = 0); } else if (n > 3) { for (o(s), --n; n > 6; n -= 6) o(8304); n > 2 && (o(n - 3 << 5 | 8208), n = 0); } for (; n--;) o(s); n = 1, s = t[a]; } return [i.subarray(0, r), e]; }, js$1 = function(t, e) { for (var i = 0, r = 0; e.length > r; ++r) i += t[r] * e[r]; return i; }, zs$1 = function(t, e, i) { var r = i.length, s = Fs$1(e + 2); t[s] = 255 & r, t[s + 1] = r >>> 8, t[s + 2] = 255 ^ t[s], t[s + 3] = 255 ^ t[s + 1]; for (var n = 0; r > n; ++n) t[s + n + 4] = i[n]; return 8 * (s + 4 + r); }, Bs = function(t, e, i, r, s, n, o, a, l, u, h) { Ms(e, h++, i), ++s[256]; for (var d = Ls(s, 15), v = d[0], c = d[1], p = Ls(n, 15), f = p[0], _ = p[1], g = Ns(v), m = g[0], b = g[1], y = Ns(f), w = y[0], x = y[1], E = new _s(19), S = 0; m.length > S; ++S) E[31 & m[S]]++; for (S = 0; w.length > S; ++S) E[31 & w[S]]++; for (var T = Ls(E, 7), k = T[0], R = T[1], P = 19; P > 4 && !k[ys[P - 1]]; --P); var O, I, C, F, A = u + 5 << 3, M = js$1(s, Ps$1) + js$1(n, Os$1) + o, D = js$1(s, v) + js$1(n, f) + o + 14 + 3 * P + js$1(E, k) + (2 * E[16] + 3 * E[17] + 7 * E[18]); if (M >= A && D >= A) return zs$1(e, h, t.subarray(l, l + u)); if (Ms(e, h, 1 + (M > D)), h += 2, M > D) { O = Rs$1(v, c, 0), I = v, C = Rs$1(f, _, 0), F = f; var L = Rs$1(k, R, 0); for (Ms(e, h, b - 257), Ms(e, h + 5, x - 1), Ms(e, h + 10, P - 4), h += 14, S = 0; P > S; ++S) Ms(e, h + 3 * S, k[ys[S]]); h += 3 * P; for (var U = [m, w], N = 0; 2 > N; ++N) { var j = U[N]; for (S = 0; j.length > S; ++S) Ms(e, h, L[z = 31 & j[S]]), h += k[z], z > 15 && (Ms(e, h, j[S] >>> 5 & 127), h += j[S] >>> 12); } } else O = Is, I = Ps$1, C = Cs, F = Os$1; for (S = 0; a > S; ++S) if (r[S] > 255) { var z; Ds$1(e, h, O[257 + (z = r[S] >>> 18 & 31)]), h += I[z + 257], z > 7 && (Ms(e, h, r[S] >>> 23 & 31), h += ms[z]); var B = 31 & r[S]; Ds$1(e, h, C[B]), h += F[B], B > 3 && (Ds$1(e, h, r[S] >>> 5 & 8191), h += bs[B]); } else Ds$1(e, h, O[r[S]]), h += I[r[S]]; return Ds$1(e, h, O[256]), h + I[256]; }, Hs$1 = new gs([ 65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632 ]), qs$1 = function() { for (var t = new gs(256), e = 0; 256 > e; ++e) { for (var i = e, r = 9; --r;) i = (1 & i && 3988292384) ^ i >>> 1; t[e] = i; } return t; }(), Vs$1 = function(t, e, i) { for (; i; ++e) t[e] = i, i >>>= 8; }; function Ws$1(t, e) { void 0 === e && (e = {}); var i = function() { var t = 4294967295; return { p(e) { for (var i = t, r = 0; e.length > r; ++r) i = qs$1[255 & i ^ e[r]] ^ i >>> 8; t = i; }, d() { return 4294967295 ^ t; } }; }(), r = t.length; i.p(t); var s, n, o, a, l, u = (a = 10 + ((s = e).filename && s.filename.length + 1 || 0), l = 8, function(t, e, i, r, s, n) { var o = t.length, a = new fs(r + o + 5 * (1 + Math.floor(o / 7e3)) + s), l = a.subarray(r, a.length - s), u = 0; if (!e || 8 > o) for (var h = 0; o >= h; h += 65535) { var d = h + 65535; o > d ? u = zs$1(l, u, t.subarray(h, d)) : (l[h] = !0, u = zs$1(l, u, t.subarray(h, o))); } else { for (var v = Hs$1[e - 1], c = v >>> 13, p = 8191 & v, f = (1 << i) - 1, _ = new _s(32768), g = new _s(f + 1), m = Math.ceil(i / 3), b = 2 * m, y = function(e) { return (t[e] ^ t[e + 1] << m ^ t[e + 2] << b) & f; }, w = new gs(25e3), x = new _s(288), E = new _s(32), S = 0, T = 0, k = (h = 0, 0), R = 0, P = 0; o > h; ++h) { var O = y(h), I = 32767 & h, C = g[O]; if (_[I] = C, g[O] = I, h >= R) { var F = o - h; if ((S > 7e3 || k > 24576) && F > 423) { u = Bs(t, l, 0, w, x, E, T, k, P, h - P, u), k = S = T = 0, P = h; for (var A = 0; 286 > A; ++A) x[A] = 0; for (A = 0; 30 > A; ++A) E[A] = 0; } var M = 2, D = 0, L = p, U = I - C & 32767; if (F > 2 && O == y(h - U)) for (var N = Math.min(c, F) - 1, j = Math.min(32767, h), z = Math.min(258, F); j >= U && --L && I != C;) { if (t[h + M] == t[h + M - U]) { for (var B = 0; z > B && t[h + B] == t[h + B - U]; ++B); if (B > M) { if (M = B, D = U, B > N) break; var H = Math.min(U, B - 2), q = 0; for (A = 0; H > A; ++A) { var V = h - U + A + 32768 & 32767, W = V - _[V] + 32768 & 32767; W > q && (q = W, C = V); } } } U += (I = C) - (C = _[I]) + 32768 & 32767; } if (D) { w[k++] = 268435456 | Es[M] << 18 | Ss$1[D]; var G = 31 & Es[M], Y = 31 & Ss$1[D]; T += ms[G] + bs[Y], ++x[257 + G], ++E[Y], R = h + M, ++S; } else w[k++] = t[h], ++x[t[h]]; } } u = Bs(t, l, !0, w, x, E, T, k, P, h - P, u); } return As$1(a, 0, r + Fs$1(u) + s); }(n = t, null == (o = e).level ? 6 : o.level, null == o.mem ? Math.ceil(1.5 * Math.max(8, Math.min(13, Math.log(n.length)))) : 12 + o.mem, a, l)), h = u.length; return function(t, e) { var i = e.filename; if (t[0] = 31, t[1] = 139, t[2] = 8, t[8] = 2 > e.level ? 4 : 9 == e.level ? 2 : 0, t[9] = 3, 0 != e.mtime && Vs$1(t, 4, Math.floor(new Date(e.mtime || Date.now()) / 1e3)), i) { t[3] = 8; for (var r = 0; i.length >= r; ++r) t[r + 10] = i.charCodeAt(r); } }(u, e), Vs$1(u, h - 8, i.d()), Vs$1(u, h - 4, r), u; } var Gs$1 = !!o$1 || !!n$2, Ys = "text/plain", Js = !1, Ks = function(t, e, i) { var r; void 0 === i && (i = !0); var [s, n] = t.split("?"), o = f$1({}, e), a = null !== (r = null == n ? void 0 : n.split("&").map(((t) => { var e, [r, s] = t.split("="), n = i && null !== (e = o[r]) && void 0 !== e ? e : s; return delete o[r], r + "=" + n; }))) && void 0 !== r ? r : [], l = function(t, e) { var i, r; void 0 === e && (e = "&"); var s = []; return Hi(t, (function(t, e) { C$2(t) || C$2(e) || "undefined" === e || (i = encodeURIComponent(((t) => t instanceof File)(t) ? t.name : t.toString()), r = encodeURIComponent(e), s[s.length] = r + "=" + i); })), s.join(e); }(o); return l && a.push(l), s + "?" + a.join("&"); }, Xs$1 = (t, e) => JSON.stringify(t, ((t, e) => "bigint" == typeof e ? e.toString() : e), e), Qs$1 = (t) => { if (t.tr) return t.tr; var { data: e, compression: i } = t; if (e) { if (i === ps.GZipJS) { var r = Ws$1(function(t, e) { var i = t.length; if ("undefined" != typeof TextEncoder) return new TextEncoder().encode(t); for (var r = new fs(t.length + (t.length >>> 1)), s = 0, n = function(t) { r[s++] = t; }, o = 0; i > o; ++o) { if (s + 5 > r.length) { var a = new fs(s + 8 + (i - o << 1)); a.set(r), r = a; } var l = t.charCodeAt(o); 128 > l ? n(l) : 2048 > l ? (n(192 | l >>> 6), n(128 | 63 & l)) : l > 55295 && 57344 > l ? (n(240 | (l = 65536 + (1047552 & l) | 1023 & t.charCodeAt(++o)) >>> 18), n(128 | l >>> 12 & 63), n(128 | l >>> 6 & 63), n(128 | 63 & l)) : (n(224 | l >>> 12), n(128 | l >>> 6 & 63), n(128 | 63 & l)); } return As$1(r, 0, s); }(Xs$1(e)), { mtime: 0 }); return { contentType: Ys, body: r.buffer.slice(r.byteOffset, r.byteOffset + r.byteLength), estimatedSize: r.byteLength }; } if (i === ps.Base64) { var n = ((t) => "data=" + encodeURIComponent("string" == typeof t ? t : Xs$1(t)))(function(t) { return t ? btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g, ((t, e) => String.fromCharCode(parseInt(e, 16))))) : t; }(Xs$1(e))); return { contentType: "application/x-www-form-urlencoded", body: n, estimatedSize: new Blob([n]).size }; } var o = Xs$1(e); return { contentType: "application/json", body: o, estimatedSize: new Blob([o]).size }; } }, Zs$1 = function() { var t = p$2((function* (t) { var i = yield function(t, e, i) { return g$2.apply(this, arguments); }(Xs$1(t.data), v$1.DEBUG, { rethrow: !0 }); if (!i) return t; var r = yield i.arrayBuffer(); return f$1({}, t, { tr: { contentType: Ys, body: r, estimatedSize: r.byteLength } }); })); return function(e) { return t.apply(this, arguments); }; }(), tn = (t, e) => Ks(t, { _: (/* @__PURE__ */ new Date()).getTime().toString(), ver: v$1.JS_SDK_VERSION, compression: e }), en = []; n$2 && en.push({ transport: "fetch", method(t) { var e, i, { contentType: r, body: s, estimatedSize: o } = null !== (e = Qs$1(t)) && void 0 !== e ? e : {}, l = new Headers(); Hi(t.headers, (function(t, e) { l.append(e, t); })), r && l.append("Content-Type", r); var u = t.url, h = null; if (a$1) { var d = new a$1(); h = { signal: d.signal, timeout: setTimeout((() => d.abort()), t.timeout) }; } n$2(u, f$1({ method: (null == t ? void 0 : t.method) || "GET", headers: l, keepalive: "POST" === t.method && 52428.8 > (o || 0), body: s, signal: null == (i = h) ? void 0 : i.signal }, t.fetchOptions)).then(((e) => e.text().then(((i) => { var r = { statusCode: e.status, text: i }; if (200 === e.status) try { r.json = JSON.parse(i); } catch (t) { Ie.error(t); } null == t.callback || t.callback(r); })))).catch(((e) => { Ie.error(e), null == t.callback || t.callback({ statusCode: 0, error: e }); })).finally((() => h ? clearTimeout(h.timeout) : null)); } }), o$1 && en.push({ transport: "XHR", method(t) { var e, i = new o$1(); i.open(t.method || "GET", t.url, !0); var { contentType: r, body: s } = null !== (e = Qs$1(t)) && void 0 !== e ? e : {}; Hi(t.headers, (function(t, e) { i.setRequestHeader(e, t); })), r && i.setRequestHeader("Content-Type", r), t.timeout && (i.timeout = t.timeout), t.disableXHRCredentials || (i.withCredentials = !0), i.onreadystatechange = () => { if (4 === i.readyState) { var e = { statusCode: i.status, text: i.responseText }; if (200 === i.status) try { e.json = JSON.parse(i.responseText); } catch (t) {} null == t.callback || t.callback(e); } }, i.send(s); } }), null != i$1 && i$1.sendBeacon && en.push({ transport: "sendBeacon", method(t) { var e = Ks(t.url, { beacon: "1" }); try { var r, { contentType: s, body: n } = null !== (r = Qs$1(t)) && void 0 !== r ? r : {}; if (!n) return; var o = n instanceof Blob ? n : new Blob([n], { type: s }); i$1.sendBeacon(e, o); } catch (t) {} } }); var rn$1 = 3e3; var sn$1 = class { constructor(t, e) { this.Pr = !0, this.Lr = [], this.Dr = Y$1((null == e ? void 0 : e.flush_interval_ms) || rn$1, 250, 5e3, Ie.createLogger("flush interval"), rn$1), this.Br = t; } enqueue(t) { this.Lr.push(t), this.jr || this.$r(); } unload() { this.qr(); var t = this.Lr.length > 0 ? this.Zr() : {}, e = Object.values(t); [...e.filter(((t) => 0 === t.url.indexOf("/e"))), ...e.filter(((t) => 0 !== t.url.indexOf("/e")))].map(((t) => { this.Br(f$1({}, t, { transport: "sendBeacon" })); })); } enable() { this.Pr = !1, this.$r(); } $r() { var t = this; this.Pr || (this.jr = setTimeout((() => { if (this.qr(), this.Lr.length > 0) { var e = this.Zr(), i = function() { var i = e[r], s = (/* @__PURE__ */ new Date()).getTime(); i.data && R$2(i.data) && Hi(i.data, ((t) => { t.offset = Math.abs(t.timestamp - s), delete t.timestamp; })), t.Br(i); }; for (var r in e) i(); } }), this.Dr)); } qr() { clearTimeout(this.jr), this.jr = void 0; } Zr() { var t = {}; return Hi(this.Lr, ((e) => { var i, r = e, s = (r ? r.batchKey : null) || r.url; C$2(t[s]) && (t[s] = f$1({}, r, { data: [] })), null == (i = t[s].data) || i.push(r.data); })), this.Lr = [], t; } }; var nn = ["retriesPerformedSoFar"]; var on = class { constructor(e) { this.Vr = !1, this.Hr = 3e3, this.Lr = [], this._instance = e, this.Lr = [], this.zr = !0, !C$2(t) && "onLine" in t.navigator && (this.zr = t.navigator.onLine, this.Ur = () => { this.zr = !0, this.Yr(); }, this.Gr = () => { this.zr = !1; }, Xi(t, "online", this.Ur), Xi(t, "offline", this.Gr)); } get length() { return this.Lr.length; } retriableRequest(t) { var { retriesPerformedSoFar: e } = t, i = _$1(t, nn); U$1(e) && (i.url = Ks(i.url, { retry_count: e })), this._instance._send_request(f$1({}, i, { callback: (t) => { 200 === t.statusCode || t.statusCode >= 400 && 500 > t.statusCode || (null != e ? e : 0) >= 10 ? null == i.callback || i.callback(t) : this.Wr(f$1({ retriesPerformedSoFar: e }, i)); } })); } Wr(t) { var e = t.retriesPerformedSoFar || 0; t.retriesPerformedSoFar = e + 1; var i = function(t) { var e = 3e3 * Math.pow(2, t), i = e / 2, r = Math.min(18e5, e), s = Math.random() - .5; return Math.ceil(r + s * (r - i)); }(e), r = Date.now() + i; this.Lr.push({ retryAt: r, requestOptions: t }); var s = "Enqueued failed request for retry in " + i; navigator.onLine || (s += " (Browser is offline)"), Ie.warn(s), this.Vr || (this.Vr = !0, this.Xr()); } Xr() { if (this.Jr && clearTimeout(this.Jr), 0 === this.Lr.length) return this.Vr = !1, void (this.Jr = void 0); this.Jr = setTimeout((() => { this.zr && this.Lr.length > 0 && this.Yr(), this.Xr(); }), this.Hr); } Yr() { var t = Date.now(), e = [], i = this.Lr.filter(((i) => t > i.retryAt || (e.push(i), !1))); if (this.Lr = e, i.length > 0) for (var { requestOptions: r } of i) this.retriableRequest(r); } unload() { for (var { requestOptions: e } of (this.Jr && (clearTimeout(this.Jr), this.Jr = void 0), this.Vr = !1, C$2(t) || (this.Ur && (t.removeEventListener("online", this.Ur), this.Ur = void 0), this.Gr && (t.removeEventListener("offline", this.Gr), this.Gr = void 0)), this.Lr)) try { this._instance._send_request(f$1({}, e, { transport: "sendBeacon" })); } catch (t) { Ie.error(t); } this.Lr = []; } }; var an$1 = class { constructor(t) { this.Kr = () => { var t, e, i, r; this.Qr || (this.Qr = {}); var s = this.scrollElement(), n = this.scrollY(), o = s ? Math.max(0, s.scrollHeight - s.clientHeight) : 0, a = n + ((null == s ? void 0 : s.clientHeight) || 0), l = (null == s ? void 0 : s.scrollHeight) || 0; this.Qr.lastScrollY = Math.ceil(n), this.Qr.maxScrollY = Math.max(n, null !== (t = this.Qr.maxScrollY) && void 0 !== t ? t : 0), this.Qr.maxScrollHeight = Math.max(o, null !== (e = this.Qr.maxScrollHeight) && void 0 !== e ? e : 0), this.Qr.lastContentY = a, this.Qr.maxContentY = Math.max(a, null !== (i = this.Qr.maxContentY) && void 0 !== i ? i : 0), this.Qr.maxContentHeight = Math.max(l, null !== (r = this.Qr.maxContentHeight) && void 0 !== r ? r : 0); }, this._instance = t; } get ei() { return this._instance.config.scroll_root_selector; } getContext() { return this.Qr; } resetContext() { var t = this.Qr; return setTimeout(this.Kr, 0), t; } startMeasuringScrollPosition() { Xi(t, "scroll", this.Kr, { capture: !0 }), Xi(t, "scrollend", this.Kr, { capture: !0 }), Xi(t, "resize", this.Kr); } scrollElement() { if (!this.ei) return null == t ? void 0 : t.document.documentElement; for (var i of R$2(this.ei) ? this.ei : [this.ei]) { var r = null == t ? void 0 : t.document.querySelector(i); if (r) return r; } } scrollY() { if (this.ei) { var e = this.scrollElement(); return e && e.scrollTop || 0; } return t && (t.scrollY || t.pageYOffset || t.document.documentElement.scrollTop) || 0; } scrollX() { if (this.ei) { var e = this.scrollElement(); return e && e.scrollLeft || 0; } return t && (t.scrollX || t.pageXOffset || t.document.documentElement.scrollLeft) || 0; } }; var ln$1 = (t) => Hr$1(null == t ? void 0 : t.config.mask_personal_data_properties, null == t ? void 0 : t.config.custom_personal_data_properties); var un$1 = class { constructor(t, e, i, r) { this.ti = (t) => { var e = this.ri(); if (!e || e.sessionId !== t) { var i = { sessionId: t, props: this.ii(this._instance) }; this.ni.register({ [bi$1]: i }); } }, this._instance = t, this.si = e, this.ni = i, this.ii = r || ln$1, this.si.onSessionId(this.ti); } ri() { return this.ni.props[bi$1]; } getSetOnceProps() { var t, e = null == (t = this.ri()) ? void 0 : t.props; return e ? "r" in e ? qr$1(e) : { $referring_domain: e.referringDomain, $pathname: e.initialPathName, utm_source: e.utm_source, utm_campaign: e.utm_campaign, utm_medium: e.utm_medium, utm_content: e.utm_content, utm_term: e.utm_term } : {}; } getSessionProps() { var t = {}; return Hi(Yi(this.getSetOnceProps()), ((e, i) => { "$current_url" === i && (i = "url"), t["$session_entry_" + E$2(i)] = e; })), t; } }; var hn$1 = class { constructor() { this.oi = {}; } on(t, e) { return this.oi[t] || (this.oi[t] = []), this.oi[t].push(e), () => { this.oi[t] = this.oi[t].filter(((t) => t !== e)); }; } emit(t, e) { for (var i of this.oi[t] || []) i(e); for (var r of this.oi["*"] || []) r(t, e); } }; var dn$1 = Ce$2("[SessionId]"); var vn$1 = class { on(t, e) { return this.ai.on(t, e); } constructor(t, e, i) { var r; if (this.li = [], this.ui = void 0, this.ai = new hn$1(), this.hi = (t, e) => !(!U$1(t) || !U$1(e)) && Math.abs(t - e) > this.sessionTimeoutMs, !t.persistence) throw new Error("SessionIdManager requires a PostHogPersistence instance"); if (t.config.cookieless_mode === Ci$1) throw new Error("SessionIdManager cannot be used with cookieless_mode=\"always\""); this.Bt = t.config, this.ni = t.persistence, this.ci = void 0, this.di = void 0, this._sessionStartTimestamp = null, this._sessionActivityTimestamp = null, this.vi = e || sr$1, this.fi = i || sr$1; var s = this.Bt.persistence_name || this.Bt.token; if (this._sessionTimeoutMs = 1e3 * Y$1(this.Bt.session_idle_timeout_seconds || 1800, 60, 36e3, dn$1.createLogger("session_idle_timeout_seconds"), 1800), t.register({ $configured_session_timeout_ms: this._sessionTimeoutMs }), this.pi(), this.gi = "ph_" + s + "_window_id", this.mi = "ph_" + s + "_primary_window_exists", this.yi()) { var n = fr$1.Z(this.gi), o = fr$1.Z(this.mi); n && !o ? this.ci = n : fr$1.F(this.gi), fr$1.M(this.mi, !0); } if (null != (r = this.Bt.bootstrap) && r.sessionID) try { var a = ((t) => { var e = this.Bt.bootstrap.sessionID.replace(/-/g, ""); if (32 !== e.length) throw new Error("Not a valid UUID"); if ("7" !== e[12]) throw new Error("Not a UUIDv7"); return parseInt(e.substring(0, 12), 16); })(); this.bi(this.Bt.bootstrap.sessionID, (/* @__PURE__ */ new Date()).getTime(), a); } catch (t) { dn$1.error("Invalid sessionID in bootstrap", t); } this.wi(); } get sessionTimeoutMs() { return this._sessionTimeoutMs; } onSessionId(t) { return C$2(this.li) && (this.li = []), this.li.push(t), this.di && t(this.di, this.ci), () => { this.li = this.li.filter(((e) => e !== t)); }; } yi() { return "memory" !== this.Bt.persistence && !this.ni._r && fr$1.R(); } Ii(t) { t !== this.ci && (this.ci = t, this.yi() && fr$1.M(this.gi, t)); } Ci() { return this.ci ? this.ci : this.yi() ? fr$1.Z(this.gi) : null; } bi(t, e, i) { t === this.di && e === this._sessionActivityTimestamp && i === this._sessionStartTimestamp || (this._sessionStartTimestamp = i, this._sessionActivityTimestamp = e, this.di = t, this.ni.register({ [Ze$2]: [ e, t, i ] })); } Si() { var t = this.ni.props[Ze$2]; return R$2(t) && 2 === t.length && t.push(t[0]), t || [ 0, null, 0 ]; } resetSessionId() { this.bi(null, null, null); } destroy() { clearTimeout(this.xi), this.xi = void 0, this.ui && t && (t.removeEventListener(Li$1, this.ui, { capture: !1 }), this.ui = void 0), this.li = []; } wi() { this.ui = () => { this.yi() && fr$1.F(this.mi); }, Xi(t, Li$1, this.ui, { capture: !1 }); } checkAndGetSessionAndWindowId(t, e) { if (void 0 === t && (t = !1), void 0 === e && (e = null), this.Bt.cookieless_mode === Ci$1) throw new Error("checkAndGetSessionAndWindowId should not be called with cookieless_mode=\"always\""); var i = e || (/* @__PURE__ */ new Date()).getTime(), [r, s, n] = this.Si(), o = this.Ci(), a = U$1(n) && Math.abs(i - n) > 864e5, l = !1, u = !s, h = !u && !t && this.hi(i, r); u || h || a ? (s = this.vi(), o = this.fi(), dn$1.info("new session ID generated", { sessionId: s, windowId: o, changeReason: { noSessionId: u, activityTimeout: h, sessionPastMaximumLength: a } }), n = i, l = !0) : o || (o = this.fi(), l = !0); var d = U$1(r) && t && !a ? r : i, v = U$1(n) ? n : (/* @__PURE__ */ new Date()).getTime(); return this.Ii(o), this.bi(s, d, v), t || this.pi(), l && this.li.forEach(((t) => t(s, o, l ? { noSessionId: u, activityTimeout: h, sessionPastMaximumLength: a } : void 0))), { sessionId: s, windowId: o, sessionStartTimestamp: v, changeReason: l ? { noSessionId: u, activityTimeout: h, sessionPastMaximumLength: a } : void 0, lastActivityTimestamp: r }; } pi() { clearTimeout(this.xi), this.xi = setTimeout((() => { var [t] = this.Si(); if (this.hi((/* @__PURE__ */ new Date()).getTime(), t)) { var e = this.di; this.resetSessionId(), this.ai.emit("forcedIdleReset", { idleSessionId: e }); } }), 1.1 * this.sessionTimeoutMs); } }; var cn$1 = function(t, e) { if (!t) return !1; var i = t.userAgent; if (i && b$2(i, e)) return !0; try { var r = null == t ? void 0 : t.userAgentData; if (null != r && r.brands && r.brands.some(((t) => b$2(null == t ? void 0 : t.brand, e)))) return !0; } catch (t) {} return !!t.webdriver; }, pn$1 = function(t, e) { if (!function(t) { try { new RegExp(t); } catch (t) { return !1; } return !0; }(e)) return !1; try { return new RegExp(e).test(t); } catch (t) { return !1; } }; function fn$1(t, e, i) { return Xs$1({ distinct_id: t, userPropertiesToSet: e, userPropertiesToSetOnce: i }); } var _n$1 = { exact: (t, e) => e.some(((e) => t.some(((t) => e === t)))), is_not: (t, e) => e.every(((e) => t.every(((t) => e !== t)))), regex: (t, e) => e.some(((e) => t.some(((t) => pn$1(e, t))))), not_regex: (t, e) => e.every(((e) => t.every(((t) => !pn$1(e, t))))), icontains: (t, e) => e.map(gn).some(((e) => t.map(gn).some(((t) => e.includes(t))))), not_icontains: (t, e) => e.map(gn).every(((e) => t.map(gn).every(((t) => !e.includes(t))))), gt: (t, e) => e.some(((e) => { var i = parseFloat(e); return !isNaN(i) && t.some(((t) => i > parseFloat(t))); })), lt: (t, e) => e.some(((e) => { var i = parseFloat(e); return !isNaN(i) && t.some(((t) => i < parseFloat(t))); })) }, gn = (t) => t.toLowerCase(); function mn$1(t, e) { return !t || Object.entries(t).every(((t) => { var [i, r] = t, s = null == e ? void 0 : e[i]; if (C$2(s) || M(s)) return !1; var n = [String(s)], o = _n$1[r.operator]; return !!o && o(r.values, n); })); } var bn$1 = "custom", yn = "i.posthog.com", wn$1 = /^\/static\//; var xn = class { constructor(t) { this.ki = {}, this.instance = t; } get apiHost() { var t = this.instance.config.api_host.trim().replace(/\/$/, ""); return "https://app.posthog.com" === t ? "https://us.i.posthog.com" : t; } get flagsApiHost() { var t = this.instance.config.flags_api_host; return t ? t.trim().replace(/\/$/, "") : this.apiHost; } get uiHost() { var t, e = null == (t = this.instance.config.ui_host) ? void 0 : t.replace(/\/$/, ""); return e || (e = this.apiHost.replace("." + yn, ".posthog.com")), "https://app.posthog.com" === e ? "https://us.posthog.com" : e; } get region() { return this.ki[this.apiHost] || (this.ki[this.apiHost] = /https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost) ? "us" : /https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost) ? "eu" : bn$1), this.ki[this.apiHost]; } Ti(t) { var e = this.instance.config.__preview_external_dependency_versioned_paths; if ("string" == typeof e && wn$1.test(t)) return e.trim().replace(/\/$/, "") || void 0; } endpointFor(t, e) { if (void 0 === e && (e = ""), e && (e = "/" === e[0] ? e : "/" + e), "ui" === t) return this.uiHost + e; if ("flags" === t) return this.flagsApiHost + e; if ("assets" === t) { var i = this.Ti(e); if (i) return "" + i + e; } if (this.region === bn$1) return this.apiHost + e; var r = yn + e; switch (t) { case "assets": return "https://" + this.region + "-assets." + r; case "api": return "https://" + this.region + "." + r; } } }; var En$1 = Ce$2("[Surveys]"), Sn$1 = "seenSurvey_", $n$1 = [ Zr.Popover, Zr.Widget, Zr.API ], Tn$1 = { ignoreConditions: !1, ignoreDelay: !1, displayType: ns.Popover }, kn$1 = Ce$2("[PostHog ExternalIntegrations]"), Rn = { intercom: "intercom-integration", crispChat: "crisp-chat-integration" }; var Pn$1 = class { constructor(t) { this._instance = t; } ur(t, e) { var i; null == (i = h$3.__PosthogExtensions__) || null == i.loadExternalDependency || i.loadExternalDependency(this._instance, t, ((t) => { if (t) return kn$1.error("failed to load script", t); e(); })); } startIfEnabledOrStop() { var t = this, e = function(e) { var i, s, n; !r || null != (i = h$3.__PosthogExtensions__) && null != (i = i.integrations) && i[e] || t.ur(Rn[e], (() => { var i; null == (i = h$3.__PosthogExtensions__) || null == (i = i.integrations) || null == (i = i[e]) || i.start(t._instance); })), !r && null != (s = h$3.__PosthogExtensions__) && null != (s = s.integrations) && s[e] && (null == (n = h$3.__PosthogExtensions__) || null == (n = n.integrations) || null == (n = n[e]) || n.stop()); }; for (var [i, r] of Object.entries(null !== (s = this._instance.config.integrations) && void 0 !== s ? s : {})) { var s; e(i); } } }; var On, In$1 = {}, Cn$1 = 0, Fn = () => {}, An$1 = "Consent opt in/out is not valid with cookieless_mode=\"always\" and will be ignored", Mn$1 = "Surveys module not available", Dn$1 = "sanitize_properties is deprecated. Use before_send instead", Ln = "Invalid value for property_denylist config: ", Un = "posthog", Nn$1 = !Gs$1 && -1 === (null == u$1 ? void 0 : u$1.indexOf("MSIE")) && -1 === (null == u$1 ? void 0 : u$1.indexOf("Mozilla")), jn$1 = (e) => { var i; return f$1({ api_host: "https://us.i.posthog.com", flags_api_host: null, ui_host: null, token: "", autocapture: !0, cross_subdomain_cookie: Ki(null == r$1 ? void 0 : r$1.location), persistence: "localStorage+cookie", persistence_name: "", cookie_persisted_properties: [], loaded: Fn, save_campaign_params: !0, custom_campaign_params: [], custom_blocked_useragents: [], save_referrer: !0, capture_pageleave: "if_capture_pageview", defaults: null != e ? e : "unset", __preview_deferred_init_extensions: !1, __preview_external_dependency_versioned_paths: !1, debug: s$1 && F$1(null == s$1 ? void 0 : s$1.search) && -1 !== s$1.search.indexOf("__posthog_debug=true") || !1, cookie_expiration: 365, upgrade: !1, disable_session_recording: !1, disable_persistence: !1, disable_web_experiments: !0, disable_surveys: !1, disable_surveys_automatic_display: !1, disable_conversations: !1, disable_product_tours: !1, disable_external_dependency_loading: !1, enable_recording_console_log: void 0, secure_cookie: "https:" === (null == t || null == (i = t.location) ? void 0 : i.protocol), ip: !1, opt_out_capturing_by_default: !1, opt_out_persistence_by_default: !1, opt_out_useragent_filter: !1, opt_out_capturing_persistence_type: "localStorage", consent_persistence_name: null, opt_out_capturing_cookie_prefix: null, opt_in_site_apps: !1, property_denylist: [], respect_dnt: !1, sanitize_properties: null, request_headers: {}, request_batching: !0, properties_string_max_length: 65535, mask_all_element_attributes: !1, mask_all_text: !1, mask_personal_data_properties: !1, custom_personal_data_properties: [], advanced_disable_flags: !1, advanced_disable_decide: !1, advanced_disable_feature_flags: !1, advanced_disable_feature_flags_on_first_load: !1, advanced_only_evaluate_survey_feature_flags: !1, advanced_feature_flags_dedup_per_session: !1, advanced_enable_surveys: !1, advanced_disable_toolbar_metrics: !1, feature_flag_request_timeout_ms: 3e3, surveys_request_timeout_ms: 1e4, on_request_error(t) { Ie.error("Bad HTTP status: " + t.statusCode + " " + t.text); }, get_device_id: (t) => t, capture_performance: void 0, name: "posthog", bootstrap: {}, disable_compression: !1, session_idle_timeout_seconds: 1800, person_profiles: Mi, before_send: void 0, request_queue_config: { flush_interval_ms: rn$1 }, error_tracking: {}, _onCapture: Fn, __preview_eager_load_replay: !1 }, ((t) => ({ rageclick: !t || "2025-11-30" > t || { content_ignorelist: !0 }, capture_pageview: !t || "2025-05-24" > t || "history_change", session_recording: t && t >= "2025-11-30" ? { strictMinimumDuration: !0 } : {}, external_scripts_inject_target: t && t >= "2026-01-30" ? "head" : "body", internal_or_test_user_hostname: t && t >= "2026-01-30" ? /^(localhost|127\.0\.0\.1)$/ : void 0 }))(e)); }, zn$1 = [ ["process_person", "person_profiles"], ["xhr_headers", "request_headers"], ["cookie_name", "persistence_name"], ["disable_cookie", "disable_persistence"], ["store_google", "save_campaign_params"], ["verbose", "debug"] ], Bn$1 = (t) => { var e = {}; for (var [i, r] of zn$1) C$2(t[i]) || (e[r] = t[i]); var s = qi({}, e, t); return R$2(t.property_blacklist) && (C$2(t.property_denylist) ? s.property_denylist = t.property_blacklist : R$2(t.property_denylist) ? s.property_denylist = [...t.property_blacklist, ...t.property_denylist] : Ie.error(Ln + t.property_denylist)), s; }; var Hn$1 = class { constructor() { this.__forceAllowLocalhost = !1; } get Ai() { return this.__forceAllowLocalhost; } set Ai(t) { Ie.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"), this.__forceAllowLocalhost = t; } }; var qn$1 = class qn$1 { Ei(t, e) { if (t) { var i = this.Ri.indexOf(t); -1 !== i && this.Ri.splice(i, 1); } return this.Ri.push(e), null == e.initialize || e.initialize(), e; } Ni() { return this.config.cookieless_mode === Ci$1 || this.config.cookieless_mode === Ii && this.consent.isRejected(); } get decideEndpointWasHit() { var t, e; return null !== (t = null == (e = this.featureFlags) ? void 0 : e.hasLoadedFlags) && void 0 !== t && t; } get flagsEndpointWasHit() { var t, e; return null !== (t = null == (e = this.featureFlags) ? void 0 : e.hasLoadedFlags) && void 0 !== t && t; } constructor() { var t; this.webPerformance = new Hn$1(), this.Mi = !1, this.version = v$1.LIB_VERSION, this.Fi = new hn$1(), this.Ri = [], this._calculate_event_properties = this.calculateEventProperties.bind(this), this.config = jn$1(), this.SentryIntegration = Sr$1, this.sentryIntegration = (t) => function(t, e) { var i = Er$1(t, e); return { name: xr$1, processEvent: (t) => i(t) }; }(this, t), this.__request_queue = [], this.__loaded = !1, this.analyticsDefaultEndpoint = "/e/", this.Oi = !1, this.Pi = null, this.Li = null, this.Di = null, this.scrollManager = new an$1(this), this.pageViewManager = new $r(this), this.rateLimiter = new hs(this), this.requestRouter = new xn(this), this.consent = new _r$1(this), this.externalIntegrations = new Pn$1(this); var e = null !== (t = qn$1.__defaultExtensionClasses) && void 0 !== t ? t : {}; this.featureFlags = e.featureFlags && new e.featureFlags(this), this.toolbar = e.toolbar && new e.toolbar(this), this.surveys = e.surveys && new e.surveys(this), this.conversations = e.conversations && new e.conversations(this), this.logs = e.logs && new e.logs(this), this.experiments = e.experiments && new e.experiments(this), this.exceptions = e.exceptions && new e.exceptions(this), this.people = { set: (t, e, i) => { var r = F$1(t) ? { [t]: e } : t; this.setPersonProperties(r), i?.({}); }, set_once: (t, e, i) => { var r = F$1(t) ? { [t]: e } : t; this.setPersonProperties(void 0, r), i?.({}); } }, this.on("eventCaptured", ((t) => Ie.info("send \"" + (null == t ? void 0 : t.event) + "\"", t))); } init(t, e, i) { if (i && i !== Un) { var r, s = null !== (r = In$1[i]) && void 0 !== r ? r : new qn$1(); return s._init(t, e, i), In$1[i] = s, In$1[Un][i] = s, s; } return this._init(t, e, i); } _init(e, i, r) { var s, n; if (void 0 === i && (i = {}), C$2(e) || A$2(e)) return Ie.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"), this; if (this.__loaded) return console.warn("[PostHog.js]", "You have already initialized PostHog! Re-initializing is a no-op"), this; this.__loaded = !0, this.config = {}, i.debug = this.Bi(i.debug), this.ji = i, this.$i = [], i.person_profiles ? this.Li = i.person_profiles : i.process_person && (this.Li = i.process_person), this.set_config(qi({}, jn$1(i.defaults), Bn$1(i), { name: r, token: e })), this.config.on_xhr_error && Ie.error("on_xhr_error is deprecated. Use on_request_error instead"), this.compression = i.disable_compression ? void 0 : ps.GZipJS; var o = this.qi(); this.persistence = new Yr$1(this.config, o), this.sessionPersistence = "sessionStorage" === this.config.persistence || "memory" === this.config.persistence ? this.persistence : new Yr$1(f$1({}, this.config, { persistence: "sessionStorage" }), o); var a = f$1({}, this.persistence.props), l = f$1({}, this.sessionPersistence.props); this.register({ $initialization_time: (/* @__PURE__ */ new Date()).toISOString() }), this.Zi = new sn$1(((t) => this.Vi(t)), this.config.request_queue_config), this.Hi = new on(this), this.__request_queue = []; var u = this.Ni(); if (u || (this.sessionManager = new vn$1(this), this.sessionPropsManager = new un$1(this, this.sessionManager, this.persistence)), this.config.__preview_deferred_init_extensions ? (Ie.info("Deferring extension initialization to improve startup performance"), setTimeout((() => { this.zi(u); }), 0)) : (Ie.info("Initializing extensions synchronously"), this.zi(u)), v$1.DEBUG = v$1.DEBUG || this.config.debug, v$1.DEBUG && Ie.info("Starting in debug mode", { this: this, config: i, thisC: f$1({}, this.config), p: a, s: l }), !this.config.identity_distinct_id || null != (s = i.bootstrap) && s.distinctID || (i.bootstrap = f$1({}, i.bootstrap, { distinctID: this.config.identity_distinct_id, isIdentifiedID: !0 })), void 0 !== (null == (n = i.bootstrap) ? void 0 : n.distinctID)) { var h = i.bootstrap.distinctID, d = this.get_distinct_id(), c = this.persistence.get_property(mi$1); if (i.bootstrap.isIdentifiedID && null != d && d !== h && c === Fi) this.identify(h); else if (i.bootstrap.isIdentifiedID && null != d && d !== h && c === Ai) Ie.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users."); else { var p = this.config.get_device_id(sr$1()), _ = i.bootstrap.isIdentifiedID ? p : h; this.persistence.set_property(mi$1, i.bootstrap.isIdentifiedID ? Ai : Fi), this.register({ distinct_id: h, $device_id: _ }); } } if (u) this.register_once({ distinct_id: Ti$1, $device_id: null }, ""); else if (!this.get_distinct_id()) { var g = this.config.get_device_id(sr$1()); this.register_once({ distinct_id: g, $device_id: g }, ""), this.persistence.set_property(mi$1, Fi); } return Xi(t, "onpagehide" in self ? "pagehide" : "unload", this._handle_unload.bind(this), { passive: !1 }), i.segment ? function(t, e) { var i = t.config.segment; if (!i) return e(); (function(t, e) { var i = t.config.segment; if (!i) return e(); var r = (i) => { var r = () => i.anonymousId() || sr$1(); t.config.get_device_id = r, i.id() && (t.register({ distinct_id: i.id(), $device_id: r() }), t.persistence.set_property(mi$1, Ai)), e(); }, s = i.user(); "then" in s && P$1(s.then) ? s.then(r) : r(s); })(t, (() => { i.register(((t) => { Promise && Promise.resolve || wr$1.warn("This browser does not have Promise support, and can not use the segment integration"); var e = (e, i) => { if (!i) return e; e.event.userId || e.event.anonymousId === t.get_distinct_id() || (wr$1.info("No userId set, resetting PostHog"), t.reset()), e.event.userId && e.event.userId !== t.get_distinct_id() && (wr$1.info("UserId set, identifying with PostHog"), t.identify(e.event.userId)); var r = t.calculateEventProperties(i, e.event.properties); return e.event.properties = Object.assign({}, r, e.event.properties), e; }; return { name: "PostHog JS", type: "enrichment", version: "1.0.0", isLoaded: () => !0, load: () => Promise.resolve(), track: (t) => e(t, t.event.event), page: (t) => e(t, Ui), identify: (t) => e(t, ji), screen: (t) => e(t, "$screen") }; })(t)).then((() => { e(); })); })); }(this, (() => this.Ui())) : this.Ui(), P$1(this.config._onCapture) && this.config._onCapture !== Fn && (Ie.warn("onCapture is deprecated. Please use `before_send` instead"), this.on("eventCaptured", ((t) => this.config._onCapture(t.event, t)))), this.config.ip && Ie.warn("The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or \"Discard IP data\" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information."), this; } zi(t) { var e, i, r, s, n, o, a, l = performance.now(), u = f$1({}, qn$1.__defaultExtensionClasses, this.config.__extensionClasses), h = []; u.featureFlags && this.Ri.push(this.featureFlags = null !== (e = this.featureFlags) && void 0 !== e ? e : new u.featureFlags(this)), u.exceptions && this.Ri.push(this.exceptions = null !== (i = this.exceptions) && void 0 !== i ? i : new u.exceptions(this)), u.historyAutocapture && this.Ri.push(this.historyAutocapture = new u.historyAutocapture(this)), u.tracingHeaders && this.Ri.push(new u.tracingHeaders(this)), u.siteApps && this.Ri.push(this.siteApps = new u.siteApps(this)), u.sessionRecording && !t && this.Ri.push(this.sessionRecording = new u.sessionRecording(this)), this.config.disable_scroll_properties || h.push((() => { this.scrollManager.startMeasuringScrollPosition(); })), u.autocapture && this.Ri.push(this.autocapture = new u.autocapture(this)), u.surveys && this.Ri.push(this.surveys = null !== (r = this.surveys) && void 0 !== r ? r : new u.surveys(this)), u.logs && this.Ri.push(this.logs = null !== (s = this.logs) && void 0 !== s ? s : new u.logs(this)), u.conversations && this.Ri.push(this.conversations = null !== (n = this.conversations) && void 0 !== n ? n : new u.conversations(this)), u.productTours && this.Ri.push(this.productTours = new u.productTours(this)), u.heatmaps && this.Ri.push(this.heatmaps = new u.heatmaps(this)), u.webVitalsAutocapture && this.Ri.push(this.webVitalsAutocapture = new u.webVitalsAutocapture(this)), u.exceptionObserver && this.Ri.push(this.exceptionObserver = new u.exceptionObserver(this)), u.deadClicksAutocapture && this.Ri.push(this.deadClicksAutocapture = new u.deadClicksAutocapture(this, br$1)), u.toolbar && this.Ri.push(this.toolbar = null !== (o = this.toolbar) && void 0 !== o ? o : new u.toolbar(this)), u.experiments && this.Ri.push(this.experiments = null !== (a = this.experiments) && void 0 !== a ? a : new u.experiments(this)), this.Ri.forEach(((t) => { t.initialize && h.push((() => { null == t.initialize || t.initialize(); })); })), h.push((() => { if (this.Yi) { var t = this.Yi; this.Yi = void 0, this.Nr(t); } })), this.Gi(h, l); } Gi(t, e) { for (; t.length > 0;) { if (this.config.__preview_deferred_init_extensions && performance.now() - e >= 30 && t.length > 0) return void setTimeout((() => { this.Gi(t, e); }), 0); var i = t.shift(); if (i) try { i(); } catch (t) { Ie.error("Error initializing extension:", t); } } var r = Math.round(performance.now() - e); this.register_for_session({ [ki$1]: this.config.__preview_deferred_init_extensions ? "deferred" : "synchronous", [Ri]: r }), this.config.__preview_deferred_init_extensions && Ie.info("PostHog extensions initialized (" + r + "ms)"); } Nr(t) { var e; if (!r$1 || !r$1.body) return Ie.info("document not ready yet, trying again in 500 milliseconds..."), void setTimeout((() => { this.Nr(t); }), 500); this.config.__preview_deferred_init_extensions && (this.Yi = t), this.Wi = t, this.compression = void 0, t.supportedCompression && !this.config.disable_compression && (this.compression = w$1(t.supportedCompression, ps.GZipJS) ? ps.GZipJS : w$1(t.supportedCompression, ps.Base64) ? ps.Base64 : void 0), null != (e = t.analytics) && e.endpoint && (this.analyticsDefaultEndpoint = t.analytics.endpoint), this.set_config({ person_profiles: this.Li ? this.Li : Mi }), this.Ri.forEach(((e) => null == e.onRemoteConfig ? void 0 : e.onRemoteConfig(t))); } Ui() { try { this.config.loaded(this); } catch (t) { Ie.critical("`loaded` function failed", t); } if (this.Xi(), this.config.internal_or_test_user_hostname && null != s$1 && s$1.hostname) { var t = s$1.hostname, e = this.config.internal_or_test_user_hostname; ("string" == typeof e ? t === e : e.test(t)) && this.setInternalOrTestUser(); } this.config.capture_pageview && setTimeout((() => { (this.consent.isOptedIn() || this.Ni()) && this.Ji(); }), 1), this.Ki = new vs(this), this.Ki.load(); } Xi() { var t; this.is_capturing() && this.config.request_batching && (null == (t = this.Zi) || t.enable()); } _dom_loaded() { this.is_capturing() && Bi(this.__request_queue, ((t) => this.Vi(t))), this.__request_queue = [], this.Xi(); } _handle_unload() { var t, e, i, r; null == (t = this.surveys) || t.handlePageUnload(), this.config.request_batching ? (this.Qi() && this.capture(Ni$1), null == (e = this.logs) || e.flushLogs("sendBeacon"), null == (i = this.Zi) || i.unload(), null == (r = this.Hi) || r.unload()) : this.Qi() && this.capture(Ni$1, null, { transport: "sendBeacon" }); } _send_request(t) { this.__loaded && (Nn$1 ? this.__request_queue.push(t) : this.rateLimiter.isServerRateLimited(t.batchKey) || (t.transport = t.transport || this.config.api_transport, t.url = Ks(t.url, { ip: this.config.ip ? 1 : 0 }), t.headers = f$1({}, this.config.request_headers, t.headers), t.compression = "best-available" === t.compression ? this.compression : t.compression, t.disableXHRCredentials = this.config.__preview_disable_xhr_credentials, this.config.__preview_disable_beacon && (t.disableTransport = ["sendBeacon"]), t.fetchOptions = t.fetchOptions || this.config.fetch_options, ((t) => { var e, i, r, s = f$1({}, t); s.timeout = s.timeout || 6e4, s.url = tn(s.url, s.compression); var n = null !== (e = s.transport) && void 0 !== e ? e : "fetch", o = en.filter(((t) => !s.disableTransport || !t.transport || !s.disableTransport.includes(t.transport))), a = null !== (i = null == (r = function(t, e) { for (var i = 0; t.length > i; i++) if (t[i].transport === n) return t[i]; }(o)) ? void 0 : r.method) && void 0 !== i ? i : o[0].method; if (!a) throw new Error("No available transport method"); "sendBeacon" !== n && s.data && s.compression === ps.GZipJS && l$1 && !Js ? Zs$1(s).then(((t) => { a(t); })).catch(((e) => { if (((t) => !(!t || "object" != typeof t) && "NotReadableError" === ("name" in t ? String(t.name) : ""))(e)) return Js = !0, void a(f$1({}, s, { compression: void 0, url: tn(t.url, void 0) })); a(s); })) : a(s); })(f$1({}, t, { callback: (e) => { var i, r; this.rateLimiter.checkForLimiting(e), 400 > e.statusCode || null == (i = (r = this.config).on_request_error) || i.call(r, e), null == t.callback || t.callback(e); } })))); } Vi(t) { this.Hi ? this.Hi.retriableRequest(t) : this._send_request(t); } _execute_array(t) { Cn$1++; try { var e, i = [], r = [], s = []; Bi(t, ((t) => { t && (R$2(e = t[0]) ? s.push(t) : P$1(t) ? t.call(this) : R$2(t) && "alias" === e ? i.push(t) : R$2(t) && -1 !== e.indexOf("capture") && P$1(this[e]) ? s.push(t) : r.push(t)); })); var n = function(t, e) { Bi(t, (function(t) { if (R$2(t[0])) { var i = e; Hi(t, (function(t) { i = i[t[0]].apply(i, t.slice(1)); })); } else e[t[0]].apply(e, t.slice(1)); })); }; n(i, this), n(r, this), n(s, this); } finally { Cn$1--; } } push(t) { if (Cn$1 > 0 && R$2(t) && F$1(t[0])) { var e = qn$1.prototype[t[0]]; P$1(e) && e.apply(this, t.slice(1)); } else this._execute_array([t]); } capture(t, e, i) { var r, s, n, o, a; if (this.__loaded && this.persistence && this.sessionPersistence && this.Zi) { if (this.is_capturing()) if (!C$2(t) && F$1(t)) { var l = !this.config.opt_out_useragent_filter && this._is_bot(); if (!l || this.config.__preview_capture_bot_pageviews) { var u = null != i && i.skip_client_rate_limiting ? void 0 : this.rateLimiter.clientRateLimitContext(); if (null == u || !u.isRateLimited) { null != e && e.$current_url && !F$1(null == e ? void 0 : e.$current_url) && (Ie.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."), null == e || delete e.$current_url), "$exception" !== t || null != i && i.en || Ie.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."), this.sessionPersistence.update_search_keyword(), this.config.save_campaign_params && this.sessionPersistence.update_campaign_params(), this.config.save_referrer && this.sessionPersistence.update_referrer_info(), (this.config.save_campaign_params || this.config.save_referrer) && this.persistence.set_initial_person_info(); var h = /* @__PURE__ */ new Date(), d = (null == i ? void 0 : i.timestamp) || h, v = sr$1(), c = { uuid: v, event: t, properties: this.calculateEventProperties(t, e || {}, d, v) }; t === Ui && this.config.__preview_capture_bot_pageviews && l && (c.event = "$bot_pageview", c.properties.$browser_type = "bot"), u && (c.properties.$lib_rate_limit_remaining_tokens = u.remainingTokens), null != i && i.$set && (c.$set = null == i ? void 0 : i.$set); var p, _, g, m = this.tn(null == i ? void 0 : i.$set_once, t !== zi, t === ji); if (m && (c.$set_once = m), null != i && i._noTruncate || (s = this.config.properties_string_max_length, n = c, o = (t) => F$1(t) ? t.slice(0, s) : t, a = /* @__PURE__ */ new Set(), c = function t(e, i) { return e !== Object(e) ? o ? o(e) : e : a.has(e) ? void 0 : (a.add(e), R$2(e) ? (r = [], Bi(e, ((e) => { r.push(t(e)); }))) : (r = {}, Hi(e, ((e, i) => { a.has(e) || (r[i] = t(e, i)); }))), r); var r; }(n)), c.timestamp = d, C$2(null == i ? void 0 : i.timestamp) || (c.properties.$event_time_override_provided = !0, c.properties.$event_time_override_system_time = h), t === rs$1.DISMISSED || t === rs$1.SENT) { var b = null == e ? void 0 : e[ss.SURVEY_ID], y = null == e ? void 0 : e[ss.SURVEY_ITERATION]; ((t) => { try { var e = ((t) => ((t, e) => { var i = "" + Sn$1 + e.id; return e.current_iteration && e.current_iteration > 0 && (i = "" + Sn$1 + e.id + "_" + e.current_iteration), i; })(0, t))(t); if (localStorage.getItem(e)) return; localStorage.setItem(e, "true"); } catch (t) { En$1.error("Failed to persist survey seen state", t); } })({ id: b, current_iteration: y }), c.$set = f$1({}, c.$set, { [(p = { id: b, current_iteration: y }, _ = t === rs$1.SENT ? "responded" : "dismissed", g = "$survey_" + _ + "/" + p.id, p.current_iteration && p.current_iteration > 0 && (g = "$survey_" + _ + "/" + p.id + "/" + p.current_iteration), g)]: !0 }); } else t === rs$1.SHOWN && (c.$set = f$1({}, c.$set, { [ss.SURVEY_LAST_SEEN_DATE]: (/* @__PURE__ */ new Date()).toISOString() })); if (t === as.SHOWN) { var w = null == e ? void 0 : e[ls$1.TOUR_TYPE]; w && (c.$set = f$1({}, c.$set, { [ls$1.TOUR_LAST_SEEN_DATE + "/" + w]: (/* @__PURE__ */ new Date()).toISOString() })); } var x = f$1({}, c.properties.$set, c.$set); if (I(x) || this.setPersonPropertiesForFlags(x), !D$1(this.config.before_send)) { var E = this.rn(c); if (!E) return; c = E; } this.Fi.emit("eventCaptured", c); var S = { method: "POST", url: null !== (r = null == i ? void 0 : i._url) && void 0 !== r ? r : this.requestRouter.endpointFor("api", this.analyticsDefaultEndpoint), data: c, compression: "best-available", batchKey: null == i ? void 0 : i._batchKey }; return !this.config.request_batching || i && (null == i || !i._batchKey) || null != i && i.send_instantly ? this.Vi(S) : this.Zi.enqueue(S), c; } Ie.critical("This capture call is ignored due to client rate limiting."); } } else Ie.error("No event name provided to posthog.capture"); } else Ie.uninitializedWarning("posthog.capture"); } _addCaptureHook(t) { return this.on("eventCaptured", ((e) => t(e.event, e))); } calculateEventProperties(e, i, n, o, a) { if (n = n || /* @__PURE__ */ new Date(), !this.persistence || !this.sessionPersistence) return i; var l = a ? void 0 : this.persistence.remove_event_timer(e), h = f$1({}, i); if (h.token = this.config.token, h.$config_defaults = this.config.defaults, this.Ni() && (h.$cookieless_mode = !0), "$snapshot" === e) { var d = f$1({}, this.persistence.properties(), this.sessionPersistence.properties()); return h.distinct_id = d.distinct_id, (!F$1(h.distinct_id) && !L$1(h.distinct_id) || A$2(h.distinct_id)) && Ie.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"), h; } var c, p = function(e, i) { var r, n, o, a; if (!u$1) return {}; var l, h, d, c, p, f, _, g, m = e ? [...Fr$1, ...i || []] : [], [b, y] = function(t) { for (var e = 0; Wt$1.length > e; e++) { var [i, r] = Wt$1[e], s = i.exec(t), n = s && (P$1(r) ? r(s, t) : r); if (n) return n; } return ["", ""]; }(u$1); return qi(Yi({ $os: b, $os_version: y, $browser: Ht$1(u$1, navigator.vendor), $device: Gt$1(u$1), $device_type: (h = u$1, d = { userAgentDataPlatform: null == (r = navigator) || null == (r = r.userAgentData) ? void 0 : r.platform, maxTouchPoints: null == (n = navigator) ? void 0 : n.maxTouchPoints, screenWidth: null == t || null == (o = t.screen) ? void 0 : o.width, screenHeight: null == t || null == (a = t.screen) ? void 0 : a.height, devicePixelRatio: null == t ? void 0 : t.devicePixelRatio }, g = Gt$1(h), g === st$2 || g === rt$2 || "Kobo" === g || "Kindle Fire" === g || g === At$1 ? it$1 : g === Et$1 || g === $t$1 || g === St$2 || g === It$1 ? "Console" : g === ot$2 ? "Wearable" : g ? Z$3 : "Android" === (null == d ? void 0 : d.userAgentDataPlatform) && (null !== (c = null == d ? void 0 : d.maxTouchPoints) && void 0 !== c ? c : 0) > 0 ? 600 > Math.min(null !== (p = null == d ? void 0 : d.screenWidth) && void 0 !== p ? p : 0, null !== (f = null == d ? void 0 : d.screenHeight) && void 0 !== f ? f : 0) / (null !== (_ = null == d ? void 0 : d.devicePixelRatio) && void 0 !== _ ? _ : 1) ? Z$3 : it$1 : "Desktop"), $timezone: Vr$1(), $timezone_offset: Wr$1() }), { $current_url: Or$1(null == s$1 ? void 0 : s$1.href, m, Mr$1), $host: null == s$1 ? void 0 : s$1.host, $pathname: null == s$1 ? void 0 : s$1.pathname, $raw_user_agent: u$1.length > 1e3 ? u$1.substring(0, 997) + "..." : u$1, $browser_version: Vt$1(u$1, navigator.vendor), $browser_language: jr$1(), $browser_language_prefix: (l = jr$1(), "string" == typeof l ? l.split("-")[0] : void 0), $screen_height: null == t ? void 0 : t.screen.height, $screen_width: null == t ? void 0 : t.screen.width, $viewport_height: null == t ? void 0 : t.innerHeight, $viewport_width: null == t ? void 0 : t.innerWidth, $lib: v$1.LIB_NAME, $lib_version: v$1.LIB_VERSION, $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10), $time: Date.now() / 1e3 }); }(this.config.mask_personal_data_properties, this.config.custom_personal_data_properties); if (this.sessionManager) { var { sessionId: _, windowId: g } = this.sessionManager.checkAndGetSessionAndWindowId(a, n.getTime()); h.$session_id = _, h.$window_id = g; } this.sessionPropsManager && qi(h, this.sessionPropsManager.getSessionProps()); try { var m; this.sessionRecording && qi(h, this.sessionRecording.sdkDebugProperties), h.$sdk_debug_retry_queue_size = null == (m = this.Hi) ? void 0 : m.length; } catch (t) { h.$sdk_debug_error_capturing_properties = String(t); } if (this.requestRouter.region === bn$1 && (h.$lib_custom_api_host = this.config.api_host), c = e !== Ui || a ? e !== Ni$1 || a ? this.pageViewManager.doEvent() : this.pageViewManager.doPageLeave(n) : this.pageViewManager.doPageView(n, o), h = qi(h, c), e === Ui && r$1 && (h.title = r$1.title), !C$2(l)) { var b = n.getTime() - l; h.$duration = parseFloat((b / 1e3).toFixed(3)); } u$1 && this.config.opt_out_useragent_filter && (h.$browser_type = this._is_bot() ? "bot" : "browser"), (h = qi({}, p, this.persistence.properties(), this.sessionPersistence.properties(), h)).$is_identified = this._isIdentified(), R$2(this.config.property_denylist) ? Hi(this.config.property_denylist, (function(t) { delete h[t]; })) : Ie.error(Ln + this.config.property_denylist + " or property_blacklist config: " + this.config.property_blacklist); var y = this.config.sanitize_properties; y && (Ie.error(Dn$1), h = y(h, e)); var w = this.nn(); return h.$process_person_profile = w, w && !a && this.sn("_calculate_event_properties"), h; } tn(t, e, i) { var r; if (void 0 === e && (e = !0), void 0 === i && (i = !1), !this.persistence || !this.nn()) return t; if (this.Mi && !i) return t; var o = qi({}, this.persistence.get_initial_props(), (null == (r = this.sessionPropsManager) ? void 0 : r.getSetOnceProps()) || {}, t || {}), a = this.config.sanitize_properties; return a && (Ie.error(Dn$1), o = a(o, "$set_once")), e && (this.Mi = !0), I(o) ? void 0 : o; } register(t, e) { var i; null == (i = this.persistence) || i.register(t, e); } register_once(t, e, i) { var r; null == (r = this.persistence) || r.register_once(t, e, i); } register_for_session(t) { var e; null == (e = this.sessionPersistence) || e.register(t); } unregister(t) { var e; null == (e = this.persistence) || e.unregister(t); } unregister_for_session(t) { var e; null == (e = this.sessionPersistence) || e.unregister(t); } an(t, e) { this.register({ [t]: e }); } getFeatureFlag(t, e) { var i; return null == (i = this.featureFlags) ? void 0 : i.getFeatureFlag(t, e); } getFeatureFlagPayload(t) { var e; return null == (e = this.featureFlags) ? void 0 : e.getFeatureFlagPayload(t); } getFeatureFlagResult(t, e) { var i; return null == (i = this.featureFlags) ? void 0 : i.getFeatureFlagResult(t, e); } isFeatureEnabled(t, e) { var i; return null == (i = this.featureFlags) ? void 0 : i.isFeatureEnabled(t, e); } reloadFeatureFlags() { var t; null == (t = this.featureFlags) || t.reloadFeatureFlags(); } updateFlags(t, e, i) { var r; null == (r = this.featureFlags) || r.updateFlags(t, e, i); } updateEarlyAccessFeatureEnrollment(t, e, i) { var r; null == (r = this.featureFlags) || r.updateEarlyAccessFeatureEnrollment(t, e, i); } getEarlyAccessFeatures(t, e, i) { var r; return void 0 === e && (e = !1), null == (r = this.featureFlags) ? void 0 : r.getEarlyAccessFeatures(t, e, i); } on(t, e) { return this.Fi.on(t, e); } onFeatureFlags(t) { return this.featureFlags ? this.featureFlags.onFeatureFlags(t) : (t([], {}, { errorsLoading: !0 }), () => {}); } onSurveysLoaded(t) { return this.surveys ? this.surveys.onSurveysLoaded(t) : (t([], { isLoaded: !1, error: Mn$1 }), () => {}); } onSessionId(t) { var e, i; return null !== (e = null == (i = this.sessionManager) ? void 0 : i.onSessionId(t)) && void 0 !== e ? e : () => {}; } getSurveys(t, e) { void 0 === e && (e = !1), this.surveys ? this.surveys.getSurveys(t, e) : t([], { isLoaded: !1, error: Mn$1 }); } getActiveMatchingSurveys(t, e) { void 0 === e && (e = !1), this.surveys ? this.surveys.getActiveMatchingSurveys(t, e) : t([], { isLoaded: !1, error: Mn$1 }); } renderSurvey(t, e) { var i; null == (i = this.surveys) || i.renderSurvey(t, e); } displaySurvey(t, e) { var i; void 0 === e && (e = Tn$1), null == (i = this.surveys) || i.displaySurvey(t, e); } cancelPendingSurvey(t) { var e; null == (e = this.surveys) || e.cancelPendingSurvey(t); } canRenderSurvey(t) { var e, i; return null !== (e = null == (i = this.surveys) ? void 0 : i.canRenderSurvey(t)) && void 0 !== e ? e : { visible: !1, disabledReason: Mn$1 }; } canRenderSurveyAsync(t, e) { var i, r; return void 0 === e && (e = !1), null !== (i = null == (r = this.surveys) ? void 0 : r.canRenderSurveyAsync(t, e)) && void 0 !== i ? i : Promise.resolve({ visible: !1, disabledReason: Mn$1 }); } ln(t) { return !t || A$2(t) ? (Ie.critical("Unique user id has not been set in posthog.identify"), !1) : t === Ti$1 ? (Ie.critical("The string \"" + t + "\" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value."), !1) : !["distinct_id", "distinctid"].includes(t.toLowerCase()) && !["undefined", "null"].includes(t.toLowerCase()) || (Ie.critical("The string \"" + t + "\" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string."), !1); } identify(t, e, i) { if (!this.__loaded || !this.persistence) return Ie.uninitializedWarning("posthog.identify"); if (L$1(t) && (t = t.toString(), Ie.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")), this.ln(t) && this.sn("posthog.identify")) { var r = this.get_distinct_id(); this.register({ $user_id: t }), this.get_property(De$1) || this.register_once({ $had_persisted_distinct_id: !0, $device_id: r }, ""), t !== r && t !== this.get_property(Le$1) && (this.unregister(Le$1), this.register({ distinct_id: t })); var s, n = (this.persistence.get_property(mi$1) || Fi) === Fi; t !== r && n ? (this.persistence.set_property(mi$1, Ai), this.setPersonPropertiesForFlags({ $set: e || {}, $set_once: i || {} }, !1), this.capture(ji, { distinct_id: t, $anon_distinct_id: r }, { $set: e || {}, $set_once: i || {} }), this.Di = fn$1(t, e, i), null == (s = this.featureFlags) || s.setAnonymousDistinctId(r)) : (e || i) && this.setPersonProperties(e, i), t !== r && (this.reloadFeatureFlags(), this.unregister(pi)); } } setPersonProperties(t, e) { if ((t || e) && this.sn("posthog.setPersonProperties")) { var i = fn$1(this.get_distinct_id(), t, e); this.Di !== i ? (this.setPersonPropertiesForFlags({ $set: t || {}, $set_once: e || {} }, !0), this.capture("$set", { $set: t || {}, $set_once: e || {} }), this.Di = i) : Ie.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored."); } } group(t, e, i) { if (t && e) { var r = this.getGroups(), s = r[t] !== e; if (s && this.resetGroupPropertiesForFlags(t), this.register({ $groups: f$1({}, r, { [t]: e }) }), s || i) { var n = { $group_type: t, $group_key: e }; i && (n.$group_set = i), this.capture(zi, n); } i && this.setGroupPropertiesForFlags({ [t]: i }), s && !i && this.reloadFeatureFlags(); } else Ie.error("posthog.group requires a group type and group key"); } resetGroups() { this.register({ $groups: {} }), this.resetGroupPropertiesForFlags(), this.reloadFeatureFlags(); } setPersonPropertiesForFlags(t, e) { var i; void 0 === e && (e = !0), null == (i = this.featureFlags) || i.setPersonPropertiesForFlags(t, e); } resetPersonPropertiesForFlags() { var t; null == (t = this.featureFlags) || t.resetPersonPropertiesForFlags(); } setGroupPropertiesForFlags(t, e) { var i; void 0 === e && (e = !0), this.sn("posthog.setGroupPropertiesForFlags") && (null == (i = this.featureFlags) || i.setGroupPropertiesForFlags(t, e)); } resetGroupPropertiesForFlags(t) { var e; null == (e = this.featureFlags) || e.resetGroupPropertiesForFlags(t); } reset(t) { var e, i, r, s, n, o, a, l; if (Ie.info("reset"), !this.__loaded) return Ie.uninitializedWarning("posthog.reset"); var u = this.get_property(De$1); if (this.consent.reset(), null == (e = this.persistence) || e.clear(), null == (i = this.sessionPersistence) || i.clear(), null == (r = this.surveys) || r.reset(), null == (s = this.Ki) || s.stop(), null == (n = this.featureFlags) || n.reset(), null == (o = this.conversations) || o.reset(), null == (a = this.persistence) || a.set_property(mi$1, Fi), null == (l = this.sessionManager) || l.resetSessionId(), this.Di = null, this.config.cookieless_mode === Ci$1) this.register_once({ distinct_id: Ti$1, $device_id: null }, ""); else { var h = this.config.get_device_id(sr$1()); this.register_once({ distinct_id: h, $device_id: t ? h : u }, ""); } this.register({ $last_posthog_reset: (/* @__PURE__ */ new Date()).toISOString() }, 1), delete this.config.identity_distinct_id, delete this.config.identity_hash, this.reloadFeatureFlags(); } setIdentity(t, e) { var i; this.config.identity_distinct_id = t, this.config.identity_hash = e, this.alias(t), null == (i = this.conversations) || i.un(); } clearIdentity() { var t; delete this.config.identity_distinct_id, delete this.config.identity_hash, null == (t = this.conversations) || t.hn(); } get_distinct_id() { return this.get_property("distinct_id"); } getGroups() { return this.get_property("$groups") || {}; } get_session_id() { var t, e; return null !== (t = null == (e = this.sessionManager) ? void 0 : e.checkAndGetSessionAndWindowId(!0).sessionId) && void 0 !== t ? t : ""; } get_session_replay_url(t) { if (!this.sessionManager) return ""; var { sessionId: e, sessionStartTimestamp: i } = this.sessionManager.checkAndGetSessionAndWindowId(!0), r = this.requestRouter.endpointFor("ui", "/project/" + this.config.token + "/replay/" + e); if (null != t && t.withTimestamp && i) { var s, n = null !== (s = t.timestampLookBack) && void 0 !== s ? s : 10; if (!i) return r; r += "?t=" + Math.max(Math.floor(((/* @__PURE__ */ new Date()).getTime() - i) / 1e3) - n, 0); } return r; } alias(t, e) { return t === this.get_property(Me$2) ? (Ie.critical("Attempting to create alias for existing People user - aborting."), -2) : this.sn("posthog.alias") ? (C$2(e) && (e = this.get_distinct_id()), t !== e ? (this.an(Le$1, t), this.capture("$create_alias", { alias: t, distinct_id: e })) : (Ie.warn("alias matches current distinct_id - skipping api call."), this.identify(t), -1)) : void 0; } set_config(t) { var e = f$1({}, this.config); if (O$1(t)) { var i, r, s, n, o, a, l, u, h, d; qi(this.config, Bn$1(t)); var c = this.qi(); null == (i = this.persistence) || i.update_config(this.config, e, c), this.sessionPersistence = "sessionStorage" === this.config.persistence || "memory" === this.config.persistence ? this.persistence : new Yr$1(f$1({}, this.config, { persistence: "sessionStorage" }), c); var p = this.Bi(this.config.debug); N(p) && (this.config.debug = p), N(this.config.debug) && (this.config.debug ? (v$1.DEBUG = !0, hr$1.R() && hr$1.M("ph_debug", !0), Ie.info("set_config", { config: t, oldConfig: e, newConfig: f$1({}, this.config) })) : (v$1.DEBUG = !1, hr$1.R() && hr$1.F("ph_debug"))), null == (r = this.exceptionObserver) || r.onConfigChange(), null == (s = this.exceptions) || s.onConfigChange(), null == (n = this.sessionRecording) || n.startIfEnabledOrStop(), null == (o = this.autocapture) || o.startIfEnabled(), null == (a = this.heatmaps) || a.startIfEnabled(), null == (l = this.exceptionObserver) || l.startIfEnabledOrStop(), null == (u = this.deadClicksAutocapture) || u.startIfEnabledOrStop(), null == (h = this.surveys) || h.loadIfEnabled(), this.cn(), null == (d = this.externalIntegrations) || d.startIfEnabledOrStop(); } } _overrideSDKInfo(t, e) { v$1.LIB_NAME = t, v$1.LIB_VERSION = e; } startSessionRecording(t) { var e, i, r, s, n, o = !0 === t, a = { sampling: o || !(null == t || !t.sampling), linked_flag: o || !(null == t || !t.linked_flag), url_trigger: o || !(null == t || !t.url_trigger), event_trigger: o || !(null == t || !t.event_trigger) }; Object.values(a).some(Boolean) && (null == (e = this.sessionManager) || e.checkAndGetSessionAndWindowId(), a.sampling && (null == (i = this.sessionRecording) || i.overrideSampling()), a.linked_flag && (null == (r = this.sessionRecording) || r.overrideLinkedFlag()), a.url_trigger && (null == (s = this.sessionRecording) || s.overrideTrigger("url")), a.event_trigger && (null == (n = this.sessionRecording) || n.overrideTrigger("event"))); this.set_config({ disable_session_recording: !1 }); } stopSessionRecording() { this.set_config({ disable_session_recording: !0 }); } sessionRecordingStarted() { var t; return !(null == (t = this.sessionRecording) || !t.started); } captureException(t, e) { if (this.exceptions) { var i = /* @__PURE__ */ new Error("PostHog syntheticException"), r = this.exceptions.buildProperties(t, { handled: !0, syntheticException: i }); return this.exceptions.sendExceptionEvent(f$1({}, r, e)); } } addExceptionStep(t, e) { var i; null == (i = this.exceptions) || i.addExceptionStep(t, e); } captureLog(t) { var e; null == (e = this.logs) || e.captureLog(t); } get logger() { var t, e; return null !== (t = null == (e = this.logs) ? void 0 : e.logger) && void 0 !== t ? t : qn$1.dn; } startExceptionAutocapture(t) { this.set_config({ capture_exceptions: null == t || t }); } stopExceptionAutocapture() { this.set_config({ capture_exceptions: !1 }); } loadToolbar(t) { var e, i; return null !== (e = null == (i = this.toolbar) ? void 0 : i.loadToolbar(t)) && void 0 !== e && e; } get_property(t) { var e; return null == (e = this.persistence) ? void 0 : e.props[t]; } getSessionProperty(t) { var e; return null == (e = this.sessionPersistence) ? void 0 : e.props[t]; } toString() { var t, e = null !== (t = this.config.name) && void 0 !== t ? t : Un; return e !== Un && (e = Un + "." + e), e; } _isIdentified() { var t, e; return (null == (t = this.persistence) ? void 0 : t.get_property(mi$1)) === Ai || (null == (e = this.sessionPersistence) ? void 0 : e.get_property(mi$1)) === Ai; } nn() { var t, e; return !("never" === this.config.person_profiles || this.config.person_profiles === Mi && !this._isIdentified() && I(this.getGroups()) && (null == (t = this.persistence) || null == (t = t.props) || !t[Le$1]) && (null == (e = this.persistence) || null == (e = e.props) || !e[Si])); } Qi() { return !0 === this.config.capture_pageleave || "if_capture_pageview" === this.config.capture_pageleave && (!0 === this.config.capture_pageview || "history_change" === this.config.capture_pageview); } createPersonProfile() { this.nn() || this.sn("posthog.createPersonProfile") && this.setPersonProperties({}, {}); } setInternalOrTestUser() { this.sn("posthog.setInternalOrTestUser") && this.setPersonProperties({ $internal_or_test_user: !0 }); } sn(t) { return "never" === this.config.person_profiles ? (Ie.error(t + " was called, but process_person is set to \"never\". This call will be ignored."), !1) : (this.an(Si, !0), !0); } qi() { if ("always" === this.config.cookieless_mode) return !0; var t = this.consent.isOptedOut(); return this.config.disable_persistence || t && !(!this.config.opt_out_persistence_by_default && this.config.cookieless_mode !== Ii); } cn() { var t, e, i, r, s = this.qi(); return (null == (t = this.persistence) ? void 0 : t._r) !== s && (null == (i = this.persistence) || i.set_disabled(s)), (null == (e = this.sessionPersistence) ? void 0 : e._r) !== s && (null == (r = this.sessionPersistence) || r.set_disabled(s)), s; } opt_in_capturing(t) { var e; if (this.config.cookieless_mode !== Ci$1) { if (this.Ni()) { var i, r, s, n, o; this.reset(!0), null == (i = this.sessionManager) || i.destroy(), null == (r = this.pageViewManager) || r.destroy(), this.sessionManager = new vn$1(this), this.pageViewManager = new $r(this), this.persistence && (this.sessionPropsManager = new un$1(this, this.sessionManager, this.persistence)); var a, l = null !== (s = null == (n = this.config.__extensionClasses) ? void 0 : n.sessionRecording) && void 0 !== s ? s : null == (o = qn$1.__defaultExtensionClasses) ? void 0 : o.sessionRecording; l && (this.sessionRecording = this.Ei(this.sessionRecording, new l(this)), this.Wi && (null == (a = this.sessionRecording) || null == a.onRemoteConfig || a.onRemoteConfig(this.Wi))); } var u, h; this.consent.optInOut(!0), this.cn(), this.Xi(), null == (e = this.sessionRecording) || e.startIfEnabledOrStop(), this.config.cookieless_mode == Ii && (null == (u = this.surveys) || u.loadIfEnabled()), (C$2(null == t ? void 0 : t.captureEventName) || null != t && t.captureEventName) && this.capture(null !== (h = null == t ? void 0 : t.captureEventName) && void 0 !== h ? h : "$opt_in", null == t ? void 0 : t.captureProperties, { send_instantly: !0 }), this.config.capture_pageview && this.Ji(); } else Ie.warn(An$1); } opt_out_capturing() { var t, e, i; this.config.cookieless_mode !== Ci$1 ? (this.config.cookieless_mode === Ii && this.consent.isOptedIn() && this.reset(!0), this.consent.optInOut(!1), this.cn(), this.config.cookieless_mode === Ii && (this.register({ distinct_id: Ti$1, $device_id: null }), null == (t = this.sessionManager) || t.destroy(), null == (e = this.pageViewManager) || e.destroy(), this.sessionManager = void 0, this.sessionPropsManager = void 0, null == (i = this.sessionRecording) || i.stopRecording(), this.sessionRecording = void 0, this.Ji())) : Ie.warn(An$1); } has_opted_in_capturing() { return this.consent.isOptedIn(); } has_opted_out_capturing() { return this.consent.isOptedOut(); } get_explicit_consent_status() { var t = this.consent.consent; return 1 === t ? "granted" : 0 === t ? "denied" : "pending"; } is_capturing() { return this.config.cookieless_mode === Ci$1 || (this.config.cookieless_mode === Ii ? this.consent.isRejected() || this.consent.isOptedIn() : !this.has_opted_out_capturing()); } clear_opt_in_out_capturing() { this.consent.reset(), this.cn(); } _is_bot() { return i$1 ? cn$1(i$1, this.config.custom_blocked_useragents) : void 0; } Ji() { r$1 && ("visible" === r$1.visibilityState ? this.Oi || (this.Oi = !0, this.capture(Ui, { title: r$1.title }, { send_instantly: !0 }), this.Pi && (r$1.removeEventListener(Di, this.Pi), this.Pi = null)) : this.Pi || (this.Pi = this.Ji.bind(this), Xi(r$1, Di, this.Pi))); } debug(e) { !1 === e ? (t?.console.log("You've disabled debug mode."), this.set_config({ debug: !1 })) : (t?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."), this.set_config({ debug: !0 })); } Fr() { var t, e, i, r, s, n, o = this.ji || {}; return "advanced_disable_flags" in o ? !!o.advanced_disable_flags : !1 !== this.config.advanced_disable_flags ? !!this.config.advanced_disable_flags : !0 === this.config.advanced_disable_decide ? (Ie.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."), !0) : (i = "advanced_disable_decide", r = Ie, s = (e = "advanced_disable_flags") in (t = o) && !D$1(t[e]), n = i in t && !D$1(t[i]), s ? t[e] : !!n && (r && r.warn("Config field '" + i + "' is deprecated. Please use '" + e + "' instead. The old field will be removed in a future major version."), t[i])); } rn(t) { if (D$1(this.config.before_send)) return t; var e = R$2(this.config.before_send) ? this.config.before_send : [this.config.before_send], i = t; for (var r of e) { if (i = r(i), D$1(i)) { var s = "Event '" + t.event + "' was rejected in beforeSend function"; return z$2(t.event) ? Ie.warn(s + ". This can cause unexpected behavior.") : Ie.info(s), null; } i.properties && !I(i.properties) || Ie.warn("Event '" + t.event + "' has no properties after beforeSend function, this is likely an error."); } return i; } getPageViewId() { var t; return null == (t = this.pageViewManager.dr) ? void 0 : t.pageViewId; } captureTraceFeedback(t, e) { this.capture("$ai_feedback", { $ai_trace_id: String(t), $ai_feedback_text: e }); } captureTraceMetric(t, e, i) { this.capture("$ai_metric", { $ai_trace_id: String(t), $ai_metric_name: e, $ai_metric_value: String(i) }); } Bi(t) { var e = N(t) && !t, i = hr$1.R() && "true" === hr$1.O("ph_debug"); return !e && (!!i || t); } }; qn$1.__defaultExtensionClasses = {}, qn$1.dn = { trace: On = () => {}, debug: On, info: On, warn: On, error: On, fatal: On }, function(t, e) { for (var i = 0; e.length > i; i++) t.prototype[e[i]] = Gi(t.prototype[e[i]]); }(qn$1, ["identify"]); var Vn$1 = 1, Wn$1 = 3, Gn = 11; function Yn$1(t) { return t instanceof Element && (t.id === $i || !(null == t.closest || !t.closest(".toolbar-global-fade-container"))); } function Jn$1(t) { return !!t && t.nodeType === Vn$1; } function Kn$1(t, e) { return !!t && !!t.tagName && t.tagName.toLowerCase() === e.toLowerCase(); } function Xn$1(t) { return !!t && t.nodeType === Wn$1; } function Qn$1(t) { return !!t && t.nodeType === Gn && Jn$1(t.host); } function Zn$1(t) { return t ? x$2(t).split(/\s+/) : []; } function to$1(e) { var i = null == t ? void 0 : t.location.href; return !!(i && e && e.some(((t) => i.match(t)))); } function eo$1(t) { var e = ""; switch (typeof t.className) { case "string": e = t.className; break; case "object": e = (t.className && "baseVal" in t.className ? t.className.baseVal : null) || t.getAttribute("class") || ""; break; default: e = ""; } return Zn$1(e); } function io$1(t) { return D$1(t) ? null : x$2(t).split(/(\s+)/).filter(((t) => wo$1(t))).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255); } function ro$1(t) { var e = ""; return co$2(t) && !po$1(t) && t.childNodes && t.childNodes.length && Hi(t.childNodes, (function(t) { var i; Xn$1(t) && t.textContent && (e += null !== (i = io$1(t.textContent)) && void 0 !== i ? i : ""); })), x$2(e); } function so$1(t) { return C$2(t.target) ? t.srcElement || null : null != (e = t.target) && e.shadowRoot ? t.composedPath()[0] || null : t.target || null; var e; } var no$1 = [ "a", "button", "form", "input", "select", "textarea", "label" ]; function oo$1(t, e) { if (C$2(e)) return !0; var i, r = function(t) { if (e.some(((e) => t.matches(e)))) return { v: !0 }; }; for (var s of t) if (i = r(s)) return i.v; return !1; } function ao$1(t) { var e = t.parentNode; return !(!e || !Jn$1(e)) && e; } var lo$1 = [ "next", "previous", "prev", ">", "<" ], uo$1 = [".ph-no-rageclick", ".ph-no-capture"]; var ho$1 = (t) => !t || Kn$1(t, "html") || !Jn$1(t), vo$1 = (e, i) => { if (!t || ho$1(e)) return { parentIsUsefulElement: !1, targetElementList: [] }; for (var r = !1, s = [e], n = e; n.parentNode && !Kn$1(n, "body");) if (Qn$1(n.parentNode)) s.push(n.parentNode.host), n = n.parentNode.host; else { var o = ao$1(n); if (!o) break; if (i || no$1.indexOf(o.tagName.toLowerCase()) > -1) r = !0; else { var a = t.getComputedStyle(o); a && "pointer" === a.getPropertyValue("cursor") && (r = !0); } s.push(o), n = o; } return { parentIsUsefulElement: r, targetElementList: s }; }; function co$2(t) { for (var e = t; e.parentNode && !Kn$1(e, "body"); e = e.parentNode) { var i = eo$1(e); if (w$1(i, "ph-sensitive") || w$1(i, "ph-no-capture")) return !1; } if (w$1(eo$1(t), "ph-include")) return !0; var r = t.type || ""; if (F$1(r)) switch (r.toLowerCase()) { case "hidden": case "password": return !1; } var s = t.name || t.id || ""; return !F$1(s) || !/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g, "")); } function po$1(t) { return !!(Kn$1(t, "input") && ![ "button", "checkbox", "submit", "reset" ].includes(t.type) || Kn$1(t, "select") || Kn$1(t, "textarea") || "true" === t.getAttribute("contenteditable")); } var fo$1 = "(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})", _o = new RegExp("^(?:" + fo$1 + ")$"), go$1 = new RegExp(fo$1), mo$1 = "\\d{3}-?\\d{2}-?\\d{4}", bo$1 = new RegExp("^(" + mo$1 + ")$"), yo$1 = new RegExp("(" + mo$1 + ")"); function wo$1(t, e) { if (void 0 === e && (e = !0), D$1(t)) return !1; if (F$1(t)) { if (t = x$2(t), (e ? _o : go$1).test((t || "").replace(/[- ]/g, ""))) return !1; if ((e ? bo$1 : yo$1).test(t)) return !1; } return !0; } function xo(t) { var e = ro$1(t); return wo$1(e = (e + " " + Eo$1(t)).trim()) ? e : ""; } function Eo$1(t) { var e = ""; return t && t.childNodes && t.childNodes.length && Hi(t.childNodes, (function(t) { var i; if (t && "span" === (null == (i = t.tagName) ? void 0 : i.toLowerCase())) try { var r = ro$1(t); e = (e + " " + r).trim(), t.childNodes && t.childNodes.length && (e = (e + " " + Eo$1(t)).trim()); } catch (t) { Ie.error("[AutoCapture]", t); } })), e; } function So$1(t) { return t.replace(/"|\\"/g, "\\\""); } function $o(t) { var e = t.attr__class; return e ? R$2(e) ? e : Zn$1(e) : void 0; } var To$1 = class { constructor(t) { this.disabled = !1 === t; var e = O$1(t) ? t : {}; this.thresholdPx = e.threshold_px || 30, this.timeoutMs = e.timeout_ms || 1e3, this.clickCount = e.click_count || 3, this.clicks = []; } isRageClick(t, e, i) { if (this.disabled) return !1; var r = this.clicks[this.clicks.length - 1]; if (r && Math.abs(t - r.x) + Math.abs(e - r.y) < this.thresholdPx && this.timeoutMs > i - r.timestamp) { if (this.clicks.push({ x: t, y: e, timestamp: i }), this.clicks.length === this.clickCount) return !0; } else this.clicks = [{ x: t, y: e, timestamp: i }]; return !1; } }; var ko$1 = "$copy_autocapture", Ro$1 = Ce$2("[AutoCapture]"); function Po$1(t, e) { return e.length > t ? e.slice(0, t) + "..." : e; } function Oo$1(t) { if (t.previousElementSibling) return t.previousElementSibling; var e = t; do e = e.previousSibling; while (e && !Jn$1(e)); return e; } function Io(e, i) { var r, s, { e: n, maskAllElementAttributes: o, maskAllText: a, elementAttributeIgnoreList: l, elementsChainAsString: u } = i; if (!Jn$1(e)) return { props: {} }; for (var h = [e], d = e; d.parentNode && !Kn$1(d, "body");) if (Qn$1(d.parentNode)) h.push(d.parentNode.host), d = d.parentNode.host; else { if (!Jn$1(d.parentNode)) break; h.push(d.parentNode), d = d.parentNode; } var v, c, p = [], _ = {}, g = !1, m = !1; if (Hi(h, ((t) => { var e = co$2(t); if (Kn$1(t, "a")) { var i = t.getAttribute("href"); g = e && !!i && wo$1(i) && i; } w$1(eo$1(t), "ph-no-capture") && (m = !0), p.push(function(t, e, i, r) { var s = t.tagName.toLowerCase(), n = { tag_name: s }; no$1.indexOf(s) > -1 && !i && (n.$el_text = "a" === s.toLowerCase() || "button" === s.toLowerCase() ? Po$1(1024, xo(t)) : Po$1(1024, ro$1(t))); var o = eo$1(t); o.length > 0 && (n.classes = o.filter((function(t) { return "" !== t; }))), Hi(t.attributes, (function(i) { var s; if ((!po$1(t) || -1 !== [ "name", "id", "class", "aria-label" ].indexOf(i.name)) && (null == r || !r.includes(i.name)) && !e && wo$1(i.value) && (!F$1(s = i.name) || "_ngcontent" !== s.substring(0, 10) && "_nghost" !== s.substring(0, 7))) { var o = i.value; "class" === i.name && (o = Zn$1(o).join(" ")), n["attr__" + i.name] = Po$1(1024, o); } })); for (var a = 1, l = 1, u = t; u = Oo$1(u);) a++, u.tagName === t.tagName && l++; return n.nth_child = a, n.nth_of_type = l, n; }(t, o, a, l)); qi(_, function(t) { if (!co$2(t)) return {}; var e = {}; return Hi(t.attributes, (function(t) { if (t.name && 0 === t.name.indexOf("data-ph-capture-attribute")) { var i = t.name.replace("data-ph-capture-attribute-", ""), r = t.value; i && r && wo$1(r) && (e[i] = r); } })), e; }(t)); })), m) return { props: {}, explicitNoCapture: m }; if (a || (p[0].$el_text = Kn$1(e, "a") || Kn$1(e, "button") ? xo(e) : ro$1(e)), g) { var b, y; p[0].attr__href = g; var x = null == (b = Rr$1(g)) ? void 0 : b.host, E = null == t || null == (y = t.location) ? void 0 : y.host; x && E && x !== E && (v = g); } return { props: qi({ $event_type: n.type, $ce_version: 1 }, u ? {} : { $elements: p }, { $elements_chain: (c = p, function(t) { return t.map(((t) => { var e, i, r = ""; if (t.tag_name && (r += t.tag_name), t.attr_class) for (var s of (t.attr_class.sort(), t.attr_class)) r += "." + s.replace(/"/g, ""); var n = f$1({}, t.text ? { text: t.text } : {}, { "nth-child": null !== (e = t.nth_child) && void 0 !== e ? e : 0, "nth-of-type": null !== (i = t.nth_of_type) && void 0 !== i ? i : 0 }, t.href ? { href: t.href } : {}, t.attr_id ? { attr_id: t.attr_id } : {}, t.attributes), o = {}; return Vi(n).sort(((t, e) => { var [i] = t, [r] = e; return i.localeCompare(r); })).forEach(((t) => { var [e, i] = t; return o[So$1(e.toString())] = So$1(i.toString()); })), (r += ":") + Vi(o).map(((t) => { var [e, i] = t; return e + "=\"" + i + "\""; })).join(""); })).join(";"); }(function(t) { return t.map(((t) => { var e, i, r = { text: null == (e = t.$el_text) ? void 0 : e.slice(0, 400), tag_name: t.tag_name, href: null == (i = t.attr__href) ? void 0 : i.slice(0, 2048), attr_class: $o(t), attr_id: t.attr__id, nth_child: t.nth_child, nth_of_type: t.nth_of_type, attributes: {} }; return Vi(t).filter(((t) => { var [e] = t; return 0 === e.indexOf("attr__"); })).forEach(((t) => { var [e, i] = t; return r.attributes[e] = i; })), r; })); }(c))) }, null != (r = p[0]) && r.$el_text ? { $el_text: null == (s = p[0]) ? void 0 : s.$el_text } : {}, v && "click" === n.type ? { $external_click_url: v } : {}, _) }; } var Co$1 = Ce$2("[ExceptionAutocapture]"); function Fo(t, e, i) { try { if (!(e in t)) return () => {}; var r = t[e], s = i(r); return P$1(s) && (s.prototype = s.prototype || {}, Object.defineProperties(s, { __posthog_wrapped__: { enumerable: !1, value: !0 } })), t[e] = s, () => { t[e] = r; }; } catch (t) { return () => {}; } } var Ao$1 = Ce$2("[TracingHeaders]"), Mo$1 = Ce$2("[Web Vitals]"), Do$1 = 9e5, Lo$1 = "disabled", Uo = "lazy_loading", No = "awaiting_config", jo = "missing_config"; Ce$2("[SessionRecording]"), Ce$2("[SessionRecording]"); var zo$2 = "[SessionRecording]", Bo$2 = Ce$2(zo$2), Ho = Ce$2("[Heatmaps]"); function qo$1(t) { return O$1(t) && "clientX" in t && "clientY" in t && L$1(t.clientX) && L$1(t.clientY); } var Vo$1 = Ce$2("[Product Tours]"), Wo$1 = ["$set_once", "$set"], Go$1 = Ce$2("[SiteApps]"), Yo$1 = "Error while initializing PostHog app with config id "; function Jo(t, e, i) { if (D$1(t)) return !1; switch (i) { case "exact": return t === e; case "contains": var r = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/_/g, ".").replace(/%/g, ".*"); return new RegExp(r, "i").test(t); case "regex": try { return new RegExp(e).test(t); } catch (t) { return !1; } default: return !1; } } var Ko$1 = class { constructor(t) { this.vn = new hn$1(), this.fn = (t, e) => this.pn(t, e) && this.gn(t, e) && this.mn(t, e) && this.yn(t, e), this.pn = (t, e) => null == e || !e.event || (null == t ? void 0 : t.event) === (null == e ? void 0 : e.event), this._instance = t, this.bn = /* @__PURE__ */ new Set(), this._n = /* @__PURE__ */ new Set(); } init() { var t, e; C$2(null == (t = this._instance) ? void 0 : t._addCaptureHook) || null == (e = this._instance) || e._addCaptureHook(((t, e) => { this.on(t, e); })); } register(t) { var e, i; if (!C$2(null == (e = this._instance) ? void 0 : e._addCaptureHook) && (t.forEach(((t) => { var e, i; null == (e = this._n) || e.add(t), null == (i = t.steps) || i.forEach(((t) => { var e; null == (e = this.bn) || e.add((null == t ? void 0 : t.event) || ""); })); })), null != (i = this._instance) && i.autocapture)) { var r, s = /* @__PURE__ */ new Set(); t.forEach(((t) => { var e; null == (e = t.steps) || e.forEach(((t) => { null != t && t.selector && s.add(null == t ? void 0 : t.selector); })); })), null == (r = this._instance) || r.autocapture.setElementSelectors(s); } } on(t, e) { var i; null != e && 0 != t.length && (this.bn.has(t) || this.bn.has(null == e ? void 0 : e.event)) && this._n && (null == (i = this._n) ? void 0 : i.size) > 0 && this._n.forEach(((t) => { this.wn(e, t) && this.vn.emit("actionCaptured", t.name); })); } In(t) { this.onAction("actionCaptured", ((e) => t(e))); } wn(t, e) { if (null == (null == e ? void 0 : e.steps)) return !1; for (var i of e.steps) if (this.fn(t, i)) return !0; return !1; } onAction(t, e) { return this.vn.on(t, e); } gn(t, e) { if (null != e && e.url) { var i, r = null == t || null == (i = t.properties) ? void 0 : i.$current_url; if (!r || "string" != typeof r) return !1; if (!Jo(r, e.url, e.url_matching || "contains")) return !1; } return !0; } mn(t, e) { return !!this.Cn(t, e) && !!this.Sn(t, e) && !!this.xn(t, e); } Cn(t, e) { var i; if (null == e || !e.href) return !0; var r = this.kn(t); if (r.length > 0) return r.some(((t) => Jo(t.href, e.href, e.href_matching || "exact"))); var s, n = (null == t || null == (i = t.properties) ? void 0 : i.$elements_chain) || ""; return !!n && Jo((s = n.match(/(?::|")href="(.*?)"/)) ? s[1] : "", e.href, e.href_matching || "exact"); } Sn(t, e) { var i; if (null == e || !e.text) return !0; var r = this.kn(t); if (r.length > 0) return r.some(((t) => Jo(t.text, e.text, e.text_matching || "exact") || Jo(t.$el_text, e.text, e.text_matching || "exact"))); var s, n, o, a = (null == t || null == (i = t.properties) ? void 0 : i.$elements_chain) || ""; return !!a && (s = function(t) { for (var e, i = [], r = /(?::|")text="(.*?)"/g; !D$1(e = r.exec(t));) i.includes(e[1]) || i.push(e[1]); return i; }(a), n = e.text, o = e.text_matching || "exact", s.some(((t) => Jo(t, n, o)))); } xn(t, e) { var i, r; if (null == e || !e.selector) return !0; var s = null == t || null == (i = t.properties) ? void 0 : i.$element_selectors; if (null != s && s.includes(e.selector)) return !0; var n = (null == t || null == (r = t.properties) ? void 0 : r.$elements_chain) || ""; if (e.selector_regex && n) try { return new RegExp(e.selector_regex).test(n); } catch (t) { return !1; } return !1; } kn(t) { var e; return null == (null == t || null == (e = t.properties) ? void 0 : e.$elements) ? [] : null == t ? void 0 : t.properties.$elements; } yn(t, e) { return null == e || !e.properties || 0 === e.properties.length || mn$1(e.properties.reduce(((t, e) => { var i = R$2(e.value) ? e.value.map(String) : null != e.value ? [String(e.value)] : []; return t[e.key] = { values: i, operator: e.operator || "exact" }, t; }), {}), null == t ? void 0 : t.properties); } }; var Xo$1 = class { constructor(t) { this._instance = t, this.Tn = /* @__PURE__ */ new Map(), this.An = /* @__PURE__ */ new Map(), this.En = /* @__PURE__ */ new Map(); } Rn(t, e) { return !!t && mn$1(t.propertyFilters, null == e ? void 0 : e.properties); } Nn(t, e) { var i = /* @__PURE__ */ new Map(); return t.forEach(((t) => { var r; null == (r = t.conditions) || null == (r = r[e]) || null == (r = r.values) || r.forEach(((e) => { if (null != e && e.name) { var r = i.get(e.name) || []; r.push(t.id), i.set(e.name, r); } })); })), i; } Mn(t, e, i) { var r = (i === Jr$1.Activation ? this.Tn : this.An).get(t), s = []; return this.Fn(((t) => { s = t.filter(((t) => null == r ? void 0 : r.includes(t.id))); })), s.filter(((r) => { var s, n = null == (s = r.conditions) || null == (s = s[i]) || null == (s = s.values) ? void 0 : s.find(((e) => e.name === t)); return this.Rn(n, e); })); } register(t) { var e; C$2(null == (e = this._instance) ? void 0 : e._addCaptureHook) || (this.On(t), this.Pn(t)); } Pn(t) { var e = t.filter(((t) => { var e, i; return (null == (e = t.conditions) ? void 0 : e.actions) && (null == (i = t.conditions) || null == (i = i.actions) || null == (i = i.values) ? void 0 : i.length) > 0; })); 0 !== e.length && (this.Ln ?? (this.Ln = new Ko$1(this._instance), this.Ln.init(), this.Ln.In(((t) => { this.onAction(t); }))), e.forEach(((t) => { var e, i, r, s, n; t.conditions && null != (e = t.conditions) && e.actions && null != (i = t.conditions) && null != (i = i.actions) && i.values && (null == (r = t.conditions) || null == (r = r.actions) || null == (r = r.values) ? void 0 : r.length) > 0 && (null == (s = this.Ln) || s.register(t.conditions.actions.values), null == (n = t.conditions) || null == (n = n.actions) || null == (n = n.values) || n.forEach(((e) => { if (e && e.name) { var i = this.En.get(e.name); i && i.push(t.id), this.En.set(e.name, i || [t.id]); } }))); }))); } On(t) { var e, i = t.filter(((t) => { var e, i; return (null == (e = t.conditions) ? void 0 : e.events) && (null == (i = t.conditions) || null == (i = i.events) || null == (i = i.values) ? void 0 : i.length) > 0; })), r = t.filter(((t) => { var e, i; return (null == (e = t.conditions) ? void 0 : e.cancelEvents) && (null == (i = t.conditions) || null == (i = i.cancelEvents) || null == (i = i.values) ? void 0 : i.length) > 0; })); 0 === i.length && 0 === r.length || (null == (e = this._instance) || e._addCaptureHook(((t, e) => { this.onEvent(t, e); })), this.Tn = this.Nn(t, Jr$1.Activation), this.An = this.Nn(t, Jr$1.Cancellation)); } onEvent(t, e) { var i, r = this.le(), s = this.Dn(), n = this.Bn(), o = (null == (i = this._instance) || null == (i = i.persistence) ? void 0 : i.props[s]) || []; if (n === t && e && o.length > 0) { var a, l; r.info("event matched, removing item from activated items", { event: t, eventPayload: e, existingActivatedItems: o }); var u = (null == e || null == (a = e.properties) ? void 0 : a.$survey_id) || (null == e || null == (l = e.properties) ? void 0 : l.$product_tour_id); if (u) { var h = o.indexOf(u); 0 > h || (o.splice(h, 1), this.jn(o)); } } else { if (this.An.has(t)) { var d = this.Mn(t, e, Jr$1.Cancellation); d.length > 0 && (r.info("cancel event matched, cancelling items", { event: t, itemsToCancel: d.map(((t) => t.id)) }), d.forEach(((t) => { var e = o.indexOf(t.id); 0 > e || o.splice(e, 1), this.$n(t.id); })), this.jn(o)); } if (this.Tn.has(t)) { r.info("event name matched", { event: t, eventPayload: e, items: this.Tn.get(t) }); var v = this.Mn(t, e, Jr$1.Activation); this.jn(o.concat(v.map(((t) => t.id)) || [])); } } } onAction(t) { var e, i = this.Dn(), r = (null == (e = this._instance) || null == (e = e.persistence) ? void 0 : e.props[i]) || []; this.En.has(t) && this.jn(r.concat(this.En.get(t) || [])); } jn(t) { var e = this.le(), i = [...new Set(t)].filter(((t) => !this.qn(t))); e.info("updating activated items", { activatedItems: i }), this.Zn(i); } getActivatedIds() { var t, e = this.Dn(); return (null == (t = this._instance) || null == (t = t.persistence) ? void 0 : t.props[e]) || []; } getEventToItemsMap() { return this.Tn; } Vn() { return this.Ln; } }; var Qo$1 = class extends Xo$1 { constructor(t) { super(t); } Dn() { return vi$1; } Bn() { return rs$1.SHOWN; } Fn(t) { var e; null == (e = this._instance) || e.getSurveys(t); } $n(t) { var e; null == (e = this._instance) || e.cancelPendingSurvey(t); } le() { return En$1; } Zn(t) { var e; null == (e = this._instance) || null == (e = e.persistence) || e.register({ [vi$1]: t }); } qn() { return !1; } getSurveys() { return this.getActivatedIds(); } getEventToSurveys() { return this.getEventToItemsMap(); } }; var Zo$1 = "SDK is not enabled or survey functionality is not yet loaded", ta$1 = "Disabled. Not loading surveys.", ea$1 = null != t && t.location ? Ir(t.location.hash, "__posthog") || Ir(location.hash, "state") : null, ia$1 = "_postHogToolbarParams", ra$1 = Ce$2("[Toolbar]"), sa$1 = Ce$2("[FeatureFlags]"), na$1 = Ce$2("[FeatureFlags]", { debugEnabled: !0 }), oa$1 = "\" failed. Feature flags didn't load in time.", aa$1 = (t) => { for (var e = {}, i = 0; t.length > i; i++) e[t[i]] = !0; return e; }, la$1 = (t) => { var e = {}; for (var [i, r] of Vi(t || {})) r && (e[i] = r); return e; }, ua$1 = Ce$2("[Error tracking]"), ha$1 = "Refusing to render web experiment since the viewer is a likely bot", da$1 = { icontains: (e, i) => !!t && i.href.toLowerCase().indexOf(e.toLowerCase()) > -1, not_icontains: (e, i) => !!t && -1 === i.href.toLowerCase().indexOf(e.toLowerCase()), regex: (e, i) => !!t && pn$1(i.href, e), not_regex: (e, i) => !!t && !pn$1(i.href, e), exact: (t, e) => e.href === t, is_not: (t, e) => e.href !== t }; var va$1 = class va$1 { get Bt() { return this._instance.config; } constructor(t) { var e = this; this.getWebExperimentsAndEvaluateDisplayLogic = function(t) { void 0 === t && (t = !1), e.getWebExperiments(((t) => { va$1.Hn("retrieved web experiments from the server"), e.zn = /* @__PURE__ */ new Map(), t.forEach(((t) => { if (t.feature_flag_key) { var i; e.zn && (va$1.Hn("setting flag key ", t.feature_flag_key, " to web experiment ", t), null == (i = e.zn) || i.set(t.feature_flag_key, t)); var r = e._instance.getFeatureFlag(t.feature_flag_key); F$1(r) && t.variants[r] && e.Un(t.name, r, t.variants[r].transforms); } else if (t.variants) for (var s in t.variants) { var n = t.variants[s]; va$1.Yn(n) && e.Un(t.name, s, n.transforms); } })); }), t); }, this._instance = t, this._instance.onFeatureFlags(((t) => { this.onFeatureFlags(t); })); } initialize() {} onFeatureFlags(t) { if (this._is_bot()) va$1.Hn(ha$1); else if (!this.Bt.disable_web_experiments) { if (D$1(this.zn)) return this.zn = /* @__PURE__ */ new Map(), this.loadIfEnabled(), void this.previewWebExperiment(); va$1.Hn("applying feature flags", t), t.forEach(((t) => { var e; if (this.zn && null != (e = this.zn) && e.has(t)) { var i, r = this._instance.getFeatureFlag(t), s = null == (i = this.zn) ? void 0 : i.get(t); r && null != s && s.variants[r] && this.Un(s.name, r, s.variants[r].transforms); } })); } } previewWebExperiment() { var t = va$1.getWindowLocation(); if (null != t && t.search) { var e = Pr$1(null == t ? void 0 : t.search, "__experiment_id"), i = Pr$1(null == t ? void 0 : t.search, "__experiment_variant"); e && i && (va$1.Hn("previewing web experiments " + e + " && " + i), this.getWebExperiments(((t) => { this.Gn(parseInt(e), i, t); }), !1, !0)); } } loadIfEnabled() { this.Bt.disable_web_experiments || this.getWebExperimentsAndEvaluateDisplayLogic(); } getWebExperiments(t, e, i) { if (this.Bt.disable_web_experiments && !i) return t([]); var r = this._instance.get_property("$web_experiments"); if (r && !e) return t(r); this._instance._send_request({ url: this._instance.requestRouter.endpointFor("api", "/api/web_experiments/?token=" + this.Bt.token), method: "GET", callback: (e) => t(200 === e.statusCode && e.json && e.json.experiments || []) }); } Gn(t, e, i) { var r = i.filter(((e) => e.id === t)); r && r.length > 0 && (va$1.Hn("Previewing web experiment [" + r[0].name + "] with variant [" + e + "]"), this.Un(r[0].name, e, r[0].variants[e].transforms)); } static Yn(t) { return !D$1(t.conditions) && va$1.Wn(t) && va$1.Xn(t); } static Wn(t) { var e; if (D$1(t.conditions) || D$1(null == (e = t.conditions) ? void 0 : e.url)) return !0; var i, r, s, n = va$1.getWindowLocation(); return !!n && (null == (i = t.conditions) || !i.url || da$1[null !== (r = null == (s = t.conditions) ? void 0 : s.urlMatchType) && void 0 !== r ? r : "icontains"](t.conditions.url, n)); } static getWindowLocation() { return null == t ? void 0 : t.location; } static Xn(t) { var e; if (D$1(t.conditions) || D$1(null == (e = t.conditions) ? void 0 : e.utm)) return !0; var i = Lr$1(); if (i.utm_source) { var r, s, n, o, a, l, u, h, d = null == (r = t.conditions) || null == (r = r.utm) || !r.utm_campaign || (null == (s = t.conditions) || null == (s = s.utm) ? void 0 : s.utm_campaign) == i.utm_campaign, v = null == (n = t.conditions) || null == (n = n.utm) || !n.utm_source || (null == (o = t.conditions) || null == (o = o.utm) ? void 0 : o.utm_source) == i.utm_source, c = null == (a = t.conditions) || null == (a = a.utm) || !a.utm_medium || (null == (l = t.conditions) || null == (l = l.utm) ? void 0 : l.utm_medium) == i.utm_medium, p = null == (u = t.conditions) || null == (u = u.utm) || !u.utm_term || (null == (h = t.conditions) || null == (h = h.utm) ? void 0 : h.utm_term) == i.utm_term; return d && c && p && v; } return !1; } static Hn(t) { for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), r = 1; e > r; r++) i[r - 1] = arguments[r]; Ie.info("[WebExperiments] " + t, i); } Un(t, e, i) { this._is_bot() ? va$1.Hn(ha$1) : "control" !== e ? i.forEach(((i) => { if (i.selector) { var r; va$1.Hn("applying transform of variant " + e + " for experiment " + t + " ", i); (null == (r = document) ? void 0 : r.querySelectorAll(i.selector))?.forEach(((t) => { var e = t; i.html && (e.innerHTML = i.html), i.css && e.setAttribute("style", i.css); })); } })) : va$1.Hn("Control variants leave the page unmodified."); } _is_bot() { return i$1 && this._instance ? cn$1(i$1, this.Bt.custom_blocked_useragents) : void 0; } }; var ca = Ce$2("[Conversations]"), pa$1 = "Conversations not available yet.", fa$1 = { featureFlags: class { constructor(t) { this.Jn = !1, this.Kn = !1, this.Qn = !1, this.es = !1, this.ts = !1, this.rs = !1, this.ns = !1, this.ss = !1, this._instance = t, this.featureFlagEventHandlers = []; } get Bt() { return this._instance.config; } get ni() { return this._instance.persistence; } os(t) { return this._instance.get_property(t); } ls() { var t, e; return null !== (t = null == (e = this.ni) ? void 0 : e.wr(this.Bt.feature_flag_cache_ttl_ms)) && void 0 !== t && t; } us() { return !!this.ls() && (this.ss || this.Qn || (this.ss = !0, sa$1.warn("Feature flag cache is stale, triggering refresh..."), this.reloadFeatureFlags()), !0); } hs() { var t, e = null !== (t = this.Bt.evaluation_contexts) && void 0 !== t ? t : this.Bt.evaluation_environments; return !this.Bt.evaluation_environments || this.Bt.evaluation_contexts || this.ns || (sa$1.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."), this.ns = !0), null != e && e.length ? e.filter(((t) => { var e = t && "string" == typeof t && t.trim().length > 0; return e || sa$1.error("Invalid evaluation context found:", t, "Expected non-empty string"), e; })) : []; } cs() { return this.hs().length > 0; } initialize() { var t, e, { config: i } = this._instance, r = null !== (t = null == (e = i.bootstrap) ? void 0 : e.featureFlags) && void 0 !== t ? t : {}; if (Object.keys(r).length) { var s, n, o = null !== (s = null == (n = i.bootstrap) ? void 0 : n.featureFlagPayloads) && void 0 !== s ? s : {}, a = Object.keys(r).filter(((t) => !!r[t])).reduce(((t, e) => (t[e] = r[e] || !1, t)), {}), l = Object.keys(o).filter(((t) => a[t])).reduce(((t, e) => (o[e] && (t[e] = o[e]), t)), {}); this.receivedFeatureFlags({ featureFlags: a, featureFlagPayloads: l }); } } updateFlags(t, e, i) { var r = null != i && i.merge ? this.getFlagVariants() : {}, s = null != i && i.merge ? this.getFlagPayloads() : {}, n = f$1({}, r, t), o = f$1({}, s, e), a = {}; for (var [l, u] of Object.entries(n)) { var h = "string" == typeof u; a[l] = { key: l, enabled: !!h || Boolean(u), variant: h ? u : void 0, reason: void 0, metadata: C$2(null == o ? void 0 : o[l]) ? void 0 : { id: 0, version: void 0, description: void 0, payload: o[l] } }; } this.receivedFeatureFlags({ flags: a }); } get hasLoadedFlags() { return this.Kn; } getFlags() { return Object.keys(this.getFlagVariants()); } getFlagsWithDetails() { var t = this.os(si$1), e = this.os(ai$1), i = this.os(li$1); if (!i && !e) return t || {}; var r = qi({}, t || {}); for (var n of [...new Set([...Object.keys(i || {}), ...Object.keys(e || {})])]) { var o, a, l = r[n], u = null == e ? void 0 : e[n], h = C$2(u) ? null !== (o = null == l ? void 0 : l.enabled) && void 0 !== o && o : !!u, d = C$2(u) ? l.variant : "string" == typeof u ? u : void 0, v = null == i ? void 0 : i[n], c = f$1({}, l, { enabled: h, variant: h ? null != d ? d : null == l ? void 0 : l.variant : void 0 }); h !== (null == l ? void 0 : l.enabled) && (c.original_enabled = null == l ? void 0 : l.enabled), d !== (null == l ? void 0 : l.variant) && (c.original_variant = null == l ? void 0 : l.variant), v && (c.metadata = f$1({}, null == l ? void 0 : l.metadata, { payload: v, original_payload: null == l || null == (a = l.metadata) ? void 0 : a.payload })), r[n] = c; } return this.Jn || (sa$1.warn(" Overriding feature flag details!", { flagDetails: t, overriddenPayloads: i, finalDetails: r }), this.Jn = !0), r; } getFlagVariants() { var t = this.os(ei$1), e = this.os(ai$1); if (!e) return t || {}; for (var i = qi({}, t), r = Object.keys(e), s = 0; r.length > s; s++) i[r[s]] = e[r[s]]; return this.Jn || (sa$1.warn(" Overriding feature flags!", { enabledFlags: t, overriddenFlags: e, finalFlags: i }), this.Jn = !0), i; } getFlagPayloads() { var t = this.os(ni), e = this.os(li$1); if (!e) return t || {}; for (var i = qi({}, t || {}), r = Object.keys(e), s = 0; r.length > s; s++) i[r[s]] = e[r[s]]; return this.Jn || (sa$1.warn(" Overriding feature flag payloads!", { flagPayloads: t, overriddenPayloads: e, finalPayloads: i }), this.Jn = !0), i; } reloadFeatureFlags() { this.es || this.Bt.advanced_disable_feature_flags || this.ds || (this._instance.Fi.emit("featureFlagsReloading", !0), this.ds = setTimeout((() => { this.vs(); }), 5)); } fs() { clearTimeout(this.ds), this.ds = void 0; } ensureFlagsLoaded() { this.Kn || this.Qn || this.ds || this.reloadFeatureFlags(); } setAnonymousDistinctId(t) { this.$anon_distinct_id = t; } setReloadingPaused(t) { this.es = t; } vs(t) { var e; if (this.fs(), !this._instance.Fr()) if (this.Qn) this.ts = !0; else { var i = this.Bt.token, r = this.os(De$1), s = { token: i, distinct_id: this._instance.get_distinct_id(), groups: this._instance.getGroups(), $anon_distinct_id: this.$anon_distinct_id, person_properties: f$1({}, (null == (e = this.ni) ? void 0 : e.get_initial_props()) || {}, this.os(ui$1) || {}), group_properties: this.os(hi$1), timezone: Vr$1() }; M(r) || C$2(r) || (s.$device_id = r), (null != t && t.disableFlags || this.Bt.advanced_disable_feature_flags) && (s.disable_flags = !0), this.cs() && (s.evaluation_contexts = this.hs()); var n = this._instance.requestRouter.endpointFor("flags", "/flags/?v=2" + (this.Bt.advanced_only_evaluate_survey_feature_flags ? "&only_evaluate_survey_feature_flags=true" : "")); this.Qn = !0, this._instance._send_request({ method: "POST", url: n, data: s, compression: this.Bt.disable_compression ? void 0 : ps.Base64, timeout: this.Bt.feature_flag_request_timeout_ms, callback: (t) => { var e, i, r, n = !0; if (200 === t.statusCode && (this.ts || (this.$anon_distinct_id = void 0), n = !1), this.Qn = !1, !s.disable_flags || this.ts) { this.rs = !n; var o = []; t.error ? t.error instanceof Error ? o.push("AbortError" === t.error.name ? "timeout" : "connection_error") : o.push("unknown_error") : 200 !== t.statusCode && o.push("api_error_" + t.statusCode), null != (e = t.json) && e.errorsWhileComputingFlags && o.push("errors_while_computing_flags"); var a, l = !(null == (i = t.json) || null == (i = i.quotaLimited) || !i.includes("feature_flags")); if (l && o.push("quota_limited"), null == (r = this.ni) || r.register({ [_i$1]: o }), l) sa$1.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."); else s.disable_flags || this.receivedFeatureFlags(null !== (a = t.json) && void 0 !== a ? a : {}, n, { partialResponse: !!this.Bt.advanced_only_evaluate_survey_feature_flags }), this.ts && (this.ts = !1, this.vs()); } } }); } } getFeatureFlag(t, e) { var i; if (void 0 === e && (e = {}), !e.fresh || this.rs) if (this.Kn || this.getFlags() && this.getFlags().length > 0) { if (!this.us()) { var r = this.getFeatureFlagResult(t, e); return null !== (i = null == r ? void 0 : r.variant) && void 0 !== i ? i : null == r ? void 0 : r.enabled; } } else sa$1.warn("getFeatureFlag for key \"" + t + oa$1); } getFeatureFlagDetails(t) { return this.getFlagsWithDetails()[t]; } getFeatureFlagPayload(t) { var e = this.getFeatureFlagResult(t, { send_event: !1 }); return null == e ? void 0 : e.payload; } getFeatureFlagResult(t, e) { if (void 0 === e && (e = {}), !e.fresh || this.rs) if (this.Kn || this.getFlags() && this.getFlags().length > 0) { if (!this.us()) { var i = this.getFlagVariants(), r = t in i, s = i[t], n = this.getFlagPayloads()[t], o = String(s), a = this.os(oi$1) || void 0, l = this.os(gi$1) || void 0, u = this.os(pi) || {}; if (this.Bt.advanced_feature_flags_dedup_per_session) { var h, d = this._instance.get_session_id(), v = this.os(fi$1); d && d !== v && (u = {}, null == (h = this.ni) || h.register({ [pi]: u, [fi$1]: d })); } if ((e.send_event || !("send_event" in e)) && (!(t in u) || !u[t].includes(o))) { var c, p, f, _, g, m, b, y, w, x; R$2(u[t]) ? u[t].push(o) : u[t] = [o], null == (c = this.ni) || c.register({ [pi]: u }); var E = this.getFeatureFlagDetails(t), S = [...null !== (p = this.os(_i$1)) && void 0 !== p ? p : []]; C$2(s) && S.push("flag_missing"); var T = { $feature_flag: t, $feature_flag_response: s, $feature_flag_payload: n || null, $feature_flag_request_id: a, $feature_flag_evaluated_at: l, $feature_flag_bootstrapped_response: (null == (f = this.Bt.bootstrap) || null == (f = f.featureFlags) ? void 0 : f[t]) || null, $feature_flag_bootstrapped_payload: (null == (_ = this.Bt.bootstrap) || null == (_ = _.featureFlagPayloads) ? void 0 : _[t]) || null, $used_bootstrap_value: !this.rs }; C$2(null == E || null == (g = E.metadata) ? void 0 : g.version) || (T.$feature_flag_version = E.metadata.version); var k, P = null !== (m = null == E || null == (b = E.reason) ? void 0 : b.description) && void 0 !== m ? m : null == E || null == (y = E.reason) ? void 0 : y.code; P && (T.$feature_flag_reason = P), null != E && null != (w = E.metadata) && w.id && (T.$feature_flag_id = E.metadata.id), C$2(null == E ? void 0 : E.original_variant) && C$2(null == E ? void 0 : E.original_enabled) || (T.$feature_flag_original_response = C$2(E.original_variant) ? E.original_enabled : E.original_variant), null != E && null != (x = E.metadata) && x.original_payload && (T.$feature_flag_original_payload = null == E || null == (k = E.metadata) ? void 0 : k.original_payload), S.length && (T.$feature_flag_error = S.join(",")), this._instance.capture("$feature_flag_called", T); } if (r) { var O = n; if (!C$2(n)) try { O = JSON.parse(n); } catch (t) {} return { key: t, enabled: !!s, variant: "string" == typeof s ? s : void 0, payload: O }; } } } else sa$1.warn("getFeatureFlagResult for key \"" + t + oa$1); } getRemoteConfigPayload(t, e) { var i = this.Bt.token, r = { distinct_id: this._instance.get_distinct_id(), token: i }; this.cs() && (r.evaluation_contexts = this.hs()), this._instance._send_request({ method: "POST", url: this._instance.requestRouter.endpointFor("flags", "/flags/?v=2"), data: r, compression: this.Bt.disable_compression ? void 0 : ps.Base64, timeout: this.Bt.feature_flag_request_timeout_ms, callback(i) { var r, s = null == (r = i.json) ? void 0 : r.featureFlagPayloads; e((null == s ? void 0 : s[t]) || void 0); } }); } isFeatureEnabled(t, e) { if (void 0 === e && (e = {}), !e.fresh || this.rs) { if (this.Kn || this.getFlags() && this.getFlags().length > 0) { var i = this.getFeatureFlag(t, e); return C$2(i) ? void 0 : !!i; } sa$1.warn("isFeatureEnabled for key \"" + t + oa$1); } } addFeatureFlagsHandler(t) { this.featureFlagEventHandlers.push(t); } removeFeatureFlagsHandler(t) { this.featureFlagEventHandlers = this.featureFlagEventHandlers.filter(((e) => e !== t)); } receivedFeatureFlags(t, e, i) { if (this.ni) { this.Kn = !0; var r = this.getFlagVariants(), s = this.getFlagPayloads(), n = this.getFlagsWithDetails(); (function(t, e, i, r, s, n) { void 0 === i && (i = {}), void 0 === r && (r = {}), void 0 === s && (s = {}); var o = ((t) => { var e = t.flags; return e ? (t.featureFlags = Object.fromEntries(Object.keys(e).map(((t) => { var i; return [t, null !== (i = e[t].variant) && void 0 !== i ? i : e[t].enabled]; }))), t.featureFlagPayloads = Object.fromEntries(Object.keys(e).filter(((t) => e[t].enabled)).filter(((t) => { var i; return null == (i = e[t].metadata) ? void 0 : i.payload; })).map(((t) => { var i; return [t, null == (i = e[t].metadata) ? void 0 : i.payload]; })))) : sa$1.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"), t; })(t), a = o.flags, l = o.featureFlags, u = o.featureFlagPayloads; if (l) { var h = t.requestId, d = t.evaluatedAt; if (R$2(l)) { sa$1.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version."); var v = {}; if (l) for (var c = 0; l.length > c; c++) v[l[c]] = !0; e && e.register({ [ii$1]: l, [ei$1]: v }); } else { var p = l, _ = u, g = a; if (null != n && n.partialResponse) p = f$1({}, i, p), _ = f$1({}, r, _), g = f$1({}, s, g); else if (t.errorsWhileComputingFlags) if (a) { var m = new Set(Object.keys(a).filter(((t) => { var e; return !(null != (e = a[t]) && e.failed); }))); p = f$1({}, i, Object.fromEntries(Object.entries(p).filter(((t) => { var [e] = t; return m.has(e); })))), _ = f$1({}, r, Object.fromEntries(Object.entries(_ || {}).filter(((t) => { var [e] = t; return m.has(e); })))), g = f$1({}, s, Object.fromEntries(Object.entries(g || {}).filter(((t) => { var [e] = t; return m.has(e); })))); } else p = f$1({}, i, p), _ = f$1({}, r, _), g = f$1({}, s, g); e && e.register(f$1({ [ii$1]: Object.keys(la$1(p)), [ei$1]: p || {}, [ni]: _ || {}, [si$1]: g || {} }, h ? { [oi$1]: h } : {}, d ? { [gi$1]: d } : {})); } } })(t, this.ni, r, s, n, i), e || (this.ss = !1), this.ps(e); } } override(t, e) { void 0 === e && (e = !1), sa$1.warn("override is deprecated. Please use overrideFeatureFlags instead."), this.overrideFeatureFlags({ flags: t, suppressWarning: e }); } overrideFeatureFlags(t) { if (!this._instance.__loaded || !this.ni) return sa$1.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags"); if (!1 === t) return this.ni.unregister(ai$1), this.ni.unregister(li$1), this.ps(), na$1.info("All overrides cleared"); if (R$2(t)) { var e = aa$1(t); return this.ni.register({ [ai$1]: e }), this.ps(), na$1.info("Flag overrides set", { flags: t }); } if (t && "object" == typeof t && ("flags" in t || "payloads" in t)) { var i, r = t; if (this.Jn = Boolean(null !== (i = r.suppressWarning) && void 0 !== i && i), "flags" in r) { if (!1 === r.flags) this.ni.unregister(ai$1), na$1.info("Flag overrides cleared"); else if (r.flags) { if (R$2(r.flags)) { var s = aa$1(r.flags); this.ni.register({ [ai$1]: s }); } else this.ni.register({ [ai$1]: r.flags }); na$1.info("Flag overrides set", { flags: r.flags }); } } "payloads" in r && (!1 === r.payloads ? (this.ni.unregister(li$1), na$1.info("Payload overrides cleared")) : r.payloads && (this.ni.register({ [li$1]: r.payloads }), na$1.info("Payload overrides set", { payloads: r.payloads }))), this.ps(); return; } if (t && "object" == typeof t) return this.ni.register({ [ai$1]: t }), this.ps(), na$1.info("Flag overrides set", { flags: t }); sa$1.warn("Invalid overrideOptions provided to overrideFeatureFlags", { overrideOptions: t }); } onFeatureFlags(t) { if (this.addFeatureFlagsHandler(t), this.Kn) { var { flags: e, flagVariants: i } = this.gs(); t(e, i); } return () => this.removeFeatureFlagsHandler(t); } updateEarlyAccessFeatureEnrollment(t, e, i) { var r, s = (this.os(ri$1) || []).find(((e) => e.flagKey === t)), n = { ["$feature_enrollment/" + t]: e }, o = { $feature_flag: t, $feature_enrollment: e, $set: n }; s && (o.$early_access_feature_name = s.name), i && (o.$feature_enrollment_stage = i), this._instance.capture("$feature_enrollment_update", o), this.setPersonPropertiesForFlags(n, !1); var a = f$1({}, this.getFlagVariants(), { [t]: e }); null == (r = this.ni) || r.register({ [ii$1]: Object.keys(la$1(a)), [ei$1]: a }), this.ps(); } getEarlyAccessFeatures(t, e, i) { void 0 === e && (e = !1); var r = this.os(ri$1), s = i ? "&" + i.map(((t) => "stage=" + t)).join("&") : ""; if (r && !e) return t(r); this._instance._send_request({ url: this._instance.requestRouter.endpointFor("api", "/api/early_access_features/?token=" + this.Bt.token + s), method: "GET", callback: (e) => { var i, r; if (e.json) { var s = e.json.earlyAccessFeatures; return null == (i = this.ni) || i.unregister(ri$1), null == (r = this.ni) || r.register({ [ri$1]: s }), t(s); } } }); } gs() { var t = this.getFlags(), e = this.getFlagVariants(); return { flags: t.filter(((t) => e[t])), flagVariants: Object.keys(e).filter(((t) => e[t])).reduce(((t, i) => (t[i] = e[i], t)), {}) }; } ps(t) { var { flags: e, flagVariants: i } = this.gs(); this.featureFlagEventHandlers.forEach(((r) => r(e, i, { errorsLoading: t }))); } setPersonPropertiesForFlags(t, e) { void 0 === e && (e = !0); var i = this.os(ui$1) || {}, r = (null == t ? void 0 : t.$set) || (null != t && t.$set_once ? {} : t), s = null == t ? void 0 : t.$set_once, n = {}; if (s) for (var o in s) ({}).hasOwnProperty.call(s, o) && (o in i || (n[o] = s[o])); this._instance.register({ [ui$1]: f$1({}, i, n, r) }), e && this._instance.reloadFeatureFlags(); } resetPersonPropertiesForFlags() { this._instance.unregister(ui$1); } setGroupPropertiesForFlags(t, e) { void 0 === e && (e = !0); var i = this.os(hi$1) || {}; 0 !== Object.keys(i).length && Object.keys(i).forEach(((e) => { i[e] = f$1({}, i[e], t[e]), delete t[e]; })), this._instance.register({ [hi$1]: f$1({}, i, t) }), e && this._instance.reloadFeatureFlags(); } resetGroupPropertiesForFlags(t) { if (t) { var e = this.os(hi$1) || {}; this._instance.register({ [hi$1]: f$1({}, e, { [t]: {} }) }); } else this._instance.unregister(hi$1); } reset() { this.Kn = !1, this.Qn = !1, this.es = !1, this.ts = !1, this.rs = !1, this.$anon_distinct_id = void 0, this.fs(), this.Jn = !1; } } }, _a$1 = { sessionRecording: class { get Bt() { return this._instance.config; } get ni() { return this._instance.persistence; } get started() { var t; return !(null == (t = this.ys) || !t.isStarted); } get status() { var t, e; return this.bs === No || this.bs === jo ? this.bs : null !== (t = null == (e = this.ys) ? void 0 : e.status) && void 0 !== t ? t : this.bs; } constructor(t) { if (this._forceAllowLocalhostNetworkCapture = !1, this.bs = Lo$1, this._s = void 0, this._instance = t, !this._instance.sessionManager) throw Bo$2.error("started without valid sessionManager"), /* @__PURE__ */ new Error(zo$2 + " started without valid sessionManager. This is a bug."); if (this.Bt.cookieless_mode === Ci$1) throw new Error(zo$2 + " cannot be used with cookieless_mode=\"always\""); } initialize() { this.startIfEnabledOrStop(); } get ws() { var e, i = !(null == (e = this._instance.get_property(Ye$1)) || !e.enabled), r = !this.Bt.disable_session_recording, s = this.Bt.disable_session_recording || this._instance.consent.isOptedOut(); return t && i && r && !s; } startIfEnabledOrStop(t) { var e; if (!this.ws || null == (e = this.ys) || !e.isStarted) { var i = !C$2(Object.assign) && !C$2(Array.from); this.ws && i ? (this.Is(t), Bo$2.info("starting")) : (this.bs = Lo$1, this.stopRecording()); } } Is(t) { var e, i, r; this.ws && (this.bs !== No && this.bs !== jo && (this.bs = Uo), null != h$3 && null != (e = h$3.__PosthogExtensions__) && null != (e = e.rrweb) && e.record && null != (i = h$3.__PosthogExtensions__) && i.initSessionRecording ? this.Cs(t) : null == (r = h$3.__PosthogExtensions__) || null == r.loadExternalDependency || r.loadExternalDependency(this._instance, this.Ss, ((e) => { if (e) return Bo$2.error("could not load recorder", e); this.Cs(t); }))); } stopRecording() { var t, e; null == (t = this._s) || t.call(this), this._s = void 0, null == (e = this.ys) || e.stop(); } xs() { var t, e; null == (t = this._s) || t.call(this), this._s = void 0, null == (e = this.ys) || e.discard(); } ks() { var t; null == (t = this.ni) || t.unregister(ti$1); } Ts(t, e) { if (D$1(t)) return null; var i, r = L$1(t) ? t : parseFloat(t); return "number" != typeof (i = r) || !Number.isFinite(i) || 0 > i || i > 1 ? (Bo$2.warn(e + " must be between 0 and 1. Ignoring invalid value:", t), null) : r; } As(t) { if (this.ni) { var e, i, r = this.ni, s = () => { var e, i = !1 === t.sessionRecording ? void 0 : t.sessionRecording, s = this.Ts(null == (e = this.Bt.session_recording) ? void 0 : e.sampleRate, "session_recording.sampleRate"), n = this.Ts(null == i ? void 0 : i.sampleRate, "remote config sampleRate"), o = null != s ? s : n; D$1(o) && this.ks(); var a = null == i ? void 0 : i.minimumDurationMilliseconds; r.register({ [Ye$1]: f$1({ cache_timestamp: Date.now(), enabled: !!i }, i, { networkPayloadCapture: f$1({ capturePerformance: t.capturePerformance }, null == i ? void 0 : i.networkPayloadCapture), canvasRecording: { enabled: null == i ? void 0 : i.recordCanvas, fps: null == i ? void 0 : i.canvasFps, quality: null == i ? void 0 : i.canvasQuality }, sampleRate: o, minimumDurationMilliseconds: C$2(a) ? null : a, endpoint: null == i ? void 0 : i.endpoint, triggerMatchType: null == i ? void 0 : i.triggerMatchType, masking: null == i ? void 0 : i.masking, urlTriggers: null == i ? void 0 : i.urlTriggers, version: null == i ? void 0 : i.version, triggerGroups: null == i ? void 0 : i.triggerGroups }) }); }; s(), null == (e = this._s) || e.call(this), this._s = null == (i = this._instance.sessionManager) ? void 0 : i.onSessionId(s); } } onRemoteConfig(t) { "sessionRecording" in t ? !1 === t.sessionRecording ? (this.As(t), this.xs()) : (this.As(t), this.startIfEnabledOrStop()) : (this.bs === No && (this.bs = jo, Bo$2.warn("config refresh failed, recording will not start until page reload")), this.startIfEnabledOrStop()); } log(t, e) { var i; void 0 === e && (e = "log"), null != (i = this.ys) && i.log ? this.ys.log(t, e) : Bo$2.warn("log called before recorder was ready"); } get Ss() { var t, e, i = null == (t = this._instance) || null == (t = t.persistence) ? void 0 : t.get_property(Ye$1); return (null == i || null == (e = i.scriptConfig) ? void 0 : e.script) || "lazy-recorder"; } Es() { var t, e = this._instance.get_property(Ye$1); if (!e) return !1; var i = null !== (t = ("object" == typeof e ? e : JSON.parse(e)).cache_timestamp) && void 0 !== t ? t : Date.now(); return 36e5 >= Date.now() - i; } Cs(t) { var e, i; if (null == (e = h$3.__PosthogExtensions__) || !e.initSessionRecording) return Bo$2.warn("Called on script loaded before session recording is available. This can be caused by adblockers."), void this._instance.register_for_session({ [Pi]: !0 }); if (this.ys || (this.ys = null == (i = h$3.__PosthogExtensions__) ? void 0 : i.initSessionRecording(this._instance), this.ys._forceAllowLocalhostNetworkCapture = this._forceAllowLocalhostNetworkCapture), !this.Es()) { if (this.bs === jo || this.bs === No) return; this.bs = No, Bo$2.info("persisted remote config is stale, requesting fresh config before starting"), new vs(this._instance).load(); return; } this.bs = Uo, this.ys.start(t); } onRRwebEmit(t) { var e; null == (e = this.ys) || null == e.onRRwebEmit || e.onRRwebEmit(t); } overrideLinkedFlag() { var t, e; this.ys || null == (e = this.ni) || e.register({ [Ke]: !0 }), null == (t = this.ys) || t.overrideLinkedFlag(); } overrideSampling() { var t, e; this.ys || null == (e = this.ni) || e.register({ [Je]: !0 }), null == (t = this.ys) || t.overrideSampling(); } overrideTrigger(t) { var e, i; this.ys || null == (i = this.ni) || i.register({ ["url" === t ? Xe : Qe$1]: !0 }), null == (e = this.ys) || e.overrideTrigger(t); } get sdkDebugProperties() { var t; return (null == (t = this.ys) ? void 0 : t.sdkDebugProperties) || { $recording_status: this.status }; } tryAddCustomEvent(t, e) { var i; return !(null == (i = this.ys) || !i.tryAddCustomEvent(t, e)); } } }, ga$1 = { autocapture: class { constructor(t) { this.Rs = !1, this.Ns = null, this.Ms = !1, this.instance = t, this.rageclicks = new To$1(t.config.rageclick), this.Fs = null; } initialize() { this.startIfEnabled(); } get Bt() { var t, e, i = O$1(this.instance.config.autocapture) ? this.instance.config.autocapture : {}; return i.url_allowlist = null == (t = i.url_allowlist) ? void 0 : t.map(((t) => new RegExp(t))), i.url_ignorelist = null == (e = i.url_ignorelist) ? void 0 : e.map(((t) => new RegExp(t))), i; } Os() { if (this.isBrowserSupported()) { if (t && r$1) { var e = (e) => { e = e || (null == t ? void 0 : t.event); try { this.Ps(e); } catch (t) { Ro$1.error("Failed to capture event", t); } }; if (Xi(r$1, "submit", e, { capture: !0 }), Xi(r$1, "change", e, { capture: !0 }), Xi(r$1, "click", e, { capture: !0 }), this.Bt.capture_copied_text) { var i = (e) => { e = e || (null == t ? void 0 : t.event); try { this.Ps(e, ko$1); } catch (t) { Ro$1.error("Failed to capture copy/cut event", t); } }; Xi(r$1, "copy", i, { capture: !0 }), Xi(r$1, "cut", i, { capture: !0 }); } } } else Ro$1.info("Disabling Automatic Event Collection because this browser is not supported"); } startIfEnabled() { this.isEnabled && !this.Rs && (this.Os(), this.Rs = !0); } onRemoteConfig(t) { t.elementsChainAsString && (this.Ms = t.elementsChainAsString), this.instance.persistence && this.instance.persistence.register({ [Ne$3]: !!t.autocapture_opt_out }), this.Ns = !!t.autocapture_opt_out, this.startIfEnabled(); } setElementSelectors(t) { this.Fs = t; } getElementSelectors(t) { var e, i = []; return null == (e = this.Fs) || e.forEach(((e) => { (null == r$1 ? void 0 : r$1.querySelectorAll(e))?.forEach(((r) => { t === r && i.push(e); })); })), i; } get isEnabled() { var t, e, i = null == (t = this.instance.persistence) ? void 0 : t.props[Ne$3]; if (M(this.Ns) && !N(i) && !this.instance.Fr()) return !1; var r = null !== (e = this.Ns) && void 0 !== e ? e : !!i; return !!this.instance.config.autocapture && !r; } Ps(e, i) { if (void 0 === i && (i = "$autocapture"), this.isEnabled) { var r, s = so$1(e); Xn$1(s) && (s = s.parentNode || null), "$autocapture" === i && "click" === e.type && e instanceof MouseEvent && this.instance.config.rageclick && null != (r = this.rageclicks) && r.isRageClick(e.clientX, e.clientY, e.timeStamp || (/* @__PURE__ */ new Date()).getTime()) && function(e, i) { if (!t || ho$1(e)) return !1; var r, s, n; if (N(i) ? (r = !!i && uo$1, s = void 0) : (r = null !== (n = null == i ? void 0 : i.css_selector_ignorelist) && void 0 !== n ? n : uo$1, s = null == i ? void 0 : i.content_ignorelist), !1 === r) return !1; var { targetElementList: o } = vo$1(e, !1); return !function(t, e) { if (!1 === t || C$2(t)) return !1; var i; if (!0 === t) i = lo$1; else { if (!R$2(t)) return !1; if (t.length > 10) return Ie.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."), !1; i = t.map(((t) => t.toLowerCase())); } return e.some(((t) => { var { safeText: e, ariaLabel: r } = t; return i.some(((t) => e.includes(t) || r.includes(t))); })); }(s, o.map(((t) => { var e; return { safeText: ro$1(t).toLowerCase(), ariaLabel: (null == (e = t.getAttribute("aria-label")) ? void 0 : e.toLowerCase().trim()) || "" }; }))) && !oo$1(o, r); }(s, this.instance.config.rageclick) && this.Ps(e, "$rageclick"); var n = i === ko$1; if (s && function(e, i, r, s, n) { var o, a, l, u; if (void 0 === r && (r = void 0), !t || ho$1(e)) return !1; if (null != (o = r) && o.url_allowlist && !to$1(r.url_allowlist)) return !1; if (null != (a = r) && a.url_ignorelist && to$1(r.url_ignorelist)) return !1; if (null != (l = r) && l.dom_event_allowlist) { var h = r.dom_event_allowlist; if (h && !h.some(((t) => i.type === t))) return !1; } var { parentIsUsefulElement: d, targetElementList: v } = vo$1(e, s); if (!function(t, e) { var i = null == e ? void 0 : e.element_allowlist; if (C$2(i)) return !0; var r, s = function(t) { if (i.some(((e) => t.tagName.toLowerCase() === e))) return { v: !0 }; }; for (var n of t) if (r = s(n)) return r.v; return !1; }(v, r)) return !1; if (!oo$1(v, null == (u = r) ? void 0 : u.css_selector_allowlist)) return !1; var c = t.getComputedStyle(e); if (c && "pointer" === c.getPropertyValue("cursor") && "click" === i.type) return !0; var p = e.tagName.toLowerCase(); switch (p) { case "html": return !1; case "form": return (n || ["submit"]).indexOf(i.type) >= 0; case "input": case "select": case "textarea": return (n || ["change", "click"]).indexOf(i.type) >= 0; default: return d ? (n || ["click"]).indexOf(i.type) >= 0 : (n || ["click"]).indexOf(i.type) >= 0 && (no$1.indexOf(p) > -1 || "true" === e.getAttribute("contenteditable")); } }(s, e, this.Bt, n, n ? ["copy", "cut"] : void 0)) { var { props: o, explicitNoCapture: a } = Io(s, { e, maskAllElementAttributes: this.instance.config.mask_all_element_attributes, maskAllText: this.instance.config.mask_all_text, elementAttributeIgnoreList: this.Bt.element_attribute_ignorelist, elementsChainAsString: this.Ms }); if (a) return !1; var l = this.getElementSelectors(s); if (l && l.length > 0 && (o.$element_selectors = l), i === ko$1) { var u, h = io$1(null == t || null == (u = t.getSelection()) ? void 0 : u.toString()), d = e.type || "clipboard"; if (!h) return !1; o.$selected_content = h, o.$copy_type = d; } return this.instance.capture(i, o), !0; } } } isBrowserSupported() { return P$1(null == r$1 ? void 0 : r$1.querySelectorAll); } }, historyAutocapture: class { constructor(e) { var i; this._instance = e, this.Ls = (null == t || null == (i = t.location) ? void 0 : i.pathname) || ""; } initialize() { this.startIfEnabled(); } get isEnabled() { return "history_change" === this._instance.config.capture_pageview; } startIfEnabled() { this.isEnabled && (Ie.info("History API monitoring enabled, starting..."), this.monitorHistoryChanges()); } stop() { this.Ds && this.Ds(), this.Ds = void 0, Ie.info("History API monitoring stopped"); } monitorHistoryChanges() { var e, i; if (t && t.history) { var r = this; null != (e = t.history.pushState) && e.__posthog_wrapped__ || Fo(t.history, "pushState", ((t) => function(e, i, s) { t.call(this, e, i, s), r.Bs("pushState"); })), null != (i = t.history.replaceState) && i.__posthog_wrapped__ || Fo(t.history, "replaceState", ((t) => function(e, i, s) { t.call(this, e, i, s), r.Bs("replaceState"); })), this.js(); } } Bs(e) { try { var i, r = null == t || null == (i = t.location) ? void 0 : i.pathname; if (!r) return; r !== this.Ls && this.isEnabled && this._instance.capture(Ui, { navigation_type: e }), this.Ls = r; } catch (t) { Ie.error("Error capturing " + e + " pageview", t); } } js() { if (!this.Ds) { var e = () => { this.Bs("popstate"); }; Xi(t, "popstate", e), this.Ds = () => { t && t.removeEventListener("popstate", e); }; } } }, heatmaps: class { get Bt() { return this.instance.config; } constructor(t) { var e; this.$s = !1, this.Rs = !1, this.qs = null, this.instance = t, this.$s = !(null == (e = this.instance.persistence) || !e.props[je$2]), this.rageclicks = new To$1(t.config.rageclick); } initialize() { this.startIfEnabled(); } get flushIntervalMilliseconds() { var t = 5e3; return O$1(this.Bt.capture_heatmaps) && this.Bt.capture_heatmaps.flush_interval_milliseconds && (t = this.Bt.capture_heatmaps.flush_interval_milliseconds), t; } get isEnabled() { return D$1(this.Bt.capture_heatmaps) ? D$1(this.Bt.enable_heatmaps) ? this.$s : this.Bt.enable_heatmaps : !1 !== this.Bt.capture_heatmaps; } startIfEnabled() { if (this.isEnabled) { if (this.Rs) return; Ho.info("starting..."), this.Zs(), this.Ft(); } else { var t; clearInterval(null !== (t = this.qs) && void 0 !== t ? t : void 0), this.Vs(), this.getAndClearBuffer(); } } onRemoteConfig(t) { if ("heatmaps" in t) { var e = !!t.heatmaps; this.instance.persistence && this.instance.persistence.register({ [je$2]: e }), this.$s = e, this.startIfEnabled(); } } getAndClearBuffer() { var t = this.T; return this.T = void 0, t; } Hs(t) { this.Tt(t.originalEvent, "deadclick"); } Ft() { this.qs && clearInterval(this.qs), this.qs = "visible" === (null == r$1 ? void 0 : r$1.visibilityState) ? setInterval(this.Yr.bind(this), this.flushIntervalMilliseconds) : null; } Zs() { t && r$1 && (this.zs = this.Yr.bind(this), Xi(t, Li$1, this.zs), this.Us = (e) => this.Tt(e || (null == t ? void 0 : t.event)), Xi(r$1, "click", this.Us, { capture: !0 }), this.Ys = (e) => this.Gs(e || (null == t ? void 0 : t.event)), Xi(r$1, "mousemove", this.Ys, { capture: !0 }), this.Ws = new yr$1(this.instance, mr$1, this.Hs.bind(this)), this.Ws.startIfEnabledOrStop(), this.Xs = this.Ft.bind(this), Xi(r$1, Di, this.Xs), this.Rs = !0); } Vs() { var e; t && r$1 && (this.zs && t.removeEventListener(Li$1, this.zs), this.Us && r$1.removeEventListener("click", this.Us, { capture: !0 }), this.Ys && r$1.removeEventListener("mousemove", this.Ys, { capture: !0 }), this.Xs && r$1.removeEventListener(Di, this.Xs), clearTimeout(this.Js), null == (e = this.Ws) || e.stop(), this.Rs = !1); } Ks(e, i) { var r = this.instance.scrollManager.scrollY(), s = this.instance.scrollManager.scrollX(), n = this.instance.scrollManager.scrollElement(), o = function(e, i, r) { for (var s = e; s && Jn$1(s) && !Kn$1(s, "body");) { if (s === r) return !1; if (w$1(i, null == t ? void 0 : t.getComputedStyle(s).position)) return !0; s = ao$1(s); } return !1; }(so$1(e), ["fixed", "sticky"], n); return { x: e.clientX + (o ? 0 : s), y: e.clientY + (o ? 0 : r), target_fixed: o, type: i }; } Tt(t, e) { var i; if (void 0 === e && (e = "click"), !Yn$1(t.target) && qo$1(t)) { var r = this.Ks(t, e); null != (i = this.rageclicks) && i.isRageClick(t.clientX, t.clientY, (/* @__PURE__ */ new Date()).getTime()) && this.Qs(f$1({}, r, { type: "rageclick" })), this.Qs(r); } } Gs(t) { !Yn$1(t.target) && qo$1(t) && (clearTimeout(this.Js), this.Js = setTimeout((() => { this.Qs(this.Ks(t, "mousemove")); }), 500)); } Qs(e) { if (t) { var i = t.location.href, r = this.Bt.custom_personal_data_properties, n = Or$1(i, this.Bt.mask_personal_data_properties ? [...Fr$1, ...r || []] : [], Mr$1); this.T = this.T || {}, this.T[n] || (this.T[n] = []), this.T[n].push(e); } } Yr() { this.T && !I(this.T) && this.instance.capture("$$heatmap", { $heatmap_data: this.getAndClearBuffer() }); } }, deadClicksAutocapture: yr$1, webVitalsAutocapture: class { constructor(t) { var e; this.$s = !1, this.Rs = !1, this.T = { url: void 0, metrics: [], firstMetricTimestamp: void 0 }, this.eo = () => { clearTimeout(this.ro), 0 !== this.T.metrics.length && (this._instance.capture("$web_vitals", this.T.metrics.reduce(((t, e) => f$1({}, t, { ["$web_vitals_" + e.name + "_event"]: f$1({}, e), ["$web_vitals_" + e.name + "_value"]: e.value })), {})), this.T = { url: void 0, metrics: [], firstMetricTimestamp: void 0 }); }, this.ht = (t) => { var e, i = null == (e = this._instance.sessionManager) ? void 0 : e.checkAndGetSessionAndWindowId(!0); if (C$2(i)) Mo$1.error("Could not read session ID. Dropping metrics!"); else { this.T = this.T || { url: void 0, metrics: [], firstMetricTimestamp: void 0 }; var r = this.io(); C$2(r) || (D$1(null == t ? void 0 : t.name) || D$1(null == t ? void 0 : t.value) ? Mo$1.error("Invalid metric received", t) : !this.no || this.no > t.value ? (this.T.url !== r && (this.eo(), this.ro = setTimeout(this.eo, this.flushToCaptureTimeoutMs)), C$2(this.T.url) && (this.T.url = r), this.T.firstMetricTimestamp = C$2(this.T.firstMetricTimestamp) ? Date.now() : this.T.firstMetricTimestamp, t.attribution && t.attribution.interactionTargetElement && (t.attribution.interactionTargetElement = void 0), this.T.metrics.push(f$1({}, t, { $current_url: r, $session_id: i.sessionId, $window_id: i.windowId, timestamp: Date.now() })), this.T.metrics.length === this.allowedMetrics.length && this.eo()) : Mo$1.error("Ignoring metric with value >= " + this.no, t)); } }, this.so = () => { if (!this.Rs) { var t, e, i, r, s = h$3.__PosthogExtensions__; C$2(s) || C$2(s.postHogWebVitalsCallbacks) || ({onLCP: t, onCLS: e, onFCP: i, onINP: r} = s.postHogWebVitalsCallbacks), t && e && i && r ? (this.allowedMetrics.indexOf("LCP") > -1 && t(this.ht.bind(this)), this.allowedMetrics.indexOf("CLS") > -1 && e(this.ht.bind(this)), this.allowedMetrics.indexOf("FCP") > -1 && i(this.ht.bind(this)), this.allowedMetrics.indexOf("INP") > -1 && r(this.ht.bind(this)), this.Rs = !0) : Mo$1.error("web vitals callbacks not loaded - not starting"); } }, this._instance = t, this.$s = !(null == (e = this._instance.persistence) || !e.props[qe]), this.startIfEnabled(); } get oo() { return this._instance.config.capture_performance; } get allowedMetrics() { var t, e, i = O$1(this.oo) ? null == (t = this.oo) ? void 0 : t.web_vitals_allowed_metrics : void 0; return D$1(i) ? (null == (e = this._instance.persistence) ? void 0 : e.props[Ge]) || [ "CLS", "FCP", "INP", "LCP" ] : i; } get flushToCaptureTimeoutMs() { return (O$1(this.oo) ? this.oo.web_vitals_delayed_flush_ms : void 0) || 5e3; } get useAttribution() { var t = O$1(this.oo) ? this.oo.web_vitals_attribution : void 0; return null != t && t; } get no() { var t = O$1(this.oo) && L$1(this.oo.__web_vitals_max_value) ? this.oo.__web_vitals_max_value : Do$1; return t > 0 && 6e4 >= t ? Do$1 : t; } get isEnabled() { var t = null == s$1 ? void 0 : s$1.protocol; if ("http:" !== t && "https:" !== t) return Mo$1.info("Web Vitals are disabled on non-http/https protocols"), !1; var e = O$1(this.oo) ? this.oo.web_vitals : N(this.oo) ? this.oo : void 0; return N(e) ? e : this.$s; } startIfEnabled() { this.isEnabled && !this.Rs && (Mo$1.info("enabled, starting..."), this.ur(this.so)); } onRemoteConfig(t) { if ("capturePerformance" in t) { var e = O$1(t.capturePerformance) && !!t.capturePerformance.web_vitals, i = O$1(t.capturePerformance) ? t.capturePerformance.web_vitals_allowed_metrics : void 0; this._instance.persistence && (this._instance.persistence.register({ [qe]: e }), this._instance.persistence.register({ [Ge]: i })), this.$s = e, this.startIfEnabled(); } } ur(t) { var e, i; null != (e = h$3.__PosthogExtensions__) && e.postHogWebVitalsCallbacks ? t() : null == (i = h$3.__PosthogExtensions__) || null == i.loadExternalDependency || i.loadExternalDependency(this._instance, this.useAttribution ? "web-vitals-with-attribution" : "web-vitals", ((e) => { e ? Mo$1.error("failed to load script", e) : t(); })); } io() { var e = t ? t.location.href : void 0; if (e) { var i = this._instance.config.custom_personal_data_properties; return Or$1(e, this._instance.config.mask_personal_data_properties ? [...Fr$1, ...i || []] : [], Mr$1); } Mo$1.error("Could not determine current URL"); } } }, ma = { exceptionObserver: class { constructor(e) { var i, r, s; this.so = () => { var e; if (t && this.isEnabled && null != (e = h$3.__PosthogExtensions__) && e.errorWrappingFunctions) { var i = h$3.__PosthogExtensions__.errorWrappingFunctions.wrapOnError, r = h$3.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection, s = h$3.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError; try { !this.ao && this.Bt.capture_unhandled_errors && (this.ao = i(this.captureException.bind(this))), !this.lo && this.Bt.capture_unhandled_rejections && (this.lo = r(this.captureException.bind(this))), !this.uo && this.Bt.capture_console_errors && (this.uo = s(this.captureException.bind(this))); } catch (t) { Co$1.error("failed to start", t), this.ho(); } } }, this._instance = e, this.co = !(null == (i = this._instance.persistence) || !i.props[ze$1]), this.do = new J({ refillRate: null !== (r = this._instance.config.error_tracking.__exceptionRateLimiterRefillRate) && void 0 !== r ? r : 1, bucketSize: null !== (s = this._instance.config.error_tracking.__exceptionRateLimiterBucketSize) && void 0 !== s ? s : 10, refillInterval: 1e4, Gt: Co$1 }), this.Bt = this.vo(), this.startIfEnabledOrStop(); } vo() { var t = this._instance.config.capture_exceptions, e = { capture_unhandled_errors: !1, capture_unhandled_rejections: !1, capture_console_errors: !1 }; return O$1(t) ? e = f$1({}, e, t) : (C$2(t) ? this.co : t) && (e = f$1({}, e, { capture_unhandled_errors: !0, capture_unhandled_rejections: !0 })), e; } get isEnabled() { return this.Bt.capture_console_errors || this.Bt.capture_unhandled_errors || this.Bt.capture_unhandled_rejections; } startIfEnabledOrStop() { this.isEnabled ? (Co$1.info("enabled"), this.ho(), this.ur(this.so)) : this.ho(); } ur(t) { var e, i; null != (e = h$3.__PosthogExtensions__) && e.errorWrappingFunctions && t(), null == (i = h$3.__PosthogExtensions__) || null == i.loadExternalDependency || i.loadExternalDependency(this._instance, "exception-autocapture", ((e) => { if (e) return Co$1.error("failed to load script", e); t(); })); } ho() { var t, e, i; null == (t = this.ao) || t.call(this), this.ao = void 0, null == (e = this.lo) || e.call(this), this.lo = void 0, null == (i = this.uo) || i.call(this), this.uo = void 0; } onRemoteConfig(t) { "autocaptureExceptions" in t && (this.co = !!t.autocaptureExceptions || !1, this._instance.persistence && this._instance.persistence.register({ [ze$1]: this.co }), this.Bt = this.vo(), this.startIfEnabledOrStop()); } onConfigChange() { this.Bt = this.vo(); } captureException(t) { var e, i, r, s = null !== (e = null == t || null == (i = t.$exception_list) || null == (i = i[0]) ? void 0 : i.type) && void 0 !== e ? e : "Exception"; this.do.consumeRateLimit(s) ? Co$1.info("Skipping exception capture because of client rate limiting.", { exception: s }) : null == (r = this._instance.exceptions) || r.sendExceptionEvent(t); } }, exceptions: class { constructor(t) { var e, i; this.fo = [], this.po = new te$1([ new ve$1(), new xe(), new pe$2(), new ce$2(), new ye$2(), new be$2(), new _e$1(), new we$2() ], function(t) { for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), r = 1; e > r; r++) i[r - 1] = arguments[r]; return function(e, r) { void 0 === r && (r = 0); for (var s = [], n = e.split("\n"), o = r; n.length > o; o++) { var a = n[o]; if (1024 >= a.length) { var l = de$2.test(a) ? a.replace(de$2, "$1") : a; if (!l.match(/\S*Error: /)) { for (var u of i) { var h = u(l, t); if (h) { s.push(h); break; } } if (s.length >= 50) break; } } } return function(t) { if (!t.length) return []; var e = Array.from(t); return e.reverse(), e.slice(0, 50).map(((t) => { return f$1({}, t, { filename: t.filename || (i = e, i[i.length - 1] || {}).filename, function: t.function || ee$2 }); var i; })); }(s); }; }("web:javascript", ae$1, he$1)), this._instance = t, this.fo = null !== (e = null == (i = this._instance.persistence) ? void 0 : i.get_property(Be$1)) && void 0 !== e ? e : [], this.mo = ke$1(this.yo()), this.bo = new Re$1(this.mo); } onConfigChange() { this.mo = ke$1(this.yo()), this.bo.setConfig(this.mo); } onRemoteConfig(t) { var e, i, r; if ("errorTracking" in t) { var s = null !== (e = null == (i = t.errorTracking) ? void 0 : i.suppressionRules) && void 0 !== e ? e : [], n = null == (r = t.errorTracking) ? void 0 : r.captureExtensionExceptions; this.fo = s, this._instance.persistence && this._instance.persistence.register({ [Be$1]: this.fo, [He$3]: n }); } } get _o() { var t, e = !!this._instance.get_property(He$3), i = this._instance.config.error_tracking.captureExtensionExceptions; return null !== (t = null != i ? i : e) && void 0 !== t && t; } buildProperties(t, e) { return this.po.buildFromUnknown(t, { syntheticException: null == e ? void 0 : e.syntheticException, mechanism: { handled: null == e ? void 0 : e.handled } }); } addExceptionStep(t, e) { if (this.mo.enabled) try { if (!F$1(t) || 0 === t.trim().length) return void ua$1.warn("Ignoring exception step because message must be a non-empty string"); var { sanitizedProperties: r, droppedKeys: s } = function(t) { if (!t) return { sanitizedProperties: {}, droppedKeys: [] }; var e = []; return { sanitizedProperties: Object.keys(t).reduce(((i, r) => $e.has(r) ? (e.push(r), i) : (i[r] = t[r], i)), {}), droppedKeys: e }; }(this.wo(e)); s.length > 0 && ua$1.warn("Ignoring reserved exception step fields", { droppedKeys: s }), this.bo.add(f$1({ [Ee]: t, [Se$2]: (/* @__PURE__ */ new Date()).toISOString() }, r)); } catch (t) { ua$1.error("Failed to add exception step. Ignoring breadcrumb.", t); } } sendExceptionEvent(t) { try { var e = t.$exception_list; if (this.Io(e)) { if (this.Co(e)) return this.So("Exception dropped: matched a suppression rule"), void ua$1.info("Skipping exception capture because a suppression rule matched"); if (!this._o && this.xo(e)) return this.So("Exception dropped: thrown by a browser extension"), void ua$1.info("Skipping exception capture because it was thrown by an extension"); if (!this._instance.config.error_tracking.__capturePostHogExceptions && this.ko(e)) return this.So("Exception dropped: thrown by the PostHog SDK"), void ua$1.info("Skipping exception capture because it was thrown by the PostHog SDK"); } var i = this.mo.enabled && D$1(t.$exception_steps) ? this.To(t) : t; try { var r = this._instance.capture("$exception", i, { _noTruncate: !0, _batchKey: "exceptionEvent", en: !0 }); return r && this.bo.clear(), r; } catch (t) { ua$1.error("Failed to capture exception event. Dropping this exception.", t), this.bo.clear(); return; } } catch (t) { ua$1.error("Failed to process exception event. Ignoring this exception.", t); return; } } To(t) { try { var e = this.bo.getAttachable(); return 0 === e.length ? t : f$1({}, t, { $exception_steps: e }); } catch (e) { return ua$1.error("Failed to read buffered exception steps. Capturing exception without steps.", e), t; } } So(t) { this.mo.enabled && this.bo.add({ [Ee]: t, [Se$2]: (/* @__PURE__ */ new Date()).toISOString() }); } wo(t) { return O$1(t) ? f$1({}, t) : {}; } yo() { var t, e; return null !== (t = null == (e = this._instance.config.error_tracking) ? void 0 : e.exception_steps) && void 0 !== t ? t : {}; } Co(t) { if (0 === t.length) return !1; var e = t.reduce(((t, e) => { var { type: i, value: r } = e; return F$1(i) && i.length > 0 && t.$exception_types.push(i), F$1(r) && r.length > 0 && t.$exception_values.push(r), t; }), { $exception_types: [], $exception_values: [] }); return this.fo.some(((t) => { var i = t.values.map(((t) => { var i, r = _n$1[t.operator], s = R$2(t.value) ? t.value : [t.value], n = null !== (i = e[t.key]) && void 0 !== i ? i : []; return s.length > 0 && r(s, n); })); return "OR" === t.type ? i.some(Boolean) : i.every(Boolean); })); } xo(t) { return t.flatMap(((t) => { var e, i; return null !== (e = null == (i = t.stacktrace) ? void 0 : i.frames) && void 0 !== e ? e : []; })).some(((t) => t.filename && t.filename.startsWith("chrome-extension://"))); } ko(t) { if (t.length > 0) { var e, i, r, s, n = null !== (e = null == (i = t[0].stacktrace) ? void 0 : i.frames) && void 0 !== e ? e : [], o = n[n.length - 1]; return null !== (r = null == o || null == (s = o.filename) ? void 0 : s.includes("posthog.com/static")) && void 0 !== r && r; } return !1; } Io(t) { return !D$1(t) && R$2(t); } } }, ba$1 = f$1({ productTours: class { get ni() { return this._instance.persistence; } constructor(t) { this.Ao = null, this.Eo = null, this._instance = t; } initialize() { this.loadIfEnabled(); } onRemoteConfig(t) { "productTours" in t && (this.ni && this.ni.register({ [We$1]: !!t.productTours }), this.loadIfEnabled()); } loadIfEnabled() { var t, e; this.Ao || (t = this._instance).config.disable_product_tours || null == (e = t.persistence) || !e.get_property(We$1) || this.ur((() => this.Ro())); } ur(t) { var e, i; null != (e = h$3.__PosthogExtensions__) && e.generateProductTours ? t() : null == (i = h$3.__PosthogExtensions__) || null == i.loadExternalDependency || i.loadExternalDependency(this._instance, "product-tours", ((e) => { e ? Vo$1.error("Could not load product tours script", e) : t(); })); } Ro() { var t; !this.Ao && null != (t = h$3.__PosthogExtensions__) && t.generateProductTours && (this.Ao = h$3.__PosthogExtensions__.generateProductTours(this._instance, !0)); } getProductTours(t, e) { if (void 0 === e && (e = !1), !R$2(this.Eo) || e) { var i = this.ni; if (i) { var r = i.props[ci$1]; if (R$2(r) && !e) return this.Eo = r, void t(r, { isLoaded: !0 }); } this._instance._send_request({ url: this._instance.requestRouter.endpointFor("api", "/api/product_tours/?token=" + this._instance.config.token), method: "GET", callback: (e) => { var r = e.statusCode; if (200 !== r || !e.json) { var s = "Product Tours API could not be loaded, status: " + r; Vo$1.error(s), t([], { isLoaded: !1, error: s }); return; } var n = R$2(e.json.product_tours) ? e.json.product_tours : []; this.Eo = n, i && i.register({ [ci$1]: n }), t(n, { isLoaded: !0 }); } }); } else t(this.Eo, { isLoaded: !0 }); } getActiveProductTours(t) { D$1(this.Ao) ? t([], { isLoaded: !1, error: "Product tours not loaded" }) : this.Ao.getActiveProductTours(t); } showProductTour(t) { var e; null == (e = this.Ao) || e.showTourById(t); } previewTour(t) { this.Ao ? this.Ao.previewTour(t) : this.ur((() => { var e; this.Ro(), null == (e = this.Ao) || e.previewTour(t); })); } dismissProductTour() { var t; null == (t = this.Ao) || t.dismissTour("user_clicked_skip"); } nextStep() { var t; null == (t = this.Ao) || t.nextStep(); } previousStep() { var t; null == (t = this.Ao) || t.previousStep(); } clearCache() { var t; this.Eo = null, null == (t = this.ni) || t.unregister(ci$1); } resetTour(t) { var e; null == (e = this.Ao) || e.resetTour(t); } resetAllTours() { var t; null == (t = this.Ao) || t.resetAllTours(); } cancelPendingTour(t) { var e; null == (e = this.Ao) || e.cancelPendingTour(t); } } }, fa$1), ya = { siteApps: class { constructor(t) { this._instance = t, this.No = [], this.apps = {}; } get isEnabled() { return !!this._instance.config.opt_in_site_apps; } Mo(t, e) { if (e) { var i = this.globalsForEvent(e); this.No.push(i), this.No.length > 1e3 && (this.No = this.No.slice(10)); } } get siteAppLoaders() { var t; return null == (t = h$3._POSTHOG_REMOTE_CONFIG) || null == (t = t[this._instance.config.token]) ? void 0 : t.siteApps; } initialize() { if (this.isEnabled) { var t = this._instance._addCaptureHook(this.Mo.bind(this)); this.Fo = () => { t(), this.No = [], this.Fo = void 0; }; } } globalsForEvent(t) { var e, i, r, s, n, o, a; if (!t) throw new Error("Event payload is required"); var l = {}, u = this._instance.get_property("$groups") || [], h = this._instance.get_property("$stored_group_properties") || {}; for (var [d, v] of Object.entries(h)) l[d] = { id: u[d], type: d, properties: v }; var { $set_once: c, $set: p } = t; return { event: f$1({}, _$1(t, Wo$1), { properties: f$1({}, t.properties, p ? { $set: f$1({}, null !== (e = null == (i = t.properties) ? void 0 : i.$set) && void 0 !== e ? e : {}, p) } : {}, c ? { $set_once: f$1({}, null !== (r = null == (s = t.properties) ? void 0 : s.$set_once) && void 0 !== r ? r : {}, c) } : {}), elements_chain: null !== (n = null == (o = t.properties) ? void 0 : o.$elements_chain) && void 0 !== n ? n : "", distinct_id: null == (a = t.properties) ? void 0 : a.distinct_id }), person: { properties: this._instance.get_property("$stored_person_properties") }, groups: l }; } setupSiteApp(t) { var e = this.apps[t.id], i = () => { var i; !e.errored && this.No.length && (Go$1.info("Processing " + this.No.length + " events for site app with id " + t.id), this.No.forEach(((t) => null == e.processEvent ? void 0 : e.processEvent(t))), e.processedBuffer = !0), Object.values(this.apps).every(((t) => t.processedBuffer || t.errored)) && (null == (i = this.Fo) || i.call(this)); }, r = !1, s = (s) => { e.errored = !s, e.loaded = !0, Go$1.info("Site app with id " + t.id + " " + (s ? "loaded" : "errored")), r && i(); }; try { var { processEvent: n } = t.init({ posthog: this._instance, callback(t) { s(t); } }); n && (e.processEvent = n), r = !0; } catch (e) { Go$1.error(Yo$1 + t.id, e), s(!1); } if (r && e.loaded) try { i(); } catch (i) { Go$1.error("Error while processing buffered events PostHog app with config id " + t.id, i), e.errored = !0; } } Oo() { var t = this.siteAppLoaders || []; for (var e of t) this.apps[e.id] = { id: e.id, loaded: !1, errored: !1, processedBuffer: !1 }; for (var i of t) this.setupSiteApp(i); } Po(t) { if (0 !== Object.keys(this.apps).length) { var e = this.globalsForEvent(t); for (var i of Object.values(this.apps)) try { null == i.processEvent || i.processEvent(e); } catch (e) { Go$1.error("Error while processing event " + t.event + " for site app " + i.id, e); } } } onRemoteConfig(t) { var e, i, r, s = this; if (null != (e = this.siteAppLoaders) && e.length) return this.isEnabled ? (this.Oo(), void this._instance.on("eventCaptured", ((t) => this.Po(t)))) : void Go$1.error("PostHog site apps are disabled. Enable the \"opt_in_site_apps\" config to proceed."); if (null == (i = this.Fo) || i.call(this), null != (r = t.siteApps) && r.length) if (this.isEnabled) { var n = function(t) { var e; h$3["__$$ph_site_app_" + t] = s._instance, null == (e = h$3.__PosthogExtensions__) || null == e.loadSiteApp || e.loadSiteApp(s._instance, a, ((e) => { if (e) return Go$1.error(Yo$1 + t, e); })); }; for (var { id: o, url: a } of t.siteApps) n(o); } else Go$1.error("PostHog site apps are disabled. Enable the \"opt_in_site_apps\" config to proceed."); } } }, wa$1 = { tracingHeaders: class { constructor(t) { this.Lo = void 0, this.Do = void 0, this.so = () => { var t, e, i = this.Bo() || []; C$2(this.Lo) && (null == (t = h$3.__PosthogExtensions__) || null == (t = t.tracingHeadersPatchFns) || t._patchXHR(i, this._instance.get_distinct_id(), this._instance.sessionManager)), C$2(this.Do) && (null == (e = h$3.__PosthogExtensions__) || null == (e = e.tracingHeadersPatchFns) || e._patchFetch(i, this._instance.get_distinct_id(), this._instance.sessionManager)); }, this._instance = t; } initialize() { this.startIfEnabledOrStop(); } ur(t) { var e, i; null != (e = h$3.__PosthogExtensions__) && e.tracingHeadersPatchFns && t(), null == (i = h$3.__PosthogExtensions__) || null == i.loadExternalDependency || i.loadExternalDependency(this._instance, "tracing-headers", ((e) => { if (e) return Ao$1.error("failed to load script", e); t(); })); } Bo() { var t; return null !== (t = this._instance.config.addTracingHeaders) && void 0 !== t ? t : this._instance.config.__add_tracing_headers; } startIfEnabledOrStop() { var t, e; this.Bo() ? this.ur(this.so) : (null == (t = this.Lo) || t.call(this), null == (e = this.Do) || e.call(this), this.Lo = void 0, this.Do = void 0); } } }, xa$1 = f$1({ surveys: class { get Bt() { return this._instance.config; } constructor(t) { this.jo = void 0, this._surveyManager = null, this.$o = !1, this.qo = [], this.Zo = null, this._instance = t, this._surveyEventReceiver = null; } initialize() { this.loadIfEnabled(); } onRemoteConfig(t) { if (!this.Bt.disable_surveys) { var e = t.surveys; if (D$1(e)) return En$1.warn("Flags not loaded yet. Not loading surveys."); var i = R$2(e); this.jo = i ? e.length > 0 : e, En$1.info("flags response received, isSurveysEnabled: " + this.jo), this.loadIfEnabled(); } } reset() { localStorage.removeItem("lastSeenSurveyDate"); for (var t = [], e = 0; e < localStorage.length; e++) { var i = localStorage.key(e); (null != i && i.startsWith(Sn$1) || null != i && i.startsWith("inProgressSurvey_")) && t.push(i); } t.forEach(((t) => localStorage.removeItem(t))); } loadIfEnabled() { if (!this._surveyManager) if (this.$o) En$1.info("Already initializing surveys, skipping..."); else if (this.Bt.disable_surveys) En$1.info(ta$1); else if (this.Bt.cookieless_mode && this._instance.consent.isOptedOut()) En$1.info("Not loading surveys in cookieless mode without consent."); else { var t = null == h$3 ? void 0 : h$3.__PosthogExtensions__; if (t) { if (!C$2(this.jo) || this.Bt.advanced_enable_surveys) { var e = this.jo || this.Bt.advanced_enable_surveys; this.$o = !0; try { var i = t.generateSurveys; if (i) return void this.Vo(i, e); var r = t.loadExternalDependency; if (!r) return void this.Ho(Oi$1); r(this._instance, "surveys", ((i) => { i || !t.generateSurveys ? this.Ho("Could not load surveys script", i) : this.Vo(t.generateSurveys, e); })); } catch (t) { throw this.Ho("Error initializing surveys", t), t; } finally { this.$o = !1; } } } else En$1.error("PostHog Extensions not found."); } } Vo(t, e) { this._surveyManager = t(this._instance, e), this._surveyEventReceiver = new Qo$1(this._instance), En$1.info("Surveys loaded successfully"), this.zo({ isLoaded: !0 }); } Ho(t, e) { En$1.error(t, e), this.zo({ isLoaded: !1, error: t }); } onSurveysLoaded(t) { return this.qo.push(t), this._surveyManager && this.zo({ isLoaded: !0 }), () => { this.qo = this.qo.filter(((e) => e !== t)); }; } getSurveys(t, e) { if (void 0 === e && (e = !1), this.Bt.disable_surveys) return En$1.info(ta$1), t([]); var i, r = this._instance.get_property(di$1); if (r && !e) return t(r, { isLoaded: !0 }); "undefined" != typeof Promise && this.Zo ? this.Zo.then(((e) => { var { surveys: i, context: r } = e; return t(i, r); })) : ("undefined" != typeof Promise && (this.Zo = new Promise(((t) => { i = t; }))), this._instance._send_request({ url: this._instance.requestRouter.endpointFor("api", "/api/surveys/?token=" + this.Bt.token), method: "GET", timeout: this.Bt.surveys_request_timeout_ms, callback: (e) => { var r; this.Zo = null; var s = e.statusCode; if (200 !== s || !e.json) { var n = "Surveys API could not be loaded, status: " + s; En$1.error(n); var o = { isLoaded: !1, error: n }; t([], o), i?.({ surveys: [], context: o }); return; } var a, l = e.json.surveys || [], u = l.filter(((t) => function(t) { return !(!t.start_date || t.end_date); }(t) && (function(t) { var e; return !(null == (e = t.conditions) || null == (e = e.events) || null == (e = e.values) || !e.length); }(t) || function(t) { var e; return !(null == (e = t.conditions) || null == (e = e.actions) || null == (e = e.values) || !e.length); }(t)))); u.length > 0 && (null == (a = this._surveyEventReceiver) || a.register(u)), null == (r = this._instance.persistence) || r.register({ [di$1]: l }); var h = { isLoaded: !0 }; t(l, h), i?.({ surveys: l, context: h }); } })); } zo(t) { for (var e of this.qo) try { if (!t.isLoaded) return e([], t); this.getSurveys(e); } catch (t) { En$1.error("Error in survey callback", t); } } getActiveMatchingSurveys(t, e) { if (void 0 === e && (e = !1), !D$1(this._surveyManager)) return this._surveyManager.getActiveMatchingSurveys(t, e); En$1.warn("init was not called"); } Uo(t) { var e = null; return this.getSurveys(((i) => { var r; e = null !== (r = i.find(((e) => e.id === t))) && void 0 !== r ? r : null; })), e; } Yo(t) { if (D$1(this._surveyManager)) return { eligible: !1, reason: Zo$1 }; var e = "string" == typeof t ? this.Uo(t) : t; return e ? this._surveyManager.checkSurveyEligibility(e) : { eligible: !1, reason: "Survey not found" }; } canRenderSurvey(t) { if (D$1(this._surveyManager)) return En$1.warn("init was not called"), { visible: !1, disabledReason: Zo$1 }; var e = this.Yo(t); return { visible: e.eligible, disabledReason: e.reason }; } canRenderSurveyAsync(t, e) { return D$1(this._surveyManager) ? (En$1.warn("init was not called"), Promise.resolve({ visible: !1, disabledReason: Zo$1 })) : new Promise(((i) => { this.getSurveys(((e) => { var r, s = null !== (r = e.find(((e) => e.id === t))) && void 0 !== r ? r : null; if (s) { var n = this.Yo(s); i({ visible: n.eligible, disabledReason: n.reason }); } else i({ visible: !1, disabledReason: "Survey not found" }); }), e); })); } renderSurvey(t, e, i) { var s; if (D$1(this._surveyManager)) En$1.warn("init was not called"); else { var n = "string" == typeof t ? this.Uo(t) : t; if (null != n && n.id) if ($n$1.includes(n.type)) { var o = null == r$1 ? void 0 : r$1.querySelector(e); if (o) return null != (s = n.appearance) && s.surveyPopupDelaySeconds ? (En$1.info("Rendering survey " + n.id + " with delay of " + n.appearance.surveyPopupDelaySeconds + " seconds"), void setTimeout((() => { var t, e; En$1.info("Rendering survey " + n.id + " with delay of " + (null == (t = n.appearance) ? void 0 : t.surveyPopupDelaySeconds) + " seconds"), null == (e = this._surveyManager) || e.renderSurvey(n, o, i), En$1.info("Survey " + n.id + " rendered"); }), 1e3 * n.appearance.surveyPopupDelaySeconds)) : void this._surveyManager.renderSurvey(n, o, i); En$1.warn("Survey element not found"); } else En$1.warn("Surveys of type " + n.type + " cannot be rendered in the app"); else En$1.warn("Survey not found"); } } displaySurvey(t, e) { var i; if (D$1(this._surveyManager)) En$1.warn("init was not called"); else { var r = this.Uo(t); if (r) { var s = r; if (null != (i = r.appearance) && i.surveyPopupDelaySeconds && e.ignoreDelay && (s = f$1({}, r, { appearance: f$1({}, r.appearance, { surveyPopupDelaySeconds: 0 }) })), e.displayType !== ns.Popover && e.initialResponses && En$1.warn("initialResponses is only supported for popover surveys. prefill will not be applied."), !1 === e.ignoreConditions) { var n = this.canRenderSurvey(r); if (!n.visible) return void En$1.warn("Survey is not eligible to be displayed: ", n.disabledReason); } e.displayType !== ns.Inline ? this._surveyManager.handlePopoverSurvey(s, e) : this.renderSurvey(s, e.selector, e.properties); } else En$1.warn("Survey not found"); } } cancelPendingSurvey(t) { D$1(this._surveyManager) ? En$1.warn("init was not called") : this._surveyManager.cancelSurvey(t); } handlePageUnload() { var t; null == (t = this._surveyManager) || t.handlePageUnload(); } } }, fa$1), Ea$1 = { toolbar: class { constructor(t) { this.instance = t; } Go(t) { h$3.ph_toolbar_state = t; } Wo() { var t; return null !== (t = h$3.ph_toolbar_state) && void 0 !== t ? t : 0; } initialize() { return this.maybeLoadToolbar(); } maybeLoadToolbar(e, i, s) { if (void 0 === e && (e = void 0), void 0 === i && (i = void 0), void 0 === s && (s = void 0), Qi(this.instance.config)) return !1; if (!t || !r$1) return !1; e = null != e ? e : t.location, s = null != s ? s : t.history; try { if (!i) { try { t.localStorage.setItem("test", "test"), t.localStorage.removeItem("test"); } catch (t) { return !1; } i = null == t ? void 0 : t.localStorage; } var n, o = ea$1 || Ir(e.hash, "__posthog") || Ir(e.hash, "state"), a = o ? Wi((() => JSON.parse(atob(decodeURIComponent(o))))) || Wi((() => JSON.parse(decodeURIComponent(o)))) : null; return a && "ph_authorize" === a.action ? ((n = a).source = "url", n && Object.keys(n).length > 0 && (a.desiredHash ? e.hash = a.desiredHash : s ? s.replaceState(s.state, "", e.pathname + e.search) : e.hash = "")) : ((n = JSON.parse(i.getItem(ia$1) || "{}")).source = "localstorage", delete n.userIntent), !(!n.token || this.instance.config.token !== n.token || (this.loadToolbar(n), 0)); } catch (t) { return !1; } } Xo(t) { var e = h$3.ph_load_toolbar || h$3.ph_load_editor; !D$1(e) && P$1(e) ? e(t, this.instance) : ra$1.warn("No toolbar load function found"); } loadToolbar(e) { var i = !(null == r$1 || !r$1.getElementById($i)); if (!t || i) return !1; var s = "custom" === this.instance.requestRouter.region && this.instance.config.advanced_disable_toolbar_metrics, n = f$1({ token: this.instance.config.token }, e, { apiURL: this.instance.requestRouter.endpointFor("ui") }, s ? { instrument: !1 } : {}); if (t.localStorage.setItem(ia$1, JSON.stringify(f$1({}, n, { source: void 0 }))), 2 === this.Wo()) this.Xo(n); else if (0 === this.Wo()) { var o; this.Go(1), null == (o = h$3.__PosthogExtensions__) || null == o.loadExternalDependency || o.loadExternalDependency(this.instance, "toolbar", ((t) => { if (t) return ra$1.error("[Toolbar] Failed to load", t), void this.Go(0); this.Go(2), this.Xo(n); })), Xi(t, "turbolinks:load", (() => { this.Go(0), this.loadToolbar(n); })); } return !0; } Jo(t) { return this.loadToolbar(t); } maybeLoadEditor(t, e, i) { return void 0 === t && (t = void 0), void 0 === e && (e = void 0), void 0 === i && (i = void 0), this.maybeLoadToolbar(t, e, i); } } }, Sa$1 = f$1({ experiments: va$1 }, fa$1), ka$1 = f$1({}, fa$1, _a$1, ga$1, ma, ba$1, ya, xa$1, wa$1, Ea$1, Sa$1, { conversations: class { constructor(t) { this.Ko = void 0, this._conversationsManager = null, this.Qo = !1, this.ea = null, this._instance = t; } initialize() { this.loadIfEnabled(); } onRemoteConfig(t) { if (!this._instance.config.disable_conversations) { var e = t.conversations; D$1(e) || (N(e) ? this.Ko = e : (this.Ko = e.enabled, this.ea = e), this.loadIfEnabled()); } } reset() { var t; null == (t = this._conversationsManager) || t.reset(), this._conversationsManager = null, this.Ko = void 0, this.ea = null; } loadIfEnabled() { if (!(this._conversationsManager || this.Qo || this._instance.config.disable_conversations || Qi(this._instance.config) || this._instance.config.cookieless_mode && this._instance.consent.isOptedOut())) { var t = null == h$3 ? void 0 : h$3.__PosthogExtensions__; if (t && !C$2(this.Ko) && this.Ko) if (this.ea && this.ea.token) { this.Qo = !0; try { var e = t.initConversations; if (e) return this.ta(e), void (this.Qo = !1); var i = t.loadExternalDependency; if (!i) return void this.ra(Oi$1); i(this._instance, "conversations", ((e) => { e || !t.initConversations ? this.ra("Could not load conversations script", e) : this.ta(t.initConversations), this.Qo = !1; })); } catch (t) { this.ra("Error initializing conversations", t), this.Qo = !1; } } else ca.error("Conversations enabled but missing token in remote config."); } } ta(t) { if (this.ea) try { this._conversationsManager = t(this.ea, this._instance), ca.info("Conversations loaded successfully"); } catch (t) { this.ra("Error completing conversations initialization", t); } else ca.error("Cannot complete initialization: remote config is null"); } ra(t, e) { ca.error(t, e), this._conversationsManager = null, this.Qo = !1; } show() { this._conversationsManager ? this._conversationsManager.show() : ca.warn("Conversations not loaded yet."); } hide() { this._conversationsManager && this._conversationsManager.hide(); } isAvailable() { return !0 === this.Ko && !M(this._conversationsManager); } isVisible() { var t, e; return null !== (t = null == (e = this._conversationsManager) ? void 0 : e.isVisible()) && void 0 !== t && t; } sendMessage(t, e, i) { var r = this; return p$2((function* () { return r._conversationsManager ? r._conversationsManager.sendMessage(t, e, i) : (ca.warn(pa$1), null); }))(); } getMessages(t, e) { var i = this; return p$2((function* () { return i._conversationsManager ? i._conversationsManager.getMessages(t, e) : (ca.warn(pa$1), null); }))(); } markAsRead(t) { var e = this; return p$2((function* () { return e._conversationsManager ? e._conversationsManager.markAsRead(t) : (ca.warn(pa$1), null); }))(); } getTickets(t) { var e = this; return p$2((function* () { return e._conversationsManager ? e._conversationsManager.getTickets(t) : (ca.warn(pa$1), null); }))(); } requestRestoreLink(t) { var e = this; return p$2((function* () { return e._conversationsManager ? e._conversationsManager.requestRestoreLink(t) : (ca.warn(pa$1), null); }))(); } restoreFromToken(t) { var e = this; return p$2((function* () { return e._conversationsManager ? e._conversationsManager.restoreFromToken(t) : (ca.warn(pa$1), null); }))(); } restoreFromUrlToken() { var t = this; return p$2((function* () { return t._conversationsManager ? t._conversationsManager.restoreFromUrlToken() : (ca.warn(pa$1), null); }))(); } getCurrentTicketId() { var t, e; return null !== (t = null == (e = this._conversationsManager) ? void 0 : e.getCurrentTicketId()) && void 0 !== t ? t : null; } getWidgetSessionId() { var t, e; return null !== (t = null == (e = this._conversationsManager) ? void 0 : e.getWidgetSessionId()) && void 0 !== t ? t : null; } un() { var t; null == (t = this._conversationsManager) || t.setIdentity(); } hn() { var t; null == (t = this._conversationsManager) || t.clearIdentity(); } } }, { logs: class { constructor(t) { var e; this.ia = !1, this.na = !1, this.Gt = Ce$2("[logs]"), this.sa = [], this.oa = 0, this.aa = 0, this.la = !1, this._instance = t, this._instance && null != (e = this._instance.config.logs) && e.captureConsoleLogs && (this.ia = !0); } initialize() { this.loadIfEnabled(); } onRemoteConfig(t) { var e, i = null == (e = t.logs) ? void 0 : e.captureConsoleLogs; !D$1(i) && i && (this.ia = !0, this.loadIfEnabled()); } reset() { this.sa = [], this.jr && (clearTimeout(this.jr), this.jr = void 0), this.oa = 0, this.aa = 0, this.la = !1; } loadIfEnabled() { if (this.ia && !this.na) { var t = null == h$3 ? void 0 : h$3.__PosthogExtensions__; if (t) { var e = t.loadExternalDependency; e ? e(this._instance, "logs", ((e) => { var i; e || null == (i = t.logs) || !i.initializeLogs ? this.Gt.error("Could not load logs script", e) : (t.logs.initializeLogs(this._instance), this.na = !0); })) : this.Gt.error(Oi$1); } else this.Gt.error("PostHog Extensions not found."); } } captureLog(t) { var e, i, r, s, n, o; if (this._instance.is_capturing()) if (t && t.body) { var a = null !== (e = null == (i = this._instance.config.logs) ? void 0 : i.flushIntervalMs) && void 0 !== e ? e : 3e3, l = null !== (r = null == (s = this._instance.config.logs) ? void 0 : s.maxLogsPerInterval) && void 0 !== r ? r : 1e3, u = Date.now(); if (a > u - this.aa || (this.aa = u, this.oa = 0, this.la = !1), l > this.oa) { this.oa++; var h = function(t, e) { var { text: r, number: s } = Jt[t.level || "info"] || Kt, n = String(Date.now()) + "000000", o = {}; e.distinctId && (o.posthogDistinctId = e.distinctId), e.sessionId && (o.sessionId = e.sessionId), e.currentUrl && (o["url.full"] = e.currentUrl), e.screenName && (o["screen.name"] = e.screenName), e.appState && (o["app.state"] = e.appState), e.activeFeatureFlags && e.activeFeatureFlags.length > 0 && (o.feature_flags = e.activeFeatureFlags); var a = f$1({}, o, t.attributes || {}), l = { timeUnixNano: n, observedTimeUnixNano: n, severityNumber: s, severityText: r, body: { stringValue: t.body }, attributes: Qt(a) }; return t.trace_id && (l.traceId = t.trace_id), t.span_id && (l.spanId = t.span_id), C$2(t.trace_flags) || (l.flags = t.trace_flags), l; }(t, this.ua()); this.sa.push({ record: h }), (null !== (n = null == (o = this._instance.config.logs) ? void 0 : o.maxBufferSize) && void 0 !== n ? n : 100) > this.sa.length ? this.ha() : this.flushLogs(); } else this.la || (this.Gt.warn("captureLog dropping logs: exceeded " + l + " logs per " + a + "ms"), this.la = !0); } else this.Gt.warn("captureLog requires a body"); } get logger() { return this.ca || (this.ca = { trace: (t, e) => this.captureLog({ body: t, level: "trace", attributes: e }), debug: (t, e) => this.captureLog({ body: t, level: "debug", attributes: e }), info: (t, e) => this.captureLog({ body: t, level: "info", attributes: e }), warn: (t, e) => this.captureLog({ body: t, level: "warn", attributes: e }), error: (t, e) => this.captureLog({ body: t, level: "error", attributes: e }), fatal: (t, e) => this.captureLog({ body: t, level: "fatal", attributes: e }) }), this.ca; } flushLogs(t) { if (this.jr && (clearTimeout(this.jr), this.jr = void 0), 0 !== this.sa.length) { var e = this.sa; this.sa = []; var i = this._instance.config.logs, r = f$1({ "service.name": (null == i ? void 0 : i.serviceName) || "unknown_service" }, (null == i ? void 0 : i.environment) && { "deployment.environment": i.environment }, (null == i ? void 0 : i.serviceVersion) && { "service.version": i.serviceVersion }, null == i ? void 0 : i.resourceAttributes), s = function(t, e, i, r) { return { resourceLogs: [{ resource: { attributes: Qt(e) }, scopeLogs: [{ scope: { name: i, version: r }, logRecords: t }] }] }; }(e.map(((t) => t.record)), r, v$1.LIB_NAME, v$1.LIB_VERSION), n = this._instance.requestRouter.endpointFor("api", "/i/v1/logs") + "?token=" + encodeURIComponent(this._instance.config.token); this._instance.Vi({ method: "POST", url: n, data: s, compression: "best-available", batchKey: "logs", transport: t }); } } ha() { var t, e; this.jr || (this.jr = setTimeout((() => { this.jr = void 0, this.flushLogs(); }), null !== (t = null == (e = this._instance.config.logs) ? void 0 : e.flushIntervalMs) && void 0 !== t ? t : 3e3)); } ua() { var t, e = {}; if (e.distinctId = this._instance.get_distinct_id(), this._instance.sessionManager) { var { sessionId: i } = this._instance.sessionManager.checkAndGetSessionAndWindowId(!0); e.sessionId = i; } if (null != h$3 && null != (t = h$3.location) && t.href && (e.currentUrl = h$3.location.href), this._instance.featureFlags) { var r = this._instance.featureFlags.getFlags(); r && r.length > 0 && (e.activeFeatureFlags = r); } return e; } } }); qn$1.__defaultExtensionClasses = f$1({}, ka$1); var Ra$1, Pa$1 = (Ra$1 = In$1[Un] = new qn$1(), function() { function e() { e.done || (e.done = !0, Nn$1 = !1, Hi(In$1, (function(t) { t._dom_loaded(); }))); } null != r$1 && r$1.addEventListener ? "complete" === r$1.readyState ? e() : Xi(r$1, "DOMContentLoaded", e, { capture: !1 }) : t && Ie.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized"); }(), Ra$1); //#endregion //#region ../send/frontend/src/plugins/posthog.js var initialized = false; function initPosthog() { if (initialized) return; Pa$1.init("phc_61NZH7teRtwmtZQHpKRltXUEEO7acpEAjpjdSiE5tdu", { api_host: "https://us.i.posthog.com", persistence: "memory" }); Pa$1.register({ service: "send" }); initialized = true; } /** * Enables or disables PostHog capture at runtime in response to the Thunderbird * telemetry opt-out preference (see issue #892). * * When enabled, PostHog is initialized lazily on first opt-in — so while opted * out it is never initialized and makes zero network requests. When disabled, * capture is opted out and the stored distinct id is reset. * * `capture()` / `identify()` calls on the shared instance before init are * no-ops, so callers throughout the app remain safe regardless of consent. */ function setPosthogConsent(enabled) { if (enabled) { initPosthog(); Pa$1.opt_in_capturing(); } else if (initialized) { Pa$1.opt_out_capturing(); Pa$1.reset(); } } var posthog_default = { install(app) { app.config.globalProperties.$posthog = Pa$1; }, rest: Pa$1 }; //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/subscribable.js var Subscribable = class { constructor() { this.listeners = /* @__PURE__ */ new Set(); this.subscribe = this.subscribe.bind(this); } subscribe(listener) { this.listeners.add(listener); this.onSubscribe(); return () => { this.listeners.delete(listener); this.onUnsubscribe(); }; } hasListeners() { return this.listeners.size > 0; } onSubscribe() {} onUnsubscribe() {} }; //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/focusManager.js var FocusManager = class extends Subscribable { #focused; #cleanup; #setup; constructor() { super(); this.#setup = (onFocus) => { if (typeof window !== "undefined" && window.addEventListener) { const listener = () => onFocus(); window.addEventListener("visibilitychange", listener, false); return () => { window.removeEventListener("visibilitychange", listener); }; } }; } onSubscribe() { if (!this.#cleanup) this.setEventListener(this.#setup); } onUnsubscribe() { if (!this.hasListeners()) { this.#cleanup?.(); this.#cleanup = void 0; } } setEventListener(setup) { this.#setup = setup; this.#cleanup?.(); this.#cleanup = setup((focused) => { if (typeof focused === "boolean") this.setFocused(focused); else this.onFocus(); }); } setFocused(focused) { if (this.#focused !== focused) { this.#focused = focused; this.onFocus(); } } onFocus() { const isFocused = this.isFocused(); this.listeners.forEach((listener) => { listener(isFocused); }); } isFocused() { if (typeof this.#focused === "boolean") return this.#focused; return globalThis.document?.visibilityState !== "hidden"; } }; var focusManager = new FocusManager(); //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/timeoutManager.js var defaultTimeoutProvider = { setTimeout: (callback, delay) => setTimeout(callback, delay), clearTimeout: (timeoutId) => clearTimeout(timeoutId), setInterval: (callback, delay) => setInterval(callback, delay), clearInterval: (intervalId) => clearInterval(intervalId) }; var TimeoutManager = class { #provider = defaultTimeoutProvider; #providerCalled = false; setTimeoutProvider(provider) { this.#provider = provider; } setTimeout(callback, delay) { return this.#provider.setTimeout(callback, delay); } clearTimeout(timeoutId) { this.#provider.clearTimeout(timeoutId); } setInterval(callback, delay) { return this.#provider.setInterval(callback, delay); } clearInterval(intervalId) { this.#provider.clearInterval(intervalId); } }; var timeoutManager = new TimeoutManager(); function systemSetTimeoutZero(callback) { setTimeout(callback, 0); } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/utils.js var isServer = typeof window === "undefined" || "Deno" in globalThis; function noop$3() {} function functionalUpdate(updater, input) { return typeof updater === "function" ? updater(input) : updater; } function isValidTimeout(value) { return typeof value === "number" && value >= 0 && value !== Infinity; } function timeUntilStale(updatedAt, staleTime) { return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0); } function resolveStaleTime(staleTime, query) { return typeof staleTime === "function" ? staleTime(query) : staleTime; } function resolveQueryBoolean(option, query) { return typeof option === "function" ? option(query) : option; } function matchQuery(filters, query) { const { type = "all", exact, fetchStatus, predicate, queryKey, stale } = filters; if (queryKey) { if (exact) { if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) return false; } else if (!partialMatchKey(query.queryKey, queryKey)) return false; } if (type !== "all") { const isActive = query.isActive(); if (type === "active" && !isActive) return false; if (type === "inactive" && isActive) return false; } if (typeof stale === "boolean" && query.isStale() !== stale) return false; if (fetchStatus && fetchStatus !== query.state.fetchStatus) return false; if (predicate && !predicate(query)) return false; return true; } function matchMutation(filters, mutation) { const { exact, status, predicate, mutationKey } = filters; if (mutationKey) { if (!mutation.options.mutationKey) return false; if (exact) { if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) return false; } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) return false; } if (status && mutation.state.status !== status) return false; if (predicate && !predicate(mutation)) return false; return true; } function hashQueryKeyByOptions(queryKey, options) { return (options?.queryKeyHashFn || hashKey)(queryKey); } function hashKey(queryKey) { return JSON.stringify(queryKey, (_, val) => isPlainObject$4(val) ? Object.keys(val).sort().reduce((result, key) => { result[key] = val[key]; return result; }, {}) : val); } function partialMatchKey(a, b) { if (a === b) return true; if (typeof a !== typeof b) return false; if (a && b && typeof a === "object" && typeof b === "object") return Object.keys(b).every((key) => partialMatchKey(a[key], b[key])); return false; } var hasOwn$1 = Object.prototype.hasOwnProperty; function replaceEqualDeep(a, b, depth = 0) { if (a === b) return a; if (depth > 500) return b; const array = isPlainArray(a) && isPlainArray(b); if (!array && !(isPlainObject$4(a) && isPlainObject$4(b))) return b; const aSize = (array ? a : Object.keys(a)).length; const bItems = array ? b : Object.keys(b); const bSize = bItems.length; const copy = array ? new Array(bSize) : {}; let equalItems = 0; for (let i = 0; i < bSize; i++) { const key = array ? i : bItems[i]; const aItem = a[key]; const bItem = b[key]; if (aItem === bItem) { copy[key] = aItem; if (array ? i < aSize : hasOwn$1.call(a, key)) equalItems++; continue; } if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") { copy[key] = bItem; continue; } const v = replaceEqualDeep(aItem, bItem, depth + 1); copy[key] = v; if (v === aItem) equalItems++; } return aSize === bSize && equalItems === aSize ? a : copy; } function shallowEqualObjects(a, b) { if (!b || Object.keys(a).length !== Object.keys(b).length) return false; for (const key in a) if (a[key] !== b[key]) return false; return true; } function isPlainArray(value) { return Array.isArray(value) && value.length === Object.keys(value).length; } function isPlainObject$4(o) { if (!hasObjectPrototype(o)) return false; const ctor = o.constructor; if (ctor === void 0) return true; const prot = ctor.prototype; if (!hasObjectPrototype(prot)) return false; if (!prot.hasOwnProperty("isPrototypeOf")) return false; if (Object.getPrototypeOf(o) !== Object.prototype) return false; return true; } function hasObjectPrototype(o) { return Object.prototype.toString.call(o) === "[object Object]"; } function sleep$1(timeout) { return new Promise((resolve) => { timeoutManager.setTimeout(resolve, timeout); }); } function replaceData(prevData, data, options) { if (typeof options.structuralSharing === "function") return options.structuralSharing(prevData, data); else if (options.structuralSharing !== false) return replaceEqualDeep(prevData, data); return data; } function addToEnd(items, item, max = 0) { const newItems = [...items, item]; return max && newItems.length > max ? newItems.slice(1) : newItems; } function addToStart(items, item, max = 0) { const newItems = [item, ...items]; return max && newItems.length > max ? newItems.slice(0, -1) : newItems; } var skipToken = /* @__PURE__ */ Symbol(); function ensureQueryFn(options, fetchOptions) { if (!options.queryFn && fetchOptions?.initialPromise) return () => fetchOptions.initialPromise; if (!options.queryFn || options.queryFn === skipToken) return () => Promise.reject(/* @__PURE__ */ new Error(`Missing queryFn: '${options.queryHash}'`)); return options.queryFn; } function shouldThrowError(throwOnError, params) { if (typeof throwOnError === "function") return throwOnError(...params); return !!throwOnError; } function addConsumeAwareSignal(object, getSignal, onCancelled) { let consumed = false; let signal; Object.defineProperty(object, "signal", { enumerable: true, get: () => { signal ??= getSignal(); if (consumed) return signal; consumed = true; if (signal.aborted) onCancelled(); else signal.addEventListener("abort", onCancelled, { once: true }); return signal; } }); return object; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/environmentManager.js var environmentManager = /* @__PURE__ */ (() => { let isServerFn = () => isServer; return { /** * Returns whether the current runtime should be treated as a server environment. */ isServer() { return isServerFn(); }, /** * Overrides the server check globally. */ setIsServer(isServerValue) { isServerFn = isServerValue; } }; })(); //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/thenable.js function pendingThenable() { let resolve; let reject; const thenable = new Promise((_resolve, _reject) => { resolve = _resolve; reject = _reject; }); thenable.status = "pending"; thenable.catch(() => {}); function finalize(data) { Object.assign(thenable, data); delete thenable.resolve; delete thenable.reject; } thenable.resolve = (value) => { finalize({ status: "fulfilled", value }); resolve(value); }; thenable.reject = (reason) => { finalize({ status: "rejected", reason }); reject(reason); }; return thenable; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/notifyManager.js var defaultScheduler = systemSetTimeoutZero; function createNotifyManager() { let queue = []; let transactions = 0; let notifyFn = (callback) => { callback(); }; let batchNotifyFn = (callback) => { callback(); }; let scheduleFn = defaultScheduler; const schedule = (callback) => { if (transactions) queue.push(callback); else scheduleFn(() => { notifyFn(callback); }); }; const flush = () => { const originalQueue = queue; queue = []; if (originalQueue.length) scheduleFn(() => { batchNotifyFn(() => { originalQueue.forEach((callback) => { notifyFn(callback); }); }); }); }; return { batch: (callback) => { let result; transactions++; try { result = callback(); } finally { transactions--; if (!transactions) flush(); } return result; }, /** * All calls to the wrapped function will be batched. */ batchCalls: (callback) => { return (...args) => { schedule(() => { callback(...args); }); }; }, schedule, /** * Use this method to set a custom notify function. * This can be used to for example wrap notifications with `React.act` while running tests. */ setNotifyFunction: (fn) => { notifyFn = fn; }, /** * Use this method to set a custom function to batch notifications together into a single tick. * By default React Query will use the batch function provided by ReactDOM or React Native. */ setBatchNotifyFunction: (fn) => { batchNotifyFn = fn; }, setScheduler: (fn) => { scheduleFn = fn; } }; } var notifyManager = createNotifyManager(); //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/onlineManager.js var OnlineManager = class extends Subscribable { #online = true; #cleanup; #setup; constructor() { super(); this.#setup = (onOnline) => { if (typeof window !== "undefined" && window.addEventListener) { const onlineListener = () => onOnline(true); const offlineListener = () => onOnline(false); window.addEventListener("online", onlineListener, false); window.addEventListener("offline", offlineListener, false); return () => { window.removeEventListener("online", onlineListener); window.removeEventListener("offline", offlineListener); }; } }; } onSubscribe() { if (!this.#cleanup) this.setEventListener(this.#setup); } onUnsubscribe() { if (!this.hasListeners()) { this.#cleanup?.(); this.#cleanup = void 0; } } setEventListener(setup) { this.#setup = setup; this.#cleanup?.(); this.#cleanup = setup(this.setOnline.bind(this)); } setOnline(online) { if (this.#online !== online) { this.#online = online; this.listeners.forEach((listener) => { listener(online); }); } } isOnline() { return this.#online; } }; var onlineManager = new OnlineManager(); //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/retryer.js function defaultRetryDelay(failureCount) { return Math.min(1e3 * 2 ** failureCount, 3e4); } function canFetch(networkMode) { return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true; } var CancelledError = class extends Error { constructor(options) { super("CancelledError"); this.revert = options?.revert; this.silent = options?.silent; } }; function createRetryer(config) { let isRetryCancelled = false; let failureCount = 0; let continueFn; const thenable = pendingThenable(); const isResolved = () => thenable.status !== "pending"; const cancel = (cancelOptions) => { if (!isResolved()) { const error = new CancelledError(cancelOptions); reject(error); config.onCancel?.(error); } }; const cancelRetry = () => { isRetryCancelled = true; }; const continueRetry = () => { isRetryCancelled = false; }; const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun(); const canStart = () => canFetch(config.networkMode) && config.canRun(); const resolve = (value) => { if (!isResolved()) { continueFn?.(); thenable.resolve(value); } }; const reject = (value) => { if (!isResolved()) { continueFn?.(); thenable.reject(value); } }; const pause = () => { return new Promise((continueResolve) => { continueFn = (value) => { if (isResolved() || canContinue()) continueResolve(value); }; config.onPause?.(); }).then(() => { continueFn = void 0; if (!isResolved()) config.onContinue?.(); }); }; const run = () => { if (isResolved()) return; let promiseOrValue; const initialPromise = failureCount === 0 ? config.initialPromise : void 0; try { promiseOrValue = initialPromise ?? config.fn(); } catch (error) { promiseOrValue = Promise.reject(error); } Promise.resolve(promiseOrValue).then(resolve).catch((error) => { if (isResolved()) return; const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3); const retryDelay = config.retryDelay ?? defaultRetryDelay; const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay; const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error); if (isRetryCancelled || !shouldRetry) { reject(error); return; } failureCount++; config.onFail?.(failureCount, error); sleep$1(delay).then(() => { return canContinue() ? void 0 : pause(); }).then(() => { if (isRetryCancelled) reject(error); else run(); }); }); }; return { promise: thenable, status: () => thenable.status, cancel, continue: () => { continueFn?.(); return thenable; }, cancelRetry, continueRetry, canStart, start: () => { if (canStart()) run(); else pause().then(run); return thenable; } }; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/removable.js var Removable = class { #gcTimeout; destroy() { this.clearGcTimeout(); } scheduleGc() { this.clearGcTimeout(); if (isValidTimeout(this.gcTime)) this.#gcTimeout = timeoutManager.setTimeout(() => { this.optionalRemove(); }, this.gcTime); } updateGcTime(newGcTime) { this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (environmentManager.isServer() ? Infinity : 300 * 1e3)); } clearGcTimeout() { if (this.#gcTimeout !== void 0) { timeoutManager.clearTimeout(this.#gcTimeout); this.#gcTimeout = void 0; } } }; //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js function infiniteQueryBehavior(pages) { return { onFetch: (context, query) => { const options = context.options; const direction = context.fetchOptions?.meta?.fetchMore?.direction; const oldPages = context.state.data?.pages || []; const oldPageParams = context.state.data?.pageParams || []; let result = { pages: [], pageParams: [] }; let currentPage = 0; const fetchFn = async () => { let cancelled = false; const addSignalProperty = (object) => { addConsumeAwareSignal(object, () => context.signal, () => cancelled = true); }; const queryFn = ensureQueryFn(context.options, context.fetchOptions); const fetchPage = async (data, param, previous) => { if (cancelled) return Promise.reject(context.signal.reason); if (param == null && data.pages.length) return Promise.resolve(data); const createQueryFnContext = () => { const queryFnContext2 = { client: context.client, queryKey: context.queryKey, pageParam: param, direction: previous ? "backward" : "forward", meta: context.options.meta }; addSignalProperty(queryFnContext2); return queryFnContext2; }; const page = await queryFn(createQueryFnContext()); const { maxPages } = context.options; const addTo = previous ? addToStart : addToEnd; return { pages: addTo(data.pages, page, maxPages), pageParams: addTo(data.pageParams, param, maxPages) }; }; if (direction && oldPages.length) { const previous = direction === "backward"; const pageParamFn = previous ? getPreviousPageParam : getNextPageParam; const oldData = { pages: oldPages, pageParams: oldPageParams }; result = await fetchPage(oldData, pageParamFn(options, oldData), previous); } else { const remainingPages = pages ?? oldPages.length; do { const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result); if (currentPage > 0 && param == null) break; result = await fetchPage(result, param); currentPage++; } while (currentPage < remainingPages); } return result; }; if (context.options.persister) context.fetchFn = () => { return context.options.persister?.(fetchFn, { client: context.client, queryKey: context.queryKey, meta: context.options.meta, signal: context.signal }, query); }; else context.fetchFn = fetchFn; } }; } function getNextPageParam(options, { pages, pageParams }) { const lastIndex = pages.length - 1; return pages.length > 0 ? options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams) : void 0; } function getPreviousPageParam(options, { pages, pageParams }) { return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/query.js var Query = class extends Removable { #queryType; #initialState; #revertState; #cache; #client; #retryer; #defaultOptions; #abortSignalConsumed; constructor(config) { super(); this.#abortSignalConsumed = false; this.#defaultOptions = config.defaultOptions; this.setOptions(config.options); this.observers = []; this.#client = config.client; this.#cache = this.#client.getQueryCache(); this.queryKey = config.queryKey; this.queryHash = config.queryHash; this.#initialState = getDefaultState$1(this.options); this.state = config.state ?? this.#initialState; this.scheduleGc(); } get meta() { return this.options.meta; } get queryType() { return this.#queryType; } get promise() { return this.#retryer?.promise; } setOptions(options) { this.options = { ...this.#defaultOptions, ...options }; if (options?._type) this.#queryType = options._type; this.updateGcTime(this.options.gcTime); if (this.state && this.state.data === void 0) { const defaultState = getDefaultState$1(this.options); if (defaultState.data !== void 0) { this.setState(successState(defaultState.data, defaultState.dataUpdatedAt)); this.#initialState = defaultState; } } } optionalRemove() { if (!this.observers.length && this.state.fetchStatus === "idle") this.#cache.remove(this); } setData(newData, options) { const data = replaceData(this.state.data, newData, this.options); this.#dispatch({ data, type: "success", dataUpdatedAt: options?.updatedAt, manual: options?.manual }); return data; } setState(state) { this.#dispatch({ type: "setState", state }); } cancel(options) { const promise = this.#retryer?.promise; this.#retryer?.cancel(options); return promise ? promise.then(noop$3).catch(noop$3) : Promise.resolve(); } destroy() { super.destroy(); this.cancel({ silent: true }); } get resetState() { return this.#initialState; } reset() { this.destroy(); this.setState(this.resetState); } isActive() { return this.observers.some((observer) => resolveQueryBoolean(observer.options.enabled, this) !== false); } isDisabled() { if (this.getObserversCount() > 0) return !this.isActive(); return this.options.queryFn === skipToken || !this.isFetched(); } isFetched() { return this.state.dataUpdateCount + this.state.errorUpdateCount > 0; } isStatic() { if (this.getObserversCount() > 0) return this.observers.some((observer) => resolveStaleTime(observer.options.staleTime, this) === "static"); return false; } isStale() { if (this.getObserversCount() > 0) return this.observers.some((observer) => observer.getCurrentResult().isStale); return this.state.data === void 0 || this.state.isInvalidated; } isStaleByTime(staleTime = 0) { if (this.state.data === void 0) return true; if (staleTime === "static") return false; if (this.state.isInvalidated) return true; return !timeUntilStale(this.state.dataUpdatedAt, staleTime); } onFocus() { this.observers.find((x) => x.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: false }); this.#retryer?.continue(); } onOnline() { this.observers.find((x) => x.shouldFetchOnReconnect())?.refetch({ cancelRefetch: false }); this.#retryer?.continue(); } addObserver(observer) { if (!this.observers.includes(observer)) { this.observers.push(observer); this.clearGcTimeout(); this.#cache.notify({ type: "observerAdded", query: this, observer }); } } removeObserver(observer) { if (this.observers.includes(observer)) { this.observers = this.observers.filter((x) => x !== observer); if (!this.observers.length) { if (this.#retryer) if (this.#abortSignalConsumed || this.#isInitialPausedFetch()) this.#retryer.cancel({ revert: true }); else this.#retryer.cancelRetry(); this.scheduleGc(); } this.#cache.notify({ type: "observerRemoved", query: this, observer }); } } getObserversCount() { return this.observers.length; } #isInitialPausedFetch() { return this.state.fetchStatus === "paused" && this.state.status === "pending"; } invalidate() { if (!this.state.isInvalidated) this.#dispatch({ type: "invalidate" }); } async fetch(options, fetchOptions) { if (this.state.fetchStatus !== "idle" && this.#retryer?.status() !== "rejected") { if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) this.cancel({ silent: true }); else if (this.#retryer) { this.#retryer.continueRetry(); return this.#retryer.promise; } } if (options) this.setOptions(options); if (!this.options.queryFn) { const observer = this.observers.find((x) => x.options.queryFn); if (observer) this.setOptions(observer.options); } const abortController = new AbortController(); const addSignalProperty = (object) => { Object.defineProperty(object, "signal", { enumerable: true, get: () => { this.#abortSignalConsumed = true; return abortController.signal; } }); }; const fetchFn = () => { const queryFn = ensureQueryFn(this.options, fetchOptions); const createQueryFnContext = () => { const queryFnContext2 = { client: this.#client, queryKey: this.queryKey, meta: this.meta }; addSignalProperty(queryFnContext2); return queryFnContext2; }; const queryFnContext = createQueryFnContext(); this.#abortSignalConsumed = false; if (this.options.persister) return this.options.persister(queryFn, queryFnContext, this); return queryFn(queryFnContext); }; const createFetchContext = () => { const context2 = { fetchOptions, options: this.options, queryKey: this.queryKey, client: this.#client, state: this.state, fetchFn }; addSignalProperty(context2); return context2; }; const context = createFetchContext(); (this.#queryType === "infinite" ? infiniteQueryBehavior(this.options.pages) : this.options.behavior)?.onFetch(context, this); this.#revertState = this.state; if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta }); this.#retryer = createRetryer({ initialPromise: fetchOptions?.initialPromise, fn: context.fetchFn, onCancel: (error) => { if (error instanceof CancelledError && error.revert) this.setState({ ...this.#revertState, fetchStatus: "idle" }); abortController.abort(); }, onFail: (failureCount, error) => { this.#dispatch({ type: "failed", failureCount, error }); }, onPause: () => { this.#dispatch({ type: "pause" }); }, onContinue: () => { this.#dispatch({ type: "continue" }); }, retry: context.options.retry, retryDelay: context.options.retryDelay, networkMode: context.options.networkMode, canRun: () => true }); try { const data = await this.#retryer.start(); if (data === void 0) throw new Error(`${this.queryHash} data is undefined`); this.setData(data); this.#cache.config.onSuccess?.(data, this); this.#cache.config.onSettled?.(data, this.state.error, this); return data; } catch (error) { if (error instanceof CancelledError) { if (error.silent) return this.#retryer.promise; else if (error.revert) { if (this.state.data === void 0) throw error; return this.state.data; } } this.#dispatch({ type: "error", error }); this.#cache.config.onError?.(error, this); this.#cache.config.onSettled?.(this.state.data, error, this); throw error; } finally { this.scheduleGc(); } } #dispatch(action) { const reducer = (state) => { switch (action.type) { case "failed": return { ...state, fetchFailureCount: action.failureCount, fetchFailureReason: action.error }; case "pause": return { ...state, fetchStatus: "paused" }; case "continue": return { ...state, fetchStatus: "fetching" }; case "fetch": return { ...state, ...fetchState(state.data, this.options), fetchMeta: action.meta ?? null }; case "success": const newState = { ...state, ...successState(action.data, action.dataUpdatedAt), dataUpdateCount: state.dataUpdateCount + 1, ...!action.manual && { fetchStatus: "idle", fetchFailureCount: 0, fetchFailureReason: null } }; this.#revertState = action.manual ? newState : void 0; return newState; case "error": const error = action.error; return { ...state, error, errorUpdateCount: state.errorUpdateCount + 1, errorUpdatedAt: Date.now(), fetchFailureCount: state.fetchFailureCount + 1, fetchFailureReason: error, fetchStatus: "idle", status: "error", isInvalidated: true }; case "invalidate": return { ...state, isInvalidated: true }; case "setState": return { ...state, ...action.state }; } }; this.state = reducer(this.state); notifyManager.batch(() => { this.observers.forEach((observer) => { observer.onQueryUpdate(); }); this.#cache.notify({ query: this, type: "updated", action }); }); } }; function fetchState(data, options) { return { fetchFailureCount: 0, fetchFailureReason: null, fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused", ...data === void 0 && { error: null, status: "pending" } }; } function successState(data, dataUpdatedAt) { return { data, dataUpdatedAt: dataUpdatedAt ?? Date.now(), error: null, isInvalidated: false, status: "success" }; } function getDefaultState$1(options) { const data = typeof options.initialData === "function" ? options.initialData() : options.initialData; const hasData = data !== void 0; const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0; return { data, dataUpdateCount: 0, dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0, error: null, errorUpdateCount: 0, errorUpdatedAt: 0, fetchFailureCount: 0, fetchFailureReason: null, fetchMeta: null, isInvalidated: false, status: hasData ? "success" : "pending", fetchStatus: "idle" }; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/queryObserver.js var QueryObserver = class extends Subscribable { constructor(client, options) { super(); this.options = options; this.#client = client; this.#selectError = null; this.#currentThenable = pendingThenable(); this.bindMethods(); this.setOptions(options); } #client; #currentQuery = void 0; #currentQueryInitialState = void 0; #currentResult = void 0; #currentResultState; #currentResultOptions; #currentThenable; #selectError; #selectFn; #selectResult; #lastQueryWithDefinedData; #staleTimeoutId; #refetchIntervalId; #currentRefetchInterval; #trackedProps = /* @__PURE__ */ new Set(); bindMethods() { this.refetch = this.refetch.bind(this); } onSubscribe() { if (this.listeners.size === 1) { this.#currentQuery.addObserver(this); if (shouldFetchOnMount(this.#currentQuery, this.options)) this.#executeFetch(); else this.updateResult(); this.#updateTimers(); } } onUnsubscribe() { if (!this.hasListeners()) this.destroy(); } shouldFetchOnReconnect() { return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect); } shouldFetchOnWindowFocus() { return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus); } destroy() { this.listeners = /* @__PURE__ */ new Set(); this.#clearStaleTimeout(); this.#clearRefetchInterval(); this.#currentQuery.removeObserver(this); } setOptions(options) { const prevOptions = this.options; const prevQuery = this.#currentQuery; this.options = this.#client.defaultQueryOptions(options); if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== "boolean") throw new Error("Expected enabled to be a boolean or a callback that returns a boolean"); this.#updateQuery(); this.#currentQuery.setOptions(this.options); if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) this.#client.getQueryCache().notify({ type: "observerOptionsUpdated", query: this.#currentQuery, observer: this }); const mounted = this.hasListeners(); if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) this.#executeFetch(); this.updateResult(); if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) this.#updateStaleTimeout(); const nextRefetchInterval = this.#computeRefetchInterval(); if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) this.#updateRefetchInterval(nextRefetchInterval); } getOptimisticResult(options) { const query = this.#client.getQueryCache().build(this.#client, options); const result = this.createResult(query, options); if (shouldAssignObserverCurrentProperties(this, result)) { this.#currentResult = result; this.#currentResultOptions = this.options; this.#currentResultState = this.#currentQuery.state; } return result; } getCurrentResult() { return this.#currentResult; } trackResult(result, onPropTracked) { return new Proxy(result, { get: (target, key) => { this.trackProp(key); onPropTracked?.(key); if (key === "promise") { this.trackProp("data"); if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") this.#currentThenable.reject(/* @__PURE__ */ new Error("experimental_prefetchInRender feature flag is not enabled")); } return Reflect.get(target, key); } }); } trackProp(key) { this.#trackedProps.add(key); } getCurrentQuery() { return this.#currentQuery; } refetch({ ...options } = {}) { return this.fetch({ ...options }); } fetchOptimistic(options) { const defaultedOptions = this.#client.defaultQueryOptions(options); const query = this.#client.getQueryCache().build(this.#client, defaultedOptions); return query.fetch().then(() => this.createResult(query, defaultedOptions)); } fetch(fetchOptions) { return this.#executeFetch({ ...fetchOptions, cancelRefetch: fetchOptions.cancelRefetch ?? true }).then(() => { this.updateResult(); return this.#currentResult; }); } #executeFetch(fetchOptions) { this.#updateQuery(); let promise = this.#currentQuery.fetch(this.options, fetchOptions); if (!fetchOptions?.throwOnError) promise = promise.catch(noop$3); return promise; } #updateStaleTimeout() { this.#clearStaleTimeout(); const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery); if (environmentManager.isServer() || this.#currentResult.isStale || !isValidTimeout(staleTime)) return; const timeout = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime) + 1; this.#staleTimeoutId = timeoutManager.setTimeout(() => { if (!this.#currentResult.isStale) this.updateResult(); }, timeout); } #computeRefetchInterval() { return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false; } #updateRefetchInterval(nextInterval) { this.#clearRefetchInterval(); this.#currentRefetchInterval = nextInterval; if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) return; this.#refetchIntervalId = timeoutManager.setInterval(() => { if (this.options.refetchIntervalInBackground || focusManager.isFocused()) this.#executeFetch(); }, this.#currentRefetchInterval); } #updateTimers() { this.#updateStaleTimeout(); this.#updateRefetchInterval(this.#computeRefetchInterval()); } #clearStaleTimeout() { if (this.#staleTimeoutId !== void 0) { timeoutManager.clearTimeout(this.#staleTimeoutId); this.#staleTimeoutId = void 0; } } #clearRefetchInterval() { if (this.#refetchIntervalId !== void 0) { timeoutManager.clearInterval(this.#refetchIntervalId); this.#refetchIntervalId = void 0; } } createResult(query, options) { const prevQuery = this.#currentQuery; const prevOptions = this.options; const prevResult = this.#currentResult; const prevResultState = this.#currentResultState; const prevResultOptions = this.#currentResultOptions; const queryInitialState = query !== prevQuery ? query.state : this.#currentQueryInitialState; const { state } = query; let newState = { ...state }; let isPlaceholderData = false; let data; if (options._optimisticResults) { const mounted = this.hasListeners(); const fetchOnMount = !mounted && shouldFetchOnMount(query, options); const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions); if (fetchOnMount || fetchOptionally) newState = { ...newState, ...fetchState(state.data, query.options) }; if (options._optimisticResults === "isRestoring") newState.fetchStatus = "idle"; } let { error, errorUpdatedAt, status } = newState; data = newState.data; let skipSelect = false; if (options.placeholderData !== void 0 && data === void 0 && status === "pending") { let placeholderData; if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) { placeholderData = prevResult.data; skipSelect = true; } else placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(this.#lastQueryWithDefinedData?.state.data, this.#lastQueryWithDefinedData) : options.placeholderData; if (placeholderData !== void 0) { status = "success"; data = replaceData(prevResult?.data, placeholderData, options); isPlaceholderData = true; } } if (options.select && data !== void 0 && !skipSelect) if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) data = this.#selectResult; else try { this.#selectFn = options.select; data = options.select(data); data = replaceData(prevResult?.data, data, options); this.#selectResult = data; this.#selectError = null; } catch (selectError) { this.#selectError = selectError; } if (this.#selectError) { error = this.#selectError; data = this.#selectResult; errorUpdatedAt = Date.now(); status = "error"; } const isFetching = newState.fetchStatus === "fetching"; const isPending = status === "pending"; const isError = status === "error"; const isLoading = isPending && isFetching; const hasData = data !== void 0; const nextResult = { status, fetchStatus: newState.fetchStatus, isPending, isSuccess: status === "success", isError, isInitialLoading: isLoading, isLoading, data, dataUpdatedAt: newState.dataUpdatedAt, error, errorUpdatedAt, failureCount: newState.fetchFailureCount, failureReason: newState.fetchFailureReason, errorUpdateCount: newState.errorUpdateCount, isFetched: query.isFetched(), isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount, isFetching, isRefetching: isFetching && !isPending, isLoadingError: isError && !hasData, isPaused: newState.fetchStatus === "paused", isPlaceholderData, isRefetchError: isError && hasData, isStale: isStale(query, options), refetch: this.refetch, promise: this.#currentThenable, isEnabled: resolveQueryBoolean(options.enabled, query) !== false }; if (this.options.experimental_prefetchInRender) { const hasResultData = nextResult.data !== void 0; const isErrorWithoutData = nextResult.status === "error" && !hasResultData; const finalizeThenableIfPossible = (thenable) => { if (isErrorWithoutData) thenable.reject(nextResult.error); else if (hasResultData) thenable.resolve(nextResult.data); }; const recreateThenable = () => { finalizeThenableIfPossible(this.#currentThenable = nextResult.promise = pendingThenable()); }; const prevThenable = this.#currentThenable; switch (prevThenable.status) { case "pending": if (query.queryHash === prevQuery.queryHash) finalizeThenableIfPossible(prevThenable); break; case "fulfilled": if (isErrorWithoutData || nextResult.data !== prevThenable.value) recreateThenable(); break; case "rejected": if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) recreateThenable(); break; } } return nextResult; } updateResult() { const prevResult = this.#currentResult; const nextResult = this.createResult(this.#currentQuery, this.options); this.#currentResultState = this.#currentQuery.state; this.#currentResultOptions = this.options; if (this.#currentResultState.data !== void 0) this.#lastQueryWithDefinedData = this.#currentQuery; if (shallowEqualObjects(nextResult, prevResult)) return; this.#currentResult = nextResult; const shouldNotifyListeners = () => { if (!prevResult) return true; const { notifyOnChangeProps } = this.options; const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps; if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) return true; const includedProps = new Set(notifyOnChangePropsValue ?? this.#trackedProps); if (this.options.throwOnError) includedProps.add("error"); return Object.keys(this.#currentResult).some((key) => { const typedKey = key; return this.#currentResult[typedKey] !== prevResult[typedKey] && includedProps.has(typedKey); }); }; this.#notify({ listeners: shouldNotifyListeners() }); } #updateQuery() { const query = this.#client.getQueryCache().build(this.#client, this.options); if (query === this.#currentQuery) return; const prevQuery = this.#currentQuery; this.#currentQuery = query; this.#currentQueryInitialState = query.state; if (this.hasListeners()) { prevQuery?.removeObserver(this); query.addObserver(this); } } onQueryUpdate() { this.updateResult(); if (this.hasListeners()) this.#updateTimers(); } #notify(notifyOptions) { notifyManager.batch(() => { if (notifyOptions.listeners) this.listeners.forEach((listener) => { listener(this.#currentResult); }); this.#client.getQueryCache().notify({ query: this.#currentQuery, type: "observerResultsUpdated" }); }); } }; function shouldLoadOnMount(query, options) { return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false); } function shouldFetchOnMount(query, options) { return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount); } function shouldFetchOn(query, options, field) { if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") { const value = typeof field === "function" ? field(query) : field; return value === "always" || value !== false && isStale(query, options); } return false; } function shouldFetchOptionally(query, prevQuery, options, prevOptions) { return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); } function isStale(query, options) { return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query)); } function shouldAssignObserverCurrentProperties(observer, optimisticResult) { if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) return true; return false; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/mutation.js var Mutation = class extends Removable { #client; #observers; #mutationCache; #retryer; constructor(config) { super(); this.#client = config.client; this.mutationId = config.mutationId; this.#mutationCache = config.mutationCache; this.#observers = []; this.state = config.state || getDefaultState(); this.setOptions(config.options); this.scheduleGc(); } setOptions(options) { this.options = options; this.updateGcTime(this.options.gcTime); } get meta() { return this.options.meta; } addObserver(observer) { if (!this.#observers.includes(observer)) { this.#observers.push(observer); this.clearGcTimeout(); this.#mutationCache.notify({ type: "observerAdded", mutation: this, observer }); } } removeObserver(observer) { this.#observers = this.#observers.filter((x) => x !== observer); this.scheduleGc(); this.#mutationCache.notify({ type: "observerRemoved", mutation: this, observer }); } optionalRemove() { if (!this.#observers.length) if (this.state.status === "pending") this.scheduleGc(); else this.#mutationCache.remove(this); } continue() { return this.#retryer?.continue() ?? this.execute(this.state.variables); } async execute(variables) { const onContinue = () => { this.#dispatch({ type: "continue" }); }; const mutationFnContext = { client: this.#client, meta: this.options.meta, mutationKey: this.options.mutationKey }; this.#retryer = createRetryer({ fn: () => { if (!this.options.mutationFn) return Promise.reject(/* @__PURE__ */ new Error("No mutationFn found")); return this.options.mutationFn(variables, mutationFnContext); }, onFail: (failureCount, error) => { this.#dispatch({ type: "failed", failureCount, error }); }, onPause: () => { this.#dispatch({ type: "pause" }); }, onContinue, retry: this.options.retry ?? 0, retryDelay: this.options.retryDelay, networkMode: this.options.networkMode, canRun: () => this.#mutationCache.canRun(this) }); const restored = this.state.status === "pending"; const isPaused = !this.#retryer.canStart(); try { if (restored) onContinue(); else { this.#dispatch({ type: "pending", variables, isPaused }); if (this.#mutationCache.config.onMutate) await this.#mutationCache.config.onMutate(variables, this, mutationFnContext); const context = await this.options.onMutate?.(variables, mutationFnContext); if (context !== this.state.context) this.#dispatch({ type: "pending", context, variables, isPaused }); } const data = await this.#retryer.start(); await this.#mutationCache.config.onSuccess?.(data, variables, this.state.context, this, mutationFnContext); await this.options.onSuccess?.(data, variables, this.state.context, mutationFnContext); await this.#mutationCache.config.onSettled?.(data, null, this.state.variables, this.state.context, this, mutationFnContext); await this.options.onSettled?.(data, null, variables, this.state.context, mutationFnContext); this.#dispatch({ type: "success", data }); return data; } catch (error) { try { await this.#mutationCache.config.onError?.(error, variables, this.state.context, this, mutationFnContext); } catch (e) { Promise.reject(e); } try { await this.options.onError?.(error, variables, this.state.context, mutationFnContext); } catch (e) { Promise.reject(e); } try { await this.#mutationCache.config.onSettled?.(void 0, error, this.state.variables, this.state.context, this, mutationFnContext); } catch (e) { Promise.reject(e); } try { await this.options.onSettled?.(void 0, error, variables, this.state.context, mutationFnContext); } catch (e) { Promise.reject(e); } this.#dispatch({ type: "error", error }); throw error; } finally { this.#mutationCache.runNext(this); } } #dispatch(action) { const reducer = (state) => { switch (action.type) { case "failed": return { ...state, failureCount: action.failureCount, failureReason: action.error }; case "pause": return { ...state, isPaused: true }; case "continue": return { ...state, isPaused: false }; case "pending": return { ...state, context: action.context, data: void 0, failureCount: 0, failureReason: null, error: null, isPaused: action.isPaused, status: "pending", variables: action.variables, submittedAt: Date.now() }; case "success": return { ...state, data: action.data, failureCount: 0, failureReason: null, error: null, status: "success", isPaused: false }; case "error": return { ...state, data: void 0, error: action.error, failureCount: state.failureCount + 1, failureReason: action.error, isPaused: false, status: "error" }; } }; this.state = reducer(this.state); notifyManager.batch(() => { this.#observers.forEach((observer) => { observer.onMutationUpdate(action); }); this.#mutationCache.notify({ mutation: this, type: "updated", action }); }); } }; function getDefaultState() { return { context: void 0, data: void 0, error: null, failureCount: 0, failureReason: null, isPaused: false, status: "idle", variables: void 0, submittedAt: 0 }; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/mutationCache.js var MutationCache$1 = class extends Subscribable { constructor(config = {}) { super(); this.config = config; this.#mutations = /* @__PURE__ */ new Set(); this.#scopes = /* @__PURE__ */ new Map(); this.#mutationId = 0; } #mutations; #scopes; #mutationId; build(client, options, state) { const mutation = new Mutation({ client, mutationCache: this, mutationId: ++this.#mutationId, options: client.defaultMutationOptions(options), state }); this.add(mutation); return mutation; } add(mutation) { this.#mutations.add(mutation); const scope = scopeFor(mutation); if (typeof scope === "string") { const scopedMutations = this.#scopes.get(scope); if (scopedMutations) scopedMutations.push(mutation); else this.#scopes.set(scope, [mutation]); } this.notify({ type: "added", mutation }); } remove(mutation) { if (this.#mutations.delete(mutation)) { const scope = scopeFor(mutation); if (typeof scope === "string") { const scopedMutations = this.#scopes.get(scope); if (scopedMutations) { if (scopedMutations.length > 1) { const index = scopedMutations.indexOf(mutation); if (index !== -1) scopedMutations.splice(index, 1); } else if (scopedMutations[0] === mutation) this.#scopes.delete(scope); } } } this.notify({ type: "removed", mutation }); } canRun(mutation) { const scope = scopeFor(mutation); if (typeof scope === "string") { const firstPendingMutation = this.#scopes.get(scope)?.find((m) => m.state.status === "pending"); return !firstPendingMutation || firstPendingMutation === mutation; } else return true; } runNext(mutation) { const scope = scopeFor(mutation); if (typeof scope === "string") return (this.#scopes.get(scope)?.find((m) => m !== mutation && m.state.isPaused))?.continue() ?? Promise.resolve(); else return Promise.resolve(); } clear() { notifyManager.batch(() => { this.#mutations.forEach((mutation) => { this.notify({ type: "removed", mutation }); }); this.#mutations.clear(); this.#scopes.clear(); }); } getAll() { return Array.from(this.#mutations); } find(filters) { const defaultedFilters = { exact: true, ...filters }; return this.getAll().find((mutation) => matchMutation(defaultedFilters, mutation)); } findAll(filters = {}) { return this.getAll().filter((mutation) => matchMutation(filters, mutation)); } notify(event) { notifyManager.batch(() => { this.listeners.forEach((listener) => { listener(event); }); }); } resumePausedMutations() { const pausedMutations = this.getAll().filter((x) => x.state.isPaused); return notifyManager.batch(() => Promise.all(pausedMutations.map((mutation) => mutation.continue().catch(noop$3)))); } }; function scopeFor(mutation) { return mutation.options.scope?.id; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/queryCache.js var QueryCache$1 = class extends Subscribable { constructor(config = {}) { super(); this.config = config; this.#queries = /* @__PURE__ */ new Map(); } #queries; build(client, options, state) { const queryKey = options.queryKey; const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options); let query = this.get(queryHash); if (!query) { query = new Query({ client, queryKey, queryHash, options: client.defaultQueryOptions(options), state, defaultOptions: client.getQueryDefaults(queryKey) }); this.add(query); } return query; } add(query) { if (!this.#queries.has(query.queryHash)) { this.#queries.set(query.queryHash, query); this.notify({ type: "added", query }); } } remove(query) { const queryInMap = this.#queries.get(query.queryHash); if (queryInMap) { query.destroy(); if (queryInMap === query) this.#queries.delete(query.queryHash); this.notify({ type: "removed", query }); } } clear() { notifyManager.batch(() => { this.getAll().forEach((query) => { this.remove(query); }); }); } get(queryHash) { return this.#queries.get(queryHash); } getAll() { return [...this.#queries.values()]; } find(filters) { const defaultedFilters = { exact: true, ...filters }; return this.getAll().find((query) => matchQuery(defaultedFilters, query)); } findAll(filters = {}) { const queries = this.getAll(); return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries; } notify(event) { notifyManager.batch(() => { this.listeners.forEach((listener) => { listener(event); }); }); } onFocus() { notifyManager.batch(() => { this.getAll().forEach((query) => { query.onFocus(); }); }); } onOnline() { notifyManager.batch(() => { this.getAll().forEach((query) => { query.onOnline(); }); }); } }; //#endregion //#region ../../node_modules/.pnpm/@tanstack+query-core@5.100.6/node_modules/@tanstack/query-core/build/modern/queryClient.js var QueryClient$1 = class { #queryCache; #mutationCache; #defaultOptions; #queryDefaults; #mutationDefaults; #mountCount; #unsubscribeFocus; #unsubscribeOnline; constructor(config = {}) { this.#queryCache = config.queryCache || new QueryCache$1(); this.#mutationCache = config.mutationCache || new MutationCache$1(); this.#defaultOptions = config.defaultOptions || {}; this.#queryDefaults = /* @__PURE__ */ new Map(); this.#mutationDefaults = /* @__PURE__ */ new Map(); this.#mountCount = 0; } mount() { this.#mountCount++; if (this.#mountCount !== 1) return; this.#unsubscribeFocus = focusManager.subscribe(async (focused) => { if (focused) { await this.resumePausedMutations(); this.#queryCache.onFocus(); } }); this.#unsubscribeOnline = onlineManager.subscribe(async (online) => { if (online) { await this.resumePausedMutations(); this.#queryCache.onOnline(); } }); } unmount() { this.#mountCount--; if (this.#mountCount !== 0) return; this.#unsubscribeFocus?.(); this.#unsubscribeFocus = void 0; this.#unsubscribeOnline?.(); this.#unsubscribeOnline = void 0; } isFetching(filters) { return this.#queryCache.findAll({ ...filters, fetchStatus: "fetching" }).length; } isMutating(filters) { return this.#mutationCache.findAll({ ...filters, status: "pending" }).length; } /** * Imperative (non-reactive) way to retrieve data for a QueryKey. * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. * * Hint: Do not use this function inside a component, because it won't receive updates. * Use `useQuery` to create a `QueryObserver` that subscribes to changes. */ getQueryData(queryKey) { const options = this.defaultQueryOptions({ queryKey }); return this.#queryCache.get(options.queryHash)?.state.data; } ensureQueryData(options) { const defaultedOptions = this.defaultQueryOptions(options); const query = this.#queryCache.build(this, defaultedOptions); const cachedData = query.state.data; if (cachedData === void 0) return this.fetchQuery(options); if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) this.prefetchQuery(defaultedOptions); return Promise.resolve(cachedData); } getQueriesData(filters) { return this.#queryCache.findAll(filters).map(({ queryKey, state }) => { return [queryKey, state.data]; }); } setQueryData(queryKey, updater, options) { const defaultedOptions = this.defaultQueryOptions({ queryKey }); const prevData = this.#queryCache.get(defaultedOptions.queryHash)?.state.data; const data = functionalUpdate(updater, prevData); if (data === void 0) return; return this.#queryCache.build(this, defaultedOptions).setData(data, { ...options, manual: true }); } setQueriesData(filters, updater, options) { return notifyManager.batch(() => this.#queryCache.findAll(filters).map(({ queryKey }) => [queryKey, this.setQueryData(queryKey, updater, options)])); } getQueryState(queryKey) { const options = this.defaultQueryOptions({ queryKey }); return this.#queryCache.get(options.queryHash)?.state; } removeQueries(filters) { const queryCache = this.#queryCache; notifyManager.batch(() => { queryCache.findAll(filters).forEach((query) => { queryCache.remove(query); }); }); } resetQueries(filters, options) { const queryCache = this.#queryCache; return notifyManager.batch(() => { queryCache.findAll(filters).forEach((query) => { query.reset(); }); return this.refetchQueries({ type: "active", ...filters }, options); }); } cancelQueries(filters, cancelOptions = {}) { const defaultedCancelOptions = { revert: true, ...cancelOptions }; const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map((query) => query.cancel(defaultedCancelOptions))); return Promise.all(promises).then(noop$3).catch(noop$3); } invalidateQueries(filters, options = {}) { return notifyManager.batch(() => { this.#queryCache.findAll(filters).forEach((query) => { query.invalidate(); }); if (filters?.refetchType === "none") return Promise.resolve(); return this.refetchQueries({ ...filters, type: filters?.refetchType ?? filters?.type ?? "active" }, options); }); } refetchQueries(filters, options = {}) { const fetchOptions = { ...options, cancelRefetch: options.cancelRefetch ?? true }; const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => { let promise = query.fetch(void 0, fetchOptions); if (!fetchOptions.throwOnError) promise = promise.catch(noop$3); return query.state.fetchStatus === "paused" ? Promise.resolve() : promise; })); return Promise.all(promises).then(noop$3); } fetchQuery(options) { const defaultedOptions = this.defaultQueryOptions(options); if (defaultedOptions.retry === void 0) defaultedOptions.retry = false; const query = this.#queryCache.build(this, defaultedOptions); return query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query)) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data); } prefetchQuery(options) { return this.fetchQuery(options).then(noop$3).catch(noop$3); } fetchInfiniteQuery(options) { options._type = "infinite"; return this.fetchQuery(options); } prefetchInfiniteQuery(options) { return this.fetchInfiniteQuery(options).then(noop$3).catch(noop$3); } ensureInfiniteQueryData(options) { options._type = "infinite"; return this.ensureQueryData(options); } resumePausedMutations() { if (onlineManager.isOnline()) return this.#mutationCache.resumePausedMutations(); return Promise.resolve(); } getQueryCache() { return this.#queryCache; } getMutationCache() { return this.#mutationCache; } getDefaultOptions() { return this.#defaultOptions; } setDefaultOptions(options) { this.#defaultOptions = options; } setQueryDefaults(queryKey, options) { this.#queryDefaults.set(hashKey(queryKey), { queryKey, defaultOptions: options }); } getQueryDefaults(queryKey) { const defaults = [...this.#queryDefaults.values()]; const result = {}; defaults.forEach((queryDefault) => { if (partialMatchKey(queryKey, queryDefault.queryKey)) Object.assign(result, queryDefault.defaultOptions); }); return result; } setMutationDefaults(mutationKey, options) { this.#mutationDefaults.set(hashKey(mutationKey), { mutationKey, defaultOptions: options }); } getMutationDefaults(mutationKey) { const defaults = [...this.#mutationDefaults.values()]; const result = {}; defaults.forEach((queryDefault) => { if (partialMatchKey(mutationKey, queryDefault.mutationKey)) Object.assign(result, queryDefault.defaultOptions); }); return result; } defaultQueryOptions(options) { if (options._defaulted) return options; const defaultedOptions = { ...this.#defaultOptions.queries, ...this.getQueryDefaults(options.queryKey), ...options, _defaulted: true }; if (!defaultedOptions.queryHash) defaultedOptions.queryHash = hashQueryKeyByOptions(defaultedOptions.queryKey, defaultedOptions); if (defaultedOptions.refetchOnReconnect === void 0) defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always"; if (defaultedOptions.throwOnError === void 0) defaultedOptions.throwOnError = !!defaultedOptions.suspense; if (!defaultedOptions.networkMode && defaultedOptions.persister) defaultedOptions.networkMode = "offlineFirst"; if (defaultedOptions.queryFn === skipToken) defaultedOptions.enabled = false; return defaultedOptions; } defaultMutationOptions(options) { if (options?._defaulted) return options; return { ...this.#defaultOptions.mutations, ...options?.mutationKey && this.getMutationDefaults(options.mutationKey), ...options, _defaulted: true }; } clear() { this.#queryCache.clear(); this.#mutationCache.clear(); } }; //#endregion //#region ../../node_modules/.pnpm/@vue+shared@3.5.33/node_modules/@vue/shared/dist/shared.esm-bundler.js /** * @vue/shared v3.5.33 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ // @__NO_SIDE_EFFECTS__ function makeMap(str) { const map = /* @__PURE__ */ Object.create(null); for (const key of str.split(",")) map[key] = 1; return (val) => val in map; } var EMPTY_OBJ = {}; var EMPTY_ARR = []; var NOOP = () => {}; var NO = () => false; var isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && (key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97); var isModelListener = (key) => key.startsWith("onUpdate:"); var extend = Object.assign; var remove = (arr, el) => { const i = arr.indexOf(el); if (i > -1) arr.splice(i, 1); }; var hasOwnProperty$1 = Object.prototype.hasOwnProperty; var hasOwn = (val, key) => hasOwnProperty$1.call(val, key); var isArray = Array.isArray; var isMap = (val) => toTypeString(val) === "[object Map]"; var isSet = (val) => toTypeString(val) === "[object Set]"; var isDate = (val) => toTypeString(val) === "[object Date]"; var isRegExp = (val) => toTypeString(val) === "[object RegExp]"; var isFunction$2 = (val) => typeof val === "function"; var isString = (val) => typeof val === "string"; var isSymbol = (val) => typeof val === "symbol"; var isObject$2 = (val) => val !== null && typeof val === "object"; var isPromise = (val) => { return (isObject$2(val) || isFunction$2(val)) && isFunction$2(val.then) && isFunction$2(val.catch); }; var objectToString$1 = Object.prototype.toString; var toTypeString = (value) => objectToString$1.call(value); var toRawType = (value) => { return toTypeString(value).slice(8, -1); }; var isPlainObject$3 = (val) => toTypeString(val) === "[object Object]"; var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key; var isReservedProp = /* @__PURE__ */ makeMap(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"); var cacheStringFunction$2 = (fn) => { const cache = /* @__PURE__ */ Object.create(null); return ((str) => { return cache[str] || (cache[str] = fn(str)); }); }; var camelizeRE$2 = /-\w/g; var camelize$2 = cacheStringFunction$2((str) => { return str.replace(camelizeRE$2, (c) => c.slice(1).toUpperCase()); }); var hyphenateRE$2 = /\B([A-Z])/g; var hyphenate$2 = cacheStringFunction$2((str) => str.replace(hyphenateRE$2, "-$1").toLowerCase()); var capitalize = cacheStringFunction$2((str) => { return str.charAt(0).toUpperCase() + str.slice(1); }); var toHandlerKey = cacheStringFunction$2((str) => { return str ? `on${capitalize(str)}` : ``; }); var hasChanged = (value, oldValue) => !Object.is(value, oldValue); var invokeArrayFns = (fns, ...arg) => { for (let i = 0; i < fns.length; i++) fns[i](...arg); }; var def = (obj, key, value, writable = false) => { Object.defineProperty(obj, key, { configurable: true, enumerable: false, writable, value }); }; var looseToNumber = (val) => { const n = parseFloat(val); return isNaN(n) ? val : n; }; var toNumber = (val) => { const n = isString(val) ? Number(val) : NaN; return isNaN(n) ? val : n; }; var _globalThis; var getGlobalThis = () => { return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {}); }; var isGloballyAllowed = /* @__PURE__ */ makeMap("Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol"); function normalizeStyle(value) { if (isArray(value)) { const res = {}; for (let i = 0; i < value.length; i++) { const item = value[i]; const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item); if (normalized) for (const key in normalized) res[key] = normalized[key]; } return res; } else if (isString(value) || isObject$2(value)) return value; } var listDelimiterRE = /;(?![^(]*\))/g; var propertyDelimiterRE = /:([^]+)/; var styleCommentRE = /\/\*[^]*?\*\//g; function parseStringStyle(cssText) { const ret = {}; cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => { if (item) { const tmp = item.split(propertyDelimiterRE); tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim()); } }); return ret; } function normalizeClass(value) { let res = ""; if (isString(value)) res = value; else if (isArray(value)) for (let i = 0; i < value.length; i++) { const normalized = normalizeClass(value[i]); if (normalized) res += normalized + " "; } else if (isObject$2(value)) { for (const name in value) if (value[name]) res += name + " "; } return res.trim(); } function normalizeProps(props) { if (!props) return null; let { class: klass, style } = props; if (klass && !isString(klass)) props.class = normalizeClass(klass); if (style) props.style = normalizeStyle(style); return props; } var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; var isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs); specialBooleanAttrs + ""; function includeBooleanAttr(value) { return !!value || value === ""; } function looseCompareArrays(a, b) { if (a.length !== b.length) return false; let equal = true; for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]); return equal; } function looseEqual(a, b) { if (a === b) return true; let aValidType = isDate(a); let bValidType = isDate(b); if (aValidType || bValidType) return aValidType && bValidType ? a.getTime() === b.getTime() : false; aValidType = isSymbol(a); bValidType = isSymbol(b); if (aValidType || bValidType) return a === b; aValidType = isArray(a); bValidType = isArray(b); if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false; aValidType = isObject$2(a); bValidType = isObject$2(b); if (aValidType || bValidType) { if (!aValidType || !bValidType) return false; if (Object.keys(a).length !== Object.keys(b).length) return false; for (const key in a) { const aHasKey = a.hasOwnProperty(key); const bHasKey = b.hasOwnProperty(key); if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false; } } return String(a) === String(b); } function looseIndexOf(arr, val) { return arr.findIndex((item) => looseEqual(item, val)); } var isRef$1 = (val) => { return !!(val && val["__v_isRef"] === true); }; var toDisplayString = (val) => { return isString(val) ? val : val == null ? "" : isArray(val) || isObject$2(val) && (val.toString === objectToString$1 || !isFunction$2(val.toString)) ? isRef$1(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val); }; var replacer = (_key, val) => { if (isRef$1(val)) return replacer(_key, val.value); else if (isMap(val)) return { [`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2], i) => { entries[stringifySymbol(key, i) + " =>"] = val2; return entries; }, {}) }; else if (isSet(val)) return { [`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v)) }; else if (isSymbol(val)) return stringifySymbol(val); else if (isObject$2(val) && !isArray(val) && !isPlainObject$3(val)) return String(val); return val; }; var stringifySymbol = (v, i = "") => { var _a; return isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v; }; function normalizeCssVarValue(value) { if (value == null) return "initial"; if (typeof value === "string") return value === "" ? " " : value; if (typeof value !== "number" || !Number.isFinite(value)) {} return String(value); } //#endregion //#region ../../node_modules/.pnpm/@vue+reactivity@3.5.33/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js /** * @vue/reactivity v3.5.33 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ var activeEffectScope; var EffectScope = class { constructor(detached = false) { this.detached = detached; /** * @internal */ this._active = true; /** * @internal track `on` calls, allow `on` call multiple times */ this._on = 0; /** * @internal */ this.effects = []; /** * @internal */ this.cleanups = []; this._isPaused = false; this.__v_skip = true; this.parent = activeEffectScope; if (!detached && activeEffectScope) this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1; } get active() { return this._active; } pause() { if (this._active) { this._isPaused = true; let i, l; if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].pause(); for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].pause(); } } /** * Resumes the effect scope, including all child scopes and effects. */ resume() { if (this._active) { if (this._isPaused) { this._isPaused = false; let i, l; if (this.scopes) for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].resume(); for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].resume(); } } } run(fn) { if (this._active) { const currentEffectScope = activeEffectScope; try { activeEffectScope = this; return fn(); } finally { activeEffectScope = currentEffectScope; } } } /** * This should only be called on non-detached scopes * @internal */ on() { if (++this._on === 1) { this.prevScope = activeEffectScope; activeEffectScope = this; } } /** * This should only be called on non-detached scopes * @internal */ off() { if (this._on > 0 && --this._on === 0) { if (activeEffectScope === this) activeEffectScope = this.prevScope; else { let current = activeEffectScope; while (current) { if (current.prevScope === this) { current.prevScope = this.prevScope; break; } current = current.prevScope; } } this.prevScope = void 0; } } stop(fromParent) { if (this._active) { this._active = false; let i, l; for (i = 0, l = this.effects.length; i < l; i++) this.effects[i].stop(); this.effects.length = 0; for (i = 0, l = this.cleanups.length; i < l; i++) this.cleanups[i](); this.cleanups.length = 0; if (this.scopes) { for (i = 0, l = this.scopes.length; i < l; i++) this.scopes[i].stop(true); this.scopes.length = 0; } if (!this.detached && this.parent && !fromParent) { const last = this.parent.scopes.pop(); if (last && last !== this) { this.parent.scopes[this.index] = last; last.index = this.index; } } this.parent = void 0; } } }; function effectScope(detached) { return new EffectScope(detached); } function getCurrentScope$1() { return activeEffectScope; } function onScopeDispose(fn, failSilently = false) { if (activeEffectScope) activeEffectScope.cleanups.push(fn); } var activeSub; var pausedQueueEffects = /* @__PURE__ */ new WeakSet(); var ReactiveEffect = class { constructor(fn) { this.fn = fn; /** * @internal */ this.deps = void 0; /** * @internal */ this.depsTail = void 0; /** * @internal */ this.flags = 5; /** * @internal */ this.next = void 0; /** * @internal */ this.cleanup = void 0; this.scheduler = void 0; if (activeEffectScope && activeEffectScope.active) activeEffectScope.effects.push(this); } pause() { this.flags |= 64; } resume() { if (this.flags & 64) { this.flags &= -65; if (pausedQueueEffects.has(this)) { pausedQueueEffects.delete(this); this.trigger(); } } } /** * @internal */ notify() { if (this.flags & 2 && !(this.flags & 32)) return; if (!(this.flags & 8)) batch(this); } run() { if (!(this.flags & 1)) return this.fn(); this.flags |= 2; cleanupEffect(this); prepareDeps(this); const prevEffect = activeSub; const prevShouldTrack = shouldTrack; activeSub = this; shouldTrack = true; try { return this.fn(); } finally { cleanupDeps(this); activeSub = prevEffect; shouldTrack = prevShouldTrack; this.flags &= -3; } } stop() { if (this.flags & 1) { for (let link = this.deps; link; link = link.nextDep) removeSub(link); this.deps = this.depsTail = void 0; cleanupEffect(this); this.onStop && this.onStop(); this.flags &= -2; } } trigger() { if (this.flags & 64) pausedQueueEffects.add(this); else if (this.scheduler) this.scheduler(); else this.runIfDirty(); } /** * @internal */ runIfDirty() { if (isDirty(this)) this.run(); } get dirty() { return isDirty(this); } }; var batchDepth = 0; var batchedSub; var batchedComputed; function batch(sub, isComputed = false) { sub.flags |= 8; if (isComputed) { sub.next = batchedComputed; batchedComputed = sub; return; } sub.next = batchedSub; batchedSub = sub; } function startBatch() { batchDepth++; } function endBatch() { if (--batchDepth > 0) return; if (batchedComputed) { let e = batchedComputed; batchedComputed = void 0; while (e) { const next = e.next; e.next = void 0; e.flags &= -9; e = next; } } let error; while (batchedSub) { let e = batchedSub; batchedSub = void 0; while (e) { const next = e.next; e.next = void 0; e.flags &= -9; if (e.flags & 1) try { e.trigger(); } catch (err) { if (!error) error = err; } e = next; } } if (error) throw error; } function prepareDeps(sub) { for (let link = sub.deps; link; link = link.nextDep) { link.version = -1; link.prevActiveLink = link.dep.activeLink; link.dep.activeLink = link; } } function cleanupDeps(sub) { let head; let tail = sub.depsTail; let link = tail; while (link) { const prev = link.prevDep; if (link.version === -1) { if (link === tail) tail = prev; removeSub(link); removeDep(link); } else head = link; link.dep.activeLink = link.prevActiveLink; link.prevActiveLink = void 0; link = prev; } sub.deps = head; sub.depsTail = tail; } function isDirty(sub) { for (let link = sub.deps; link; link = link.nextDep) if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) return true; if (sub._dirty) return true; return false; } function refreshComputed(computed) { if (computed.flags & 4 && !(computed.flags & 16)) return; computed.flags &= -17; if (computed.globalVersion === globalVersion) return; computed.globalVersion = globalVersion; if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) return; computed.flags |= 2; const dep = computed.dep; const prevSub = activeSub; const prevShouldTrack = shouldTrack; activeSub = computed; shouldTrack = true; try { prepareDeps(computed); const value = computed.fn(computed._value); if (dep.version === 0 || hasChanged(value, computed._value)) { computed.flags |= 128; computed._value = value; dep.version++; } } catch (err) { dep.version++; throw err; } finally { activeSub = prevSub; shouldTrack = prevShouldTrack; cleanupDeps(computed); computed.flags &= -3; } } function removeSub(link, soft = false) { const { dep, prevSub, nextSub } = link; if (prevSub) { prevSub.nextSub = nextSub; link.prevSub = void 0; } if (nextSub) { nextSub.prevSub = prevSub; link.nextSub = void 0; } if (dep.subs === link) { dep.subs = prevSub; if (!prevSub && dep.computed) { dep.computed.flags &= -5; for (let l = dep.computed.deps; l; l = l.nextDep) removeSub(l, true); } } if (!soft && !--dep.sc && dep.map) dep.map.delete(dep.key); } function removeDep(link) { const { prevDep, nextDep } = link; if (prevDep) { prevDep.nextDep = nextDep; link.prevDep = void 0; } if (nextDep) { nextDep.prevDep = prevDep; link.nextDep = void 0; } } function effect(fn, options) { if (fn.effect instanceof ReactiveEffect) fn = fn.effect.fn; const e = new ReactiveEffect(fn); if (options) extend(e, options); try { e.run(); } catch (err) { e.stop(); throw err; } const runner = e.run.bind(e); runner.effect = e; return runner; } function stop(runner) { runner.effect.stop(); } var shouldTrack = true; var trackStack = []; function pauseTracking() { trackStack.push(shouldTrack); shouldTrack = false; } function resetTracking() { const last = trackStack.pop(); shouldTrack = last === void 0 ? true : last; } function cleanupEffect(e) { const { cleanup } = e; e.cleanup = void 0; if (cleanup) { const prevSub = activeSub; activeSub = void 0; try { cleanup(); } finally { activeSub = prevSub; } } } var globalVersion = 0; var Link = class { constructor(sub, dep) { this.sub = sub; this.dep = dep; this.version = dep.version; this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0; } }; var Dep = class { constructor(computed) { this.computed = computed; this.version = 0; /** * Link between this dep and the current active effect */ this.activeLink = void 0; /** * Doubly linked list representing the subscribing effects (tail) */ this.subs = void 0; /** * For object property deps cleanup */ this.map = void 0; this.key = void 0; /** * Subscriber counter */ this.sc = 0; /** * @internal */ this.__v_skip = true; } track(debugInfo) { if (!activeSub || !shouldTrack || activeSub === this.computed) return; let link = this.activeLink; if (link === void 0 || link.sub !== activeSub) { link = this.activeLink = new Link(activeSub, this); if (!activeSub.deps) activeSub.deps = activeSub.depsTail = link; else { link.prevDep = activeSub.depsTail; activeSub.depsTail.nextDep = link; activeSub.depsTail = link; } addSub(link); } else if (link.version === -1) { link.version = this.version; if (link.nextDep) { const next = link.nextDep; next.prevDep = link.prevDep; if (link.prevDep) link.prevDep.nextDep = next; link.prevDep = activeSub.depsTail; link.nextDep = void 0; activeSub.depsTail.nextDep = link; activeSub.depsTail = link; if (activeSub.deps === link) activeSub.deps = next; } } return link; } trigger(debugInfo) { this.version++; globalVersion++; this.notify(debugInfo); } notify(debugInfo) { startBatch(); try { for (let link = this.subs; link; link = link.prevSub) if (link.sub.notify()) link.sub.dep.notify(); } finally { endBatch(); } } }; function addSub(link) { link.dep.sc++; if (link.sub.flags & 4) { const computed = link.dep.computed; if (computed && !link.dep.subs) { computed.flags |= 20; for (let l = computed.deps; l; l = l.nextDep) addSub(l); } const currentTail = link.dep.subs; if (currentTail !== link) { link.prevSub = currentTail; if (currentTail) currentTail.nextSub = link; } link.dep.subs = link; } } var targetMap = /* @__PURE__ */ new WeakMap(); var ITERATE_KEY = /* @__PURE__ */ Symbol(""); var MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(""); var ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(""); function track(target, type, key) { if (shouldTrack && activeSub) { let depsMap = targetMap.get(target); if (!depsMap) targetMap.set(target, depsMap = /* @__PURE__ */ new Map()); let dep = depsMap.get(key); if (!dep) { depsMap.set(key, dep = new Dep()); dep.map = depsMap; dep.key = key; } dep.track(); } } function trigger(target, type, key, newValue, oldValue, oldTarget) { const depsMap = targetMap.get(target); if (!depsMap) { globalVersion++; return; } const run = (dep) => { if (dep) dep.trigger(); }; startBatch(); if (type === "clear") depsMap.forEach(run); else { const targetIsArray = isArray(target); const isArrayIndex = targetIsArray && isIntegerKey(key); if (targetIsArray && key === "length") { const newLength = Number(newValue); depsMap.forEach((dep, key2) => { if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) run(dep); }); } else { if (key !== void 0 || depsMap.has(void 0)) run(depsMap.get(key)); if (isArrayIndex) run(depsMap.get(ARRAY_ITERATE_KEY)); switch (type) { case "add": if (!targetIsArray) { run(depsMap.get(ITERATE_KEY)); if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY)); } else if (isArrayIndex) run(depsMap.get("length")); break; case "delete": if (!targetIsArray) { run(depsMap.get(ITERATE_KEY)); if (isMap(target)) run(depsMap.get(MAP_KEY_ITERATE_KEY)); } break; case "set": if (isMap(target)) run(depsMap.get(ITERATE_KEY)); break; } } } endBatch(); } function getDepFromReactive(object, key) { const depMap = targetMap.get(object); return depMap && depMap.get(key); } function reactiveReadArray(array) { const raw = /* @__PURE__ */ toRaw(array); if (raw === array) return raw; track(raw, "iterate", ARRAY_ITERATE_KEY); return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive); } function shallowReadArray(arr) { track(arr = /* @__PURE__ */ toRaw(arr), "iterate", ARRAY_ITERATE_KEY); return arr; } function toWrapped(target, item) { if (/* @__PURE__ */ isReadonly(target)) return /* @__PURE__ */ isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item); return toReactive(item); } var arrayInstrumentations = { __proto__: null, [Symbol.iterator]() { return iterator(this, Symbol.iterator, (item) => toWrapped(this, item)); }, concat(...args) { return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x)); }, entries() { return iterator(this, "entries", (value) => { value[1] = toWrapped(this, value[1]); return value; }); }, every(fn, thisArg) { return apply(this, "every", fn, thisArg, void 0, arguments); }, filter(fn, thisArg) { return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments); }, find(fn, thisArg) { return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments); }, findIndex(fn, thisArg) { return apply(this, "findIndex", fn, thisArg, void 0, arguments); }, findLast(fn, thisArg) { return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments); }, findLastIndex(fn, thisArg) { return apply(this, "findLastIndex", fn, thisArg, void 0, arguments); }, forEach(fn, thisArg) { return apply(this, "forEach", fn, thisArg, void 0, arguments); }, includes(...args) { return searchProxy(this, "includes", args); }, indexOf(...args) { return searchProxy(this, "indexOf", args); }, join(separator) { return reactiveReadArray(this).join(separator); }, lastIndexOf(...args) { return searchProxy(this, "lastIndexOf", args); }, map(fn, thisArg) { return apply(this, "map", fn, thisArg, void 0, arguments); }, pop() { return noTracking(this, "pop"); }, push(...args) { return noTracking(this, "push", args); }, reduce(fn, ...args) { return reduce(this, "reduce", fn, args); }, reduceRight(fn, ...args) { return reduce(this, "reduceRight", fn, args); }, shift() { return noTracking(this, "shift"); }, some(fn, thisArg) { return apply(this, "some", fn, thisArg, void 0, arguments); }, splice(...args) { return noTracking(this, "splice", args); }, toReversed() { return reactiveReadArray(this).toReversed(); }, toSorted(comparer) { return reactiveReadArray(this).toSorted(comparer); }, toSpliced(...args) { return reactiveReadArray(this).toSpliced(...args); }, unshift(...args) { return noTracking(this, "unshift", args); }, values() { return iterator(this, "values", (item) => toWrapped(this, item)); } }; function iterator(self, method, wrapValue) { const arr = shallowReadArray(self); const iter = arr[method](); if (arr !== self && !/* @__PURE__ */ isShallow(self)) { iter._next = iter.next; iter.next = () => { const result = iter._next(); if (!result.done) result.value = wrapValue(result.value); return result; }; } return iter; } var arrayProto = Array.prototype; function apply(self, method, fn, thisArg, wrappedRetFn, args) { const arr = shallowReadArray(self); const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self); const methodFn = arr[method]; if (methodFn !== arrayProto[method]) { const result2 = methodFn.apply(self, args); return needsWrap ? toReactive(result2) : result2; } let wrappedFn = fn; if (arr !== self) { if (needsWrap) wrappedFn = function(item, index) { return fn.call(this, toWrapped(self, item), index, self); }; else if (fn.length > 2) wrappedFn = function(item, index) { return fn.call(this, item, index, self); }; } const result = methodFn.call(arr, wrappedFn, thisArg); return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result; } function reduce(self, method, fn, args) { const arr = shallowReadArray(self); const needsWrap = arr !== self && !/* @__PURE__ */ isShallow(self); let wrappedFn = fn; let wrapInitialAccumulator = false; if (arr !== self) { if (needsWrap) { wrapInitialAccumulator = args.length === 0; wrappedFn = function(acc, item, index) { if (wrapInitialAccumulator) { wrapInitialAccumulator = false; acc = toWrapped(self, acc); } return fn.call(this, acc, toWrapped(self, item), index, self); }; } else if (fn.length > 3) wrappedFn = function(acc, item, index) { return fn.call(this, acc, item, index, self); }; } const result = arr[method](wrappedFn, ...args); return wrapInitialAccumulator ? toWrapped(self, result) : result; } function searchProxy(self, method, args) { const arr = /* @__PURE__ */ toRaw(self); track(arr, "iterate", ARRAY_ITERATE_KEY); const res = arr[method](...args); if ((res === -1 || res === false) && /* @__PURE__ */ isProxy(args[0])) { args[0] = /* @__PURE__ */ toRaw(args[0]); return arr[method](...args); } return res; } function noTracking(self, method, args = []) { pauseTracking(); startBatch(); const res = (/* @__PURE__ */ toRaw(self))[method].apply(self, args); endBatch(); resetTracking(); return res; } var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)); function hasOwnProperty(key) { if (!isSymbol(key)) key = String(key); const obj = /* @__PURE__ */ toRaw(this); track(obj, "has", key); return obj.hasOwnProperty(key); } var BaseReactiveHandler = class { constructor(_isReadonly = false, _isShallow = false) { this._isReadonly = _isReadonly; this._isShallow = _isShallow; } get(target, key, receiver) { if (key === "__v_skip") return target["__v_skip"]; const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow; if (key === "__v_isReactive") return !isReadonly2; else if (key === "__v_isReadonly") return isReadonly2; else if (key === "__v_isShallow") return isShallow2; else if (key === "__v_raw") { if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) return target; return; } const targetIsArray = isArray(target); if (!isReadonly2) { let fn; if (targetIsArray && (fn = arrayInstrumentations[key])) return fn; if (key === "hasOwnProperty") return hasOwnProperty; } const res = Reflect.get(target, key, /* @__PURE__ */ isRef(target) ? target : receiver); if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) return res; if (!isReadonly2) track(target, "get", key); if (isShallow2) return res; if (/* @__PURE__ */ isRef(res)) { const value = targetIsArray && isIntegerKey(key) ? res : res.value; return isReadonly2 && isObject$2(value) ? /* @__PURE__ */ readonly(value) : value; } if (isObject$2(res)) return isReadonly2 ? /* @__PURE__ */ readonly(res) : /* @__PURE__ */ reactive(res); return res; } }; var MutableReactiveHandler = class extends BaseReactiveHandler { constructor(isShallow2 = false) { super(false, isShallow2); } set(target, key, value, receiver) { let oldValue = target[key]; const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key); if (!this._isShallow) { const isOldValueReadonly = /* @__PURE__ */ isReadonly(oldValue); if (!/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) { oldValue = /* @__PURE__ */ toRaw(oldValue); value = /* @__PURE__ */ toRaw(value); } if (!isArrayWithIntegerKey && /* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) if (isOldValueReadonly) return true; else { oldValue.value = value; return true; } } const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key); const result = Reflect.set(target, key, value, /* @__PURE__ */ isRef(target) ? target : receiver); if (target === /* @__PURE__ */ toRaw(receiver)) { if (!hadKey) trigger(target, "add", key, value); else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue); } return result; } deleteProperty(target, key) { const hadKey = hasOwn(target, key); const oldValue = target[key]; const result = Reflect.deleteProperty(target, key); if (result && hadKey) trigger(target, "delete", key, void 0, oldValue); return result; } has(target, key) { const result = Reflect.has(target, key); if (!isSymbol(key) || !builtInSymbols.has(key)) track(target, "has", key); return result; } ownKeys(target) { track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY); return Reflect.ownKeys(target); } }; var ReadonlyReactiveHandler = class extends BaseReactiveHandler { constructor(isShallow2 = false) { super(true, isShallow2); } set(target, key) { return true; } deleteProperty(target, key) { return true; } }; var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler(); var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(); var shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true); var shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true); var toShallow = (value) => value; var getProto = (v) => Reflect.getPrototypeOf(v); function createIterableMethod(method, isReadonly2, isShallow2) { return function(...args) { const target = this["__v_raw"]; const rawTarget = /* @__PURE__ */ toRaw(target); const targetIsMap = isMap(rawTarget); const isPair = method === "entries" || method === Symbol.iterator && targetIsMap; const isKeyOnly = method === "keys" && targetIsMap; const innerIterator = target[method](...args); const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive; !isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); return extend(Object.create(innerIterator), { next() { const { value, done } = innerIterator.next(); return done ? { value, done } : { value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), done }; } }); }; } function createReadonlyMethod(type) { return function(...args) { return type === "delete" ? false : type === "clear" ? void 0 : this; }; } function createInstrumentations(readonly, shallow) { const instrumentations = { get(key) { const target = this["__v_raw"]; const rawTarget = /* @__PURE__ */ toRaw(target); const rawKey = /* @__PURE__ */ toRaw(key); if (!readonly) { if (hasChanged(key, rawKey)) track(rawTarget, "get", key); track(rawTarget, "get", rawKey); } const { has } = getProto(rawTarget); const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive; if (has.call(rawTarget, key)) return wrap(target.get(key)); else if (has.call(rawTarget, rawKey)) return wrap(target.get(rawKey)); else if (target !== rawTarget) target.get(key); }, get size() { const target = this["__v_raw"]; !readonly && track(/* @__PURE__ */ toRaw(target), "iterate", ITERATE_KEY); return target.size; }, has(key) { const target = this["__v_raw"]; const rawTarget = /* @__PURE__ */ toRaw(target); const rawKey = /* @__PURE__ */ toRaw(key); if (!readonly) { if (hasChanged(key, rawKey)) track(rawTarget, "has", key); track(rawTarget, "has", rawKey); } return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); }, forEach(callback, thisArg) { const observed = this; const target = observed["__v_raw"]; const rawTarget = /* @__PURE__ */ toRaw(target); const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive; !readonly && track(rawTarget, "iterate", ITERATE_KEY); return target.forEach((value, key) => { return callback.call(thisArg, wrap(value), wrap(key), observed); }); } }; extend(instrumentations, readonly ? { add: createReadonlyMethod("add"), set: createReadonlyMethod("set"), delete: createReadonlyMethod("delete"), clear: createReadonlyMethod("clear") } : { add(value) { const target = /* @__PURE__ */ toRaw(this); const proto = getProto(target); const rawValue = /* @__PURE__ */ toRaw(value); const valueToAdd = !shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value) ? rawValue : value; if (!(proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue))) { target.add(valueToAdd); trigger(target, "add", valueToAdd, valueToAdd); } return this; }, set(key, value) { if (!shallow && !/* @__PURE__ */ isShallow(value) && !/* @__PURE__ */ isReadonly(value)) value = /* @__PURE__ */ toRaw(value); const target = /* @__PURE__ */ toRaw(this); const { has, get } = getProto(target); let hadKey = has.call(target, key); if (!hadKey) { key = /* @__PURE__ */ toRaw(key); hadKey = has.call(target, key); } const oldValue = get.call(target, key); target.set(key, value); if (!hadKey) trigger(target, "add", key, value); else if (hasChanged(value, oldValue)) trigger(target, "set", key, value, oldValue); return this; }, delete(key) { const target = /* @__PURE__ */ toRaw(this); const { has, get } = getProto(target); let hadKey = has.call(target, key); if (!hadKey) { key = /* @__PURE__ */ toRaw(key); hadKey = has.call(target, key); } const oldValue = get ? get.call(target, key) : void 0; const result = target.delete(key); if (hadKey) trigger(target, "delete", key, void 0, oldValue); return result; }, clear() { const target = /* @__PURE__ */ toRaw(this); const hadItems = target.size !== 0; const oldTarget = void 0; const result = target.clear(); if (hadItems) trigger(target, "clear", void 0, void 0, oldTarget); return result; } }); [ "keys", "values", "entries", Symbol.iterator ].forEach((method) => { instrumentations[method] = createIterableMethod(method, readonly, shallow); }); return instrumentations; } function createInstrumentationGetter(isReadonly2, shallow) { const instrumentations = createInstrumentations(isReadonly2, shallow); return (target, key, receiver) => { if (key === "__v_isReactive") return !isReadonly2; else if (key === "__v_isReadonly") return isReadonly2; else if (key === "__v_raw") return target; return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); }; } var mutableCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, false) }; var shallowCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(false, true) }; var readonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, false) }; var shallowReadonlyCollectionHandlers = { get: /* @__PURE__ */ createInstrumentationGetter(true, true) }; var reactiveMap = /* @__PURE__ */ new WeakMap(); var shallowReactiveMap = /* @__PURE__ */ new WeakMap(); var readonlyMap = /* @__PURE__ */ new WeakMap(); var shallowReadonlyMap = /* @__PURE__ */ new WeakMap(); function targetTypeMap(rawType) { switch (rawType) { case "Object": case "Array": return 1; case "Map": case "Set": case "WeakMap": case "WeakSet": return 2; default: return 0; } } function getTargetType(value) { return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value)); } // @__NO_SIDE_EFFECTS__ function reactive(target) { if (/* @__PURE__ */ isReadonly(target)) return target; return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); } // @__NO_SIDE_EFFECTS__ function shallowReactive(target) { return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); } // @__NO_SIDE_EFFECTS__ function readonly(target) { return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); } // @__NO_SIDE_EFFECTS__ function shallowReadonly(target) { return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); } function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) { if (!isObject$2(target)) return target; if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) return target; const targetType = getTargetType(target); if (targetType === 0) return target; const existingProxy = proxyMap.get(target); if (existingProxy) return existingProxy; const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers); proxyMap.set(target, proxy); return proxy; } // @__NO_SIDE_EFFECTS__ function isReactive(value) { if (/* @__PURE__ */ isReadonly(value)) return /* @__PURE__ */ isReactive(value["__v_raw"]); return !!(value && value["__v_isReactive"]); } // @__NO_SIDE_EFFECTS__ function isReadonly(value) { return !!(value && value["__v_isReadonly"]); } // @__NO_SIDE_EFFECTS__ function isShallow(value) { return !!(value && value["__v_isShallow"]); } // @__NO_SIDE_EFFECTS__ function isProxy(value) { return value ? !!value["__v_raw"] : false; } // @__NO_SIDE_EFFECTS__ function toRaw(observed) { const raw = observed && observed["__v_raw"]; return raw ? /* @__PURE__ */ toRaw(raw) : observed; } function markRaw(value) { if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) def(value, "__v_skip", true); return value; } var toReactive = (value) => isObject$2(value) ? /* @__PURE__ */ reactive(value) : value; var toReadonly = (value) => isObject$2(value) ? /* @__PURE__ */ readonly(value) : value; // @__NO_SIDE_EFFECTS__ function isRef(r) { return r ? r["__v_isRef"] === true : false; } // @__NO_SIDE_EFFECTS__ function ref(value) { return createRef(value, false); } // @__NO_SIDE_EFFECTS__ function shallowRef(value) { return createRef(value, true); } function createRef(rawValue, shallow) { if (/* @__PURE__ */ isRef(rawValue)) return rawValue; return new RefImpl(rawValue, shallow); } var RefImpl = class { constructor(value, isShallow2) { this.dep = new Dep(); this["__v_isRef"] = true; this["__v_isShallow"] = false; this._rawValue = isShallow2 ? value : /* @__PURE__ */ toRaw(value); this._value = isShallow2 ? value : toReactive(value); this["__v_isShallow"] = isShallow2; } get value() { this.dep.track(); return this._value; } set value(newValue) { const oldValue = this._rawValue; const useDirectValue = this["__v_isShallow"] || /* @__PURE__ */ isShallow(newValue) || /* @__PURE__ */ isReadonly(newValue); newValue = useDirectValue ? newValue : /* @__PURE__ */ toRaw(newValue); if (hasChanged(newValue, oldValue)) { this._rawValue = newValue; this._value = useDirectValue ? newValue : toReactive(newValue); this.dep.trigger(); } } }; function triggerRef(ref2) { if (ref2.dep) ref2.dep.trigger(); } function unref(ref2) { return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2; } function toValue$1(source) { return isFunction$2(source) ? source() : unref(source); } var shallowUnwrapHandlers = { get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)), set: (target, key, value, receiver) => { const oldValue = target[key]; if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) { oldValue.value = value; return true; } else return Reflect.set(target, key, value, receiver); } }; function proxyRefs(objectWithRefs) { return /* @__PURE__ */ isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers); } var CustomRefImpl = class { constructor(factory) { this["__v_isRef"] = true; this._value = void 0; const dep = this.dep = new Dep(); const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep)); this._get = get; this._set = set; } get value() { return this._value = this._get(); } set value(newVal) { this._set(newVal); } }; function customRef(factory) { return new CustomRefImpl(factory); } // @__NO_SIDE_EFFECTS__ function toRefs(object) { const ret = isArray(object) ? new Array(object.length) : {}; for (const key in object) ret[key] = propertyToRef(object, key); return ret; } var ObjectRefImpl = class { constructor(_object, key, _defaultValue) { this._object = _object; this._defaultValue = _defaultValue; this["__v_isRef"] = true; this._value = void 0; this._key = isSymbol(key) ? key : String(key); this._raw = /* @__PURE__ */ toRaw(_object); let shallow = true; let obj = _object; if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) do shallow = !/* @__PURE__ */ isProxy(obj) || /* @__PURE__ */ isShallow(obj); while (shallow && (obj = obj["__v_raw"])); this._shallow = shallow; } get value() { let val = this._object[this._key]; if (this._shallow) val = unref(val); return this._value = val === void 0 ? this._defaultValue : val; } set value(newVal) { if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) { const nestedRef = this._object[this._key]; if (/* @__PURE__ */ isRef(nestedRef)) { nestedRef.value = newVal; return; } } this._object[this._key] = newVal; } get dep() { return getDepFromReactive(this._raw, this._key); } }; var GetterRefImpl = class { constructor(_getter) { this._getter = _getter; this["__v_isRef"] = true; this["__v_isReadonly"] = true; this._value = void 0; } get value() { return this._value = this._getter(); } }; // @__NO_SIDE_EFFECTS__ function toRef(source, key, defaultValue) { if (/* @__PURE__ */ isRef(source)) return source; else if (isFunction$2(source)) return new GetterRefImpl(source); else if (isObject$2(source) && arguments.length > 1) return propertyToRef(source, key, defaultValue); else return /* @__PURE__ */ ref(source); } function propertyToRef(source, key, defaultValue) { return new ObjectRefImpl(source, key, defaultValue); } var ComputedRefImpl = class { constructor(fn, setter, isSSR) { this.fn = fn; this.setter = setter; /** * @internal */ this._value = void 0; /** * @internal */ this.dep = new Dep(this); /** * @internal */ this.__v_isRef = true; /** * @internal */ this.deps = void 0; /** * @internal */ this.depsTail = void 0; /** * @internal */ this.flags = 16; /** * @internal */ this.globalVersion = globalVersion - 1; /** * @internal */ this.next = void 0; this.effect = this; this["__v_isReadonly"] = !setter; this.isSSR = isSSR; } /** * @internal */ notify() { this.flags |= 16; if (!(this.flags & 8) && activeSub !== this) { batch(this, true); return true; } } get value() { const link = this.dep.track(); refreshComputed(this); if (link) link.version = this.dep.version; return this._value; } set value(newValue) { if (this.setter) this.setter(newValue); } }; // @__NO_SIDE_EFFECTS__ function computed$1(getterOrOptions, debugOptions, isSSR = false) { let getter; let setter; if (isFunction$2(getterOrOptions)) getter = getterOrOptions; else { getter = getterOrOptions.get; setter = getterOrOptions.set; } return new ComputedRefImpl(getter, setter, isSSR); } var TrackOpTypes = { "GET": "get", "HAS": "has", "ITERATE": "iterate" }; var TriggerOpTypes = { "SET": "set", "ADD": "add", "DELETE": "delete", "CLEAR": "clear" }; var INITIAL_WATCHER_VALUE = {}; var cleanupMap = /* @__PURE__ */ new WeakMap(); var activeWatcher = void 0; function getCurrentWatcher() { return activeWatcher; } function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) { if (owner) { let cleanups = cleanupMap.get(owner); if (!cleanups) cleanupMap.set(owner, cleanups = []); cleanups.push(cleanupFn); } } function watch$1(source, cb, options = EMPTY_OBJ) { const { immediate, deep, once, scheduler, augmentJob, call } = options; const reactiveGetter = (source2) => { if (deep) return source2; if (/* @__PURE__ */ isShallow(source2) || deep === false || deep === 0) return traverse(source2, 1); return traverse(source2); }; let effect; let getter; let cleanup; let boundCleanup; let forceTrigger = false; let isMultiSource = false; if (/* @__PURE__ */ isRef(source)) { getter = () => source.value; forceTrigger = /* @__PURE__ */ isShallow(source); } else if (/* @__PURE__ */ isReactive(source)) { getter = () => reactiveGetter(source); forceTrigger = true; } else if (isArray(source)) { isMultiSource = true; forceTrigger = source.some((s) => /* @__PURE__ */ isReactive(s) || /* @__PURE__ */ isShallow(s)); getter = () => source.map((s) => { if (/* @__PURE__ */ isRef(s)) return s.value; else if (/* @__PURE__ */ isReactive(s)) return reactiveGetter(s); else if (isFunction$2(s)) return call ? call(s, 2) : s(); }); } else if (isFunction$2(source)) if (cb) getter = call ? () => call(source, 2) : source; else getter = () => { if (cleanup) { pauseTracking(); try { cleanup(); } finally { resetTracking(); } } const currentEffect = activeWatcher; activeWatcher = effect; try { return call ? call(source, 3, [boundCleanup]) : source(boundCleanup); } finally { activeWatcher = currentEffect; } }; else getter = NOOP; if (cb && deep) { const baseGetter = getter; const depth = deep === true ? Infinity : deep; getter = () => traverse(baseGetter(), depth); } const scope = getCurrentScope$1(); const watchHandle = () => { effect.stop(); if (scope && scope.active) remove(scope.effects, effect); }; if (once && cb) { const _cb = cb; cb = (...args) => { _cb(...args); watchHandle(); }; } let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE; const job = (immediateFirstRun) => { if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) return; if (cb) { const newValue = effect.run(); if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) { if (cleanup) cleanup(); const currentWatcher = activeWatcher; activeWatcher = effect; try { const args = [ newValue, oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue, boundCleanup ]; oldValue = newValue; call ? call(cb, 3, args) : cb(...args); } finally { activeWatcher = currentWatcher; } } } else effect.run(); }; if (augmentJob) augmentJob(job); effect = new ReactiveEffect(getter); effect.scheduler = scheduler ? () => scheduler(job, false) : job; boundCleanup = (fn) => onWatcherCleanup(fn, false, effect); cleanup = effect.onStop = () => { const cleanups = cleanupMap.get(effect); if (cleanups) { if (call) call(cleanups, 4); else for (const cleanup2 of cleanups) cleanup2(); cleanupMap.delete(effect); } }; if (cb) if (immediate) job(true); else oldValue = effect.run(); else if (scheduler) scheduler(job.bind(null, true), true); else effect.run(); watchHandle.pause = effect.pause.bind(effect); watchHandle.resume = effect.resume.bind(effect); watchHandle.stop = watchHandle; return watchHandle; } function traverse(value, depth = Infinity, seen) { if (depth <= 0 || !isObject$2(value) || value["__v_skip"]) return value; seen = seen || /* @__PURE__ */ new Map(); if ((seen.get(value) || 0) >= depth) return value; seen.set(value, depth); depth--; if (/* @__PURE__ */ isRef(value)) traverse(value.value, depth, seen); else if (isArray(value)) for (let i = 0; i < value.length; i++) traverse(value[i], depth, seen); else if (isSet(value) || isMap(value)) value.forEach((v) => { traverse(v, depth, seen); }); else if (isPlainObject$3(value)) { for (const key in value) traverse(value[key], depth, seen); for (const key of Object.getOwnPropertySymbols(value)) if (Object.prototype.propertyIsEnumerable.call(value, key)) traverse(value[key], depth, seen); } return value; } //#endregion //#region ../../node_modules/.pnpm/@vue+runtime-core@3.5.33/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js /** * @vue/runtime-core v3.5.33 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ var stack = []; function pushWarningContext(vnode) { stack.push(vnode); } function popWarningContext() { stack.pop(); } function assertNumber(val, type) {} var ErrorCodes = { "SETUP_FUNCTION": 0, "0": "SETUP_FUNCTION", "RENDER_FUNCTION": 1, "1": "RENDER_FUNCTION", "NATIVE_EVENT_HANDLER": 5, "5": "NATIVE_EVENT_HANDLER", "COMPONENT_EVENT_HANDLER": 6, "6": "COMPONENT_EVENT_HANDLER", "VNODE_HOOK": 7, "7": "VNODE_HOOK", "DIRECTIVE_HOOK": 8, "8": "DIRECTIVE_HOOK", "TRANSITION_HOOK": 9, "9": "TRANSITION_HOOK", "APP_ERROR_HANDLER": 10, "10": "APP_ERROR_HANDLER", "APP_WARN_HANDLER": 11, "11": "APP_WARN_HANDLER", "FUNCTION_REF": 12, "12": "FUNCTION_REF", "ASYNC_COMPONENT_LOADER": 13, "13": "ASYNC_COMPONENT_LOADER", "SCHEDULER": 14, "14": "SCHEDULER", "COMPONENT_UPDATE": 15, "15": "COMPONENT_UPDATE", "APP_UNMOUNT_CLEANUP": 16, "16": "APP_UNMOUNT_CLEANUP" }; var ErrorTypeStrings$1 = { ["sp"]: "serverPrefetch hook", ["bc"]: "beforeCreate hook", ["c"]: "created hook", ["bm"]: "beforeMount hook", ["m"]: "mounted hook", ["bu"]: "beforeUpdate hook", ["u"]: "updated", ["bum"]: "beforeUnmount hook", ["um"]: "unmounted hook", ["a"]: "activated hook", ["da"]: "deactivated hook", ["ec"]: "errorCaptured hook", ["rtc"]: "renderTracked hook", ["rtg"]: "renderTriggered hook", [0]: "setup function", [1]: "render function", [2]: "watcher getter", [3]: "watcher callback", [4]: "watcher cleanup function", [5]: "native event handler", [6]: "component event handler", [7]: "vnode hook", [8]: "directive hook", [9]: "transition hook", [10]: "app errorHandler", [11]: "app warnHandler", [12]: "ref function", [13]: "async component loader", [14]: "scheduler flush", [15]: "component update", [16]: "app unmount cleanup function" }; function callWithErrorHandling(fn, instance, type, args) { try { return args ? fn(...args) : fn(); } catch (err) { handleError(err, instance, type); } } function callWithAsyncErrorHandling(fn, instance, type, args) { if (isFunction$2(fn)) { const res = callWithErrorHandling(fn, instance, type, args); if (res && isPromise(res)) res.catch((err) => { handleError(err, instance, type); }); return res; } if (isArray(fn)) { const values = []; for (let i = 0; i < fn.length; i++) values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)); return values; } } function handleError(err, instance, type, throwInDev = true) { const contextVNode = instance ? instance.vnode : null; const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || EMPTY_OBJ; if (instance) { let cur = instance.parent; const exposedInstance = instance.proxy; const errorInfo = `https://vuejs.org/error-reference/#runtime-${type}`; while (cur) { const errorCapturedHooks = cur.ec; if (errorCapturedHooks) { for (let i = 0; i < errorCapturedHooks.length; i++) if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) return; } cur = cur.parent; } if (errorHandler) { pauseTracking(); callWithErrorHandling(errorHandler, null, 10, [ err, exposedInstance, errorInfo ]); resetTracking(); return; } } logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction); } function logError(err, type, contextVNode, throwInDev = true, throwInProd = false) { if (throwInProd) throw err; else console.error(err); } var queue = []; var flushIndex = -1; var pendingPostFlushCbs = []; var activePostFlushCbs = null; var postFlushIndex = 0; var resolvedPromise = /* @__PURE__ */ Promise.resolve(); var currentFlushPromise = null; function nextTick(fn) { const p = currentFlushPromise || resolvedPromise; return fn ? p.then(this ? fn.bind(this) : fn) : p; } function findInsertionIndex(id) { let start = flushIndex + 1; let end = queue.length; while (start < end) { const middle = start + end >>> 1; const middleJob = queue[middle]; const middleJobId = getId(middleJob); if (middleJobId < id || middleJobId === id && middleJob.flags & 2) start = middle + 1; else end = middle; } return start; } function queueJob(job) { if (!(job.flags & 1)) { const jobId = getId(job); const lastJob = queue[queue.length - 1]; if (!lastJob || !(job.flags & 2) && jobId >= getId(lastJob)) queue.push(job); else queue.splice(findInsertionIndex(jobId), 0, job); job.flags |= 1; queueFlush(); } } function queueFlush() { if (!currentFlushPromise) currentFlushPromise = resolvedPromise.then(flushJobs); } function queuePostFlushCb(cb) { if (!isArray(cb)) { if (activePostFlushCbs && cb.id === -1) activePostFlushCbs.splice(postFlushIndex + 1, 0, cb); else if (!(cb.flags & 1)) { pendingPostFlushCbs.push(cb); cb.flags |= 1; } } else pendingPostFlushCbs.push(...cb); queueFlush(); } function flushPreFlushCbs(instance, seen, i = flushIndex + 1) { for (; i < queue.length; i++) { const cb = queue[i]; if (cb && cb.flags & 2) { if (instance && cb.id !== instance.uid) continue; queue.splice(i, 1); i--; if (cb.flags & 4) cb.flags &= -2; cb(); if (!(cb.flags & 4)) cb.flags &= -2; } } } function flushPostFlushCbs(seen) { if (pendingPostFlushCbs.length) { const deduped = [...new Set(pendingPostFlushCbs)].sort((a, b) => getId(a) - getId(b)); pendingPostFlushCbs.length = 0; if (activePostFlushCbs) { activePostFlushCbs.push(...deduped); return; } activePostFlushCbs = deduped; for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) { const cb = activePostFlushCbs[postFlushIndex]; if (cb.flags & 4) cb.flags &= -2; if (!(cb.flags & 8)) cb(); cb.flags &= -2; } activePostFlushCbs = null; postFlushIndex = 0; } } var getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id; function flushJobs(seen) { try { for (flushIndex = 0; flushIndex < queue.length; flushIndex++) { const job = queue[flushIndex]; if (job && !(job.flags & 8)) { if (job.flags & 4) job.flags &= -2; callWithErrorHandling(job, job.i, job.i ? 15 : 14); if (!(job.flags & 4)) job.flags &= -2; } } } finally { for (; flushIndex < queue.length; flushIndex++) { const job = queue[flushIndex]; if (job) job.flags &= -2; } flushIndex = -1; queue.length = 0; flushPostFlushCbs(seen); currentFlushPromise = null; if (queue.length || pendingPostFlushCbs.length) flushJobs(seen); } } var devtools$1; var buffer = []; function setDevtoolsHook$1(hook, target) { var _a, _b; devtools$1 = hook; if (devtools$1) { devtools$1.enabled = true; buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args)); buffer = []; } else if (typeof window !== "undefined" && window.HTMLElement && !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))) { (target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((newHook) => { setDevtoolsHook$1(newHook, target); }); setTimeout(() => { if (!devtools$1) { target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null; buffer = []; } }, 3e3); } else buffer = []; } var currentRenderingInstance = null; var currentScopeId = null; function setCurrentRenderingInstance(instance) { const prev = currentRenderingInstance; currentRenderingInstance = instance; currentScopeId = instance && instance.type.__scopeId || null; return prev; } function pushScopeId(id) { currentScopeId = id; } function popScopeId() { currentScopeId = null; } var withScopeId = (_id) => withCtx; function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) { if (!ctx) return fn; if (fn._n) return fn; const renderFnWithContext = (...args) => { if (renderFnWithContext._d) setBlockTracking(-1); const prevInstance = setCurrentRenderingInstance(ctx); let res; try { res = fn(...args); } finally { setCurrentRenderingInstance(prevInstance); if (renderFnWithContext._d) setBlockTracking(1); } return res; }; renderFnWithContext._n = true; renderFnWithContext._c = true; renderFnWithContext._d = true; return renderFnWithContext; } function withDirectives(vnode, directives) { if (currentRenderingInstance === null) return vnode; const instance = getComponentPublicInstance(currentRenderingInstance); const bindings = vnode.dirs || (vnode.dirs = []); for (let i = 0; i < directives.length; i++) { let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i]; if (dir) { if (isFunction$2(dir)) dir = { mounted: dir, updated: dir }; if (dir.deep) traverse(value); bindings.push({ dir, instance, value, oldValue: void 0, arg, modifiers }); } } return vnode; } function invokeDirectiveHook(vnode, prevVNode, instance, name) { const bindings = vnode.dirs; const oldBindings = prevVNode && prevVNode.dirs; for (let i = 0; i < bindings.length; i++) { const binding = bindings[i]; if (oldBindings) binding.oldValue = oldBindings[i].value; let hook = binding.dir[name]; if (hook) { pauseTracking(); callWithAsyncErrorHandling(hook, instance, 8, [ vnode.el, binding, vnode, prevVNode ]); resetTracking(); } } } function provide(key, value) { if (currentInstance) { let provides = currentInstance.provides; const parentProvides = currentInstance.parent && currentInstance.parent.provides; if (parentProvides === provides) provides = currentInstance.provides = Object.create(parentProvides); provides[key] = value; } } function inject(key, defaultValue, treatDefaultAsFactory = false) { const instance = getCurrentInstance(); if (instance || currentApp) { let provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null || instance.ce ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0; if (provides && key in provides) return provides[key]; else if (arguments.length > 1) return treatDefaultAsFactory && isFunction$2(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue; } } function hasInjectionContext() { return !!(getCurrentInstance() || currentApp); } var ssrContextKey = /* @__PURE__ */ Symbol.for("v-scx"); var useSSRContext = () => { { const ctx = inject(ssrContextKey); if (!ctx) {} return ctx; } }; function watchEffect(effect, options) { return doWatch(effect, null, options); } function watchPostEffect(effect, options) { return doWatch(effect, null, { flush: "post" }); } function watchSyncEffect(effect, options) { return doWatch(effect, null, { flush: "sync" }); } function watch(source, cb, options) { return doWatch(source, cb, options); } function doWatch(source, cb, options = EMPTY_OBJ) { const { immediate, deep, flush, once } = options; const baseWatchOptions = extend({}, options); const runsImmediately = cb && immediate || !cb && flush !== "post"; let ssrCleanup; if (isInSSRComponentSetup) { if (flush === "sync") { const ctx = useSSRContext(); ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []); } else if (!runsImmediately) { const watchStopHandle = () => {}; watchStopHandle.stop = NOOP; watchStopHandle.resume = NOOP; watchStopHandle.pause = NOOP; return watchStopHandle; } } const instance = currentInstance; baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args); let isPre = false; if (flush === "post") baseWatchOptions.scheduler = (job) => { queuePostRenderEffect(job, instance && instance.suspense); }; else if (flush !== "sync") { isPre = true; baseWatchOptions.scheduler = (job, isFirstRun) => { if (isFirstRun) job(); else queueJob(job); }; } baseWatchOptions.augmentJob = (job) => { if (cb) job.flags |= 4; if (isPre) { job.flags |= 2; if (instance) { job.id = instance.uid; job.i = instance; } } }; const watchHandle = watch$1(source, cb, baseWatchOptions); if (isInSSRComponentSetup) { if (ssrCleanup) ssrCleanup.push(watchHandle); else if (runsImmediately) watchHandle(); } return watchHandle; } function instanceWatch(source, value, options) { const publicThis = this.proxy; const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis); let cb; if (isFunction$2(value)) cb = value; else { cb = value.handler; options = value; } const reset = setCurrentInstance(this); const res = doWatch(getter, cb.bind(publicThis), options); reset(); return res; } function createPathGetter(ctx, path) { const segments = path.split("."); return () => { let cur = ctx; for (let i = 0; i < segments.length && cur; i++) cur = cur[segments[i]]; return cur; }; } var pendingMounts = /* @__PURE__ */ new WeakMap(); var TeleportEndKey = /* @__PURE__ */ Symbol("_vte"); var isTeleport = (type) => type.__isTeleport; var isTeleportDisabled = (props) => props && (props.disabled || props.disabled === ""); var isTeleportDeferred = (props) => props && (props.defer || props.defer === ""); var isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement; var isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement; var resolveTarget = (props, select) => { const targetSelector = props && props.to; if (isString(targetSelector)) if (!select) return null; else return select(targetSelector); else return targetSelector; }; var TeleportImpl = { name: "Teleport", __isTeleport: true, process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals) { const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment, parentNode } } = internals; const disabled = isTeleportDisabled(n2.props); let { dynamicChildren } = n2; const mount = (vnode, container2, anchor2) => { if (vnode.shapeFlag & 16) mountChildren(vnode.children, container2, anchor2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); }; const mountToTarget = (vnode = n2) => { const disabled2 = isTeleportDisabled(vnode.props); const target = vnode.target = resolveTarget(vnode.props, querySelector); const targetAnchor = prepareAnchor(target, vnode, createText, insert); if (target) { if (namespace !== "svg" && isTargetSVG(target)) namespace = "svg"; else if (namespace !== "mathml" && isTargetMathML(target)) namespace = "mathml"; if (parentComponent && parentComponent.isCE) (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target); if (!disabled2) { mount(vnode, target, targetAnchor); updateCssVars(vnode, false); } } }; const queuePendingMount = (vnode) => { const mountJob = () => { if (pendingMounts.get(vnode) !== mountJob) return; pendingMounts.delete(vnode); if (isTeleportDisabled(vnode.props)) { mount(vnode, parentNode(vnode.el) || container, vnode.anchor); updateCssVars(vnode, true); } mountToTarget(vnode); }; pendingMounts.set(vnode, mountJob); queuePostRenderEffect(mountJob, parentSuspense); }; if (n1 == null) { const placeholder = n2.el = createText(""); const mainAnchor = n2.anchor = createText(""); insert(placeholder, container, anchor); insert(mainAnchor, container, anchor); if (isTeleportDeferred(n2.props) || parentSuspense && parentSuspense.pendingBranch) { queuePendingMount(n2); return; } if (disabled) { mount(n2, container, mainAnchor); updateCssVars(n2, true); } mountToTarget(); } else { n2.el = n1.el; const mainAnchor = n2.anchor = n1.anchor; const pendingMount = pendingMounts.get(n1); if (pendingMount) { pendingMount.flags |= 8; pendingMounts.delete(n1); queuePendingMount(n2); return; } n2.targetStart = n1.targetStart; const target = n2.target = n1.target; const targetAnchor = n2.targetAnchor = n1.targetAnchor; const wasDisabled = isTeleportDisabled(n1.props); const currentContainer = wasDisabled ? container : target; const currentAnchor = wasDisabled ? mainAnchor : targetAnchor; if (namespace === "svg" || isTargetSVG(target)) namespace = "svg"; else if (namespace === "mathml" || isTargetMathML(target)) namespace = "mathml"; if (dynamicChildren) { patchBlockChildren(n1.dynamicChildren, dynamicChildren, currentContainer, parentComponent, parentSuspense, namespace, slotScopeIds); traverseStaticChildren(n1, n2, true); } else if (!optimized) patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, false); if (disabled) { if (!wasDisabled) moveTeleport(n2, container, mainAnchor, internals, 1); else if (n2.props && n1.props && n2.props.to !== n1.props.to) n2.props.to = n1.props.to; } else if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) { const nextTarget = n2.target = resolveTarget(n2.props, querySelector); if (nextTarget) moveTeleport(n2, nextTarget, null, internals, 0); } else if (wasDisabled) moveTeleport(n2, target, targetAnchor, internals, 1); updateCssVars(n2, disabled); } }, remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) { const { shapeFlag, children, anchor, targetStart, targetAnchor, target, props } = vnode; let shouldRemove = doRemove || !isTeleportDisabled(props); const pendingMount = pendingMounts.get(vnode); if (pendingMount) { pendingMount.flags |= 8; pendingMounts.delete(vnode); shouldRemove = false; } if (target) { hostRemove(targetStart); hostRemove(targetAnchor); } doRemove && hostRemove(anchor); if (shapeFlag & 16) for (let i = 0; i < children.length; i++) { const child = children[i]; unmount(child, parentComponent, parentSuspense, shouldRemove, !!child.dynamicChildren); } }, move: moveTeleport, hydrate: hydrateTeleport }; function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) { if (moveType === 0) insert(vnode.targetAnchor, container, parentAnchor); const { el, anchor, shapeFlag, children, props } = vnode; const isReorder = moveType === 2; if (isReorder) insert(el, container, parentAnchor); if (!pendingMounts.has(vnode) && (!isReorder || isTeleportDisabled(props))) { if (shapeFlag & 16) for (let i = 0; i < children.length; i++) move(children[i], container, parentAnchor, 2); } if (isReorder) insert(anchor, container, parentAnchor); } function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, { o: { nextSibling, parentNode, querySelector, insert, createText } }, hydrateChildren) { function hydrateAnchor(target2, targetNode) { let targetAnchor = targetNode; while (targetAnchor) { if (targetAnchor && targetAnchor.nodeType === 8) { if (targetAnchor.data === "teleport start anchor") vnode.targetStart = targetAnchor; else if (targetAnchor.data === "teleport anchor") { vnode.targetAnchor = targetAnchor; target2._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor); break; } } targetAnchor = nextSibling(targetAnchor); } } function hydrateDisabledTeleport(node2, vnode2) { vnode2.anchor = hydrateChildren(nextSibling(node2), vnode2, parentNode(node2), parentComponent, parentSuspense, slotScopeIds, optimized); } const target = vnode.target = resolveTarget(vnode.props, querySelector); const disabled = isTeleportDisabled(vnode.props); if (target) { const targetNode = target._lpa || target.firstChild; if (vnode.shapeFlag & 16) if (disabled) { hydrateDisabledTeleport(node, vnode); hydrateAnchor(target, targetNode); if (!vnode.targetAnchor) prepareAnchor(target, vnode, createText, insert, parentNode(node) === target ? node : null); } else { vnode.anchor = nextSibling(node); hydrateAnchor(target, targetNode); if (!vnode.targetAnchor) prepareAnchor(target, vnode, createText, insert); hydrateChildren(targetNode && nextSibling(targetNode), vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized); } updateCssVars(vnode, disabled); } else if (disabled) { if (vnode.shapeFlag & 16) { hydrateDisabledTeleport(node, vnode); vnode.targetStart = node; vnode.targetAnchor = nextSibling(node); } } return vnode.anchor && nextSibling(vnode.anchor); } var Teleport = TeleportImpl; function updateCssVars(vnode, isDisabled) { const ctx = vnode.ctx; if (ctx && ctx.ut) { let node, anchor; if (isDisabled) { node = vnode.el; anchor = vnode.anchor; } else { node = vnode.targetStart; anchor = vnode.targetAnchor; } while (node && node !== anchor) { if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid); node = node.nextSibling; } ctx.ut(); } } function prepareAnchor(target, vnode, createText, insert, anchor = null) { const targetStart = vnode.targetStart = createText(""); const targetAnchor = vnode.targetAnchor = createText(""); targetStart[TeleportEndKey] = targetAnchor; if (target) { insert(targetStart, target, anchor); insert(targetAnchor, target, anchor); } return targetAnchor; } var leaveCbKey = /* @__PURE__ */ Symbol("_leaveCb"); var enterCbKey$1 = /* @__PURE__ */ Symbol("_enterCb"); function useTransitionState() { const state = { isMounted: false, isLeaving: false, isUnmounting: false, leavingVNodes: /* @__PURE__ */ new Map() }; onMounted(() => { state.isMounted = true; }); onBeforeUnmount(() => { state.isUnmounting = true; }); return state; } var TransitionHookValidator = [Function, Array]; var BaseTransitionPropsValidators = { mode: String, appear: Boolean, persisted: Boolean, onBeforeEnter: TransitionHookValidator, onEnter: TransitionHookValidator, onAfterEnter: TransitionHookValidator, onEnterCancelled: TransitionHookValidator, onBeforeLeave: TransitionHookValidator, onLeave: TransitionHookValidator, onAfterLeave: TransitionHookValidator, onLeaveCancelled: TransitionHookValidator, onBeforeAppear: TransitionHookValidator, onAppear: TransitionHookValidator, onAfterAppear: TransitionHookValidator, onAppearCancelled: TransitionHookValidator }; var recursiveGetSubtree = (instance) => { const subTree = instance.subTree; return subTree.component ? recursiveGetSubtree(subTree.component) : subTree; }; var BaseTransitionImpl = { name: `BaseTransition`, props: BaseTransitionPropsValidators, setup(props, { slots }) { const instance = getCurrentInstance(); const state = useTransitionState(); return () => { const children = slots.default && getTransitionRawChildren(slots.default(), true); const child = children && children.length ? findNonCommentChild(children) : instance.subTree ? createCommentVNode() : void 0; if (!child) return; const rawProps = /* @__PURE__ */ toRaw(props); const { mode } = rawProps; if (state.isLeaving) return emptyPlaceholder(child); const innerChild = getInnerChild$1(child); if (!innerChild) return emptyPlaceholder(child); let enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance, (hooks) => enterHooks = hooks); if (innerChild.type !== Comment) setTransitionHooks(innerChild, enterHooks); let oldInnerChild = instance.subTree && getInnerChild$1(instance.subTree); if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(oldInnerChild, innerChild) && recursiveGetSubtree(instance).type !== Comment) { let leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance); setTransitionHooks(oldInnerChild, leavingHooks); if (mode === "out-in" && innerChild.type !== Comment) { state.isLeaving = true; leavingHooks.afterLeave = () => { state.isLeaving = false; if (!(instance.job.flags & 8)) instance.update(); delete leavingHooks.afterLeave; oldInnerChild = void 0; }; return emptyPlaceholder(child); } else if (mode === "in-out" && innerChild.type !== Comment) leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => { const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild); leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild; el[leaveCbKey] = () => { earlyRemove(); el[leaveCbKey] = void 0; delete enterHooks.delayedLeave; oldInnerChild = void 0; }; enterHooks.delayedLeave = () => { delayedLeave(); delete enterHooks.delayedLeave; oldInnerChild = void 0; }; }; else oldInnerChild = void 0; } else if (oldInnerChild) oldInnerChild = void 0; return child; }; } }; function findNonCommentChild(children) { let child = children[0]; if (children.length > 1) { for (const c of children) if (c.type !== Comment) { child = c; break; } } return child; } var BaseTransition = BaseTransitionImpl; function getLeavingNodesForType(state, vnode) { const { leavingVNodes } = state; let leavingVNodesCache = leavingVNodes.get(vnode.type); if (!leavingVNodesCache) { leavingVNodesCache = /* @__PURE__ */ Object.create(null); leavingVNodes.set(vnode.type, leavingVNodesCache); } return leavingVNodesCache; } function resolveTransitionHooks(vnode, props, state, instance, postClone) { const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props; const key = String(vnode.key); const leavingVNodesCache = getLeavingNodesForType(state, vnode); const callHook = (hook, args) => { hook && callWithAsyncErrorHandling(hook, instance, 9, args); }; const callAsyncHook = (hook, args) => { const done = args[1]; callHook(hook, args); if (isArray(hook)) { if (hook.every((hook2) => hook2.length <= 1)) done(); } else if (hook.length <= 1) done(); }; const hooks = { mode, persisted, beforeEnter(el) { let hook = onBeforeEnter; if (!state.isMounted) if (appear) hook = onBeforeAppear || onBeforeEnter; else return; if (el[leaveCbKey]) el[leaveCbKey](true); const leavingVNode = leavingVNodesCache[key]; if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) leavingVNode.el[leaveCbKey](); callHook(hook, [el]); }, enter(el) { if (leavingVNodesCache[key] === vnode) return; let hook = onEnter; let afterHook = onAfterEnter; let cancelHook = onEnterCancelled; if (!state.isMounted) if (appear) { hook = onAppear || onEnter; afterHook = onAfterAppear || onAfterEnter; cancelHook = onAppearCancelled || onEnterCancelled; } else return; let called = false; el[enterCbKey$1] = (cancelled) => { if (called) return; called = true; if (cancelled) callHook(cancelHook, [el]); else callHook(afterHook, [el]); if (hooks.delayedLeave) hooks.delayedLeave(); el[enterCbKey$1] = void 0; }; const done = el[enterCbKey$1].bind(null, false); if (hook) callAsyncHook(hook, [el, done]); else done(); }, leave(el, remove) { const key2 = String(vnode.key); if (el[enterCbKey$1]) el[enterCbKey$1](true); if (state.isUnmounting) return remove(); callHook(onBeforeLeave, [el]); let called = false; el[leaveCbKey] = (cancelled) => { if (called) return; called = true; remove(); if (cancelled) callHook(onLeaveCancelled, [el]); else callHook(onAfterLeave, [el]); el[leaveCbKey] = void 0; if (leavingVNodesCache[key2] === vnode) delete leavingVNodesCache[key2]; }; const done = el[leaveCbKey].bind(null, false); leavingVNodesCache[key2] = vnode; if (onLeave) callAsyncHook(onLeave, [el, done]); else done(); }, clone(vnode2) { const hooks2 = resolveTransitionHooks(vnode2, props, state, instance, postClone); if (postClone) postClone(hooks2); return hooks2; } }; return hooks; } function emptyPlaceholder(vnode) { if (isKeepAlive(vnode)) { vnode = cloneVNode(vnode); vnode.children = null; return vnode; } } function getInnerChild$1(vnode) { if (!isKeepAlive(vnode)) { if (isTeleport(vnode.type) && vnode.children) return findNonCommentChild(vnode.children); return vnode; } if (vnode.component) return vnode.component.subTree; const { shapeFlag, children } = vnode; if (children) { if (shapeFlag & 16) return children[0]; if (shapeFlag & 32 && isFunction$2(children.default)) return children.default(); } } function setTransitionHooks(vnode, hooks) { if (vnode.shapeFlag & 6 && vnode.component) { vnode.transition = hooks; setTransitionHooks(vnode.component.subTree, hooks); } else if (vnode.shapeFlag & 128) { vnode.ssContent.transition = hooks.clone(vnode.ssContent); vnode.ssFallback.transition = hooks.clone(vnode.ssFallback); } else vnode.transition = hooks; } function getTransitionRawChildren(children, keepComment = false, parentKey) { let ret = []; let keyedFragmentCount = 0; for (let i = 0; i < children.length; i++) { let child = children[i]; const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i); if (child.type === Fragment) { if (child.patchFlag & 128) keyedFragmentCount++; ret = ret.concat(getTransitionRawChildren(child.children, keepComment, key)); } else if (keepComment || child.type !== Comment) ret.push(key != null ? cloneVNode(child, { key }) : child); } if (keyedFragmentCount > 1) for (let i = 0; i < ret.length; i++) ret[i].patchFlag = -2; return ret; } // @__NO_SIDE_EFFECTS__ function defineComponent(options, extraOptions) { return isFunction$2(options) ? /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))() : options; } function useId() { const i = getCurrentInstance(); if (i) return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++; return ""; } function markAsyncBoundary(instance) { instance.ids = [ instance.ids[0] + instance.ids[2]++ + "-", 0, 0 ]; } function useTemplateRef(key) { const i = getCurrentInstance(); const r = /* @__PURE__ */ shallowRef(null); if (i) { const refs = i.refs === EMPTY_OBJ ? i.refs = {} : i.refs; Object.defineProperty(refs, key, { enumerable: true, get: () => r.value, set: (val) => r.value = val }); } return r; } function isTemplateRefKey(refs, key) { let desc; return !!((desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable); } var pendingSetRefMap = /* @__PURE__ */ new WeakMap(); function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) { if (isArray(rawRef)) { rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount)); return; } if (isAsyncWrapper(vnode) && !isUnmount) { if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree); return; } const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el; const value = isUnmount ? null : refValue; const { i: owner, r: ref } = rawRef; const oldRef = oldRawRef && oldRawRef.r; const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs; const setupState = owner.setupState; const rawSetupState = /* @__PURE__ */ toRaw(setupState); const canSetSetupRef = setupState === EMPTY_OBJ ? NO : (key) => { if (isTemplateRefKey(refs, key)) return false; return hasOwn(rawSetupState, key); }; const canSetRef = (ref2, key) => { if (key && isTemplateRefKey(refs, key)) return false; return true; }; if (oldRef != null && oldRef !== ref) { invalidatePendingSetRef(oldRawRef); if (isString(oldRef)) { refs[oldRef] = null; if (canSetSetupRef(oldRef)) setupState[oldRef] = null; } else if (/* @__PURE__ */ isRef(oldRef)) { const oldRawRefAtom = oldRawRef; if (canSetRef(oldRef, oldRawRefAtom.k)) oldRef.value = null; if (oldRawRefAtom.k) refs[oldRawRefAtom.k] = null; } } if (isFunction$2(ref)) callWithErrorHandling(ref, owner, 12, [value, refs]); else { const _isString = isString(ref); const _isRef = /* @__PURE__ */ isRef(ref); if (_isString || _isRef) { const doSet = () => { if (rawRef.f) { const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : canSetRef(ref) || !rawRef.k ? ref.value : refs[rawRef.k]; if (isUnmount) isArray(existing) && remove(existing, refValue); else if (!isArray(existing)) if (_isString) { refs[ref] = [refValue]; if (canSetSetupRef(ref)) setupState[ref] = refs[ref]; } else { const newVal = [refValue]; if (canSetRef(ref, rawRef.k)) ref.value = newVal; if (rawRef.k) refs[rawRef.k] = newVal; } else if (!existing.includes(refValue)) existing.push(refValue); } else if (_isString) { refs[ref] = value; if (canSetSetupRef(ref)) setupState[ref] = value; } else if (_isRef) { if (canSetRef(ref, rawRef.k)) ref.value = value; if (rawRef.k) refs[rawRef.k] = value; } }; if (value) { const job = () => { doSet(); pendingSetRefMap.delete(rawRef); }; job.id = -1; pendingSetRefMap.set(rawRef, job); queuePostRenderEffect(job, parentSuspense); } else { invalidatePendingSetRef(rawRef); doSet(); } } } } function invalidatePendingSetRef(rawRef) { const pendingSetRef = pendingSetRefMap.get(rawRef); if (pendingSetRef) { pendingSetRef.flags |= 8; pendingSetRefMap.delete(rawRef); } } var hasLoggedMismatchError = false; var logMismatchError = () => { if (hasLoggedMismatchError) return; console.error("Hydration completed but contains mismatches."); hasLoggedMismatchError = true; }; var isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject"; var isMathMLContainer = (container) => container.namespaceURI.includes("MathML"); var getContainerType = (container) => { if (container.nodeType !== 1) return void 0; if (isSVGContainer(container)) return "svg"; if (isMathMLContainer(container)) return "mathml"; }; var isComment = (node) => node.nodeType === 8; function createHydrationFunctions(rendererInternals) { const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals; const hydrate = (vnode, container) => { if (!container.hasChildNodes()) { patch(null, vnode, container); flushPostFlushCbs(); container._vnode = vnode; return; } hydrateNode(container.firstChild, vnode, null, null, null); flushPostFlushCbs(); container._vnode = vnode; }; const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => { optimized = optimized || !!vnode.dynamicChildren; const isFragmentStart = isComment(node) && node.data === "["; const onMismatch = () => handleMismatch(node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragmentStart); const { type, ref, shapeFlag, patchFlag } = vnode; let domType = node.nodeType; vnode.el = node; if (patchFlag === -2) { optimized = false; vnode.dynamicChildren = null; } let nextNode = null; switch (type) { case Text: if (domType !== 3) if (vnode.children === "") { insert(vnode.el = createText(""), parentNode(node), node); nextNode = node; } else nextNode = onMismatch(); else { if (node.data !== vnode.children) { logMismatchError(); node.data = vnode.children; } nextNode = nextSibling(node); } break; case Comment: if (isTemplateNode(node)) { nextNode = nextSibling(node); replaceNode(vnode.el = node.content.firstChild, node, parentComponent); } else if (domType !== 8 || isFragmentStart) nextNode = onMismatch(); else nextNode = nextSibling(node); break; case Static: if (isFragmentStart) { node = nextSibling(node); domType = node.nodeType; } if (domType === 1 || domType === 3) { nextNode = node; const needToAdoptContent = !vnode.children.length; for (let i = 0; i < vnode.staticCount; i++) { if (needToAdoptContent) vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data; if (i === vnode.staticCount - 1) vnode.anchor = nextNode; nextNode = nextSibling(nextNode); } return isFragmentStart ? nextSibling(nextNode) : nextNode; } else onMismatch(); break; case Fragment: if (!isFragmentStart) nextNode = onMismatch(); else nextNode = hydrateFragment(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized); break; default: if (shapeFlag & 1) if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) nextNode = onMismatch(); else nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized); else if (shapeFlag & 6) { vnode.slotScopeIds = slotScopeIds; const container = parentNode(node); if (isFragmentStart) nextNode = locateClosingAnchor(node); else if (isComment(node) && node.data === "teleport start") nextNode = locateClosingAnchor(node, node.data, "teleport end"); else nextNode = nextSibling(node); mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized); if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) { let subTree; if (isFragmentStart) { subTree = createVNode(Fragment); subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild; } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div"); subTree.el = node; vnode.component.subTree = subTree; } } else if (shapeFlag & 64) if (domType !== 8) nextNode = onMismatch(); else nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren); else if (shapeFlag & 128) nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, getContainerType(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode); } if (ref != null) setRef(ref, null, parentSuspense, vnode); return nextNode; }; const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => { optimized = optimized || !!vnode.dynamicChildren; const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode; const forcePatch = type === "input" || type === "option"; if (forcePatch || patchFlag !== -1) { if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "created"); let needCallTransitionHooks = false; if (isTemplateNode(el)) { needCallTransitionHooks = needTransition(null, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear; const content = el.content.firstChild; if (needCallTransitionHooks) { const cls = content.getAttribute("class"); if (cls) content.$cls = cls; transition.beforeEnter(content); } replaceNode(content, el, parentComponent); vnode.el = el = content; } if (shapeFlag & 16 && !(props && (props.innerHTML || props.textContent))) { let next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized); while (next) { if (!isMismatchAllowed(el, 1)) logMismatchError(); const cur = next; next = next.nextSibling; remove(cur); } } else if (shapeFlag & 8) { let clientText = vnode.children; if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) clientText = clientText.slice(1); const { textContent } = el; if (textContent !== clientText && textContent !== clientText.replace(/\r\n|\r/g, "\n")) { if (!isMismatchAllowed(el, 0)) logMismatchError(); el.textContent = vnode.children; } } if (props) { if (forcePatch || !optimized || patchFlag & 48) { const isCustomElement = el.tagName.includes("-"); for (const key in props) if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || key[0] === "." || isCustomElement && !isReservedProp(key)) patchProp(el, key, null, props[key], void 0, parentComponent); } else if (props.onClick) patchProp(el, "onClick", null, props.onClick, void 0, parentComponent); else if (patchFlag & 4 && /* @__PURE__ */ isReactive(props.style)) for (const key in props.style) props.style[key]; } let vnodeHooks; if (vnodeHooks = props && props.onVnodeBeforeMount) invokeVNodeHook(vnodeHooks, parentComponent, vnode); if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "beforeMount"); if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) queueEffectWithSuspense(() => { vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode); needCallTransitionHooks && transition.enter(el); dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted"); }, parentSuspense); } return el.nextSibling; }; const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => { optimized = optimized || !!parentVNode.dynamicChildren; const children = parentVNode.children; const l = children.length; for (let i = 0; i < l; i++) { const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]); const isText = vnode.type === Text; if (node) { if (isText && !optimized) { if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) { insert(createText(node.data.slice(vnode.children.length)), container, nextSibling(node)); node.data = vnode.children; } } node = hydrateNode(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized); } else if (isText && !vnode.children) insert(vnode.el = createText(""), container); else { if (!isMismatchAllowed(container, 1)) logMismatchError(); patch(null, vnode, container, null, parentComponent, parentSuspense, getContainerType(container), slotScopeIds); } } return node; }; const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => { const { slotScopeIds: fragmentSlotScopeIds } = vnode; if (fragmentSlotScopeIds) slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds; const container = parentNode(node); const next = hydrateChildren(nextSibling(node), vnode, container, parentComponent, parentSuspense, slotScopeIds, optimized); if (next && isComment(next) && next.data === "]") return nextSibling(vnode.anchor = next); else { logMismatchError(); insert(vnode.anchor = createComment(`]`), container, next); return next; } }; const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => { if (!isMismatchAllowed(node.parentElement, 1)) logMismatchError(); vnode.el = null; if (isFragment) { const end = locateClosingAnchor(node); while (true) { const next2 = nextSibling(node); if (next2 && next2 !== end) remove(next2); else break; } } const next = nextSibling(node); const container = parentNode(node); remove(node); patch(null, vnode, container, next, parentComponent, parentSuspense, getContainerType(container), slotScopeIds); if (parentComponent) { parentComponent.vnode.el = vnode.el; updateHOCHostEl(parentComponent, vnode.el); } return next; }; const locateClosingAnchor = (node, open = "[", close = "]") => { let match = 0; while (node) { node = nextSibling(node); if (node && isComment(node)) { if (node.data === open) match++; if (node.data === close) if (match === 0) return nextSibling(node); else match--; } } return node; }; const replaceNode = (newNode, oldNode, parentComponent) => { const parentNode2 = oldNode.parentNode; if (parentNode2) parentNode2.replaceChild(newNode, oldNode); let parent = parentComponent; while (parent) { if (parent.vnode.el === oldNode) parent.vnode.el = parent.subTree.el = newNode; parent = parent.parent; } }; const isTemplateNode = (node) => { return node.nodeType === 1 && node.tagName === "TEMPLATE"; }; return [hydrate, hydrateNode]; } var allowMismatchAttr = "data-allow-mismatch"; var MismatchTypeString = { [0]: "text", [1]: "children", [2]: "class", [3]: "style", [4]: "attribute" }; function isMismatchAllowed(el, allowedType) { if (allowedType === 0 || allowedType === 1) while (el && !el.hasAttribute(allowMismatchAttr)) el = el.parentElement; const allowedAttr = el && el.getAttribute(allowMismatchAttr); if (allowedAttr == null) return false; else if (allowedAttr === "") return true; else { const list = allowedAttr.split(","); if (allowedType === 0 && list.includes("children")) return true; return list.includes(MismatchTypeString[allowedType]); } } var requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1)); var cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id)); var hydrateOnIdle = (timeout = 1e4) => (hydrate) => { const id = requestIdleCallback(hydrate, { timeout }); return () => cancelIdleCallback(id); }; function elementIsVisibleInViewport(el) { const { top, left, bottom, right } = el.getBoundingClientRect(); const { innerHeight, innerWidth } = window; return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth); } var hydrateOnVisible = (opts) => (hydrate, forEach) => { const ob = new IntersectionObserver((entries) => { for (const e of entries) { if (!e.isIntersecting) continue; ob.disconnect(); hydrate(); break; } }, opts); forEach((el) => { if (!(el instanceof Element)) return; if (elementIsVisibleInViewport(el)) { hydrate(); ob.disconnect(); return false; } ob.observe(el); }); return () => ob.disconnect(); }; var hydrateOnMediaQuery = (query) => (hydrate) => { if (query) { const mql = matchMedia(query); if (mql.matches) hydrate(); else { mql.addEventListener("change", hydrate, { once: true }); return () => mql.removeEventListener("change", hydrate); } } }; var hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => { if (isString(interactions)) interactions = [interactions]; let hasHydrated = false; const doHydrate = (e) => { if (!hasHydrated) { hasHydrated = true; teardown(); hydrate(); e.target.dispatchEvent(new e.constructor(e.type, e)); } }; const teardown = () => { forEach((el) => { for (const i of interactions) el.removeEventListener(i, doHydrate); }); }; forEach((el) => { for (const i of interactions) el.addEventListener(i, doHydrate, { once: true }); }); return teardown; }; function forEachElement(node, cb) { if (isComment(node) && node.data === "[") { let depth = 1; let next = node.nextSibling; while (next) { if (next.nodeType === 1) { if (cb(next) === false) break; } else if (isComment(next)) { if (next.data === "]") { if (--depth === 0) break; } else if (next.data === "[") depth++; } next = next.nextSibling; } } else cb(node); } var isAsyncWrapper = (i) => !!i.type.__asyncLoader; // @__NO_SIDE_EFFECTS__ function defineAsyncComponent(source) { if (isFunction$2(source)) source = { loader: source }; const { loader, loadingComponent, errorComponent, delay = 200, hydrate: hydrateStrategy, timeout, suspensible = true, onError: userOnError } = source; let pendingRequest = null; let resolvedComp; let retries = 0; const retry = () => { retries++; pendingRequest = null; return load(); }; const load = () => { let thisRequest; return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => { err = err instanceof Error ? err : new Error(String(err)); if (userOnError) return new Promise((resolve, reject) => { const userRetry = () => resolve(retry()); const userFail = () => reject(err); userOnError(err, userRetry, userFail, retries + 1); }); else throw err; }).then((comp) => { if (thisRequest !== pendingRequest && pendingRequest) return pendingRequest; if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) comp = comp.default; resolvedComp = comp; return comp; })); }; return /* @__PURE__ */ defineComponent({ name: "AsyncComponentWrapper", __asyncLoader: load, __asyncHydrate(el, instance, hydrate) { let patched = false; (instance.bu || (instance.bu = [])).push(() => patched = true); const performHydrate = () => { if (patched) return; hydrate(); }; const doHydrate = hydrateStrategy ? () => { const teardown = hydrateStrategy(performHydrate, (cb) => forEachElement(el, cb)); if (teardown) (instance.bum || (instance.bum = [])).push(teardown); } : performHydrate; if (resolvedComp) doHydrate(); else load().then(() => !instance.isUnmounted && doHydrate()); }, get __asyncResolved() { return resolvedComp; }, setup() { const instance = currentInstance; markAsyncBoundary(instance); if (resolvedComp) return () => createInnerComp(resolvedComp, instance); const onError = (err) => { pendingRequest = null; handleError(err, instance, 13, !errorComponent); }; if (suspensible && instance.suspense || isInSSRComponentSetup) return load().then((comp) => { return () => createInnerComp(comp, instance); }).catch((err) => { onError(err); return () => errorComponent ? createVNode(errorComponent, { error: err }) : null; }); const loaded = /* @__PURE__ */ ref(false); const error = /* @__PURE__ */ ref(); const delayed = /* @__PURE__ */ ref(!!delay); if (delay) setTimeout(() => { delayed.value = false; }, delay); if (timeout != null) setTimeout(() => { if (!loaded.value && !error.value) { const err = /* @__PURE__ */ new Error(`Async component timed out after ${timeout}ms.`); onError(err); error.value = err; } }, timeout); load().then(() => { loaded.value = true; if (instance.parent && isKeepAlive(instance.parent.vnode)) instance.parent.update(); }).catch((err) => { onError(err); error.value = err; }); return () => { if (loaded.value && resolvedComp) return createInnerComp(resolvedComp, instance); else if (error.value && errorComponent) return createVNode(errorComponent, { error: error.value }); else if (loadingComponent && !delayed.value) return createInnerComp(loadingComponent, instance); }; } }); } function createInnerComp(comp, parent) { const { ref: ref2, props, children, ce } = parent.vnode; const vnode = createVNode(comp, props, children); vnode.ref = ref2; vnode.ce = ce; delete parent.vnode.ce; return vnode; } var isKeepAlive = (vnode) => vnode.type.__isKeepAlive; var KeepAlive = { name: `KeepAlive`, __isKeepAlive: true, props: { include: [ String, RegExp, Array ], exclude: [ String, RegExp, Array ], max: [String, Number] }, setup(props, { slots }) { const instance = getCurrentInstance(); const sharedContext = instance.ctx; if (!sharedContext.renderer) return () => { const children = slots.default && slots.default(); return children && children.length === 1 ? children[0] : children; }; const cache = /* @__PURE__ */ new Map(); const keys = /* @__PURE__ */ new Set(); let current = null; const parentSuspense = instance.suspense; const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext; const storageContainer = createElement("div"); sharedContext.activate = (vnode, container, anchor, namespace, optimized) => { const instance2 = vnode.component; move(vnode, container, anchor, 0, parentSuspense); patch(instance2.vnode, vnode, container, anchor, instance2, parentSuspense, namespace, vnode.slotScopeIds, optimized); queuePostRenderEffect(() => { instance2.isDeactivated = false; if (instance2.a) invokeArrayFns(instance2.a); const vnodeHook = vnode.props && vnode.props.onVnodeMounted; if (vnodeHook) invokeVNodeHook(vnodeHook, instance2.parent, vnode); }, parentSuspense); }; sharedContext.deactivate = (vnode) => { const instance2 = vnode.component; invalidateMount(instance2.m); invalidateMount(instance2.a); move(vnode, storageContainer, null, 1, parentSuspense); queuePostRenderEffect(() => { if (instance2.da) invokeArrayFns(instance2.da); const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted; if (vnodeHook) invokeVNodeHook(vnodeHook, instance2.parent, vnode); instance2.isDeactivated = true; }, parentSuspense); }; function unmount(vnode) { resetShapeFlag(vnode); _unmount(vnode, instance, parentSuspense, true); } function pruneCache(filter) { cache.forEach((vnode, key) => { const name = getComponentName(isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : vnode.type); if (name && !filter(name)) pruneCacheEntry(key); }); } function pruneCacheEntry(key) { const cached = cache.get(key); if (cached && (!current || !isSameVNodeType(cached, current))) unmount(cached); else if (current) resetShapeFlag(current); cache.delete(key); keys.delete(key); } watch(() => [props.include, props.exclude], ([include, exclude]) => { include && pruneCache((name) => matches$1(include, name)); exclude && pruneCache((name) => !matches$1(exclude, name)); }, { flush: "post", deep: true }); let pendingCacheKey = null; const cacheSubtree = () => { if (pendingCacheKey != null) if (isSuspense(instance.subTree.type)) queuePostRenderEffect(() => { cache.set(pendingCacheKey, getInnerChild(instance.subTree)); }, instance.subTree.suspense); else cache.set(pendingCacheKey, getInnerChild(instance.subTree)); }; onMounted(cacheSubtree); onUpdated(cacheSubtree); onBeforeUnmount(() => { cache.forEach((cached) => { const { subTree, suspense } = instance; const vnode = getInnerChild(subTree); if (cached.type === vnode.type && cached.key === vnode.key) { resetShapeFlag(vnode); const da = vnode.component.da; da && queuePostRenderEffect(da, suspense); return; } unmount(cached); }); }); return () => { pendingCacheKey = null; if (!slots.default) return current = null; const children = slots.default(); const rawVNode = children[0]; if (children.length > 1) { current = null; return children; } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) { current = null; return rawVNode; } let vnode = getInnerChild(rawVNode); if (vnode.type === Comment) { current = null; return vnode; } const comp = vnode.type; const name = getComponentName(isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp); const { include, exclude, max } = props; if (include && (!name || !matches$1(include, name)) || exclude && name && matches$1(exclude, name)) { vnode.shapeFlag &= -257; current = vnode; return rawVNode; } const key = vnode.key == null ? comp : vnode.key; const cachedVNode = cache.get(key); if (vnode.el) { vnode = cloneVNode(vnode); if (rawVNode.shapeFlag & 128) rawVNode.ssContent = vnode; } pendingCacheKey = key; if (cachedVNode) { vnode.el = cachedVNode.el; vnode.component = cachedVNode.component; if (vnode.transition) setTransitionHooks(vnode, vnode.transition); vnode.shapeFlag |= 512; keys.delete(key); keys.add(key); } else { keys.add(key); if (max && keys.size > parseInt(max, 10)) pruneCacheEntry(keys.values().next().value); } vnode.shapeFlag |= 256; current = vnode; return isSuspense(rawVNode.type) ? rawVNode : vnode; }; } }; function matches$1(pattern, name) { if (isArray(pattern)) return pattern.some((p) => matches$1(p, name)); else if (isString(pattern)) return pattern.split(",").includes(name); else if (isRegExp(pattern)) { pattern.lastIndex = 0; return pattern.test(name); } return false; } function onActivated(hook, target) { registerKeepAliveHook(hook, "a", target); } function onDeactivated(hook, target) { registerKeepAliveHook(hook, "da", target); } function registerKeepAliveHook(hook, type, target = currentInstance) { const wrappedHook = hook.__wdc || (hook.__wdc = () => { let current = target; while (current) { if (current.isDeactivated) return; current = current.parent; } return hook(); }); injectHook(type, wrappedHook, target); if (target) { let current = target.parent; while (current && current.parent) { if (isKeepAlive(current.parent.vnode)) injectToKeepAliveRoot(wrappedHook, type, target, current); current = current.parent; } } } function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) { const injected = injectHook(type, hook, keepAliveRoot, true); onUnmounted(() => { remove(keepAliveRoot[type], injected); }, target); } function resetShapeFlag(vnode) { vnode.shapeFlag &= -257; vnode.shapeFlag &= -513; } function getInnerChild(vnode) { return vnode.shapeFlag & 128 ? vnode.ssContent : vnode; } function injectHook(type, hook, target = currentInstance, prepend = false) { if (target) { const hooks = target[type] || (target[type] = []); const wrappedHook = hook.__weh || (hook.__weh = (...args) => { pauseTracking(); const reset = setCurrentInstance(target); const res = callWithAsyncErrorHandling(hook, target, type, args); reset(); resetTracking(); return res; }); if (prepend) hooks.unshift(wrappedHook); else hooks.push(wrappedHook); return wrappedHook; } } var createHook = (lifecycle) => (hook, target = currentInstance) => { if (!isInSSRComponentSetup || lifecycle === "sp") injectHook(lifecycle, (...args) => hook(...args), target); }; var onBeforeMount = createHook("bm"); var onMounted = createHook("m"); var onBeforeUpdate = createHook("bu"); var onUpdated = createHook("u"); var onBeforeUnmount = createHook("bum"); var onUnmounted = createHook("um"); var onServerPrefetch = createHook("sp"); var onRenderTriggered = createHook("rtg"); var onRenderTracked = createHook("rtc"); function onErrorCaptured(hook, target = currentInstance) { injectHook("ec", hook, target); } var COMPONENTS = "components"; var DIRECTIVES = "directives"; function resolveComponent(name, maybeSelfReference) { return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name; } var NULL_DYNAMIC_COMPONENT = /* @__PURE__ */ Symbol.for("v-ndc"); function resolveDynamicComponent(component) { if (isString(component)) return resolveAsset(COMPONENTS, component, false) || component; else return component || NULL_DYNAMIC_COMPONENT; } function resolveDirective(name) { return resolveAsset(DIRECTIVES, name); } function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) { const instance = currentRenderingInstance || currentInstance; if (instance) { const Component = instance.type; if (type === COMPONENTS) { const selfName = getComponentName(Component, false); if (selfName && (selfName === name || selfName === camelize$2(name) || selfName === capitalize(camelize$2(name)))) return Component; } const res = resolve(instance[type] || Component[type], name) || resolve(instance.appContext[type], name); if (!res && maybeSelfReference) return Component; return res; } } function resolve(registry, name) { return registry && (registry[name] || registry[camelize$2(name)] || registry[capitalize(camelize$2(name))]); } function renderList(source, renderItem, cache, index) { let ret; const cached = cache && cache[index]; const sourceIsArray = isArray(source); if (sourceIsArray || isString(source)) { const sourceIsReactiveArray = sourceIsArray && /* @__PURE__ */ isReactive(source); let needsWrap = false; let isReadonlySource = false; if (sourceIsReactiveArray) { needsWrap = !/* @__PURE__ */ isShallow(source); isReadonlySource = /* @__PURE__ */ isReadonly(source); source = shallowReadArray(source); } ret = new Array(source.length); for (let i = 0, l = source.length; i < l; i++) ret[i] = renderItem(needsWrap ? isReadonlySource ? toReadonly(toReactive(source[i])) : toReactive(source[i]) : source[i], i, void 0, cached && cached[i]); } else if (typeof source === "number") { ret = new Array(source); for (let i = 0; i < source; i++) ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]); } else if (isObject$2(source)) if (source[Symbol.iterator]) ret = Array.from(source, (item, i) => renderItem(item, i, void 0, cached && cached[i])); else { const keys = Object.keys(source); ret = new Array(keys.length); for (let i = 0, l = keys.length; i < l; i++) { const key = keys[i]; ret[i] = renderItem(source[key], key, i, cached && cached[i]); } } else ret = []; if (cache) cache[index] = ret; return ret; } function createSlots(slots, dynamicSlots) { for (let i = 0; i < dynamicSlots.length; i++) { const slot = dynamicSlots[i]; if (isArray(slot)) for (let j = 0; j < slot.length; j++) slots[slot[j].name] = slot[j].fn; else if (slot) slots[slot.name] = slot.key ? (...args) => { const res = slot.fn(...args); if (res) res.key = slot.key; return res; } : slot.fn; } return slots; } function renderSlot(slots, name, props = {}, fallback, noSlotted) { if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) { const hasProps = Object.keys(props).length > 0; if (name !== "default") props.name = name; return openBlock(), createBlock(Fragment, null, [createVNode("slot", props, fallback && fallback())], hasProps ? -2 : 64); } let slot = slots[name]; if (slot && slot._c) slot._d = false; openBlock(); const validSlotContent = slot && ensureValidVNode(slot(props)); const slotKey = props.key || validSlotContent && validSlotContent.key; const rendered = createBlock(Fragment, { key: (slotKey && !isSymbol(slotKey) ? slotKey : `_${name}`) + (!validSlotContent && fallback ? "_fb" : "") }, validSlotContent || (fallback ? fallback() : []), validSlotContent && slots._ === 1 ? 64 : -2); if (!noSlotted && rendered.scopeId) rendered.slotScopeIds = [rendered.scopeId + "-s"]; if (slot && slot._c) slot._d = true; return rendered; } function ensureValidVNode(vnodes) { return vnodes.some((child) => { if (!isVNode(child)) return true; if (child.type === Comment) return false; if (child.type === Fragment && !ensureValidVNode(child.children)) return false; return true; }) ? vnodes : null; } function toHandlers(obj, preserveCaseIfNecessary) { const ret = {}; for (const key in obj) ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key]; return ret; } var getPublicInstance = (i) => { if (!i) return null; if (isStatefulComponent(i)) return getComponentPublicInstance(i); return getPublicInstance(i.parent); }; var publicPropertiesMap = /* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), { $: (i) => i, $el: (i) => i.vnode.el, $data: (i) => i.data, $props: (i) => i.props, $attrs: (i) => i.attrs, $slots: (i) => i.slots, $refs: (i) => i.refs, $parent: (i) => getPublicInstance(i.parent), $root: (i) => getPublicInstance(i.root), $host: (i) => i.ce, $emit: (i) => i.emit, $options: (i) => resolveMergedOptions(i), $forceUpdate: (i) => i.f || (i.f = () => { queueJob(i.update); }), $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)), $watch: (i) => instanceWatch.bind(i) }); var hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key); var PublicInstanceProxyHandlers = { get({ _: instance }, key) { if (key === "__v_skip") return true; const { ctx, setupState, data, props, accessCache, type, appContext } = instance; if (key[0] !== "$") { const n = accessCache[key]; if (n !== void 0) switch (n) { case 1: return setupState[key]; case 2: return data[key]; case 4: return ctx[key]; case 3: return props[key]; } else if (hasSetupBinding(setupState, key)) { accessCache[key] = 1; return setupState[key]; } else if (data !== EMPTY_OBJ && hasOwn(data, key)) { accessCache[key] = 2; return data[key]; } else if (hasOwn(props, key)) { accessCache[key] = 3; return props[key]; } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { accessCache[key] = 4; return ctx[key]; } else if (shouldCacheAccess) accessCache[key] = 0; } const publicGetter = publicPropertiesMap[key]; let cssModule, globalProperties; if (publicGetter) { if (key === "$attrs") track(instance.attrs, "get", ""); return publicGetter(instance); } else if ((cssModule = type.__cssModules) && (cssModule = cssModule[key])) return cssModule; else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { accessCache[key] = 4; return ctx[key]; } else if (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) return globalProperties[key]; }, set({ _: instance }, key, value) { const { data, setupState, ctx } = instance; if (hasSetupBinding(setupState, key)) { setupState[key] = value; return true; } else if (data !== EMPTY_OBJ && hasOwn(data, key)) { data[key] = value; return true; } else if (hasOwn(instance.props, key)) return false; if (key[0] === "$" && key.slice(1) in instance) return false; else ctx[key] = value; return true; }, has({ _: { data, setupState, accessCache, ctx, appContext, props, type } }, key) { let cssModules; return !!(accessCache[key] || data !== EMPTY_OBJ && key[0] !== "$" && hasOwn(data, key) || hasSetupBinding(setupState, key) || hasOwn(props, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key) || (cssModules = type.__cssModules) && cssModules[key]); }, defineProperty(target, key, descriptor) { if (descriptor.get != null) target._.accessCache[key] = 0; else if (hasOwn(descriptor, "value")) this.set(target, key, descriptor.value, null); return Reflect.defineProperty(target, key, descriptor); } }; var RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend({}, PublicInstanceProxyHandlers, { get(target, key) { if (key === Symbol.unscopables) return; return PublicInstanceProxyHandlers.get(target, key, target); }, has(_, key) { return key[0] !== "_" && !isGloballyAllowed(key); } }); function defineProps() { return null; } function defineEmits() { return null; } function defineExpose(exposed) {} function defineOptions(options) {} function defineSlots() { return null; } function defineModel() {} function withDefaults(props, defaults) { return null; } function useSlots() { return getContext("useSlots").slots; } function useAttrs() { return getContext("useAttrs").attrs; } function getContext(calledFunctionName) { const i = getCurrentInstance(); return i.setupContext || (i.setupContext = createSetupContext(i)); } function normalizePropsOrEmits(props) { return isArray(props) ? props.reduce((normalized, p) => (normalized[p] = null, normalized), {}) : props; } function mergeDefaults(raw, defaults) { const props = normalizePropsOrEmits(raw); for (const key in defaults) { if (key.startsWith("__skip")) continue; let opt = props[key]; if (opt) if (isArray(opt) || isFunction$2(opt)) opt = props[key] = { type: opt, default: defaults[key] }; else opt.default = defaults[key]; else if (opt === null) opt = props[key] = { default: defaults[key] }; if (opt && defaults[`__skip_${key}`]) opt.skipFactory = true; } return props; } function mergeModels(a, b) { if (!a || !b) return a || b; if (isArray(a) && isArray(b)) return a.concat(b); return extend({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b)); } function createPropsRestProxy(props, excludedKeys) { const ret = {}; for (const key in props) if (!excludedKeys.includes(key)) Object.defineProperty(ret, key, { enumerable: true, get: () => props[key] }); return ret; } function withAsyncContext(getAwaitable) { const ctx = getCurrentInstance(); const inSSRSetup = isInSSRComponentSetup; let awaitable = getAwaitable(); unsetCurrentInstance(); if (inSSRSetup) setInSSRSetupState(false); const restore = () => { setCurrentInstance(ctx); if (inSSRSetup) setInSSRSetupState(true); }; const cleanup = () => { if (getCurrentInstance() !== ctx) ctx.scope.off(); unsetCurrentInstance(); if (inSSRSetup) setInSSRSetupState(false); }; if (isPromise(awaitable)) awaitable = awaitable.catch((e) => { restore(); Promise.resolve().then(() => Promise.resolve().then(cleanup)); throw e; }); return [awaitable, () => { restore(); Promise.resolve().then(cleanup); }]; } var shouldCacheAccess = true; function applyOptions(instance) { const options = resolveMergedOptions(instance); const publicThis = instance.proxy; const ctx = instance.ctx; shouldCacheAccess = false; if (options.beforeCreate) callHook$1(options.beforeCreate, instance, "bc"); const { data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions, created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch, expose, inheritAttrs, components, directives, filters } = options; const checkDuplicateProperties = null; if (injectOptions) resolveInjections(injectOptions, ctx, checkDuplicateProperties); if (methods) for (const key in methods) { const methodHandler = methods[key]; if (isFunction$2(methodHandler)) ctx[key] = methodHandler.bind(publicThis); } if (dataOptions) { const data = dataOptions.call(publicThis, publicThis); if (!isObject$2(data)) {} else instance.data = /* @__PURE__ */ reactive(data); } shouldCacheAccess = true; if (computedOptions) for (const key in computedOptions) { const opt = computedOptions[key]; const c = computed({ get: isFunction$2(opt) ? opt.bind(publicThis, publicThis) : isFunction$2(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP, set: !isFunction$2(opt) && isFunction$2(opt.set) ? opt.set.bind(publicThis) : NOOP }); Object.defineProperty(ctx, key, { enumerable: true, configurable: true, get: () => c.value, set: (v) => c.value = v }); } if (watchOptions) for (const key in watchOptions) createWatcher(watchOptions[key], ctx, publicThis, key); if (provideOptions) { const provides = isFunction$2(provideOptions) ? provideOptions.call(publicThis) : provideOptions; Reflect.ownKeys(provides).forEach((key) => { provide(key, provides[key]); }); } if (created) callHook$1(created, instance, "c"); function registerLifecycleHook(register, hook) { if (isArray(hook)) hook.forEach((_hook) => register(_hook.bind(publicThis))); else if (hook) register(hook.bind(publicThis)); } registerLifecycleHook(onBeforeMount, beforeMount); registerLifecycleHook(onMounted, mounted); registerLifecycleHook(onBeforeUpdate, beforeUpdate); registerLifecycleHook(onUpdated, updated); registerLifecycleHook(onActivated, activated); registerLifecycleHook(onDeactivated, deactivated); registerLifecycleHook(onErrorCaptured, errorCaptured); registerLifecycleHook(onRenderTracked, renderTracked); registerLifecycleHook(onRenderTriggered, renderTriggered); registerLifecycleHook(onBeforeUnmount, beforeUnmount); registerLifecycleHook(onUnmounted, unmounted); registerLifecycleHook(onServerPrefetch, serverPrefetch); if (isArray(expose)) { if (expose.length) { const exposed = instance.exposed || (instance.exposed = {}); expose.forEach((key) => { Object.defineProperty(exposed, key, { get: () => publicThis[key], set: (val) => publicThis[key] = val, enumerable: true }); }); } else if (!instance.exposed) instance.exposed = {}; } if (render && instance.render === NOOP) instance.render = render; if (inheritAttrs != null) instance.inheritAttrs = inheritAttrs; if (components) instance.components = components; if (directives) instance.directives = directives; if (serverPrefetch) markAsyncBoundary(instance); } function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) { if (isArray(injectOptions)) injectOptions = normalizeInject(injectOptions); for (const key in injectOptions) { const opt = injectOptions[key]; let injected; if (isObject$2(opt)) if ("default" in opt) injected = inject(opt.from || key, opt.default, true); else injected = inject(opt.from || key); else injected = inject(opt); if (/* @__PURE__ */ isRef(injected)) Object.defineProperty(ctx, key, { enumerable: true, configurable: true, get: () => injected.value, set: (v) => injected.value = v }); else ctx[key] = injected; } } function callHook$1(hook, instance, type) { callWithAsyncErrorHandling(isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy), instance, type); } function createWatcher(raw, ctx, publicThis, key) { let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key]; if (isString(raw)) { const handler = ctx[raw]; if (isFunction$2(handler)) watch(getter, handler); } else if (isFunction$2(raw)) watch(getter, raw.bind(publicThis)); else if (isObject$2(raw)) if (isArray(raw)) raw.forEach((r) => createWatcher(r, ctx, publicThis, key)); else { const handler = isFunction$2(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler]; if (isFunction$2(handler)) watch(getter, handler, raw); } } function resolveMergedOptions(instance) { const base = instance.type; const { mixins, extends: extendsOptions } = base; const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext; const cached = cache.get(base); let resolved; if (cached) resolved = cached; else if (!globalMixins.length && !mixins && !extendsOptions) resolved = base; else { resolved = {}; if (globalMixins.length) globalMixins.forEach((m) => mergeOptions(resolved, m, optionMergeStrategies, true)); mergeOptions(resolved, base, optionMergeStrategies); } if (isObject$2(base)) cache.set(base, resolved); return resolved; } function mergeOptions(to, from, strats, asMixin = false) { const { mixins, extends: extendsOptions } = from; if (extendsOptions) mergeOptions(to, extendsOptions, strats, true); if (mixins) mixins.forEach((m) => mergeOptions(to, m, strats, true)); for (const key in from) if (asMixin && key === "expose") {} else { const strat = internalOptionMergeStrats[key] || strats && strats[key]; to[key] = strat ? strat(to[key], from[key]) : from[key]; } return to; } var internalOptionMergeStrats = { data: mergeDataFn, props: mergeEmitsOrPropsOptions, emits: mergeEmitsOrPropsOptions, methods: mergeObjectOptions, computed: mergeObjectOptions, beforeCreate: mergeAsArray, created: mergeAsArray, beforeMount: mergeAsArray, mounted: mergeAsArray, beforeUpdate: mergeAsArray, updated: mergeAsArray, beforeDestroy: mergeAsArray, beforeUnmount: mergeAsArray, destroyed: mergeAsArray, unmounted: mergeAsArray, activated: mergeAsArray, deactivated: mergeAsArray, errorCaptured: mergeAsArray, serverPrefetch: mergeAsArray, components: mergeObjectOptions, directives: mergeObjectOptions, watch: mergeWatchOptions, provide: mergeDataFn, inject: mergeInject }; function mergeDataFn(to, from) { if (!from) return to; if (!to) return from; return function mergedDataFn() { return extend(isFunction$2(to) ? to.call(this, this) : to, isFunction$2(from) ? from.call(this, this) : from); }; } function mergeInject(to, from) { return mergeObjectOptions(normalizeInject(to), normalizeInject(from)); } function normalizeInject(raw) { if (isArray(raw)) { const res = {}; for (let i = 0; i < raw.length; i++) res[raw[i]] = raw[i]; return res; } return raw; } function mergeAsArray(to, from) { return to ? [...new Set([].concat(to, from))] : from; } function mergeObjectOptions(to, from) { return to ? extend(/* @__PURE__ */ Object.create(null), to, from) : from; } function mergeEmitsOrPropsOptions(to, from) { if (to) { if (isArray(to) && isArray(from)) return [.../* @__PURE__ */ new Set([...to, ...from])]; return extend(/* @__PURE__ */ Object.create(null), normalizePropsOrEmits(to), normalizePropsOrEmits(from != null ? from : {})); } else return from; } function mergeWatchOptions(to, from) { if (!to) return from; if (!from) return to; const merged = extend(/* @__PURE__ */ Object.create(null), to); for (const key in from) merged[key] = mergeAsArray(to[key], from[key]); return merged; } function createAppContext() { return { app: null, config: { isNativeTag: NO, performance: false, globalProperties: {}, optionMergeStrategies: {}, errorHandler: void 0, warnHandler: void 0, compilerOptions: {} }, mixins: [], components: {}, directives: {}, provides: /* @__PURE__ */ Object.create(null), optionsCache: /* @__PURE__ */ new WeakMap(), propsCache: /* @__PURE__ */ new WeakMap(), emitsCache: /* @__PURE__ */ new WeakMap() }; } var uid$1 = 0; function createAppAPI(render, hydrate) { return function createApp(rootComponent, rootProps = null) { if (!isFunction$2(rootComponent)) rootComponent = extend({}, rootComponent); if (rootProps != null && !isObject$2(rootProps)) rootProps = null; const context = createAppContext(); const installedPlugins = /* @__PURE__ */ new WeakSet(); const pluginCleanupFns = []; let isMounted = false; const app = context.app = { _uid: uid$1++, _component: rootComponent, _props: rootProps, _container: null, _context: context, _instance: null, version, get config() { return context.config; }, set config(v) {}, use(plugin, ...options) { if (installedPlugins.has(plugin)) {} else if (plugin && isFunction$2(plugin.install)) { installedPlugins.add(plugin); plugin.install(app, ...options); } else if (isFunction$2(plugin)) { installedPlugins.add(plugin); plugin(app, ...options); } return app; }, mixin(mixin) { if (!context.mixins.includes(mixin)) context.mixins.push(mixin); return app; }, component(name, component) { if (!component) return context.components[name]; context.components[name] = component; return app; }, directive(name, directive) { if (!directive) return context.directives[name]; context.directives[name] = directive; return app; }, mount(rootContainer, isHydrate, namespace) { if (!isMounted) { const vnode = app._ceVNode || createVNode(rootComponent, rootProps); vnode.appContext = context; if (namespace === true) namespace = "svg"; else if (namespace === false) namespace = void 0; if (isHydrate && hydrate) hydrate(vnode, rootContainer); else render(vnode, rootContainer, namespace); isMounted = true; app._container = rootContainer; rootContainer.__vue_app__ = app; return getComponentPublicInstance(vnode.component); } }, onUnmount(cleanupFn) { pluginCleanupFns.push(cleanupFn); }, unmount() { if (isMounted) { callWithAsyncErrorHandling(pluginCleanupFns, app._instance, 16); render(null, app._container); delete app._container.__vue_app__; } }, provide(key, value) { context.provides[key] = value; return app; }, runWithContext(fn) { const lastApp = currentApp; currentApp = app; try { return fn(); } finally { currentApp = lastApp; } } }; return app; }; } var currentApp = null; function useModel(props, name, options = EMPTY_OBJ) { const i = getCurrentInstance(); const camelizedName = camelize$2(name); const hyphenatedName = hyphenate$2(name); const modifiers = getModelModifiers(props, camelizedName); const res = customRef((track, trigger) => { let localValue; let prevSetValue = EMPTY_OBJ; let prevEmittedValue; watchSyncEffect(() => { const propValue = props[camelizedName]; if (hasChanged(localValue, propValue)) { localValue = propValue; trigger(); } }); return { get() { track(); return options.get ? options.get(localValue) : localValue; }, set(value) { const emittedValue = options.set ? options.set(value) : value; if (!hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) return; const rawProps = i.vnode.props; if (!(rawProps && (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) { localValue = value; trigger(); } i.emit(`update:${name}`, emittedValue); if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) trigger(); prevSetValue = value; prevEmittedValue = emittedValue; } }; }); res[Symbol.iterator] = () => { let i2 = 0; return { next() { if (i2 < 2) return { value: i2++ ? modifiers || EMPTY_OBJ : res, done: false }; else return { done: true }; } }; }; return res; } var getModelModifiers = (props, modelName) => { return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${camelize$2(modelName)}Modifiers`] || props[`${hyphenate$2(modelName)}Modifiers`]; }; function emit(instance, event, ...rawArgs) { if (instance.isUnmounted) return; const props = instance.vnode.props || EMPTY_OBJ; let args = rawArgs; const isModelListener = event.startsWith("update:"); const modifiers = isModelListener && getModelModifiers(props, event.slice(7)); if (modifiers) { if (modifiers.trim) args = rawArgs.map((a) => isString(a) ? a.trim() : a); if (modifiers.number) args = rawArgs.map(looseToNumber); } let handlerName; let handler = props[handlerName = toHandlerKey(event)] || props[handlerName = toHandlerKey(camelize$2(event))]; if (!handler && isModelListener) handler = props[handlerName = toHandlerKey(hyphenate$2(event))]; if (handler) callWithAsyncErrorHandling(handler, instance, 6, args); const onceHandler = props[handlerName + `Once`]; if (onceHandler) { if (!instance.emitted) instance.emitted = {}; else if (instance.emitted[handlerName]) return; instance.emitted[handlerName] = true; callWithAsyncErrorHandling(onceHandler, instance, 6, args); } } var mixinEmitsCache = /* @__PURE__ */ new WeakMap(); function normalizeEmitsOptions(comp, appContext, asMixin = false) { const cache = asMixin ? mixinEmitsCache : appContext.emitsCache; const cached = cache.get(comp); if (cached !== void 0) return cached; const raw = comp.emits; let normalized = {}; let hasExtends = false; if (!isFunction$2(comp)) { const extendEmits = (raw2) => { const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true); if (normalizedFromExtend) { hasExtends = true; extend(normalized, normalizedFromExtend); } }; if (!asMixin && appContext.mixins.length) appContext.mixins.forEach(extendEmits); if (comp.extends) extendEmits(comp.extends); if (comp.mixins) comp.mixins.forEach(extendEmits); } if (!raw && !hasExtends) { if (isObject$2(comp)) cache.set(comp, null); return null; } if (isArray(raw)) raw.forEach((key) => normalized[key] = null); else extend(normalized, raw); if (isObject$2(comp)) cache.set(comp, normalized); return normalized; } function isEmitListener(options, key) { if (!options || !isOn(key)) return false; key = key.slice(2).replace(/Once$/, ""); return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate$2(key)) || hasOwn(options, key); } function renderComponentRoot(instance) { const { type: Component, vnode, proxy, withProxy, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, props, data, setupState, ctx, inheritAttrs } = instance; const prev = setCurrentRenderingInstance(instance); let result; let fallthroughAttrs; try { if (vnode.shapeFlag & 4) { const proxyToUse = withProxy || proxy; const thisProxy = proxyToUse; result = normalizeVNode(render.call(thisProxy, proxyToUse, renderCache, props, setupState, data, ctx)); fallthroughAttrs = attrs; } else { const render2 = Component; result = normalizeVNode(render2.length > 1 ? render2(props, { attrs, slots, emit }) : render2(props, null)); fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs); } } catch (err) { blockStack.length = 0; handleError(err, instance, 1); result = createVNode(Comment); } let root = result; if (fallthroughAttrs && inheritAttrs !== false) { const keys = Object.keys(fallthroughAttrs); const { shapeFlag } = root; if (keys.length) { if (shapeFlag & 7) { if (propsOptions && keys.some(isModelListener)) fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions); root = cloneVNode(root, fallthroughAttrs, false, true); } } } if (vnode.dirs) { root = cloneVNode(root, null, false, true); root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs; } if (vnode.transition) setTransitionHooks(root, vnode.transition); result = root; setCurrentRenderingInstance(prev); return result; } function filterSingleRoot(children, recurse = true) { let singleRoot; for (let i = 0; i < children.length; i++) { const child = children[i]; if (isVNode(child)) { if (child.type !== Comment || child.children === "v-if") if (singleRoot) return; else singleRoot = child; } else return; } return singleRoot; } var getFunctionalFallthrough = (attrs) => { let res; for (const key in attrs) if (key === "class" || key === "style" || isOn(key)) (res || (res = {}))[key] = attrs[key]; return res; }; var filterModelListeners = (attrs, props) => { const res = {}; for (const key in attrs) if (!isModelListener(key) || !(key.slice(9) in props)) res[key] = attrs[key]; return res; }; function shouldUpdateComponent(prevVNode, nextVNode, optimized) { const { props: prevProps, children: prevChildren, component } = prevVNode; const { props: nextProps, children: nextChildren, patchFlag } = nextVNode; const emits = component.emitsOptions; if (nextVNode.dirs || nextVNode.transition) return true; if (optimized && patchFlag >= 0) { if (patchFlag & 1024) return true; if (patchFlag & 16) { if (!prevProps) return !!nextProps; return hasPropsChanged(prevProps, nextProps, emits); } else if (patchFlag & 8) { const dynamicProps = nextVNode.dynamicProps; for (let i = 0; i < dynamicProps.length; i++) { const key = dynamicProps[i]; if (hasPropValueChanged(nextProps, prevProps, key) && !isEmitListener(emits, key)) return true; } } } else { if (prevChildren || nextChildren) { if (!nextChildren || !nextChildren.$stable) return true; } if (prevProps === nextProps) return false; if (!prevProps) return !!nextProps; if (!nextProps) return true; return hasPropsChanged(prevProps, nextProps, emits); } return false; } function hasPropsChanged(prevProps, nextProps, emitsOptions) { const nextKeys = Object.keys(nextProps); if (nextKeys.length !== Object.keys(prevProps).length) return true; for (let i = 0; i < nextKeys.length; i++) { const key = nextKeys[i]; if (hasPropValueChanged(nextProps, prevProps, key) && !isEmitListener(emitsOptions, key)) return true; } return false; } function hasPropValueChanged(nextProps, prevProps, key) { const nextProp = nextProps[key]; const prevProp = prevProps[key]; if (key === "style" && isObject$2(nextProp) && isObject$2(prevProp)) return !looseEqual(nextProp, prevProp); return nextProp !== prevProp; } function updateHOCHostEl({ vnode, parent, suspense }, el) { while (parent) { const root = parent.subTree; if (root.suspense && root.suspense.activeBranch === vnode) { root.suspense.vnode.el = root.el = el; vnode = root; } if (root === vnode) { (vnode = parent.vnode).el = el; parent = parent.parent; } else break; } if (suspense && suspense.activeBranch === vnode) suspense.vnode.el = el; } var internalObjectProto = {}; var createInternalObject = () => Object.create(internalObjectProto); var isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto; function initProps(instance, rawProps, isStateful, isSSR = false) { const props = {}; const attrs = createInternalObject(); instance.propsDefaults = /* @__PURE__ */ Object.create(null); setFullProps(instance, rawProps, props, attrs); for (const key in instance.propsOptions[0]) if (!(key in props)) props[key] = void 0; if (isStateful) instance.props = isSSR ? props : /* @__PURE__ */ shallowReactive(props); else if (!instance.type.props) instance.props = attrs; else instance.props = props; instance.attrs = attrs; } function updateProps(instance, rawProps, rawPrevProps, optimized) { const { props, attrs, vnode: { patchFlag } } = instance; const rawCurrentProps = /* @__PURE__ */ toRaw(props); const [options] = instance.propsOptions; let hasAttrsChanged = false; if ((optimized || patchFlag > 0) && !(patchFlag & 16)) { if (patchFlag & 8) { const propsToUpdate = instance.vnode.dynamicProps; for (let i = 0; i < propsToUpdate.length; i++) { let key = propsToUpdate[i]; if (isEmitListener(instance.emitsOptions, key)) continue; const value = rawProps[key]; if (options) if (hasOwn(attrs, key)) { if (value !== attrs[key]) { attrs[key] = value; hasAttrsChanged = true; } } else { const camelizedKey = camelize$2(key); props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false); } else if (value !== attrs[key]) { attrs[key] = value; hasAttrsChanged = true; } } } } else { if (setFullProps(instance, rawProps, props, attrs)) hasAttrsChanged = true; let kebabKey; for (const key in rawCurrentProps) if (!rawProps || !hasOwn(rawProps, key) && ((kebabKey = hyphenate$2(key)) === key || !hasOwn(rawProps, kebabKey))) if (options) { if (rawPrevProps && (rawPrevProps[key] !== void 0 || rawPrevProps[kebabKey] !== void 0)) props[key] = resolvePropValue(options, rawCurrentProps, key, void 0, instance, true); } else delete props[key]; if (attrs !== rawCurrentProps) { for (const key in attrs) if (!rawProps || !hasOwn(rawProps, key) && true) { delete attrs[key]; hasAttrsChanged = true; } } } if (hasAttrsChanged) trigger(instance.attrs, "set", ""); } function setFullProps(instance, rawProps, props, attrs) { const [options, needCastKeys] = instance.propsOptions; let hasAttrsChanged = false; let rawCastValues; if (rawProps) for (let key in rawProps) { if (isReservedProp(key)) continue; const value = rawProps[key]; let camelKey; if (options && hasOwn(options, camelKey = camelize$2(key))) if (!needCastKeys || !needCastKeys.includes(camelKey)) props[camelKey] = value; else (rawCastValues || (rawCastValues = {}))[camelKey] = value; else if (!isEmitListener(instance.emitsOptions, key)) { if (!(key in attrs) || value !== attrs[key]) { attrs[key] = value; hasAttrsChanged = true; } } } if (needCastKeys) { const rawCurrentProps = /* @__PURE__ */ toRaw(props); const castValues = rawCastValues || EMPTY_OBJ; for (let i = 0; i < needCastKeys.length; i++) { const key = needCastKeys[i]; props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key)); } } return hasAttrsChanged; } function resolvePropValue(options, props, key, value, instance, isAbsent) { const opt = options[key]; if (opt != null) { const hasDefault = hasOwn(opt, "default"); if (hasDefault && value === void 0) { const defaultValue = opt.default; if (opt.type !== Function && !opt.skipFactory && isFunction$2(defaultValue)) { const { propsDefaults } = instance; if (key in propsDefaults) value = propsDefaults[key]; else { const reset = setCurrentInstance(instance); value = propsDefaults[key] = defaultValue.call(null, props); reset(); } } else value = defaultValue; if (instance.ce) instance.ce._setProp(key, value); } if (opt[0]) { if (isAbsent && !hasDefault) value = false; else if (opt[1] && (value === "" || value === hyphenate$2(key))) value = true; } } return value; } var mixinPropsCache = /* @__PURE__ */ new WeakMap(); function normalizePropsOptions(comp, appContext, asMixin = false) { const cache = asMixin ? mixinPropsCache : appContext.propsCache; const cached = cache.get(comp); if (cached) return cached; const raw = comp.props; const normalized = {}; const needCastKeys = []; let hasExtends = false; if (!isFunction$2(comp)) { const extendProps = (raw2) => { hasExtends = true; const [props, keys] = normalizePropsOptions(raw2, appContext, true); extend(normalized, props); if (keys) needCastKeys.push(...keys); }; if (!asMixin && appContext.mixins.length) appContext.mixins.forEach(extendProps); if (comp.extends) extendProps(comp.extends); if (comp.mixins) comp.mixins.forEach(extendProps); } if (!raw && !hasExtends) { if (isObject$2(comp)) cache.set(comp, EMPTY_ARR); return EMPTY_ARR; } if (isArray(raw)) for (let i = 0; i < raw.length; i++) { const normalizedKey = camelize$2(raw[i]); if (validatePropName(normalizedKey)) normalized[normalizedKey] = EMPTY_OBJ; } else if (raw) for (const key in raw) { const normalizedKey = camelize$2(key); if (validatePropName(normalizedKey)) { const opt = raw[key]; const prop = normalized[normalizedKey] = isArray(opt) || isFunction$2(opt) ? { type: opt } : extend({}, opt); const propType = prop.type; let shouldCast = false; let shouldCastTrue = true; if (isArray(propType)) for (let index = 0; index < propType.length; ++index) { const type = propType[index]; const typeName = isFunction$2(type) && type.name; if (typeName === "Boolean") { shouldCast = true; break; } else if (typeName === "String") shouldCastTrue = false; } else shouldCast = isFunction$2(propType) && propType.name === "Boolean"; prop[0] = shouldCast; prop[1] = shouldCastTrue; if (shouldCast || hasOwn(prop, "default")) needCastKeys.push(normalizedKey); } } const res = [normalized, needCastKeys]; if (isObject$2(comp)) cache.set(comp, res); return res; } function validatePropName(key) { if (key[0] !== "$" && !isReservedProp(key)) return true; return false; } var isInternalKey = (key) => key === "_" || key === "_ctx" || key === "$stable"; var normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)]; var normalizeSlot = (key, rawSlot, ctx) => { if (rawSlot._n) return rawSlot; const normalized = withCtx((...args) => { return normalizeSlotValue(rawSlot(...args)); }, ctx); normalized._c = false; return normalized; }; var normalizeObjectSlots = (rawSlots, slots, instance) => { const ctx = rawSlots._ctx; for (const key in rawSlots) { if (isInternalKey(key)) continue; const value = rawSlots[key]; if (isFunction$2(value)) slots[key] = normalizeSlot(key, value, ctx); else if (value != null) { const normalized = normalizeSlotValue(value); slots[key] = () => normalized; } } }; var normalizeVNodeSlots = (instance, children) => { const normalized = normalizeSlotValue(children); instance.slots.default = () => normalized; }; var assignSlots = (slots, children, optimized) => { for (const key in children) if (optimized || !isInternalKey(key)) slots[key] = children[key]; }; var initSlots = (instance, children, optimized) => { const slots = instance.slots = createInternalObject(); if (instance.vnode.shapeFlag & 32) { const type = children._; if (type) { assignSlots(slots, children, optimized); if (optimized) def(slots, "_", type, true); } else normalizeObjectSlots(children, slots); } else if (children) normalizeVNodeSlots(instance, children); }; var updateSlots = (instance, children, optimized) => { const { vnode, slots } = instance; let needDeletionCheck = true; let deletionComparisonTarget = EMPTY_OBJ; if (vnode.shapeFlag & 32) { const type = children._; if (type) if (optimized && type === 1) needDeletionCheck = false; else assignSlots(slots, children, optimized); else { needDeletionCheck = !children.$stable; normalizeObjectSlots(children, slots); } deletionComparisonTarget = children; } else if (children) { normalizeVNodeSlots(instance, children); deletionComparisonTarget = { default: 1 }; } if (needDeletionCheck) { for (const key in slots) if (!isInternalKey(key) && deletionComparisonTarget[key] == null) delete slots[key]; } }; var queuePostRenderEffect = queueEffectWithSuspense; function createRenderer(options) { return baseCreateRenderer(options); } function createHydrationRenderer(options) { return baseCreateRenderer(options, createHydrationFunctions); } function baseCreateRenderer(options, createHydrationFns) { const target = getGlobalThis(); target.__VUE__ = true; const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, insertStaticContent: hostInsertStaticContent } = options; const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => { if (n1 === n2) return; if (n1 && !isSameVNodeType(n1, n2)) { anchor = getNextHostNode(n1); unmount(n1, parentComponent, parentSuspense, true); n1 = null; } if (n2.patchFlag === -2) { optimized = false; n2.dynamicChildren = null; } const { type, ref, shapeFlag } = n2; switch (type) { case Text: processText(n1, n2, container, anchor); break; case Comment: processCommentNode(n1, n2, container, anchor); break; case Static: if (n1 == null) mountStaticNode(n2, container, anchor, namespace); break; case Fragment: processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); break; default: if (shapeFlag & 1) processElement(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); else if (shapeFlag & 6) processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); else if (shapeFlag & 64) type.process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals); else if (shapeFlag & 128) type.process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, internals); } if (ref != null && parentComponent) setRef(ref, n1 && n1.ref, parentSuspense, n2 || n1, !n2); else if (ref == null && n1 && n1.ref != null) setRef(n1.ref, null, parentSuspense, n1, true); }; const processText = (n1, n2, container, anchor) => { if (n1 == null) hostInsert(n2.el = hostCreateText(n2.children), container, anchor); else { const el = n2.el = n1.el; if (n2.children !== n1.children) hostSetText(el, n2.children); } }; const processCommentNode = (n1, n2, container, anchor) => { if (n1 == null) hostInsert(n2.el = hostCreateComment(n2.children || ""), container, anchor); else n2.el = n1.el; }; const mountStaticNode = (n2, container, anchor, namespace) => { [n2.el, n2.anchor] = hostInsertStaticContent(n2.children, container, anchor, namespace, n2.el, n2.anchor); }; const moveStaticNode = ({ el, anchor }, container, nextSibling) => { let next; while (el && el !== anchor) { next = hostNextSibling(el); hostInsert(el, container, nextSibling); el = next; } hostInsert(anchor, container, nextSibling); }; const removeStaticNode = ({ el, anchor }) => { let next; while (el && el !== anchor) { next = hostNextSibling(el); hostRemove(el); el = next; } hostRemove(anchor); }; const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => { if (n2.type === "svg") namespace = "svg"; else if (n2.type === "math") namespace = "mathml"; if (n1 == null) mountElement(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); else { const customElement = n1.el && n1.el._isVueCE ? n1.el : null; try { if (customElement) customElement._beginPatch(); patchElement(n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); } finally { if (customElement) customElement._endPatch(); } } }; const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => { let el; let vnodeHook; const { props, shapeFlag, transition, dirs } = vnode; el = vnode.el = hostCreateElement(vnode.type, namespace, props && props.is, props); if (shapeFlag & 8) hostSetElementText(el, vnode.children); else if (shapeFlag & 16) mountChildren(vnode.children, el, null, parentComponent, parentSuspense, resolveChildrenNamespace(vnode, namespace), slotScopeIds, optimized); if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "created"); setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent); if (props) { for (const key in props) if (key !== "value" && !isReservedProp(key)) hostPatchProp(el, key, null, props[key], namespace, parentComponent); if ("value" in props) hostPatchProp(el, "value", null, props.value, namespace); if (vnodeHook = props.onVnodeBeforeMount) invokeVNodeHook(vnodeHook, parentComponent, vnode); } if (dirs) invokeDirectiveHook(vnode, null, parentComponent, "beforeMount"); const needCallTransitionHooks = needTransition(parentSuspense, transition); if (needCallTransitionHooks) transition.beforeEnter(el); hostInsert(el, container, anchor); if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) queuePostRenderEffect(() => { try { vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode); needCallTransitionHooks && transition.enter(el); dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted"); } finally {} }, parentSuspense); }; const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => { if (scopeId) hostSetScopeId(el, scopeId); if (slotScopeIds) for (let i = 0; i < slotScopeIds.length; i++) hostSetScopeId(el, slotScopeIds[i]); if (parentComponent) { let subTree = parentComponent.subTree; if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) { const parentVNode = parentComponent.vnode; setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent); } } }; const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, start = 0) => { for (let i = start; i < children.length; i++) patch(null, children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]), container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); }; const patchElement = (n1, n2, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => { const el = n2.el = n1.el; let { patchFlag, dynamicChildren, dirs } = n2; patchFlag |= n1.patchFlag & 16; const oldProps = n1.props || EMPTY_OBJ; const newProps = n2.props || EMPTY_OBJ; let vnodeHook; parentComponent && toggleRecurse(parentComponent, false); if (vnodeHook = newProps.onVnodeBeforeUpdate) invokeVNodeHook(vnodeHook, parentComponent, n2, n1); if (dirs) invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate"); parentComponent && toggleRecurse(parentComponent, true); if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) hostSetElementText(el, ""); if (dynamicChildren) patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, resolveChildrenNamespace(n2, namespace), slotScopeIds); else if (!optimized) patchChildren(n1, n2, el, null, parentComponent, parentSuspense, resolveChildrenNamespace(n2, namespace), slotScopeIds, false); if (patchFlag > 0) { if (patchFlag & 16) patchProps(el, oldProps, newProps, parentComponent, namespace); else { if (patchFlag & 2) { if (oldProps.class !== newProps.class) hostPatchProp(el, "class", null, newProps.class, namespace); } if (patchFlag & 4) hostPatchProp(el, "style", oldProps.style, newProps.style, namespace); if (patchFlag & 8) { const propsToUpdate = n2.dynamicProps; for (let i = 0; i < propsToUpdate.length; i++) { const key = propsToUpdate[i]; const prev = oldProps[key]; const next = newProps[key]; if (next !== prev || key === "value") hostPatchProp(el, key, prev, next, namespace, parentComponent); } } } if (patchFlag & 1) { if (n1.children !== n2.children) hostSetElementText(el, n2.children); } } else if (!optimized && dynamicChildren == null) patchProps(el, oldProps, newProps, parentComponent, namespace); if ((vnodeHook = newProps.onVnodeUpdated) || dirs) queuePostRenderEffect(() => { vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1); dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated"); }, parentSuspense); }; const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace, slotScopeIds) => { for (let i = 0; i < newChildren.length; i++) { const oldVNode = oldChildren[i]; const newVNode = newChildren[i]; patch(oldVNode, newVNode, oldVNode.el && (oldVNode.type === Fragment || !isSameVNodeType(oldVNode, newVNode) || oldVNode.shapeFlag & 198) ? hostParentNode(oldVNode.el) : fallbackContainer, null, parentComponent, parentSuspense, namespace, slotScopeIds, true); } }; const patchProps = (el, oldProps, newProps, parentComponent, namespace) => { if (oldProps !== newProps) { if (oldProps !== EMPTY_OBJ) { for (const key in oldProps) if (!isReservedProp(key) && !(key in newProps)) hostPatchProp(el, key, oldProps[key], null, namespace, parentComponent); } for (const key in newProps) { if (isReservedProp(key)) continue; const next = newProps[key]; const prev = oldProps[key]; if (next !== prev && key !== "value") hostPatchProp(el, key, prev, next, namespace, parentComponent); } if ("value" in newProps) hostPatchProp(el, "value", oldProps.value, newProps.value, namespace); } }; const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => { const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText(""); const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText(""); let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2; if (fragmentSlotScopeIds) slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds; if (n1 == null) { hostInsert(fragmentStartAnchor, container, anchor); hostInsert(fragmentEndAnchor, container, anchor); mountChildren(n2.children || [], container, fragmentEndAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); } else if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && n1.dynamicChildren && n1.dynamicChildren.length === dynamicChildren.length) { patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, namespace, slotScopeIds); if (n2.key != null || parentComponent && n2 === parentComponent.subTree) traverseStaticChildren(n1, n2, true); } else patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); }; const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => { n2.slotScopeIds = slotScopeIds; if (n1 == null) if (n2.shapeFlag & 512) parentComponent.ctx.activate(n2, container, anchor, namespace, optimized); else mountComponent(n2, container, anchor, parentComponent, parentSuspense, namespace, optimized); else updateComponent(n1, n2, optimized); }; const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace, optimized) => { const instance = initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense); if (isKeepAlive(initialVNode)) instance.ctx.renderer = internals; setupComponent(instance, false, optimized); if (instance.asyncDep) { parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized); if (!initialVNode.el) { const placeholder = instance.subTree = createVNode(Comment); processCommentNode(null, placeholder, container, anchor); initialVNode.placeholder = placeholder.el; } } else setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, namespace, optimized); }; const updateComponent = (n1, n2, optimized) => { const instance = n2.component = n1.component; if (shouldUpdateComponent(n1, n2, optimized)) if (instance.asyncDep && !instance.asyncResolved) { updateComponentPreRender(instance, n2, optimized); return; } else { instance.next = n2; instance.update(); } else { n2.el = n1.el; instance.vnode = n2; } }; const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace, optimized) => { const componentUpdateFn = () => { if (!instance.isMounted) { let vnodeHook; const { el, props } = initialVNode; const { bm, m, parent, root, type } = instance; const isAsyncWrapperVNode = isAsyncWrapper(initialVNode); toggleRecurse(instance, false); if (bm) invokeArrayFns(bm); if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) invokeVNodeHook(vnodeHook, parent, initialVNode); toggleRecurse(instance, true); if (el && hydrateNode) { const hydrateSubTree = () => { instance.subTree = renderComponentRoot(instance); hydrateNode(el, instance.subTree, instance, parentSuspense, null); }; if (isAsyncWrapperVNode && type.__asyncHydrate) type.__asyncHydrate(el, instance, hydrateSubTree); else hydrateSubTree(); } else { if (root.ce && root.ce._hasShadowRoot()) root.ce._injectChildStyle(type, instance.parent ? instance.parent.type : void 0); const subTree = instance.subTree = renderComponentRoot(instance); patch(null, subTree, container, anchor, instance, parentSuspense, namespace); initialVNode.el = subTree.el; } if (m) queuePostRenderEffect(m, parentSuspense); if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) { const scopedInitialVNode = initialVNode; queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense); } if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) instance.a && queuePostRenderEffect(instance.a, parentSuspense); instance.isMounted = true; initialVNode = container = anchor = null; } else { let { next, bu, u, parent, vnode } = instance; { const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance); if (nonHydratedAsyncRoot) { if (next) { next.el = vnode.el; updateComponentPreRender(instance, next, optimized); } nonHydratedAsyncRoot.asyncDep.then(() => { queuePostRenderEffect(() => { if (!instance.isUnmounted) update(); }, parentSuspense); }); return; } } let originNext = next; let vnodeHook; toggleRecurse(instance, false); if (next) { next.el = vnode.el; updateComponentPreRender(instance, next, optimized); } else next = vnode; if (bu) invokeArrayFns(bu); if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) invokeVNodeHook(vnodeHook, parent, next, vnode); toggleRecurse(instance, true); const nextTree = renderComponentRoot(instance); const prevTree = instance.subTree; instance.subTree = nextTree; patch(prevTree, nextTree, hostParentNode(prevTree.el), getNextHostNode(prevTree), instance, parentSuspense, namespace); next.el = nextTree.el; if (originNext === null) updateHOCHostEl(instance, nextTree.el); if (u) queuePostRenderEffect(u, parentSuspense); if (vnodeHook = next.props && next.props.onVnodeUpdated) queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense); } }; instance.scope.on(); const effect = instance.effect = new ReactiveEffect(componentUpdateFn); instance.scope.off(); const update = instance.update = effect.run.bind(effect); const job = instance.job = effect.runIfDirty.bind(effect); job.i = instance; job.id = instance.uid; effect.scheduler = () => queueJob(job); toggleRecurse(instance, true); update(); }; const updateComponentPreRender = (instance, nextVNode, optimized) => { nextVNode.component = instance; const prevProps = instance.vnode.props; instance.vnode = nextVNode; instance.next = null; updateProps(instance, nextVNode.props, prevProps, optimized); updateSlots(instance, nextVNode.children, optimized); pauseTracking(); flushPreFlushCbs(instance); resetTracking(); }; const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized = false) => { const c1 = n1 && n1.children; const prevShapeFlag = n1 ? n1.shapeFlag : 0; const c2 = n2.children; const { patchFlag, shapeFlag } = n2; if (patchFlag > 0) { if (patchFlag & 128) { patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); return; } else if (patchFlag & 256) { patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); return; } } if (shapeFlag & 8) { if (prevShapeFlag & 16) unmountChildren(c1, parentComponent, parentSuspense); if (c2 !== c1) hostSetElementText(container, c2); } else if (prevShapeFlag & 16) if (shapeFlag & 16) patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); else unmountChildren(c1, parentComponent, parentSuspense, true); else { if (prevShapeFlag & 8) hostSetElementText(container, ""); if (shapeFlag & 16) mountChildren(c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); } }; const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => { c1 = c1 || EMPTY_ARR; c2 = c2 || EMPTY_ARR; const oldLength = c1.length; const newLength = c2.length; const commonLength = Math.min(oldLength, newLength); let i; for (i = 0; i < commonLength; i++) { const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); } if (oldLength > newLength) unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength); else mountChildren(c2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, commonLength); }; const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized) => { let i = 0; const l2 = c2.length; let e1 = c1.length - 1; let e2 = l2 - 1; while (i <= e1 && i <= e2) { const n1 = c1[i]; const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); if (isSameVNodeType(n1, n2)) patch(n1, n2, container, null, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); else break; i++; } while (i <= e1 && i <= e2) { const n1 = c1[e1]; const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]); if (isSameVNodeType(n1, n2)) patch(n1, n2, container, null, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); else break; e1--; e2--; } if (i > e1) { if (i <= e2) { const nextPos = e2 + 1; const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor; while (i <= e2) { patch(null, c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]), container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); i++; } } } else if (i > e2) while (i <= e1) { unmount(c1[i], parentComponent, parentSuspense, true); i++; } else { const s1 = i; const s2 = i; const keyToNewIndexMap = /* @__PURE__ */ new Map(); for (i = s2; i <= e2; i++) { const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); if (nextChild.key != null) keyToNewIndexMap.set(nextChild.key, i); } let j; let patched = 0; const toBePatched = e2 - s2 + 1; let moved = false; let maxNewIndexSoFar = 0; const newIndexToOldIndexMap = new Array(toBePatched); for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0; for (i = s1; i <= e1; i++) { const prevChild = c1[i]; if (patched >= toBePatched) { unmount(prevChild, parentComponent, parentSuspense, true); continue; } let newIndex; if (prevChild.key != null) newIndex = keyToNewIndexMap.get(prevChild.key); else for (j = s2; j <= e2; j++) if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) { newIndex = j; break; } if (newIndex === void 0) unmount(prevChild, parentComponent, parentSuspense, true); else { newIndexToOldIndexMap[newIndex - s2] = i + 1; if (newIndex >= maxNewIndexSoFar) maxNewIndexSoFar = newIndex; else moved = true; patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); patched++; } } const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR; j = increasingNewIndexSequence.length - 1; for (i = toBePatched - 1; i >= 0; i--) { const nextIndex = s2 + i; const nextChild = c2[nextIndex]; const anchorVNode = c2[nextIndex + 1]; const anchor = nextIndex + 1 < l2 ? anchorVNode.el || resolveAsyncComponentPlaceholder(anchorVNode) : parentAnchor; if (newIndexToOldIndexMap[i] === 0) patch(null, nextChild, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized); else if (moved) if (j < 0 || i !== increasingNewIndexSequence[j]) move(nextChild, container, anchor, 2); else j--; } } }; const move = (vnode, container, anchor, moveType, parentSuspense = null) => { const { el, type, transition, children, shapeFlag } = vnode; if (shapeFlag & 6) { move(vnode.component.subTree, container, anchor, moveType); return; } if (shapeFlag & 128) { vnode.suspense.move(container, anchor, moveType); return; } if (shapeFlag & 64) { type.move(vnode, container, anchor, internals); return; } if (type === Fragment) { hostInsert(el, container, anchor); for (let i = 0; i < children.length; i++) move(children[i], container, anchor, moveType); hostInsert(vnode.anchor, container, anchor); return; } if (type === Static) { moveStaticNode(vnode, container, anchor); return; } if (moveType !== 2 && shapeFlag & 1 && transition) if (moveType === 0) { transition.beforeEnter(el); hostInsert(el, container, anchor); queuePostRenderEffect(() => transition.enter(el), parentSuspense); } else { const { leave, delayLeave, afterLeave } = transition; const remove2 = () => { if (vnode.ctx.isUnmounted) hostRemove(el); else hostInsert(el, container, anchor); }; const performLeave = () => { if (el._isLeaving) el[leaveCbKey](true); leave(el, () => { remove2(); afterLeave && afterLeave(); }); }; if (delayLeave) delayLeave(el, remove2, performLeave); else performLeave(); } else hostInsert(el, container, anchor); }; const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => { const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode; if (patchFlag === -2) optimized = false; if (ref != null) { pauseTracking(); setRef(ref, null, parentSuspense, vnode, true); resetTracking(); } if (cacheIndex != null) parentComponent.renderCache[cacheIndex] = void 0; if (shapeFlag & 256) { parentComponent.ctx.deactivate(vnode); return; } const shouldInvokeDirs = shapeFlag & 1 && dirs; const shouldInvokeVnodeHook = !isAsyncWrapper(vnode); let vnodeHook; if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) invokeVNodeHook(vnodeHook, parentComponent, vnode); if (shapeFlag & 6) unmountComponent(vnode.component, parentSuspense, doRemove); else { if (shapeFlag & 128) { vnode.suspense.unmount(parentSuspense, doRemove); return; } if (shouldInvokeDirs) invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount"); if (shapeFlag & 64) vnode.type.remove(vnode, parentComponent, parentSuspense, internals, doRemove); else if (dynamicChildren && !dynamicChildren.hasOnce && (type !== Fragment || patchFlag > 0 && patchFlag & 64)) unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true); else if (type === Fragment && patchFlag & 384 || !optimized && shapeFlag & 16) unmountChildren(children, parentComponent, parentSuspense); if (doRemove) remove(vnode); } const shouldInvalidateMemo = memo != null && cacheIndex == null; if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs || shouldInvalidateMemo) queuePostRenderEffect(() => { vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode); shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted"); if (shouldInvalidateMemo) vnode.el = null; }, parentSuspense); }; const remove = (vnode) => { const { type, el, anchor, transition } = vnode; if (type === Fragment) { removeFragment(el, anchor); return; } if (type === Static) { removeStaticNode(vnode); return; } const performRemove = () => { hostRemove(el); if (transition && !transition.persisted && transition.afterLeave) transition.afterLeave(); }; if (vnode.shapeFlag & 1 && transition && !transition.persisted) { const { leave, delayLeave } = transition; const performLeave = () => leave(el, performRemove); if (delayLeave) delayLeave(vnode.el, performRemove, performLeave); else performLeave(); } else performRemove(); }; const removeFragment = (cur, end) => { let next; while (cur !== end) { next = hostNextSibling(cur); hostRemove(cur); cur = next; } hostRemove(end); }; const unmountComponent = (instance, parentSuspense, doRemove) => { const { bum, scope, job, subTree, um, m, a } = instance; invalidateMount(m); invalidateMount(a); if (bum) invokeArrayFns(bum); scope.stop(); if (job) { job.flags |= 8; unmount(subTree, instance, parentSuspense, doRemove); } if (um) queuePostRenderEffect(um, parentSuspense); queuePostRenderEffect(() => { instance.isUnmounted = true; }, parentSuspense); }; const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => { for (let i = start; i < children.length; i++) unmount(children[i], parentComponent, parentSuspense, doRemove, optimized); }; const getNextHostNode = (vnode) => { if (vnode.shapeFlag & 6) return getNextHostNode(vnode.component.subTree); if (vnode.shapeFlag & 128) return vnode.suspense.next(); const el = hostNextSibling(vnode.anchor || vnode.el); const teleportEnd = el && el[TeleportEndKey]; return teleportEnd ? hostNextSibling(teleportEnd) : el; }; let isFlushing = false; const render = (vnode, container, namespace) => { let instance; if (vnode == null) { if (container._vnode) { unmount(container._vnode, null, null, true); instance = container._vnode.component; } } else patch(container._vnode || null, vnode, container, null, null, null, namespace); container._vnode = vnode; if (!isFlushing) { isFlushing = true; flushPreFlushCbs(instance); flushPostFlushCbs(); isFlushing = false; } }; const internals = { p: patch, um: unmount, m: move, r: remove, mt: mountComponent, mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, n: getNextHostNode, o: options }; let hydrate; let hydrateNode; if (createHydrationFns) [hydrate, hydrateNode] = createHydrationFns(internals); return { render, hydrate, createApp: createAppAPI(render, hydrate) }; } function resolveChildrenNamespace({ type, props }, currentNamespace) { return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace; } function toggleRecurse({ effect, job }, allowed) { if (allowed) { effect.flags |= 32; job.flags |= 4; } else { effect.flags &= -33; job.flags &= -5; } } function needTransition(parentSuspense, transition) { return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted; } function traverseStaticChildren(n1, n2, shallow = false) { const ch1 = n1.children; const ch2 = n2.children; if (isArray(ch1) && isArray(ch2)) for (let i = 0; i < ch1.length; i++) { const c1 = ch1[i]; let c2 = ch2[i]; if (c2.shapeFlag & 1 && !c2.dynamicChildren) { if (c2.patchFlag <= 0 || c2.patchFlag === 32) { c2 = ch2[i] = cloneIfMounted(ch2[i]); c2.el = c1.el; } if (!shallow && c2.patchFlag !== -2) traverseStaticChildren(c1, c2); } if (c2.type === Text) { if (c2.patchFlag === -1) c2 = ch2[i] = cloneIfMounted(c2); c2.el = c1.el; } if (c2.type === Comment && !c2.el) c2.el = c1.el; } } function getSequence(arr) { const p = arr.slice(); const result = [0]; let i, j, u, v, c; const len = arr.length; for (i = 0; i < len; i++) { const arrI = arr[i]; if (arrI !== 0) { j = result[result.length - 1]; if (arr[j] < arrI) { p[i] = j; result.push(i); continue; } u = 0; v = result.length - 1; while (u < v) { c = u + v >> 1; if (arr[result[c]] < arrI) u = c + 1; else v = c; } if (arrI < arr[result[u]]) { if (u > 0) p[i] = result[u - 1]; result[u] = i; } } } u = result.length; v = result[u - 1]; while (u-- > 0) { result[u] = v; v = p[v]; } return result; } function locateNonHydratedAsyncRoot(instance) { const subComponent = instance.subTree.component; if (subComponent) if (subComponent.asyncDep && !subComponent.asyncResolved) return subComponent; else return locateNonHydratedAsyncRoot(subComponent); } function invalidateMount(hooks) { if (hooks) for (let i = 0; i < hooks.length; i++) hooks[i].flags |= 8; } function resolveAsyncComponentPlaceholder(anchorVnode) { if (anchorVnode.placeholder) return anchorVnode.placeholder; const instance = anchorVnode.component; if (instance) return resolveAsyncComponentPlaceholder(instance.subTree); return null; } var isSuspense = (type) => type.__isSuspense; var suspenseId = 0; var Suspense = { name: "Suspense", __isSuspense: true, process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) { if (n1 == null) mountSuspense(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals); else { if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) { n2.suspense = n1.suspense; n2.suspense.vnode = n2; n2.el = n1.el; return; } patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, rendererInternals); } }, hydrate: hydrateSuspense, normalize: normalizeSuspenseChildren }; function triggerEvent(vnode, name) { const eventListener = vnode.props && vnode.props[name]; if (isFunction$2(eventListener)) eventListener(); } function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) { const { p: patch, o: { createElement } } = rendererInternals; const hiddenContainer = createElement("div"); const suspense = vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals); patch(null, suspense.pendingBranch = vnode.ssContent, hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds); if (suspense.deps > 0) { triggerEvent(vnode, "onPending"); triggerEvent(vnode, "onFallback"); patch(null, vnode.ssFallback, container, anchor, parentComponent, null, namespace, slotScopeIds); setActiveBranch(suspense, vnode.ssFallback); } else suspense.resolve(false, true); } function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, slotScopeIds, optimized, { p: patch, um: unmount, o: { createElement } }) { const suspense = n2.suspense = n1.suspense; suspense.vnode = n2; n2.el = n1.el; const newBranch = n2.ssContent; const newFallback = n2.ssFallback; const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense; if (pendingBranch) { suspense.pendingBranch = newBranch; if (isSameVNodeType(pendingBranch, newBranch)) { patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized); if (suspense.deps <= 0) suspense.resolve(); else if (isInFallback) { if (!isHydrating) { patch(activeBranch, newFallback, container, anchor, parentComponent, null, namespace, slotScopeIds, optimized); setActiveBranch(suspense, newFallback); } } } else { suspense.pendingId = suspenseId++; if (isHydrating) { suspense.isHydrating = false; suspense.activeBranch = pendingBranch; } else unmount(pendingBranch, parentComponent, suspense); suspense.deps = 0; suspense.effects.length = 0; suspense.hiddenContainer = createElement("div"); if (isInFallback) { patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized); if (suspense.deps <= 0) suspense.resolve(); else { patch(activeBranch, newFallback, container, anchor, parentComponent, null, namespace, slotScopeIds, optimized); setActiveBranch(suspense, newFallback); } } else if (activeBranch && isSameVNodeType(activeBranch, newBranch)) { patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, namespace, slotScopeIds, optimized); suspense.resolve(true); } else { patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized); if (suspense.deps <= 0) suspense.resolve(); } } } else if (activeBranch && isSameVNodeType(activeBranch, newBranch)) { patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, namespace, slotScopeIds, optimized); setActiveBranch(suspense, newBranch); } else { triggerEvent(n2, "onPending"); suspense.pendingBranch = newBranch; if (newBranch.shapeFlag & 512) suspense.pendingId = newBranch.component.suspenseId; else suspense.pendingId = suspenseId++; patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized); if (suspense.deps <= 0) suspense.resolve(); else { const { timeout, pendingId } = suspense; if (timeout > 0) setTimeout(() => { if (suspense.pendingId === pendingId) suspense.fallback(newFallback); }, timeout); else if (timeout === 0) suspense.fallback(newFallback); } } } function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace, slotScopeIds, optimized, rendererInternals, isHydrating = false) { const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals; let parentSuspenseId; const isSuspensible = isVNodeSuspensible(vnode); if (isSuspensible) { if (parentSuspense && parentSuspense.pendingBranch) { parentSuspenseId = parentSuspense.pendingId; parentSuspense.deps++; } } const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0; const initialAnchor = anchor; const suspense = { vnode, parent: parentSuspense, parentComponent, namespace, container, hiddenContainer, deps: 0, pendingId: suspenseId++, timeout: typeof timeout === "number" ? timeout : -1, activeBranch: null, isFallbackMountPending: false, pendingBranch: null, isInFallback: !isHydrating, isHydrating, isUnmounted: false, effects: [], resolve(resume = false, sync = false) { const { vnode: vnode2, activeBranch, pendingBranch, pendingId, effects, parentComponent: parentComponent2, container: container2, isInFallback } = suspense; let delayEnter = false; if (suspense.isHydrating) suspense.isHydrating = false; else if (!resume) { delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in"; if (delayEnter) activeBranch.transition.afterLeave = () => { if (pendingId === suspense.pendingId) { move(pendingBranch, container2, anchor === initialAnchor ? next(activeBranch) : anchor, 0); queuePostFlushCb(effects); if (isInFallback && vnode2.ssFallback) vnode2.ssFallback.el = null; } }; if (activeBranch && !suspense.isFallbackMountPending) { if (parentNode(activeBranch.el) === container2) anchor = next(activeBranch); unmount(activeBranch, parentComponent2, suspense, true); if (!delayEnter && isInFallback && vnode2.ssFallback) queuePostRenderEffect(() => vnode2.ssFallback.el = null, suspense); } if (!delayEnter) move(pendingBranch, container2, anchor, 0); } suspense.isFallbackMountPending = false; setActiveBranch(suspense, pendingBranch); suspense.pendingBranch = null; suspense.isInFallback = false; let parent = suspense.parent; let hasUnresolvedAncestor = false; while (parent) { if (parent.pendingBranch) { parent.effects.push(...effects); hasUnresolvedAncestor = true; break; } parent = parent.parent; } if (!hasUnresolvedAncestor && !delayEnter) queuePostFlushCb(effects); suspense.effects = []; if (isSuspensible) { if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) { parentSuspense.deps--; if (parentSuspense.deps === 0 && !sync) parentSuspense.resolve(); } } triggerEvent(vnode2, "onResolve"); }, fallback(fallbackVNode) { if (!suspense.pendingBranch) return; const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace2 } = suspense; triggerEvent(vnode2, "onFallback"); const anchor2 = next(activeBranch); const mountFallback = () => { suspense.isFallbackMountPending = false; if (!suspense.isInFallback) return; patch(null, fallbackVNode, container2, anchor2, parentComponent2, null, namespace2, slotScopeIds, optimized); setActiveBranch(suspense, fallbackVNode); }; const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in"; if (delayEnter) { suspense.isFallbackMountPending = true; activeBranch.transition.afterLeave = mountFallback; } suspense.isInFallback = true; unmount(activeBranch, parentComponent2, null, true); if (!delayEnter) mountFallback(); }, move(container2, anchor2, type) { suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type); suspense.container = container2; }, next() { return suspense.activeBranch && next(suspense.activeBranch); }, registerDep(instance, setupRenderEffect, optimized2) { const isInPendingSuspense = !!suspense.pendingBranch; if (isInPendingSuspense) suspense.deps++; const hydratedEl = instance.vnode.el; instance.asyncDep.catch((err) => { handleError(err, instance, 0); }).then((asyncSetupResult) => { if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return; unsetCurrentInstance(); instance.asyncResolved = true; const { vnode: vnode2 } = instance; handleSetupResult(instance, asyncSetupResult, false); if (hydratedEl) vnode2.el = hydratedEl; const placeholder = !hydratedEl && instance.subTree.el; setupRenderEffect(instance, vnode2, parentNode(hydratedEl || instance.subTree.el), hydratedEl ? null : next(instance.subTree), suspense, namespace, optimized2); if (placeholder) { vnode2.placeholder = null; remove(placeholder); } updateHOCHostEl(instance, vnode2.el); if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve(); }); }, unmount(parentSuspense2, doRemove) { suspense.isUnmounted = true; if (suspense.activeBranch) unmount(suspense.activeBranch, parentComponent, parentSuspense2, doRemove); if (suspense.pendingBranch) unmount(suspense.pendingBranch, parentComponent, parentSuspense2, doRemove); } }; return suspense; } function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals, hydrateNode) { const suspense = vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement("div"), null, namespace, slotScopeIds, optimized, rendererInternals, true); const result = hydrateNode(node, suspense.pendingBranch = vnode.ssContent, parentComponent, suspense, slotScopeIds, optimized); if (suspense.deps === 0) suspense.resolve(false, true); return result; } function normalizeSuspenseChildren(vnode) { const { shapeFlag, children } = vnode; const isSlotChildren = shapeFlag & 32; vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children); vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment); } function normalizeSuspenseSlot(s) { let block; if (isFunction$2(s)) { const trackBlock = isBlockTreeEnabled && s._c; if (trackBlock) { s._d = false; openBlock(); } s = s(); if (trackBlock) { s._d = true; block = currentBlock; closeBlock(); } } if (isArray(s)) s = filterSingleRoot(s); s = normalizeVNode(s); if (block && !s.dynamicChildren) s.dynamicChildren = block.filter((c) => c !== s); return s; } function queueEffectWithSuspense(fn, suspense) { if (suspense && suspense.pendingBranch) if (isArray(fn)) suspense.effects.push(...fn); else suspense.effects.push(fn); else queuePostFlushCb(fn); } function setActiveBranch(suspense, branch) { suspense.activeBranch = branch; const { vnode, parentComponent } = suspense; let el = branch.el; while (!el && branch.component) { branch = branch.component.subTree; el = branch.el; } vnode.el = el; if (parentComponent && parentComponent.subTree === vnode) { parentComponent.vnode.el = el; updateHOCHostEl(parentComponent, el); } } function isVNodeSuspensible(vnode) { const suspensible = vnode.props && vnode.props.suspensible; return suspensible != null && suspensible !== false; } var Fragment = /* @__PURE__ */ Symbol.for("v-fgt"); var Text = /* @__PURE__ */ Symbol.for("v-txt"); var Comment = /* @__PURE__ */ Symbol.for("v-cmt"); var Static = /* @__PURE__ */ Symbol.for("v-stc"); var blockStack = []; var currentBlock = null; function openBlock(disableTracking = false) { blockStack.push(currentBlock = disableTracking ? null : []); } function closeBlock() { blockStack.pop(); currentBlock = blockStack[blockStack.length - 1] || null; } var isBlockTreeEnabled = 1; function setBlockTracking(value, inVOnce = false) { isBlockTreeEnabled += value; if (value < 0 && currentBlock && inVOnce) currentBlock.hasOnce = true; } function setupBlock(vnode) { vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null; closeBlock(); if (isBlockTreeEnabled > 0 && currentBlock) currentBlock.push(vnode); return vnode; } function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) { return setupBlock(createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, true)); } function createBlock(type, props, children, patchFlag, dynamicProps) { return setupBlock(createVNode(type, props, children, patchFlag, dynamicProps, true)); } function isVNode(value) { return value ? value.__v_isVNode === true : false; } function isSameVNodeType(n1, n2) { return n1.type === n2.type && n1.key === n2.key; } function transformVNodeArgs(transformer) {} var normalizeKey = ({ key }) => key != null ? key : null; var normalizeRef = ({ ref, ref_key, ref_for }) => { if (typeof ref === "number") ref = "" + ref; return ref != null ? isString(ref) || /* @__PURE__ */ isRef(ref) || isFunction$2(ref) ? { i: currentRenderingInstance, r: ref, k: ref_key, f: !!ref_for } : ref : null; }; function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) { const vnode = { __v_isVNode: true, __v_skip: true, type, props, key: props && normalizeKey(props), ref: props && normalizeRef(props), scopeId: currentScopeId, slotScopeIds: null, children, component: null, suspense: null, ssContent: null, ssFallback: null, dirs: null, transition: null, el: null, anchor: null, target: null, targetStart: null, targetAnchor: null, staticCount: 0, shapeFlag, patchFlag, dynamicProps, dynamicChildren: null, appContext: null, ctx: currentRenderingInstance }; if (needFullChildrenNormalization) { normalizeChildren(vnode, children); if (shapeFlag & 128) type.normalize(vnode); } else if (children) vnode.shapeFlag |= isString(children) ? 8 : 16; if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock && (vnode.patchFlag > 0 || shapeFlag & 6) && vnode.patchFlag !== 32) currentBlock.push(vnode); return vnode; } var createVNode = _createVNode; function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) { if (!type || type === NULL_DYNAMIC_COMPONENT) type = Comment; if (isVNode(type)) { const cloned = cloneVNode(type, props, true); if (children) normalizeChildren(cloned, children); if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) if (cloned.shapeFlag & 6) currentBlock[currentBlock.indexOf(type)] = cloned; else currentBlock.push(cloned); cloned.patchFlag = -2; return cloned; } if (isClassComponent(type)) type = type.__vccOpts; if (props) { props = guardReactiveProps(props); let { class: klass, style } = props; if (klass && !isString(klass)) props.class = normalizeClass(klass); if (isObject$2(style)) { if (/* @__PURE__ */ isProxy(style) && !isArray(style)) style = extend({}, style); props.style = normalizeStyle(style); } } const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject$2(type) ? 4 : isFunction$2(type) ? 2 : 0; return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true); } function guardReactiveProps(props) { if (!props) return null; return /* @__PURE__ */ isProxy(props) || isInternalObject(props) ? extend({}, props) : props; } function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) { const { props, ref, patchFlag, children, transition } = vnode; const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props; const cloned = { __v_isVNode: true, __v_skip: true, type: vnode.type, props: mergedProps, key: mergedProps && normalizeKey(mergedProps), ref: extraProps && extraProps.ref ? mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps) : ref, scopeId: vnode.scopeId, slotScopeIds: vnode.slotScopeIds, children, target: vnode.target, targetStart: vnode.targetStart, targetAnchor: vnode.targetAnchor, staticCount: vnode.staticCount, shapeFlag: vnode.shapeFlag, patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag, dynamicProps: vnode.dynamicProps, dynamicChildren: vnode.dynamicChildren, appContext: vnode.appContext, dirs: vnode.dirs, transition, component: vnode.component, suspense: vnode.suspense, ssContent: vnode.ssContent && cloneVNode(vnode.ssContent), ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback), placeholder: vnode.placeholder, el: vnode.el, anchor: vnode.anchor, ctx: vnode.ctx, ce: vnode.ce }; if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned)); return cloned; } function createTextVNode(text = " ", flag = 0) { return createVNode(Text, null, text, flag); } function createStaticVNode(content, numberOfNodes) { const vnode = createVNode(Static, null, content); vnode.staticCount = numberOfNodes; return vnode; } function createCommentVNode(text = "", asBlock = false) { return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text); } function normalizeVNode(child) { if (child == null || typeof child === "boolean") return createVNode(Comment); else if (isArray(child)) return createVNode(Fragment, null, child.slice()); else if (isVNode(child)) return cloneIfMounted(child); else return createVNode(Text, null, String(child)); } function cloneIfMounted(child) { return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child); } function normalizeChildren(vnode, children) { let type = 0; const { shapeFlag } = vnode; if (children == null) children = null; else if (isArray(children)) type = 16; else if (typeof children === "object") if (shapeFlag & 65) { const slot = children.default; if (slot) { slot._c && (slot._d = false); normalizeChildren(vnode, slot()); slot._c && (slot._d = true); } return; } else { type = 32; const slotFlag = children._; if (!slotFlag && !isInternalObject(children)) children._ctx = currentRenderingInstance; else if (slotFlag === 3 && currentRenderingInstance) if (currentRenderingInstance.slots._ === 1) children._ = 1; else { children._ = 2; vnode.patchFlag |= 1024; } } else if (isFunction$2(children)) { children = { default: children, _ctx: currentRenderingInstance }; type = 32; } else { children = String(children); if (shapeFlag & 64) { type = 16; children = [createTextVNode(children)]; } else type = 8; } vnode.children = children; vnode.shapeFlag |= type; } function mergeProps(...args) { const ret = {}; for (let i = 0; i < args.length; i++) { const toMerge = args[i]; for (const key in toMerge) if (key === "class") { if (ret.class !== toMerge.class) ret.class = normalizeClass([ret.class, toMerge.class]); } else if (key === "style") ret.style = normalizeStyle([ret.style, toMerge.style]); else if (isOn(key)) { const existing = ret[key]; const incoming = toMerge[key]; if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) ret[key] = existing ? [].concat(existing, incoming) : incoming; else if (incoming == null && existing == null && !isModelListener(key)) ret[key] = incoming; } else if (key !== "") ret[key] = toMerge[key]; } return ret; } function invokeVNodeHook(hook, instance, vnode, prevVNode = null) { callWithAsyncErrorHandling(hook, instance, 7, [vnode, prevVNode]); } var emptyAppContext = createAppContext(); var uid = 0; function createComponentInstance(vnode, parent, suspense) { const type = vnode.type; const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext; const instance = { uid: uid++, vnode, type, parent, appContext, root: null, next: null, subTree: null, effect: null, update: null, job: null, scope: new EffectScope(true), render: null, proxy: null, exposed: null, exposeProxy: null, withProxy: null, provides: parent ? parent.provides : Object.create(appContext.provides), ids: parent ? parent.ids : [ "", 0, 0 ], accessCache: null, renderCache: [], components: null, directives: null, propsOptions: normalizePropsOptions(type, appContext), emitsOptions: normalizeEmitsOptions(type, appContext), emit: null, emitted: null, propsDefaults: EMPTY_OBJ, inheritAttrs: type.inheritAttrs, ctx: EMPTY_OBJ, data: EMPTY_OBJ, props: EMPTY_OBJ, attrs: EMPTY_OBJ, slots: EMPTY_OBJ, refs: EMPTY_OBJ, setupState: EMPTY_OBJ, setupContext: null, suspense, suspenseId: suspense ? suspense.pendingId : 0, asyncDep: null, asyncResolved: false, isMounted: false, isUnmounted: false, isDeactivated: false, bc: null, c: null, bm: null, m: null, bu: null, u: null, um: null, bum: null, da: null, a: null, rtg: null, rtc: null, ec: null, sp: null }; instance.ctx = { _: instance }; instance.root = parent ? parent.root : instance; instance.emit = emit.bind(null, instance); if (vnode.ce) vnode.ce(instance); return instance; } var currentInstance = null; var getCurrentInstance = () => currentInstance || currentRenderingInstance; var internalSetCurrentInstance; var setInSSRSetupState; { const g = getGlobalThis(); const registerGlobalSetter = (key, setter) => { let setters; if (!(setters = g[key])) setters = g[key] = []; setters.push(setter); return (v) => { if (setters.length > 1) setters.forEach((set) => set(v)); else setters[0](v); }; }; internalSetCurrentInstance = registerGlobalSetter(`__VUE_INSTANCE_SETTERS__`, (v) => currentInstance = v); setInSSRSetupState = registerGlobalSetter(`__VUE_SSR_SETTERS__`, (v) => isInSSRComponentSetup = v); } var setCurrentInstance = (instance) => { const prev = currentInstance; internalSetCurrentInstance(instance); instance.scope.on(); return () => { instance.scope.off(); internalSetCurrentInstance(prev); }; }; var unsetCurrentInstance = () => { currentInstance && currentInstance.scope.off(); internalSetCurrentInstance(null); }; function isStatefulComponent(instance) { return instance.vnode.shapeFlag & 4; } var isInSSRComponentSetup = false; function setupComponent(instance, isSSR = false, optimized = false) { isSSR && setInSSRSetupState(isSSR); const { props, children } = instance.vnode; const isStateful = isStatefulComponent(instance); initProps(instance, props, isStateful, isSSR); initSlots(instance, children, optimized || isSSR); const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0; isSSR && setInSSRSetupState(false); return setupResult; } function setupStatefulComponent(instance, isSSR) { const Component = instance.type; instance.accessCache = /* @__PURE__ */ Object.create(null); instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers); const { setup } = Component; if (setup) { pauseTracking(); const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null; const reset = setCurrentInstance(instance); const setupResult = callWithErrorHandling(setup, instance, 0, [instance.props, setupContext]); const isAsyncSetup = isPromise(setupResult); resetTracking(); reset(); if ((isAsyncSetup || instance.sp) && !isAsyncWrapper(instance)) markAsyncBoundary(instance); if (isAsyncSetup) { setupResult.then(unsetCurrentInstance, unsetCurrentInstance); if (isSSR) return setupResult.then((resolvedResult) => { handleSetupResult(instance, resolvedResult, isSSR); }).catch((e) => { handleError(e, instance, 0); }); else instance.asyncDep = setupResult; } else handleSetupResult(instance, setupResult, isSSR); } else finishComponentSetup(instance, isSSR); } function handleSetupResult(instance, setupResult, isSSR) { if (isFunction$2(setupResult)) if (instance.type.__ssrInlineRender) instance.ssrRender = setupResult; else instance.render = setupResult; else if (isObject$2(setupResult)) instance.setupState = proxyRefs(setupResult); finishComponentSetup(instance, isSSR); } var compile$1; var installWithProxy; function registerRuntimeCompiler(_compile) { compile$1 = _compile; installWithProxy = (i) => { if (i.render._rc) i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers); }; } var isRuntimeOnly = () => !compile$1; function finishComponentSetup(instance, isSSR, skipOptions) { const Component = instance.type; if (!instance.render) { if (!isSSR && compile$1 && !Component.render) { const template = Component.template || resolveMergedOptions(instance).template; if (template) { const { isCustomElement, compilerOptions } = instance.appContext.config; const { delimiters, compilerOptions: componentCompilerOptions } = Component; const finalCompilerOptions = extend(extend({ isCustomElement, delimiters }, compilerOptions), componentCompilerOptions); Component.render = compile$1(template, finalCompilerOptions); } } instance.render = Component.render || NOOP; if (installWithProxy) installWithProxy(instance); } { const reset = setCurrentInstance(instance); pauseTracking(); try { applyOptions(instance); } finally { resetTracking(); reset(); } } } var attrsProxyHandlers = { get(target, key) { track(target, "get", ""); return target[key]; } }; function createSetupContext(instance) { const expose = (exposed) => { instance.exposed = exposed || {}; }; return { attrs: new Proxy(instance.attrs, attrsProxyHandlers), slots: instance.slots, emit: instance.emit, expose }; } function getComponentPublicInstance(instance) { if (instance.exposed) return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), { get(target, key) { if (key in target) return target[key]; else if (key in publicPropertiesMap) return publicPropertiesMap[key](instance); }, has(target, key) { return key in target || key in publicPropertiesMap; } })); else return instance.proxy; } function getComponentName(Component, includeInferred = true) { return isFunction$2(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name; } function isClassComponent(value) { return isFunction$2(value) && "__vccOpts" in value; } var computed = (getterOrOptions, debugOptions) => { return /* @__PURE__ */ computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup); }; function h$2(type, propsOrChildren, children) { try { setBlockTracking(-1); const l = arguments.length; if (l === 2) if (isObject$2(propsOrChildren) && !isArray(propsOrChildren)) { if (isVNode(propsOrChildren)) return createVNode(type, null, [propsOrChildren]); return createVNode(type, propsOrChildren); } else return createVNode(type, null, propsOrChildren); else { if (l > 3) children = Array.prototype.slice.call(arguments, 2); else if (l === 3 && isVNode(children)) children = [children]; return createVNode(type, propsOrChildren, children); } } finally { setBlockTracking(1); } } function initCustomFormatter() { return; function isKeyOfType(Comp, key, type) { const opts = Comp[type]; if (isArray(opts) && opts.includes(key) || isObject$2(opts) && key in opts) return true; if (Comp.extends && isKeyOfType(Comp.extends, key, type)) return true; if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) return true; } } function withMemo(memo, render, cache, index) { const cached = cache[index]; if (cached && isMemoSame(cached, memo)) return cached; const ret = render(); ret.memo = memo.slice(); ret.cacheIndex = index; return cache[index] = ret; } function isMemoSame(cached, memo) { const prev = cached.memo; if (prev.length != memo.length) return false; for (let i = 0; i < prev.length; i++) if (hasChanged(prev[i], memo[i])) return false; if (isBlockTreeEnabled > 0 && currentBlock) currentBlock.push(cached); return true; } var version = "3.5.33"; var warn = NOOP; var ErrorTypeStrings = ErrorTypeStrings$1; var devtools = devtools$1; var setDevtoolsHook = setDevtoolsHook$1; var ssrUtils = { createComponentInstance, setupComponent, renderComponentRoot, setCurrentRenderingInstance, isVNode, normalizeVNode, getComponentPublicInstance, ensureValidVNode, pushWarningContext, popWarningContext }; //#endregion //#region ../../node_modules/.pnpm/@vue+runtime-dom@3.5.33/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js /** * @vue/runtime-dom v3.5.33 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ var policy = void 0; var tt$2 = typeof window !== "undefined" && window.trustedTypes; if (tt$2) try { policy = /* @__PURE__ */ tt$2.createPolicy("vue", { createHTML: (val) => val }); } catch (e) {} var unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val; var svgNS = "http://www.w3.org/2000/svg"; var mathmlNS = "http://www.w3.org/1998/Math/MathML"; var doc = typeof document !== "undefined" ? document : null; var templateContainer = doc && /* @__PURE__ */ doc.createElement("template"); var nodeOps = { insert: (child, parent, anchor) => { parent.insertBefore(child, anchor || null); }, remove: (child) => { const parent = child.parentNode; if (parent) parent.removeChild(child); }, createElement: (tag, namespace, is, props) => { const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag); if (tag === "select" && props && props.multiple != null) el.setAttribute("multiple", props.multiple); return el; }, createText: (text) => doc.createTextNode(text), createComment: (text) => doc.createComment(text), setText: (node, text) => { node.nodeValue = text; }, setElementText: (el, text) => { el.textContent = text; }, parentNode: (node) => node.parentNode, nextSibling: (node) => node.nextSibling, querySelector: (selector) => doc.querySelector(selector), setScopeId(el, id) { el.setAttribute(id, ""); }, insertStaticContent(content, parent, anchor, namespace, start, end) { const before = anchor ? anchor.previousSibling : parent.lastChild; if (start && (start === end || start.nextSibling)) while (true) { parent.insertBefore(start.cloneNode(true), anchor); if (start === end || !(start = start.nextSibling)) break; } else { templateContainer.innerHTML = unsafeToTrustedHTML(namespace === "svg" ? `${content}` : namespace === "mathml" ? `${content}` : content); const template = templateContainer.content; if (namespace === "svg" || namespace === "mathml") { const wrapper = template.firstChild; while (wrapper.firstChild) template.appendChild(wrapper.firstChild); template.removeChild(wrapper); } parent.insertBefore(template, anchor); } return [before ? before.nextSibling : parent.firstChild, anchor ? anchor.previousSibling : parent.lastChild]; } }; var TRANSITION = "transition"; var ANIMATION = "animation"; var vtcKey = /* @__PURE__ */ Symbol("_vtc"); var DOMTransitionPropsValidators = { name: String, type: String, css: { type: Boolean, default: true }, duration: [ String, Number, Object ], enterFromClass: String, enterActiveClass: String, enterToClass: String, appearFromClass: String, appearActiveClass: String, appearToClass: String, leaveFromClass: String, leaveActiveClass: String, leaveToClass: String }; var TransitionPropsValidators = /* @__PURE__ */ extend({}, BaseTransitionPropsValidators, DOMTransitionPropsValidators); var decorate$1 = (t) => { t.displayName = "Transition"; t.props = TransitionPropsValidators; return t; }; var Transition = /* @__PURE__ */ decorate$1((props, { slots }) => h$2(BaseTransition, resolveTransitionProps(props), slots)); var callHook = (hook, args = []) => { if (isArray(hook)) hook.forEach((h2) => h2(...args)); else if (hook) hook(...args); }; var hasExplicitCallback = (hook) => { return hook ? isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false; }; function resolveTransitionProps(rawProps) { const baseProps = {}; for (const key in rawProps) if (!(key in DOMTransitionPropsValidators)) baseProps[key] = rawProps[key]; if (rawProps.css === false) return baseProps; const { name = "v", type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps; const durations = normalizeDuration(duration); const enterDuration = durations && durations[0]; const leaveDuration = durations && durations[1]; const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps; const finishEnter = (el, isAppear, done, isCancelled) => { el._enterCancelled = isCancelled; removeTransitionClass(el, isAppear ? appearToClass : enterToClass); removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass); done && done(); }; const finishLeave = (el, done) => { el._isLeaving = false; removeTransitionClass(el, leaveFromClass); removeTransitionClass(el, leaveToClass); removeTransitionClass(el, leaveActiveClass); done && done(); }; const makeEnterHook = (isAppear) => { return (el, done) => { const hook = isAppear ? onAppear : onEnter; const resolve = () => finishEnter(el, isAppear, done); callHook(hook, [el, resolve]); nextFrame(() => { removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass); addTransitionClass(el, isAppear ? appearToClass : enterToClass); if (!hasExplicitCallback(hook)) whenTransitionEnds(el, type, enterDuration, resolve); }); }; }; return extend(baseProps, { onBeforeEnter(el) { callHook(onBeforeEnter, [el]); addTransitionClass(el, enterFromClass); addTransitionClass(el, enterActiveClass); }, onBeforeAppear(el) { callHook(onBeforeAppear, [el]); addTransitionClass(el, appearFromClass); addTransitionClass(el, appearActiveClass); }, onEnter: makeEnterHook(false), onAppear: makeEnterHook(true), onLeave(el, done) { el._isLeaving = true; const resolve = () => finishLeave(el, done); addTransitionClass(el, leaveFromClass); if (!el._enterCancelled) { forceReflow(el); addTransitionClass(el, leaveActiveClass); } else { addTransitionClass(el, leaveActiveClass); forceReflow(el); } nextFrame(() => { if (!el._isLeaving) return; removeTransitionClass(el, leaveFromClass); addTransitionClass(el, leaveToClass); if (!hasExplicitCallback(onLeave)) whenTransitionEnds(el, type, leaveDuration, resolve); }); callHook(onLeave, [el, resolve]); }, onEnterCancelled(el) { finishEnter(el, false, void 0, true); callHook(onEnterCancelled, [el]); }, onAppearCancelled(el) { finishEnter(el, true, void 0, true); callHook(onAppearCancelled, [el]); }, onLeaveCancelled(el) { finishLeave(el); callHook(onLeaveCancelled, [el]); } }); } function normalizeDuration(duration) { if (duration == null) return null; else if (isObject$2(duration)) return [NumberOf(duration.enter), NumberOf(duration.leave)]; else { const n = NumberOf(duration); return [n, n]; } } function NumberOf(val) { return toNumber(val); } function addTransitionClass(el, cls) { cls.split(/\s+/).forEach((c) => c && el.classList.add(c)); (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls); } function removeTransitionClass(el, cls) { cls.split(/\s+/).forEach((c) => c && el.classList.remove(c)); const _vtc = el[vtcKey]; if (_vtc) { _vtc.delete(cls); if (!_vtc.size) el[vtcKey] = void 0; } } function nextFrame(cb) { requestAnimationFrame(() => { requestAnimationFrame(cb); }); } var endId = 0; function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) { const id = el._endId = ++endId; const resolveIfNotStale = () => { if (id === el._endId) resolve(); }; if (explicitTimeout != null) return setTimeout(resolveIfNotStale, explicitTimeout); const { type, timeout, propCount } = getTransitionInfo(el, expectedType); if (!type) return resolve(); const endEvent = type + "end"; let ended = 0; const end = () => { el.removeEventListener(endEvent, onEnd); resolveIfNotStale(); }; const onEnd = (e) => { if (e.target === el && ++ended >= propCount) end(); }; setTimeout(() => { if (ended < propCount) end(); }, timeout + 1); el.addEventListener(endEvent, onEnd); } function getTransitionInfo(el, expectedType) { const styles = window.getComputedStyle(el); const getStyleProperties = (key) => (styles[key] || "").split(", "); const transitionDelays = getStyleProperties(`${TRANSITION}Delay`); const transitionDurations = getStyleProperties(`${TRANSITION}Duration`); const transitionTimeout = getTimeout(transitionDelays, transitionDurations); const animationDelays = getStyleProperties(`${ANIMATION}Delay`); const animationDurations = getStyleProperties(`${ANIMATION}Duration`); const animationTimeout = getTimeout(animationDelays, animationDurations); let type = null; let timeout = 0; let propCount = 0; if (expectedType === TRANSITION) { if (transitionTimeout > 0) { type = TRANSITION; timeout = transitionTimeout; propCount = transitionDurations.length; } } else if (expectedType === ANIMATION) { if (animationTimeout > 0) { type = ANIMATION; timeout = animationTimeout; propCount = animationDurations.length; } } else { timeout = Math.max(transitionTimeout, animationTimeout); type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null; propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0; } const hasTransform = type === TRANSITION && /\b(?:transform|all)(?:,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString()); return { type, timeout, propCount, hasTransform }; } function getTimeout(delays, durations) { while (delays.length < durations.length) delays = delays.concat(delays); return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i]))); } function toMs(s) { if (s === "auto") return 0; return Number(s.slice(0, -1).replace(",", ".")) * 1e3; } function forceReflow(el) { return (el ? el.ownerDocument : document).body.offsetHeight; } function patchClass(el, value, isSVG) { const transitionClasses = el[vtcKey]; if (transitionClasses) value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" "); if (value == null) el.removeAttribute("class"); else if (isSVG) el.setAttribute("class", value); else el.className = value; } var vShowOriginalDisplay = /* @__PURE__ */ Symbol("_vod"); var vShowHidden = /* @__PURE__ */ Symbol("_vsh"); var vShow = { name: "show", beforeMount(el, { value }, { transition }) { el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display; if (transition && value) transition.beforeEnter(el); else setDisplay(el, value); }, mounted(el, { value }, { transition }) { if (transition && value) transition.enter(el); }, updated(el, { value, oldValue }, { transition }) { if (!value === !oldValue) return; if (transition) if (value) { transition.beforeEnter(el); setDisplay(el, true); transition.enter(el); } else transition.leave(el, () => { setDisplay(el, false); }); else setDisplay(el, value); }, beforeUnmount(el, { value }) { setDisplay(el, value); } }; function setDisplay(el, value) { el.style.display = value ? el[vShowOriginalDisplay] : "none"; el[vShowHidden] = !value; } function initVShowForSSR() { vShow.getSSRProps = ({ value }) => { if (!value) return { style: { display: "none" } }; }; } var CSS_VAR_TEXT = /* @__PURE__ */ Symbol(""); function useCssVars(getter) { const instance = getCurrentInstance(); if (!instance) return; const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => { Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach((node) => setVarsOnNode(node, vars)); }; const setVars = () => { const vars = getter(instance.proxy); if (instance.ce) setVarsOnNode(instance.ce, vars); else setVarsOnVNode(instance.subTree, vars); updateTeleports(vars); }; onBeforeUpdate(() => { queuePostFlushCb(setVars); }); onMounted(() => { watch(setVars, NOOP, { flush: "post" }); const ob = new MutationObserver(setVars); ob.observe(instance.subTree.el.parentNode, { childList: true }); onUnmounted(() => ob.disconnect()); }); } function setVarsOnVNode(vnode, vars) { if (vnode.shapeFlag & 128) { const suspense = vnode.suspense; vnode = suspense.activeBranch; if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => { setVarsOnVNode(suspense.activeBranch, vars); }); } while (vnode.component) vnode = vnode.component.subTree; if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars); else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars)); else if (vnode.type === Static) { let { el, anchor } = vnode; while (el) { setVarsOnNode(el, vars); if (el === anchor) break; el = el.nextSibling; } } } function setVarsOnNode(el, vars) { if (el.nodeType === 1) { const style = el.style; let cssText = ""; for (const key in vars) { const value = normalizeCssVarValue(vars[key]); style.setProperty(`--${key}`, value); cssText += `--${key}: ${value};`; } style[CSS_VAR_TEXT] = cssText; } } var displayRE = /(?:^|;)\s*display\s*:/; function patchStyle(el, prev, next) { const style = el.style; const isCssString = isString(next); let hasControlledDisplay = false; if (next && !isCssString) { if (prev) if (!isString(prev)) { for (const key in prev) if (next[key] == null) setStyle(style, key, ""); } else for (const prevStyle of prev.split(";")) { const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim(); if (next[key] == null) setStyle(style, key, ""); } for (const key in next) { if (key === "display") hasControlledDisplay = true; const value = next[key]; if (value != null) { if (!shouldPreserveTextareaResizeStyle(el, key, !isString(prev) && prev ? prev[key] : void 0, value)) setStyle(style, key, value); } else setStyle(style, key, ""); } } else if (isCssString) { if (prev !== next) { const cssVarText = style[CSS_VAR_TEXT]; if (cssVarText) next += ";" + cssVarText; style.cssText = next; hasControlledDisplay = displayRE.test(next); } } else if (prev) el.removeAttribute("style"); if (vShowOriginalDisplay in el) { el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : ""; if (el[vShowHidden]) style.display = "none"; } } var importantRE = /\s*!important$/; function setStyle(style, name, val) { if (isArray(val)) val.forEach((v) => setStyle(style, name, v)); else { if (val == null) val = ""; if (name.startsWith("--")) style.setProperty(name, val); else { const prefixed = autoPrefix(style, name); if (importantRE.test(val)) style.setProperty(hyphenate$2(prefixed), val.replace(importantRE, ""), "important"); else style[prefixed] = val; } } } var prefixes = [ "Webkit", "Moz", "ms" ]; var prefixCache = {}; function autoPrefix(style, rawName) { const cached = prefixCache[rawName]; if (cached) return cached; let name = camelize$2(rawName); if (name !== "filter" && name in style) return prefixCache[rawName] = name; name = capitalize(name); for (let i = 0; i < prefixes.length; i++) { const prefixed = prefixes[i] + name; if (prefixed in style) return prefixCache[rawName] = prefixed; } return rawName; } function shouldPreserveTextareaResizeStyle(el, key, prev, next) { return el.tagName === "TEXTAREA" && (key === "width" || key === "height") && isString(next) && prev === next; } var xlinkNS = "http://www.w3.org/1999/xlink"; function patchAttr(el, key, value, isSVG, instance, isBoolean = isSpecialBooleanAttr(key)) { if (isSVG && key.startsWith("xlink:")) if (value == null) el.removeAttributeNS(xlinkNS, key.slice(6, key.length)); else el.setAttributeNS(xlinkNS, key, value); else if (value == null || isBoolean && !includeBooleanAttr(value)) el.removeAttribute(key); else el.setAttribute(key, isBoolean ? "" : isSymbol(value) ? String(value) : value); } function patchDOMProp(el, key, value, parentComponent, attrName) { if (key === "innerHTML" || key === "textContent") { if (value != null) el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value; return; } const tag = el.tagName; if (key === "value" && tag !== "PROGRESS" && !tag.includes("-")) { const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value; const newValue = value == null ? el.type === "checkbox" ? "on" : "" : String(value); if (oldValue !== newValue || !("_value" in el)) el.value = newValue; if (value == null) el.removeAttribute(key); el._value = value; return; } let needRemove = false; if (value === "" || value == null) { const type = typeof el[key]; if (type === "boolean") value = includeBooleanAttr(value); else if (value == null && type === "string") { value = ""; needRemove = true; } else if (type === "number") { value = 0; needRemove = true; } } try { el[key] = value; } catch (e) {} needRemove && el.removeAttribute(attrName || key); } function addEventListener(el, event, handler, options) { el.addEventListener(event, handler, options); } function removeEventListener(el, event, handler, options) { el.removeEventListener(event, handler, options); } var veiKey = /* @__PURE__ */ Symbol("_vei"); function patchEvent(el, rawName, prevValue, nextValue, instance = null) { const invokers = el[veiKey] || (el[veiKey] = {}); const existingInvoker = invokers[rawName]; if (nextValue && existingInvoker) existingInvoker.value = nextValue; else { const [name, options] = parseName(rawName); if (nextValue) addEventListener(el, name, invokers[rawName] = createInvoker(nextValue, instance), options); else if (existingInvoker) { removeEventListener(el, name, existingInvoker, options); invokers[rawName] = void 0; } } } var optionsModifierRE = /(?:Once|Passive|Capture)$/; function parseName(name) { let options; if (optionsModifierRE.test(name)) { options = {}; let m; while (m = name.match(optionsModifierRE)) { name = name.slice(0, name.length - m[0].length); options[m[0].toLowerCase()] = true; } } return [name[2] === ":" ? name.slice(3) : hyphenate$2(name.slice(2)), options]; } var cachedNow = 0; var p$1 = /* @__PURE__ */ Promise.resolve(); var getNow = () => cachedNow || (p$1.then(() => cachedNow = 0), cachedNow = Date.now()); function createInvoker(initialValue, instance) { const invoker = (e) => { if (!e._vts) e._vts = Date.now(); else if (e._vts <= invoker.attached) return; callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5, [e]); }; invoker.value = initialValue; invoker.attached = getNow(); return invoker; } function patchStopImmediatePropagation(e, value) { if (isArray(value)) { const originalStop = e.stopImmediatePropagation; e.stopImmediatePropagation = () => { originalStop.call(e); e._stopped = true; }; return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2)); } else return value; } var isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123; var patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => { const isSVG = namespace === "svg"; if (key === "class") patchClass(el, nextValue, isSVG); else if (key === "style") patchStyle(el, prevValue, nextValue); else if (isOn(key)) { if (!isModelListener(key)) patchEvent(el, key, prevValue, nextValue, parentComponent); } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) { patchDOMProp(el, key, nextValue); if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value"); } else if (el._isVueCE && (shouldSetAsPropForVueCE(el, key) || el._def.__asyncLoader && (/[A-Z]/.test(key) || !isString(nextValue)))) patchDOMProp(el, camelize$2(key), nextValue, parentComponent, key); else { if (key === "true-value") el._trueValue = nextValue; else if (key === "false-value") el._falseValue = nextValue; patchAttr(el, key, nextValue, isSVG); } }; function shouldSetAsProp(el, key, value, isSVG) { if (isSVG) { if (key === "innerHTML" || key === "textContent") return true; if (key in el && isNativeOn(key) && isFunction$2(value)) return true; return false; } if (key === "spellcheck" || key === "draggable" || key === "translate" || key === "autocorrect") return false; if (key === "sandbox" && el.tagName === "IFRAME") return false; if (key === "form") return false; if (key === "list" && el.tagName === "INPUT") return false; if (key === "type" && el.tagName === "TEXTAREA") return false; if (key === "width" || key === "height") { const tag = el.tagName; if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") return false; } if (isNativeOn(key) && isString(value)) return false; return key in el; } function shouldSetAsPropForVueCE(el, key) { const props = el._def.props; if (!props) return false; const camelKey = camelize$2(key); return Array.isArray(props) ? props.some((prop) => camelize$2(prop) === camelKey) : Object.keys(props).some((prop) => camelize$2(prop) === camelKey); } var REMOVAL = {}; // @__NO_SIDE_EFFECTS__ function defineCustomElement(options, extraOptions, _createApp) { let Comp = /* @__PURE__ */ defineComponent(options, extraOptions); if (isPlainObject$3(Comp)) Comp = extend({}, Comp, extraOptions); class VueCustomElement extends VueElement { constructor(initialProps) { super(Comp, initialProps, _createApp); } } VueCustomElement.def = Comp; return VueCustomElement; } var defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ ((options, extraOptions) => { return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp); }); var BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {}; var VueElement = class VueElement extends BaseClass { constructor(_def, _props = {}, _createApp = createApp) { super(); this._def = _def; this._props = _props; this._createApp = _createApp; this._isVueCE = true; /** * @internal */ this._instance = null; /** * @internal */ this._app = null; /** * @internal */ this._nonce = this._def.nonce; this._connected = false; this._resolved = false; this._patching = false; this._dirty = false; this._numberProps = null; this._styleChildren = /* @__PURE__ */ new WeakSet(); this._styleAnchors = /* @__PURE__ */ new WeakMap(); this._ob = null; if (this.shadowRoot && _createApp !== createApp) this._root = this.shadowRoot; else if (_def.shadowRoot !== false) { this.attachShadow(extend({}, _def.shadowRootOptions, { mode: "open" })); this._root = this.shadowRoot; } else this._root = this; } connectedCallback() { if (!this.isConnected) return; if (!this.shadowRoot && !this._resolved) this._parseSlots(); this._connected = true; let parent = this; while (parent = parent && (parent.assignedSlot || parent.parentNode || parent.host)) if (parent instanceof VueElement) { this._parent = parent; break; } if (!this._instance) if (this._resolved) this._mount(this._def); else if (parent && parent._pendingResolve) this._pendingResolve = parent._pendingResolve.then(() => { this._pendingResolve = void 0; this._resolveDef(); }); else this._resolveDef(); } _setParent(parent = this._parent) { if (parent) { this._instance.parent = parent._instance; this._inheritParentContext(parent); } } _inheritParentContext(parent = this._parent) { if (parent && this._app) Object.setPrototypeOf(this._app._context.provides, parent._instance.provides); } disconnectedCallback() { this._connected = false; nextTick(() => { if (!this._connected) { if (this._ob) { this._ob.disconnect(); this._ob = null; } this._app && this._app.unmount(); if (this._instance) this._instance.ce = void 0; this._app = this._instance = null; if (this._teleportTargets) { this._teleportTargets.clear(); this._teleportTargets = void 0; } } }); } _processMutations(mutations) { for (const m of mutations) this._setAttr(m.attributeName); } /** * resolve inner component definition (handle possible async component) */ _resolveDef() { if (this._pendingResolve) return; for (let i = 0; i < this.attributes.length; i++) this._setAttr(this.attributes[i].name); this._ob = new MutationObserver(this._processMutations.bind(this)); this._ob.observe(this, { attributes: true }); const resolve = (def, isAsync = false) => { this._resolved = true; this._pendingResolve = void 0; const { props, styles } = def; let numberProps; if (props && !isArray(props)) for (const key in props) { const opt = props[key]; if (opt === Number || opt && opt.type === Number) { if (key in this._props) this._props[key] = toNumber(this._props[key]); (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize$2(key)] = true; } } this._numberProps = numberProps; this._resolveProps(def); if (this.shadowRoot) this._applyStyles(styles); this._mount(def); }; const asyncDef = this._def.__asyncLoader; if (asyncDef) this._pendingResolve = asyncDef().then((def) => { def.configureApp = this._def.configureApp; resolve(this._def = def, true); }); else resolve(this._def); } _mount(def) { this._app = this._createApp(def); this._inheritParentContext(); if (def.configureApp) def.configureApp(this._app); this._app._ceVNode = this._createVNode(); this._app.mount(this._root); const exposed = this._instance && this._instance.exposed; if (!exposed) return; for (const key in exposed) if (!hasOwn(this, key)) Object.defineProperty(this, key, { get: () => unref(exposed[key]) }); } _resolveProps(def) { const { props } = def; const declaredPropKeys = isArray(props) ? props : Object.keys(props || {}); for (const key of Object.keys(this)) if (key[0] !== "_" && declaredPropKeys.includes(key)) this._setProp(key, this[key]); for (const key of declaredPropKeys.map(camelize$2)) Object.defineProperty(this, key, { get() { return this._getProp(key); }, set(val) { this._setProp(key, val, true, !this._patching); } }); } _setAttr(key) { if (key.startsWith("data-v-")) return; const has = this.hasAttribute(key); let value = has ? this.getAttribute(key) : REMOVAL; const camelKey = camelize$2(key); if (has && this._numberProps && this._numberProps[camelKey]) value = toNumber(value); this._setProp(camelKey, value, false, true); } /** * @internal */ _getProp(key) { return this._props[key]; } /** * @internal */ _setProp(key, val, shouldReflect = true, shouldUpdate = false) { if (val !== this._props[key]) { this._dirty = true; if (val === REMOVAL) delete this._props[key]; else { this._props[key] = val; if (key === "key" && this._app) this._app._ceVNode.key = val; } if (shouldUpdate && this._instance) this._update(); if (shouldReflect) { const ob = this._ob; if (ob) { this._processMutations(ob.takeRecords()); ob.disconnect(); } if (val === true) this.setAttribute(hyphenate$2(key), ""); else if (typeof val === "string" || typeof val === "number") this.setAttribute(hyphenate$2(key), val + ""); else if (!val) this.removeAttribute(hyphenate$2(key)); ob && ob.observe(this, { attributes: true }); } } } _update() { const vnode = this._createVNode(); if (this._app) vnode.appContext = this._app._context; render(vnode, this._root); } _createVNode() { const baseProps = {}; if (!this.shadowRoot) baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this); const vnode = createVNode(this._def, extend(baseProps, this._props)); if (!this._instance) vnode.ce = (instance) => { this._instance = instance; instance.ce = this; instance.isCE = true; const dispatch = (event, args) => { this.dispatchEvent(new CustomEvent(event, isPlainObject$3(args[0]) ? extend({ detail: args }, args[0]) : { detail: args })); }; instance.emit = (event, ...args) => { dispatch(event, args); if (hyphenate$2(event) !== event) dispatch(hyphenate$2(event), args); }; this._setParent(); }; return vnode; } _applyStyles(styles, owner, parentComp) { if (!styles) return; if (owner) { if (owner === this._def || this._styleChildren.has(owner)) return; this._styleChildren.add(owner); } const nonce = this._nonce; const root = this.shadowRoot; const insertionAnchor = parentComp ? this._getStyleAnchor(parentComp) || this._getStyleAnchor(this._def) : this._getRootStyleInsertionAnchor(root); let last = null; for (let i = styles.length - 1; i >= 0; i--) { const s = document.createElement("style"); if (nonce) s.setAttribute("nonce", nonce); s.textContent = styles[i]; root.insertBefore(s, last || insertionAnchor); last = s; if (i === 0) { if (!parentComp) this._styleAnchors.set(this._def, s); if (owner) this._styleAnchors.set(owner, s); } } } _getStyleAnchor(comp) { if (!comp) return null; const anchor = this._styleAnchors.get(comp); if (anchor && anchor.parentNode === this.shadowRoot) return anchor; if (anchor) this._styleAnchors.delete(comp); return null; } _getRootStyleInsertionAnchor(root) { for (let i = 0; i < root.childNodes.length; i++) { const node = root.childNodes[i]; if (!(node instanceof HTMLStyleElement)) return node; } return null; } /** * Only called when shadowRoot is false */ _parseSlots() { const slots = this._slots = {}; let n; while (n = this.firstChild) { const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default"; (slots[slotName] || (slots[slotName] = [])).push(n); this.removeChild(n); } } /** * Only called when shadowRoot is false */ _renderSlots() { const outlets = this._getSlots(); const scopeId = this._instance.type.__scopeId; for (let i = 0; i < outlets.length; i++) { const o = outlets[i]; const slotName = o.getAttribute("name") || "default"; const content = this._slots[slotName]; const parent = o.parentNode; if (content) for (const n of content) { if (scopeId && n.nodeType === 1) { const id = scopeId + "-s"; const walker = document.createTreeWalker(n, 1); n.setAttribute(id, ""); let child; while (child = walker.nextNode()) child.setAttribute(id, ""); } parent.insertBefore(n, o); } else while (o.firstChild) parent.insertBefore(o.firstChild, o); parent.removeChild(o); } } /** * @internal */ _getSlots() { const roots = [this]; if (this._teleportTargets) roots.push(...this._teleportTargets); const slots = /* @__PURE__ */ new Set(); for (const root of roots) { const found = root.querySelectorAll("slot"); for (let i = 0; i < found.length; i++) slots.add(found[i]); } return Array.from(slots); } /** * @internal */ _injectChildStyle(comp, parentComp) { this._applyStyles(comp.styles, comp, parentComp); } /** * @internal */ _beginPatch() { this._patching = true; this._dirty = false; } /** * @internal */ _endPatch() { this._patching = false; if (this._dirty && this._instance) this._update(); } /** * @internal */ _hasShadowRoot() { return this._def.shadowRoot !== false; } /** * @internal */ _removeChildStyle(comp) {} }; function useHost(caller) { const instance = getCurrentInstance(); const el = instance && instance.ce; if (el) return el; return null; } function useShadowRoot() { const el = useHost(); return el && el.shadowRoot; } function useCssModule(name = "$style") { { const instance = getCurrentInstance(); if (!instance) return EMPTY_OBJ; const modules = instance.type.__cssModules; if (!modules) return EMPTY_OBJ; const mod = modules[name]; if (!mod) return EMPTY_OBJ; return mod; } } var positionMap = /* @__PURE__ */ new WeakMap(); var newPositionMap = /* @__PURE__ */ new WeakMap(); var moveCbKey = /* @__PURE__ */ Symbol("_moveCb"); var enterCbKey = /* @__PURE__ */ Symbol("_enterCb"); var decorate = (t) => { delete t.props.mode; return t; }; var TransitionGroup = /* @__PURE__ */ decorate({ name: "TransitionGroup", props: /* @__PURE__ */ extend({}, TransitionPropsValidators, { tag: String, moveClass: String }), setup(props, { slots }) { const instance = getCurrentInstance(); const state = useTransitionState(); let prevChildren; let children; onUpdated(() => { if (!prevChildren.length) return; const moveClass = props.moveClass || `${props.name || "v"}-move`; if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) { prevChildren = []; return; } prevChildren.forEach(callPendingCbs); prevChildren.forEach(recordPosition); const movedChildren = prevChildren.filter(applyTranslation); forceReflow(instance.vnode.el); movedChildren.forEach((c) => { const el = c.el; const style = el.style; addTransitionClass(el, moveClass); style.transform = style.webkitTransform = style.transitionDuration = ""; const cb = el[moveCbKey] = (e) => { if (e && e.target !== el) return; if (!e || e.propertyName.endsWith("transform")) { el.removeEventListener("transitionend", cb); el[moveCbKey] = null; removeTransitionClass(el, moveClass); } }; el.addEventListener("transitionend", cb); }); prevChildren = []; }); return () => { const rawProps = /* @__PURE__ */ toRaw(props); const cssTransitionProps = resolveTransitionProps(rawProps); let tag = rawProps.tag || Fragment; prevChildren = []; if (children) for (let i = 0; i < children.length; i++) { const child = children[i]; if (child.el && child.el instanceof Element) { prevChildren.push(child); setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance)); positionMap.set(child, getPosition(child.el)); } } children = slots.default ? getTransitionRawChildren(slots.default()) : []; for (let i = 0; i < children.length; i++) { const child = children[i]; if (child.key != null) setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance)); } return createVNode(tag, null, children); }; } }); function callPendingCbs(c) { const el = c.el; if (el[moveCbKey]) el[moveCbKey](); if (el[enterCbKey]) el[enterCbKey](); } function recordPosition(c) { newPositionMap.set(c, getPosition(c.el)); } function applyTranslation(c) { const oldPos = positionMap.get(c); const newPos = newPositionMap.get(c); const dx = oldPos.left - newPos.left; const dy = oldPos.top - newPos.top; if (dx || dy) { const el = c.el; const s = el.style; const rect = el.getBoundingClientRect(); let scaleX = 1; let scaleY = 1; if (el.offsetWidth) scaleX = rect.width / el.offsetWidth; if (el.offsetHeight) scaleY = rect.height / el.offsetHeight; if (!Number.isFinite(scaleX) || scaleX === 0) scaleX = 1; if (!Number.isFinite(scaleY) || scaleY === 0) scaleY = 1; if (Math.abs(scaleX - 1) < .01) scaleX = 1; if (Math.abs(scaleY - 1) < .01) scaleY = 1; s.transform = s.webkitTransform = `translate(${dx / scaleX}px,${dy / scaleY}px)`; s.transitionDuration = "0s"; return c; } } function getPosition(el) { const rect = el.getBoundingClientRect(); return { left: rect.left, top: rect.top }; } function hasCSSTransform(el, root, moveClass) { const clone = el.cloneNode(); const _vtc = el[vtcKey]; if (_vtc) _vtc.forEach((cls) => { cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c)); }); moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c)); clone.style.display = "none"; const container = root.nodeType === 1 ? root : root.parentNode; container.appendChild(clone); const { hasTransform } = getTransitionInfo(clone); container.removeChild(clone); return hasTransform; } var getModelAssigner = (vnode) => { const fn = vnode.props["onUpdate:modelValue"] || false; return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn; }; function onCompositionStart(e) { e.target.composing = true; } function onCompositionEnd(e) { const target = e.target; if (target.composing) { target.composing = false; target.dispatchEvent(new Event("input")); } } var assignKey = /* @__PURE__ */ Symbol("_assign"); function castValue(value, trim, number) { if (trim) value = value.trim(); if (number) value = looseToNumber(value); return value; } var vModelText = { created(el, { modifiers: { lazy, trim, number } }, vnode) { el[assignKey] = getModelAssigner(vnode); const castToNumber = number || vnode.props && vnode.props.type === "number"; addEventListener(el, lazy ? "change" : "input", (e) => { if (e.target.composing) return; el[assignKey](castValue(el.value, trim, castToNumber)); }); if (trim || castToNumber) addEventListener(el, "change", () => { el.value = castValue(el.value, trim, castToNumber); }); if (!lazy) { addEventListener(el, "compositionstart", onCompositionStart); addEventListener(el, "compositionend", onCompositionEnd); addEventListener(el, "change", onCompositionEnd); } }, mounted(el, { value }) { el.value = value == null ? "" : value; }, beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) { el[assignKey] = getModelAssigner(vnode); if (el.composing) return; const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value; const newValue = value == null ? "" : value; if (elValue === newValue) return; const rootNode = el.getRootNode(); if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement === el && el.type !== "range") { if (lazy && value === oldValue) return; if (trim && el.value.trim() === newValue) return; } el.value = newValue; } }; var vModelCheckbox = { deep: true, created(el, _, vnode) { el[assignKey] = getModelAssigner(vnode); addEventListener(el, "change", () => { const modelValue = el._modelValue; const elementValue = getValue(el); const checked = el.checked; const assign = el[assignKey]; if (isArray(modelValue)) { const index = looseIndexOf(modelValue, elementValue); const found = index !== -1; if (checked && !found) assign(modelValue.concat(elementValue)); else if (!checked && found) { const filtered = [...modelValue]; filtered.splice(index, 1); assign(filtered); } } else if (isSet(modelValue)) { const cloned = new Set(modelValue); if (checked) cloned.add(elementValue); else cloned.delete(elementValue); assign(cloned); } else assign(getCheckboxValue(el, checked)); }); }, mounted: setChecked, beforeUpdate(el, binding, vnode) { el[assignKey] = getModelAssigner(vnode); setChecked(el, binding, vnode); } }; function setChecked(el, { value, oldValue }, vnode) { el._modelValue = value; let checked; if (isArray(value)) checked = looseIndexOf(value, vnode.props.value) > -1; else if (isSet(value)) checked = value.has(vnode.props.value); else { if (value === oldValue) return; checked = looseEqual(value, getCheckboxValue(el, true)); } if (el.checked !== checked) el.checked = checked; } var vModelRadio = { created(el, { value }, vnode) { el.checked = looseEqual(value, vnode.props.value); el[assignKey] = getModelAssigner(vnode); addEventListener(el, "change", () => { el[assignKey](getValue(el)); }); }, beforeUpdate(el, { value, oldValue }, vnode) { el[assignKey] = getModelAssigner(vnode); if (value !== oldValue) el.checked = looseEqual(value, vnode.props.value); } }; var vModelSelect = { deep: true, created(el, { value, modifiers: { number } }, vnode) { const isSetModel = isSet(value); addEventListener(el, "change", () => { const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map((o) => number ? looseToNumber(getValue(o)) : getValue(o)); el[assignKey](el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]); el._assigning = true; nextTick(() => { el._assigning = false; }); }); el[assignKey] = getModelAssigner(vnode); }, mounted(el, { value }) { setSelected(el, value); }, beforeUpdate(el, _binding, vnode) { el[assignKey] = getModelAssigner(vnode); }, updated(el, { value }) { if (!el._assigning) setSelected(el, value); } }; function setSelected(el, value) { const isMultiple = el.multiple; const isArrayValue = isArray(value); if (isMultiple && !isArrayValue && !isSet(value)) return; for (let i = 0, l = el.options.length; i < l; i++) { const option = el.options[i]; const optionValue = getValue(option); if (isMultiple) if (isArrayValue) { const optionType = typeof optionValue; if (optionType === "string" || optionType === "number") option.selected = value.some((v) => String(v) === String(optionValue)); else option.selected = looseIndexOf(value, optionValue) > -1; } else option.selected = value.has(optionValue); else if (looseEqual(getValue(option), value)) { if (el.selectedIndex !== i) el.selectedIndex = i; return; } } if (!isMultiple && el.selectedIndex !== -1) el.selectedIndex = -1; } function getValue(el) { return "_value" in el ? el._value : el.value; } function getCheckboxValue(el, checked) { const key = checked ? "_trueValue" : "_falseValue"; return key in el ? el[key] : checked; } var vModelDynamic = { created(el, binding, vnode) { callModelHook(el, binding, vnode, null, "created"); }, mounted(el, binding, vnode) { callModelHook(el, binding, vnode, null, "mounted"); }, beforeUpdate(el, binding, vnode, prevVNode) { callModelHook(el, binding, vnode, prevVNode, "beforeUpdate"); }, updated(el, binding, vnode, prevVNode) { callModelHook(el, binding, vnode, prevVNode, "updated"); } }; function resolveDynamicModel(tagName, type) { switch (tagName) { case "SELECT": return vModelSelect; case "TEXTAREA": return vModelText; default: switch (type) { case "checkbox": return vModelCheckbox; case "radio": return vModelRadio; default: return vModelText; } } } function callModelHook(el, binding, vnode, prevVNode, hook) { const fn = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type)[hook]; fn && fn(el, binding, vnode, prevVNode); } function initVModelForSSR() { vModelText.getSSRProps = ({ value }) => ({ value }); vModelRadio.getSSRProps = ({ value }, vnode) => { if (vnode.props && looseEqual(vnode.props.value, value)) return { checked: true }; }; vModelCheckbox.getSSRProps = ({ value }, vnode) => { if (isArray(value)) { if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) return { checked: true }; } else if (isSet(value)) { if (vnode.props && value.has(vnode.props.value)) return { checked: true }; } else if (value) return { checked: true }; }; vModelDynamic.getSSRProps = (binding, vnode) => { if (typeof vnode.type !== "string") return; const modelToUse = resolveDynamicModel(vnode.type.toUpperCase(), vnode.props && vnode.props.type); if (modelToUse.getSSRProps) return modelToUse.getSSRProps(binding, vnode); }; } var systemModifiers = [ "ctrl", "shift", "alt", "meta" ]; var modifierGuards = { stop: (e) => e.stopPropagation(), prevent: (e) => e.preventDefault(), self: (e) => e.target !== e.currentTarget, ctrl: (e) => !e.ctrlKey, shift: (e) => !e.shiftKey, alt: (e) => !e.altKey, meta: (e) => !e.metaKey, left: (e) => "button" in e && e.button !== 0, middle: (e) => "button" in e && e.button !== 1, right: (e) => "button" in e && e.button !== 2, exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m)) }; var withModifiers = (fn, modifiers) => { if (!fn) return fn; const cache = fn._withMods || (fn._withMods = {}); const cacheKey = modifiers.join("."); return cache[cacheKey] || (cache[cacheKey] = ((event, ...args) => { for (let i = 0; i < modifiers.length; i++) { const guard = modifierGuards[modifiers[i]]; if (guard && guard(event, modifiers)) return; } return fn(event, ...args); })); }; var keyNames = { esc: "escape", space: " ", up: "arrow-up", left: "arrow-left", right: "arrow-right", down: "arrow-down", delete: "backspace" }; var withKeys = (fn, modifiers) => { const cache = fn._withKeys || (fn._withKeys = {}); const cacheKey = modifiers.join("."); return cache[cacheKey] || (cache[cacheKey] = ((event) => { if (!("key" in event)) return; const eventKey = hyphenate$2(event.key); if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) return fn(event); })); }; var rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps); var renderer; var enabledHydration = false; function ensureRenderer() { return renderer || (renderer = createRenderer(rendererOptions)); } function ensureHydrationRenderer() { renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions); enabledHydration = true; return renderer; } var render = ((...args) => { ensureRenderer().render(...args); }); var hydrate = ((...args) => { ensureHydrationRenderer().hydrate(...args); }); var createApp = ((...args) => { const app = ensureRenderer().createApp(...args); const { mount } = app; app.mount = (containerOrSelector) => { const container = normalizeContainer(containerOrSelector); if (!container) return; const component = app._component; if (!isFunction$2(component) && !component.render && !component.template) component.template = container.innerHTML; if (container.nodeType === 1) container.textContent = ""; const proxy = mount(container, false, resolveRootNamespace(container)); if (container instanceof Element) { container.removeAttribute("v-cloak"); container.setAttribute("data-v-app", ""); } return proxy; }; return app; }); var createSSRApp = ((...args) => { const app = ensureHydrationRenderer().createApp(...args); const { mount } = app; app.mount = (containerOrSelector) => { const container = normalizeContainer(containerOrSelector); if (container) return mount(container, true, resolveRootNamespace(container)); }; return app; }); function resolveRootNamespace(container) { if (container instanceof SVGElement) return "svg"; if (typeof MathMLElement === "function" && container instanceof MathMLElement) return "mathml"; } function normalizeContainer(container) { if (isString(container)) return document.querySelector(container); return container; } var ssrDirectiveInitialized = false; var initDirectivesForSSR = () => { if (!ssrDirectiveInitialized) { ssrDirectiveInitialized = true; initVModelForSSR(); initVShowForSSR(); } }; //#endregion //#region ../../node_modules/.pnpm/vue@3.5.33_typescript@5.9.3/node_modules/vue/dist/vue.runtime.esm-bundler.js var vue_runtime_esm_bundler_exports = /* @__PURE__ */ __exportAll({ BaseTransition: () => BaseTransition, BaseTransitionPropsValidators: () => BaseTransitionPropsValidators, Comment: () => Comment, DeprecationTypes: () => null, EffectScope: () => EffectScope, ErrorCodes: () => ErrorCodes, ErrorTypeStrings: () => ErrorTypeStrings, Fragment: () => Fragment, KeepAlive: () => KeepAlive, ReactiveEffect: () => ReactiveEffect, Static: () => Static, Suspense: () => Suspense, Teleport: () => Teleport, Text: () => Text, TrackOpTypes: () => TrackOpTypes, Transition: () => Transition, TransitionGroup: () => TransitionGroup, TriggerOpTypes: () => TriggerOpTypes, VueElement: () => VueElement, assertNumber: () => assertNumber, callWithAsyncErrorHandling: () => callWithAsyncErrorHandling, callWithErrorHandling: () => callWithErrorHandling, camelize: () => camelize$2, capitalize: () => capitalize, cloneVNode: () => cloneVNode, compatUtils: () => null, compile: () => compile, computed: () => computed, createApp: () => createApp, createBlock: () => createBlock, createCommentVNode: () => createCommentVNode, createElementBlock: () => createElementBlock, createElementVNode: () => createBaseVNode, createHydrationRenderer: () => createHydrationRenderer, createPropsRestProxy: () => createPropsRestProxy, createRenderer: () => createRenderer, createSSRApp: () => createSSRApp, createSlots: () => createSlots, createStaticVNode: () => createStaticVNode, createTextVNode: () => createTextVNode, createVNode: () => createVNode, customRef: () => customRef, defineAsyncComponent: () => defineAsyncComponent, defineComponent: () => defineComponent, defineCustomElement: () => defineCustomElement, defineEmits: () => defineEmits, defineExpose: () => defineExpose, defineModel: () => defineModel, defineOptions: () => defineOptions, defineProps: () => defineProps, defineSSRCustomElement: () => defineSSRCustomElement, defineSlots: () => defineSlots, devtools: () => devtools, effect: () => effect, effectScope: () => effectScope, getCurrentInstance: () => getCurrentInstance, getCurrentScope: () => getCurrentScope$1, getCurrentWatcher: () => getCurrentWatcher, getTransitionRawChildren: () => getTransitionRawChildren, guardReactiveProps: () => guardReactiveProps, h: () => h$2, handleError: () => handleError, hasInjectionContext: () => hasInjectionContext, hydrate: () => hydrate, hydrateOnIdle: () => hydrateOnIdle, hydrateOnInteraction: () => hydrateOnInteraction, hydrateOnMediaQuery: () => hydrateOnMediaQuery, hydrateOnVisible: () => hydrateOnVisible, initCustomFormatter: () => initCustomFormatter, initDirectivesForSSR: () => initDirectivesForSSR, inject: () => inject, isMemoSame: () => isMemoSame, isProxy: () => isProxy, isReactive: () => isReactive, isReadonly: () => isReadonly, isRef: () => isRef, isRuntimeOnly: () => isRuntimeOnly, isShallow: () => isShallow, isVNode: () => isVNode, markRaw: () => markRaw, mergeDefaults: () => mergeDefaults, mergeModels: () => mergeModels, mergeProps: () => mergeProps, nextTick: () => nextTick, nodeOps: () => nodeOps, normalizeClass: () => normalizeClass, normalizeProps: () => normalizeProps, normalizeStyle: () => normalizeStyle, onActivated: () => onActivated, onBeforeMount: () => onBeforeMount, onBeforeUnmount: () => onBeforeUnmount, onBeforeUpdate: () => onBeforeUpdate, onDeactivated: () => onDeactivated, onErrorCaptured: () => onErrorCaptured, onMounted: () => onMounted, onRenderTracked: () => onRenderTracked, onRenderTriggered: () => onRenderTriggered, onScopeDispose: () => onScopeDispose, onServerPrefetch: () => onServerPrefetch, onUnmounted: () => onUnmounted, onUpdated: () => onUpdated, onWatcherCleanup: () => onWatcherCleanup, openBlock: () => openBlock, patchProp: () => patchProp, popScopeId: () => popScopeId, provide: () => provide, proxyRefs: () => proxyRefs, pushScopeId: () => pushScopeId, queuePostFlushCb: () => queuePostFlushCb, reactive: () => reactive, readonly: () => readonly, ref: () => ref, registerRuntimeCompiler: () => registerRuntimeCompiler, render: () => render, renderList: () => renderList, renderSlot: () => renderSlot, resolveComponent: () => resolveComponent, resolveDirective: () => resolveDirective, resolveDynamicComponent: () => resolveDynamicComponent, resolveFilter: () => null, resolveTransitionHooks: () => resolveTransitionHooks, setBlockTracking: () => setBlockTracking, setDevtoolsHook: () => setDevtoolsHook, setTransitionHooks: () => setTransitionHooks, shallowReactive: () => shallowReactive, shallowReadonly: () => shallowReadonly, shallowRef: () => shallowRef, ssrContextKey: () => ssrContextKey, ssrUtils: () => ssrUtils, stop: () => stop, toDisplayString: () => toDisplayString, toHandlerKey: () => toHandlerKey, toHandlers: () => toHandlers, toRaw: () => toRaw, toRef: () => toRef, toRefs: () => toRefs, toValue: () => toValue$1, transformVNodeArgs: () => transformVNodeArgs, triggerRef: () => triggerRef, unref: () => unref, useAttrs: () => useAttrs, useCssModule: () => useCssModule, useCssVars: () => useCssVars, useHost: () => useHost, useId: () => useId, useModel: () => useModel, useSSRContext: () => useSSRContext, useShadowRoot: () => useShadowRoot, useSlots: () => useSlots, useTemplateRef: () => useTemplateRef, useTransitionState: () => useTransitionState, vModelCheckbox: () => vModelCheckbox, vModelDynamic: () => vModelDynamic, vModelRadio: () => vModelRadio, vModelSelect: () => vModelSelect, vModelText: () => vModelText, vShow: () => vShow, version: () => version, warn: () => warn, watch: () => watch, watchEffect: () => watchEffect, watchPostEffect: () => watchPostEffect, watchSyncEffect: () => watchSyncEffect, withAsyncContext: () => withAsyncContext, withCtx: () => withCtx, withDefaults: () => withDefaults, withDirectives: () => withDirectives, withKeys: () => withKeys, withMemo: () => withMemo, withModifiers: () => withModifiers, withScopeId: () => withScopeId }); /** * vue v3.5.33 * (c) 2018-present Yuxi (Evan) You and Vue contributors * @license MIT **/ var compile = () => {}; //#endregion //#region ../../node_modules/.pnpm/@tanstack+vue-query@5.100.6_vue@3.5.33_typescript@5.9.3_/node_modules/@tanstack/vue-query/build/modern/utils.js var VUE_QUERY_CLIENT = "VUE_QUERY_CLIENT"; function getClientKey(key) { return `${VUE_QUERY_CLIENT}${key ? `:${key}` : ""}`; } function updateState(state, update) { Object.keys(state).forEach((key) => { state[key] = update[key]; }); } function _cloneDeep(value, customize, currentKey = "", currentLevel = 0) { if (customize) { const result = customize(value, currentKey, currentLevel); if (result === void 0 && /* @__PURE__ */ isRef(value)) return result; if (result !== void 0) return result; } if (Array.isArray(value)) return value.map((val, index) => _cloneDeep(val, customize, String(index), currentLevel + 1)); if (typeof value === "object" && isPlainObject$2(value)) { const entries = Object.entries(value).map(([key, val]) => [key, _cloneDeep(val, customize, key, currentLevel + 1)]); return Object.fromEntries(entries); } return value; } function cloneDeep(value, customize) { return _cloneDeep(value, customize); } function cloneDeepUnref(obj, unrefGetters = false) { return cloneDeep(obj, (val, key, level) => { if (level === 1 && key === "queryKey") return cloneDeepUnref(val, true); if (unrefGetters && isFunction$1(val)) return cloneDeepUnref(val(), unrefGetters); if (/* @__PURE__ */ isRef(val)) return cloneDeepUnref(unref(val), unrefGetters); }); } function isPlainObject$2(value) { if (Object.prototype.toString.call(value) !== "[object Object]") return false; const prototype = Object.getPrototypeOf(value); return prototype === null || prototype === Object.prototype; } function isFunction$1(value) { return typeof value === "function"; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+vue-query@5.100.6_vue@3.5.33_typescript@5.9.3_/node_modules/@tanstack/vue-query/build/modern/useQueryClient.js function useQueryClient(id = "") { if (!hasInjectionContext()) throw new Error("vue-query hooks can only be used inside setup() function or functions that support injection context."); const queryClient = inject(getClientKey(id)); if (!queryClient) throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library."); return queryClient; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+vue-query@5.100.6_vue@3.5.33_typescript@5.9.3_/node_modules/@tanstack/vue-query/build/modern/queryCache.js var QueryCache = class extends QueryCache$1 { find(filters) { return super.find(cloneDeepUnref(filters)); } findAll(filters = {}) { return super.findAll(cloneDeepUnref(filters)); } }; //#endregion //#region ../../node_modules/.pnpm/@tanstack+vue-query@5.100.6_vue@3.5.33_typescript@5.9.3_/node_modules/@tanstack/vue-query/build/modern/mutationCache.js var MutationCache = class extends MutationCache$1 { find(filters) { return super.find(cloneDeepUnref(filters)); } findAll(filters = {}) { return super.findAll(cloneDeepUnref(filters)); } }; //#endregion //#region ../../node_modules/.pnpm/@tanstack+vue-query@5.100.6_vue@3.5.33_typescript@5.9.3_/node_modules/@tanstack/vue-query/build/modern/queryClient.js var QueryClient = class extends QueryClient$1 { constructor(config = {}) { const vueQueryConfig = { defaultOptions: config.defaultOptions, queryCache: config.queryCache || new QueryCache(), mutationCache: config.mutationCache || new MutationCache() }; super(vueQueryConfig); this.isRestoring = /* @__PURE__ */ ref(false); } isFetching(filters = {}) { return super.isFetching(cloneDeepUnref(filters)); } isMutating(filters = {}) { return super.isMutating(cloneDeepUnref(filters)); } getQueryData(queryKey) { return super.getQueryData(cloneDeepUnref(queryKey)); } ensureQueryData(options) { return super.ensureQueryData(cloneDeepUnref(options)); } getQueriesData(filters) { return super.getQueriesData(cloneDeepUnref(filters)); } setQueryData(queryKey, updater, options = {}) { return super.setQueryData(cloneDeepUnref(queryKey), updater, cloneDeepUnref(options)); } setQueriesData(filters, updater, options = {}) { return super.setQueriesData(cloneDeepUnref(filters), updater, cloneDeepUnref(options)); } getQueryState(queryKey) { return super.getQueryState(cloneDeepUnref(queryKey)); } removeQueries(filters = {}) { return super.removeQueries(cloneDeepUnref(filters)); } resetQueries(filters = {}, options = {}) { return super.resetQueries(cloneDeepUnref(filters), cloneDeepUnref(options)); } cancelQueries(filters = {}, options = {}) { return super.cancelQueries(cloneDeepUnref(filters), cloneDeepUnref(options)); } invalidateQueries(filters = {}, options = {}) { const filtersCloned = cloneDeepUnref(filters); const optionsCloned = cloneDeepUnref(options); super.invalidateQueries({ ...filtersCloned, refetchType: "none" }, optionsCloned); if (filtersCloned.refetchType === "none") return Promise.resolve(); const refetchFilters = { ...filtersCloned, type: filtersCloned.refetchType ?? filtersCloned.type ?? "active" }; return nextTick().then(() => { return super.refetchQueries(refetchFilters, optionsCloned); }); } refetchQueries(filters = {}, options = {}) { return super.refetchQueries(cloneDeepUnref(filters), cloneDeepUnref(options)); } fetchQuery(options) { return super.fetchQuery(cloneDeepUnref(options)); } prefetchQuery(options) { return super.prefetchQuery(cloneDeepUnref(options)); } fetchInfiniteQuery(options) { return super.fetchInfiniteQuery(cloneDeepUnref(options)); } prefetchInfiniteQuery(options) { return super.prefetchInfiniteQuery(cloneDeepUnref(options)); } setDefaultOptions(options) { super.setDefaultOptions(cloneDeepUnref(options)); } setQueryDefaults(queryKey, options) { super.setQueryDefaults(cloneDeepUnref(queryKey), cloneDeepUnref(options)); } getQueryDefaults(queryKey) { return super.getQueryDefaults(cloneDeepUnref(queryKey)); } setMutationDefaults(mutationKey, options) { super.setMutationDefaults(cloneDeepUnref(mutationKey), cloneDeepUnref(options)); } getMutationDefaults(mutationKey) { return super.getMutationDefaults(cloneDeepUnref(mutationKey)); } }; //#endregion //#region ../../node_modules/.pnpm/@tanstack+vue-query@5.100.6_vue@3.5.33_typescript@5.9.3_/node_modules/@tanstack/vue-query/build/modern/vueQueryPlugin.js var VueQueryPlugin = { install: (app, options = {}) => { const clientKey = getClientKey(options.queryClientKey); let client; if ("queryClient" in options && options.queryClient) client = options.queryClient; else client = new QueryClient("queryClientConfig" in options ? options.queryClientConfig : void 0); if (!isServer) client.mount(); let persisterUnmount = () => {}; if (options.clientPersister) { if (client.isRestoring) client.isRestoring.value = true; const [unmount, promise] = options.clientPersister(client); persisterUnmount = unmount; promise.then(() => { if (client.isRestoring) client.isRestoring.value = false; options.clientPersisterOnSuccess?.(client); }); } const cleanup = () => { client.unmount(); persisterUnmount(); }; if (app.onUnmount) app.onUnmount(cleanup); else { const originalUnmount = app.unmount; app.unmount = function vueQueryUnmount() { cleanup(); originalUnmount(); }; } app.provide(clientKey, client); } }; //#endregion //#region ../../node_modules/.pnpm/@tanstack+vue-query@5.100.6_vue@3.5.33_typescript@5.9.3_/node_modules/@tanstack/vue-query/build/modern/useBaseQuery.js function useBaseQuery(Observer, options, queryClient) { const client = queryClient || useQueryClient(); const defaultedOptions = computed(() => { let resolvedOptions = options; if (typeof resolvedOptions === "function") resolvedOptions = resolvedOptions(); const clonedOptions = cloneDeepUnref(resolvedOptions); if (typeof clonedOptions.enabled === "function") clonedOptions.enabled = clonedOptions.enabled(); const defaulted = client.defaultQueryOptions(clonedOptions); defaulted._optimisticResults = client.isRestoring?.value ? "isRestoring" : "optimistic"; return defaulted; }); const observer = new Observer(client, defaultedOptions.value); const state = defaultedOptions.value.shallow ? /* @__PURE__ */ shallowReactive(observer.getCurrentResult()) : /* @__PURE__ */ reactive(observer.getCurrentResult()); let unsubscribe = () => {}; if (client.isRestoring) watch(client.isRestoring, (isRestoring) => { if (!isRestoring) { unsubscribe(); unsubscribe = observer.subscribe((result) => { updateState(state, result); }); } }, { immediate: true }); const updater = () => { observer.setOptions(defaultedOptions.value); updateState(state, observer.getCurrentResult()); }; watch(defaultedOptions, updater); onScopeDispose(() => { unsubscribe(); }); const refetch = (...args) => { updater(); return state.refetch(...args); }; const suspense = () => { return new Promise((resolve, reject) => { let stopWatch = () => {}; const run = () => { if (defaultedOptions.value.enabled !== false) { observer.setOptions(defaultedOptions.value); const optimisticResult = observer.getOptimisticResult(defaultedOptions.value); if (optimisticResult.isStale) { stopWatch(); observer.fetchOptimistic(defaultedOptions.value).then(resolve, (error) => { if (shouldThrowError(defaultedOptions.value.throwOnError, [error, observer.getCurrentQuery()])) reject(error); else resolve(observer.getCurrentResult()); }); } else { stopWatch(); resolve(optimisticResult); } } }; run(); stopWatch = watch(defaultedOptions, run); }); }; watch(() => state.error, (error) => { if (state.isError && !state.isFetching && shouldThrowError(defaultedOptions.value.throwOnError, [error, observer.getCurrentQuery()])) throw error; }); const object = /* @__PURE__ */ toRefs(defaultedOptions.value.shallow ? /* @__PURE__ */ shallowReadonly(state) : /* @__PURE__ */ readonly(state)); for (const key in state) if (typeof state[key] === "function") object[key] = state[key]; object.suspense = suspense; object.refetch = refetch; return object; } //#endregion //#region ../../node_modules/.pnpm/@tanstack+vue-query@5.100.6_vue@3.5.33_typescript@5.9.3_/node_modules/@tanstack/vue-query/build/modern/useQuery.js function useQuery(options, queryClient) { return useBaseQuery(QueryObserver, options, queryClient); } //#endregion //#region ../../node_modules/.pnpm/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs /** * Custom positioning reference element. * @see https://floating-ui.com/docs/virtual-elements */ var sides = [ "top", "right", "bottom", "left" ]; var alignments = ["start", "end"]; var placements = /*#__PURE__*/ sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []); var min = Math.min; var max = Math.max; var oppositeSideMap = { left: "right", right: "left", bottom: "top", top: "bottom" }; function clamp(start, value, end) { return max(start, min(value, end)); } function evaluate(value, param) { return typeof value === "function" ? value(param) : value; } function getSide(placement) { return placement.split("-")[0]; } function getAlignment(placement) { return placement.split("-")[1]; } function getOppositeAxis(axis) { return axis === "x" ? "y" : "x"; } function getAxisLength(axis) { return axis === "y" ? "height" : "width"; } function getSideAxis(placement) { const firstChar = placement[0]; return firstChar === "t" || firstChar === "b" ? "y" : "x"; } function getAlignmentAxis(placement) { return getOppositeAxis(getSideAxis(placement)); } function getAlignmentSides(placement, rects, rtl) { if (rtl === void 0) rtl = false; const alignment = getAlignment(placement); const alignmentAxis = getAlignmentAxis(placement); const length = getAxisLength(alignmentAxis); let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top"; if (rects.reference[length] > rects.floating[length]) mainAlignmentSide = getOppositePlacement(mainAlignmentSide); return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)]; } function getExpandedPlacements(placement) { const oppositePlacement = getOppositePlacement(placement); return [ getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement) ]; } function getOppositeAlignmentPlacement(placement) { return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start"); } var lrPlacement = ["left", "right"]; var rlPlacement = ["right", "left"]; var tbPlacement = ["top", "bottom"]; var btPlacement = ["bottom", "top"]; function getSideList(side, isStart, rtl) { switch (side) { case "top": case "bottom": if (rtl) return isStart ? rlPlacement : lrPlacement; return isStart ? lrPlacement : rlPlacement; case "left": case "right": return isStart ? tbPlacement : btPlacement; default: return []; } } function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) { const alignment = getAlignment(placement); let list = getSideList(getSide(placement), direction === "start", rtl); if (alignment) { list = list.map((side) => side + "-" + alignment); if (flipAlignment) list = list.concat(list.map(getOppositeAlignmentPlacement)); } return list; } function getOppositePlacement(placement) { const side = getSide(placement); return oppositeSideMap[side] + placement.slice(side.length); } function expandPaddingObject(padding) { return { top: 0, right: 0, bottom: 0, left: 0, ...padding }; } function getPaddingObject(padding) { return typeof padding !== "number" ? expandPaddingObject(padding) : { top: padding, right: padding, bottom: padding, left: padding }; } function rectToClientRect(rect) { const { x, y, width, height } = rect; return { width, height, top: y, left: x, right: x + width, bottom: y + height, x, y }; } //#endregion //#region ../../node_modules/.pnpm/@floating-ui+core@1.7.5/node_modules/@floating-ui/core/dist/floating-ui.core.mjs function computeCoordsFromPlacement(_ref, placement, rtl) { let { reference, floating } = _ref; const sideAxis = getSideAxis(placement); const alignmentAxis = getAlignmentAxis(placement); const alignLength = getAxisLength(alignmentAxis); const side = getSide(placement); const isVertical = sideAxis === "y"; const commonX = reference.x + reference.width / 2 - floating.width / 2; const commonY = reference.y + reference.height / 2 - floating.height / 2; const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2; let coords; switch (side) { case "top": coords = { x: commonX, y: reference.y - floating.height }; break; case "bottom": coords = { x: commonX, y: reference.y + reference.height }; break; case "right": coords = { x: reference.x + reference.width, y: commonY }; break; case "left": coords = { x: reference.x - floating.width, y: commonY }; break; default: coords = { x: reference.x, y: reference.y }; } switch (getAlignment(placement)) { case "start": coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1); break; case "end": coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1); break; } return coords; } /** * Resolves with an object of overflow side offsets that determine how much the * element is overflowing a given clipping boundary on each side. * - positive = overflowing the boundary by that number of pixels * - negative = how many pixels left before it will overflow * - 0 = lies flush with the boundary * @see https://floating-ui.com/docs/detectOverflow */ async function detectOverflow(state, options) { var _await$platform$isEle; if (options === void 0) options = {}; const { x, y, platform, rects, elements, strategy } = state; const { boundary = "clippingAncestors", rootBoundary = "viewport", elementContext = "floating", altBoundary = false, padding = 0 } = evaluate(options, state); const paddingObject = getPaddingObject(padding); const element = elements[altBoundary ? elementContext === "floating" ? "reference" : "floating" : elementContext]; const clippingClientRect = rectToClientRect(await platform.getClippingRect({ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)), boundary, rootBoundary, strategy })); const rect = elementContext === "floating" ? { x, y, width: rects.floating.width, height: rects.floating.height } : rects.reference; const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)); const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || { x: 1, y: 1 } : { x: 1, y: 1 }; const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({ elements, rect, offsetParent, strategy }) : rect); return { top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y, bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y, left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x, right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x }; } var MAX_RESET_COUNT = 50; /** * Computes the `x` and `y` coordinates that will place the floating element * next to a given reference element. * * This export does not have any `platform` interface logic. You will need to * write one for the platform you are using Floating UI with. */ var computePosition = async (reference, floating, config) => { const { placement = "bottom", strategy = "absolute", middleware = [], platform } = config; const platformWithDetectOverflow = platform.detectOverflow ? platform : { ...platform, detectOverflow }; const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating)); let rects = await platform.getElementRects({ reference, floating, strategy }); let { x, y } = computeCoordsFromPlacement(rects, placement, rtl); let statefulPlacement = placement; let resetCount = 0; const middlewareData = {}; for (let i = 0; i < middleware.length; i++) { const currentMiddleware = middleware[i]; if (!currentMiddleware) continue; const { name, fn } = currentMiddleware; const { x: nextX, y: nextY, data, reset } = await fn({ x, y, initialPlacement: placement, placement: statefulPlacement, strategy, middlewareData, rects, platform: platformWithDetectOverflow, elements: { reference, floating } }); x = nextX != null ? nextX : x; y = nextY != null ? nextY : y; middlewareData[name] = { ...middlewareData[name], ...data }; if (reset && resetCount < MAX_RESET_COUNT) { resetCount++; if (typeof reset === "object") { if (reset.placement) statefulPlacement = reset.placement; if (reset.rects) rects = reset.rects === true ? await platform.getElementRects({ reference, floating, strategy }) : reset.rects; ({x, y} = computeCoordsFromPlacement(rects, statefulPlacement, rtl)); } i = -1; } } return { x, y, placement: statefulPlacement, strategy, middlewareData }; }; /** * Provides data to position an inner element of the floating element so that it * appears centered to the reference element. * @see https://floating-ui.com/docs/arrow */ var arrow = (options) => ({ name: "arrow", options, async fn(state) { const { x, y, placement, rects, platform, elements, middlewareData } = state; const { element, padding = 0 } = evaluate(options, state) || {}; if (element == null) return {}; const paddingObject = getPaddingObject(padding); const coords = { x, y }; const axis = getAlignmentAxis(placement); const length = getAxisLength(axis); const arrowDimensions = await platform.getDimensions(element); const isYAxis = axis === "y"; const minProp = isYAxis ? "top" : "left"; const maxProp = isYAxis ? "bottom" : "right"; const clientProp = isYAxis ? "clientHeight" : "clientWidth"; const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length]; const startDiff = coords[axis] - rects.reference[axis]; const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element)); let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0; if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) clientSize = elements.floating[clientProp] || rects.floating[length]; const centerToReference = endDiff / 2 - startDiff / 2; const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1; const minPadding = min(paddingObject[minProp], largestPossiblePadding); const maxPadding = min(paddingObject[maxProp], largestPossiblePadding); const min$1 = minPadding; const max = clientSize - arrowDimensions[length] - maxPadding; const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference; const offset = clamp(min$1, center, max); const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0; const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0; return { [axis]: coords[axis] + alignmentOffset, data: { [axis]: offset, centerOffset: center - offset - alignmentOffset, ...shouldAddOffset && { alignmentOffset } }, reset: shouldAddOffset }; } }); function getPlacementList(alignment, autoAlignment, allowedPlacements) { return (alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement)).filter((placement) => { if (alignment) return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false); return true; }); } /** * Optimizes the visibility of the floating element by choosing the placement * that has the most space available automatically, without needing to specify a * preferred placement. Alternative to `flip`. * @see https://floating-ui.com/docs/autoPlacement */ var autoPlacement = function(options) { if (options === void 0) options = {}; return { name: "autoPlacement", options, async fn(state) { var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE; const { rects, middlewareData, placement, platform, elements } = state; const { crossAxis = false, alignment, allowedPlacements = placements, autoAlignment = true, ...detectOverflowOptions } = evaluate(options, state); const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements; const overflow = await platform.detectOverflow(state, detectOverflowOptions); const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0; const currentPlacement = placements$1[currentIndex]; if (currentPlacement == null) return {}; const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))); if (placement !== currentPlacement) return { reset: { placement: placements$1[0] } }; const currentOverflows = [ overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]] ]; const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], { placement: currentPlacement, overflows: currentOverflows }]; const nextPlacement = placements$1[currentIndex + 1]; if (nextPlacement) return { data: { index: currentIndex + 1, overflows: allOverflows }, reset: { placement: nextPlacement } }; const placementsSortedByMostSpace = allOverflows.map((d) => { const alignment = getAlignment(d.placement); return [ d.placement, alignment && crossAxis ? d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) : d.overflows[0], d.overflows ]; }).sort((a, b) => a[1] - b[1]); const resetPlacement = ((_placementsThatFitOnE = placementsSortedByMostSpace.filter((d) => d[2].slice(0, getAlignment(d[0]) ? 2 : 3).every((v) => v <= 0))[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0]; if (resetPlacement !== placement) return { data: { index: currentIndex + 1, overflows: allOverflows }, reset: { placement: resetPlacement } }; return {}; } }; }; /** * Optimizes the visibility of the floating element by flipping the `placement` * in order to keep it in view when the preferred placement(s) will overflow the * clipping boundary. Alternative to `autoPlacement`. * @see https://floating-ui.com/docs/flip */ var flip = function(options) { if (options === void 0) options = {}; return { name: "flip", options, async fn(state) { var _middlewareData$arrow, _middlewareData$flip; const { placement, middlewareData, rects, initialPlacement, platform, elements } = state; const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = true, fallbackPlacements: specifiedFallbackPlacements, fallbackStrategy = "bestFit", fallbackAxisSideDirection = "none", flipAlignment = true, ...detectOverflowOptions } = evaluate(options, state); if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {}; const side = getSide(placement); const initialSideAxis = getSideAxis(initialPlacement); const isBasePlacement = getSide(initialPlacement) === initialPlacement; const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement)); const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none"; if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl)); const placements = [initialPlacement, ...fallbackPlacements]; const overflow = await platform.detectOverflow(state, detectOverflowOptions); const overflows = []; let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || []; if (checkMainAxis) overflows.push(overflow[side]); if (checkCrossAxis) { const sides = getAlignmentSides(placement, rects, rtl); overflows.push(overflow[sides[0]], overflow[sides[1]]); } overflowsData = [...overflowsData, { placement, overflows }]; if (!overflows.every((side) => side <= 0)) { var _middlewareData$flip2, _overflowsData$filter; const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1; const nextPlacement = placements[nextIndex]; if (nextPlacement) { if (!(checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false) || overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) return { data: { index: nextIndex, overflows: overflowsData }, reset: { placement: nextPlacement } }; } let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement; if (!resetPlacement) switch (fallbackStrategy) { case "bestFit": { var _overflowsData$filter2; const placement = (_overflowsData$filter2 = overflowsData.filter((d) => { if (hasFallbackAxisSideDirection) { const currentSideAxis = getSideAxis(d.placement); return currentSideAxis === initialSideAxis || currentSideAxis === "y"; } return true; }).map((d) => [d.placement, d.overflows.filter((overflow) => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0]; if (placement) resetPlacement = placement; break; } case "initialPlacement": resetPlacement = initialPlacement; break; } if (placement !== resetPlacement) return { reset: { placement: resetPlacement } }; } return {}; } }; }; var originSides = /*#__PURE__*/ new Set(["left", "top"]); async function convertValueToCoords(state, options) { const { placement, platform, elements } = state; const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)); const side = getSide(placement); const alignment = getAlignment(placement); const isVertical = getSideAxis(placement) === "y"; const mainAxisMulti = originSides.has(side) ? -1 : 1; const crossAxisMulti = rtl && isVertical ? -1 : 1; const rawValue = evaluate(options, state); let { mainAxis, crossAxis, alignmentAxis } = typeof rawValue === "number" ? { mainAxis: rawValue, crossAxis: 0, alignmentAxis: null } : { mainAxis: rawValue.mainAxis || 0, crossAxis: rawValue.crossAxis || 0, alignmentAxis: rawValue.alignmentAxis }; if (alignment && typeof alignmentAxis === "number") crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis; return isVertical ? { x: crossAxis * crossAxisMulti, y: mainAxis * mainAxisMulti } : { x: mainAxis * mainAxisMulti, y: crossAxis * crossAxisMulti }; } /** * Modifies the placement by translating the floating element along the * specified axes. * A number (shorthand for `mainAxis` or distance), or an axes configuration * object may be passed. * @see https://floating-ui.com/docs/offset */ var offset = function(options) { if (options === void 0) options = 0; return { name: "offset", options, async fn(state) { var _middlewareData$offse, _middlewareData$arrow; const { x, y, placement, middlewareData } = state; const diffCoords = await convertValueToCoords(state, options); if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) return {}; return { x: x + diffCoords.x, y: y + diffCoords.y, data: { ...diffCoords, placement } }; } }; }; /** * Optimizes the visibility of the floating element by shifting it in order to * keep it in view when it will overflow the clipping boundary. * @see https://floating-ui.com/docs/shift */ var shift = function(options) { if (options === void 0) options = {}; return { name: "shift", options, async fn(state) { const { x, y, placement, platform } = state; const { mainAxis: checkMainAxis = true, crossAxis: checkCrossAxis = false, limiter = { fn: (_ref) => { let { x, y } = _ref; return { x, y }; } }, ...detectOverflowOptions } = evaluate(options, state); const coords = { x, y }; const overflow = await platform.detectOverflow(state, detectOverflowOptions); const crossAxis = getSideAxis(getSide(placement)); const mainAxis = getOppositeAxis(crossAxis); let mainAxisCoord = coords[mainAxis]; let crossAxisCoord = coords[crossAxis]; if (checkMainAxis) { const minSide = mainAxis === "y" ? "top" : "left"; const maxSide = mainAxis === "y" ? "bottom" : "right"; const min = mainAxisCoord + overflow[minSide]; const max = mainAxisCoord - overflow[maxSide]; mainAxisCoord = clamp(min, mainAxisCoord, max); } if (checkCrossAxis) { const minSide = crossAxis === "y" ? "top" : "left"; const maxSide = crossAxis === "y" ? "bottom" : "right"; const min = crossAxisCoord + overflow[minSide]; const max = crossAxisCoord - overflow[maxSide]; crossAxisCoord = clamp(min, crossAxisCoord, max); } const limitedCoords = limiter.fn({ ...state, [mainAxis]: mainAxisCoord, [crossAxis]: crossAxisCoord }); return { ...limitedCoords, data: { x: limitedCoords.x - x, y: limitedCoords.y - y, enabled: { [mainAxis]: checkMainAxis, [crossAxis]: checkCrossAxis } } }; } }; }; /** * Provides data that allows you to change the size of the floating element — * for instance, prevent it from overflowing the clipping boundary or match the * width of the reference element. * @see https://floating-ui.com/docs/size */ var size = function(options) { if (options === void 0) options = {}; return { name: "size", options, async fn(state) { var _state$middlewareData, _state$middlewareData2; const { placement, rects, platform, elements } = state; const { apply = () => {}, ...detectOverflowOptions } = evaluate(options, state); const overflow = await platform.detectOverflow(state, detectOverflowOptions); const side = getSide(placement); const alignment = getAlignment(placement); const isYAxis = getSideAxis(placement) === "y"; const { width, height } = rects.floating; let heightSide; let widthSide; if (side === "top" || side === "bottom") { heightSide = side; widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right"; } else { widthSide = side; heightSide = alignment === "end" ? "top" : "bottom"; } const maximumClippingHeight = height - overflow.top - overflow.bottom; const maximumClippingWidth = width - overflow.left - overflow.right; const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight); const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth); const noShift = !state.middlewareData.shift; let availableHeight = overflowAvailableHeight; let availableWidth = overflowAvailableWidth; if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) availableWidth = maximumClippingWidth; if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) availableHeight = maximumClippingHeight; if (noShift && !alignment) { const xMin = max(overflow.left, 0); const xMax = max(overflow.right, 0); const yMin = max(overflow.top, 0); const yMax = max(overflow.bottom, 0); if (isYAxis) availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)); else availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)); } await apply({ ...state, availableWidth, availableHeight }); const nextDimensions = await platform.getDimensions(elements.floating); if (width !== nextDimensions.width || height !== nextDimensions.height) return { reset: { rects: true } }; return {}; } }; }; //#endregion //#region ../../node_modules/.pnpm/@floating-ui+dom@1.1.1/node_modules/@floating-ui/dom/dist/floating-ui.dom.browser.min.mjs function n$1(t) { var e; return (null == (e = t.ownerDocument) ? void 0 : e.defaultView) || window; } function o(t) { return n$1(t).getComputedStyle(t); } var i = Math.min, r = Math.max, l = Math.round; function c$1(t) { const e = o(t); let n = parseFloat(e.width), i = parseFloat(e.height); const r = t.offsetWidth, c = t.offsetHeight, s = l(n) !== r || l(i) !== c; return s && (n = r, i = c), { width: n, height: i, fallback: s }; } function s(t) { return h$1(t) ? (t.nodeName || "").toLowerCase() : ""; } var f; function u() { if (f) return f; const t = navigator.userAgentData; return t && Array.isArray(t.brands) ? (f = t.brands.map(((t) => t.brand + "/" + t.version)).join(" "), f) : navigator.userAgent; } function a(t) { return t instanceof n$1(t).HTMLElement; } function d$1(t) { return t instanceof n$1(t).Element; } function h$1(t) { return t instanceof n$1(t).Node; } function p(t) { if ("undefined" == typeof ShadowRoot) return !1; return t instanceof n$1(t).ShadowRoot || t instanceof ShadowRoot; } function g$1(t) { const { overflow: e, overflowX: n, overflowY: i, display: r } = o(t); return /auto|scroll|overlay|hidden|clip/.test(e + i + n) && !["inline", "contents"].includes(r); } function m$1(t) { return [ "table", "td", "th" ].includes(s(t)); } function y$1(t) { const e = /firefox/i.test(u()), n = o(t), i = n.backdropFilter || n.WebkitBackdropFilter; return "none" !== n.transform || "none" !== n.perspective || !!i && "none" !== i || e && "filter" === n.willChange || e && !!n.filter && "none" !== n.filter || ["transform", "perspective"].some(((t) => n.willChange.includes(t))) || [ "paint", "layout", "strict", "content" ].some(((t) => { const e = n.contain; return null != e && e.includes(t); })); } function x$1() { return !/^((?!chrome|android).)*safari/i.test(u()); } function w(t) { return [ "html", "body", "#document" ].includes(s(t)); } function v(t) { return d$1(t) ? t : t.contextElement; } var b$1 = { x: 1, y: 1 }; function L(t) { const e = v(t); if (!a(e)) return b$1; const n = e.getBoundingClientRect(), { width: o, height: i, fallback: r } = c$1(e); let s = (r ? l(n.width) : n.width) / o, f = (r ? l(n.height) : n.height) / i; return s && Number.isFinite(s) || (s = 1), f && Number.isFinite(f) || (f = 1), { x: s, y: f }; } function E$1(t, e, o, i) { var r, l; void 0 === e && (e = !1), void 0 === o && (o = !1); const c = t.getBoundingClientRect(), s = v(t); let f = b$1; e && (i ? d$1(i) && (f = L(i)) : f = L(t)); const u = s ? n$1(s) : window, a = !x$1() && o; let h = (c.left + (a && (null == (r = u.visualViewport) ? void 0 : r.offsetLeft) || 0)) / f.x, p = (c.top + (a && (null == (l = u.visualViewport) ? void 0 : l.offsetTop) || 0)) / f.y, g = c.width / f.x, m = c.height / f.y; if (s) { const t = n$1(s), e = i && d$1(i) ? n$1(i) : i; let o = t.frameElement; for (; o && i && e !== t;) { const t = L(o), e = o.getBoundingClientRect(), i = getComputedStyle(o); e.x += (o.clientLeft + parseFloat(i.paddingLeft)) * t.x, e.y += (o.clientTop + parseFloat(i.paddingTop)) * t.y, h *= t.x, p *= t.y, g *= t.x, m *= t.y, h += e.x, p += e.y, o = n$1(o).frameElement; } } return { width: g, height: m, top: p, right: h + g, bottom: p + m, left: h, x: h, y: p }; } function R$1(t) { return ((h$1(t) ? t.ownerDocument : t.document) || window.document).documentElement; } function T(t) { return d$1(t) ? { scrollLeft: t.scrollLeft, scrollTop: t.scrollTop } : { scrollLeft: t.pageXOffset, scrollTop: t.pageYOffset }; } function C$1(t) { return E$1(R$1(t)).left + T(t).scrollLeft; } function F(t) { if ("html" === s(t)) return t; const e = t.assignedSlot || t.parentNode || p(t) && t.host || R$1(t); return p(e) ? e.host : e; } function W$1(t) { const e = F(t); return w(e) ? e.ownerDocument.body : a(e) && g$1(e) ? e : W$1(e); } function D(t, e) { var o; void 0 === e && (e = []); const i = W$1(t), r = i === (null == (o = t.ownerDocument) ? void 0 : o.body), l = n$1(i); return r ? e.concat(l, l.visualViewport || [], g$1(i) ? i : []) : e.concat(i, D(i)); } function S$1(e, i, l) { return "viewport" === i ? rectToClientRect(function(t, e) { const o = n$1(t), i = R$1(t), r = o.visualViewport; let l = i.clientWidth, c = i.clientHeight, s = 0, f = 0; if (r) { l = r.width, c = r.height; const t = x$1(); (t || !t && "fixed" === e) && (s = r.offsetLeft, f = r.offsetTop); } return { width: l, height: c, x: s, y: f }; }(e, l)) : d$1(i) ? rectToClientRect(function(t, e) { const n = E$1(t, !0, "fixed" === e), o = n.top + t.clientTop, i = n.left + t.clientLeft, r = a(t) ? L(t) : { x: 1, y: 1 }; return { width: t.clientWidth * r.x, height: t.clientHeight * r.y, x: i * r.x, y: o * r.y }; }(i, l)) : rectToClientRect(function(t) { const e = R$1(t), n = T(t), i = t.ownerDocument.body, l = r(e.scrollWidth, e.clientWidth, i.scrollWidth, i.clientWidth), c = r(e.scrollHeight, e.clientHeight, i.scrollHeight, i.clientHeight); let s = -n.scrollLeft + C$1(t); const f = -n.scrollTop; return "rtl" === o(i).direction && (s += r(e.clientWidth, i.clientWidth) - l), { width: l, height: c, x: s, y: f }; }(R$1(e))); } function A$1(t) { return a(t) && "fixed" !== o(t).position ? t.offsetParent : null; } function H$3(t) { const e = n$1(t); let i = A$1(t); for (; i && m$1(i) && "static" === o(i).position;) i = A$1(i); return i && ("html" === s(i) || "body" === s(i) && "static" === o(i).position && !y$1(i)) ? e : i || function(t) { let e = F(t); for (; a(e) && !w(e);) { if (y$1(e)) return e; e = F(e); } return null; }(t) || e; } function O(t, e, n) { const o = a(e), i = R$1(e), r = E$1(t, !0, "fixed" === n, e); let l = { scrollLeft: 0, scrollTop: 0 }; const c = { x: 0, y: 0 }; if (o || !o && "fixed" !== n) if (("body" !== s(e) || g$1(i)) && (l = T(e)), a(e)) { const t = E$1(e, !0); c.x = t.x + e.clientLeft, c.y = t.y + e.clientTop; } else i && (c.x = C$1(i)); return { x: r.left + l.scrollLeft - c.x, y: r.top + l.scrollTop - c.y, width: r.width, height: r.height }; } var P = { getClippingRect: function(t) { let { element: e, boundary: n, rootBoundary: l, strategy: c } = t; const u = [..."clippingAncestors" === n ? function(t, e) { const n = e.get(t); if (n) return n; let i = D(t).filter(((t) => d$1(t) && "body" !== s(t))), r = null; const l = "fixed" === o(t).position; let c = l ? F(t) : t; for (; d$1(c) && !w(c);) { const t = o(c), e = y$1(c); (l ? e || r : e || "static" !== t.position || !r || !["absolute", "fixed"].includes(r.position)) ? r = t : i = i.filter(((t) => t !== c)), c = F(c); } return e.set(t, i), i; }(e, this._c) : [].concat(n), l], a = u[0], h = u.reduce(((t, n) => { const o = S$1(e, n, c); return t.top = r(o.top, t.top), t.right = i(o.right, t.right), t.bottom = i(o.bottom, t.bottom), t.left = r(o.left, t.left), t; }), S$1(e, a, c)); return { width: h.right - h.left, height: h.bottom - h.top, x: h.left, y: h.top }; }, convertOffsetParentRelativeRectToViewportRelativeRect: function(t) { let { rect: e, offsetParent: n, strategy: o } = t; const i = a(n), r = R$1(n); if (n === r) return e; let l = { scrollLeft: 0, scrollTop: 0 }, c = { x: 1, y: 1 }; const f = { x: 0, y: 0 }; if ((i || !i && "fixed" !== o) && (("body" !== s(n) || g$1(r)) && (l = T(n)), a(n))) { const t = E$1(n); c = L(n), f.x = t.x + n.clientLeft, f.y = t.y + n.clientTop; } return { width: e.width * c.x, height: e.height * c.y, x: e.x * c.x - l.scrollLeft * c.x + f.x, y: e.y * c.y - l.scrollTop * c.y + f.y }; }, isElement: d$1, getDimensions: function(t) { return a(t) ? c$1(t) : t.getBoundingClientRect(); }, getOffsetParent: H$3, getDocumentElement: R$1, getScale: L, async getElementRects(t) { let { reference: e, floating: n, strategy: o } = t; const i = this.getOffsetParent || H$3, r = this.getDimensions; return { reference: O(e, await i(n), o), floating: { x: 0, y: 0, ...await r(n) } }; }, getClientRects: (t) => Array.from(t.getClientRects()), isRTL: (t) => "rtl" === o(t).direction }; var B$2 = (t, n, o) => { const i = /* @__PURE__ */ new Map(), r = { platform: P, ...o }, l = { ...r.platform, _c: i }; return computePosition(t, n, { ...r, platform: l }); }; //#endregion //#region ../../node_modules/.pnpm/floating-vue@5.2.2_vue@3.5.33_typescript@5.9.3_/node_modules/floating-vue/dist/floating-vue.mjs function ye$1(e, t) { for (const o in t) Object.prototype.hasOwnProperty.call(t, o) && (typeof t[o] == "object" && e[o] ? ye$1(e[o], t[o]) : e[o] = t[o]); } var h = { disabled: !1, distance: 5, skidding: 0, container: "body", boundary: void 0, instantMove: !1, disposeTimeout: 150, popperTriggers: [], strategy: "absolute", preventOverflow: !0, flip: !0, shift: !0, overflowPadding: 0, arrowPadding: 0, arrowOverflow: !0, /** * By default, compute autohide on 'click'. */ autoHideOnMousedown: !1, themes: { tooltip: { placement: "top", triggers: [ "hover", "focus", "touch" ], hideTriggers: (e) => [...e, "click"], delay: { show: 200, hide: 0 }, handleResize: !1, html: !1, loadingContent: "..." }, dropdown: { placement: "bottom", triggers: ["click"], delay: 0, handleResize: !0, autoHide: !0 }, menu: { $extend: "dropdown", triggers: ["hover", "focus"], popperTriggers: ["hover"], delay: { show: 0, hide: 400 } } } }; function S(e, t) { let o = h.themes[e] || {}, i; do i = o[t], typeof i > "u" ? o.$extend ? o = h.themes[o.$extend] || {} : (o = null, i = h[t]) : o = null; while (o); return i; } function Ze$1(e) { const t = [e]; let o = h.themes[e] || {}; do o.$extend && !o.$resetCss ? (t.push(o.$extend), o = h.themes[o.$extend] || {}) : o = null; while (o); return t.map((i) => `v-popper--theme-${i}`); } function re(e) { const t = [e]; let o = h.themes[e] || {}; do o.$extend ? (t.push(o.$extend), o = h.themes[o.$extend] || {}) : o = null; while (o); return t; } var $$1 = !1; if (typeof window < "u") { $$1 = !1; try { const e = Object.defineProperty({}, "passive", { get() { $$1 = !0; } }); window.addEventListener("test", null, e); } catch {} } var _e = !1; typeof window < "u" && typeof navigator < "u" && (_e = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream); var Te$1 = [ "auto", "top", "bottom", "left", "right" ].reduce((e, t) => e.concat([ t, `${t}-start`, `${t}-end` ]), []), pe$1 = { hover: "mouseenter", focus: "focus", click: "click", touch: "touchstart", pointer: "pointerdown" }, ae = { hover: "mouseleave", focus: "blur", click: "click", touch: "touchend", pointer: "pointerup" }; function de$1(e, t) { const o = e.indexOf(t); o !== -1 && e.splice(o, 1); } function G$2() { return new Promise((e) => requestAnimationFrame(() => { requestAnimationFrame(e); })); } var d = []; var g = null; var le$1 = {}; function he(e) { let t = le$1[e]; return t || (t = le$1[e] = []), t; } var Y = function() {}; typeof window < "u" && (Y = window.Element); function n(e) { return function(t) { return S(t.theme, e); }; } var q$2 = "__floating-vue__popper", Q = () => /* @__PURE__ */ defineComponent({ name: "VPopper", provide() { return { [q$2]: { parentPopper: this } }; }, inject: { [q$2]: { default: null } }, props: { theme: { type: String, required: !0 }, targetNodes: { type: Function, required: !0 }, referenceNode: { type: Function, default: null }, popperNode: { type: Function, required: !0 }, shown: { type: Boolean, default: !1 }, showGroup: { type: String, default: null }, ariaId: { default: null }, disabled: { type: Boolean, default: n("disabled") }, positioningDisabled: { type: Boolean, default: n("positioningDisabled") }, placement: { type: String, default: n("placement"), validator: (e) => Te$1.includes(e) }, delay: { type: [ String, Number, Object ], default: n("delay") }, distance: { type: [Number, String], default: n("distance") }, skidding: { type: [Number, String], default: n("skidding") }, triggers: { type: Array, default: n("triggers") }, showTriggers: { type: [Array, Function], default: n("showTriggers") }, hideTriggers: { type: [Array, Function], default: n("hideTriggers") }, popperTriggers: { type: Array, default: n("popperTriggers") }, popperShowTriggers: { type: [Array, Function], default: n("popperShowTriggers") }, popperHideTriggers: { type: [Array, Function], default: n("popperHideTriggers") }, container: { type: [ String, Object, Y, Boolean ], default: n("container") }, boundary: { type: [String, Y], default: n("boundary") }, strategy: { type: String, validator: (e) => ["absolute", "fixed"].includes(e), default: n("strategy") }, autoHide: { type: [Boolean, Function], default: n("autoHide") }, handleResize: { type: Boolean, default: n("handleResize") }, instantMove: { type: Boolean, default: n("instantMove") }, eagerMount: { type: Boolean, default: n("eagerMount") }, popperClass: { type: [ String, Array, Object ], default: n("popperClass") }, computeTransformOrigin: { type: Boolean, default: n("computeTransformOrigin") }, /** * @deprecated */ autoMinSize: { type: Boolean, default: n("autoMinSize") }, autoSize: { type: [Boolean, String], default: n("autoSize") }, /** * @deprecated */ autoMaxSize: { type: Boolean, default: n("autoMaxSize") }, autoBoundaryMaxSize: { type: Boolean, default: n("autoBoundaryMaxSize") }, preventOverflow: { type: Boolean, default: n("preventOverflow") }, overflowPadding: { type: [Number, String], default: n("overflowPadding") }, arrowPadding: { type: [Number, String], default: n("arrowPadding") }, arrowOverflow: { type: Boolean, default: n("arrowOverflow") }, flip: { type: Boolean, default: n("flip") }, shift: { type: Boolean, default: n("shift") }, shiftCrossAxis: { type: Boolean, default: n("shiftCrossAxis") }, noAutoFocus: { type: Boolean, default: n("noAutoFocus") }, disposeTimeout: { type: Number, default: n("disposeTimeout") } }, emits: { show: () => !0, hide: () => !0, "update:shown": (e) => !0, "apply-show": () => !0, "apply-hide": () => !0, "close-group": () => !0, "close-directive": () => !0, "auto-hide": () => !0, resize: () => !0 }, data() { return { isShown: !1, isMounted: !1, skipTransition: !1, classes: { showFrom: !1, showTo: !1, hideFrom: !1, hideTo: !0 }, result: { x: 0, y: 0, placement: "", strategy: this.strategy, arrow: { x: 0, y: 0, centerOffset: 0 }, transformOrigin: null }, randomId: `popper_${[Math.random(), Date.now()].map((e) => e.toString(36).substring(2, 10)).join("_")}`, shownChildren: /* @__PURE__ */ new Set(), lastAutoHide: !0, pendingHide: !1, containsGlobalTarget: !1, isDisposed: !0, mouseDownContains: !1 }; }, computed: { popperId() { return this.ariaId != null ? this.ariaId : this.randomId; }, shouldMountContent() { return this.eagerMount || this.isMounted; }, slotData() { return { popperId: this.popperId, isShown: this.isShown, shouldMountContent: this.shouldMountContent, skipTransition: this.skipTransition, autoHide: typeof this.autoHide == "function" ? this.lastAutoHide : this.autoHide, show: this.show, hide: this.hide, handleResize: this.handleResize, onResize: this.onResize, classes: { ...this.classes, popperClass: this.popperClass }, result: this.positioningDisabled ? null : this.result, attrs: this.$attrs }; }, parentPopper() { var e; return (e = this[q$2]) == null ? void 0 : e.parentPopper; }, hasPopperShowTriggerHover() { var e, t; return ((e = this.popperTriggers) == null ? void 0 : e.includes("hover")) || ((t = this.popperShowTriggers) == null ? void 0 : t.includes("hover")); } }, watch: { shown: "$_autoShowHide", disabled(e) { e ? this.dispose() : this.init(); }, async container() { this.isShown && (this.$_ensureTeleport(), await this.$_computePosition()); }, triggers: { handler: "$_refreshListeners", deep: !0 }, positioningDisabled: "$_refreshListeners", ...[ "placement", "distance", "skidding", "boundary", "strategy", "overflowPadding", "arrowPadding", "preventOverflow", "shift", "shiftCrossAxis", "flip" ].reduce((e, t) => (e[t] = "$_computePosition", e), {}) }, created() { this.autoMinSize && console.warn("[floating-vue] `autoMinSize` option is deprecated. Use `autoSize=\"min\"` instead."), this.autoMaxSize && console.warn("[floating-vue] `autoMaxSize` option is deprecated. Use `autoBoundaryMaxSize` instead."); }, mounted() { this.init(), this.$_detachPopperNode(); }, activated() { this.$_autoShowHide(); }, deactivated() { this.hide(); }, beforeUnmount() { this.dispose(); }, methods: { show({ event: e = null, skipDelay: t = !1, force: o = !1 } = {}) { var i, s; (i = this.parentPopper) != null && i.lockedChild && this.parentPopper.lockedChild !== this || (this.pendingHide = !1, (o || !this.disabled) && (((s = this.parentPopper) == null ? void 0 : s.lockedChild) === this && (this.parentPopper.lockedChild = null), this.$_scheduleShow(e, t), this.$emit("show"), this.$_showFrameLocked = !0, requestAnimationFrame(() => { this.$_showFrameLocked = !1; })), this.$emit("update:shown", !0)); }, hide({ event: e = null, skipDelay: t = !1 } = {}) { var o; if (!this.$_hideInProgress) { if (this.shownChildren.size > 0) { this.pendingHide = !0; return; } if (this.hasPopperShowTriggerHover && this.$_isAimingPopper()) { this.parentPopper && (this.parentPopper.lockedChild = this, clearTimeout(this.parentPopper.lockedChildTimer), this.parentPopper.lockedChildTimer = setTimeout(() => { this.parentPopper.lockedChild === this && (this.parentPopper.lockedChild.hide({ skipDelay: t }), this.parentPopper.lockedChild = null); }, 1e3)); return; } ((o = this.parentPopper) == null ? void 0 : o.lockedChild) === this && (this.parentPopper.lockedChild = null), this.pendingHide = !1, this.$_scheduleHide(e, t), this.$emit("hide"), this.$emit("update:shown", !1); } }, init() { var e; this.isDisposed && (this.isDisposed = !1, this.isMounted = !1, this.$_events = [], this.$_preventShow = !1, this.$_referenceNode = ((e = this.referenceNode) == null ? void 0 : e.call(this)) ?? this.$el, this.$_targetNodes = this.targetNodes().filter((t) => t.nodeType === t.ELEMENT_NODE), this.$_popperNode = this.popperNode(), this.$_innerNode = this.$_popperNode.querySelector(".v-popper__inner"), this.$_arrowNode = this.$_popperNode.querySelector(".v-popper__arrow-container"), this.$_swapTargetAttrs("title", "data-original-title"), this.$_detachPopperNode(), this.triggers.length && this.$_addEventListeners(), this.shown && this.show()); }, dispose() { this.isDisposed || (this.isDisposed = !0, this.$_removeEventListeners(), this.hide({ skipDelay: !0 }), this.$_detachPopperNode(), this.isMounted = !1, this.isShown = !1, this.$_updateParentShownChildren(!1), this.$_swapTargetAttrs("data-original-title", "title")); }, async onResize() { this.isShown && (await this.$_computePosition(), this.$emit("resize")); }, async $_computePosition() { if (this.isDisposed || this.positioningDisabled) return; const e = { strategy: this.strategy, middleware: [] }; (this.distance || this.skidding) && e.middleware.push(offset({ mainAxis: this.distance, crossAxis: this.skidding })); const t = this.placement.startsWith("auto"); if (t ? e.middleware.push(autoPlacement({ alignment: this.placement.split("-")[1] ?? "" })) : e.placement = this.placement, this.preventOverflow && (this.shift && e.middleware.push(shift({ padding: this.overflowPadding, boundary: this.boundary, crossAxis: this.shiftCrossAxis })), !t && this.flip && e.middleware.push(flip({ padding: this.overflowPadding, boundary: this.boundary }))), e.middleware.push(arrow({ element: this.$_arrowNode, padding: this.arrowPadding })), this.arrowOverflow && e.middleware.push({ name: "arrowOverflow", fn: ({ placement: i, rects: s, middlewareData: r }) => { let p; const { centerOffset: a } = r.arrow; return i.startsWith("top") || i.startsWith("bottom") ? p = Math.abs(a) > s.reference.width / 2 : p = Math.abs(a) > s.reference.height / 2, { data: { overflow: p } }; } }), this.autoMinSize || this.autoSize) { const i = this.autoSize ? this.autoSize : this.autoMinSize ? "min" : null; e.middleware.push({ name: "autoSize", fn: ({ rects: s, placement: r, middlewareData: p }) => { var u; if ((u = p.autoSize) != null && u.skip) return {}; let a, l; return r.startsWith("top") || r.startsWith("bottom") ? a = s.reference.width : l = s.reference.height, this.$_innerNode.style[i === "min" ? "minWidth" : i === "max" ? "maxWidth" : "width"] = a != null ? `${a}px` : null, this.$_innerNode.style[i === "min" ? "minHeight" : i === "max" ? "maxHeight" : "height"] = l != null ? `${l}px` : null, { data: { skip: !0 }, reset: { rects: !0 } }; } }); } (this.autoMaxSize || this.autoBoundaryMaxSize) && (this.$_innerNode.style.maxWidth = null, this.$_innerNode.style.maxHeight = null, e.middleware.push(size({ boundary: this.boundary, padding: this.overflowPadding, apply: ({ availableWidth: i, availableHeight: s }) => { this.$_innerNode.style.maxWidth = i != null ? `${i}px` : null, this.$_innerNode.style.maxHeight = s != null ? `${s}px` : null; } }))); const o = await B$2(this.$_referenceNode, this.$_popperNode, e); Object.assign(this.result, { x: o.x, y: o.y, placement: o.placement, strategy: o.strategy, arrow: { ...o.middlewareData.arrow, ...o.middlewareData.arrowOverflow } }); }, $_scheduleShow(e, t = !1) { if (this.$_updateParentShownChildren(!0), this.$_hideInProgress = !1, clearTimeout(this.$_scheduleTimer), g && this.instantMove && g.instantMove && g !== this.parentPopper) { g.$_applyHide(!0), this.$_applyShow(!0); return; } t ? this.$_applyShow() : this.$_scheduleTimer = setTimeout(this.$_applyShow.bind(this), this.$_computeDelay("show")); }, $_scheduleHide(e, t = !1) { if (this.shownChildren.size > 0) { this.pendingHide = !0; return; } this.$_updateParentShownChildren(!1), this.$_hideInProgress = !0, clearTimeout(this.$_scheduleTimer), this.isShown && (g = this), t ? this.$_applyHide() : this.$_scheduleTimer = setTimeout(this.$_applyHide.bind(this), this.$_computeDelay("hide")); }, $_computeDelay(e) { const t = this.delay; return parseInt(t && t[e] || t || 0); }, async $_applyShow(e = !1) { clearTimeout(this.$_disposeTimer), clearTimeout(this.$_scheduleTimer), this.skipTransition = e, !this.isShown && (this.$_ensureTeleport(), await G$2(), await this.$_computePosition(), await this.$_applyShowEffect(), this.positioningDisabled || this.$_registerEventListeners([...D(this.$_referenceNode), ...D(this.$_popperNode)], "scroll", () => { this.$_computePosition(); })); }, async $_applyShowEffect() { if (this.$_hideInProgress) return; if (this.computeTransformOrigin) { const t = this.$_referenceNode.getBoundingClientRect(), o = this.$_popperNode.querySelector(".v-popper__wrapper"), i = o.parentNode.getBoundingClientRect(), s = t.x + t.width / 2 - (i.left + o.offsetLeft), r = t.y + t.height / 2 - (i.top + o.offsetTop); this.result.transformOrigin = `${s}px ${r}px`; } this.isShown = !0, this.$_applyAttrsToTarget({ "aria-describedby": this.popperId, "data-popper-shown": "" }); const e = this.showGroup; if (e) { let t; for (let o = 0; o < d.length; o++) t = d[o], t.showGroup !== e && (t.hide(), t.$emit("close-group")); } d.push(this), document.body.classList.add("v-popper--some-open"); for (const t of re(this.theme)) he(t).push(this), document.body.classList.add(`v-popper--some-open--${t}`); this.$emit("apply-show"), this.classes.showFrom = !0, this.classes.showTo = !1, this.classes.hideFrom = !1, this.classes.hideTo = !1, await G$2(), this.classes.showFrom = !1, this.classes.showTo = !0, this.noAutoFocus || this.$_popperNode.focus(); }, async $_applyHide(e = !1) { if (this.shownChildren.size > 0) { this.pendingHide = !0, this.$_hideInProgress = !1; return; } if (clearTimeout(this.$_scheduleTimer), !this.isShown) return; this.skipTransition = e, de$1(d, this), d.length === 0 && document.body.classList.remove("v-popper--some-open"); for (const o of re(this.theme)) { const i = he(o); de$1(i, this), i.length === 0 && document.body.classList.remove(`v-popper--some-open--${o}`); } g === this && (g = null), this.isShown = !1, this.$_applyAttrsToTarget({ "aria-describedby": void 0, "data-popper-shown": void 0 }), clearTimeout(this.$_disposeTimer); const t = this.disposeTimeout; t !== null && (this.$_disposeTimer = setTimeout(() => { this.$_popperNode && (this.$_detachPopperNode(), this.isMounted = !1); }, t)), this.$_removeEventListeners("scroll"), this.$emit("apply-hide"), this.classes.showFrom = !1, this.classes.showTo = !1, this.classes.hideFrom = !0, this.classes.hideTo = !1, await G$2(), this.classes.hideFrom = !1, this.classes.hideTo = !0; }, $_autoShowHide() { this.shown ? this.show() : this.hide(); }, $_ensureTeleport() { if (this.isDisposed) return; let e = this.container; if (typeof e == "string" ? e = window.document.querySelector(e) : e === !1 && (e = this.$_targetNodes[0].parentNode), !e) throw new Error("No container for popover: " + this.container); e.appendChild(this.$_popperNode), this.isMounted = !0; }, $_addEventListeners() { const e = (o) => { this.isShown && !this.$_hideInProgress || (o.usedByTooltip = !0, !this.$_preventShow && this.show({ event: o })); }; this.$_registerTriggerListeners(this.$_targetNodes, pe$1, this.triggers, this.showTriggers, e), this.$_registerTriggerListeners([this.$_popperNode], pe$1, this.popperTriggers, this.popperShowTriggers, e); const t = (o) => { o.usedByTooltip || this.hide({ event: o }); }; this.$_registerTriggerListeners(this.$_targetNodes, ae, this.triggers, this.hideTriggers, t), this.$_registerTriggerListeners([this.$_popperNode], ae, this.popperTriggers, this.popperHideTriggers, t); }, $_registerEventListeners(e, t, o) { this.$_events.push({ targetNodes: e, eventType: t, handler: o }), e.forEach((i) => i.addEventListener(t, o, $$1 ? { passive: !0 } : void 0)); }, $_registerTriggerListeners(e, t, o, i, s) { let r = o; i != null && (r = typeof i == "function" ? i(r) : i), r.forEach((p) => { const a = t[p]; a && this.$_registerEventListeners(e, a, s); }); }, $_removeEventListeners(e) { const t = []; this.$_events.forEach((o) => { const { targetNodes: i, eventType: s, handler: r } = o; !e || e === s ? i.forEach((p) => p.removeEventListener(s, r)) : t.push(o); }), this.$_events = t; }, $_refreshListeners() { this.isDisposed || (this.$_removeEventListeners(), this.$_addEventListeners()); }, $_handleGlobalClose(e, t = !1) { this.$_showFrameLocked || (this.hide({ event: e }), e.closePopover ? this.$emit("close-directive") : this.$emit("auto-hide"), t && (this.$_preventShow = !0, setTimeout(() => { this.$_preventShow = !1; }, 300))); }, $_detachPopperNode() { this.$_popperNode.parentNode && this.$_popperNode.parentNode.removeChild(this.$_popperNode); }, $_swapTargetAttrs(e, t) { for (const o of this.$_targetNodes) { const i = o.getAttribute(e); i && (o.removeAttribute(e), o.setAttribute(t, i)); } }, $_applyAttrsToTarget(e) { for (const t of this.$_targetNodes) for (const o in e) { const i = e[o]; i == null ? t.removeAttribute(o) : t.setAttribute(o, i); } }, $_updateParentShownChildren(e) { let t = this.parentPopper; for (; t;) e ? t.shownChildren.add(this.randomId) : (t.shownChildren.delete(this.randomId), t.pendingHide && t.hide()), t = t.parentPopper; }, $_isAimingPopper() { const e = this.$_referenceNode.getBoundingClientRect(); if (y >= e.left && y <= e.right && _ >= e.top && _ <= e.bottom) { const t = this.$_popperNode.getBoundingClientRect(), o = y - c, i = _ - m, r = t.left + t.width / 2 - c + (t.top + t.height / 2) - m + t.width + t.height, p = c + o * r, a = m + i * r; return C(c, m, p, a, t.left, t.top, t.left, t.bottom) || C(c, m, p, a, t.left, t.top, t.right, t.top) || C(c, m, p, a, t.right, t.top, t.right, t.bottom) || C(c, m, p, a, t.left, t.bottom, t.right, t.bottom); } return !1; } }, render() { return this.$slots.default(this.slotData); } }); if (typeof document < "u" && typeof window < "u") { if (_e) { const e = $$1 ? { passive: !0, capture: !0 } : !0; document.addEventListener("touchstart", (t) => ue(t, !0), e), document.addEventListener("touchend", (t) => fe$2(t, !0), e); } else window.addEventListener("mousedown", (e) => ue(e, !1), !0), window.addEventListener("click", (e) => fe$2(e, !1), !0); window.addEventListener("resize", tt$1); } function ue(e, t) { if (h.autoHideOnMousedown) Pe$1(e, t); else for (let o = 0; o < d.length; o++) { const i = d[o]; try { i.mouseDownContains = i.popperNode().contains(e.target); } catch {} } } function fe$2(e, t) { h.autoHideOnMousedown || Pe$1(e, t); } function Pe$1(e, t) { const o = {}; for (let i = d.length - 1; i >= 0; i--) { const s = d[i]; try { const r = s.containsGlobalTarget = s.mouseDownContains || s.popperNode().contains(e.target); s.pendingHide = !1, requestAnimationFrame(() => { if (s.pendingHide = !1, !o[s.randomId] && ce$1(s, r, e)) { if (s.$_handleGlobalClose(e, t), !e.closeAllPopover && e.closePopover && r) { let a = s.parentPopper; for (; a;) o[a.randomId] = !0, a = a.parentPopper; return; } let p = s.parentPopper; for (; p && ce$1(p, p.containsGlobalTarget, e);) { p.$_handleGlobalClose(e, t); p = p.parentPopper; } } }); } catch {} } } function ce$1(e, t, o) { return o.closeAllPopover || o.closePopover && t || et$1(e, o) && !t; } function et$1(e, t) { if (typeof e.autoHide == "function") { const o = e.autoHide(t); return e.lastAutoHide = o, o; } return e.autoHide; } function tt$1() { for (let e = 0; e < d.length; e++) d[e].$_computePosition(); } var c = 0, m = 0, y = 0, _ = 0; typeof window < "u" && window.addEventListener("mousemove", (e) => { c = y, m = _, y = e.clientX, _ = e.clientY; }, $$1 ? { passive: !0 } : void 0); function C(e, t, o, i, s, r, p, a) { const l = ((p - s) * (t - r) - (a - r) * (e - s)) / ((a - r) * (o - e) - (p - s) * (i - t)), u = ((o - e) * (t - r) - (i - t) * (e - s)) / ((a - r) * (o - e) - (p - s) * (i - t)); return l >= 0 && l <= 1 && u >= 0 && u <= 1; } var ot$1 = { extends: Q() }, B$1 = (e, t) => { const o = e.__vccOpts || e; for (const [i, s] of t) o[i] = s; return o; }; function it(e, t, o, i, s, r) { return openBlock(), createElementBlock("div", { ref: "reference", class: normalizeClass(["v-popper", { "v-popper--shown": e.slotData.isShown }]) }, [renderSlot(e.$slots, "default", normalizeProps(guardReactiveProps(e.slotData)))], 2); } var st$1 = /* @__PURE__ */ B$1(ot$1, [["render", it]]); function nt$1() { var e = window.navigator.userAgent, t = e.indexOf("MSIE "); if (t > 0) return parseInt(e.substring(t + 5, e.indexOf(".", t)), 10); if (e.indexOf("Trident/") > 0) { var i = e.indexOf("rv:"); return parseInt(e.substring(i + 3, e.indexOf(".", i)), 10); } var s = e.indexOf("Edge/"); return s > 0 ? parseInt(e.substring(s + 5, e.indexOf(".", s)), 10) : -1; } var z$1; function X$2() { X$2.init || (X$2.init = !0, z$1 = nt$1() !== -1); } var E = { name: "ResizeObserver", props: { emitOnMount: { type: Boolean, default: !1 }, ignoreWidth: { type: Boolean, default: !1 }, ignoreHeight: { type: Boolean, default: !1 } }, emits: ["notify"], mounted() { X$2(), nextTick(() => { this._w = this.$el.offsetWidth, this._h = this.$el.offsetHeight, this.emitOnMount && this.emitSize(); }); const e = document.createElement("object"); this._resizeObject = e, e.setAttribute("aria-hidden", "true"), e.setAttribute("tabindex", -1), e.onload = this.addResizeHandlers, e.type = "text/html", z$1 && this.$el.appendChild(e), e.data = "about:blank", z$1 || this.$el.appendChild(e); }, beforeUnmount() { this.removeResizeHandlers(); }, methods: { compareAndNotify() { (!this.ignoreWidth && this._w !== this.$el.offsetWidth || !this.ignoreHeight && this._h !== this.$el.offsetHeight) && (this._w = this.$el.offsetWidth, this._h = this.$el.offsetHeight, this.emitSize()); }, emitSize() { this.$emit("notify", { width: this._w, height: this._h }); }, addResizeHandlers() { this._resizeObject.contentDocument.defaultView.addEventListener("resize", this.compareAndNotify), this.compareAndNotify(); }, removeResizeHandlers() { this._resizeObject && this._resizeObject.onload && (!z$1 && this._resizeObject.contentDocument && this._resizeObject.contentDocument.defaultView.removeEventListener("resize", this.compareAndNotify), this.$el.removeChild(this._resizeObject), this._resizeObject.onload = null, this._resizeObject = null); } } }; var rt$1 = /* @__PURE__ */ withScopeId("data-v-b329ee4c"); pushScopeId("data-v-b329ee4c"); var pt$1 = { class: "resize-observer", tabindex: "-1" }; popScopeId(); E.render = /* @__PURE__ */ rt$1((e, t, o, i, s, r) => (openBlock(), createBlock("div", pt$1))); E.__scopeId = "data-v-b329ee4c"; E.__file = "src/components/ResizeObserver.vue"; var Z$2 = (e = "theme") => ({ computed: { themeClass() { return Ze$1(this[e]); } } }), dt = /* @__PURE__ */ defineComponent({ name: "VPopperContent", components: { ResizeObserver: E }, mixins: [Z$2()], props: { popperId: String, theme: String, shown: Boolean, mounted: Boolean, skipTransition: Boolean, autoHide: Boolean, handleResize: Boolean, classes: Object, result: Object }, emits: ["hide", "resize"], methods: { toPx(e) { return e != null && !isNaN(e) ? `${e}px` : null; } } }), lt = [ "id", "aria-hidden", "tabindex", "data-popper-placement" ], ht$1 = { ref: "inner", class: "v-popper__inner" }, ct = [/* @__PURE__ */ createBaseVNode("div", { class: "v-popper__arrow-outer" }, null, -1), /* @__PURE__ */ createBaseVNode("div", { class: "v-popper__arrow-inner" }, null, -1)]; function mt$1(e, t, o, i, s, r) { const p = resolveComponent("ResizeObserver"); return openBlock(), createElementBlock("div", { id: e.popperId, ref: "popover", class: normalizeClass(["v-popper__popper", [ e.themeClass, e.classes.popperClass, { "v-popper__popper--shown": e.shown, "v-popper__popper--hidden": !e.shown, "v-popper__popper--show-from": e.classes.showFrom, "v-popper__popper--show-to": e.classes.showTo, "v-popper__popper--hide-from": e.classes.hideFrom, "v-popper__popper--hide-to": e.classes.hideTo, "v-popper__popper--skip-transition": e.skipTransition, "v-popper__popper--arrow-overflow": e.result && e.result.arrow.overflow, "v-popper__popper--no-positioning": !e.result } ]]), style: normalizeStyle(e.result ? { position: e.result.strategy, transform: `translate3d(${Math.round(e.result.x)}px,${Math.round(e.result.y)}px,0)` } : void 0), "aria-hidden": e.shown ? "false" : "true", tabindex: e.autoHide ? 0 : void 0, "data-popper-placement": e.result ? e.result.placement : void 0, onKeyup: t[2] || (t[2] = withKeys((a) => e.autoHide && e.$emit("hide"), ["esc"])) }, [createBaseVNode("div", { class: "v-popper__backdrop", onClick: t[0] || (t[0] = (a) => e.autoHide && e.$emit("hide")) }), createBaseVNode("div", { class: "v-popper__wrapper", style: normalizeStyle(e.result ? { transformOrigin: e.result.transformOrigin } : void 0) }, [createBaseVNode("div", ht$1, [e.mounted ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createBaseVNode("div", null, [renderSlot(e.$slots, "default")]), e.handleResize ? (openBlock(), createBlock(p, { key: 0, onNotify: t[1] || (t[1] = (a) => e.$emit("resize", a)) })) : createCommentVNode("", !0)], 64)) : createCommentVNode("", !0)], 512), createBaseVNode("div", { ref: "arrow", class: "v-popper__arrow-container", style: normalizeStyle(e.result ? { left: e.toPx(e.result.arrow.x), top: e.toPx(e.result.arrow.y) } : void 0) }, ct, 4)], 4)], 46, lt); } var ee$1 = /* @__PURE__ */ B$1(dt, [["render", mt$1]]), te = { methods: { show(...e) { return this.$refs.popper.show(...e); }, hide(...e) { return this.$refs.popper.hide(...e); }, dispose(...e) { return this.$refs.popper.dispose(...e); }, onResize(...e) { return this.$refs.popper.onResize(...e); } } }; var K$1 = function() {}; typeof window < "u" && (K$1 = window.Element); var gt = /* @__PURE__ */ defineComponent({ name: "VPopperWrapper", components: { Popper: st$1, PopperContent: ee$1 }, mixins: [te, Z$2("finalTheme")], props: { theme: { type: String, default: null }, referenceNode: { type: Function, default: null }, shown: { type: Boolean, default: !1 }, showGroup: { type: String, default: null }, ariaId: { default: null }, disabled: { type: Boolean, default: void 0 }, positioningDisabled: { type: Boolean, default: void 0 }, placement: { type: String, default: void 0 }, delay: { type: [ String, Number, Object ], default: void 0 }, distance: { type: [Number, String], default: void 0 }, skidding: { type: [Number, String], default: void 0 }, triggers: { type: Array, default: void 0 }, showTriggers: { type: [Array, Function], default: void 0 }, hideTriggers: { type: [Array, Function], default: void 0 }, popperTriggers: { type: Array, default: void 0 }, popperShowTriggers: { type: [Array, Function], default: void 0 }, popperHideTriggers: { type: [Array, Function], default: void 0 }, container: { type: [ String, Object, K$1, Boolean ], default: void 0 }, boundary: { type: [String, K$1], default: void 0 }, strategy: { type: String, default: void 0 }, autoHide: { type: [Boolean, Function], default: void 0 }, handleResize: { type: Boolean, default: void 0 }, instantMove: { type: Boolean, default: void 0 }, eagerMount: { type: Boolean, default: void 0 }, popperClass: { type: [ String, Array, Object ], default: void 0 }, computeTransformOrigin: { type: Boolean, default: void 0 }, /** * @deprecated */ autoMinSize: { type: Boolean, default: void 0 }, autoSize: { type: [Boolean, String], default: void 0 }, /** * @deprecated */ autoMaxSize: { type: Boolean, default: void 0 }, autoBoundaryMaxSize: { type: Boolean, default: void 0 }, preventOverflow: { type: Boolean, default: void 0 }, overflowPadding: { type: [Number, String], default: void 0 }, arrowPadding: { type: [Number, String], default: void 0 }, arrowOverflow: { type: Boolean, default: void 0 }, flip: { type: Boolean, default: void 0 }, shift: { type: Boolean, default: void 0 }, shiftCrossAxis: { type: Boolean, default: void 0 }, noAutoFocus: { type: Boolean, default: void 0 }, disposeTimeout: { type: Number, default: void 0 } }, emits: { show: () => !0, hide: () => !0, "update:shown": (e) => !0, "apply-show": () => !0, "apply-hide": () => !0, "close-group": () => !0, "close-directive": () => !0, "auto-hide": () => !0, resize: () => !0 }, computed: { finalTheme() { return this.theme ?? this.$options.vPopperTheme; } }, methods: { getTargetNodes() { return Array.from(this.$el.children).filter((e) => e !== this.$refs.popperContent.$el); } } }); function wt(e, t, o, i, s, r) { const p = resolveComponent("PopperContent"), a = resolveComponent("Popper"); return openBlock(), createBlock(a, mergeProps({ ref: "popper" }, e.$props, { theme: e.finalTheme, "target-nodes": e.getTargetNodes, "popper-node": () => e.$refs.popperContent.$el, class: [e.themeClass], onShow: t[0] || (t[0] = () => e.$emit("show")), onHide: t[1] || (t[1] = () => e.$emit("hide")), "onUpdate:shown": t[2] || (t[2] = (l) => e.$emit("update:shown", l)), onApplyShow: t[3] || (t[3] = () => e.$emit("apply-show")), onApplyHide: t[4] || (t[4] = () => e.$emit("apply-hide")), onCloseGroup: t[5] || (t[5] = () => e.$emit("close-group")), onCloseDirective: t[6] || (t[6] = () => e.$emit("close-directive")), onAutoHide: t[7] || (t[7] = () => e.$emit("auto-hide")), onResize: t[8] || (t[8] = () => e.$emit("resize")) }), { default: withCtx(({ popperId: l, isShown: u, shouldMountContent: L, skipTransition: D, autoHide: I, show: F, hide: v, handleResize: R, onResize: j, classes: V, result: Ee }) => [renderSlot(e.$slots, "default", { shown: u, show: F, hide: v }), createVNode(p, { ref: "popperContent", "popper-id": l, theme: e.finalTheme, shown: u, mounted: L, "skip-transition": D, "auto-hide": I, "handle-resize": R, classes: V, result: Ee, onHide: v, onResize: j }, { default: withCtx(() => [renderSlot(e.$slots, "popper", { shown: u, hide: v })]), _: 2 }, 1032, [ "popper-id", "theme", "shown", "mounted", "skip-transition", "auto-hide", "handle-resize", "classes", "result", "onHide", "onResize" ])]), _: 3 }, 16, [ "theme", "target-nodes", "popper-node", "class" ]); } var k = /* @__PURE__ */ B$1(gt, [["render", wt]]), Se$1 = { ...k, name: "VDropdown", vPopperTheme: "dropdown" }, be$1 = { ...k, name: "VMenu", vPopperTheme: "menu" }, Ce$1 = { ...k, name: "VTooltip", vPopperTheme: "tooltip" }, $t = /* @__PURE__ */ defineComponent({ name: "VTooltipDirective", components: { Popper: Q(), PopperContent: ee$1 }, mixins: [te], inheritAttrs: !1, props: { theme: { type: String, default: "tooltip" }, html: { type: Boolean, default: (e) => S(e.theme, "html") }, content: { type: [ String, Number, Function ], default: null }, loadingContent: { type: String, default: (e) => S(e.theme, "loadingContent") }, targetNodes: { type: Function, required: !0 } }, data() { return { asyncContent: null }; }, computed: { isContentAsync() { return typeof this.content == "function"; }, loading() { return this.isContentAsync && this.asyncContent == null; }, finalContent() { return this.isContentAsync ? this.loading ? this.loadingContent : this.asyncContent : this.content; } }, watch: { content: { handler() { this.fetchContent(!0); }, immediate: !0 }, async finalContent() { await this.$nextTick(), this.$refs.popper.onResize(); } }, created() { this.$_fetchId = 0; }, methods: { fetchContent(e) { if (typeof this.content == "function" && this.$_isShown && (e || !this.$_loading && this.asyncContent == null)) { this.asyncContent = null, this.$_loading = !0; const t = ++this.$_fetchId, o = this.content(this); o.then ? o.then((i) => this.onResult(t, i)) : this.onResult(t, o); } }, onResult(e, t) { e === this.$_fetchId && (this.$_loading = !1, this.asyncContent = t); }, onShow() { this.$_isShown = !0, this.fetchContent(); }, onHide() { this.$_isShown = !1; } } }), vt = ["innerHTML"], yt = ["textContent"]; function _t$1(e, t, o, i, s, r) { const p = resolveComponent("PopperContent"), a = resolveComponent("Popper"); return openBlock(), createBlock(a, mergeProps({ ref: "popper" }, e.$attrs, { theme: e.theme, "target-nodes": e.targetNodes, "popper-node": () => e.$refs.popperContent.$el, onApplyShow: e.onShow, onApplyHide: e.onHide }), { default: withCtx(({ popperId: l, isShown: u, shouldMountContent: L, skipTransition: D, autoHide: I, hide: F, handleResize: v, onResize: R, classes: j, result: V }) => [createVNode(p, { ref: "popperContent", class: normalizeClass({ "v-popper--tooltip-loading": e.loading }), "popper-id": l, theme: e.theme, shown: u, mounted: L, "skip-transition": D, "auto-hide": I, "handle-resize": v, classes: j, result: V, onHide: F, onResize: R }, { default: withCtx(() => [e.html ? (openBlock(), createElementBlock("div", { key: 0, innerHTML: e.finalContent }, null, 8, vt)) : (openBlock(), createElementBlock("div", { key: 1, textContent: toDisplayString(e.finalContent) }, null, 8, yt))]), _: 2 }, 1032, [ "class", "popper-id", "theme", "shown", "mounted", "skip-transition", "auto-hide", "handle-resize", "classes", "result", "onHide", "onResize" ])]), _: 1 }, 16, [ "theme", "target-nodes", "popper-node", "onApplyShow", "onApplyHide" ]); } var ze = /* @__PURE__ */ B$1($t, [["render", _t$1]]), Ae$1 = "v-popper--has-tooltip"; function Tt$1(e, t) { let o = e.placement; if (!o && t) for (const i of Te$1) t[i] && (o = i); return o || (o = S(e.theme || "tooltip", "placement")), o; } function Ne$2(e, t, o) { let i; const s = typeof t; return s === "string" ? i = { content: t } : t && s === "object" ? i = t : i = { content: !1 }, i.placement = Tt$1(i, o), i.targetNodes = () => [e], i.referenceNode = () => e, i; } var x, b, Pt = 0; function St$1() { if (x) return; b = /* @__PURE__ */ ref([]), x = createApp({ name: "VTooltipDirectiveApp", setup() { return { directives: b }; }, render() { return this.directives.map((t) => h$2(ze, { ...t.options, shown: t.shown || t.options.shown, key: t.id })); }, devtools: { hide: !0 } }); const e = document.createElement("div"); document.body.appendChild(e), x.mount(e); } function bt(e, t, o) { St$1(); const i = /* @__PURE__ */ ref(Ne$2(e, t, o)), s = /* @__PURE__ */ ref(!1), r = { id: Pt++, options: i, shown: s }; return b.value.push(r), e.classList && e.classList.add(Ae$1), e.$_popper = { options: i, item: r, show() { s.value = !0; }, hide() { s.value = !1; } }; } function He$2(e) { if (e.$_popper) { const t = b.value.indexOf(e.$_popper.item); t !== -1 && b.value.splice(t, 1), delete e.$_popper, delete e.$_popperOldShown, delete e.$_popperMountTarget; } e.classList && e.classList.remove(Ae$1); } function me$1(e, { value: t, modifiers: o }) { const i = Ne$2(e, t, o); if (!i.content || S(i.theme || "tooltip", "disabled")) He$2(e); else { let s; e.$_popper ? (s = e.$_popper, s.options.value = i) : s = bt(e, t, o), typeof t.shown < "u" && t.shown !== e.$_popperOldShown && (e.$_popperOldShown = t.shown, t.shown ? s.show() : s.hide()); } } var oe$2 = { beforeMount: me$1, updated: me$1, beforeUnmount(e) { He$2(e); } }; function ge(e) { e.addEventListener("mousedown", H$2), e.addEventListener("click", H$2), e.addEventListener("touchstart", Oe$2, $$1 ? { passive: !0 } : !1); } function we$1(e) { e.removeEventListener("mousedown", H$2), e.removeEventListener("click", H$2), e.removeEventListener("touchstart", Oe$2), e.removeEventListener("touchend", Me$1), e.removeEventListener("touchcancel", Be); } function H$2(e) { const t = e.currentTarget; e.closePopover = !t.$_vclosepopover_touch, e.closeAllPopover = t.$_closePopoverModifiers && !!t.$_closePopoverModifiers.all; } function Oe$2(e) { if (e.changedTouches.length === 1) { const t = e.currentTarget; t.$_vclosepopover_touch = !0; t.$_vclosepopover_touchPoint = e.changedTouches[0], t.addEventListener("touchend", Me$1), t.addEventListener("touchcancel", Be); } } function Me$1(e) { const t = e.currentTarget; if (t.$_vclosepopover_touch = !1, e.changedTouches.length === 1) { const o = e.changedTouches[0], i = t.$_vclosepopover_touchPoint; e.closePopover = Math.abs(o.screenY - i.screenY) < 20 && Math.abs(o.screenX - i.screenX) < 20, e.closeAllPopover = t.$_closePopoverModifiers && !!t.$_closePopoverModifiers.all; } } function Be(e) { const t = e.currentTarget; t.$_vclosepopover_touch = !1; } var ie = { beforeMount(e, { value: t, modifiers: o }) { e.$_closePopoverModifiers = o, (typeof t > "u" || t) && ge(e); }, updated(e, { value: t, oldValue: o, modifiers: i }) { e.$_closePopoverModifiers = i, t !== o && (typeof t > "u" || t ? ge(e) : we$1(e)); }, beforeUnmount(e) { we$1(e); } }; function Ct$1(e, t = {}) { e.$_vTooltipInstalled || (e.$_vTooltipInstalled = !0, ye$1(h, t), e.directive("tooltip", oe$2), e.directive("close-popper", ie), e.component("VTooltip", Ce$1), e.component("VDropdown", Se$1), e.component("VMenu", be$1)); } var Gt = { version: "5.2.2", install: Ct$1, options: h }; //#endregion //#region ../../node_modules/.pnpm/pinia@2.3.1_typescript@5.9.3_vue@3.5.33_typescript@5.9.3_/node_modules/pinia/dist/pinia.mjs /*! * pinia v2.3.1 * (c) 2025 Eduardo San Martin Morote * @license MIT */ /** * setActivePinia must be called to handle SSR at the top of functions like * `fetch`, `setup`, `serverPrefetch` and others */ var activePinia; /** * Sets or unsets the active pinia. Used in SSR and internally when calling * actions and getters * * @param pinia - Pinia instance */ var setActivePinia = (pinia) => activePinia = pinia; var piniaSymbol = Symbol(); function isPlainObject$1(o) { return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function"; } /** * Possible types for SubscriptionCallback */ var MutationType; (function(MutationType) { /** * Direct mutation of the state: * * - `store.name = 'new name'` * - `store.$state.name = 'new name'` * - `store.list.push('new item')` */ MutationType["direct"] = "direct"; /** * Mutated the state with `$patch` and an object * * - `store.$patch({ name: 'newName' })` */ MutationType["patchObject"] = "patch object"; /** * Mutated the state with `$patch` and a function * * - `store.$patch(state => state.name = 'newName')` */ MutationType["patchFunction"] = "patch function"; })(MutationType || (MutationType = {})); var IS_CLIENT = typeof window !== "undefined"; var _global = /*#__PURE__*/ (() => typeof window === "object" && window.window === window ? window : typeof self === "object" && self.self === self ? self : typeof global === "object" && global.global === global ? global : typeof globalThis === "object" ? globalThis : { HTMLElement: null })(); function bom(blob, { autoBom = false } = {}) { if (autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) return new Blob([String.fromCharCode(65279), blob], { type: blob.type }); return blob; } function download(url, name, opts) { const xhr = new XMLHttpRequest(); xhr.open("GET", url); xhr.responseType = "blob"; xhr.onload = function() { saveAs(xhr.response, name, opts); }; xhr.onerror = function() { console.error("could not download file"); }; xhr.send(); } function corsEnabled(url) { const xhr = new XMLHttpRequest(); xhr.open("HEAD", url, false); try { xhr.send(); } catch (e) {} return xhr.status >= 200 && xhr.status <= 299; } function click(node) { try { node.dispatchEvent(new MouseEvent("click")); } catch (e) { const evt = document.createEvent("MouseEvents"); evt.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null); node.dispatchEvent(evt); } } var _navigator = typeof navigator === "object" ? navigator : { userAgent: "" }; var isMacOSWebView = /*#__PURE__*/ (() => /Macintosh/.test(_navigator.userAgent) && /AppleWebKit/.test(_navigator.userAgent) && !/Safari/.test(_navigator.userAgent))(); var saveAs = !IS_CLIENT ? () => {} : typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : "msSaveOrOpenBlob" in _navigator ? msSaveAs : fileSaverSaveAs; function downloadSaveAs(blob, name = "download", opts) { const a = document.createElement("a"); a.download = name; a.rel = "noopener"; if (typeof blob === "string") { a.href = blob; if (a.origin !== location.origin) if (corsEnabled(a.href)) download(blob, name, opts); else { a.target = "_blank"; click(a); } else click(a); } else { a.href = URL.createObjectURL(blob); setTimeout(function() { URL.revokeObjectURL(a.href); }, 4e4); setTimeout(function() { click(a); }, 0); } } function msSaveAs(blob, name = "download", opts) { if (typeof blob === "string") if (corsEnabled(blob)) download(blob, name, opts); else { const a = document.createElement("a"); a.href = blob; a.target = "_blank"; setTimeout(function() { click(a); }); } else navigator.msSaveOrOpenBlob(bom(blob, opts), name); } function fileSaverSaveAs(blob, name, opts, popup) { popup = popup || open("", "_blank"); if (popup) popup.document.title = popup.document.body.innerText = "downloading..."; if (typeof blob === "string") return download(blob, name, opts); const force = blob.type === "application/octet-stream"; const isSafari = /constructor/i.test(String(_global.HTMLElement)) || "safari" in _global; const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent); if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== "undefined") { const reader = new FileReader(); reader.onloadend = function() { let url = reader.result; if (typeof url !== "string") { popup = null; throw new Error("Wrong reader.result type"); } url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, "data:attachment/file;"); if (popup) popup.location.href = url; else location.assign(url); popup = null; }; reader.readAsDataURL(blob); } else { const url = URL.createObjectURL(blob); if (popup) popup.location.assign(url); else location.href = url; popup = null; setTimeout(function() { URL.revokeObjectURL(url); }, 4e4); } } var { assign: assign$1 } = Object; /** * Creates a Pinia instance to be used by the application */ function createPinia() { const scope = effectScope(true); const state = scope.run(() => /* @__PURE__ */ ref({})); let _p = []; let toBeInstalled = []; const pinia = markRaw({ install(app) { setActivePinia(pinia); pinia._a = app; app.provide(piniaSymbol, pinia); app.config.globalProperties.$pinia = pinia; toBeInstalled.forEach((plugin) => _p.push(plugin)); toBeInstalled = []; }, use(plugin) { if (!this._a && true) toBeInstalled.push(plugin); else _p.push(plugin); return this; }, _p, _a: null, _e: scope, _s: /* @__PURE__ */ new Map(), state }); return pinia; } var noop$2 = () => {}; function addSubscription(subscriptions, callback, detached, onCleanup = noop$2) { subscriptions.push(callback); const removeSubscription = () => { const idx = subscriptions.indexOf(callback); if (idx > -1) { subscriptions.splice(idx, 1); onCleanup(); } }; if (!detached && getCurrentScope$1()) onScopeDispose(removeSubscription); return removeSubscription; } function triggerSubscriptions(subscriptions, ...args) { subscriptions.slice().forEach((callback) => { callback(...args); }); } var fallbackRunWithContext = (fn) => fn(); /** * Marks a function as an action for `$onAction` * @internal */ var ACTION_MARKER = Symbol(); /** * Action name symbol. Allows to add a name to an action after defining it * @internal */ var ACTION_NAME = Symbol(); function mergeReactiveObjects(target, patchToApply) { if (target instanceof Map && patchToApply instanceof Map) patchToApply.forEach((value, key) => target.set(key, value)); else if (target instanceof Set && patchToApply instanceof Set) patchToApply.forEach(target.add, target); for (const key in patchToApply) { if (!patchToApply.hasOwnProperty(key)) continue; const subPatch = patchToApply[key]; const targetValue = target[key]; if (isPlainObject$1(targetValue) && isPlainObject$1(subPatch) && target.hasOwnProperty(key) && !/* @__PURE__ */ isRef(subPatch) && !/* @__PURE__ */ isReactive(subPatch)) target[key] = mergeReactiveObjects(targetValue, subPatch); else target[key] = subPatch; } return target; } var skipHydrateSymbol = Symbol(); /** * Returns whether a value should be hydrated * * @param obj - target variable * @returns true if `obj` should be hydrated */ function shouldHydrate(obj) { return !isPlainObject$1(obj) || !obj.hasOwnProperty(skipHydrateSymbol); } var { assign } = Object; function isComputed(o) { return !!(/* @__PURE__ */ isRef(o) && o.effect); } function createOptionsStore(id, options, pinia, hot) { const { state, actions, getters } = options; const initialState = pinia.state.value[id]; let store; function setup() { if (!initialState && true) pinia.state.value[id] = state ? state() : {}; return assign(/* @__PURE__ */ toRefs(pinia.state.value[id]), actions, Object.keys(getters || {}).reduce((computedGetters, name) => { computedGetters[name] = markRaw(computed(() => { setActivePinia(pinia); const store = pinia._s.get(id); return getters[name].call(store, store); })); return computedGetters; }, {})); } store = createSetupStore(id, setup, options, pinia, hot, true); return store; } function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) { let scope; const optionsForPlugin = assign({ actions: {} }, options); const $subscribeOptions = { deep: true }; let isListening; let isSyncListening; let subscriptions = []; let actionSubscriptions = []; let debuggerEvents; const initialState = pinia.state.value[$id]; if (!isOptionsStore && !initialState && true) pinia.state.value[$id] = {}; let activeListener; function $patch(partialStateOrMutator) { let subscriptionMutation; isListening = isSyncListening = false; if (typeof partialStateOrMutator === "function") { partialStateOrMutator(pinia.state.value[$id]); subscriptionMutation = { type: MutationType.patchFunction, storeId: $id, events: debuggerEvents }; } else { mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator); subscriptionMutation = { type: MutationType.patchObject, payload: partialStateOrMutator, storeId: $id, events: debuggerEvents }; } const myListenerId = activeListener = Symbol(); nextTick().then(() => { if (activeListener === myListenerId) isListening = true; }); isSyncListening = true; triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]); } const $reset = isOptionsStore ? function $reset() { const { state } = options; const newState = state ? state() : {}; this.$patch(($state) => { assign($state, newState); }); } : noop$2; function $dispose() { scope.stop(); subscriptions = []; actionSubscriptions = []; pinia._s.delete($id); } /** * Helper that wraps function so it can be tracked with $onAction * @param fn - action to wrap * @param name - name of the action */ const action = (fn, name = "") => { if (ACTION_MARKER in fn) { fn[ACTION_NAME] = name; return fn; } const wrappedAction = function() { setActivePinia(pinia); const args = Array.from(arguments); const afterCallbackList = []; const onErrorCallbackList = []; function after(callback) { afterCallbackList.push(callback); } function onError(callback) { onErrorCallbackList.push(callback); } triggerSubscriptions(actionSubscriptions, { args, name: wrappedAction[ACTION_NAME], store, after, onError }); let ret; try { ret = fn.apply(this && this.$id === $id ? this : store, args); } catch (error) { triggerSubscriptions(onErrorCallbackList, error); throw error; } if (ret instanceof Promise) return ret.then((value) => { triggerSubscriptions(afterCallbackList, value); return value; }).catch((error) => { triggerSubscriptions(onErrorCallbackList, error); return Promise.reject(error); }); triggerSubscriptions(afterCallbackList, ret); return ret; }; wrappedAction[ACTION_MARKER] = true; wrappedAction[ACTION_NAME] = name; return wrappedAction; }; const store = /* @__PURE__ */ reactive({ _p: pinia, $id, $onAction: addSubscription.bind(null, actionSubscriptions), $patch, $reset, $subscribe(callback, options = {}) { const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher()); const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => { if (options.flush === "sync" ? isSyncListening : isListening) callback({ storeId: $id, type: MutationType.direct, events: debuggerEvents }, state); }, assign({}, $subscribeOptions, options))); return removeSubscription; }, $dispose }); pinia._s.set($id, store); const setupStore = (pinia._a && pinia._a.runWithContext || fallbackRunWithContext)(() => pinia._e.run(() => (scope = effectScope()).run(() => setup({ action })))); for (const key in setupStore) { const prop = setupStore[key]; if (/* @__PURE__ */ isRef(prop) && !isComputed(prop) || /* @__PURE__ */ isReactive(prop)) { if (!isOptionsStore) { if (initialState && shouldHydrate(prop)) if (/* @__PURE__ */ isRef(prop)) prop.value = initialState[key]; else mergeReactiveObjects(prop, initialState[key]); pinia.state.value[$id][key] = prop; } } else if (typeof prop === "function") { setupStore[key] = action(prop, key); optionsForPlugin.actions[key] = prop; } } assign(store, setupStore); assign(/* @__PURE__ */ toRaw(store), setupStore); Object.defineProperty(store, "$state", { get: () => pinia.state.value[$id], set: (state) => { $patch(($state) => { assign($state, state); }); } }); pinia._p.forEach((extender) => { assign(store, scope.run(() => extender({ store, app: pinia._a, pinia, options: optionsForPlugin }))); }); if (initialState && isOptionsStore && options.hydrate) options.hydrate(store.$state, initialState); isListening = true; isSyncListening = true; return store; } /*! #__NO_SIDE_EFFECTS__ */ function defineStore(idOrOptions, setup, setupOptions) { let id; let options; const isSetupStore = typeof setup === "function"; if (typeof idOrOptions === "string") { id = idOrOptions; options = isSetupStore ? setupOptions : setup; } else { options = idOrOptions; id = idOrOptions.id; } function useStore(pinia, hot) { const hasContext = hasInjectionContext(); pinia = pinia || (hasContext ? inject(piniaSymbol, null) : null); if (pinia) setActivePinia(pinia); pinia = activePinia; if (!pinia._s.has(id)) if (isSetupStore) createSetupStore(id, setup, options, pinia); else createOptionsStore(id, options, pinia); return pinia._s.get(id); } useStore.$id = id; return useStore; } /** * Creates an object of references with all the state, getters, and plugin-added * state properties of the store. Similar to `toRefs()` but specifically * designed for Pinia stores so methods and non reactive properties are * completely ignored. * * @param store - store to extract the refs from */ function storeToRefs(store) { { const rawStore = /* @__PURE__ */ toRaw(store); const refs = {}; for (const key in rawStore) { const value = rawStore[key]; if (value.effect) refs[key] = computed({ get: () => store[key], set(value) { store[key] = value; } }); else if (/* @__PURE__ */ isRef(value) || /* @__PURE__ */ isReactive(value)) refs[key] = /* @__PURE__ */ toRef(store, key); } return refs; } } //#endregion //#region ../send/frontend/src/lib/shared-pinia.ts var piniaInstance = null; /** * Gets or creates the shared Pinia instance. * This ensures both background.ts and extension contexts use the same instance. */ function getSharedPinia() { if (!piniaInstance) { piniaInstance = createPinia(); setActivePinia(piniaInstance); } return piniaInstance; } function toValue(r) { return typeof r === "function" ? r() : unref(r); } var isClient$1 = typeof window !== "undefined" && typeof document !== "undefined"; typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope; var noop$1 = () => {}; function createFilterWrapper(filter, fn) { function wrapper(...args) { return new Promise((resolve, reject) => { Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject); }); } return wrapper; } function debounceFilter(ms, options = {}) { let timer; let maxTimer; let lastRejector = noop$1; const _clearTimeout = (timer2) => { clearTimeout(timer2); lastRejector(); lastRejector = noop$1; }; const filter = (invoke) => { const duration = toValue(ms); const maxDuration = toValue(options.maxWait); if (timer) _clearTimeout(timer); if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) { if (maxTimer) { _clearTimeout(maxTimer); maxTimer = null; } return Promise.resolve(invoke()); } return new Promise((resolve, reject) => { lastRejector = options.rejectOnCancel ? reject : resolve; if (maxDuration && !maxTimer) maxTimer = setTimeout(() => { if (timer) _clearTimeout(timer); maxTimer = null; resolve(invoke()); }, maxDuration); timer = setTimeout(() => { if (maxTimer) _clearTimeout(maxTimer); maxTimer = null; resolve(invoke()); }, duration); }); }; return filter; } function useDebounceFn(fn, ms = 200, options = {}) { return createFilterWrapper(debounceFilter(ms, options), fn); } isClient$1 && window.document; isClient$1 && window.navigator; isClient$1 && window.location; Number.POSITIVE_INFINITY; var isClient = typeof window !== "undefined" && typeof document !== "undefined"; typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope; isClient && window.document; isClient && window.navigator; isClient && window.location; Number.POSITIVE_INFINITY; /*! * tabbable 6.4.0 * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE */ var candidateSelector = /* #__PURE__ */ [ "input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", "[contenteditable]:not([contenteditable=\"false\"]):not([inert]):not([inert] *)", "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)" ].join(","); var NoElement = typeof Element === "undefined"; var matches = NoElement ? function() {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; !NoElement && Element.prototype.getRootNode; /** * Determines if a node is inert or in an inert ancestor. * @param {Node} [node] * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to * see if any of them are inert. If false, only `node` itself is considered. * @returns {boolean} True if inert itself or by way of being in an inert ancestor. * False if `node` is falsy. */ var _isInert = function isInert(node, lookUp) { var _node$getAttribute; if (lookUp === void 0) lookUp = true; var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, "inert"); return inertAtt === "" || inertAtt === "true" || lookUp && node && (typeof node.closest === "function" ? node.closest("[inert]") : _isInert(node.parentNode)); }; /** * Determines if a node's content is editable. * @param {Element} [node] * @returns True if it's content-editable; false if it's not or `node` is falsy. */ var isContentEditable = function isContentEditable(node) { var _node$getAttribute2; var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, "contenteditable"); return attValue === "" || attValue === "true"; }; /** * @callback GetShadowRoot * @param {Element} element to check for shadow root * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available. */ /** * @callback ShadowRootFilter * @param {Element} shadowHostNode the element which contains shadow content * @returns {boolean} true if a shadow root could potentially contain valid candidates. */ /** * @typedef {Object} CandidateScope * @property {Element} scopeParent contains inner candidates * @property {Element[]} candidates list of candidates found in the scope parent */ /** * @typedef {Object} IterativeOptions * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not; * if a function, implies shadow support is enabled and either returns the shadow root of an element * or a boolean stating if it has an undisclosed shadow root * @property {(node: Element) => boolean} filter filter candidates * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list * @property {ShadowRootFilter} shadowRootFilter filter shadow roots; */ /** * @param {Element[]} elements list of element containers to match candidates from * @param {boolean} includeContainer add container list to check * @param {IterativeOptions} options * @returns {Array.} */ var _getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) { var candidates = []; var elementsToCheck = Array.from(elements); while (elementsToCheck.length) { var element = elementsToCheck.shift(); if (_isInert(element, false)) continue; if (element.tagName === "SLOT") { var assigned = element.assignedElements(); var nestedCandidates = _getCandidatesIteratively(assigned.length ? assigned : element.children, true, options); if (options.flatten) candidates.push.apply(candidates, nestedCandidates); else candidates.push({ scopeParent: element, candidates: nestedCandidates }); } else { if (matches.call(element, candidateSelector) && options.filter(element) && (includeContainer || !elements.includes(element))) candidates.push(element); var shadowRoot = element.shadowRoot || typeof options.getShadowRoot === "function" && options.getShadowRoot(element); var validShadowRoot = !_isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element)); if (shadowRoot && validShadowRoot) { var _nestedCandidates = _getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options); if (options.flatten) candidates.push.apply(candidates, _nestedCandidates); else candidates.push({ scopeParent: element, candidates: _nestedCandidates }); } else elementsToCheck.unshift.apply(elementsToCheck, element.children); } } return candidates; }; /** * @private * Determines if the node has an explicitly specified `tabindex` attribute. * @param {HTMLElement} node * @returns {boolean} True if so; false if not. */ var hasTabIndex = function hasTabIndex(node) { return !isNaN(parseInt(node.getAttribute("tabindex"), 10)); }; /** * Determine the tab index of a given node. * @param {HTMLElement} node * @returns {number} Tab order (negative, 0, or positive number). * @throws {Error} If `node` is falsy. */ var getTabIndex = function getTabIndex(node) { if (!node) throw new Error("No node provided"); if (node.tabIndex < 0) { if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) return 0; } return node.tabIndex; }; /** * Determine the tab index of a given node __for sort order purposes__. * @param {HTMLElement} node * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default, * has tabIndex -1, but needs to be sorted by document order in order for its content to be * inserted into the correct sort position. * @returns {number} Tab order (negative, 0, or positive number). */ var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) { var tabIndex = getTabIndex(node); if (tabIndex < 0 && isScope && !hasTabIndex(node)) return 0; return tabIndex; }; var sortOrderedTabbables = function sortOrderedTabbables(a, b) { return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex; }; /** * @param {Array.} candidates * @returns Element[] */ var _sortByOrder = function sortByOrder(candidates) { var regularTabbables = []; var orderedTabbables = []; candidates.forEach(function(item, i) { var isScope = !!item.scopeParent; var element = isScope ? item.scopeParent : item; var candidateTabindex = getSortOrderTabIndex(element, isScope); var elements = isScope ? _sortByOrder(item.candidates) : element; if (candidateTabindex === 0) isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element); else orderedTabbables.push({ documentOrder: i, tabIndex: candidateTabindex, item, isScope, content: elements }); }); return orderedTabbables.sort(sortOrderedTabbables).reduce(function(acc, sortable) { sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content); return acc; }, []).concat(regularTabbables); }; /*! * focus-trap 7.6.4 * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE */ if (typeof window < "u") { const e = { get passive() {} }; window.addEventListener("testPassive", null, e), window.removeEventListener("testPassive", null, e); } typeof window < "u" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints); var Ye = Symbol("vfm"); function zo$1() { const e = /* @__PURE__ */ shallowReactive([]), o = /* @__PURE__ */ shallowReactive([]), c = markRaw({ install(a) { a.provide(Ye, c), a.config.globalProperties.$vfm = c; }, modals: e, openedModals: o, openedModalOverlays: /* @__PURE__ */ shallowReactive([]), dynamicModals: /* @__PURE__ */ shallowReactive([]), modalsContainers: /* @__PURE__ */ ref([]), get(a) { return e.find((n) => { var t, r; return ((r = (t = Z$1(n)) == null ? void 0 : t.value.modalId) == null ? void 0 : r.value) === a; }); }, toggle(a, n) { var r; return (r = Z$1(c.get(a))) == null ? void 0 : r.value.toggle(n); }, open(a) { return c.toggle(a, !0); }, close(a) { return c.toggle(a, !1); }, closeAll() { return Promise.allSettled(o.reduce((a, n) => { const t = Z$1(n), r = t == null ? void 0 : t.value.toggle(!1); return r && a.push(r), a; }, [])); } }); return c; } function Z$1(e) { var o; return (o = e == null ? void 0 : e.exposed) == null ? void 0 : o.modalExposed; } ({ .../* @__PURE__ */ defineComponent({ inheritAttrs: !1 }) }); //#endregion //#region ../send/frontend/src/apps/send/setup.js var i18nStubMessages = { "footer.copywrite": "Thunderbird is part of {mzlaLink}, a wholly owned subsidiary of the not-for-profit Mozilla.org. Portions of this content are ©1998–{currentYear} by individual contributors. Content available under a {creativeCommonsLink}.", "footer.mzlaLinkText": "MZLA Technologies Corporation", "footer.creativeCommonsLinkText": "Creative Commons license" }; var I18nTStub = { name: "i18n-t", props: ["keypath", "tag"], render() { const message = i18nStubMessages[this.keypath] || this.keypath; const slots = this.$slots; return h$2(this.tag || "span", null, message.split(/(\{[^}]+\})/g).map((part) => { const match = part.match(/^\{(.+)\}$/); if (match && slots[match[1]]) return slots[match[1]](); return part; })); } }; function setupApp(app, telemetryAllowed = false) { const pinia = getSharedPinia(); app.use(VueQueryPlugin); app.use(pinia); app.use(Gt); app.use(posthog_default); setPosthogConsent(telemetryAllowed); app.config.globalProperties.$t = (key) => i18nStubMessages[key] || key; app.component("i18n-t", I18nTStub); } function mountApp(app, nodeName) { const vfm = zo$1(); app.use(vfm).mount(nodeName); } //#endregion //#region \0plugin-vue:export-helper var _plugin_vue_export_helper_default = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) target[key] = val; return target; }; //#endregion //#region src/assets/TbproLogo.vue var _sfc_main$3 = {}; var _hoisted_1$8 = { width: "228", height: "40", viewBox: "0 0 228 40", fill: "none", xmlns: "http://www.w3.org/2000/svg" }; function _sfc_render$3(_ctx, _cache) { return openBlock(), createElementBlock("svg", _hoisted_1$8, [..._cache[0] || (_cache[0] = [ createBaseVNode("path", { d: "M183.373 28.797V14.688c0-.286.232-.518.519-.518h5.732a3.933 3.933 0 0 1 0 7.866h-3.759", stroke: "#1373D9", "stroke-width": "2.543" }, null, -1), createBaseVNode("path", { d: "M204.756 12.673a5.436 5.436 0 0 1 1.76 10.578l3.866 5.54-.158.111h-3.356l-3.921-5.618c-.79-1.133.02-2.686 1.401-2.686h.408a2.49 2.49 0 0 0 0-4.98h-4.765V28.83h-2.945V14.664c0-1.1.892-1.991 1.991-1.991h5.719z", fill: "#1373D9" }, null, -1), createBaseVNode("path", { d: "M223.289 15.155a6.943 6.943 0 1 0 2.645 3.081", stroke: "#1373D9", "stroke-width": "2.543", "stroke-linecap": "round" }, null, -1), createBaseVNode("path", { d: "M7.758 28.715V11.35H1.091V7.895h17.092v3.455h-6.667v17.365H7.758zm21.63-16.032c3.425 0 5.82 2.516 5.82 6.061v9.97H31.63v-9.242c0-2.122-1.364-3.637-3.303-3.637-2.091 0-3.819 1.515-3.819 3.394v9.486h-3.697V7.53h3.697V15.2c.94-1.516 2.788-2.516 4.88-2.516zm19.985.364h3.698v15.668h-3.698v-2.091c-.97 1.454-2.788 2.454-4.849 2.454-3.424 0-5.818-2.515-5.818-6.06v-9.971h3.576v9.243c0 2.121 1.363 3.637 3.303 3.637s3.546-1.303 3.788-2.97v-9.91zm15.863-.364c3.425 0 5.819 2.516 5.819 6.061v9.97h-3.576v-9.242c0-2.122-1.364-3.637-3.303-3.637-1.94 0-3.546 1.303-3.788 2.97v9.91H56.69V13.047h3.698v2.091c.97-1.455 2.788-2.455 4.848-2.455zm21.288-5.152h3.697v21.184h-3.697V26.29c-1.242 1.758-3.121 2.788-5.424 2.788-4.152 0-7.183-3.394-7.183-8.212 0-4.789 3.03-8.183 7.183-8.183 2.303 0 4.182 1.03 5.424 2.788v-7.94zM82.1 25.927c2.606 0 4.424-2.122 4.424-5.061 0-2.94-1.818-5.031-4.424-5.031-2.637 0-4.516 2.091-4.516 5.03 0 2.94 1.879 5.062 4.516 5.062zm19.133-.122c1.454 0 3.182-.666 4.06-1.575l2.334 2.424c-1.364 1.454-4.091 2.424-6.364 2.424-4.485 0-8.182-3.424-8.182-8.243 0-4.697 3.515-8.152 7.97-8.152 4.849 0 7.667 3.667 7.667 9.456H96.899c.454 2.151 2.091 3.666 4.334 3.666zm-.031-9.849c-2.06 0-3.727 1.303-4.273 3.364h8.243c-.424-1.97-1.757-3.364-3.97-3.364zm14.055.121c.999-2.09 3.03-3.394 5.606-3.394v3.152c-3.364 0-5.606 2-5.606 4.97v7.91h-3.698V13.047h3.698v3.03zm17.134-3.394c4.151 0 7.182 3.394 7.182 8.183 0 4.818-3.031 8.212-7.182 8.212-2.334 0-4.213-1.06-5.455-2.848v2.485h-3.698V7.53h3.698v8.001c1.242-1.788 3.121-2.849 5.455-2.849zm-1 13.244c2.636 0 4.515-2.122 4.515-5.061 0-2.94-1.879-5.031-4.515-5.031-2.607 0-4.425 2.091-4.425 5.03 0 2.94 1.818 5.062 4.425 5.062zm12.95-15.244c-1.181 0-2.121-1-2.121-2.121 0-1.122.94-2.091 2.121-2.091 1.152 0 2.091.97 2.091 2.09 0 1.122-.939 2.122-2.091 2.122zm-1.878 18.032V13.047h3.697v15.668h-3.697zm11.117-12.638c1-2.09 3.03-3.394 5.606-3.394v3.152c-3.364 0-5.606 2-5.606 4.97v7.91h-3.698V13.047h3.698v3.03zm19.801-8.546h3.697v21.184h-3.697V26.29c-1.243 1.758-3.122 2.788-5.425 2.788-4.152 0-7.182-3.394-7.182-8.212 0-4.789 3.03-8.183 7.182-8.183 2.303 0 4.182 1.03 5.425 2.788v-7.94zm-4.425 18.396c2.606 0 4.425-2.122 4.425-5.061 0-2.94-1.819-5.031-4.425-5.031-2.636 0-4.515 2.091-4.515 5.03 0 2.94 1.879 5.062 4.515 5.062z", fill: "#2A284A" }, null, -1) ])]); } var TbproLogo_default = /*#__PURE__*/ _plugin_vue_export_helper_default(_sfc_main$3, [["render", _sfc_render$3]]); //#endregion //#region ../send/frontend/src/apps/send/components/SpinnerAnimated.vue var _sfc_main$2 = {}; var _hoisted_1$7 = { class: "flex flex-col items-center justify-center p-4 rounded-lg transition duration-500 ease-in-out text-white", role: "status" }; function _sfc_render$2(_ctx, _cache) { return openBlock(), createElementBlock("div", _hoisted_1$7, [..._cache[0] || (_cache[0] = [createBaseVNode("div", null, [createBaseVNode("svg", { class: "animate-spin h-5 w-5 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24" }, [createBaseVNode("circle", { class: "opacity-25 fill", cx: "12", cy: "12", r: "10", "stroke-width": "4" }), createBaseVNode("path", { class: "opacity-75 fill", d: "M4 12a8 8 0 018-8V2.5" })])], -1)])]); } var SpinnerAnimated_default = /*#__PURE__*/ _plugin_vue_export_helper_default(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-611f9e03"]]); //#endregion //#region ../send/frontend/src/apps/common/LoadingComponent.vue?vue&type=script&setup=true&lang.ts var _hoisted_1$6 = { class: "loading", "data-tesid": "loading" }; //#endregion //#region ../send/frontend/src/apps/common/LoadingComponent.vue var LoadingComponent_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({ __name: "LoadingComponent", setup(__props) { return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1$6, [createVNode(SpinnerAnimated_default)]); }; } }), [["__scopeId", "data-v-4be0547e"]]); //#endregion //#region src/assets/WithLoader.vue var WithLoader_default = /* @__PURE__ */ defineComponent({ __name: "WithLoader", props: { isLoading: { type: Boolean } }, setup(__props) { return (_ctx, _cache) => { return __props.isLoading ? (openBlock(), createBlock(LoadingComponent_default, { key: 0 })) : renderSlot(_ctx.$slots, "default", { key: 1 }); }; } }); //#endregion //#region ../send/frontend/src/apps/common/constants.ts var BASE_URL = "https://send.tb.pro"; BASE_URL.includes("send.tb.pro"); //#endregion //#region ../send/frontend/src/lib/clientConfig.ts function isClientExecution() { try { return true; } catch (error) { throw new Error("This code is running on server, it should be executed only on client"); } } isClientExecution(); isClientExecution(); var getEnvName = () => { isClientExecution(); const base_url = "https://send.tb.pro"; if (base_url.includes("send.tb.pro")) return "production"; if (base_url.includes("send-stage.tb.pro")) return "staging"; if (base_url.includes("localhost")) return "development"; }; //#endregion //#region ../send/frontend/src/apps/send/stores/config-store.ts var useConfigStore = defineStore("config", () => { const environmentName = getEnvName(); const isProd = environmentName === "production"; const isStaging = environmentName === "staging"; const isDev = environmentName === "development"; const isThunderbirdHost = computed(() => { return navigator.userAgent.includes("Thunderbird"); }); /** * Check if the URL is a moz-extension:// URL * This is the case for addons/extensions running inside Thunderbird */ const isExtension = computed(() => { return location.href.includes("moz-extension:"); }); /** * Checks if the name if the app is 'addon' * This is helpful to differentiate between the web app and the addon */ const isTbproExtension = computed(() => { return true; }); const _serverUrl = /* @__PURE__ */ ref("https://send-backend.tb.pro"); const _isPublicLogin = /* @__PURE__ */ ref(false); const serverUrl = computed(() => _serverUrl.value); const isPublicLogin = computed(() => _isPublicLogin.value); function setServerUrl(url) { _serverUrl.value = url; } function getAddonId() { const runtimeId = typeof browser !== "undefined" ? browser?.runtime?.id : void 0; if (runtimeId) return `ext-${runtimeId}`; if (serverUrl.value.includes("send-backend.tb.pro")) return "ext-tbpro-add-on@thunderbird.net"; else return "ext-tbpro-addon-stage@thunderbird.net"; } async function openManagementPage() {} return { isProd, isStaging, isDev, serverUrl, setServerUrl, isPublicLogin, isExtension, isTbproExtension, isThunderbirdHost, getAddonId, openManagementPage }; }); //#endregion //#region ../../node_modules/.pnpm/pretty-bytes@6.1.1/node_modules/pretty-bytes/index.js var BYTE_UNITS = [ "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" ]; var BIBYTE_UNITS = [ "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" ]; var BIT_UNITS = [ "b", "kbit", "Mbit", "Gbit", "Tbit", "Pbit", "Ebit", "Zbit", "Ybit" ]; var BIBIT_UNITS = [ "b", "kibit", "Mibit", "Gibit", "Tibit", "Pibit", "Eibit", "Zibit", "Yibit" ]; var toLocaleString = (number, locale, options) => { let result = number; if (typeof locale === "string" || Array.isArray(locale)) result = number.toLocaleString(locale, options); else if (locale === true || options !== void 0) result = number.toLocaleString(void 0, options); return result; }; function prettyBytes(number, options) { if (!Number.isFinite(number)) throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`); options = { bits: false, binary: false, space: true, ...options }; const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS; const separator = options.space ? " " : ""; if (options.signed && number === 0) return ` 0${separator}${UNITS[0]}`; const isNegative = number < 0; const prefix = isNegative ? "-" : options.signed ? "+" : ""; if (isNegative) number = -number; let localeOptions; if (options.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: options.minimumFractionDigits }; if (options.maximumFractionDigits !== void 0) localeOptions = { maximumFractionDigits: options.maximumFractionDigits, ...localeOptions }; if (number < 1) return prefix + toLocaleString(number, options.locale, localeOptions) + separator + UNITS[0]; const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1); number /= (options.binary ? 1024 : 1e3) ** exponent; if (!localeOptions) number = number.toPrecision(3); const numberString = toLocaleString(Number(number), options.locale, localeOptions); const unit = UNITS[exponent]; return prefix + numberString + separator + unit; } //#endregion //#region ../send/frontend/src/lib/const.ts var CONTAINER_TYPE = { CONVERSATION: "CONVERSATION", FOLDER: "FOLDER" }; var ONE_MB_IN_BYTES = 1e3 * 1e3; var MAX_FILE_SIZE_HUMAN_READABLE = prettyBytes(ONE_MB_IN_BYTES * 1e3 * 20); var SPLIT_SIZE = 100 * ONE_MB_IN_BYTES; var BRIDGE_PING = "APP/PING"; var OIDC_USER = "TB/OIDC_USER"; var OIDC_TOKEN = "TB/OIDC_TOKEN"; var SIGN_OUT = "SIGN_OUT"; var SEND_MESSAGE_TO_BRIDGE = "SEND_MESSAGE_TO_BRIDGE"; var GET_LOGIN_STATE = "GET_LOGIN_STATE"; var STORAGE_KEY_AUTH = "STORAGE_KEY_AUTH"; var GET_PENDING_ADDON_TOKEN = "TB/GET_PENDING_ADDON_TOKEN"; //#endregion //#region ../send/frontend/src/composables/useIsExtension.ts function useIsExtension() { const { isThunderbirdHost } = useConfigStore(); const isExtension = computed(() => { if (window.location.href.includes("https://send.tb.pro") && !isThunderbirdHost) return false; return true; }); const isRunningInsideThunderbird = computed(() => { return isThunderbirdHost; }); const isUrlMozExtension = computed(() => { return location.href.includes("moz-extension:"); }); const isAppNameAddon = computed(() => { return true; }); return { isExtension, isRunningInsideThunderbird, isAppNameAddon, isUrlMozExtension, environmentType: computed(() => { if (!isUrlMozExtension.value && isRunningInsideThunderbird.value) return "WEB APP INSIDE THUNDERBIRD"; if (isUrlMozExtension.value && isRunningInsideThunderbird.value) return "EXTENSION INSIDE THUNDERBIRD"; if (!isAppNameAddon.value && !isRunningInsideThunderbird.value) return "WEB APP OUTSIDE THUNDERBIRD"; return "UNKNOWN ENVIRONMENT"; }) }; } //#endregion //#region ../send/frontend/src/apps/send/stores/extension-store.ts var SERVER = `server`; var useExtensionStore = defineStore("extension", () => { const { serverUrl, setServerUrl, getAddonId } = useConfigStore(); const { isRunningInsideThunderbird } = useIsExtension(); const accountId = new URL(location.href).searchParams.get("accountId"); function setAccountConfigured(accountId) { try { browser.cloudFile.updateAccount(accountId, { configured: true }); } catch { console.log(`setAccountConfigured: You're probably running this outside of Thundebird`); } } async function configureExtension(id = accountId) { if (!isRunningInsideThunderbird.value) return; try { const result = await browser.CloudFileAccounts.createAccount(getAddonId(), true); if (!result.success) console.warn(`[extension-store] Failed to create cloud file account: ${result.error}`); else if (result.alreadyExists) console.log(`[extension-store] Cloud file account already exists: ${result.accountId}`); else console.log(`[extension-store] Cloud file account created: ${result.accountId}`); } catch (error) { console.warn(`[extension-store] Error creating cloud file account:`, error); } if (!id) { console.log(`[extension-store] No id provided to configureExtension()`); return; } return browser.storage.local.set({ [id]: { [SERVER]: serverUrl.value } }).catch((error) => { console.log(error); }).then(() => { setAccountConfigured(id); setServerUrl(serverUrl.value); browser.storage.local.get(id).then((accountInfo) => { if (accountInfo[id] && SERVER in accountInfo[id]) { setServerUrl(accountInfo[id][SERVER]); setAccountConfigured(id); } else console.log(`You probably need to wait longer`); }); }); } const sendMessageToBridge = (message) => { window.postMessage({ type: SEND_MESSAGE_TO_BRIDGE, value: message }, window.location.origin); }; return { configureExtension, sendMessageToBridge, serverUrl, setServerUrl }; }); //#endregion //#region ../send/frontend/src/lib/streams.ts var DEFAULT_CHUNK_SIZE = 1024 * 64; function readableToTransformController(controller, overrides) { return { enqueue: controller.enqueue.bind(controller), error: controller.error.bind(controller), terminate: () => {}, desiredSize: controller.desiredSize, ...overrides }; } function transformStream(readable, transformer, oncancel) { try { return readable.pipeThrough(new TransformStream(transformer)); } catch (e) { const reader = readable.getReader(); return new ReadableStream({ start(controller) { if (transformer.start) return transformer.start(readableToTransformController(controller)); }, async pull(controller) { let enqueued = false; while (!enqueued) { const data = await reader.read(); if (data.done) { if (transformer.flush) await transformer.flush(readableToTransformController(controller)); return controller.close(); } await transformer.transform(data.value, readableToTransformController(controller, { enqueue(d) { enqueued = true; controller.enqueue(d); } })); } }, cancel(reason) { readable.cancel(reason); if (oncancel) oncancel(reason); } }); } } var BlobStreamController = class { constructor(blob, size) { this.blob = blob; this.index = 0; this.chunkSize = size || DEFAULT_CHUNK_SIZE; } pull(controller) { return new Promise((resolve, reject) => { const bytesLeft = this.blob.size - this.index; if (bytesLeft <= 0) { controller.close(); return resolve(); } const size = Math.min(this.chunkSize, bytesLeft); const slice = this.blob.slice(this.index, this.index + size); const reader = new FileReader(); reader.onload = () => { if (reader.result instanceof ArrayBuffer) { controller.enqueue(new Uint8Array(reader.result)); resolve(); } }; reader.onerror = reject; reader.readAsArrayBuffer(slice); this.index += size; }); } }; function blobStream(blob, size) { return new ReadableStream(new BlobStreamController(blob, size)); } //#endregion //#region ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js var require_base64_js = /* @__PURE__ */ __commonJSMin(((exports) => { exports.byteLength = byteLength; exports.toByteArray = toByteArray; exports.fromByteArray = fromByteArray; var lookup = []; var revLookup = []; var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array; var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; for (var i = 0, len = code.length; i < len; ++i) { lookup[i] = code[i]; revLookup[code.charCodeAt(i)] = i; } revLookup["-".charCodeAt(0)] = 62; revLookup["_".charCodeAt(0)] = 63; function getLens(b64) { var len = b64.length; if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4"); var validLen = b64.indexOf("="); if (validLen === -1) validLen = len; var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4; return [validLen, placeHoldersLen]; } function byteLength(b64) { var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; } function _byteLength(b64, validLen, placeHoldersLen) { return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen; } function toByteArray(b64) { var tmp; var lens = getLens(b64); var validLen = lens[0]; var placeHoldersLen = lens[1]; var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)); var curByte = 0; var len = placeHoldersLen > 0 ? validLen - 4 : validLen; var i; for (i = 0; i < len; i += 4) { tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)]; arr[curByte++] = tmp >> 16 & 255; arr[curByte++] = tmp >> 8 & 255; arr[curByte++] = tmp & 255; } if (placeHoldersLen === 2) { tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4; arr[curByte++] = tmp & 255; } if (placeHoldersLen === 1) { tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2; arr[curByte++] = tmp >> 8 & 255; arr[curByte++] = tmp & 255; } return arr; } function tripletToBase64(num) { return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63]; } function encodeChunk(uint8, start, end) { var tmp; var output = []; for (var i = start; i < end; i += 3) { tmp = (uint8[i] << 16 & 16711680) + (uint8[i + 1] << 8 & 65280) + (uint8[i + 2] & 255); output.push(tripletToBase64(tmp)); } return output.join(""); } function fromByteArray(uint8) { var tmp; var len = uint8.length; var extraBytes = len % 3; var parts = []; var maxChunkLength = 16383; for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength)); if (extraBytes === 1) { tmp = uint8[len - 1]; parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="); } else if (extraBytes === 2) { tmp = (uint8[len - 2] << 8) + uint8[len - 1]; parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="); } return parts.join(""); } })); //#endregion //#region ../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js var require_ieee754 = /* @__PURE__ */ __commonJSMin(((exports) => { /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ exports.read = function(buffer, offset, isLE, mLen, nBytes) { var e, m; var eLen = nBytes * 8 - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var nBits = -7; var i = isLE ? nBytes - 1 : 0; var d = isLE ? -1 : 1; var s = buffer[offset + i]; i += d; e = s & (1 << -nBits) - 1; s >>= -nBits; nBits += eLen; for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); m = e & (1 << -nBits) - 1; e >>= -nBits; nBits += mLen; for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); if (e === 0) e = 1 - eBias; else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity; else { m = m + Math.pow(2, mLen); e = e - eBias; } return (s ? -1 : 1) * m * Math.pow(2, e - mLen); }; exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { var e, m, c; var eLen = nBytes * 8 - mLen - 1; var eMax = (1 << eLen) - 1; var eBias = eMax >> 1; var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0; var i = isLE ? 0 : nBytes - 1; var d = isLE ? 1 : -1; var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0; value = Math.abs(value); if (isNaN(value) || value === Infinity) { m = isNaN(value) ? 1 : 0; e = eMax; } else { e = Math.floor(Math.log(value) / Math.LN2); if (value * (c = Math.pow(2, -e)) < 1) { e--; c *= 2; } if (e + eBias >= 1) value += rt / c; else value += rt * Math.pow(2, 1 - eBias); if (value * c >= 2) { e++; c /= 2; } if (e + eBias >= eMax) { m = 0; e = eMax; } else if (e + eBias >= 1) { m = (value * c - 1) * Math.pow(2, mLen); e = e + eBias; } else { m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); e = 0; } } for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8); e = e << mLen | m; eLen += mLen; for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8); buffer[offset + i - d] |= s * 128; }; })); //#endregion //#region ../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var require_buffer = /* @__PURE__ */ __commonJSMin(((exports) => { var base64 = require_base64_js(); var ieee754 = require_ieee754(); var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null; exports.Buffer = Buffer; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; var K_MAX_LENGTH = 2147483647; exports.kMaxLength = K_MAX_LENGTH; /** * If `Buffer.TYPED_ARRAY_SUPPORT`: * === true Use Uint8Array implementation (fastest) * === false Print warning and recommend using `buffer` v4.x which has an Object * implementation (most compatible, even IE6) * * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, * Opera 11.6+, iOS 4.2+. * * We report that the browser does not support typed arrays if the are not subclassable * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array` * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support * for __proto__ and has a buggy typed array implementation. */ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport(); if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."); function typedArraySupport() { try { const arr = new Uint8Array(1); const proto = { foo: function() { return 42; } }; Object.setPrototypeOf(proto, Uint8Array.prototype); Object.setPrototypeOf(arr, proto); return arr.foo() === 42; } catch (e) { return false; } } Object.defineProperty(Buffer.prototype, "parent", { enumerable: true, get: function() { if (!Buffer.isBuffer(this)) return void 0; return this.buffer; } }); Object.defineProperty(Buffer.prototype, "offset", { enumerable: true, get: function() { if (!Buffer.isBuffer(this)) return void 0; return this.byteOffset; } }); function createBuffer(length) { if (length > K_MAX_LENGTH) throw new RangeError("The value \"" + length + "\" is invalid for option \"size\""); const buf = new Uint8Array(length); Object.setPrototypeOf(buf, Buffer.prototype); return buf; } /** * The Buffer constructor returns instances of `Uint8Array` that have their * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of * `Uint8Array`, so the returned instances will have all the node `Buffer` methods * and the `Uint8Array` methods. Square bracket notation works as expected -- it * returns a single octet. * * The `Uint8Array` prototype remains unmodified. */ function Buffer(arg, encodingOrOffset, length) { if (typeof arg === "number") { if (typeof encodingOrOffset === "string") throw new TypeError("The \"string\" argument must be of type string. Received type number"); return allocUnsafe(arg); } return from(arg, encodingOrOffset, length); } Buffer.poolSize = 8192; function from(value, encodingOrOffset, length) { if (typeof value === "string") return fromString(value, encodingOrOffset); if (ArrayBuffer.isView(value)) return fromArrayView(value); if (value == null) throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) return fromArrayBuffer(value, encodingOrOffset, length); if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) return fromArrayBuffer(value, encodingOrOffset, length); if (typeof value === "number") throw new TypeError("The \"value\" argument must not be of type number. Received type number"); const valueOf = value.valueOf && value.valueOf(); if (valueOf != null && valueOf !== value) return Buffer.from(valueOf, encodingOrOffset, length); const b = fromObject(value); if (b) return b; if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") return Buffer.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length); throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value); } /** * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError * if value is a number. * Buffer.from(str[, encoding]) * Buffer.from(array) * Buffer.from(buffer) * Buffer.from(arrayBuffer[, byteOffset[, length]]) **/ Buffer.from = function(value, encodingOrOffset, length) { return from(value, encodingOrOffset, length); }; Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); Object.setPrototypeOf(Buffer, Uint8Array); function assertSize(size) { if (typeof size !== "number") throw new TypeError("\"size\" argument must be of type number"); else if (size < 0) throw new RangeError("The value \"" + size + "\" is invalid for option \"size\""); } function alloc(size, fill, encoding) { assertSize(size); if (size <= 0) return createBuffer(size); if (fill !== void 0) return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill); return createBuffer(size); } /** * Creates a new filled Buffer instance. * alloc(size[, fill[, encoding]]) **/ Buffer.alloc = function(size, fill, encoding) { return alloc(size, fill, encoding); }; function allocUnsafe(size) { assertSize(size); return createBuffer(size < 0 ? 0 : checked(size) | 0); } /** * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. * */ Buffer.allocUnsafe = function(size) { return allocUnsafe(size); }; /** * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. */ Buffer.allocUnsafeSlow = function(size) { return allocUnsafe(size); }; function fromString(string, encoding) { if (typeof encoding !== "string" || encoding === "") encoding = "utf8"; if (!Buffer.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding); const length = byteLength(string, encoding) | 0; let buf = createBuffer(length); const actual = buf.write(string, encoding); if (actual !== length) buf = buf.slice(0, actual); return buf; } function fromArrayLike(array) { const length = array.length < 0 ? 0 : checked(array.length) | 0; const buf = createBuffer(length); for (let i = 0; i < length; i += 1) buf[i] = array[i] & 255; return buf; } function fromArrayView(arrayView) { if (isInstance(arrayView, Uint8Array)) { const copy = new Uint8Array(arrayView); return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength); } return fromArrayLike(arrayView); } function fromArrayBuffer(array, byteOffset, length) { if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError("\"offset\" is outside of buffer bounds"); if (array.byteLength < byteOffset + (length || 0)) throw new RangeError("\"length\" is outside of buffer bounds"); let buf; if (byteOffset === void 0 && length === void 0) buf = new Uint8Array(array); else if (length === void 0) buf = new Uint8Array(array, byteOffset); else buf = new Uint8Array(array, byteOffset, length); Object.setPrototypeOf(buf, Buffer.prototype); return buf; } function fromObject(obj) { if (Buffer.isBuffer(obj)) { const len = checked(obj.length) | 0; const buf = createBuffer(len); if (buf.length === 0) return buf; obj.copy(buf, 0, 0, len); return buf; } if (obj.length !== void 0) { if (typeof obj.length !== "number" || numberIsNaN(obj.length)) return createBuffer(0); return fromArrayLike(obj); } if (obj.type === "Buffer" && Array.isArray(obj.data)) return fromArrayLike(obj.data); } function checked(length) { if (length >= K_MAX_LENGTH) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes"); return length | 0; } function SlowBuffer(length) { if (+length != length) length = 0; return Buffer.alloc(+length); } Buffer.isBuffer = function isBuffer(b) { return b != null && b._isBuffer === true && b !== Buffer.prototype; }; Buffer.compare = function compare(a, b) { if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength); if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength); if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) throw new TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array"); if (a === b) return 0; let x = a.length; let y = b.length; for (let i = 0, len = Math.min(x, y); i < len; ++i) if (a[i] !== b[i]) { x = a[i]; y = b[i]; break; } if (x < y) return -1; if (y < x) return 1; return 0; }; Buffer.isEncoding = function isEncoding(encoding) { switch (String(encoding).toLowerCase()) { case "hex": case "utf8": case "utf-8": case "ascii": case "latin1": case "binary": case "base64": case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return true; default: return false; } }; Buffer.concat = function concat(list, length) { if (!Array.isArray(list)) throw new TypeError("\"list\" argument must be an Array of Buffers"); if (list.length === 0) return Buffer.alloc(0); let i; if (length === void 0) { length = 0; for (i = 0; i < list.length; ++i) length += list[i].length; } const buffer = Buffer.allocUnsafe(length); let pos = 0; for (i = 0; i < list.length; ++i) { let buf = list[i]; if (isInstance(buf, Uint8Array)) if (pos + buf.length > buffer.length) { if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf); buf.copy(buffer, pos); } else Uint8Array.prototype.set.call(buffer, buf, pos); else if (!Buffer.isBuffer(buf)) throw new TypeError("\"list\" argument must be an Array of Buffers"); else buf.copy(buffer, pos); pos += buf.length; } return buffer; }; function byteLength(string, encoding) { if (Buffer.isBuffer(string)) return string.length; if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) return string.byteLength; if (typeof string !== "string") throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type " + typeof string); const len = string.length; const mustMatch = arguments.length > 2 && arguments[2] === true; if (!mustMatch && len === 0) return 0; let loweredCase = false; for (;;) switch (encoding) { case "ascii": case "latin1": case "binary": return len; case "utf8": case "utf-8": return utf8ToBytes(string).length; case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return len * 2; case "hex": return len >>> 1; case "base64": return base64ToBytes(string).length; default: if (loweredCase) return mustMatch ? -1 : utf8ToBytes(string).length; encoding = ("" + encoding).toLowerCase(); loweredCase = true; } } Buffer.byteLength = byteLength; function slowToString(encoding, start, end) { let loweredCase = false; if (start === void 0 || start < 0) start = 0; if (start > this.length) return ""; if (end === void 0 || end > this.length) end = this.length; if (end <= 0) return ""; end >>>= 0; start >>>= 0; if (end <= start) return ""; if (!encoding) encoding = "utf8"; while (true) switch (encoding) { case "hex": return hexSlice(this, start, end); case "utf8": case "utf-8": return utf8Slice(this, start, end); case "ascii": return asciiSlice(this, start, end); case "latin1": case "binary": return latin1Slice(this, start, end); case "base64": return base64Slice(this, start, end); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return utf16leSlice(this, start, end); default: if (loweredCase) throw new TypeError("Unknown encoding: " + encoding); encoding = (encoding + "").toLowerCase(); loweredCase = true; } } Buffer.prototype._isBuffer = true; function swap(b, n, m) { const i = b[n]; b[n] = b[m]; b[m] = i; } Buffer.prototype.swap16 = function swap16() { const len = this.length; if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits"); for (let i = 0; i < len; i += 2) swap(this, i, i + 1); return this; }; Buffer.prototype.swap32 = function swap32() { const len = this.length; if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits"); for (let i = 0; i < len; i += 4) { swap(this, i, i + 3); swap(this, i + 1, i + 2); } return this; }; Buffer.prototype.swap64 = function swap64() { const len = this.length; if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits"); for (let i = 0; i < len; i += 8) { swap(this, i, i + 7); swap(this, i + 1, i + 6); swap(this, i + 2, i + 5); swap(this, i + 3, i + 4); } return this; }; Buffer.prototype.toString = function toString() { const length = this.length; if (length === 0) return ""; if (arguments.length === 0) return utf8Slice(this, 0, length); return slowToString.apply(this, arguments); }; Buffer.prototype.toLocaleString = Buffer.prototype.toString; Buffer.prototype.equals = function equals(b) { if (!Buffer.isBuffer(b)) throw new TypeError("Argument must be a Buffer"); if (this === b) return true; return Buffer.compare(this, b) === 0; }; Buffer.prototype.inspect = function inspect() { let str = ""; const max = exports.INSPECT_MAX_BYTES; str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim(); if (this.length > max) str += " ... "; return ""; }; if (customInspectSymbol) Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) target = Buffer.from(target, target.offset, target.byteLength); if (!Buffer.isBuffer(target)) throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type " + typeof target); if (start === void 0) start = 0; if (end === void 0) end = target ? target.length : 0; if (thisStart === void 0) thisStart = 0; if (thisEnd === void 0) thisEnd = this.length; if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError("out of range index"); if (thisStart >= thisEnd && start >= end) return 0; if (thisStart >= thisEnd) return -1; if (start >= end) return 1; start >>>= 0; end >>>= 0; thisStart >>>= 0; thisEnd >>>= 0; if (this === target) return 0; let x = thisEnd - thisStart; let y = end - start; const len = Math.min(x, y); const thisCopy = this.slice(thisStart, thisEnd); const targetCopy = target.slice(start, end); for (let i = 0; i < len; ++i) if (thisCopy[i] !== targetCopy[i]) { x = thisCopy[i]; y = targetCopy[i]; break; } if (x < y) return -1; if (y < x) return 1; return 0; }; function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { if (buffer.length === 0) return -1; if (typeof byteOffset === "string") { encoding = byteOffset; byteOffset = 0; } else if (byteOffset > 2147483647) byteOffset = 2147483647; else if (byteOffset < -2147483648) byteOffset = -2147483648; byteOffset = +byteOffset; if (numberIsNaN(byteOffset)) byteOffset = dir ? 0 : buffer.length - 1; if (byteOffset < 0) byteOffset = buffer.length + byteOffset; if (byteOffset >= buffer.length) if (dir) return -1; else byteOffset = buffer.length - 1; else if (byteOffset < 0) if (dir) byteOffset = 0; else return -1; if (typeof val === "string") val = Buffer.from(val, encoding); if (Buffer.isBuffer(val)) { if (val.length === 0) return -1; return arrayIndexOf(buffer, val, byteOffset, encoding, dir); } else if (typeof val === "number") { val = val & 255; if (typeof Uint8Array.prototype.indexOf === "function") if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset); else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset); return arrayIndexOf(buffer, [val], byteOffset, encoding, dir); } throw new TypeError("val must be string, number or Buffer"); } function arrayIndexOf(arr, val, byteOffset, encoding, dir) { let indexSize = 1; let arrLength = arr.length; let valLength = val.length; if (encoding !== void 0) { encoding = String(encoding).toLowerCase(); if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") { if (arr.length < 2 || val.length < 2) return -1; indexSize = 2; arrLength /= 2; valLength /= 2; byteOffset /= 2; } } function read(buf, i) { if (indexSize === 1) return buf[i]; else return buf.readUInt16BE(i * indexSize); } let i; if (dir) { let foundIndex = -1; for (i = byteOffset; i < arrLength; i++) if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { if (foundIndex === -1) foundIndex = i; if (i - foundIndex + 1 === valLength) return foundIndex * indexSize; } else { if (foundIndex !== -1) i -= i - foundIndex; foundIndex = -1; } } else { if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength; for (i = byteOffset; i >= 0; i--) { let found = true; for (let j = 0; j < valLength; j++) if (read(arr, i + j) !== read(val, j)) { found = false; break; } if (found) return i; } } return -1; } Buffer.prototype.includes = function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }; Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }; Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false); }; function hexWrite(buf, string, offset, length) { offset = Number(offset) || 0; const remaining = buf.length - offset; if (!length) length = remaining; else { length = Number(length); if (length > remaining) length = remaining; } const strLen = string.length; if (length > strLen / 2) length = strLen / 2; let i; for (i = 0; i < length; ++i) { const parsed = parseInt(string.substr(i * 2, 2), 16); if (numberIsNaN(parsed)) return i; buf[offset + i] = parsed; } return i; } function utf8Write(buf, string, offset, length) { return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length); } function asciiWrite(buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length); } function base64Write(buf, string, offset, length) { return blitBuffer(base64ToBytes(string), buf, offset, length); } function ucs2Write(buf, string, offset, length) { return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length); } Buffer.prototype.write = function write(string, offset, length, encoding) { if (offset === void 0) { encoding = "utf8"; length = this.length; offset = 0; } else if (length === void 0 && typeof offset === "string") { encoding = offset; length = this.length; offset = 0; } else if (isFinite(offset)) { offset = offset >>> 0; if (isFinite(length)) { length = length >>> 0; if (encoding === void 0) encoding = "utf8"; } else { encoding = length; length = void 0; } } else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); const remaining = this.length - offset; if (length === void 0 || length > remaining) length = remaining; if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw new RangeError("Attempt to write outside buffer bounds"); if (!encoding) encoding = "utf8"; let loweredCase = false; for (;;) switch (encoding) { case "hex": return hexWrite(this, string, offset, length); case "utf8": case "utf-8": return utf8Write(this, string, offset, length); case "ascii": case "latin1": case "binary": return asciiWrite(this, string, offset, length); case "base64": return base64Write(this, string, offset, length); case "ucs2": case "ucs-2": case "utf16le": case "utf-16le": return ucs2Write(this, string, offset, length); default: if (loweredCase) throw new TypeError("Unknown encoding: " + encoding); encoding = ("" + encoding).toLowerCase(); loweredCase = true; } }; Buffer.prototype.toJSON = function toJSON() { return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) }; }; function base64Slice(buf, start, end) { if (start === 0 && end === buf.length) return base64.fromByteArray(buf); else return base64.fromByteArray(buf.slice(start, end)); } function utf8Slice(buf, start, end) { end = Math.min(buf.length, end); const res = []; let i = start; while (i < end) { const firstByte = buf[i]; let codePoint = null; let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1; if (i + bytesPerSequence <= end) { let secondByte, thirdByte, fourthByte, tempCodePoint; switch (bytesPerSequence) { case 1: if (firstByte < 128) codePoint = firstByte; break; case 2: secondByte = buf[i + 1]; if ((secondByte & 192) === 128) { tempCodePoint = (firstByte & 31) << 6 | secondByte & 63; if (tempCodePoint > 127) codePoint = tempCodePoint; } break; case 3: secondByte = buf[i + 1]; thirdByte = buf[i + 2]; if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) { tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63; if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) codePoint = tempCodePoint; } break; case 4: secondByte = buf[i + 1]; thirdByte = buf[i + 2]; fourthByte = buf[i + 3]; if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) { tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63; if (tempCodePoint > 65535 && tempCodePoint < 1114112) codePoint = tempCodePoint; } } } if (codePoint === null) { codePoint = 65533; bytesPerSequence = 1; } else if (codePoint > 65535) { codePoint -= 65536; res.push(codePoint >>> 10 & 1023 | 55296); codePoint = 56320 | codePoint & 1023; } res.push(codePoint); i += bytesPerSequence; } return decodeCodePointsArray(res); } var MAX_ARGUMENTS_LENGTH = 4096; function decodeCodePointsArray(codePoints) { const len = codePoints.length; if (len <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints); let res = ""; let i = 0; while (i < len) res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)); return res; } function asciiSlice(buf, start, end) { let ret = ""; end = Math.min(buf.length, end); for (let i = start; i < end; ++i) ret += String.fromCharCode(buf[i] & 127); return ret; } function latin1Slice(buf, start, end) { let ret = ""; end = Math.min(buf.length, end); for (let i = start; i < end; ++i) ret += String.fromCharCode(buf[i]); return ret; } function hexSlice(buf, start, end) { const len = buf.length; if (!start || start < 0) start = 0; if (!end || end < 0 || end > len) end = len; let out = ""; for (let i = start; i < end; ++i) out += hexSliceLookupTable[buf[i]]; return out; } function utf16leSlice(buf, start, end) { const bytes = buf.slice(start, end); let res = ""; for (let i = 0; i < bytes.length - 1; i += 2) res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256); return res; } Buffer.prototype.slice = function slice(start, end) { const len = this.length; start = ~~start; end = end === void 0 ? len : ~~end; if (start < 0) { start += len; if (start < 0) start = 0; } else if (start > len) start = len; if (end < 0) { end += len; if (end < 0) end = 0; } else if (end > len) end = len; if (end < start) end = start; const newBuf = this.subarray(start, end); Object.setPrototypeOf(newBuf, Buffer.prototype); return newBuf; }; function checkOffset(offset, ext, length) { if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint"); if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length"); } Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); let val = this[offset]; let mul = 1; let i = 0; while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul; return val; }; Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); let val = this[offset + --byteLength]; let mul = 1; while (byteLength > 0 && (mul *= 256)) val += this[offset + --byteLength] * mul; return val; }; Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }; Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | this[offset + 1] << 8; }; Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] << 8 | this[offset + 1]; }; Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216; }; Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]); }; Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; const last = this[offset + 7]; if (first === void 0 || last === void 0) boundsError(offset, this.length - 8); const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24; const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24; return BigInt(lo) + (BigInt(hi) << BigInt(32)); }); Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; const last = this[offset + 7]; if (first === void 0 || last === void 0) boundsError(offset, this.length - 8); const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last; return (BigInt(hi) << BigInt(32)) + BigInt(lo); }); Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); let val = this[offset]; let mul = 1; let i = 0; while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul; mul *= 128; if (val >= mul) val -= Math.pow(2, 8 * byteLength); return val; }; Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); let i = byteLength; let mul = 1; let val = this[offset + --i]; while (i > 0 && (mul *= 256)) val += this[offset + --i] * mul; mul *= 128; if (val >= mul) val -= Math.pow(2, 8 * byteLength); return val; }; Buffer.prototype.readInt8 = function readInt8(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); if (!(this[offset] & 128)) return this[offset]; return (255 - this[offset] + 1) * -1; }; Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); const val = this[offset] | this[offset + 1] << 8; return val & 32768 ? val | 4294901760 : val; }; Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); const val = this[offset + 1] | this[offset] << 8; return val & 32768 ? val | 4294901760 : val; }; Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24; }; Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]; }; Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; const last = this[offset + 7]; if (first === void 0 || last === void 0) boundsError(offset, this.length - 8); const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24); return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24); }); Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) { offset = offset >>> 0; validateNumber(offset, "offset"); const first = this[offset]; const last = this[offset + 7]; if (first === void 0 || last === void 0) boundsError(offset, this.length - 8); const val = (first << 24) + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset]; return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last); }); Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee754.read(this, offset, true, 23, 4); }; Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ieee754.read(this, offset, false, 23, 4); }; Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee754.read(this, offset, true, 52, 8); }; Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return ieee754.read(this, offset, false, 52, 8); }; function checkInt(buf, value, offset, ext, max, min) { if (!Buffer.isBuffer(buf)) throw new TypeError("\"buffer\" argument must be a Buffer instance"); if (value > max || value < min) throw new RangeError("\"value\" argument is out of bounds"); if (offset + ext > buf.length) throw new RangeError("Index out of range"); } Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { const maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } let mul = 1; let i = 0; this[offset] = value & 255; while (++i < byteLength && (mul *= 256)) this[offset + i] = value / mul & 255; return offset + byteLength; }; Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { const maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } let i = byteLength - 1; let mul = 1; this[offset + i] = value & 255; while (--i >= 0 && (mul *= 256)) this[offset + i] = value / mul & 255; return offset + byteLength; }; Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 255, 0); this[offset] = value & 255; return offset + 1; }; Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 65535, 0); this[offset] = value & 255; this[offset + 1] = value >>> 8; return offset + 2; }; Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 65535, 0); this[offset] = value >>> 8; this[offset + 1] = value & 255; return offset + 2; }; Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0); this[offset + 3] = value >>> 24; this[offset + 2] = value >>> 16; this[offset + 1] = value >>> 8; this[offset] = value & 255; return offset + 4; }; Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0); this[offset] = value >>> 24; this[offset + 1] = value >>> 16; this[offset + 2] = value >>> 8; this[offset + 3] = value & 255; return offset + 4; }; function wrtBigUInt64LE(buf, value, offset, min, max) { checkIntBI(value, min, max, buf, offset, 7); let lo = Number(value & BigInt(4294967295)); buf[offset++] = lo; lo = lo >> 8; buf[offset++] = lo; lo = lo >> 8; buf[offset++] = lo; lo = lo >> 8; buf[offset++] = lo; let hi = Number(value >> BigInt(32) & BigInt(4294967295)); buf[offset++] = hi; hi = hi >> 8; buf[offset++] = hi; hi = hi >> 8; buf[offset++] = hi; hi = hi >> 8; buf[offset++] = hi; return offset; } function wrtBigUInt64BE(buf, value, offset, min, max) { checkIntBI(value, min, max, buf, offset, 7); let lo = Number(value & BigInt(4294967295)); buf[offset + 7] = lo; lo = lo >> 8; buf[offset + 6] = lo; lo = lo >> 8; buf[offset + 5] = lo; lo = lo >> 8; buf[offset + 4] = lo; let hi = Number(value >> BigInt(32) & BigInt(4294967295)); buf[offset + 3] = hi; hi = hi >> 8; buf[offset + 2] = hi; hi = hi >> 8; buf[offset + 1] = hi; hi = hi >> 8; buf[offset] = hi; return offset + 8; } Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) { return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff")); }); Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { const limit = Math.pow(2, 8 * byteLength - 1); checkInt(this, value, offset, byteLength, limit - 1, -limit); } let i = 0; let mul = 1; let sub = 0; this[offset] = value & 255; while (++i < byteLength && (mul *= 256)) { if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1; this[offset + i] = (value / mul >> 0) - sub & 255; } return offset + byteLength; }; Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { const limit = Math.pow(2, 8 * byteLength - 1); checkInt(this, value, offset, byteLength, limit - 1, -limit); } let i = byteLength - 1; let mul = 1; let sub = 0; this[offset + i] = value & 255; while (--i >= 0 && (mul *= 256)) { if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1; this[offset + i] = (value / mul >> 0) - sub & 255; } return offset + byteLength; }; Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 127, -128); if (value < 0) value = 255 + value + 1; this[offset] = value & 255; return offset + 1; }; Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768); this[offset] = value & 255; this[offset + 1] = value >>> 8; return offset + 2; }; Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768); this[offset] = value >>> 8; this[offset + 1] = value & 255; return offset + 2; }; Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648); this[offset] = value & 255; this[offset + 1] = value >>> 8; this[offset + 2] = value >>> 16; this[offset + 3] = value >>> 24; return offset + 4; }; Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648); if (value < 0) value = 4294967295 + value + 1; this[offset] = value >>> 24; this[offset + 1] = value >>> 16; this[offset + 2] = value >>> 8; this[offset + 3] = value & 255; return offset + 4; }; Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) { return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); }); Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) { return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff")); }); function checkIEEE754(buf, value, offset, ext, max, min) { if (offset + ext > buf.length) throw new RangeError("Index out of range"); if (offset < 0) throw new RangeError("Index out of range"); } function writeFloat(buf, value, offset, littleEndian, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22); ieee754.write(buf, value, offset, littleEndian, 23, 4); return offset + 4; } Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert); }; Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert); }; function writeDouble(buf, value, offset, littleEndian, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292); ieee754.write(buf, value, offset, littleEndian, 52, 8); return offset + 8; } Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert); }; Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert); }; Buffer.prototype.copy = function copy(target, targetStart, start, end) { if (!Buffer.isBuffer(target)) throw new TypeError("argument should be a Buffer"); if (!start) start = 0; if (!end && end !== 0) end = this.length; if (targetStart >= target.length) targetStart = target.length; if (!targetStart) targetStart = 0; if (end > 0 && end < start) end = start; if (end === start) return 0; if (target.length === 0 || this.length === 0) return 0; if (targetStart < 0) throw new RangeError("targetStart out of bounds"); if (start < 0 || start >= this.length) throw new RangeError("Index out of range"); if (end < 0) throw new RangeError("sourceEnd out of bounds"); if (end > this.length) end = this.length; if (target.length - targetStart < end - start) end = target.length - targetStart + start; const len = end - start; if (this === target && typeof Uint8Array.prototype.copyWithin === "function") this.copyWithin(targetStart, start, end); else Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart); return len; }; Buffer.prototype.fill = function fill(val, start, end, encoding) { if (typeof val === "string") { if (typeof start === "string") { encoding = start; start = 0; end = this.length; } else if (typeof end === "string") { encoding = end; end = this.length; } if (encoding !== void 0 && typeof encoding !== "string") throw new TypeError("encoding must be a string"); if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding); if (val.length === 1) { const code = val.charCodeAt(0); if (encoding === "utf8" && code < 128 || encoding === "latin1") val = code; } } else if (typeof val === "number") val = val & 255; else if (typeof val === "boolean") val = Number(val); if (start < 0 || this.length < start || this.length < end) throw new RangeError("Out of range index"); if (end <= start) return this; start = start >>> 0; end = end === void 0 ? this.length : end >>> 0; if (!val) val = 0; let i; if (typeof val === "number") for (i = start; i < end; ++i) this[i] = val; else { const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding); const len = bytes.length; if (len === 0) throw new TypeError("The value \"" + val + "\" is invalid for argument \"value\""); for (i = 0; i < end - start; ++i) this[i + start] = bytes[i % len]; } return this; }; var errors = {}; function E(sym, getMessage, Base) { errors[sym] = class NodeError extends Base { constructor() { super(); Object.defineProperty(this, "message", { value: getMessage.apply(this, arguments), writable: true, configurable: true }); this.name = `${this.name} [${sym}]`; this.stack; delete this.name; } get code() { return sym; } set code(value) { Object.defineProperty(this, "code", { configurable: true, enumerable: true, value, writable: true }); } toString() { return `${this.name} [${sym}]: ${this.message}`; } }; } E("ERR_BUFFER_OUT_OF_BOUNDS", function(name) { if (name) return `${name} is outside of buffer bounds`; return "Attempt to access memory outside buffer bounds"; }, RangeError); E("ERR_INVALID_ARG_TYPE", function(name, actual) { return `The "${name}" argument must be of type number. Received type ${typeof actual}`; }, TypeError); E("ERR_OUT_OF_RANGE", function(str, range, input) { let msg = `The value of "${str}" is out of range.`; let received = input; if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) received = addNumericalSeparator(String(input)); else if (typeof input === "bigint") { received = String(input); if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) received = addNumericalSeparator(received); received += "n"; } msg += ` It must be ${range}. Received ${received}`; return msg; }, RangeError); function addNumericalSeparator(val) { let res = ""; let i = val.length; const start = val[0] === "-" ? 1 : 0; for (; i >= start + 4; i -= 3) res = `_${val.slice(i - 3, i)}${res}`; return `${val.slice(0, i)}${res}`; } function checkBounds(buf, offset, byteLength) { validateNumber(offset, "offset"); if (buf[offset] === void 0 || buf[offset + byteLength] === void 0) boundsError(offset, buf.length - (byteLength + 1)); } function checkIntBI(value, min, max, buf, offset, byteLength) { if (value > max || value < min) { const n = typeof min === "bigint" ? "n" : ""; let range; if (byteLength > 3) if (min === 0 || min === BigInt(0)) range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`; else range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength + 1) * 8 - 1}${n}`; else range = `>= ${min}${n} and <= ${max}${n}`; throw new errors.ERR_OUT_OF_RANGE("value", range, value); } checkBounds(buf, offset, byteLength); } function validateNumber(value, name) { if (typeof value !== "number") throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value); } function boundsError(value, length, type) { if (Math.floor(value) !== value) { validateNumber(value, type); throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value); } if (length < 0) throw new errors.ERR_BUFFER_OUT_OF_BOUNDS(); throw new errors.ERR_OUT_OF_RANGE(type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value); } var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g; function base64clean(str) { str = str.split("=")[0]; str = str.trim().replace(INVALID_BASE64_RE, ""); if (str.length < 2) return ""; while (str.length % 4 !== 0) str = str + "="; return str; } function utf8ToBytes(string, units) { units = units || Infinity; let codePoint; const length = string.length; let leadSurrogate = null; const bytes = []; for (let i = 0; i < length; ++i) { codePoint = string.charCodeAt(i); if (codePoint > 55295 && codePoint < 57344) { if (!leadSurrogate) { if (codePoint > 56319) { if ((units -= 3) > -1) bytes.push(239, 191, 189); continue; } else if (i + 1 === length) { if ((units -= 3) > -1) bytes.push(239, 191, 189); continue; } leadSurrogate = codePoint; continue; } if (codePoint < 56320) { if ((units -= 3) > -1) bytes.push(239, 191, 189); leadSurrogate = codePoint; continue; } codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536; } else if (leadSurrogate) { if ((units -= 3) > -1) bytes.push(239, 191, 189); } leadSurrogate = null; if (codePoint < 128) { if ((units -= 1) < 0) break; bytes.push(codePoint); } else if (codePoint < 2048) { if ((units -= 2) < 0) break; bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128); } else if (codePoint < 65536) { if ((units -= 3) < 0) break; bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); } else if (codePoint < 1114112) { if ((units -= 4) < 0) break; bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128); } else throw new Error("Invalid code point"); } return bytes; } function asciiToBytes(str) { const byteArray = []; for (let i = 0; i < str.length; ++i) byteArray.push(str.charCodeAt(i) & 255); return byteArray; } function utf16leToBytes(str, units) { let c, hi, lo; const byteArray = []; for (let i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break; c = str.charCodeAt(i); hi = c >> 8; lo = c % 256; byteArray.push(lo); byteArray.push(hi); } return byteArray; } function base64ToBytes(str) { return base64.toByteArray(base64clean(str)); } function blitBuffer(src, dst, offset, length) { let i; for (i = 0; i < length; ++i) { if (i + offset >= dst.length || i >= src.length) break; dst[i + offset] = src[i]; } return i; } function isInstance(obj, type) { return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name; } function numberIsNaN(obj) { return obj !== obj; } var hexSliceLookupTable = (function() { const alphabet = "0123456789abcdef"; const table = new Array(256); for (let i = 0; i < 16; ++i) { const i16 = i * 16; for (let j = 0; j < 16; ++j) table[i16 + j] = alphabet[i] + alphabet[j]; } return table; })(); function defineBigIntMethod(fn) { return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn; } function BufferBigIntNotDefined() { throw new Error("BigInt not supported"); } })); //#endregion //#region ../../node_modules/.pnpm/global@4.4.0/node_modules/global/window.js var require_window = /* @__PURE__ */ __commonJSMin(((exports, module) => { var win; if (typeof window !== "undefined") win = window; else if (typeof global !== "undefined") win = global; else if (typeof self !== "undefined") win = self; else win = {}; module.exports = win; })); //#endregion //#region __vite-browser-external var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((exports, module) => { module.exports = {}; })); //#endregion //#region ../../node_modules/.pnpm/get-random-values@3.0.0/node_modules/get-random-values/index.js var require_get_random_values = /* @__PURE__ */ __commonJSMin(((exports, module) => { var window = require_window(); var nodeCrypto = require___vite_browser_external(); /** * @template {ArrayBufferView | null} T * @param {T} buf * @returns {T} */ function getRandomValues(buf) { if (window.crypto && window.crypto.getRandomValues) return window.crypto.getRandomValues(buf); if (typeof window.msCrypto === "object" && typeof window.msCrypto.getRandomValues === "function") return window.msCrypto.getRandomValues(buf); if (nodeCrypto.randomBytes) { if (!(buf instanceof Uint8Array)) throw new TypeError("expected Uint8Array"); if (buf.length > 65536) { var e = /* @__PURE__ */ new Error(); e.code = 22; e.message = "Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length (" + buf.length + ") exceeds the number of bytes of entropy available via this API (65536)."; e.name = "QuotaExceededError"; throw e; } var bytes = nodeCrypto.randomBytes(buf.length); buf.set(bytes); return buf; } else throw new Error("No secure random number generator available."); } module.exports = getRandomValues; })); //#endregion //#region ../send/frontend/src/lib/ece.ts var import_buffer = require_buffer(); var import_get_random_values = /* @__PURE__ */ __toESM$2(require_get_random_values(), 1); var NONCE_LENGTH = 12; var TAG_LENGTH = 16; var KEY_LENGTH = 16; var MODE_ENCRYPT = "encrypt"; var MODE_DECRYPT = "decrypt"; var ECE_RECORD_SIZE = 1024 * 64; function generateSalt(len) { const randSalt = new Uint8Array(len); (0, import_get_random_values.default)(randSalt); return randSalt.buffer; } var ECETransformer = class { constructor(mode, ikm, rs, salt) { this.mode = mode; this.prevChunk; this.seq = 0; this.firstchunk = true; this.rs = rs; this.key = ikm; this.salt = salt; } async generateNonceBase() { const base = await window.crypto.subtle.exportKey("raw", this.key); const exported = new Uint8Array(base); return import_buffer.Buffer.from(exported.slice(0, NONCE_LENGTH)); } generateNonce(seq) { if (seq > 4294967295) throw new Error("record sequence number exceeds limit"); const nonce = import_buffer.Buffer.from(this.nonceBase); const xor = (nonce.readUIntBE(nonce.length - 4, 4) ^ seq) >>> 0; nonce.writeUIntBE(xor, nonce.length - 4, 4); return nonce; } pad(data, isLast) { const len = data.length; if (len + TAG_LENGTH >= this.rs) throw new Error("data too large for record size"); if (isLast) { const padding = import_buffer.Buffer.alloc(1); padding.writeUInt8(2, 0); return import_buffer.Buffer.concat([data, padding]); } else { const padding = import_buffer.Buffer.alloc(this.rs - len - TAG_LENGTH); padding.fill(0); padding.writeUInt8(1, 0); return import_buffer.Buffer.concat([data, padding]); } } unpad(data, isLast) { for (let i = data.length - 1; i >= 0; i--) if (data[i]) { if (isLast) { if (data[i] !== 2) throw new Error("delimiter of final record is not 2"); } else if (data[i] !== 1) throw new Error("delimiter of not final record is not 1"); return data.slice(0, i); } throw new Error("no delimiter found"); } createHeader() { const nums = import_buffer.Buffer.alloc(5); nums.writeUIntBE(this.rs, 0, 4); nums.writeUIntBE(0, 4, 1); return import_buffer.Buffer.concat([import_buffer.Buffer.from(this.salt), nums]); } readHeader(buffer) { if (buffer.length < 21) throw new Error("chunk too small for reading header"); const header = {}; header.salt = buffer.buffer.slice(0, KEY_LENGTH); header.rs = buffer.readUIntBE(KEY_LENGTH, 4); header.length = buffer.readUInt8(20) + KEY_LENGTH + 5; return header; } async encryptRecord(buffer, seq, isLast) { const nonce = this.generateNonce(seq); const encrypted = await crypto.subtle.encrypt({ name: "AES-GCM", iv: nonce }, this.key, this.pad(buffer, isLast)); return import_buffer.Buffer.from(encrypted); } async decryptRecord(buffer, seq, isLast) { const nonce = this.generateNonce(seq); const data = await crypto.subtle.decrypt({ name: "AES-GCM", iv: nonce, tagLength: 128 }, this.key, buffer); return this.unpad(import_buffer.Buffer.from(data), isLast); } async start(controller) { if (this.mode === MODE_ENCRYPT) { this.nonceBase = await this.generateNonceBase(); controller.enqueue(this.createHeader()); } else if (this.mode !== MODE_DECRYPT) throw new Error("mode must be either encrypt or decrypt"); } async transformPrevChunk(isLast, controller) { if (this.mode === MODE_ENCRYPT) { controller.enqueue(await this.encryptRecord(this.prevChunk, this.seq, isLast)); this.seq++; } else { if (this.seq === 0) { const header = this.readHeader(this.prevChunk); this.salt = header.salt; this.rs = header.rs; this.nonceBase = await this.generateNonceBase(); } else controller.enqueue(await this.decryptRecord(this.prevChunk, this.seq - 1, isLast)); this.seq++; } } async transform(chunk, controller) { if (!this.firstchunk) await this.transformPrevChunk(false, controller); this.firstchunk = false; this.prevChunk = import_buffer.Buffer.from(chunk.buffer); } async flush(controller) { if (this.prevChunk) await this.transformPrevChunk(true, controller); } }; var StreamSlicer = class { constructor(rs, mode) { this.mode = mode; this.rs = rs; this.chunkSize = mode === MODE_ENCRYPT ? rs - 17 : 21; this.partialChunk = new Uint8Array(this.chunkSize); this.offset = 0; } send(buf, controller) { controller.enqueue(buf); if (this.chunkSize === 21 && this.mode === MODE_DECRYPT) this.chunkSize = this.rs; this.partialChunk = new Uint8Array(this.chunkSize); this.offset = 0; } transform(chunk, controller) { let i = 0; if (this.offset > 0) { const len = Math.min(chunk.byteLength, this.chunkSize - this.offset); this.partialChunk.set(chunk.slice(0, len), this.offset); this.offset += len; i += len; if (this.offset === this.chunkSize) this.send(this.partialChunk, controller); } while (i < chunk.byteLength) { const remainingBytes = chunk.byteLength - i; if (remainingBytes >= this.chunkSize) { const record = chunk.slice(i, i + this.chunkSize); i += this.chunkSize; this.send(record, controller); } else { const end = chunk.slice(i, i + remainingBytes); i += end.byteLength; this.partialChunk.set(end); this.offset = end.byteLength; } } } flush(controller) { if (this.offset > 0) controller.enqueue(this.partialChunk.slice(0, this.offset)); } }; function encryptStream(input, key, rs = ECE_RECORD_SIZE, salt = generateSalt(KEY_LENGTH)) { const mode = "encrypt"; return transformStream(transformStream(input, new StreamSlicer(rs, mode)), new ECETransformer(mode, key, rs, salt)); } function decryptStream(input, key, rs = ECE_RECORD_SIZE) { const mode = "decrypt"; return transformStream(transformStream(input, new StreamSlicer(rs, mode)), new ECETransformer(mode, key, rs)); } //#endregion //#region ../send/frontend/src/apps/send/const.js /** * Enum for Initialization codes. Non-zero values indicate an error. * @readonly * @enum {number} */ var INIT_ERRORS = { NONE: 0, NO_USER: 1, NO_KEYCHAIN: 2, COULD_NOT_CREATE_DEFAULT_FOLDER: 3 }; //#endregion //#region ../send/frontend/src/lib/storage/LocalStorage.ts var LocalStorageAdapter = class { constructor() {} keys() { const keys = []; for (let i = 0; i < localStorage.length; i++) keys.push(localStorage.key(i)); return keys; } get(key) { const val = localStorage.getItem(key); if (!val) return null; return JSON.parse(val); } set(key, val) { const value = JSON.stringify(val); localStorage.setItem(key, value); } remove(id) { localStorage.removeItem(id); } clear() { console.log(`clearing localStorage`); localStorage.clear(); } }; //#endregion //#region ../send/frontend/src/lib/storage/index.ts var Storage$1 = class { constructor(Adapter = LocalStorageAdapter) { this.USER_KEY = "lb/user"; this.OTHER_KEYS_KEY = "lb/keys"; this.RSA_KEYS_KEY = "lb/rsa"; this.PASS_PHRASE = "lb/passphrase"; this.adapter = new Adapter(); } async storeUser(userObj) { this.adapter.set(this.USER_KEY, { ...userObj }); } async getUserFromLocalStorage() { return this.adapter.get(this.USER_KEY); } async storeKeys(keysObj) { this.adapter.set(this.OTHER_KEYS_KEY, { ...keysObj }); } async storePassPhrase(passPhrase) { this.adapter.set(this.PASS_PHRASE, { passPhrase }); } getPassPhrase() { return this.adapter.get(this.PASS_PHRASE)?.passPhrase || ""; } async loadKeys() { return this.adapter.get(this.OTHER_KEYS_KEY); } async storeKeypair(keypair) { this.adapter.set(this.RSA_KEYS_KEY, { ...keypair }); } async loadKeypair() { return this.adapter.get(this.RSA_KEYS_KEY); } async clear() { return this.adapter.clear(); } async export() { return { user: await this.getUserFromLocalStorage(), keypair: await this.loadKeypair(), keys: await this.loadKeys() }; } }; //#endregion //#region ../send/frontend/src/lib/bridgePassphrase.ts /** * Pull a passphrase shared from the web app via the token bridge into the * keychain. * * The web app (running in a browser tab) posts SEND_MESSAGE_TO_BRIDGE; the * add-on background stores its value in browser.storage.local under that key * (see background.ts). This moves that staged value into the keychain — i.e. * localStorage['lb/passphrase'], which every moz-extension page (background, * popup, management) shares — and clears the staged copy so it is consumed once. * * Runs only in an extension context where browser.storage.local exists; it is a * no-op in a plain web page (where `browser` is undefined). Safe to call from * any context that is about to restore keys, so the popup and background don't * depend on the management page having run the transfer first. * * @returns true if a bridged passphrase was found and stored, false otherwise. */ async function pullBridgedPassphrase(keychain) { if (typeof browser === "undefined" || !browser?.storage?.local) return false; try { const passphrase = (await browser.storage.local.get(SEND_MESSAGE_TO_BRIDGE))?.[SEND_MESSAGE_TO_BRIDGE]; if (!passphrase) return false; await keychain.storePassPhrase(passphrase); await browser.storage.local.remove(SEND_MESSAGE_TO_BRIDGE); console.log("✅ Pulled bridged passphrase into the keychain"); return true; } catch (error) { console.error("Error pulling bridged passphrase:", error); return false; } } //#endregion //#region ../send/frontend/src/lib/keychain.ts var import___vite_browser_external = /* @__PURE__ */ __toESM$2(require___vite_browser_external(), 1); var SALT_LENGTH = 128; var crypto$1 = import___vite_browser_external.default; try { crypto$1 = window.crypto; } catch (e) {} async function generateAesGcmKey() { try { return await crypto$1.subtle.generateKey({ name: "AES-GCM", length: 256 }, true, ["encrypt", "decrypt"]); } catch (err) { console.error(err); } } var Content = class { async generateKey() { return await generateAesGcmKey(); } }; var Container = class { async generateContainerKey() { try { return await crypto$1.subtle.generateKey({ name: "AES-KW", length: 256 }, true, ["wrapKey", "unwrapKey"]); } catch (err) { console.error(err); } } async wrapContentKey(key, wrappingKey) { const wrappedKey = await crypto$1.subtle.wrapKey("raw", key, wrappingKey, "AES-KW"); return Util.arrayBufferToBase64(wrappedKey); } async unwrapContentKey(wrappedKeyStr, wrappingKey) { const buf = Util.base64ToArrayBuffer(wrappedKeyStr); return await crypto$1.subtle.unwrapKey("raw", buf, wrappingKey, "AES-KW", "AES-GCM", true, ["encrypt", "decrypt"]); } }; var Password = class { async _wrap(keyToWrap, password, salt) { const wrappingKey = await getKey(await getKeyMaterial(password), salt); const wrappedKey = await crypto$1.subtle.wrapKey("raw", keyToWrap, wrappingKey, "AES-KW"); return Util.arrayBufferToBase64(wrappedKey); } async _unwrap(wrappedKeyStr, password, salt, algorithm, permissions) { const unwrappingKey = await getUnwrappingKey(password, salt); return crypto$1.subtle.unwrapKey("raw", Util.base64ToArrayBuffer(wrappedKeyStr), unwrappingKey, "AES-KW", algorithm, true, permissions); } async wrapContainerKey(keyToWrap, password, salt) { return await this._wrap(keyToWrap, password, salt); } async unwrapContainerKey(wrappedKeyStr, password, salt) { return await this._unwrap(wrappedKeyStr, password, salt, "AES-KW", ["wrapKey", "unwrapKey"]); } async wrapContentKey(keyToWrap, password, salt) { return await this._wrap(keyToWrap, password, salt); } async unwrapContentKey(wrappedKeyStr, password, salt) { return await this._unwrap(wrappedKeyStr, password, salt, "AES-GCM", ["encrypt", "decrypt"]); } }; var Rsa = class { async generateKeyPair() { const { publicKey, privateKey } = await crypto$1.subtle.generateKey({ name: "RSA-OAEP", modulusLength: 2048, publicExponent: new Uint8Array([ 1, 0, 1 ]), hash: "SHA-256" }, true, ["wrapKey", "unwrapKey"]); this.publicKey = publicKey; this.privateKey = privateKey; return { publicKey, privateKey }; } async getPublicKeyJwk() { if (!this.publicKey) return null; const jwk = await rsaToJsonWebKey(this.publicKey); return JSON.stringify(jwk); } async getPrivateKeyJwk() { if (!this.privateKey) return null; const jwk = await rsaToJsonWebKey(this.privateKey); return JSON.stringify(jwk); } async setPrivateKeyFromJwk(jwk) { this.privateKey = await jwkToRsa(jwk); } async setPublicKeyFromJwk(jwk) { this.publicKey = await jwkToRsa(jwk); } async wrapContainerKey(aesKey, publicKey) { const wrappedKey = await crypto$1.subtle.wrapKey("jwk", aesKey, publicKey, { name: "RSA-OAEP" }); return Util.arrayBufferToBase64(wrappedKey); } async unwrapContainerKey(wrappedKeyStr, privateKey) { return await crypto$1.subtle.unwrapKey("jwk", Util.base64ToArrayBuffer(wrappedKeyStr), privateKey, { name: "RSA-OAEP" }, { name: "AES-KW", length: 256 }, true, ["wrapKey", "unwrapKey"]); } }; var Challenge = class { createChallenge() { return Util.arrayBufferToBase64(Util.generateSalt(SALT_LENGTH)); } async generateKey() { return await generateAesGcmKey(); } async encryptChallenge(challengePlaintext, key, salt) { const arrayBuffer = new TextEncoder().encode(challengePlaintext); const ciphertextBuffer = await crypto$1.subtle.encrypt({ name: "AES-GCM", iv: salt }, key, arrayBuffer); return Util.arrayBufferToBase64(ciphertextBuffer); } async decryptChallenge(challengeCiphertext, key, salt) { const arrayBuffer = await crypto$1.subtle.decrypt({ name: "AES-GCM", iv: salt }, key, Util.base64ToArrayBuffer(challengeCiphertext)); return new TextDecoder().decode(arrayBuffer); } }; var Backup = class { async generateKey() { return await generateAesGcmKey(); } async encryptBackup(plaintext, key, salt) { const arrayBuffer = new TextEncoder().encode(plaintext); const ciphertextBuffer = await crypto$1.subtle.encrypt({ name: "AES-GCM", iv: salt }, key, arrayBuffer); return Util.arrayBufferToBase64(ciphertextBuffer); } async decryptBackup(ciphertext, key, salt) { const arrayBuffer = await crypto$1.subtle.decrypt({ name: "AES-GCM", iv: salt }, key, Util.base64ToArrayBuffer(ciphertext)); return new TextDecoder().decode(arrayBuffer); } }; var Keychain = class { constructor(storage) { this._init(storage); this.locked = false; } _init(storage) { this.content = new Content(); this.container = new Container(); this.password = new Password(); this.rsa = new Rsa(); this.challenge = new Challenge(); this.backup = new Backup(); this._keys = {}; this._storage = storage ?? new Storage$1(); } get keys() { return { ...this._keys }; } set keys(keyObj) { this._keys = keyObj; } getPassphraseValue() { return this._storage.getPassPhrase(); } count() { return Object.keys(this._keys).length; } async add(id, key) { if (!this.rsa.publicKey) throw Error("Missing public key, required for wrapping AES key"); const wrappedKeyStr = await this.rsa.wrapContainerKey(key, this.rsa.publicKey); this._keys[id] = wrappedKeyStr; } async get(id) { const wrappedKeyStr = this._keys[id]; if (!wrappedKeyStr) throw Error(`You don't have the key to decrypt this container`); return await this.rsa.unwrapContainerKey(wrappedKeyStr, this.rsa.privateKey); } remove(id) { delete this._keys[id]; } async newKeyForContainer(id) { const key = await this.container.generateContainerKey(); console.log(`adding key for container id ${id}`); await this.add(id, key); } async exportKeypair() { return { publicKey: await this.rsa.getPublicKeyJwk(), privateKey: await this.rsa.getPrivateKeyJwk() }; } async exportKeys() { return { ...this.keys }; } async storePassPhrase(passphrase) { await this._storage.storePassPhrase(passphrase); } async store() { await this._storage.storeKeypair(await this.exportKeypair()); await this._storage.storeKeys(await this.exportKeys()); } async fallbackToStoredKeypair(keypair) { if (!keypair) keypair = await this._storage.loadKeypair(); return keypair; } async fallbackToStoredKeys(keys) { if (!keys) keys = await this._storage.loadKeys(); return keys; } async load(keypairStr, keys) { try { const { publicKey, privateKey } = await this.fallbackToStoredKeypair(keypairStr); await this.rsa.setPrivateKeyFromJwk(privateKey); await this.rsa.setPublicKeyFromJwk(publicKey); this.keys = await this.fallbackToStoredKeys(keys); return true; } catch (e) { console.log(`No keychain in storage`); return false; } } async generateBackupKey() { return await generateAesGcmKey(); } }; var Util = class { static generateSalt(size = 16) { return (0, import_get_random_values.default)(new Uint8Array(size)); } static generateRandomPassword(size = 16) { return this.arrayBufferToBase64(this.generateSalt(size)); } static async compareKeys(k1, k2) { return await exportKeyToBase64(k1) === await exportKeyToBase64(k2); } static arrayBufferToBase64(arrayBuffer) { const byteArray = new Uint8Array(arrayBuffer); const byteString = String.fromCharCode(...byteArray); return btoa(encodeURIComponent(byteString)); } static base64ToArrayBuffer(base64) { const byteString = decodeURIComponent(atob(base64)); const byteArray = new Uint8Array(byteString.length); for (let i = 0; i < byteString.length; i++) byteArray[i] = byteString.charCodeAt(i); return byteArray.buffer; } }; function getKeyMaterial(password) { const enc = new TextEncoder(); return crypto$1.subtle.importKey("raw", enc.encode(password), { name: "PBKDF2" }, false, ["deriveBits", "deriveKey"]); } function getKey(keyMaterial, salt) { return crypto$1.subtle.deriveKey({ name: "PBKDF2", salt, iterations: 1e5, hash: "SHA-256" }, keyMaterial, { name: "AES-KW", length: 256 }, true, ["wrapKey", "unwrapKey"]); } async function getUnwrappingKey(password, salt) { const keyMaterial = await getKeyMaterial(password); return crypto$1.subtle.deriveKey({ name: "PBKDF2", salt, iterations: 1e5, hash: "SHA-256" }, keyMaterial, { name: "AES-KW", length: 256 }, true, ["wrapKey", "unwrapKey"]); } async function rsaToJsonWebKey(key) { return await crypto$1.subtle.exportKey("jwk", key); } function toJsonWebKey(jwk) { if (typeof jwk === "string") return JSON.parse(jwk); return jwk; } async function jwkToRsa(jwk) { jwk = toJsonWebKey(jwk); return await crypto$1.subtle.importKey("jwk", jwk, { name: "RSA-OAEP", hash: "SHA-256" }, true, jwk.key_ops || []); } async function exportKeyToBase64(key) { const keyBuffer = await crypto$1.subtle.exportKey("raw", key); return Util.arrayBufferToBase64(keyBuffer); } async function decryptKeys(protectedContainerKeysObj, keychain, key, salt) { const obj = {}; await Promise.all(Object.keys(protectedContainerKeysObj).map(async (k) => { obj[k] = await keychain.backup.decryptBackup(protectedContainerKeysObj[k], key, salt); return true; })); return obj; } async function decryptAll(keychainFromParams, { protectedContainerKeysStr, protectedKeypairStr, passwordWrappedKeyStr, saltStr, password }) { const salt = Util.base64ToArrayBuffer(saltStr); const key = await keychainFromParams.password.unwrapContentKey(passwordWrappedKeyStr, password, salt); const protectedKeypair = JSON.parse(protectedKeypairStr); const publicKeyCiphertext = protectedKeypair.publicKey; const privateKeyCiphertext = protectedKeypair.privateKey; return { publicKeyJwk: await keychainFromParams.backup.decryptBackup(publicKeyCiphertext, key, salt), privateKeyJwk: await keychainFromParams.backup.decryptBackup(privateKeyCiphertext, key, salt), containerKeys: await decryptKeys(JSON.parse(protectedContainerKeysStr), keychainFromParams, key, salt) }; } var MSG_INCORRECT_PASSPHRASE = "Passphrase is incorrect"; var MSG_COULD_NOT_RETRIEVE = "Could not retrieve backup from the server."; async function restoreKeysUsingLocalStorage(keychain, api) { await pullBridgedPassphrase(keychain); console.log("🔑 auto restoring keys"); if (!keychain.getPassphraseValue()) { console.log("Keychain passphrase is not initialized"); return; } return restoreKeys(keychain, api); } async function restoreKeys(keychain, api, msg, passPhrase) { if (!msg) msg = { value: "" }; const password = keychain.getPassphraseValue() || passPhrase; if (!password) console.error("Keychain is not initialized"); let getBackupAPIResponse; try { getBackupAPIResponse = await api.call(`users/backup`); } catch (error) { console.error("Could not retrieve backup from the server.", error); return; } if (!getBackupAPIResponse) { msg.value = MSG_COULD_NOT_RETRIEVE; return; } const { backupContainerKeys, backupKeypair, backupKeystring, backupSalt } = getBackupAPIResponse; const decryptParams = { protectedContainerKeysStr: backupContainerKeys, protectedKeypairStr: backupKeypair, passwordWrappedKeyStr: backupKeystring, saltStr: backupSalt, password }; try { const { publicKeyJwk, privateKeyJwk, containerKeys } = await decryptAll(keychain, decryptParams); const keypair = { publicKey: publicKeyJwk, privateKey: privateKeyJwk }; await keychain.load(keypair, containerKeys); await keychain.store(); msg.value = "✅ Restore complete"; } catch (e) { keychain.locked = true; const KEY_RESTORE_ERROR = `⛔️ Could not restore keys. Please make sure your backup phrase is correct.`; console.error(KEY_RESTORE_ERROR, e); msg.value = MSG_INCORRECT_PASSPHRASE; throw new Error(KEY_RESTORE_ERROR); } } async function encryptKeys(containerKeysObj, key, salt, keychain) { const obj = {}; await Promise.all(Object.keys(containerKeysObj).map(async (k) => { obj[k] = await keychain.backup.encryptBackup(containerKeysObj[k], key, salt); return true; })); return obj; } async function encryptAll(publicKeyJwk, privateKeyJwk, containerKeys, password, keychain) { const key = await keychain.generateBackupKey(); const salt = Util.generateSalt(); const protectedContainerKeys = await encryptKeys(containerKeys, key, salt, keychain); const protectedContainerKeysStr = JSON.stringify(protectedContainerKeys); const protectedKeypair = { publicKey: await keychain.backup.encryptBackup(publicKeyJwk, key, salt), privateKey: await keychain.backup.encryptBackup(privateKeyJwk, key, salt) }; return { protectedContainerKeysStr, protectedKeypairStr: JSON.stringify(protectedKeypair), passwordWrappedKeyStr: await keychain.password.wrapContentKey(key, password, salt), saltStr: Util.arrayBufferToBase64(salt) }; } async function createBackup(keys, keypair, keystring, salt, api) { return await api.call(`users/backup`, { keys, keypair, keystring, salt }, "POST"); } async function backupKeys(keychain, api, msg) { const password = keychain.getPassphraseValue(); msg.value = ""; console.log("🔐 auto-backing up keys"); if (!password) { console.warn("Keychain is not initialized, cannot backup keys"); return; } const keypair = await keychain.exportKeypair(); const containerKeys = await keychain.exportKeys(); const { protectedContainerKeysStr, protectedKeypairStr, passwordWrappedKeyStr, saltStr } = await encryptAll(keypair.publicKey, keypair.privateKey, containerKeys, password, keychain); await createBackup(protectedContainerKeysStr, protectedKeypairStr, passwordWrappedKeyStr, saltStr, api); msg.value = "✅ Backup complete"; console.log("🔒 Backup complete"); } //#endregion //#region ../../node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs var __create$1 = Object.create; var __defProp$1 = Object.defineProperty; var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor; var __getOwnPropNames$1 = Object.getOwnPropertyNames; var __getProtoOf$1 = Object.getPrototypeOf; var __hasOwnProp$1 = Object.prototype.hasOwnProperty; var __commonJS$1 = (cb, mod) => function() { return mod || (0, cb[__getOwnPropNames$1(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __copyProps$1 = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$1(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp$1.call(to, key) && key !== except) __defProp$1(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc$1(from, key)) || desc.enumerable }); } return to; }; var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$1(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", { value: mod, enumerable: true }) : target, mod)); var require_typeof$1 = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) { function _typeof$2(o) { "@babel/helpers - typeof"; return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) { return typeof o$1; } : function(o$1) { return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1; }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o); } module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_toPrimitive$1 = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) { var _typeof$1 = require_typeof$1()["default"]; function toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_toPropertyKey$1 = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) { var _typeof = require_typeof$1()["default"]; var toPrimitive = require_toPrimitive$1(); function toPropertyKey$1(t) { var i = toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_defineProperty$1 = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) { var toPropertyKey = require_toPropertyKey$1(); function _defineProperty(e, r, t) { return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_objectSpread2$1 = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) { var defineProperty = require_defineProperty$1(); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function(r$1) { return Object.getOwnPropertyDescriptor(e, r$1).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) { defineProperty(e, r$1, t[r$1]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) { Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1)); }); } return e; } module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); //#endregion //#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-UMO3vUa_.mjs /** @public */ function observable(subscribe) { const self = { subscribe(observer) { let teardownRef = null; let isDone = false; let unsubscribed = false; let teardownImmediately = false; function unsubscribe() { if (teardownRef === null) { teardownImmediately = true; return; } if (unsubscribed) return; unsubscribed = true; if (typeof teardownRef === "function") teardownRef(); else if (teardownRef) teardownRef.unsubscribe(); } teardownRef = subscribe({ next(value) { var _observer$next; if (isDone) return; (_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value); }, error(err) { var _observer$error; if (isDone) return; isDone = true; (_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, err); unsubscribe(); }, complete() { var _observer$complete; if (isDone) return; isDone = true; (_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer); unsubscribe(); } }); if (teardownImmediately) unsubscribe(); return { unsubscribe }; }, pipe(...operations) { return operations.reduce(pipeReducer, self); } }; return self; } function pipeReducer(prev, fn) { return fn(prev); } /** @internal */ function observableToPromise(observable$1) { const ac = new AbortController(); return new Promise((resolve, reject) => { let isDone = false; function onDone() { if (isDone) return; isDone = true; obs$.unsubscribe(); } ac.signal.addEventListener("abort", () => { reject(ac.signal.reason); }); const obs$ = observable$1.subscribe({ next(data) { isDone = true; resolve(data); onDone(); }, error(data) { reject(data); }, complete() { ac.abort(); onDone(); } }); }); } //#endregion //#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-CUiPknO-.mjs function share(_opts) { return (source) => { let refCount = 0; let subscription = null; const observers = []; function startIfNeeded() { if (subscription) return; subscription = source.subscribe({ next(value) { for (const observer of observers) { var _observer$next; (_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value); } }, error(error) { for (const observer of observers) { var _observer$error; (_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, error); } }, complete() { for (const observer of observers) { var _observer$complete; (_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer); } } }); } function resetIfNeeded() { if (refCount === 0 && subscription) { const _sub = subscription; subscription = null; _sub.unsubscribe(); } } return observable((subscriber) => { refCount++; observers.push(subscriber); startIfNeeded(); return { unsubscribe() { refCount--; resetIfNeeded(); const index = observers.findIndex((v) => v === subscriber); if (index > -1) observers.splice(index, 1); } }; }); }; } /** * @internal * An observable that maintains and provides a "current value" to subscribers * @see https://www.learnrxjs.io/learn-rxjs/subjects/behaviorsubject */ function behaviorSubject(initialValue) { let value = initialValue; const observerList = []; const addObserver = (observer) => { if (value !== void 0) observer.next(value); observerList.push(observer); }; const removeObserver = (observer) => { observerList.splice(observerList.indexOf(observer), 1); }; const obs = observable((observer) => { addObserver(observer); return () => { removeObserver(observer); }; }); obs.next = (nextValue) => { if (value === nextValue) return; value = nextValue; for (const observer of observerList) observer.next(nextValue); }; obs.get = () => value; return obs; } //#endregion //#region ../../node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/splitLink-B7Cuf2c_.mjs /** @internal */ function createChain(opts) { return observable((observer) => { function execute(index = 0, op = opts.op) { const next = opts.links[index]; if (!next) throw new Error("No more links to execute - did you forget to add an ending link?"); return next({ op, next(nextOp) { return execute(index + 1, nextOp); } }); } return execute().subscribe(observer); }); } function asArray(value) { return Array.isArray(value) ? value : [value]; } function splitLink(opts) { return (runtime) => { const yes = asArray(opts.true).map((link) => link(runtime)); const no = asArray(opts.false).map((link) => link(runtime)); return (props) => { return observable((observer) => { const links = opts.condition(props.op) ? yes : no; return createChain({ op: props.op, links }).subscribe(observer); }); }; }; } //#endregion //#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/codes-DagpWZLc.mjs /** * Check that value is object * @internal */ function isObject(value) { return !!value && !Array.isArray(value) && typeof value === "object"; } /** * Create an object without inheriting anything from `Object.prototype` * @internal */ function emptyObject() { return Object.create(null); } /** * Run an IIFE */ var run = (fn) => fn(); function sleep(ms = 0) { return new Promise((res) => setTimeout(res, ms)); } /** * JSON-RPC 2.0 Error codes * * `-32000` to `-32099` are reserved for implementation-defined server-errors. * For tRPC we're copying the last digits of HTTP 4XX errors. */ var TRPC_ERROR_CODES_BY_KEY = { PARSE_ERROR: -32700, BAD_REQUEST: -32600, INTERNAL_SERVER_ERROR: -32603, NOT_IMPLEMENTED: -32603, BAD_GATEWAY: -32603, SERVICE_UNAVAILABLE: -32603, GATEWAY_TIMEOUT: -32603, UNAUTHORIZED: -32001, PAYMENT_REQUIRED: -32002, FORBIDDEN: -32003, NOT_FOUND: -32004, METHOD_NOT_SUPPORTED: -32005, TIMEOUT: -32008, CONFLICT: -32009, PRECONDITION_FAILED: -32012, PAYLOAD_TOO_LARGE: -32013, UNSUPPORTED_MEDIA_TYPE: -32015, UNPROCESSABLE_CONTENT: -32022, PRECONDITION_REQUIRED: -32028, TOO_MANY_REQUESTS: -32029, CLIENT_CLOSED_REQUEST: -32099 }; TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY, TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE, TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT, TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR; //#endregion //#region ../../node_modules/.pnpm/@trpc+server@11.17.0_typescript@5.9.3/node_modules/@trpc/server/dist/getErrorShape-BPSzUA7W.mjs var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); var noop = () => {}; var freezeIfAvailable = (obj) => { if (Object.freeze) Object.freeze(obj); }; function createInnerProxy(callback, path, memo) { var _memo$cacheKey; const cacheKey = path.join("."); (_memo$cacheKey = memo[cacheKey]) !== null && _memo$cacheKey !== void 0 || (memo[cacheKey] = new Proxy(noop, { get(_obj, key) { if (typeof key !== "string" || key === "then") return void 0; return createInnerProxy(callback, [...path, key], memo); }, apply(_1, _2, args) { const lastOfPath = path[path.length - 1]; if (lastOfPath === "valueOf" || lastOfPath === "toString" || lastOfPath === "toJSON") return `tRPC.proxy(${path.slice(0, -1).join(".")})`; let opts = { args, path }; if (lastOfPath === "call") opts = { args: args.length >= 2 ? [args[1]] : [], path: path.slice(0, -1) }; else if (lastOfPath === "apply") opts = { args: args.length >= 2 ? args[1] : [], path: path.slice(0, -1) }; freezeIfAvailable(opts.args); freezeIfAvailable(opts.path); return callback(opts); } })); return memo[cacheKey]; } /** * Creates a proxy that calls the callback with the path and arguments * * @internal */ var createRecursiveProxy = (callback) => createInnerProxy(callback, [], emptyObject()); /** * Used in place of `new Proxy` where each handler will map 1 level deep to another value. * * @internal */ var createFlatProxy = (callback) => { return new Proxy(noop, { get(_obj, name) { if (name === "then") return void 0; return callback(name); } }); }; var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) { function _typeof$2(o) { "@babel/helpers - typeof"; return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) { return typeof o$1; } : function(o$1) { return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1; }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o); } module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) { var _typeof$1 = require_typeof()["default"]; function toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) { var _typeof = require_typeof()["default"]; var toPrimitive = require_toPrimitive(); function toPropertyKey$1(t) { var i = toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) { var toPropertyKey = require_toPropertyKey(); function _defineProperty(e, r, t) { return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) { var defineProperty = require_defineProperty(); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function(r$1) { return Object.getOwnPropertyDescriptor(e, r$1).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) { defineProperty(e, r$1, t[r$1]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) { Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1)); }); } return e; } module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); __toESM(require_objectSpread2(), 1); __toESM(require_defineProperty(), 1); var import_objectSpread2$1$11 = __toESM(require_objectSpread2(), 1); /** @internal */ function transformResultInner(response, transformer) { if ("error" in response) { const error = transformer.deserialize(response.error); return { ok: false, error: (0, import_objectSpread2$1$11.default)((0, import_objectSpread2$1$11.default)({}, response), {}, { error }) }; } return { ok: true, result: (0, import_objectSpread2$1$11.default)((0, import_objectSpread2$1$11.default)({}, response.result), (!response.result.type || response.result.type === "data") && { type: "data", data: transformer.deserialize(response.result.data) }) }; } var TransformResultError = class extends Error { constructor() { super("Unable to transform response from server"); } }; /** * Transforms and validates that the result is a valid TRPCResponse * @internal */ function transformResult(response, transformer) { let result; try { result = transformResultInner(response, transformer); } catch (_unused) { throw new TransformResultError(); } if (!result.ok && (!isObject(result.error.error) || typeof result.error.error["code"] !== "number")) throw new TransformResultError(); if (result.ok && !isObject(result.result)) throw new TransformResultError(); return result; } __toESM(require_objectSpread2(), 1); //#endregion //#region ../../node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs var import_defineProperty$5 = __toESM$1(require_defineProperty$1(), 1); var import_objectSpread2$10 = __toESM$1(require_objectSpread2$1(), 1); function isTRPCClientError(cause) { return cause instanceof TRPCClientError; } function isTRPCErrorResponse(obj) { return isObject(obj) && isObject(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string"; } function getMessageFromUnknownError(err, fallback) { if (typeof err === "string") return err; if (isObject(err) && typeof err["message"] === "string") return err["message"]; return fallback; } var TRPCClientError = class TRPCClientError extends Error { constructor(message, opts) { var _opts$result, _opts$result2; const cause = opts === null || opts === void 0 ? void 0 : opts.cause; super(message, { cause }); (0, import_defineProperty$5.default)(this, "cause", void 0); (0, import_defineProperty$5.default)(this, "shape", void 0); (0, import_defineProperty$5.default)(this, "data", void 0); (0, import_defineProperty$5.default)(this, "meta", void 0); this.meta = opts === null || opts === void 0 ? void 0 : opts.meta; this.cause = cause; this.shape = opts === null || opts === void 0 || (_opts$result = opts.result) === null || _opts$result === void 0 ? void 0 : _opts$result.error; this.data = opts === null || opts === void 0 || (_opts$result2 = opts.result) === null || _opts$result2 === void 0 ? void 0 : _opts$result2.error.data; this.name = "TRPCClientError"; Object.setPrototypeOf(this, TRPCClientError.prototype); } static from(_cause, opts = {}) { const cause = _cause; if (isTRPCClientError(cause)) { if (opts.meta) cause.meta = (0, import_objectSpread2$10.default)((0, import_objectSpread2$10.default)({}, cause.meta), opts.meta); return cause; } if (isTRPCErrorResponse(cause)) return new TRPCClientError(cause.error.message, (0, import_objectSpread2$10.default)((0, import_objectSpread2$10.default)({}, opts), {}, { result: cause, cause: opts.cause })); return new TRPCClientError(getMessageFromUnknownError(cause, "Unknown error"), (0, import_objectSpread2$10.default)((0, import_objectSpread2$10.default)({}, opts), {}, { cause })); } }; //#endregion //#region ../../node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs /** * @internal */ /** * @internal */ function getTransformer(transformer) { const _transformer = transformer; if (!_transformer) return { input: { serialize: (data) => data, deserialize: (data) => data }, output: { serialize: (data) => data, deserialize: (data) => data } }; if ("input" in _transformer) return _transformer; return { input: _transformer, output: _transformer }; } //#endregion //#region ../../node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpUtils-pyf5RF99.mjs var isFunction = (fn) => typeof fn === "function"; function getFetch(customFetchImpl) { if (customFetchImpl) return customFetchImpl; if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch; if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch; throw new Error("No fetch implementation found"); } var import_objectSpread2$9 = __toESM$1(require_objectSpread2$1(), 1); function resolveHTTPLinkOptions(opts) { return { url: opts.url.toString(), fetch: opts.fetch, transformer: getTransformer(opts.transformer), methodOverride: opts.methodOverride }; } function arrayToDict(array) { const dict = {}; for (let index = 0; index < array.length; index++) dict[index] = array[index]; return dict; } var METHOD = { query: "GET", mutation: "POST", subscription: "PATCH" }; function getInput(opts) { return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input))); } var getUrl = (opts) => { const parts = opts.url.split("?"); let url = parts[0].replace(/\/$/, "") + "/" + opts.path; const queryParts = []; if (parts[1]) queryParts.push(parts[1]); if ("inputs" in opts) queryParts.push("batch=1"); if (opts.type === "query" || opts.type === "subscription") { const input = getInput(opts); if (input !== void 0 && opts.methodOverride !== "POST") queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`); } if (queryParts.length) url += "?" + queryParts.join("&"); return url; }; var getBody = (opts) => { if (opts.type === "query" && opts.methodOverride !== "POST") return void 0; const input = getInput(opts); return input !== void 0 ? JSON.stringify(input) : void 0; }; var jsonHttpRequester = (opts) => { return httpRequest((0, import_objectSpread2$9.default)((0, import_objectSpread2$9.default)({}, opts), {}, { contentTypeHeader: "application/json", getUrl, getBody })); }; /** * Polyfill for DOMException with AbortError name */ var AbortError = class extends Error { constructor() { const name = "AbortError"; super(name); this.name = name; this.message = name; } }; /** * Polyfill for `signal.throwIfAborted()` * * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted */ var throwIfAborted = (signal) => { var _signal$throwIfAborte; if (!(signal === null || signal === void 0 ? void 0 : signal.aborted)) return; (_signal$throwIfAborte = signal.throwIfAborted) === null || _signal$throwIfAborte === void 0 || _signal$throwIfAborte.call(signal); if (typeof DOMException !== "undefined") throw new DOMException("AbortError", "AbortError"); throw new AbortError(); }; async function fetchHTTPResponse(opts) { var _opts$methodOverride, _opts$trpcAcceptHeade; throwIfAborted(opts.signal); const url = opts.getUrl(opts); const body = opts.getBody(opts); const method = (_opts$methodOverride = opts.methodOverride) !== null && _opts$methodOverride !== void 0 ? _opts$methodOverride : METHOD[opts.type]; const resolvedHeaders = await (async () => { const heads = await opts.headers(); if (Symbol.iterator in heads) return Object.fromEntries(heads); return heads; })(); const headers = (0, import_objectSpread2$9.default)((0, import_objectSpread2$9.default)((0, import_objectSpread2$9.default)({}, opts.contentTypeHeader && method !== "GET" ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { [(_opts$trpcAcceptHeade = opts.trpcAcceptHeaderKey) !== null && _opts$trpcAcceptHeade !== void 0 ? _opts$trpcAcceptHeade : "trpc-accept"]: opts.trpcAcceptHeader } : void 0), resolvedHeaders); return getFetch(opts.fetch)(url, { method, signal: opts.signal, body, headers }); } async function httpRequest(opts) { const meta = {}; const res = await fetchHTTPResponse(opts); meta.response = res; const json = await res.json(); meta.responseJSON = json; return { json, meta }; } __toESM$1(require_objectSpread2$1(), 1); //#endregion //#region ../../node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpBatchLink-LhidKAPw.mjs /** * A function that should never be called unless we messed something up. */ var throwFatalError = () => { throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new"); }; /** * Dataloader that's very inspired by https://github.com/graphql/dataloader * Less configuration, no caching, and allows you to cancel requests * When cancelling a single fetch the whole batch will be cancelled only when _all_ items are cancelled */ function dataLoader(batchLoader) { let pendingItems = null; let dispatchTimer = null; const destroyTimerAndPendingItems = () => { clearTimeout(dispatchTimer); dispatchTimer = null; pendingItems = null; }; /** * Iterate through the items and split them into groups based on the `batchLoader`'s validate function */ function groupItems(items) { const groupedItems = [[]]; let index = 0; while (true) { const item = items[index]; if (!item) break; const lastGroup = groupedItems[groupedItems.length - 1]; if (item.aborted) { var _item$reject; (_item$reject = item.reject) === null || _item$reject === void 0 || _item$reject.call(item, /* @__PURE__ */ new Error("Aborted")); index++; continue; } if (batchLoader.validate(lastGroup.concat(item).map((it) => it.key))) { lastGroup.push(item); index++; continue; } if (lastGroup.length === 0) { var _item$reject2; (_item$reject2 = item.reject) === null || _item$reject2 === void 0 || _item$reject2.call(item, /* @__PURE__ */ new Error("Input is too big for a single dispatch")); index++; continue; } groupedItems.push([]); } return groupedItems; } function dispatch() { const groupedItems = groupItems(pendingItems); destroyTimerAndPendingItems(); for (const items of groupedItems) { if (!items.length) continue; const batch = { items }; for (const item of items) item.batch = batch; batchLoader.fetch(batch.items.map((_item) => _item.key)).then(async (result) => { await Promise.all(result.map(async (valueOrPromise, index) => { const item = batch.items[index]; try { var _item$resolve; const value = await Promise.resolve(valueOrPromise); (_item$resolve = item.resolve) === null || _item$resolve === void 0 || _item$resolve.call(item, value); } catch (cause) { var _item$reject3; (_item$reject3 = item.reject) === null || _item$reject3 === void 0 || _item$reject3.call(item, cause); } item.batch = null; item.reject = null; item.resolve = null; })); for (const item of batch.items) { var _item$reject4; (_item$reject4 = item.reject) === null || _item$reject4 === void 0 || _item$reject4.call(item, /* @__PURE__ */ new Error("Missing result")); item.batch = null; } }).catch((cause) => { for (const item of batch.items) { var _item$reject5; (_item$reject5 = item.reject) === null || _item$reject5 === void 0 || _item$reject5.call(item, cause); item.batch = null; } }); } } function load(key) { var _dispatchTimer; const item = { aborted: false, key, batch: null, resolve: throwFatalError, reject: throwFatalError }; const promise = new Promise((resolve, reject) => { var _pendingItems; item.reject = reject; item.resolve = resolve; (_pendingItems = pendingItems) !== null && _pendingItems !== void 0 || (pendingItems = []); pendingItems.push(item); }); (_dispatchTimer = dispatchTimer) !== null && _dispatchTimer !== void 0 || (dispatchTimer = setTimeout(dispatch)); return promise; } return { load }; } /** * Like `Promise.all()` but for abort signals * - When all signals have been aborted, the merged signal will be aborted * - If one signal is `null`, no signal will be aborted */ function allAbortSignals(...signals) { const ac = new AbortController(); const count = signals.length; let abortedCount = 0; const onAbort = () => { if (++abortedCount === count) ac.abort(); }; for (const signal of signals) if (signal === null || signal === void 0 ? void 0 : signal.aborted) onAbort(); else signal === null || signal === void 0 || signal.addEventListener("abort", onAbort, { once: true }); return ac.signal; } var import_objectSpread2$7 = __toESM$1(require_objectSpread2$1(), 1); /** * @see https://trpc.io/docs/client/links/httpBatchLink */ function httpBatchLink(opts) { var _opts$maxURLLength, _opts$maxItems; const resolvedOpts = resolveHTTPLinkOptions(opts); const maxURLLength = (_opts$maxURLLength = opts.maxURLLength) !== null && _opts$maxURLLength !== void 0 ? _opts$maxURLLength : Infinity; const maxItems = (_opts$maxItems = opts.maxItems) !== null && _opts$maxItems !== void 0 ? _opts$maxItems : Infinity; return () => { const batchLoader = (type) => { return { validate(batchOps) { if (maxURLLength === Infinity && maxItems === Infinity) return true; if (batchOps.length > maxItems) return false; const path = batchOps.map((op) => op.path).join(","); const inputs = batchOps.map((op) => op.input); return getUrl((0, import_objectSpread2$7.default)((0, import_objectSpread2$7.default)({}, resolvedOpts), {}, { type, path, inputs, signal: null })).length <= maxURLLength; }, async fetch(batchOps) { const path = batchOps.map((op) => op.path).join(","); const inputs = batchOps.map((op) => op.input); const signal = allAbortSignals(...batchOps.map((op) => op.signal)); const res = await jsonHttpRequester((0, import_objectSpread2$7.default)((0, import_objectSpread2$7.default)({}, resolvedOpts), {}, { path, inputs, type, headers() { if (!opts.headers) return {}; if (typeof opts.headers === "function") return opts.headers({ opList: batchOps }); return opts.headers; }, signal })); return (Array.isArray(res.json) ? res.json : batchOps.map(() => res.json)).map((item) => ({ meta: res.meta, json: item })); } }; }; const loaders = { query: dataLoader(batchLoader("query")), mutation: dataLoader(batchLoader("mutation")) }; return ({ op }) => { return observable((observer) => { /* istanbul ignore if -- @preserve */ if (op.type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`"); const promise = loaders[op.type].load(op); let _res = void 0; promise.then((res) => { _res = res; const transformed = transformResult(res.json, resolvedOpts.transformer.output); if (!transformed.ok) { observer.error(TRPCClientError.from(transformed.error, { meta: res.meta })); return; } observer.next({ context: res.meta, result: transformed.result }); observer.complete(); }).catch((err) => { observer.error(TRPCClientError.from(err, { meta: _res === null || _res === void 0 ? void 0 : _res.meta })); }); return () => {}; }); }; }; } __toESM$1(require_objectSpread2$1(), 1); //#endregion //#region ../../node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs var jsonEncoder = { encode: (data) => JSON.stringify(data), decode: (data) => { if (typeof data !== "string") throw new Error("jsonEncoder received binary data. JSON uses text frames. Use a binary encoder for binary data."); return JSON.parse(data); } }; var lazyDefaults = { enabled: false, closeMs: 0 }; var keepAliveDefaults = { enabled: false, pongTimeoutMs: 1e3, intervalMs: 5e3 }; /** * Calculates a delay for exponential backoff based on the retry attempt index. * The delay starts at 0 for the first attempt and doubles for each subsequent attempt, * capped at 30 seconds. */ var exponentialBackoff = (attemptIndex) => { return attemptIndex === 0 ? 0 : Math.min(1e3 * 2 ** attemptIndex, 3e4); }; /** * Get the result of a value or function that returns a value * It also optionally accepts typesafe arguments for the function */ var resultOf = (value, ...args) => { return typeof value === "function" ? value(...args) : value; }; var import_defineProperty$3 = __toESM$1(require_defineProperty$1(), 1); var TRPCWebSocketClosedError = class TRPCWebSocketClosedError extends Error { constructor(opts) { super(opts.message, { cause: opts.cause }); this.name = "TRPCWebSocketClosedError"; Object.setPrototypeOf(this, TRPCWebSocketClosedError.prototype); } }; /** * Utility class for managing a timeout that can be started, stopped, and reset. * Useful for scenarios where the timeout duration is reset dynamically based on events. */ var ResettableTimeout = class { constructor(onTimeout, timeoutMs) { this.onTimeout = onTimeout; this.timeoutMs = timeoutMs; (0, import_defineProperty$3.default)(this, "timeout", void 0); } /** * Resets the current timeout, restarting it with the same duration. * Does nothing if no timeout is active. */ reset() { if (!this.timeout) return; clearTimeout(this.timeout); this.timeout = setTimeout(this.onTimeout, this.timeoutMs); } start() { clearTimeout(this.timeout); this.timeout = setTimeout(this.onTimeout, this.timeoutMs); } stop() { clearTimeout(this.timeout); this.timeout = void 0; } }; function withResolvers() { let resolve; let reject; return { promise: new Promise((res, rej) => { resolve = res; reject = rej; }), resolve, reject }; } /** * Resolves a WebSocket URL and optionally appends connection parameters. * * If connectionParams are provided, appends 'connectionParams=1' query parameter. */ async function prepareUrl(urlOptions) { const url = await resultOf(urlOptions.url); if (!urlOptions.connectionParams) return url; return url + `${url.includes("?") ? "&" : "?"}connectionParams=1`; } async function buildConnectionMessage(connectionParams, encoder) { const message = { method: "connectionParams", data: await resultOf(connectionParams) }; return encoder.encode(message); } var import_defineProperty$2 = __toESM$1(require_defineProperty$1(), 1); /** * Manages WebSocket requests, tracking their lifecycle and providing utility methods * for handling outgoing and pending requests. * * - **Outgoing requests**: Requests that are queued and waiting to be sent. * - **Pending requests**: Requests that have been sent and are in flight awaiting a response. * For subscriptions, multiple responses may be received until the subscription is closed. */ var RequestManager = class { constructor() { (0, import_defineProperty$2.default)(this, "outgoingRequests", new Array()); (0, import_defineProperty$2.default)(this, "pendingRequests", {}); } /** * Registers a new request by adding it to the outgoing queue and setting up * callbacks for lifecycle events such as completion or error. * * @param message - The outgoing message to be sent. * @param callbacks - Callback functions to observe the request's state. * @returns A cleanup function to manually remove the request. */ register(message, callbacks) { const { promise: end, resolve } = withResolvers(); this.outgoingRequests.push({ id: String(message.id), message, end, callbacks: { next: callbacks.next, complete: () => { callbacks.complete(); resolve(); }, error: (e) => { callbacks.error(e); resolve(); } } }); return () => { this.delete(message.id); callbacks.complete(); resolve(); }; } /** * Deletes a request from both the outgoing and pending collections, if it exists. */ delete(messageId) { if (messageId === null) return; this.outgoingRequests = this.outgoingRequests.filter(({ id }) => id !== String(messageId)); delete this.pendingRequests[String(messageId)]; } /** * Moves all outgoing requests to the pending state and clears the outgoing queue. * * The caller is expected to handle the actual sending of the requests * (e.g., sending them over the network) after this method is called. * * @returns The list of requests that were transitioned to the pending state. */ flush() { const requests = this.outgoingRequests; this.outgoingRequests = []; for (const request of requests) this.pendingRequests[request.id] = request; return requests; } /** * Retrieves all currently pending requests, which are in flight awaiting responses * or handling ongoing subscriptions. */ getPendingRequests() { return Object.values(this.pendingRequests); } /** * Retrieves a specific pending request by its message ID. */ getPendingRequest(messageId) { if (messageId === null) return null; return this.pendingRequests[String(messageId)]; } /** * Retrieves all outgoing requests, which are waiting to be sent. */ getOutgoingRequests() { return this.outgoingRequests; } /** * Retrieves all requests, both outgoing and pending, with their respective states. * * @returns An array of all requests with their state ("outgoing" or "pending"). */ getRequests() { return [...this.getOutgoingRequests().map((request) => ({ state: "outgoing", message: request.message, end: request.end, callbacks: request.callbacks })), ...this.getPendingRequests().map((request) => ({ state: "pending", message: request.message, end: request.end, callbacks: request.callbacks }))]; } /** * Checks if there are any pending requests, including ongoing subscriptions. */ hasPendingRequests() { return this.getPendingRequests().length > 0; } /** * Checks if there are any pending subscriptions */ hasPendingSubscriptions() { return this.getPendingRequests().some((request) => request.message.method === "subscription"); } /** * Checks if there are any outgoing requests waiting to be sent. */ hasOutgoingRequests() { return this.outgoingRequests.length > 0; } }; var import_defineProperty$1 = __toESM$1(require_defineProperty$1(), 1); /** * Opens a WebSocket connection asynchronously and returns a promise * that resolves when the connection is successfully established. * The promise rejects if an error occurs during the connection attempt. */ function asyncWsOpen(ws) { const { promise, resolve, reject } = withResolvers(); ws.addEventListener("open", () => { ws.removeEventListener("error", reject); resolve(); }); ws.addEventListener("error", reject); return promise; } /** * Sets up a periodic ping-pong mechanism to keep the WebSocket connection alive. * * - Sends "PING" messages at regular intervals defined by `intervalMs`. * - If a "PONG" response is not received within the `pongTimeoutMs`, the WebSocket is closed. * - The ping timer resets upon receiving any message to maintain activity. * - Automatically starts the ping process when the WebSocket connection is opened. * - Cleans up timers when the WebSocket is closed. * * @param ws - The WebSocket instance to manage. * @param options - Configuration options for ping-pong intervals and timeouts. */ function setupPingInterval(ws, { intervalMs, pongTimeoutMs }) { let pingTimeout; let pongTimeout; function start() { pingTimeout = setTimeout(() => { ws.send("PING"); pongTimeout = setTimeout(() => { ws.close(); }, pongTimeoutMs); }, intervalMs); } function reset() { clearTimeout(pingTimeout); start(); } function pong() { clearTimeout(pongTimeout); reset(); } ws.addEventListener("open", start); ws.addEventListener("message", ({ data }) => { clearTimeout(pingTimeout); start(); if (data === "PONG") pong(); }); ws.addEventListener("close", () => { clearTimeout(pingTimeout); clearTimeout(pongTimeout); }); } /** * Manages a WebSocket connection with support for reconnection, keep-alive mechanisms, * and observable state tracking. */ var WsConnection = class WsConnection { constructor(opts) { var _opts$WebSocketPonyfi; (0, import_defineProperty$1.default)(this, "id", ++WsConnection.connectCount); (0, import_defineProperty$1.default)(this, "WebSocketPonyfill", void 0); (0, import_defineProperty$1.default)(this, "urlOptions", void 0); (0, import_defineProperty$1.default)(this, "keepAliveOpts", void 0); (0, import_defineProperty$1.default)(this, "encoder", void 0); (0, import_defineProperty$1.default)(this, "wsObservable", behaviorSubject(null)); (0, import_defineProperty$1.default)(this, "openPromise", null); this.WebSocketPonyfill = (_opts$WebSocketPonyfi = opts.WebSocketPonyfill) !== null && _opts$WebSocketPonyfi !== void 0 ? _opts$WebSocketPonyfi : WebSocket; if (!this.WebSocketPonyfill) throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill"); this.urlOptions = opts.urlOptions; this.keepAliveOpts = opts.keepAlive; this.encoder = opts.encoder; } get ws() { return this.wsObservable.get(); } set ws(ws) { this.wsObservable.next(ws); } /** * Checks if the WebSocket connection is open and ready to communicate. */ isOpen() { return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise; } /** * Checks if the WebSocket connection is closed or in the process of closing. */ isClosed() { return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED); } async open() { var _this = this; if (_this.openPromise) return _this.openPromise; _this.id = ++WsConnection.connectCount; _this.openPromise = prepareUrl(_this.urlOptions).then((url) => new _this.WebSocketPonyfill(url)).then(async (ws) => { _this.ws = ws; ws.binaryType = "arraybuffer"; ws.addEventListener("message", function({ data }) { if (data === "PING") this.send("PONG"); }); if (_this.keepAliveOpts.enabled) setupPingInterval(ws, _this.keepAliveOpts); ws.addEventListener("close", () => { if (_this.ws === ws) _this.ws = null; }); await asyncWsOpen(ws); if (_this.urlOptions.connectionParams) ws.send(await buildConnectionMessage(_this.urlOptions.connectionParams, _this.encoder)); }); try { await _this.openPromise; } finally { _this.openPromise = null; } } /** * Closes the WebSocket connection gracefully. * Waits for any ongoing open operation to complete before closing. */ async close() { var _this2 = this; try { await _this2.openPromise; } finally { var _this$ws; (_this$ws = _this2.ws) === null || _this$ws === void 0 || _this$ws.close(); } } }; (0, import_defineProperty$1.default)(WsConnection, "connectCount", 0); /** * Provides a backward-compatible representation of the connection state. */ function backwardCompatibility(connection) { if (connection.isOpen()) return { id: connection.id, state: "open", ws: connection.ws }; if (connection.isClosed()) return { id: connection.id, state: "closed", ws: connection.ws }; if (!connection.ws) return null; return { id: connection.id, state: "connecting", ws: connection.ws }; } var import_defineProperty$4 = __toESM$1(require_defineProperty$1(), 1); var import_objectSpread2$5 = __toESM$1(require_objectSpread2$1(), 1); /** * A WebSocket client for managing TRPC operations, supporting lazy initialization, * reconnection, keep-alive, and request management. */ var WsClient = class { constructor(opts) { var _opts$experimental_en, _opts$retryDelayMs; (0, import_defineProperty$4.default)(this, "connectionState", void 0); (0, import_defineProperty$4.default)(this, "allowReconnect", false); (0, import_defineProperty$4.default)(this, "requestManager", new RequestManager()); (0, import_defineProperty$4.default)(this, "activeConnection", void 0); (0, import_defineProperty$4.default)(this, "reconnectRetryDelay", void 0); (0, import_defineProperty$4.default)(this, "inactivityTimeout", void 0); (0, import_defineProperty$4.default)(this, "callbacks", void 0); (0, import_defineProperty$4.default)(this, "lazyMode", void 0); (0, import_defineProperty$4.default)(this, "encoder", void 0); (0, import_defineProperty$4.default)(this, "reconnecting", null); this.encoder = (_opts$experimental_en = opts.experimental_encoder) !== null && _opts$experimental_en !== void 0 ? _opts$experimental_en : jsonEncoder; this.callbacks = { onOpen: opts.onOpen, onClose: opts.onClose, onError: opts.onError }; const lazyOptions = (0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, lazyDefaults), opts.lazy); this.inactivityTimeout = new ResettableTimeout(() => { if (this.requestManager.hasOutgoingRequests() || this.requestManager.hasPendingRequests()) { this.inactivityTimeout.reset(); return; } this.close().catch(() => null); }, lazyOptions.closeMs); this.activeConnection = new WsConnection({ WebSocketPonyfill: opts.WebSocket, urlOptions: opts, keepAlive: (0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, keepAliveDefaults), opts.keepAlive), encoder: this.encoder }); this.activeConnection.wsObservable.subscribe({ next: (ws) => { if (!ws) return; this.setupWebSocketListeners(ws); } }); this.reconnectRetryDelay = (_opts$retryDelayMs = opts.retryDelayMs) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : exponentialBackoff; this.lazyMode = lazyOptions.enabled; this.connectionState = behaviorSubject({ type: "state", state: lazyOptions.enabled ? "idle" : "connecting", error: null }); if (!this.lazyMode) this.open().catch(() => null); } /** * Opens the WebSocket connection. Handles reconnection attempts and updates * the connection state accordingly. */ async open() { var _this = this; _this.allowReconnect = true; if (_this.connectionState.get().state === "idle") _this.connectionState.next({ type: "state", state: "connecting", error: null }); try { await _this.activeConnection.open(); } catch (error) { _this.reconnect(new TRPCWebSocketClosedError({ message: "Initialization error", cause: error })); return _this.reconnecting; } } /** * Closes the WebSocket connection and stops managing requests. * Ensures all outgoing and pending requests are properly finalized. */ async close() { var _this2 = this; _this2.allowReconnect = false; _this2.inactivityTimeout.stop(); const requestsToAwait = []; for (const request of _this2.requestManager.getRequests()) if (request.message.method === "subscription") request.callbacks.complete(); else if (request.state === "outgoing") request.callbacks.error(TRPCClientError.from(new TRPCWebSocketClosedError({ message: "Closed before connection was established" }))); else requestsToAwait.push(request.end); await Promise.all(requestsToAwait).catch(() => null); await _this2.activeConnection.close().catch(() => null); _this2.connectionState.next({ type: "state", state: "idle", error: null }); } /** * Method to request the server. * Handles data transformation, batching of requests, and subscription lifecycle. * * @param op - The operation details including id, type, path, input and signal * @param transformer - Data transformer for serializing requests and deserializing responses * @param lastEventId - Optional ID of the last received event for subscriptions * * @returns An observable that emits operation results and handles cleanup */ request({ op: { id, type, path, input, signal }, transformer, lastEventId }) { return observable((observer) => { const abort = this.batchSend({ id, method: type, params: { input: transformer.input.serialize(input), path, lastEventId } }, (0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, observer), {}, { next(event) { const transformed = transformResult(event, transformer.output); if (!transformed.ok) { observer.error(TRPCClientError.from(transformed.error)); return; } observer.next({ result: transformed.result }); } })); return () => { abort(); if (type === "subscription" && this.activeConnection.isOpen()) this.send({ id, method: "subscription.stop" }); signal === null || signal === void 0 || signal.removeEventListener("abort", abort); }; }); } get connection() { return backwardCompatibility(this.activeConnection); } reconnect(closedError) { var _this3 = this; this.connectionState.next({ type: "state", state: "connecting", error: TRPCClientError.from(closedError) }); if (this.reconnecting) return; const tryReconnect = async (attemptIndex) => { try { await sleep(_this3.reconnectRetryDelay(attemptIndex)); if (_this3.allowReconnect) { await _this3.activeConnection.close(); await _this3.activeConnection.open(); if (_this3.requestManager.hasPendingRequests()) _this3.send(_this3.requestManager.getPendingRequests().map(({ message }) => message)); } _this3.reconnecting = null; } catch (_unused) { await tryReconnect(attemptIndex + 1); } }; this.reconnecting = tryReconnect(0); } setupWebSocketListeners(ws) { var _this4 = this; const handleCloseOrError = (cause) => { const reqs = this.requestManager.getPendingRequests(); for (const { message, callbacks } of reqs) { if (message.method === "subscription") continue; callbacks.error(TRPCClientError.from(cause !== null && cause !== void 0 ? cause : new TRPCWebSocketClosedError({ message: "WebSocket closed", cause }))); this.requestManager.delete(message.id); } }; ws.addEventListener("open", () => { run(async () => { var _this$callbacks$onOpe, _this$callbacks; if (_this4.lazyMode) _this4.inactivityTimeout.start(); (_this$callbacks$onOpe = (_this$callbacks = _this4.callbacks).onOpen) === null || _this$callbacks$onOpe === void 0 || _this$callbacks$onOpe.call(_this$callbacks); _this4.connectionState.next({ type: "state", state: "pending", error: null }); }).catch((error) => { ws.close(3e3); handleCloseOrError(error); }); }); ws.addEventListener("message", ({ data }) => { this.inactivityTimeout.reset(); if (["PING", "PONG"].includes(data)) return; const incomingMessage = this.encoder.decode(data); if ("method" in incomingMessage) { this.handleIncomingRequest(incomingMessage); return; } this.handleResponseMessage(incomingMessage); }); ws.addEventListener("close", (event) => { var _this$callbacks$onClo, _this$callbacks2; handleCloseOrError(event); (_this$callbacks$onClo = (_this$callbacks2 = this.callbacks).onClose) === null || _this$callbacks$onClo === void 0 || _this$callbacks$onClo.call(_this$callbacks2, event); if (!this.lazyMode || this.requestManager.hasPendingSubscriptions()) this.reconnect(new TRPCWebSocketClosedError({ message: "WebSocket closed", cause: event })); }); ws.addEventListener("error", (event) => { var _this$callbacks$onErr, _this$callbacks3; handleCloseOrError(event); (_this$callbacks$onErr = (_this$callbacks3 = this.callbacks).onError) === null || _this$callbacks$onErr === void 0 || _this$callbacks$onErr.call(_this$callbacks3, event); this.reconnect(new TRPCWebSocketClosedError({ message: "WebSocket closed", cause: event })); }); } handleResponseMessage(message) { const request = this.requestManager.getPendingRequest(message.id); if (!request) return; request.callbacks.next(message); let completed = true; if ("result" in message && request.message.method === "subscription") { if (message.result.type === "data") request.message.params.lastEventId = message.result.id; if (message.result.type !== "stopped") completed = false; } if (completed) { request.callbacks.complete(); this.requestManager.delete(message.id); } } handleIncomingRequest(message) { if (message.method === "reconnect") this.reconnect(new TRPCWebSocketClosedError({ message: "Server requested reconnect" })); } /** * Sends a message or batch of messages directly to the server. */ send(messageOrMessages) { if (!this.activeConnection.isOpen()) throw new Error("Active connection is not open"); const messages = messageOrMessages instanceof Array ? messageOrMessages : [messageOrMessages]; this.activeConnection.ws.send(this.encoder.encode(messages.length === 1 ? messages[0] : messages)); } /** * Groups requests for batch sending. * * @returns A function to abort the batched request. */ batchSend(message, callbacks) { var _this5 = this; this.inactivityTimeout.reset(); run(async () => { if (!_this5.activeConnection.isOpen()) await _this5.open(); await sleep(0); if (!_this5.requestManager.hasOutgoingRequests()) return; _this5.send(_this5.requestManager.flush().map(({ message: message$1 }) => message$1)); }).catch((err) => { this.requestManager.delete(message.id); callbacks.error(TRPCClientError.from(err)); }); return this.requestManager.register(message, callbacks); } }; function createWSClient(opts) { return new WsClient(opts); } function wsLink(opts) { const { client } = opts; const transformer = getTransformer(opts.transformer); return () => { return ({ op }) => { return observable((observer) => { const connStateSubscription = op.type === "subscription" ? client.connectionState.subscribe({ next(result) { observer.next({ result, context: op.context }); } }) : null; const requestSubscription = client.request({ op, transformer }).subscribe(observer); return () => { requestSubscription.unsubscribe(); connStateSubscription === null || connStateSubscription === void 0 || connStateSubscription.unsubscribe(); }; }); }; }; } //#endregion //#region ../../node_modules/.pnpm/@trpc+client@11.17.0_@trpc+server@11.17.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/index.mjs var import_defineProperty = __toESM$1(require_defineProperty$1(), 1); var import_objectSpread2$4 = __toESM$1(require_objectSpread2$1(), 1); var TRPCUntypedClient = class { constructor(opts) { (0, import_defineProperty.default)(this, "links", void 0); (0, import_defineProperty.default)(this, "runtime", void 0); (0, import_defineProperty.default)(this, "requestId", void 0); this.requestId = 0; this.runtime = {}; this.links = opts.links.map((link) => link(this.runtime)); } $request(opts) { var _opts$context; return createChain({ links: this.links, op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, { context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {}, id: ++this.requestId }) }).pipe(share()); } async requestAsPromise(opts) { var _this = this; try { return (await observableToPromise(_this.$request(opts))).result.data; } catch (err) { throw TRPCClientError.from(err); } } query(path, input, opts) { return this.requestAsPromise({ type: "query", path, input, context: opts === null || opts === void 0 ? void 0 : opts.context, signal: opts === null || opts === void 0 ? void 0 : opts.signal }); } mutation(path, input, opts) { return this.requestAsPromise({ type: "mutation", path, input, context: opts === null || opts === void 0 ? void 0 : opts.context, signal: opts === null || opts === void 0 ? void 0 : opts.signal }); } subscription(path, input, opts) { return this.$request({ type: "subscription", path, input, context: opts.context, signal: opts.signal }).subscribe({ next(envelope) { switch (envelope.result.type) { case "state": var _opts$onConnectionSta; (_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result); break; case "started": var _opts$onStarted; (_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context }); break; case "stopped": var _opts$onStopped; (_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts); break; case "data": case void 0: var _opts$onData; (_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data); break; } }, error(err) { var _opts$onError; (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err); }, complete() { var _opts$onComplete; (_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts); } }); } }; var untypedClientSymbol = Symbol.for("trpc_untypedClient"); var clientCallTypeMap = { query: "query", mutate: "mutation", subscribe: "subscription" }; /** @internal */ var clientCallTypeToProcedureType = (clientCallType) => { return clientCallTypeMap[clientCallType]; }; /** * @internal */ function createTRPCClientProxy(client) { const proxy = createRecursiveProxy(({ path, args }) => { const pathCopy = [...path]; const procedureType = clientCallTypeToProcedureType(pathCopy.pop()); const fullPath = pathCopy.join("."); return client[procedureType](fullPath, ...args); }); return createFlatProxy((key) => { if (key === untypedClientSymbol) return client; return proxy[key]; }); } function createTRPCClient(opts) { return createTRPCClientProxy(new TRPCUntypedClient(opts)); } __toESM$1(require_objectSpread2$1(), 1); var import_objectSpread2$2 = __toESM$1(require_objectSpread2$1(), 1); function inputWithTrackedEventId(input, lastEventId) { if (!lastEventId) return input; if (input != null && typeof input !== "object") return input; return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, input !== null && input !== void 0 ? input : {}), {}, { lastEventId }); } __toESM$1(__commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) { function _asyncIterator$1(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); } function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r$1) { if (Object(r$1) !== r$1) return Promise.reject(/* @__PURE__ */ new TypeError(r$1 + " is not an object.")); var n = r$1.done; return Promise.resolve(r$1.value).then(function(r$2) { return { value: r$2, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) { this.s = r$1, this.n = r$1.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r$1) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r$1, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r$1) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); } module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports; } })(), 1); var import_objectSpread2$1 = __toESM$1(require_objectSpread2$1(), 1); /** * @see https://trpc.io/docs/v11/client/links/retryLink */ function retryLink(opts) { return () => { return (callOpts) => { return observable((observer) => { let next$; let callNextTimeout = void 0; let lastEventId = void 0; attempt(1); function opWithLastEventId() { const op = callOpts.op; if (!lastEventId) return op; return (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, op), {}, { input: inputWithTrackedEventId(op.input, lastEventId) }); } function attempt(attempts) { const op = opWithLastEventId(); next$ = callOpts.next(op).subscribe({ error(error) { var _opts$retryDelayMs, _opts$retryDelayMs2; if (!opts.retry({ op, attempts, error })) { observer.error(error); return; } const delayMs = (_opts$retryDelayMs = (_opts$retryDelayMs2 = opts.retryDelayMs) === null || _opts$retryDelayMs2 === void 0 ? void 0 : _opts$retryDelayMs2.call(opts, attempts)) !== null && _opts$retryDelayMs !== void 0 ? _opts$retryDelayMs : 0; if (delayMs <= 0) { attempt(attempts + 1); return; } callNextTimeout = setTimeout(() => attempt(attempts + 1), delayMs); }, next(envelope) { if ((!envelope.result.type || envelope.result.type === "data") && envelope.result.id) lastEventId = envelope.result.id; observer.next(envelope); }, complete() { observer.complete(); } }); } return () => { next$.unsubscribe(); clearTimeout(callNextTimeout); }; }); }; }; } var require_usingCtx = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) { function _usingCtx() { var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) { var n$1 = Error(); return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1; }, e = {}, n = []; function using(r$1, e$1) { if (null != e$1) { if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined."); if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")]; if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o; if ("function" != typeof o) throw new TypeError("Object is not disposable."); t && (o = function o$1() { try { t.call(e$1); } catch (r$2) { return Promise.reject(r$2); } }), n.push({ v: e$1, d: o, a: r$1 }); } else r$1 && n.push({ d: e$1, a: r$1 }); return e$1; } return { e, u: using.bind(null, !1), a: using.bind(null, !0), d: function d() { var o, t = this.e, s = 0; function next() { for (; o = n.pop();) try { if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next); if (o.d) { var r$1 = o.d.call(o.v); if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err); } else s |= 1; } catch (r$2) { return err(r$2); } if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve(); if (t !== e) throw t; } function err(n$1) { return t = t !== e ? new r(n$1, t) : n$1, next(); } return next(); } }; } module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_OverloadYield = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) { function _OverloadYield(e, d) { this.v = e, this.k = d; } module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_awaitAsyncGenerator = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) { var OverloadYield$1 = require_OverloadYield(); function _awaitAsyncGenerator$1(e) { return new OverloadYield$1(e, 0); } module.exports = _awaitAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); var require_wrapAsyncGenerator = __commonJS$1({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) { var OverloadYield = require_OverloadYield(); function _wrapAsyncGenerator$1(e) { return function() { return new AsyncGenerator(e.apply(this, arguments)); }; } function AsyncGenerator(e) { var r, t; function resume(r$1, t$1) { try { var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield; Promise.resolve(u ? o.v : o).then(function(t$2) { if (u) { var i = "return" === r$1 ? "return" : "next"; if (!o.k || t$2.done) return resume(i, t$2); t$2 = e[i](t$2).value; } settle(n.done ? "return" : "normal", t$2); }, function(e$1) { resume("throw", e$1); }); } catch (e$1) { settle("throw", e$1); } } function settle(e$1, n) { switch (e$1) { case "return": r.resolve({ value: n, done: !0 }); break; case "throw": r.reject(n); break; default: r.resolve({ value: n, done: !1 }); } (r = r.next) ? resume(r.key, r.arg) : t = null; } this._invoke = function(e$1, n) { return new Promise(function(o, u) { var i = { key: e$1, arg: n, resolve: o, reject: u, next: null }; t ? t = t.next = i : (r = t = i, resume(e$1, n)); }); }, "function" != typeof e["return"] && (this["return"] = void 0); } AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() { return this; }, AsyncGenerator.prototype.next = function(e) { return this._invoke("next", e); }, AsyncGenerator.prototype["throw"] = function(e) { return this._invoke("throw", e); }, AsyncGenerator.prototype["return"] = function(e) { return this._invoke("return", e); }; module.exports = _wrapAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports; } }); __toESM$1(require_usingCtx(), 1); __toESM$1(require_awaitAsyncGenerator(), 1); __toESM$1(require_wrapAsyncGenerator(), 1); __toESM$1(require_objectSpread2$1(), 1); //#endregion //#region ../send/frontend/src/lib/config.ts var TRPC_WS_PATH = `/trpc/ws`; //#endregion //#region \0vite/preload-helper.js var scriptRel = "modulepreload"; var assetsURL = function(dep) { return "/" + dep; }; var seen = {}; var __vitePreload = function preload(baseModule, deps, importerUrl) { let promise = Promise.resolve(); if (deps && deps.length > 0) { const links = document.getElementsByTagName("link"); const cspNonceMeta = document.querySelector("meta[property=csp-nonce]"); const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce"); function allSettled(promises) { return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({ status: "fulfilled", value }), (reason) => ({ status: "rejected", reason })))); } promise = allSettled(deps.map((dep) => { dep = assetsURL(dep, importerUrl); if (dep in seen) return; seen[dep] = true; const isCss = dep.endsWith(".css"); const cssSelector = isCss ? "[rel=\"stylesheet\"]" : ""; if (!!importerUrl) for (let i = links.length - 1; i >= 0; i--) { const link = links[i]; if (link.href === dep && (!isCss || link.rel === "stylesheet")) return; } else if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) return; const link = document.createElement("link"); link.rel = isCss ? "stylesheet" : scriptRel; if (!isCss) link.as = "script"; link.crossOrigin = ""; link.href = dep; if (cspNonce) link.setAttribute("nonce", cspNonce); document.head.appendChild(link); if (isCss) return new Promise((res, rej) => { link.addEventListener("load", res); link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`))); }); })); } function handlePreloadError(err) { const e = new Event("vite:preloadError", { cancelable: true }); e.payload = err; window.dispatchEvent(e); if (!e.defaultPrevented) throw err; } return promise.then((res) => { for (const item of res || []) { if (item.status !== "rejected") continue; handlePreloadError(item.reason); } return baseModule().catch(handlePreloadError); }); }; //#endregion //#region ../send/frontend/src/lib/trpc.ts /** * This is the client-side code that uses the inferred types from the server */ var serverUrl = "https://send-backend.tb.pro".trim(); var refreshUrl = `${serverUrl}/api/auth/refresh`; var trpcUrl = `${serverUrl}/trpc`; /** * Detect whether we're running in a test/automation context, where the * WebSocket must stay closed. * * Unit tests inject `import.meta.env.VITE_TESTING`. When that build-time flag is * unavailable — as in the shipped background bundle — fall back to the presence * of the WebExtension `browser.test` API, which the Thunderbird/Firefox test * harness only exposes when the add-on is loaded under automation. This keeps a * logged-out automation profile from ever opening the socket at startup. */ function detectTesting() { return typeof browser !== "undefined" && Boolean(browser.test); } var isTesting = detectTesting(); /** * Decide how (and whether) to build the WebSocket client. * * Returns `null` — meaning "do not connect" — when running under unit tests or * when no backend host is configured (empty `serverUrl`). Otherwise returns the * client config with **lazy mode** enabled. * * Lazy mode is critical: the background page of the built-in/system add-on * imports this module on every Thunderbird launch, including fresh, * never-signed-in profiles. A non-lazy client opens the socket as a side effect * of construction (at module load), which under automation triggers a fatal * "non-local network connections are disabled" abort and crashes the process * before any feature is used. With lazy mode the connection is deferred until * the first subscription actually runs (i.e. an authenticated user is using a * feature) and is closed again after inactivity, so a logged-out profile makes * zero outbound connections at startup. */ function getWsClientConfig(url, testing) { const normalizedUrl = url.trim(); if (testing || normalizedUrl.length === 0) return null; return { url: `${normalizedUrl}${TRPC_WS_PATH}`, lazy: { enabled: true, closeMs: 1e3 } }; } var wsClientConfig = getWsClientConfig(serverUrl, isTesting); var wsClient = wsClientConfig ? createWSClient(wsClientConfig) : null; /** * We only import the `AppRouter` type from the server - this is not available at runtime */ async function fetchWithLogoutCheck(url, options) { async function getAuthStore() { const { useAuthStore } = await __vitePreload(async () => { const { useAuthStore } = await Promise.resolve().then(() => auth_store_exports); return { useAuthStore }; }, void 0); return useAuthStore(); } async function buildHeaders() { const headers = new Headers(options.headers); try { if (!headers.has("Authorization")) { const token = await (await getAuthStore()).getAccessToken(); if (token) headers.set("Authorization", `Bearer ${token}`); } } catch {} return headers; } const res = await fetch(url, { ...options, headers: await buildHeaders(), credentials: "include" }); if (res.headers?.get?.("x-logout")) try { if (await (await getAuthStore()).recoverOrForceLogout()) return await fetch(url, { ...options, headers: await buildHeaders(), credentials: "include" }); } catch (error) { console.error("Forced-logout handling failed:", error); } return res; } var trpc = createTRPCClient({ links: [splitLink({ condition: (op) => op.type === "subscription", false: [retryLink({ /** * Retry strategy for failed requests: * - For 401 unauthorized errors: Attempts to refresh the token and retries up to 3 times * - For queries (not mutations): Retries up to 3 times * - For all other cases: No retry */ retry(opts) { if (opts.error.data?.code === "UNAUTHORIZED") { if (opts.op.type !== "query") return false; fetch(refreshUrl, { credentials: "include" }).then(() => { console.info("revalidated token"); }).catch((err) => { console.info("could not revalidate token", err); }); return opts.attempts <= 3; } } }), httpBatchLink({ url: trpcUrl, fetch: fetchWithLogoutCheck })], true: wsClient ? [wsLink({ client: wsClient })] : [httpBatchLink({ url: trpcUrl, fetch: fetchWithLogoutCheck })] })] }); //#endregion //#region ../send/frontend/src/lib/api.ts var ApiConnection = class { constructor(serverUrl) { if (!serverUrl) throw Error("No Server URL provided."); const u = new URL(serverUrl); this.serverUrl = u.origin; this.getStorageType().then((isBucketStorage) => { this.isBucketStorage = isBucketStorage; }); } async getStorageType() { return true; } toString() { return this.serverUrl; } async removeAuthToken() { await this.call("api/auth/oidc/logout"); } async call(path, body = {}, method = "GET", headers = {}, options) { const url = `${this.serverUrl}/api/${path}`; const refreshTokenUrl = `${this.serverUrl}/api/auth/refresh`; const requestHeaders = { ...headers }; if (!requestHeaders["Authorization"]) try { const { useAuthStore } = await __vitePreload(async () => { const { useAuthStore } = await Promise.resolve().then(() => auth_store_exports); return { useAuthStore }; }, void 0); const accessToken = await useAuthStore().getAccessToken(); if (accessToken) requestHeaders["Authorization"] = `Bearer ${accessToken}`; } catch (error) { console.debug("Could not get OIDC token for request:", error); } const opts = { mode: "cors", credentials: "include", method, headers: { "content-type": "application/json", ...requestHeaders } }; if (method.trim().toUpperCase() === "POST") opts.body = JSON.stringify({ ...body }); let resp; try { resp = await fetch(url, opts); } catch (e) { console.log(e); options?.onFailure?.({ kind: "network", status: null, error: e }); return null; } if (resp.headers?.get?.("x-logout")) try { const { useAuthStore } = await __vitePreload(async () => { const { useAuthStore } = await Promise.resolve().then(() => auth_store_exports); return { useAuthStore }; }, void 0); const authStore = useAuthStore(); if (!await authStore.recoverOrForceLogout()) return null; const newToken = await authStore.getAccessToken(); if (newToken) { opts.headers["Authorization"] = `Bearer ${newToken}`; resp = await fetch(url, opts); } } catch (error) { console.error("Forced-logout handling failed:", error); return null; } else if (resp.status === 401) if (requestHeaders["Authorization"]) try { const { useAuthStore } = await __vitePreload(async () => { const { useAuthStore } = await Promise.resolve().then(() => auth_store_exports); return { useAuthStore }; }, void 0); const newToken = await useAuthStore().refreshToken(); if (newToken) { opts.headers["Authorization"] = `Bearer ${newToken}`; resp = await fetch(url, opts); } } catch (error) { console.error("Token refresh failed:", error); options?.onFailure?.({ kind: "network", status: null, error }); return null; } else try { await fetch(refreshTokenUrl, { credentials: "include", mode: "cors" }); resp = await fetch(url, opts); } catch (error) { console.log(error); options?.onFailure?.({ kind: "network", status: null, error }); return null; } if (!resp.ok) { let body; try { body = (await resp.text()).slice(0, 500); } catch { body = void 0; } options?.onFailure?.({ kind: "http", status: resp.status, statusText: resp.statusText, body }); return null; } if (!!options?.fullResponse) return resp; return resp.json(); } }; //#endregion //#region ../send/frontend/src/stores/api-store.ts var useApiStore = defineStore("api", () => { const url = useConfigStore().serverUrl; return { api: new ApiConnection(url) }; }); //#endregion //#region ../send/frontend/src/lib/init.ts /** * Loads user and keychain from storage; creates default folder if necessary. * @param {UserStore} userStore - Pinia store for managing user. * @param {Keychain} keychain - Instance of Keychain class. * @param {FolderStore} folderStore - Pinia store for managing folders. * @return {Promise} - Returns Promise of 0 (success) or an error code typed by INIT_ERRORS. */ async function _init(userStore, keychain, folderStore) { const hasUser = await userStore.loadFromLocalStorage(); const hasKeychain = await keychain.load(); if (!hasUser) return INIT_ERRORS.NO_USER; if (!hasKeychain) return INIT_ERRORS.NO_KEYCHAIN; try { const { api } = useApiStore(); await restoreKeysUsingLocalStorage(keychain, api); } catch (error) { console.warn("init(): could not restore keys before folder check", error); } await folderStore.sync(); const defaultFolder = folderStore?.defaultFolder; const defaultFolderKeyIsMissing = defaultFolder && !keychain.keys[defaultFolder.id]; if (defaultFolderKeyIsMissing) { console.warn(`Default folder ${defaultFolder.id} exists but has no key. Deleting orphaned container and recreating.`); await folderStore.deleteFolder(defaultFolder.id); } if (!defaultFolder || defaultFolderKeyIsMissing) { if (!(await folderStore.createFolder())?.id) return INIT_ERRORS.COULD_NOT_CREATE_DEFAULT_FOLDER; } return INIT_ERRORS.NONE; } var inFlight = null; function init(userStore, keychain, folderStore) { if (inFlight) return inFlight; inFlight = _init(userStore, keychain, folderStore).finally(() => { inFlight = null; }); return inFlight; } /*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */ //#endregion //#region ../send/frontend/src/lib/utils.ts var import_jszip_min = /* @__PURE__ */ __toESM$2((/* @__PURE__ */ __commonJSMin(((exports, module) => { (function(e) { if ("object" == typeof exports && "undefined" != typeof module) module.exports = e(); else if ("function" == typeof define && define.amd) define([], e); else ("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this).JSZip = e(); })(function() { return function s(a, o, h) { function u(r, e) { if (!o[r]) { if (!a[r]) { var t = "function" == typeof __require && __require; if (!e && t) return t(r, !0); if (l) return l(r, !0); var n = /* @__PURE__ */ new Error("Cannot find module '" + r + "'"); throw n.code = "MODULE_NOT_FOUND", n; } var i = o[r] = { exports: {} }; a[r][0].call(i.exports, function(e) { var t = a[r][1][e]; return u(t || e); }, i, i.exports, s, a, o, h); } return o[r].exports; } for (var l = "function" == typeof __require && __require, e = 0; e < h.length; e++) u(h[e]); return u; }({ 1: [function(e, t, r) { "use strict"; var d = e("./utils"), c = e("./support"), p = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; r.encode = function(e) { for (var t, r, n, i, s, a, o, h = [], u = 0, l = e.length, f = l, c = "string" !== d.getTypeOf(e); u < e.length;) f = l - u, n = c ? (t = e[u++], r = u < l ? e[u++] : 0, u < l ? e[u++] : 0) : (t = e.charCodeAt(u++), r = u < l ? e.charCodeAt(u++) : 0, u < l ? e.charCodeAt(u++) : 0), i = t >> 2, s = (3 & t) << 4 | r >> 4, a = 1 < f ? (15 & r) << 2 | n >> 6 : 64, o = 2 < f ? 63 & n : 64, h.push(p.charAt(i) + p.charAt(s) + p.charAt(a) + p.charAt(o)); return h.join(""); }, r.decode = function(e) { var t, r, n, i, s, a, o = 0, h = 0, u = "data:"; if (e.substr(0, u.length) === u) throw new Error("Invalid base64 input, it looks like a data url."); var l, f = 3 * (e = e.replace(/[^A-Za-z0-9+/=]/g, "")).length / 4; if (e.charAt(e.length - 1) === p.charAt(64) && f--, e.charAt(e.length - 2) === p.charAt(64) && f--, f % 1 != 0) throw new Error("Invalid base64 input, bad content length."); for (l = c.uint8array ? new Uint8Array(0 | f) : new Array(0 | f); o < e.length;) t = p.indexOf(e.charAt(o++)) << 2 | (i = p.indexOf(e.charAt(o++))) >> 4, r = (15 & i) << 4 | (s = p.indexOf(e.charAt(o++))) >> 2, n = (3 & s) << 6 | (a = p.indexOf(e.charAt(o++))), l[h++] = t, 64 !== s && (l[h++] = r), 64 !== a && (l[h++] = n); return l; }; }, { "./support": 30, "./utils": 32 }], 2: [function(e, t, r) { "use strict"; var n = e("./external"), i = e("./stream/DataWorker"), s = e("./stream/Crc32Probe"), a = e("./stream/DataLengthProbe"); function o(e, t, r, n, i) { this.compressedSize = e, this.uncompressedSize = t, this.crc32 = r, this.compression = n, this.compressedContent = i; } o.prototype = { getContentWorker: function() { var e = new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")), t = this; return e.on("end", function() { if (this.streamInfo.data_length !== t.uncompressedSize) throw new Error("Bug : uncompressed data size mismatch"); }), e; }, getCompressedWorker: function() { return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression); } }, o.createWorkerFrom = function(e, t, r) { return e.pipe(new s()).pipe(new a("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression", t); }, t.exports = o; }, { "./external": 6, "./stream/Crc32Probe": 25, "./stream/DataLengthProbe": 26, "./stream/DataWorker": 27 }], 3: [function(e, t, r) { "use strict"; var n = e("./stream/GenericWorker"); r.STORE = { magic: "\0\0", compressWorker: function() { return new n("STORE compression"); }, uncompressWorker: function() { return new n("STORE decompression"); } }, r.DEFLATE = e("./flate"); }, { "./flate": 7, "./stream/GenericWorker": 28 }], 4: [function(e, t, r) { "use strict"; var n = e("./utils"); var o = function() { for (var e, t = [], r = 0; r < 256; r++) { e = r; for (var n = 0; n < 8; n++) e = 1 & e ? 3988292384 ^ e >>> 1 : e >>> 1; t[r] = e; } return t; }(); t.exports = function(e, t) { return void 0 !== e && e.length ? "string" !== n.getTypeOf(e) ? function(e, t, r, n) { var i = o, s = n + r; e ^= -1; for (var a = n; a < s; a++) e = e >>> 8 ^ i[255 & (e ^ t[a])]; return -1 ^ e; }(0 | t, e, e.length, 0) : function(e, t, r, n) { var i = o, s = n + r; e ^= -1; for (var a = n; a < s; a++) e = e >>> 8 ^ i[255 & (e ^ t.charCodeAt(a))]; return -1 ^ e; }(0 | t, e, e.length, 0) : 0; }; }, { "./utils": 32 }], 5: [function(e, t, r) { "use strict"; r.base64 = !1, r.binary = !1, r.dir = !1, r.createFolders = !0, r.date = null, r.compression = null, r.compressionOptions = null, r.comment = null, r.unixPermissions = null, r.dosPermissions = null; }, {}], 6: [function(e, t, r) { "use strict"; var n = null; n = "undefined" != typeof Promise ? Promise : e("lie"), t.exports = { Promise: n }; }, { lie: 37 }], 7: [function(e, t, r) { "use strict"; var n = "undefined" != typeof Uint8Array && "undefined" != typeof Uint16Array && "undefined" != typeof Uint32Array, i = e("pako"), s = e("./utils"), a = e("./stream/GenericWorker"), o = n ? "uint8array" : "array"; function h(e, t) { a.call(this, "FlateWorker/" + e), this._pako = null, this._pakoAction = e, this._pakoOptions = t, this.meta = {}; } r.magic = "\b\0", s.inherits(h, a), h.prototype.processChunk = function(e) { this.meta = e.meta, null === this._pako && this._createPako(), this._pako.push(s.transformTo(o, e.data), !1); }, h.prototype.flush = function() { a.prototype.flush.call(this), null === this._pako && this._createPako(), this._pako.push([], !0); }, h.prototype.cleanUp = function() { a.prototype.cleanUp.call(this), this._pako = null; }, h.prototype._createPako = function() { this._pako = new i[this._pakoAction]({ raw: !0, level: this._pakoOptions.level || -1 }); var t = this; this._pako.onData = function(e) { t.push({ data: e, meta: t.meta }); }; }, r.compressWorker = function(e) { return new h("Deflate", e); }, r.uncompressWorker = function() { return new h("Inflate", {}); }; }, { "./stream/GenericWorker": 28, "./utils": 32, pako: 38 }], 8: [function(e, t, r) { "use strict"; function A(e, t) { var r, n = ""; for (r = 0; r < t; r++) n += String.fromCharCode(255 & e), e >>>= 8; return n; } function n(e, t, r, n, i, s) { var a, o, h = e.file, u = e.compression, l = s !== O.utf8encode, f = I.transformTo("string", s(h.name)), c = I.transformTo("string", O.utf8encode(h.name)), d = h.comment, p = I.transformTo("string", s(d)), m = I.transformTo("string", O.utf8encode(d)), _ = c.length !== h.name.length, g = m.length !== d.length, b = "", v = "", y = "", w = h.dir, k = h.date, x = { crc32: 0, compressedSize: 0, uncompressedSize: 0 }; t && !r || (x.crc32 = e.crc32, x.compressedSize = e.compressedSize, x.uncompressedSize = e.uncompressedSize); var S = 0; t && (S |= 8), l || !_ && !g || (S |= 2048); var z = 0, C = 0; w && (z |= 16), "UNIX" === i ? (C = 798, z |= function(e, t) { var r = e; return e || (r = t ? 16893 : 33204), (65535 & r) << 16; }(h.unixPermissions, w)) : (C = 20, z |= function(e) { return 63 & (e || 0); }(h.dosPermissions)), a = k.getUTCHours(), a <<= 6, a |= k.getUTCMinutes(), a <<= 5, a |= k.getUTCSeconds() / 2, o = k.getUTCFullYear() - 1980, o <<= 4, o |= k.getUTCMonth() + 1, o <<= 5, o |= k.getUTCDate(), _ && (v = A(1, 1) + A(B(f), 4) + c, b += "up" + A(v.length, 2) + v), g && (y = A(1, 1) + A(B(p), 4) + m, b += "uc" + A(y.length, 2) + y); var E = ""; return E += "\n\0", E += A(S, 2), E += u.magic, E += A(a, 2), E += A(o, 2), E += A(x.crc32, 4), E += A(x.compressedSize, 4), E += A(x.uncompressedSize, 4), E += A(f.length, 2), E += A(b.length, 2), { fileRecord: R.LOCAL_FILE_HEADER + E + f + b, dirRecord: R.CENTRAL_FILE_HEADER + A(C, 2) + E + A(p.length, 2) + "\0\0\0\0" + A(z, 4) + A(n, 4) + f + b + p }; } var I = e("../utils"), i = e("../stream/GenericWorker"), O = e("../utf8"), B = e("../crc32"), R = e("../signature"); function s(e, t, r, n) { i.call(this, "ZipFileWorker"), this.bytesWritten = 0, this.zipComment = t, this.zipPlatform = r, this.encodeFileName = n, this.streamFiles = e, this.accumulate = !1, this.contentBuffer = [], this.dirRecords = [], this.currentSourceOffset = 0, this.entriesCount = 0, this.currentFile = null, this._sources = []; } I.inherits(s, i), s.prototype.push = function(e) { var t = e.meta.percent || 0, r = this.entriesCount, n = this._sources.length; this.accumulate ? this.contentBuffer.push(e) : (this.bytesWritten += e.data.length, i.prototype.push.call(this, { data: e.data, meta: { currentFile: this.currentFile, percent: r ? (t + 100 * (r - n - 1)) / r : 100 } })); }, s.prototype.openedSource = function(e) { this.currentSourceOffset = this.bytesWritten, this.currentFile = e.file.name; var t = this.streamFiles && !e.file.dir; if (t) { var r = n(e, t, !1, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); this.push({ data: r.fileRecord, meta: { percent: 0 } }); } else this.accumulate = !0; }, s.prototype.closedSource = function(e) { this.accumulate = !1; var t = this.streamFiles && !e.file.dir, r = n(e, t, !0, this.currentSourceOffset, this.zipPlatform, this.encodeFileName); if (this.dirRecords.push(r.dirRecord), t) this.push({ data: function(e) { return R.DATA_DESCRIPTOR + A(e.crc32, 4) + A(e.compressedSize, 4) + A(e.uncompressedSize, 4); }(e), meta: { percent: 100 } }); else for (this.push({ data: r.fileRecord, meta: { percent: 0 } }); this.contentBuffer.length;) this.push(this.contentBuffer.shift()); this.currentFile = null; }, s.prototype.flush = function() { for (var e = this.bytesWritten, t = 0; t < this.dirRecords.length; t++) this.push({ data: this.dirRecords[t], meta: { percent: 100 } }); var r = this.bytesWritten - e, n = function(e, t, r, n, i) { var s = I.transformTo("string", i(n)); return R.CENTRAL_DIRECTORY_END + "\0\0\0\0" + A(e, 2) + A(e, 2) + A(t, 4) + A(r, 4) + A(s.length, 2) + s; }(this.dirRecords.length, r, e, this.zipComment, this.encodeFileName); this.push({ data: n, meta: { percent: 100 } }); }, s.prototype.prepareNextSource = function() { this.previous = this._sources.shift(), this.openedSource(this.previous.streamInfo), this.isPaused ? this.previous.pause() : this.previous.resume(); }, s.prototype.registerPrevious = function(e) { this._sources.push(e); var t = this; return e.on("data", function(e) { t.processChunk(e); }), e.on("end", function() { t.closedSource(t.previous.streamInfo), t._sources.length ? t.prepareNextSource() : t.end(); }), e.on("error", function(e) { t.error(e); }), this; }, s.prototype.resume = function() { return !!i.prototype.resume.call(this) && (!this.previous && this._sources.length ? (this.prepareNextSource(), !0) : this.previous || this._sources.length || this.generatedError ? void 0 : (this.end(), !0)); }, s.prototype.error = function(e) { var t = this._sources; if (!i.prototype.error.call(this, e)) return !1; for (var r = 0; r < t.length; r++) try { t[r].error(e); } catch (e) {} return !0; }, s.prototype.lock = function() { i.prototype.lock.call(this); for (var e = this._sources, t = 0; t < e.length; t++) e[t].lock(); }, t.exports = s; }, { "../crc32": 4, "../signature": 23, "../stream/GenericWorker": 28, "../utf8": 31, "../utils": 32 }], 9: [function(e, t, r) { "use strict"; var u = e("../compressions"), n = e("./ZipFileWorker"); r.generateWorker = function(e, a, t) { var o = new n(a.streamFiles, t, a.platform, a.encodeFileName), h = 0; try { e.forEach(function(e, t) { h++; var r = function(e, t) { var r = e || t, n = u[r]; if (!n) throw new Error(r + " is not a valid compression method !"); return n; }(t.options.compression, a.compression), n = t.options.compressionOptions || a.compressionOptions || {}, i = t.dir, s = t.date; t._compressWorker(r, n).withStreamInfo("file", { name: e, dir: i, date: s, comment: t.comment || "", unixPermissions: t.unixPermissions, dosPermissions: t.dosPermissions }).pipe(o); }), o.entriesCount = h; } catch (e) { o.error(e); } return o; }; }, { "../compressions": 3, "./ZipFileWorker": 8 }], 10: [function(e, t, r) { "use strict"; function n() { if (!(this instanceof n)) return new n(); if (arguments.length) throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide."); this.files = Object.create(null), this.comment = null, this.root = "", this.clone = function() { var e = new n(); for (var t in this) "function" != typeof this[t] && (e[t] = this[t]); return e; }; } (n.prototype = e("./object")).loadAsync = e("./load"), n.support = e("./support"), n.defaults = e("./defaults"), n.version = "3.10.1", n.loadAsync = function(e, t) { return new n().loadAsync(e, t); }, n.external = e("./external"), t.exports = n; }, { "./defaults": 5, "./external": 6, "./load": 11, "./object": 15, "./support": 30 }], 11: [function(e, t, r) { "use strict"; var u = e("./utils"), i = e("./external"), n = e("./utf8"), s = e("./zipEntries"), a = e("./stream/Crc32Probe"), l = e("./nodejsUtils"); function f(n) { return new i.Promise(function(e, t) { var r = n.decompressed.getContentWorker().pipe(new a()); r.on("error", function(e) { t(e); }).on("end", function() { r.streamInfo.crc32 !== n.decompressed.crc32 ? t(/* @__PURE__ */ new Error("Corrupted zip : CRC32 mismatch")) : e(); }).resume(); }); } t.exports = function(e, o) { var h = this; return o = u.extend(o || {}, { base64: !1, checkCRC32: !1, optimizedBinaryString: !1, createFolders: !1, decodeFileName: n.utf8decode }), l.isNode && l.isStream(e) ? i.Promise.reject(/* @__PURE__ */ new Error("JSZip can't accept a stream when loading a zip file.")) : u.prepareContent("the loaded zip file", e, !0, o.optimizedBinaryString, o.base64).then(function(e) { var t = new s(o); return t.load(e), t; }).then(function(e) { var t = [i.Promise.resolve(e)], r = e.files; if (o.checkCRC32) for (var n = 0; n < r.length; n++) t.push(f(r[n])); return i.Promise.all(t); }).then(function(e) { for (var t = e.shift(), r = t.files, n = 0; n < r.length; n++) { var i = r[n], s = i.fileNameStr, a = u.resolve(i.fileNameStr); h.file(a, i.decompressed, { binary: !0, optimizedBinaryString: !0, date: i.date, dir: i.dir, comment: i.fileCommentStr.length ? i.fileCommentStr : null, unixPermissions: i.unixPermissions, dosPermissions: i.dosPermissions, createFolders: o.createFolders }), i.dir || (h.file(a).unsafeOriginalName = s); } return t.zipComment.length && (h.comment = t.zipComment), h; }); }; }, { "./external": 6, "./nodejsUtils": 14, "./stream/Crc32Probe": 25, "./utf8": 31, "./utils": 32, "./zipEntries": 33 }], 12: [function(e, t, r) { "use strict"; var n = e("../utils"), i = e("../stream/GenericWorker"); function s(e, t) { i.call(this, "Nodejs stream input adapter for " + e), this._upstreamEnded = !1, this._bindStream(t); } n.inherits(s, i), s.prototype._bindStream = function(e) { var t = this; (this._stream = e).pause(), e.on("data", function(e) { t.push({ data: e, meta: { percent: 0 } }); }).on("error", function(e) { t.isPaused ? this.generatedError = e : t.error(e); }).on("end", function() { t.isPaused ? t._upstreamEnded = !0 : t.end(); }); }, s.prototype.pause = function() { return !!i.prototype.pause.call(this) && (this._stream.pause(), !0); }, s.prototype.resume = function() { return !!i.prototype.resume.call(this) && (this._upstreamEnded ? this.end() : this._stream.resume(), !0); }, t.exports = s; }, { "../stream/GenericWorker": 28, "../utils": 32 }], 13: [function(e, t, r) { "use strict"; var i = e("readable-stream").Readable; function n(e, t, r) { i.call(this, t), this._helper = e; var n = this; e.on("data", function(e, t) { n.push(e) || n._helper.pause(), r && r(t); }).on("error", function(e) { n.emit("error", e); }).on("end", function() { n.push(null); }); } e("../utils").inherits(n, i), n.prototype._read = function() { this._helper.resume(); }, t.exports = n; }, { "../utils": 32, "readable-stream": 16 }], 14: [function(e, t, r) { "use strict"; t.exports = { isNode: "undefined" != typeof Buffer, newBufferFrom: function(e, t) { if (Buffer.from && Buffer.from !== Uint8Array.from) return Buffer.from(e, t); if ("number" == typeof e) throw new Error("The \"data\" argument must not be a number"); return new Buffer(e, t); }, allocBuffer: function(e) { if (Buffer.alloc) return Buffer.alloc(e); var t = new Buffer(e); return t.fill(0), t; }, isBuffer: function(e) { return Buffer.isBuffer(e); }, isStream: function(e) { return e && "function" == typeof e.on && "function" == typeof e.pause && "function" == typeof e.resume; } }; }, {}], 15: [function(e, t, r) { "use strict"; function s(e, t, r) { var n, i = u.getTypeOf(t), s = u.extend(r || {}, f); s.date = s.date || /* @__PURE__ */ new Date(), null !== s.compression && (s.compression = s.compression.toUpperCase()), "string" == typeof s.unixPermissions && (s.unixPermissions = parseInt(s.unixPermissions, 8)), s.unixPermissions && 16384 & s.unixPermissions && (s.dir = !0), s.dosPermissions && 16 & s.dosPermissions && (s.dir = !0), s.dir && (e = g(e)), s.createFolders && (n = _(e)) && b.call(this, n, !0); var a = "string" === i && !1 === s.binary && !1 === s.base64; r && void 0 !== r.binary || (s.binary = !a), (t instanceof c && 0 === t.uncompressedSize || s.dir || !t || 0 === t.length) && (s.base64 = !1, s.binary = !0, t = "", s.compression = "STORE", i = "string"); var o = null; o = t instanceof c || t instanceof l ? t : p.isNode && p.isStream(t) ? new m(e, t) : u.prepareContent(e, t, s.binary, s.optimizedBinaryString, s.base64); var h = new d(e, o, s); this.files[e] = h; } var i = e("./utf8"), u = e("./utils"), l = e("./stream/GenericWorker"), a = e("./stream/StreamHelper"), f = e("./defaults"), c = e("./compressedObject"), d = e("./zipObject"), o = e("./generate"), p = e("./nodejsUtils"), m = e("./nodejs/NodejsStreamInputAdapter"), _ = function(e) { "/" === e.slice(-1) && (e = e.substring(0, e.length - 1)); var t = e.lastIndexOf("/"); return 0 < t ? e.substring(0, t) : ""; }, g = function(e) { return "/" !== e.slice(-1) && (e += "/"), e; }, b = function(e, t) { return t = void 0 !== t ? t : f.createFolders, e = g(e), this.files[e] || s.call(this, e, null, { dir: !0, createFolders: t }), this.files[e]; }; function h(e) { return "[object RegExp]" === Object.prototype.toString.call(e); } t.exports = { load: function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, forEach: function(e) { var t, r, n; for (t in this.files) n = this.files[t], (r = t.slice(this.root.length, t.length)) && t.slice(0, this.root.length) === this.root && e(r, n); }, filter: function(r) { var n = []; return this.forEach(function(e, t) { r(e, t) && n.push(t); }), n; }, file: function(e, t, r) { if (1 !== arguments.length) return e = this.root + e, s.call(this, e, t, r), this; if (h(e)) { var n = e; return this.filter(function(e, t) { return !t.dir && n.test(e); }); } var i = this.files[this.root + e]; return i && !i.dir ? i : null; }, folder: function(r) { if (!r) return this; if (h(r)) return this.filter(function(e, t) { return t.dir && r.test(e); }); var e = this.root + r, t = b.call(this, e), n = this.clone(); return n.root = t.name, n; }, remove: function(r) { r = this.root + r; var e = this.files[r]; if (e || ("/" !== r.slice(-1) && (r += "/"), e = this.files[r]), e && !e.dir) delete this.files[r]; else for (var t = this.filter(function(e, t) { return t.name.slice(0, r.length) === r; }), n = 0; n < t.length; n++) delete this.files[t[n].name]; return this; }, generate: function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, generateInternalStream: function(e) { var t, r = {}; try { if ((r = u.extend(e || {}, { streamFiles: !1, compression: "STORE", compressionOptions: null, type: "", platform: "DOS", comment: null, mimeType: "application/zip", encodeFileName: i.utf8encode })).type = r.type.toLowerCase(), r.compression = r.compression.toUpperCase(), "binarystring" === r.type && (r.type = "string"), !r.type) throw new Error("No output type specified."); u.checkSupport(r.type), "darwin" !== r.platform && "freebsd" !== r.platform && "linux" !== r.platform && "sunos" !== r.platform || (r.platform = "UNIX"), "win32" === r.platform && (r.platform = "DOS"); var n = r.comment || this.comment || ""; t = o.generateWorker(this, r, n); } catch (e) { (t = new l("error")).error(e); } return new a(t, r.type || "string", r.mimeType); }, generateAsync: function(e, t) { return this.generateInternalStream(e).accumulate(t); }, generateNodeStream: function(e, t) { return (e = e || {}).type || (e.type = "nodebuffer"), this.generateInternalStream(e).toNodejsStream(t); } }; }, { "./compressedObject": 2, "./defaults": 5, "./generate": 9, "./nodejs/NodejsStreamInputAdapter": 12, "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31, "./utils": 32, "./zipObject": 35 }], 16: [function(e, t, r) { "use strict"; t.exports = e("stream"); }, { stream: void 0 }], 17: [function(e, t, r) { "use strict"; var n = e("./DataReader"); function i(e) { n.call(this, e); for (var t = 0; t < this.data.length; t++) e[t] = 255 & e[t]; } e("../utils").inherits(i, n), i.prototype.byteAt = function(e) { return this.data[this.zero + e]; }, i.prototype.lastIndexOfSignature = function(e) { for (var t = e.charCodeAt(0), r = e.charCodeAt(1), n = e.charCodeAt(2), i = e.charCodeAt(3), s = this.length - 4; 0 <= s; --s) if (this.data[s] === t && this.data[s + 1] === r && this.data[s + 2] === n && this.data[s + 3] === i) return s - this.zero; return -1; }, i.prototype.readAndCheckSignature = function(e) { var t = e.charCodeAt(0), r = e.charCodeAt(1), n = e.charCodeAt(2), i = e.charCodeAt(3), s = this.readData(4); return t === s[0] && r === s[1] && n === s[2] && i === s[3]; }, i.prototype.readData = function(e) { if (this.checkOffset(e), 0 === e) return []; var t = this.data.slice(this.zero + this.index, this.zero + this.index + e); return this.index += e, t; }, t.exports = i; }, { "../utils": 32, "./DataReader": 18 }], 18: [function(e, t, r) { "use strict"; var n = e("../utils"); function i(e) { this.data = e, this.length = e.length, this.index = 0, this.zero = 0; } i.prototype = { checkOffset: function(e) { this.checkIndex(this.index + e); }, checkIndex: function(e) { if (this.length < this.zero + e || e < 0) throw new Error("End of data reached (data length = " + this.length + ", asked index = " + e + "). Corrupted zip ?"); }, setIndex: function(e) { this.checkIndex(e), this.index = e; }, skip: function(e) { this.setIndex(this.index + e); }, byteAt: function() {}, readInt: function(e) { var t, r = 0; for (this.checkOffset(e), t = this.index + e - 1; t >= this.index; t--) r = (r << 8) + this.byteAt(t); return this.index += e, r; }, readString: function(e) { return n.transformTo("string", this.readData(e)); }, readData: function() {}, lastIndexOfSignature: function() {}, readAndCheckSignature: function() {}, readDate: function() { var e = this.readInt(4); return new Date(Date.UTC(1980 + (e >> 25 & 127), (e >> 21 & 15) - 1, e >> 16 & 31, e >> 11 & 31, e >> 5 & 63, (31 & e) << 1)); } }, t.exports = i; }, { "../utils": 32 }], 19: [function(e, t, r) { "use strict"; var n = e("./Uint8ArrayReader"); function i(e) { n.call(this, e); } e("../utils").inherits(i, n), i.prototype.readData = function(e) { this.checkOffset(e); var t = this.data.slice(this.zero + this.index, this.zero + this.index + e); return this.index += e, t; }, t.exports = i; }, { "../utils": 32, "./Uint8ArrayReader": 21 }], 20: [function(e, t, r) { "use strict"; var n = e("./DataReader"); function i(e) { n.call(this, e); } e("../utils").inherits(i, n), i.prototype.byteAt = function(e) { return this.data.charCodeAt(this.zero + e); }, i.prototype.lastIndexOfSignature = function(e) { return this.data.lastIndexOf(e) - this.zero; }, i.prototype.readAndCheckSignature = function(e) { return e === this.readData(4); }, i.prototype.readData = function(e) { this.checkOffset(e); var t = this.data.slice(this.zero + this.index, this.zero + this.index + e); return this.index += e, t; }, t.exports = i; }, { "../utils": 32, "./DataReader": 18 }], 21: [function(e, t, r) { "use strict"; var n = e("./ArrayReader"); function i(e) { n.call(this, e); } e("../utils").inherits(i, n), i.prototype.readData = function(e) { if (this.checkOffset(e), 0 === e) return new Uint8Array(0); var t = this.data.subarray(this.zero + this.index, this.zero + this.index + e); return this.index += e, t; }, t.exports = i; }, { "../utils": 32, "./ArrayReader": 17 }], 22: [function(e, t, r) { "use strict"; var n = e("../utils"), i = e("../support"), s = e("./ArrayReader"), a = e("./StringReader"), o = e("./NodeBufferReader"), h = e("./Uint8ArrayReader"); t.exports = function(e) { var t = n.getTypeOf(e); return n.checkSupport(t), "string" !== t || i.uint8array ? "nodebuffer" === t ? new o(e) : i.uint8array ? new h(n.transformTo("uint8array", e)) : new s(n.transformTo("array", e)) : new a(e); }; }, { "../support": 30, "../utils": 32, "./ArrayReader": 17, "./NodeBufferReader": 19, "./StringReader": 20, "./Uint8ArrayReader": 21 }], 23: [function(e, t, r) { "use strict"; r.LOCAL_FILE_HEADER = "PK", r.CENTRAL_FILE_HEADER = "PK", r.CENTRAL_DIRECTORY_END = "PK", r.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x07", r.ZIP64_CENTRAL_DIRECTORY_END = "PK", r.DATA_DESCRIPTOR = "PK\x07\b"; }, {}], 24: [function(e, t, r) { "use strict"; var n = e("./GenericWorker"), i = e("../utils"); function s(e) { n.call(this, "ConvertWorker to " + e), this.destType = e; } i.inherits(s, n), s.prototype.processChunk = function(e) { this.push({ data: i.transformTo(this.destType, e.data), meta: e.meta }); }, t.exports = s; }, { "../utils": 32, "./GenericWorker": 28 }], 25: [function(e, t, r) { "use strict"; var n = e("./GenericWorker"), i = e("../crc32"); function s() { n.call(this, "Crc32Probe"), this.withStreamInfo("crc32", 0); } e("../utils").inherits(s, n), s.prototype.processChunk = function(e) { this.streamInfo.crc32 = i(e.data, this.streamInfo.crc32 || 0), this.push(e); }, t.exports = s; }, { "../crc32": 4, "../utils": 32, "./GenericWorker": 28 }], 26: [function(e, t, r) { "use strict"; var n = e("../utils"), i = e("./GenericWorker"); function s(e) { i.call(this, "DataLengthProbe for " + e), this.propName = e, this.withStreamInfo(e, 0); } n.inherits(s, i), s.prototype.processChunk = function(e) { if (e) { var t = this.streamInfo[this.propName] || 0; this.streamInfo[this.propName] = t + e.data.length; } i.prototype.processChunk.call(this, e); }, t.exports = s; }, { "../utils": 32, "./GenericWorker": 28 }], 27: [function(e, t, r) { "use strict"; var n = e("../utils"), i = e("./GenericWorker"); function s(e) { i.call(this, "DataWorker"); var t = this; this.dataIsReady = !1, this.index = 0, this.max = 0, this.data = null, this.type = "", this._tickScheduled = !1, e.then(function(e) { t.dataIsReady = !0, t.data = e, t.max = e && e.length || 0, t.type = n.getTypeOf(e), t.isPaused || t._tickAndRepeat(); }, function(e) { t.error(e); }); } n.inherits(s, i), s.prototype.cleanUp = function() { i.prototype.cleanUp.call(this), this.data = null; }, s.prototype.resume = function() { return !!i.prototype.resume.call(this) && (!this._tickScheduled && this.dataIsReady && (this._tickScheduled = !0, n.delay(this._tickAndRepeat, [], this)), !0); }, s.prototype._tickAndRepeat = function() { this._tickScheduled = !1, this.isPaused || this.isFinished || (this._tick(), this.isFinished || (n.delay(this._tickAndRepeat, [], this), this._tickScheduled = !0)); }, s.prototype._tick = function() { if (this.isPaused || this.isFinished) return !1; var e = null, t = Math.min(this.max, this.index + 16384); if (this.index >= this.max) return this.end(); switch (this.type) { case "string": e = this.data.substring(this.index, t); break; case "uint8array": e = this.data.subarray(this.index, t); break; case "array": case "nodebuffer": e = this.data.slice(this.index, t); } return this.index = t, this.push({ data: e, meta: { percent: this.max ? this.index / this.max * 100 : 0 } }); }, t.exports = s; }, { "../utils": 32, "./GenericWorker": 28 }], 28: [function(e, t, r) { "use strict"; function n(e) { this.name = e || "default", this.streamInfo = {}, this.generatedError = null, this.extraStreamInfo = {}, this.isPaused = !0, this.isFinished = !1, this.isLocked = !1, this._listeners = { data: [], end: [], error: [] }, this.previous = null; } n.prototype = { push: function(e) { this.emit("data", e); }, end: function() { if (this.isFinished) return !1; this.flush(); try { this.emit("end"), this.cleanUp(), this.isFinished = !0; } catch (e) { this.emit("error", e); } return !0; }, error: function(e) { return !this.isFinished && (this.isPaused ? this.generatedError = e : (this.isFinished = !0, this.emit("error", e), this.previous && this.previous.error(e), this.cleanUp()), !0); }, on: function(e, t) { return this._listeners[e].push(t), this; }, cleanUp: function() { this.streamInfo = this.generatedError = this.extraStreamInfo = null, this._listeners = []; }, emit: function(e, t) { if (this._listeners[e]) for (var r = 0; r < this._listeners[e].length; r++) this._listeners[e][r].call(this, t); }, pipe: function(e) { return e.registerPrevious(this); }, registerPrevious: function(e) { if (this.isLocked) throw new Error("The stream '" + this + "' has already been used."); this.streamInfo = e.streamInfo, this.mergeStreamInfo(), this.previous = e; var t = this; return e.on("data", function(e) { t.processChunk(e); }), e.on("end", function() { t.end(); }), e.on("error", function(e) { t.error(e); }), this; }, pause: function() { return !this.isPaused && !this.isFinished && (this.isPaused = !0, this.previous && this.previous.pause(), !0); }, resume: function() { if (!this.isPaused || this.isFinished) return !1; var e = this.isPaused = !1; return this.generatedError && (this.error(this.generatedError), e = !0), this.previous && this.previous.resume(), !e; }, flush: function() {}, processChunk: function(e) { this.push(e); }, withStreamInfo: function(e, t) { return this.extraStreamInfo[e] = t, this.mergeStreamInfo(), this; }, mergeStreamInfo: function() { for (var e in this.extraStreamInfo) Object.prototype.hasOwnProperty.call(this.extraStreamInfo, e) && (this.streamInfo[e] = this.extraStreamInfo[e]); }, lock: function() { if (this.isLocked) throw new Error("The stream '" + this + "' has already been used."); this.isLocked = !0, this.previous && this.previous.lock(); }, toString: function() { var e = "Worker " + this.name; return this.previous ? this.previous + " -> " + e : e; } }, t.exports = n; }, {}], 29: [function(e, t, r) { "use strict"; var h = e("../utils"), i = e("./ConvertWorker"), s = e("./GenericWorker"), u = e("../base64"), n = e("../support"), a = e("../external"), o = null; if (n.nodestream) try { o = e("../nodejs/NodejsStreamOutputAdapter"); } catch (e) {} function l(e, o) { return new a.Promise(function(t, r) { var n = [], i = e._internalType, s = e._outputType, a = e._mimeType; e.on("data", function(e, t) { n.push(e), o && o(t); }).on("error", function(e) { n = [], r(e); }).on("end", function() { try { t(function(e, t, r) { switch (e) { case "blob": return h.newBlob(h.transformTo("arraybuffer", t), r); case "base64": return u.encode(t); default: return h.transformTo(e, t); } }(s, function(e, t) { var r, n = 0, i = null, s = 0; for (r = 0; r < t.length; r++) s += t[r].length; switch (e) { case "string": return t.join(""); case "array": return Array.prototype.concat.apply([], t); case "uint8array": for (i = new Uint8Array(s), r = 0; r < t.length; r++) i.set(t[r], n), n += t[r].length; return i; case "nodebuffer": return Buffer.concat(t); default: throw new Error("concat : unsupported type '" + e + "'"); } }(i, n), a)); } catch (e) { r(e); } n = []; }).resume(); }); } function f(e, t, r) { var n = t; switch (t) { case "blob": case "arraybuffer": n = "uint8array"; break; case "base64": n = "string"; } try { this._internalType = n, this._outputType = t, this._mimeType = r, h.checkSupport(n), this._worker = e.pipe(new i(n)), e.lock(); } catch (e) { this._worker = new s("error"), this._worker.error(e); } } f.prototype = { accumulate: function(e) { return l(this, e); }, on: function(e, t) { var r = this; return "data" === e ? this._worker.on(e, function(e) { t.call(r, e.data, e.meta); }) : this._worker.on(e, function() { h.delay(t, arguments, r); }), this; }, resume: function() { return h.delay(this._worker.resume, [], this._worker), this; }, pause: function() { return this._worker.pause(), this; }, toNodejsStream: function(e) { if (h.checkSupport("nodestream"), "nodebuffer" !== this._outputType) throw new Error(this._outputType + " is not supported by this method"); return new o(this, { objectMode: "nodebuffer" !== this._outputType }, e); } }, t.exports = f; }, { "../base64": 1, "../external": 6, "../nodejs/NodejsStreamOutputAdapter": 13, "../support": 30, "../utils": 32, "./ConvertWorker": 24, "./GenericWorker": 28 }], 30: [function(e, t, r) { "use strict"; if (r.base64 = !0, r.array = !0, r.string = !0, r.arraybuffer = "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8Array, r.nodebuffer = "undefined" != typeof Buffer, r.uint8array = "undefined" != typeof Uint8Array, "undefined" == typeof ArrayBuffer) r.blob = !1; else { var n = /* @__PURE__ */ new ArrayBuffer(0); try { r.blob = 0 === new Blob([n], { type: "application/zip" }).size; } catch (e) { try { var i = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)(); i.append(n), r.blob = 0 === i.getBlob("application/zip").size; } catch (e) { r.blob = !1; } } } try { r.nodestream = !!e("readable-stream").Readable; } catch (e) { r.nodestream = !1; } }, { "readable-stream": 16 }], 31: [function(e, t, s) { "use strict"; for (var o = e("./utils"), h = e("./support"), r = e("./nodejsUtils"), n = e("./stream/GenericWorker"), u = new Array(256), i = 0; i < 256; i++) u[i] = 252 <= i ? 6 : 248 <= i ? 5 : 240 <= i ? 4 : 224 <= i ? 3 : 192 <= i ? 2 : 1; u[254] = u[254] = 1; function a() { n.call(this, "utf-8 decode"), this.leftOver = null; } function l() { n.call(this, "utf-8 encode"); } s.utf8encode = function(e) { return h.nodebuffer ? r.newBufferFrom(e, "utf-8") : function(e) { var t, r, n, i, s, a = e.length, o = 0; for (i = 0; i < a; i++) 55296 == (64512 & (r = e.charCodeAt(i))) && i + 1 < a && 56320 == (64512 & (n = e.charCodeAt(i + 1))) && (r = 65536 + (r - 55296 << 10) + (n - 56320), i++), o += r < 128 ? 1 : r < 2048 ? 2 : r < 65536 ? 3 : 4; for (t = h.uint8array ? new Uint8Array(o) : new Array(o), i = s = 0; s < o; i++) 55296 == (64512 & (r = e.charCodeAt(i))) && i + 1 < a && 56320 == (64512 & (n = e.charCodeAt(i + 1))) && (r = 65536 + (r - 55296 << 10) + (n - 56320), i++), r < 128 ? t[s++] = r : (r < 2048 ? t[s++] = 192 | r >>> 6 : (r < 65536 ? t[s++] = 224 | r >>> 12 : (t[s++] = 240 | r >>> 18, t[s++] = 128 | r >>> 12 & 63), t[s++] = 128 | r >>> 6 & 63), t[s++] = 128 | 63 & r); return t; }(e); }, s.utf8decode = function(e) { return h.nodebuffer ? o.transformTo("nodebuffer", e).toString("utf-8") : function(e) { var t, r, n, i, s = e.length, a = new Array(2 * s); for (t = r = 0; t < s;) if ((n = e[t++]) < 128) a[r++] = n; else if (4 < (i = u[n])) a[r++] = 65533, t += i - 1; else { for (n &= 2 === i ? 31 : 3 === i ? 15 : 7; 1 < i && t < s;) n = n << 6 | 63 & e[t++], i--; 1 < i ? a[r++] = 65533 : n < 65536 ? a[r++] = n : (n -= 65536, a[r++] = 55296 | n >> 10 & 1023, a[r++] = 56320 | 1023 & n); } return a.length !== r && (a.subarray ? a = a.subarray(0, r) : a.length = r), o.applyFromCharCode(a); }(e = o.transformTo(h.uint8array ? "uint8array" : "array", e)); }, o.inherits(a, n), a.prototype.processChunk = function(e) { var t = o.transformTo(h.uint8array ? "uint8array" : "array", e.data); if (this.leftOver && this.leftOver.length) { if (h.uint8array) { var r = t; (t = new Uint8Array(r.length + this.leftOver.length)).set(this.leftOver, 0), t.set(r, this.leftOver.length); } else t = this.leftOver.concat(t); this.leftOver = null; } var n = function(e, t) { var r; for ((t = t || e.length) > e.length && (t = e.length), r = t - 1; 0 <= r && 128 == (192 & e[r]);) r--; return r < 0 ? t : 0 === r ? t : r + u[e[r]] > t ? r : t; }(t), i = t; n !== t.length && (h.uint8array ? (i = t.subarray(0, n), this.leftOver = t.subarray(n, t.length)) : (i = t.slice(0, n), this.leftOver = t.slice(n, t.length))), this.push({ data: s.utf8decode(i), meta: e.meta }); }, a.prototype.flush = function() { this.leftOver && this.leftOver.length && (this.push({ data: s.utf8decode(this.leftOver), meta: {} }), this.leftOver = null); }, s.Utf8DecodeWorker = a, o.inherits(l, n), l.prototype.processChunk = function(e) { this.push({ data: s.utf8encode(e.data), meta: e.meta }); }, s.Utf8EncodeWorker = l; }, { "./nodejsUtils": 14, "./stream/GenericWorker": 28, "./support": 30, "./utils": 32 }], 32: [function(e, t, a) { "use strict"; var o = e("./support"), h = e("./base64"), r = e("./nodejsUtils"), u = e("./external"); function n(e) { return e; } function l(e, t) { for (var r = 0; r < e.length; ++r) t[r] = 255 & e.charCodeAt(r); return t; } e("setimmediate"), a.newBlob = function(t, r) { a.checkSupport("blob"); try { return new Blob([t], { type: r }); } catch (e) { try { var n = new (self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder)(); return n.append(t), n.getBlob(r); } catch (e) { throw new Error("Bug : can't construct the Blob."); } } }; var i = { stringifyByChunk: function(e, t, r) { var n = [], i = 0, s = e.length; if (s <= r) return String.fromCharCode.apply(null, e); for (; i < s;) "array" === t || "nodebuffer" === t ? n.push(String.fromCharCode.apply(null, e.slice(i, Math.min(i + r, s)))) : n.push(String.fromCharCode.apply(null, e.subarray(i, Math.min(i + r, s)))), i += r; return n.join(""); }, stringifyByChar: function(e) { for (var t = "", r = 0; r < e.length; r++) t += String.fromCharCode(e[r]); return t; }, applyCanBeUsed: { uint8array: function() { try { return o.uint8array && 1 === String.fromCharCode.apply(null, new Uint8Array(1)).length; } catch (e) { return !1; } }(), nodebuffer: function() { try { return o.nodebuffer && 1 === String.fromCharCode.apply(null, r.allocBuffer(1)).length; } catch (e) { return !1; } }() } }; function s(e) { var t = 65536, r = a.getTypeOf(e), n = !0; if ("uint8array" === r ? n = i.applyCanBeUsed.uint8array : "nodebuffer" === r && (n = i.applyCanBeUsed.nodebuffer), n) for (; 1 < t;) try { return i.stringifyByChunk(e, r, t); } catch (e) { t = Math.floor(t / 2); } return i.stringifyByChar(e); } function f(e, t) { for (var r = 0; r < e.length; r++) t[r] = e[r]; return t; } a.applyFromCharCode = s; var c = {}; c.string = { string: n, array: function(e) { return l(e, new Array(e.length)); }, arraybuffer: function(e) { return c.string.uint8array(e).buffer; }, uint8array: function(e) { return l(e, new Uint8Array(e.length)); }, nodebuffer: function(e) { return l(e, r.allocBuffer(e.length)); } }, c.array = { string: s, array: n, arraybuffer: function(e) { return new Uint8Array(e).buffer; }, uint8array: function(e) { return new Uint8Array(e); }, nodebuffer: function(e) { return r.newBufferFrom(e); } }, c.arraybuffer = { string: function(e) { return s(new Uint8Array(e)); }, array: function(e) { return f(new Uint8Array(e), new Array(e.byteLength)); }, arraybuffer: n, uint8array: function(e) { return new Uint8Array(e); }, nodebuffer: function(e) { return r.newBufferFrom(new Uint8Array(e)); } }, c.uint8array = { string: s, array: function(e) { return f(e, new Array(e.length)); }, arraybuffer: function(e) { return e.buffer; }, uint8array: n, nodebuffer: function(e) { return r.newBufferFrom(e); } }, c.nodebuffer = { string: s, array: function(e) { return f(e, new Array(e.length)); }, arraybuffer: function(e) { return c.nodebuffer.uint8array(e).buffer; }, uint8array: function(e) { return f(e, new Uint8Array(e.length)); }, nodebuffer: n }, a.transformTo = function(e, t) { if (t = t || "", !e) return t; a.checkSupport(e); return c[a.getTypeOf(t)][e](t); }, a.resolve = function(e) { for (var t = e.split("/"), r = [], n = 0; n < t.length; n++) { var i = t[n]; "." === i || "" === i && 0 !== n && n !== t.length - 1 || (".." === i ? r.pop() : r.push(i)); } return r.join("/"); }, a.getTypeOf = function(e) { return "string" == typeof e ? "string" : "[object Array]" === Object.prototype.toString.call(e) ? "array" : o.nodebuffer && r.isBuffer(e) ? "nodebuffer" : o.uint8array && e instanceof Uint8Array ? "uint8array" : o.arraybuffer && e instanceof ArrayBuffer ? "arraybuffer" : void 0; }, a.checkSupport = function(e) { if (!o[e.toLowerCase()]) throw new Error(e + " is not supported by this platform"); }, a.MAX_VALUE_16BITS = 65535, a.MAX_VALUE_32BITS = -1, a.pretty = function(e) { var t, r, n = ""; for (r = 0; r < (e || "").length; r++) n += "\\x" + ((t = e.charCodeAt(r)) < 16 ? "0" : "") + t.toString(16).toUpperCase(); return n; }, a.delay = function(e, t, r) { setImmediate(function() { e.apply(r || null, t || []); }); }, a.inherits = function(e, t) { function r() {} r.prototype = t.prototype, e.prototype = new r(); }, a.extend = function() { var e, t, r = {}; for (e = 0; e < arguments.length; e++) for (t in arguments[e]) Object.prototype.hasOwnProperty.call(arguments[e], t) && void 0 === r[t] && (r[t] = arguments[e][t]); return r; }, a.prepareContent = function(r, e, n, i, s) { return u.Promise.resolve(e).then(function(n) { return o.blob && (n instanceof Blob || -1 !== ["[object File]", "[object Blob]"].indexOf(Object.prototype.toString.call(n))) && "undefined" != typeof FileReader ? new u.Promise(function(t, r) { var e = new FileReader(); e.onload = function(e) { t(e.target.result); }, e.onerror = function(e) { r(e.target.error); }, e.readAsArrayBuffer(n); }) : n; }).then(function(e) { var t = a.getTypeOf(e); return t ? ("arraybuffer" === t ? e = a.transformTo("uint8array", e) : "string" === t && (s ? e = h.decode(e) : n && !0 !== i && (e = function(e) { return l(e, o.uint8array ? new Uint8Array(e.length) : new Array(e.length)); }(e))), e) : u.Promise.reject(/* @__PURE__ */ new Error("Can't read the data of '" + r + "'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?")); }); }; }, { "./base64": 1, "./external": 6, "./nodejsUtils": 14, "./support": 30, setimmediate: 54 }], 33: [function(e, t, r) { "use strict"; var n = e("./reader/readerFor"), i = e("./utils"), s = e("./signature"), a = e("./zipEntry"), o = e("./support"); function h(e) { this.files = [], this.loadOptions = e; } h.prototype = { checkSignature: function(e) { if (!this.reader.readAndCheckSignature(e)) { this.reader.index -= 4; var t = this.reader.readString(4); throw new Error("Corrupted zip or bug: unexpected signature (" + i.pretty(t) + ", expected " + i.pretty(e) + ")"); } }, isSignature: function(e, t) { var r = this.reader.index; this.reader.setIndex(e); var n = this.reader.readString(4) === t; return this.reader.setIndex(r), n; }, readBlockEndOfCentral: function() { this.diskNumber = this.reader.readInt(2), this.diskWithCentralDirStart = this.reader.readInt(2), this.centralDirRecordsOnThisDisk = this.reader.readInt(2), this.centralDirRecords = this.reader.readInt(2), this.centralDirSize = this.reader.readInt(4), this.centralDirOffset = this.reader.readInt(4), this.zipCommentLength = this.reader.readInt(2); var e = this.reader.readData(this.zipCommentLength), t = o.uint8array ? "uint8array" : "array", r = i.transformTo(t, e); this.zipComment = this.loadOptions.decodeFileName(r); }, readBlockZip64EndOfCentral: function() { this.zip64EndOfCentralSize = this.reader.readInt(8), this.reader.skip(4), this.diskNumber = this.reader.readInt(4), this.diskWithCentralDirStart = this.reader.readInt(4), this.centralDirRecordsOnThisDisk = this.reader.readInt(8), this.centralDirRecords = this.reader.readInt(8), this.centralDirSize = this.reader.readInt(8), this.centralDirOffset = this.reader.readInt(8), this.zip64ExtensibleData = {}; for (var e, t, r, n = this.zip64EndOfCentralSize - 44; 0 < n;) e = this.reader.readInt(2), t = this.reader.readInt(4), r = this.reader.readData(t), this.zip64ExtensibleData[e] = { id: e, length: t, value: r }; }, readBlockZip64EndOfCentralLocator: function() { if (this.diskWithZip64CentralDirStart = this.reader.readInt(4), this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8), this.disksCount = this.reader.readInt(4), 1 < this.disksCount) throw new Error("Multi-volumes zip are not supported"); }, readLocalFiles: function() { var e, t; for (e = 0; e < this.files.length; e++) t = this.files[e], this.reader.setIndex(t.localHeaderOffset), this.checkSignature(s.LOCAL_FILE_HEADER), t.readLocalPart(this.reader), t.handleUTF8(), t.processAttributes(); }, readCentralDir: function() { var e; for (this.reader.setIndex(this.centralDirOffset); this.reader.readAndCheckSignature(s.CENTRAL_FILE_HEADER);) (e = new a({ zip64: this.zip64 }, this.loadOptions)).readCentralPart(this.reader), this.files.push(e); if (this.centralDirRecords !== this.files.length && 0 !== this.centralDirRecords && 0 === this.files.length) throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length); }, readEndOfCentral: function() { var e = this.reader.lastIndexOfSignature(s.CENTRAL_DIRECTORY_END); if (e < 0) throw !this.isSignature(0, s.LOCAL_FILE_HEADER) ? /* @__PURE__ */ new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html") : /* @__PURE__ */ new Error("Corrupted zip: can't find end of central directory"); this.reader.setIndex(e); var t = e; if (this.checkSignature(s.CENTRAL_DIRECTORY_END), this.readBlockEndOfCentral(), this.diskNumber === i.MAX_VALUE_16BITS || this.diskWithCentralDirStart === i.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === i.MAX_VALUE_16BITS || this.centralDirRecords === i.MAX_VALUE_16BITS || this.centralDirSize === i.MAX_VALUE_32BITS || this.centralDirOffset === i.MAX_VALUE_32BITS) { if (this.zip64 = !0, (e = this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR)) < 0) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator"); if (this.reader.setIndex(e), this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_LOCATOR), this.readBlockZip64EndOfCentralLocator(), !this.isSignature(this.relativeOffsetEndOfZip64CentralDir, s.ZIP64_CENTRAL_DIRECTORY_END) && (this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(s.ZIP64_CENTRAL_DIRECTORY_END), this.relativeOffsetEndOfZip64CentralDir < 0)) throw new Error("Corrupted zip: can't find the ZIP64 end of central directory"); this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir), this.checkSignature(s.ZIP64_CENTRAL_DIRECTORY_END), this.readBlockZip64EndOfCentral(); } var r = this.centralDirOffset + this.centralDirSize; this.zip64 && (r += 20, r += 12 + this.zip64EndOfCentralSize); var n = t - r; if (0 < n) this.isSignature(t, s.CENTRAL_FILE_HEADER) || (this.reader.zero = n); else if (n < 0) throw new Error("Corrupted zip: missing " + Math.abs(n) + " bytes."); }, prepareReader: function(e) { this.reader = n(e); }, load: function(e) { this.prepareReader(e), this.readEndOfCentral(), this.readCentralDir(), this.readLocalFiles(); } }, t.exports = h; }, { "./reader/readerFor": 22, "./signature": 23, "./support": 30, "./utils": 32, "./zipEntry": 34 }], 34: [function(e, t, r) { "use strict"; var n = e("./reader/readerFor"), s = e("./utils"), i = e("./compressedObject"), a = e("./crc32"), o = e("./utf8"), h = e("./compressions"), u = e("./support"); function l(e, t) { this.options = e, this.loadOptions = t; } l.prototype = { isEncrypted: function() { return 1 == (1 & this.bitFlag); }, useUTF8: function() { return 2048 == (2048 & this.bitFlag); }, readLocalPart: function(e) { var t, r; if (e.skip(22), this.fileNameLength = e.readInt(2), r = e.readInt(2), this.fileName = e.readData(this.fileNameLength), e.skip(r), -1 === this.compressedSize || -1 === this.uncompressedSize) throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)"); if (null === (t = function(e) { for (var t in h) if (Object.prototype.hasOwnProperty.call(h, t) && h[t].magic === e) return h[t]; return null; }(this.compressionMethod))) throw new Error("Corrupted zip : compression " + s.pretty(this.compressionMethod) + " unknown (inner file : " + s.transformTo("string", this.fileName) + ")"); this.decompressed = new i(this.compressedSize, this.uncompressedSize, this.crc32, t, e.readData(this.compressedSize)); }, readCentralPart: function(e) { this.versionMadeBy = e.readInt(2), e.skip(2), this.bitFlag = e.readInt(2), this.compressionMethod = e.readString(2), this.date = e.readDate(), this.crc32 = e.readInt(4), this.compressedSize = e.readInt(4), this.uncompressedSize = e.readInt(4); var t = e.readInt(2); if (this.extraFieldsLength = e.readInt(2), this.fileCommentLength = e.readInt(2), this.diskNumberStart = e.readInt(2), this.internalFileAttributes = e.readInt(2), this.externalFileAttributes = e.readInt(4), this.localHeaderOffset = e.readInt(4), this.isEncrypted()) throw new Error("Encrypted zip are not supported"); e.skip(t), this.readExtraFields(e), this.parseZIP64ExtraField(e), this.fileComment = e.readData(this.fileCommentLength); }, processAttributes: function() { this.unixPermissions = null, this.dosPermissions = null; var e = this.versionMadeBy >> 8; this.dir = !!(16 & this.externalFileAttributes), 0 == e && (this.dosPermissions = 63 & this.externalFileAttributes), 3 == e && (this.unixPermissions = this.externalFileAttributes >> 16 & 65535), this.dir || "/" !== this.fileNameStr.slice(-1) || (this.dir = !0); }, parseZIP64ExtraField: function() { if (this.extraFields[1]) { var e = n(this.extraFields[1].value); this.uncompressedSize === s.MAX_VALUE_32BITS && (this.uncompressedSize = e.readInt(8)), this.compressedSize === s.MAX_VALUE_32BITS && (this.compressedSize = e.readInt(8)), this.localHeaderOffset === s.MAX_VALUE_32BITS && (this.localHeaderOffset = e.readInt(8)), this.diskNumberStart === s.MAX_VALUE_32BITS && (this.diskNumberStart = e.readInt(4)); } }, readExtraFields: function(e) { var t, r, n, i = e.index + this.extraFieldsLength; for (this.extraFields || (this.extraFields = {}); e.index + 4 < i;) t = e.readInt(2), r = e.readInt(2), n = e.readData(r), this.extraFields[t] = { id: t, length: r, value: n }; e.setIndex(i); }, handleUTF8: function() { var e = u.uint8array ? "uint8array" : "array"; if (this.useUTF8()) this.fileNameStr = o.utf8decode(this.fileName), this.fileCommentStr = o.utf8decode(this.fileComment); else { var t = this.findExtraFieldUnicodePath(); if (null !== t) this.fileNameStr = t; else { var r = s.transformTo(e, this.fileName); this.fileNameStr = this.loadOptions.decodeFileName(r); } var n = this.findExtraFieldUnicodeComment(); if (null !== n) this.fileCommentStr = n; else { var i = s.transformTo(e, this.fileComment); this.fileCommentStr = this.loadOptions.decodeFileName(i); } } }, findExtraFieldUnicodePath: function() { var e = this.extraFields[28789]; if (e) { var t = n(e.value); return 1 !== t.readInt(1) ? null : a(this.fileName) !== t.readInt(4) ? null : o.utf8decode(t.readData(e.length - 5)); } return null; }, findExtraFieldUnicodeComment: function() { var e = this.extraFields[25461]; if (e) { var t = n(e.value); return 1 !== t.readInt(1) ? null : a(this.fileComment) !== t.readInt(4) ? null : o.utf8decode(t.readData(e.length - 5)); } return null; } }, t.exports = l; }, { "./compressedObject": 2, "./compressions": 3, "./crc32": 4, "./reader/readerFor": 22, "./support": 30, "./utf8": 31, "./utils": 32 }], 35: [function(e, t, r) { "use strict"; function n(e, t, r) { this.name = e, this.dir = r.dir, this.date = r.date, this.comment = r.comment, this.unixPermissions = r.unixPermissions, this.dosPermissions = r.dosPermissions, this._data = t, this._dataBinary = r.binary, this.options = { compression: r.compression, compressionOptions: r.compressionOptions }; } var s = e("./stream/StreamHelper"), i = e("./stream/DataWorker"), a = e("./utf8"), o = e("./compressedObject"), h = e("./stream/GenericWorker"); n.prototype = { internalStream: function(e) { var t = null, r = "string"; try { if (!e) throw new Error("No output type specified."); var n = "string" === (r = e.toLowerCase()) || "text" === r; "binarystring" !== r && "text" !== r || (r = "string"), t = this._decompressWorker(); var i = !this._dataBinary; i && !n && (t = t.pipe(new a.Utf8EncodeWorker())), !i && n && (t = t.pipe(new a.Utf8DecodeWorker())); } catch (e) { (t = new h("error")).error(e); } return new s(t, r, ""); }, async: function(e, t) { return this.internalStream(e).accumulate(t); }, nodeStream: function(e, t) { return this.internalStream(e || "nodebuffer").toNodejsStream(t); }, _compressWorker: function(e, t) { if (this._data instanceof o && this._data.compression.magic === e.magic) return this._data.getCompressedWorker(); var r = this._decompressWorker(); return this._dataBinary || (r = r.pipe(new a.Utf8EncodeWorker())), o.createWorkerFrom(r, e, t); }, _decompressWorker: function() { return this._data instanceof o ? this._data.getContentWorker() : this._data instanceof h ? this._data : new i(this._data); } }; for (var u = [ "asText", "asBinary", "asNodeBuffer", "asUint8Array", "asArrayBuffer" ], l = function() { throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); }, f = 0; f < u.length; f++) n.prototype[u[f]] = l; t.exports = n; }, { "./compressedObject": 2, "./stream/DataWorker": 27, "./stream/GenericWorker": 28, "./stream/StreamHelper": 29, "./utf8": 31 }], 36: [function(e, l, t) { (function(t) { "use strict"; var r, n, e = t.MutationObserver || t.WebKitMutationObserver; if (e) { var i = 0, s = new e(u), a = t.document.createTextNode(""); s.observe(a, { characterData: !0 }), r = function() { a.data = i = ++i % 2; }; } else if (t.setImmediate || void 0 === t.MessageChannel) r = "document" in t && "onreadystatechange" in t.document.createElement("script") ? function() { var e = t.document.createElement("script"); e.onreadystatechange = function() { u(), e.onreadystatechange = null, e.parentNode.removeChild(e), e = null; }, t.document.documentElement.appendChild(e); } : function() { setTimeout(u, 0); }; else { var o = new t.MessageChannel(); o.port1.onmessage = u, r = function() { o.port2.postMessage(0); }; } var h = []; function u() { var e, t; n = !0; for (var r = h.length; r;) { for (t = h, h = [], e = -1; ++e < r;) t[e](); r = h.length; } n = !1; } l.exports = function(e) { 1 !== h.push(e) || n || r(); }; }).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}); }, {}], 37: [function(e, t, r) { "use strict"; var i = e("immediate"); function u() {} var l = {}, s = ["REJECTED"], a = ["FULFILLED"], n = ["PENDING"]; function o(e) { if ("function" != typeof e) throw new TypeError("resolver must be a function"); this.state = n, this.queue = [], this.outcome = void 0, e !== u && d(this, e); } function h(e, t, r) { this.promise = e, "function" == typeof t && (this.onFulfilled = t, this.callFulfilled = this.otherCallFulfilled), "function" == typeof r && (this.onRejected = r, this.callRejected = this.otherCallRejected); } function f(t, r, n) { i(function() { var e; try { e = r(n); } catch (e) { return l.reject(t, e); } e === t ? l.reject(t, /* @__PURE__ */ new TypeError("Cannot resolve promise with itself")) : l.resolve(t, e); }); } function c(e) { var t = e && e.then; if (e && ("object" == typeof e || "function" == typeof e) && "function" == typeof t) return function() { t.apply(e, arguments); }; } function d(t, e) { var r = !1; function n(e) { r || (r = !0, l.reject(t, e)); } function i(e) { r || (r = !0, l.resolve(t, e)); } var s = p(function() { e(i, n); }); "error" === s.status && n(s.value); } function p(e, t) { var r = {}; try { r.value = e(t), r.status = "success"; } catch (e) { r.status = "error", r.value = e; } return r; } (t.exports = o).prototype.finally = function(t) { if ("function" != typeof t) return this; var r = this.constructor; return this.then(function(e) { return r.resolve(t()).then(function() { return e; }); }, function(e) { return r.resolve(t()).then(function() { throw e; }); }); }, o.prototype.catch = function(e) { return this.then(null, e); }, o.prototype.then = function(e, t) { if ("function" != typeof e && this.state === a || "function" != typeof t && this.state === s) return this; var r = new this.constructor(u); this.state !== n ? f(r, this.state === a ? e : t, this.outcome) : this.queue.push(new h(r, e, t)); return r; }, h.prototype.callFulfilled = function(e) { l.resolve(this.promise, e); }, h.prototype.otherCallFulfilled = function(e) { f(this.promise, this.onFulfilled, e); }, h.prototype.callRejected = function(e) { l.reject(this.promise, e); }, h.prototype.otherCallRejected = function(e) { f(this.promise, this.onRejected, e); }, l.resolve = function(e, t) { var r = p(c, t); if ("error" === r.status) return l.reject(e, r.value); var n = r.value; if (n) d(e, n); else { e.state = a, e.outcome = t; for (var i = -1, s = e.queue.length; ++i < s;) e.queue[i].callFulfilled(t); } return e; }, l.reject = function(e, t) { e.state = s, e.outcome = t; for (var r = -1, n = e.queue.length; ++r < n;) e.queue[r].callRejected(t); return e; }, o.resolve = function(e) { if (e instanceof this) return e; return l.resolve(new this(u), e); }, o.reject = function(e) { var t = new this(u); return l.reject(t, e); }, o.all = function(e) { var r = this; if ("[object Array]" !== Object.prototype.toString.call(e)) return this.reject(/* @__PURE__ */ new TypeError("must be an array")); var n = e.length, i = !1; if (!n) return this.resolve([]); var s = new Array(n), a = 0, t = -1, o = new this(u); for (; ++t < n;) h(e[t], t); return o; function h(e, t) { r.resolve(e).then(function(e) { s[t] = e, ++a !== n || i || (i = !0, l.resolve(o, s)); }, function(e) { i || (i = !0, l.reject(o, e)); }); } }, o.race = function(e) { var t = this; if ("[object Array]" !== Object.prototype.toString.call(e)) return this.reject(/* @__PURE__ */ new TypeError("must be an array")); var r = e.length, n = !1; if (!r) return this.resolve([]); var i = -1, s = new this(u); for (; ++i < r;) a = e[i], t.resolve(a).then(function(e) { n || (n = !0, l.resolve(s, e)); }, function(e) { n || (n = !0, l.reject(s, e)); }); var a; return s; }; }, { immediate: 36 }], 38: [function(e, t, r) { "use strict"; var n = {}; (0, e("./lib/utils/common").assign)(n, e("./lib/deflate"), e("./lib/inflate"), e("./lib/zlib/constants")), t.exports = n; }, { "./lib/deflate": 39, "./lib/inflate": 40, "./lib/utils/common": 41, "./lib/zlib/constants": 44 }], 39: [function(e, t, r) { "use strict"; var a = e("./zlib/deflate"), o = e("./utils/common"), h = e("./utils/strings"), i = e("./zlib/messages"), s = e("./zlib/zstream"), u = Object.prototype.toString, l = 0, f = -1, c = 0, d = 8; function p(e) { if (!(this instanceof p)) return new p(e); this.options = o.assign({ level: f, method: d, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: c, to: "" }, e || {}); var t = this.options; t.raw && 0 < t.windowBits ? t.windowBits = -t.windowBits : t.gzip && 0 < t.windowBits && t.windowBits < 16 && (t.windowBits += 16), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new s(), this.strm.avail_out = 0; var r = a.deflateInit2(this.strm, t.level, t.method, t.windowBits, t.memLevel, t.strategy); if (r !== l) throw new Error(i[r]); if (t.header && a.deflateSetHeader(this.strm, t.header), t.dictionary) { var n; if (n = "string" == typeof t.dictionary ? h.string2buf(t.dictionary) : "[object ArrayBuffer]" === u.call(t.dictionary) ? new Uint8Array(t.dictionary) : t.dictionary, (r = a.deflateSetDictionary(this.strm, n)) !== l) throw new Error(i[r]); this._dict_set = !0; } } function n(e, t) { var r = new p(t); if (r.push(e, !0), r.err) throw r.msg || i[r.err]; return r.result; } p.prototype.push = function(e, t) { var r, n, i = this.strm, s = this.options.chunkSize; if (this.ended) return !1; n = t === ~~t ? t : !0 === t ? 4 : 0, "string" == typeof e ? i.input = h.string2buf(e) : "[object ArrayBuffer]" === u.call(e) ? i.input = new Uint8Array(e) : i.input = e, i.next_in = 0, i.avail_in = i.input.length; do { if (0 === i.avail_out && (i.output = new o.Buf8(s), i.next_out = 0, i.avail_out = s), 1 !== (r = a.deflate(i, n)) && r !== l) return this.onEnd(r), !(this.ended = !0); 0 !== i.avail_out && (0 !== i.avail_in || 4 !== n && 2 !== n) || ("string" === this.options.to ? this.onData(h.buf2binstring(o.shrinkBuf(i.output, i.next_out))) : this.onData(o.shrinkBuf(i.output, i.next_out))); } while ((0 < i.avail_in || 0 === i.avail_out) && 1 !== r); return 4 === n ? (r = a.deflateEnd(this.strm), this.onEnd(r), this.ended = !0, r === l) : 2 !== n || (this.onEnd(l), !(i.avail_out = 0)); }, p.prototype.onData = function(e) { this.chunks.push(e); }, p.prototype.onEnd = function(e) { e === l && ("string" === this.options.to ? this.result = this.chunks.join("") : this.result = o.flattenChunks(this.chunks)), this.chunks = [], this.err = e, this.msg = this.strm.msg; }, r.Deflate = p, r.deflate = n, r.deflateRaw = function(e, t) { return (t = t || {}).raw = !0, n(e, t); }, r.gzip = function(e, t) { return (t = t || {}).gzip = !0, n(e, t); }; }, { "./utils/common": 41, "./utils/strings": 42, "./zlib/deflate": 46, "./zlib/messages": 51, "./zlib/zstream": 53 }], 40: [function(e, t, r) { "use strict"; var c = e("./zlib/inflate"), d = e("./utils/common"), p = e("./utils/strings"), m = e("./zlib/constants"), n = e("./zlib/messages"), i = e("./zlib/zstream"), s = e("./zlib/gzheader"), _ = Object.prototype.toString; function a(e) { if (!(this instanceof a)) return new a(e); this.options = d.assign({ chunkSize: 16384, windowBits: 0, to: "" }, e || {}); var t = this.options; t.raw && 0 <= t.windowBits && t.windowBits < 16 && (t.windowBits = -t.windowBits, 0 === t.windowBits && (t.windowBits = -15)), !(0 <= t.windowBits && t.windowBits < 16) || e && e.windowBits || (t.windowBits += 32), 15 < t.windowBits && t.windowBits < 48 && 0 == (15 & t.windowBits) && (t.windowBits |= 15), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new i(), this.strm.avail_out = 0; var r = c.inflateInit2(this.strm, t.windowBits); if (r !== m.Z_OK) throw new Error(n[r]); this.header = new s(), c.inflateGetHeader(this.strm, this.header); } function o(e, t) { var r = new a(t); if (r.push(e, !0), r.err) throw r.msg || n[r.err]; return r.result; } a.prototype.push = function(e, t) { var r, n, i, s, a, o, h = this.strm, u = this.options.chunkSize, l = this.options.dictionary, f = !1; if (this.ended) return !1; n = t === ~~t ? t : !0 === t ? m.Z_FINISH : m.Z_NO_FLUSH, "string" == typeof e ? h.input = p.binstring2buf(e) : "[object ArrayBuffer]" === _.call(e) ? h.input = new Uint8Array(e) : h.input = e, h.next_in = 0, h.avail_in = h.input.length; do { if (0 === h.avail_out && (h.output = new d.Buf8(u), h.next_out = 0, h.avail_out = u), (r = c.inflate(h, m.Z_NO_FLUSH)) === m.Z_NEED_DICT && l && (o = "string" == typeof l ? p.string2buf(l) : "[object ArrayBuffer]" === _.call(l) ? new Uint8Array(l) : l, r = c.inflateSetDictionary(this.strm, o)), r === m.Z_BUF_ERROR && !0 === f && (r = m.Z_OK, f = !1), r !== m.Z_STREAM_END && r !== m.Z_OK) return this.onEnd(r), !(this.ended = !0); h.next_out && (0 !== h.avail_out && r !== m.Z_STREAM_END && (0 !== h.avail_in || n !== m.Z_FINISH && n !== m.Z_SYNC_FLUSH) || ("string" === this.options.to ? (i = p.utf8border(h.output, h.next_out), s = h.next_out - i, a = p.buf2string(h.output, i), h.next_out = s, h.avail_out = u - s, s && d.arraySet(h.output, h.output, i, s, 0), this.onData(a)) : this.onData(d.shrinkBuf(h.output, h.next_out)))), 0 === h.avail_in && 0 === h.avail_out && (f = !0); } while ((0 < h.avail_in || 0 === h.avail_out) && r !== m.Z_STREAM_END); return r === m.Z_STREAM_END && (n = m.Z_FINISH), n === m.Z_FINISH ? (r = c.inflateEnd(this.strm), this.onEnd(r), this.ended = !0, r === m.Z_OK) : n !== m.Z_SYNC_FLUSH || (this.onEnd(m.Z_OK), !(h.avail_out = 0)); }, a.prototype.onData = function(e) { this.chunks.push(e); }, a.prototype.onEnd = function(e) { e === m.Z_OK && ("string" === this.options.to ? this.result = this.chunks.join("") : this.result = d.flattenChunks(this.chunks)), this.chunks = [], this.err = e, this.msg = this.strm.msg; }, r.Inflate = a, r.inflate = o, r.inflateRaw = function(e, t) { return (t = t || {}).raw = !0, o(e, t); }, r.ungzip = o; }, { "./utils/common": 41, "./utils/strings": 42, "./zlib/constants": 44, "./zlib/gzheader": 47, "./zlib/inflate": 49, "./zlib/messages": 51, "./zlib/zstream": 53 }], 41: [function(e, t, r) { "use strict"; var n = "undefined" != typeof Uint8Array && "undefined" != typeof Uint16Array && "undefined" != typeof Int32Array; r.assign = function(e) { for (var t = Array.prototype.slice.call(arguments, 1); t.length;) { var r = t.shift(); if (r) { if ("object" != typeof r) throw new TypeError(r + "must be non-object"); for (var n in r) r.hasOwnProperty(n) && (e[n] = r[n]); } } return e; }, r.shrinkBuf = function(e, t) { return e.length === t ? e : e.subarray ? e.subarray(0, t) : (e.length = t, e); }; var i = { arraySet: function(e, t, r, n, i) { if (t.subarray && e.subarray) e.set(t.subarray(r, r + n), i); else for (var s = 0; s < n; s++) e[i + s] = t[r + s]; }, flattenChunks: function(e) { var t, r, n, i, s, a; for (t = n = 0, r = e.length; t < r; t++) n += e[t].length; for (a = new Uint8Array(n), t = i = 0, r = e.length; t < r; t++) s = e[t], a.set(s, i), i += s.length; return a; } }, s = { arraySet: function(e, t, r, n, i) { for (var s = 0; s < n; s++) e[i + s] = t[r + s]; }, flattenChunks: function(e) { return [].concat.apply([], e); } }; r.setTyped = function(e) { e ? (r.Buf8 = Uint8Array, r.Buf16 = Uint16Array, r.Buf32 = Int32Array, r.assign(r, i)) : (r.Buf8 = Array, r.Buf16 = Array, r.Buf32 = Array, r.assign(r, s)); }, r.setTyped(n); }, {}], 42: [function(e, t, r) { "use strict"; var h = e("./common"), i = !0, s = !0; try { String.fromCharCode.apply(null, [0]); } catch (e) { i = !1; } try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (e) { s = !1; } for (var u = new h.Buf8(256), n = 0; n < 256; n++) u[n] = 252 <= n ? 6 : 248 <= n ? 5 : 240 <= n ? 4 : 224 <= n ? 3 : 192 <= n ? 2 : 1; function l(e, t) { if (t < 65537 && (e.subarray && s || !e.subarray && i)) return String.fromCharCode.apply(null, h.shrinkBuf(e, t)); for (var r = "", n = 0; n < t; n++) r += String.fromCharCode(e[n]); return r; } u[254] = u[254] = 1, r.string2buf = function(e) { var t, r, n, i, s, a = e.length, o = 0; for (i = 0; i < a; i++) 55296 == (64512 & (r = e.charCodeAt(i))) && i + 1 < a && 56320 == (64512 & (n = e.charCodeAt(i + 1))) && (r = 65536 + (r - 55296 << 10) + (n - 56320), i++), o += r < 128 ? 1 : r < 2048 ? 2 : r < 65536 ? 3 : 4; for (t = new h.Buf8(o), i = s = 0; s < o; i++) 55296 == (64512 & (r = e.charCodeAt(i))) && i + 1 < a && 56320 == (64512 & (n = e.charCodeAt(i + 1))) && (r = 65536 + (r - 55296 << 10) + (n - 56320), i++), r < 128 ? t[s++] = r : (r < 2048 ? t[s++] = 192 | r >>> 6 : (r < 65536 ? t[s++] = 224 | r >>> 12 : (t[s++] = 240 | r >>> 18, t[s++] = 128 | r >>> 12 & 63), t[s++] = 128 | r >>> 6 & 63), t[s++] = 128 | 63 & r); return t; }, r.buf2binstring = function(e) { return l(e, e.length); }, r.binstring2buf = function(e) { for (var t = new h.Buf8(e.length), r = 0, n = t.length; r < n; r++) t[r] = e.charCodeAt(r); return t; }, r.buf2string = function(e, t) { var r, n, i, s, a = t || e.length, o = new Array(2 * a); for (r = n = 0; r < a;) if ((i = e[r++]) < 128) o[n++] = i; else if (4 < (s = u[i])) o[n++] = 65533, r += s - 1; else { for (i &= 2 === s ? 31 : 3 === s ? 15 : 7; 1 < s && r < a;) i = i << 6 | 63 & e[r++], s--; 1 < s ? o[n++] = 65533 : i < 65536 ? o[n++] = i : (i -= 65536, o[n++] = 55296 | i >> 10 & 1023, o[n++] = 56320 | 1023 & i); } return l(o, n); }, r.utf8border = function(e, t) { var r; for ((t = t || e.length) > e.length && (t = e.length), r = t - 1; 0 <= r && 128 == (192 & e[r]);) r--; return r < 0 ? t : 0 === r ? t : r + u[e[r]] > t ? r : t; }; }, { "./common": 41 }], 43: [function(e, t, r) { "use strict"; t.exports = function(e, t, r, n) { for (var i = 65535 & e | 0, s = e >>> 16 & 65535 | 0, a = 0; 0 !== r;) { for (r -= a = 2e3 < r ? 2e3 : r; s = s + (i = i + t[n++] | 0) | 0, --a;); i %= 65521, s %= 65521; } return i | s << 16 | 0; }; }, {}], 44: [function(e, t, r) { "use strict"; t.exports = { Z_NO_FLUSH: 0, Z_PARTIAL_FLUSH: 1, Z_SYNC_FLUSH: 2, Z_FULL_FLUSH: 3, Z_FINISH: 4, Z_BLOCK: 5, Z_TREES: 6, Z_OK: 0, Z_STREAM_END: 1, Z_NEED_DICT: 2, Z_ERRNO: -1, Z_STREAM_ERROR: -2, Z_DATA_ERROR: -3, Z_BUF_ERROR: -5, Z_NO_COMPRESSION: 0, Z_BEST_SPEED: 1, Z_BEST_COMPRESSION: 9, Z_DEFAULT_COMPRESSION: -1, Z_FILTERED: 1, Z_HUFFMAN_ONLY: 2, Z_RLE: 3, Z_FIXED: 4, Z_DEFAULT_STRATEGY: 0, Z_BINARY: 0, Z_TEXT: 1, Z_UNKNOWN: 2, Z_DEFLATED: 8 }; }, {}], 45: [function(e, t, r) { "use strict"; var o = function() { for (var e, t = [], r = 0; r < 256; r++) { e = r; for (var n = 0; n < 8; n++) e = 1 & e ? 3988292384 ^ e >>> 1 : e >>> 1; t[r] = e; } return t; }(); t.exports = function(e, t, r, n) { var i = o, s = n + r; e ^= -1; for (var a = n; a < s; a++) e = e >>> 8 ^ i[255 & (e ^ t[a])]; return -1 ^ e; }; }, {}], 46: [function(e, t, r) { "use strict"; var h, c = e("../utils/common"), u = e("./trees"), d = e("./adler32"), p = e("./crc32"), n = e("./messages"), l = 0, f = 4, m = 0, _ = -2, g = -1, b = 4, i = 2, v = 8, y = 9, s = 286, a = 30, o = 19, w = 2 * s + 1, k = 15, x = 3, S = 258, z = S + x + 1, C = 42, E = 113, A = 1, I = 2, O = 3, B = 4; function R(e, t) { return e.msg = n[t], t; } function T(e) { return (e << 1) - (4 < e ? 9 : 0); } function D(e) { for (var t = e.length; 0 <= --t;) e[t] = 0; } function F(e) { var t = e.state, r = t.pending; r > e.avail_out && (r = e.avail_out), 0 !== r && (c.arraySet(e.output, t.pending_buf, t.pending_out, r, e.next_out), e.next_out += r, t.pending_out += r, e.total_out += r, e.avail_out -= r, t.pending -= r, 0 === t.pending && (t.pending_out = 0)); } function N(e, t) { u._tr_flush_block(e, 0 <= e.block_start ? e.block_start : -1, e.strstart - e.block_start, t), e.block_start = e.strstart, F(e.strm); } function U(e, t) { e.pending_buf[e.pending++] = t; } function P(e, t) { e.pending_buf[e.pending++] = t >>> 8 & 255, e.pending_buf[e.pending++] = 255 & t; } function L(e, t) { var r, n, i = e.max_chain_length, s = e.strstart, a = e.prev_length, o = e.nice_match, h = e.strstart > e.w_size - z ? e.strstart - (e.w_size - z) : 0, u = e.window, l = e.w_mask, f = e.prev, c = e.strstart + S, d = u[s + a - 1], p = u[s + a]; e.prev_length >= e.good_match && (i >>= 2), o > e.lookahead && (o = e.lookahead); do if (u[(r = t) + a] === p && u[r + a - 1] === d && u[r] === u[s] && u[++r] === u[s + 1]) { s += 2, r++; do ; while (u[++s] === u[++r] && u[++s] === u[++r] && u[++s] === u[++r] && u[++s] === u[++r] && u[++s] === u[++r] && u[++s] === u[++r] && u[++s] === u[++r] && u[++s] === u[++r] && s < c); if (n = S - (c - s), s = c - S, a < n) { if (e.match_start = t, o <= (a = n)) break; d = u[s + a - 1], p = u[s + a]; } } while ((t = f[t & l]) > h && 0 != --i); return a <= e.lookahead ? a : e.lookahead; } function j(e) { var t, r, n, i, s, a, o, h, u, l, f = e.w_size; do { if (i = e.window_size - e.lookahead - e.strstart, e.strstart >= f + (f - z)) { for (c.arraySet(e.window, e.window, f, f, 0), e.match_start -= f, e.strstart -= f, e.block_start -= f, t = r = e.hash_size; n = e.head[--t], e.head[t] = f <= n ? n - f : 0, --r;); for (t = r = f; n = e.prev[--t], e.prev[t] = f <= n ? n - f : 0, --r;); i += f; } if (0 === e.strm.avail_in) break; if (a = e.strm, o = e.window, h = e.strstart + e.lookahead, u = i, l = void 0, l = a.avail_in, u < l && (l = u), r = 0 === l ? 0 : (a.avail_in -= l, c.arraySet(o, a.input, a.next_in, l, h), 1 === a.state.wrap ? a.adler = d(a.adler, o, l, h) : 2 === a.state.wrap && (a.adler = p(a.adler, o, l, h)), a.next_in += l, a.total_in += l, l), e.lookahead += r, e.lookahead + e.insert >= x) for (s = e.strstart - e.insert, e.ins_h = e.window[s], e.ins_h = (e.ins_h << e.hash_shift ^ e.window[s + 1]) & e.hash_mask; e.insert && (e.ins_h = (e.ins_h << e.hash_shift ^ e.window[s + x - 1]) & e.hash_mask, e.prev[s & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = s, s++, e.insert--, !(e.lookahead + e.insert < x));); } while (e.lookahead < z && 0 !== e.strm.avail_in); } function Z(e, t) { for (var r, n;;) { if (e.lookahead < z) { if (j(e), e.lookahead < z && t === l) return A; if (0 === e.lookahead) break; } if (r = 0, e.lookahead >= x && (e.ins_h = (e.ins_h << e.hash_shift ^ e.window[e.strstart + x - 1]) & e.hash_mask, r = e.prev[e.strstart & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = e.strstart), 0 !== r && e.strstart - r <= e.w_size - z && (e.match_length = L(e, r)), e.match_length >= x) if (n = u._tr_tally(e, e.strstart - e.match_start, e.match_length - x), e.lookahead -= e.match_length, e.match_length <= e.max_lazy_match && e.lookahead >= x) { for (e.match_length--; e.strstart++, e.ins_h = (e.ins_h << e.hash_shift ^ e.window[e.strstart + x - 1]) & e.hash_mask, r = e.prev[e.strstart & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = e.strstart, 0 != --e.match_length;); e.strstart++; } else e.strstart += e.match_length, e.match_length = 0, e.ins_h = e.window[e.strstart], e.ins_h = (e.ins_h << e.hash_shift ^ e.window[e.strstart + 1]) & e.hash_mask; else n = u._tr_tally(e, 0, e.window[e.strstart]), e.lookahead--, e.strstart++; if (n && (N(e, !1), 0 === e.strm.avail_out)) return A; } return e.insert = e.strstart < x - 1 ? e.strstart : x - 1, t === f ? (N(e, !0), 0 === e.strm.avail_out ? O : B) : e.last_lit && (N(e, !1), 0 === e.strm.avail_out) ? A : I; } function W(e, t) { for (var r, n, i;;) { if (e.lookahead < z) { if (j(e), e.lookahead < z && t === l) return A; if (0 === e.lookahead) break; } if (r = 0, e.lookahead >= x && (e.ins_h = (e.ins_h << e.hash_shift ^ e.window[e.strstart + x - 1]) & e.hash_mask, r = e.prev[e.strstart & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = e.strstart), e.prev_length = e.match_length, e.prev_match = e.match_start, e.match_length = x - 1, 0 !== r && e.prev_length < e.max_lazy_match && e.strstart - r <= e.w_size - z && (e.match_length = L(e, r), e.match_length <= 5 && (1 === e.strategy || e.match_length === x && 4096 < e.strstart - e.match_start) && (e.match_length = x - 1)), e.prev_length >= x && e.match_length <= e.prev_length) { for (i = e.strstart + e.lookahead - x, n = u._tr_tally(e, e.strstart - 1 - e.prev_match, e.prev_length - x), e.lookahead -= e.prev_length - 1, e.prev_length -= 2; ++e.strstart <= i && (e.ins_h = (e.ins_h << e.hash_shift ^ e.window[e.strstart + x - 1]) & e.hash_mask, r = e.prev[e.strstart & e.w_mask] = e.head[e.ins_h], e.head[e.ins_h] = e.strstart), 0 != --e.prev_length;); if (e.match_available = 0, e.match_length = x - 1, e.strstart++, n && (N(e, !1), 0 === e.strm.avail_out)) return A; } else if (e.match_available) { if ((n = u._tr_tally(e, 0, e.window[e.strstart - 1])) && N(e, !1), e.strstart++, e.lookahead--, 0 === e.strm.avail_out) return A; } else e.match_available = 1, e.strstart++, e.lookahead--; } return e.match_available && (n = u._tr_tally(e, 0, e.window[e.strstart - 1]), e.match_available = 0), e.insert = e.strstart < x - 1 ? e.strstart : x - 1, t === f ? (N(e, !0), 0 === e.strm.avail_out ? O : B) : e.last_lit && (N(e, !1), 0 === e.strm.avail_out) ? A : I; } function M(e, t, r, n, i) { this.good_length = e, this.max_lazy = t, this.nice_length = r, this.max_chain = n, this.func = i; } function H() { this.strm = null, this.status = 0, this.pending_buf = null, this.pending_buf_size = 0, this.pending_out = 0, this.pending = 0, this.wrap = 0, this.gzhead = null, this.gzindex = 0, this.method = v, this.last_flush = -1, this.w_size = 0, this.w_bits = 0, this.w_mask = 0, this.window = null, this.window_size = 0, this.prev = null, this.head = null, this.ins_h = 0, this.hash_size = 0, this.hash_bits = 0, this.hash_mask = 0, this.hash_shift = 0, this.block_start = 0, this.match_length = 0, this.prev_match = 0, this.match_available = 0, this.strstart = 0, this.match_start = 0, this.lookahead = 0, this.prev_length = 0, this.max_chain_length = 0, this.max_lazy_match = 0, this.level = 0, this.strategy = 0, this.good_match = 0, this.nice_match = 0, this.dyn_ltree = new c.Buf16(2 * w), this.dyn_dtree = new c.Buf16(2 * (2 * a + 1)), this.bl_tree = new c.Buf16(2 * (2 * o + 1)), D(this.dyn_ltree), D(this.dyn_dtree), D(this.bl_tree), this.l_desc = null, this.d_desc = null, this.bl_desc = null, this.bl_count = new c.Buf16(k + 1), this.heap = new c.Buf16(2 * s + 1), D(this.heap), this.heap_len = 0, this.heap_max = 0, this.depth = new c.Buf16(2 * s + 1), D(this.depth), this.l_buf = 0, this.lit_bufsize = 0, this.last_lit = 0, this.d_buf = 0, this.opt_len = 0, this.static_len = 0, this.matches = 0, this.insert = 0, this.bi_buf = 0, this.bi_valid = 0; } function G(e) { var t; return e && e.state ? (e.total_in = e.total_out = 0, e.data_type = i, (t = e.state).pending = 0, t.pending_out = 0, t.wrap < 0 && (t.wrap = -t.wrap), t.status = t.wrap ? C : E, e.adler = 2 === t.wrap ? 0 : 1, t.last_flush = l, u._tr_init(t), m) : R(e, _); } function K(e) { var t = G(e); return t === m && function(e) { e.window_size = 2 * e.w_size, D(e.head), e.max_lazy_match = h[e.level].max_lazy, e.good_match = h[e.level].good_length, e.nice_match = h[e.level].nice_length, e.max_chain_length = h[e.level].max_chain, e.strstart = 0, e.block_start = 0, e.lookahead = 0, e.insert = 0, e.match_length = e.prev_length = x - 1, e.match_available = 0, e.ins_h = 0; }(e.state), t; } function Y(e, t, r, n, i, s) { if (!e) return _; var a = 1; if (t === g && (t = 6), n < 0 ? (a = 0, n = -n) : 15 < n && (a = 2, n -= 16), i < 1 || y < i || r !== v || n < 8 || 15 < n || t < 0 || 9 < t || s < 0 || b < s) return R(e, _); 8 === n && (n = 9); var o = new H(); return (e.state = o).strm = e, o.wrap = a, o.gzhead = null, o.w_bits = n, o.w_size = 1 << o.w_bits, o.w_mask = o.w_size - 1, o.hash_bits = i + 7, o.hash_size = 1 << o.hash_bits, o.hash_mask = o.hash_size - 1, o.hash_shift = ~~((o.hash_bits + x - 1) / x), o.window = new c.Buf8(2 * o.w_size), o.head = new c.Buf16(o.hash_size), o.prev = new c.Buf16(o.w_size), o.lit_bufsize = 1 << i + 6, o.pending_buf_size = 4 * o.lit_bufsize, o.pending_buf = new c.Buf8(o.pending_buf_size), o.d_buf = 1 * o.lit_bufsize, o.l_buf = 3 * o.lit_bufsize, o.level = t, o.strategy = s, o.method = r, K(e); } h = [ new M(0, 0, 0, 0, function(e, t) { var r = 65535; for (r > e.pending_buf_size - 5 && (r = e.pending_buf_size - 5);;) { if (e.lookahead <= 1) { if (j(e), 0 === e.lookahead && t === l) return A; if (0 === e.lookahead) break; } e.strstart += e.lookahead, e.lookahead = 0; var n = e.block_start + r; if ((0 === e.strstart || e.strstart >= n) && (e.lookahead = e.strstart - n, e.strstart = n, N(e, !1), 0 === e.strm.avail_out)) return A; if (e.strstart - e.block_start >= e.w_size - z && (N(e, !1), 0 === e.strm.avail_out)) return A; } return e.insert = 0, t === f ? (N(e, !0), 0 === e.strm.avail_out ? O : B) : (e.strstart > e.block_start && (N(e, !1), e.strm.avail_out), A); }), new M(4, 4, 8, 4, Z), new M(4, 5, 16, 8, Z), new M(4, 6, 32, 32, Z), new M(4, 4, 16, 16, W), new M(8, 16, 32, 32, W), new M(8, 16, 128, 128, W), new M(8, 32, 128, 256, W), new M(32, 128, 258, 1024, W), new M(32, 258, 258, 4096, W) ], r.deflateInit = function(e, t) { return Y(e, t, v, 15, 8, 0); }, r.deflateInit2 = Y, r.deflateReset = K, r.deflateResetKeep = G, r.deflateSetHeader = function(e, t) { return e && e.state ? 2 !== e.state.wrap ? _ : (e.state.gzhead = t, m) : _; }, r.deflate = function(e, t) { var r, n, i, s; if (!e || !e.state || 5 < t || t < 0) return e ? R(e, _) : _; if (n = e.state, !e.output || !e.input && 0 !== e.avail_in || 666 === n.status && t !== f) return R(e, 0 === e.avail_out ? -5 : _); if (n.strm = e, r = n.last_flush, n.last_flush = t, n.status === C) if (2 === n.wrap) e.adler = 0, U(n, 31), U(n, 139), U(n, 8), n.gzhead ? (U(n, (n.gzhead.text ? 1 : 0) + (n.gzhead.hcrc ? 2 : 0) + (n.gzhead.extra ? 4 : 0) + (n.gzhead.name ? 8 : 0) + (n.gzhead.comment ? 16 : 0)), U(n, 255 & n.gzhead.time), U(n, n.gzhead.time >> 8 & 255), U(n, n.gzhead.time >> 16 & 255), U(n, n.gzhead.time >> 24 & 255), U(n, 9 === n.level ? 2 : 2 <= n.strategy || n.level < 2 ? 4 : 0), U(n, 255 & n.gzhead.os), n.gzhead.extra && n.gzhead.extra.length && (U(n, 255 & n.gzhead.extra.length), U(n, n.gzhead.extra.length >> 8 & 255)), n.gzhead.hcrc && (e.adler = p(e.adler, n.pending_buf, n.pending, 0)), n.gzindex = 0, n.status = 69) : (U(n, 0), U(n, 0), U(n, 0), U(n, 0), U(n, 0), U(n, 9 === n.level ? 2 : 2 <= n.strategy || n.level < 2 ? 4 : 0), U(n, 3), n.status = E); else { var a = v + (n.w_bits - 8 << 4) << 8; a |= (2 <= n.strategy || n.level < 2 ? 0 : n.level < 6 ? 1 : 6 === n.level ? 2 : 3) << 6, 0 !== n.strstart && (a |= 32), a += 31 - a % 31, n.status = E, P(n, a), 0 !== n.strstart && (P(n, e.adler >>> 16), P(n, 65535 & e.adler)), e.adler = 1; } if (69 === n.status) if (n.gzhead.extra) { for (i = n.pending; n.gzindex < (65535 & n.gzhead.extra.length) && (n.pending !== n.pending_buf_size || (n.gzhead.hcrc && n.pending > i && (e.adler = p(e.adler, n.pending_buf, n.pending - i, i)), F(e), i = n.pending, n.pending !== n.pending_buf_size));) U(n, 255 & n.gzhead.extra[n.gzindex]), n.gzindex++; n.gzhead.hcrc && n.pending > i && (e.adler = p(e.adler, n.pending_buf, n.pending - i, i)), n.gzindex === n.gzhead.extra.length && (n.gzindex = 0, n.status = 73); } else n.status = 73; if (73 === n.status) if (n.gzhead.name) { i = n.pending; do { if (n.pending === n.pending_buf_size && (n.gzhead.hcrc && n.pending > i && (e.adler = p(e.adler, n.pending_buf, n.pending - i, i)), F(e), i = n.pending, n.pending === n.pending_buf_size)) { s = 1; break; } s = n.gzindex < n.gzhead.name.length ? 255 & n.gzhead.name.charCodeAt(n.gzindex++) : 0, U(n, s); } while (0 !== s); n.gzhead.hcrc && n.pending > i && (e.adler = p(e.adler, n.pending_buf, n.pending - i, i)), 0 === s && (n.gzindex = 0, n.status = 91); } else n.status = 91; if (91 === n.status) if (n.gzhead.comment) { i = n.pending; do { if (n.pending === n.pending_buf_size && (n.gzhead.hcrc && n.pending > i && (e.adler = p(e.adler, n.pending_buf, n.pending - i, i)), F(e), i = n.pending, n.pending === n.pending_buf_size)) { s = 1; break; } s = n.gzindex < n.gzhead.comment.length ? 255 & n.gzhead.comment.charCodeAt(n.gzindex++) : 0, U(n, s); } while (0 !== s); n.gzhead.hcrc && n.pending > i && (e.adler = p(e.adler, n.pending_buf, n.pending - i, i)), 0 === s && (n.status = 103); } else n.status = 103; if (103 === n.status && (n.gzhead.hcrc ? (n.pending + 2 > n.pending_buf_size && F(e), n.pending + 2 <= n.pending_buf_size && (U(n, 255 & e.adler), U(n, e.adler >> 8 & 255), e.adler = 0, n.status = E)) : n.status = E), 0 !== n.pending) { if (F(e), 0 === e.avail_out) return n.last_flush = -1, m; } else if (0 === e.avail_in && T(t) <= T(r) && t !== f) return R(e, -5); if (666 === n.status && 0 !== e.avail_in) return R(e, -5); if (0 !== e.avail_in || 0 !== n.lookahead || t !== l && 666 !== n.status) { var o = 2 === n.strategy ? function(e, t) { for (var r;;) { if (0 === e.lookahead && (j(e), 0 === e.lookahead)) { if (t === l) return A; break; } if (e.match_length = 0, r = u._tr_tally(e, 0, e.window[e.strstart]), e.lookahead--, e.strstart++, r && (N(e, !1), 0 === e.strm.avail_out)) return A; } return e.insert = 0, t === f ? (N(e, !0), 0 === e.strm.avail_out ? O : B) : e.last_lit && (N(e, !1), 0 === e.strm.avail_out) ? A : I; }(n, t) : 3 === n.strategy ? function(e, t) { for (var r, n, i, s, a = e.window;;) { if (e.lookahead <= S) { if (j(e), e.lookahead <= S && t === l) return A; if (0 === e.lookahead) break; } if (e.match_length = 0, e.lookahead >= x && 0 < e.strstart && (n = a[i = e.strstart - 1]) === a[++i] && n === a[++i] && n === a[++i]) { s = e.strstart + S; do ; while (n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && n === a[++i] && i < s); e.match_length = S - (s - i), e.match_length > e.lookahead && (e.match_length = e.lookahead); } if (e.match_length >= x ? (r = u._tr_tally(e, 1, e.match_length - x), e.lookahead -= e.match_length, e.strstart += e.match_length, e.match_length = 0) : (r = u._tr_tally(e, 0, e.window[e.strstart]), e.lookahead--, e.strstart++), r && (N(e, !1), 0 === e.strm.avail_out)) return A; } return e.insert = 0, t === f ? (N(e, !0), 0 === e.strm.avail_out ? O : B) : e.last_lit && (N(e, !1), 0 === e.strm.avail_out) ? A : I; }(n, t) : h[n.level].func(n, t); if (o !== O && o !== B || (n.status = 666), o === A || o === O) return 0 === e.avail_out && (n.last_flush = -1), m; if (o === I && (1 === t ? u._tr_align(n) : 5 !== t && (u._tr_stored_block(n, 0, 0, !1), 3 === t && (D(n.head), 0 === n.lookahead && (n.strstart = 0, n.block_start = 0, n.insert = 0))), F(e), 0 === e.avail_out)) return n.last_flush = -1, m; } return t !== f ? m : n.wrap <= 0 ? 1 : (2 === n.wrap ? (U(n, 255 & e.adler), U(n, e.adler >> 8 & 255), U(n, e.adler >> 16 & 255), U(n, e.adler >> 24 & 255), U(n, 255 & e.total_in), U(n, e.total_in >> 8 & 255), U(n, e.total_in >> 16 & 255), U(n, e.total_in >> 24 & 255)) : (P(n, e.adler >>> 16), P(n, 65535 & e.adler)), F(e), 0 < n.wrap && (n.wrap = -n.wrap), 0 !== n.pending ? m : 1); }, r.deflateEnd = function(e) { var t; return e && e.state ? (t = e.state.status) !== C && 69 !== t && 73 !== t && 91 !== t && 103 !== t && t !== E && 666 !== t ? R(e, _) : (e.state = null, t === E ? R(e, -3) : m) : _; }, r.deflateSetDictionary = function(e, t) { var r, n, i, s, a, o, h, u, l = t.length; if (!e || !e.state) return _; if (2 === (s = (r = e.state).wrap) || 1 === s && r.status !== C || r.lookahead) return _; for (1 === s && (e.adler = d(e.adler, t, l, 0)), r.wrap = 0, l >= r.w_size && (0 === s && (D(r.head), r.strstart = 0, r.block_start = 0, r.insert = 0), u = new c.Buf8(r.w_size), c.arraySet(u, t, l - r.w_size, r.w_size, 0), t = u, l = r.w_size), a = e.avail_in, o = e.next_in, h = e.input, e.avail_in = l, e.next_in = 0, e.input = t, j(r); r.lookahead >= x;) { for (n = r.strstart, i = r.lookahead - (x - 1); r.ins_h = (r.ins_h << r.hash_shift ^ r.window[n + x - 1]) & r.hash_mask, r.prev[n & r.w_mask] = r.head[r.ins_h], r.head[r.ins_h] = n, n++, --i;); r.strstart = n, r.lookahead = x - 1, j(r); } return r.strstart += r.lookahead, r.block_start = r.strstart, r.insert = r.lookahead, r.lookahead = 0, r.match_length = r.prev_length = x - 1, r.match_available = 0, e.next_in = o, e.input = h, e.avail_in = a, r.wrap = s, m; }, r.deflateInfo = "pako deflate (from Nodeca project)"; }, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./messages": 51, "./trees": 52 }], 47: [function(e, t, r) { "use strict"; t.exports = function() { this.text = 0, this.time = 0, this.xflags = 0, this.os = 0, this.extra = null, this.extra_len = 0, this.name = "", this.comment = "", this.hcrc = 0, this.done = !1; }; }, {}], 48: [function(e, t, r) { "use strict"; t.exports = function(e, t) { var r = e.state, n = e.next_in, i, s, a, o, h, u, l, f, c, d, p, m, _, g, b, v, y, w, k, x, S, z = e.input, C; i = n + (e.avail_in - 5), s = e.next_out, C = e.output, a = s - (t - e.avail_out), o = s + (e.avail_out - 257), h = r.dmax, u = r.wsize, l = r.whave, f = r.wnext, c = r.window, d = r.hold, p = r.bits, m = r.lencode, _ = r.distcode, g = (1 << r.lenbits) - 1, b = (1 << r.distbits) - 1; e: do { p < 15 && (d += z[n++] << p, p += 8, d += z[n++] << p, p += 8), v = m[d & g]; t: for (;;) { if (d >>>= y = v >>> 24, p -= y, 0 === (y = v >>> 16 & 255)) C[s++] = 65535 & v; else { if (!(16 & y)) { if (0 == (64 & y)) { v = m[(65535 & v) + (d & (1 << y) - 1)]; continue t; } if (32 & y) { r.mode = 12; break e; } e.msg = "invalid literal/length code", r.mode = 30; break e; } w = 65535 & v, (y &= 15) && (p < y && (d += z[n++] << p, p += 8), w += d & (1 << y) - 1, d >>>= y, p -= y), p < 15 && (d += z[n++] << p, p += 8, d += z[n++] << p, p += 8), v = _[d & b]; r: for (;;) { if (d >>>= y = v >>> 24, p -= y, !(16 & (y = v >>> 16 & 255))) { if (0 == (64 & y)) { v = _[(65535 & v) + (d & (1 << y) - 1)]; continue r; } e.msg = "invalid distance code", r.mode = 30; break e; } if (k = 65535 & v, p < (y &= 15) && (d += z[n++] << p, (p += 8) < y && (d += z[n++] << p, p += 8)), h < (k += d & (1 << y) - 1)) { e.msg = "invalid distance too far back", r.mode = 30; break e; } if (d >>>= y, p -= y, (y = s - a) < k) { if (l < (y = k - y) && r.sane) { e.msg = "invalid distance too far back", r.mode = 30; break e; } if (S = c, (x = 0) === f) { if (x += u - y, y < w) { for (w -= y; C[s++] = c[x++], --y;); x = s - k, S = C; } } else if (f < y) { if (x += u + f - y, (y -= f) < w) { for (w -= y; C[s++] = c[x++], --y;); if (x = 0, f < w) { for (w -= y = f; C[s++] = c[x++], --y;); x = s - k, S = C; } } } else if (x += f - y, y < w) { for (w -= y; C[s++] = c[x++], --y;); x = s - k, S = C; } for (; 2 < w;) C[s++] = S[x++], C[s++] = S[x++], C[s++] = S[x++], w -= 3; w && (C[s++] = S[x++], 1 < w && (C[s++] = S[x++])); } else { for (x = s - k; C[s++] = C[x++], C[s++] = C[x++], C[s++] = C[x++], 2 < (w -= 3);); w && (C[s++] = C[x++], 1 < w && (C[s++] = C[x++])); } break; } } break; } } while (n < i && s < o); n -= w = p >> 3, d &= (1 << (p -= w << 3)) - 1, e.next_in = n, e.next_out = s, e.avail_in = n < i ? i - n + 5 : 5 - (n - i), e.avail_out = s < o ? o - s + 257 : 257 - (s - o), r.hold = d, r.bits = p; }; }, {}], 49: [function(e, t, r) { "use strict"; var I = e("../utils/common"), O = e("./adler32"), B = e("./crc32"), R = e("./inffast"), T = e("./inftrees"), D = 1, F = 2, N = 0, U = -2, P = 1, n = 852, i = 592; function L(e) { return (e >>> 24 & 255) + (e >>> 8 & 65280) + ((65280 & e) << 8) + ((255 & e) << 24); } function s() { this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new I.Buf16(320), this.work = new I.Buf16(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0; } function a(e) { var t; return e && e.state ? (t = e.state, e.total_in = e.total_out = t.total = 0, e.msg = "", t.wrap && (e.adler = 1 & t.wrap), t.mode = P, t.last = 0, t.havedict = 0, t.dmax = 32768, t.head = null, t.hold = 0, t.bits = 0, t.lencode = t.lendyn = new I.Buf32(n), t.distcode = t.distdyn = new I.Buf32(i), t.sane = 1, t.back = -1, N) : U; } function o(e) { var t; return e && e.state ? ((t = e.state).wsize = 0, t.whave = 0, t.wnext = 0, a(e)) : U; } function h(e, t) { var r, n; return e && e.state ? (n = e.state, t < 0 ? (r = 0, t = -t) : (r = 1 + (t >> 4), t < 48 && (t &= 15)), t && (t < 8 || 15 < t) ? U : (null !== n.window && n.wbits !== t && (n.window = null), n.wrap = r, n.wbits = t, o(e))) : U; } function u(e, t) { var r, n; return e ? (n = new s(), (e.state = n).window = null, (r = h(e, t)) !== N && (e.state = null), r) : U; } var l, f, c = !0; function j(e) { if (c) { var t; for (l = new I.Buf32(512), f = new I.Buf32(32), t = 0; t < 144;) e.lens[t++] = 8; for (; t < 256;) e.lens[t++] = 9; for (; t < 280;) e.lens[t++] = 7; for (; t < 288;) e.lens[t++] = 8; for (T(D, e.lens, 0, 288, l, 0, e.work, { bits: 9 }), t = 0; t < 32;) e.lens[t++] = 5; T(F, e.lens, 0, 32, f, 0, e.work, { bits: 5 }), c = !1; } e.lencode = l, e.lenbits = 9, e.distcode = f, e.distbits = 5; } function Z(e, t, r, n) { var i, s = e.state; return null === s.window && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new I.Buf8(s.wsize)), n >= s.wsize ? (I.arraySet(s.window, t, r - s.wsize, s.wsize, 0), s.wnext = 0, s.whave = s.wsize) : (n < (i = s.wsize - s.wnext) && (i = n), I.arraySet(s.window, t, r - n, i, s.wnext), (n -= i) ? (I.arraySet(s.window, t, r - n, n, 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += i, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += i))), 0; } r.inflateReset = o, r.inflateReset2 = h, r.inflateResetKeep = a, r.inflateInit = function(e) { return u(e, 15); }, r.inflateInit2 = u, r.inflate = function(e, t) { var r, n, i, s, a, o, h, u, l, f, c, d, p, m, _, g, b, v, y, w, k, x, S, z, C = 0, E = new I.Buf8(4), A = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; if (!e || !e.state || !e.output || !e.input && 0 !== e.avail_in) return U; 12 === (r = e.state).mode && (r.mode = 13), a = e.next_out, i = e.output, h = e.avail_out, s = e.next_in, n = e.input, o = e.avail_in, u = r.hold, l = r.bits, f = o, c = h, x = N; e: for (;;) switch (r.mode) { case P: if (0 === r.wrap) { r.mode = 13; break; } for (; l < 16;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (2 & r.wrap && 35615 === u) { E[r.check = 0] = 255 & u, E[1] = u >>> 8 & 255, r.check = B(r.check, E, 2, 0), l = u = 0, r.mode = 2; break; } if (r.flags = 0, r.head && (r.head.done = !1), !(1 & r.wrap) || (((255 & u) << 8) + (u >> 8)) % 31) { e.msg = "incorrect header check", r.mode = 30; break; } if (8 != (15 & u)) { e.msg = "unknown compression method", r.mode = 30; break; } if (l -= 4, k = 8 + (15 & (u >>>= 4)), 0 === r.wbits) r.wbits = k; else if (k > r.wbits) { e.msg = "invalid window size", r.mode = 30; break; } r.dmax = 1 << k, e.adler = r.check = 1, r.mode = 512 & u ? 10 : 12, l = u = 0; break; case 2: for (; l < 16;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (r.flags = u, 8 != (255 & r.flags)) { e.msg = "unknown compression method", r.mode = 30; break; } if (57344 & r.flags) { e.msg = "unknown header flags set", r.mode = 30; break; } r.head && (r.head.text = u >> 8 & 1), 512 & r.flags && (E[0] = 255 & u, E[1] = u >>> 8 & 255, r.check = B(r.check, E, 2, 0)), l = u = 0, r.mode = 3; case 3: for (; l < 32;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } r.head && (r.head.time = u), 512 & r.flags && (E[0] = 255 & u, E[1] = u >>> 8 & 255, E[2] = u >>> 16 & 255, E[3] = u >>> 24 & 255, r.check = B(r.check, E, 4, 0)), l = u = 0, r.mode = 4; case 4: for (; l < 16;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } r.head && (r.head.xflags = 255 & u, r.head.os = u >> 8), 512 & r.flags && (E[0] = 255 & u, E[1] = u >>> 8 & 255, r.check = B(r.check, E, 2, 0)), l = u = 0, r.mode = 5; case 5: if (1024 & r.flags) { for (; l < 16;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } r.length = u, r.head && (r.head.extra_len = u), 512 & r.flags && (E[0] = 255 & u, E[1] = u >>> 8 & 255, r.check = B(r.check, E, 2, 0)), l = u = 0; } else r.head && (r.head.extra = null); r.mode = 6; case 6: if (1024 & r.flags && (o < (d = r.length) && (d = o), d && (r.head && (k = r.head.extra_len - r.length, r.head.extra || (r.head.extra = new Array(r.head.extra_len)), I.arraySet(r.head.extra, n, s, d, k)), 512 & r.flags && (r.check = B(r.check, n, d, s)), o -= d, s += d, r.length -= d), r.length)) break e; r.length = 0, r.mode = 7; case 7: if (2048 & r.flags) { if (0 === o) break e; for (d = 0; k = n[s + d++], r.head && k && r.length < 65536 && (r.head.name += String.fromCharCode(k)), k && d < o;); if (512 & r.flags && (r.check = B(r.check, n, d, s)), o -= d, s += d, k) break e; } else r.head && (r.head.name = null); r.length = 0, r.mode = 8; case 8: if (4096 & r.flags) { if (0 === o) break e; for (d = 0; k = n[s + d++], r.head && k && r.length < 65536 && (r.head.comment += String.fromCharCode(k)), k && d < o;); if (512 & r.flags && (r.check = B(r.check, n, d, s)), o -= d, s += d, k) break e; } else r.head && (r.head.comment = null); r.mode = 9; case 9: if (512 & r.flags) { for (; l < 16;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (u !== (65535 & r.check)) { e.msg = "header crc mismatch", r.mode = 30; break; } l = u = 0; } r.head && (r.head.hcrc = r.flags >> 9 & 1, r.head.done = !0), e.adler = r.check = 0, r.mode = 12; break; case 10: for (; l < 32;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } e.adler = r.check = L(u), l = u = 0, r.mode = 11; case 11: if (0 === r.havedict) return e.next_out = a, e.avail_out = h, e.next_in = s, e.avail_in = o, r.hold = u, r.bits = l, 2; e.adler = r.check = 1, r.mode = 12; case 12: if (5 === t || 6 === t) break e; case 13: if (r.last) { u >>>= 7 & l, l -= 7 & l, r.mode = 27; break; } for (; l < 3;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } switch (r.last = 1 & u, l -= 1, 3 & (u >>>= 1)) { case 0: r.mode = 14; break; case 1: if (j(r), r.mode = 20, 6 !== t) break; u >>>= 2, l -= 2; break e; case 2: r.mode = 17; break; case 3: e.msg = "invalid block type", r.mode = 30; } u >>>= 2, l -= 2; break; case 14: for (u >>>= 7 & l, l -= 7 & l; l < 32;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if ((65535 & u) != (u >>> 16 ^ 65535)) { e.msg = "invalid stored block lengths", r.mode = 30; break; } if (r.length = 65535 & u, l = u = 0, r.mode = 15, 6 === t) break e; case 15: r.mode = 16; case 16: if (d = r.length) { if (o < d && (d = o), h < d && (d = h), 0 === d) break e; I.arraySet(i, n, s, d, a), o -= d, s += d, h -= d, a += d, r.length -= d; break; } r.mode = 12; break; case 17: for (; l < 14;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (r.nlen = 257 + (31 & u), u >>>= 5, l -= 5, r.ndist = 1 + (31 & u), u >>>= 5, l -= 5, r.ncode = 4 + (15 & u), u >>>= 4, l -= 4, 286 < r.nlen || 30 < r.ndist) { e.msg = "too many length or distance symbols", r.mode = 30; break; } r.have = 0, r.mode = 18; case 18: for (; r.have < r.ncode;) { for (; l < 3;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } r.lens[A[r.have++]] = 7 & u, u >>>= 3, l -= 3; } for (; r.have < 19;) r.lens[A[r.have++]] = 0; if (r.lencode = r.lendyn, r.lenbits = 7, S = { bits: r.lenbits }, x = T(0, r.lens, 0, 19, r.lencode, 0, r.work, S), r.lenbits = S.bits, x) { e.msg = "invalid code lengths set", r.mode = 30; break; } r.have = 0, r.mode = 19; case 19: for (; r.have < r.nlen + r.ndist;) { for (; g = (C = r.lencode[u & (1 << r.lenbits) - 1]) >>> 16 & 255, b = 65535 & C, !((_ = C >>> 24) <= l);) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (b < 16) u >>>= _, l -= _, r.lens[r.have++] = b; else { if (16 === b) { for (z = _ + 2; l < z;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (u >>>= _, l -= _, 0 === r.have) { e.msg = "invalid bit length repeat", r.mode = 30; break; } k = r.lens[r.have - 1], d = 3 + (3 & u), u >>>= 2, l -= 2; } else if (17 === b) { for (z = _ + 3; l < z;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } l -= _, k = 0, d = 3 + (7 & (u >>>= _)), u >>>= 3, l -= 3; } else { for (z = _ + 7; l < z;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } l -= _, k = 0, d = 11 + (127 & (u >>>= _)), u >>>= 7, l -= 7; } if (r.have + d > r.nlen + r.ndist) { e.msg = "invalid bit length repeat", r.mode = 30; break; } for (; d--;) r.lens[r.have++] = k; } } if (30 === r.mode) break; if (0 === r.lens[256]) { e.msg = "invalid code -- missing end-of-block", r.mode = 30; break; } if (r.lenbits = 9, S = { bits: r.lenbits }, x = T(D, r.lens, 0, r.nlen, r.lencode, 0, r.work, S), r.lenbits = S.bits, x) { e.msg = "invalid literal/lengths set", r.mode = 30; break; } if (r.distbits = 6, r.distcode = r.distdyn, S = { bits: r.distbits }, x = T(F, r.lens, r.nlen, r.ndist, r.distcode, 0, r.work, S), r.distbits = S.bits, x) { e.msg = "invalid distances set", r.mode = 30; break; } if (r.mode = 20, 6 === t) break e; case 20: r.mode = 21; case 21: if (6 <= o && 258 <= h) { e.next_out = a, e.avail_out = h, e.next_in = s, e.avail_in = o, r.hold = u, r.bits = l, R(e, c), a = e.next_out, i = e.output, h = e.avail_out, s = e.next_in, n = e.input, o = e.avail_in, u = r.hold, l = r.bits, 12 === r.mode && (r.back = -1); break; } for (r.back = 0; g = (C = r.lencode[u & (1 << r.lenbits) - 1]) >>> 16 & 255, b = 65535 & C, !((_ = C >>> 24) <= l);) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (g && 0 == (240 & g)) { for (v = _, y = g, w = b; g = (C = r.lencode[w + ((u & (1 << v + y) - 1) >> v)]) >>> 16 & 255, b = 65535 & C, !(v + (_ = C >>> 24) <= l);) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } u >>>= v, l -= v, r.back += v; } if (u >>>= _, l -= _, r.back += _, r.length = b, 0 === g) { r.mode = 26; break; } if (32 & g) { r.back = -1, r.mode = 12; break; } if (64 & g) { e.msg = "invalid literal/length code", r.mode = 30; break; } r.extra = 15 & g, r.mode = 22; case 22: if (r.extra) { for (z = r.extra; l < z;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } r.length += u & (1 << r.extra) - 1, u >>>= r.extra, l -= r.extra, r.back += r.extra; } r.was = r.length, r.mode = 23; case 23: for (; g = (C = r.distcode[u & (1 << r.distbits) - 1]) >>> 16 & 255, b = 65535 & C, !((_ = C >>> 24) <= l);) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (0 == (240 & g)) { for (v = _, y = g, w = b; g = (C = r.distcode[w + ((u & (1 << v + y) - 1) >> v)]) >>> 16 & 255, b = 65535 & C, !(v + (_ = C >>> 24) <= l);) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } u >>>= v, l -= v, r.back += v; } if (u >>>= _, l -= _, r.back += _, 64 & g) { e.msg = "invalid distance code", r.mode = 30; break; } r.offset = b, r.extra = 15 & g, r.mode = 24; case 24: if (r.extra) { for (z = r.extra; l < z;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } r.offset += u & (1 << r.extra) - 1, u >>>= r.extra, l -= r.extra, r.back += r.extra; } if (r.offset > r.dmax) { e.msg = "invalid distance too far back", r.mode = 30; break; } r.mode = 25; case 25: if (0 === h) break e; if (d = c - h, r.offset > d) { if ((d = r.offset - d) > r.whave && r.sane) { e.msg = "invalid distance too far back", r.mode = 30; break; } p = d > r.wnext ? (d -= r.wnext, r.wsize - d) : r.wnext - d, d > r.length && (d = r.length), m = r.window; } else m = i, p = a - r.offset, d = r.length; for (h < d && (d = h), h -= d, r.length -= d; i[a++] = m[p++], --d;); 0 === r.length && (r.mode = 21); break; case 26: if (0 === h) break e; i[a++] = r.length, h--, r.mode = 21; break; case 27: if (r.wrap) { for (; l < 32;) { if (0 === o) break e; o--, u |= n[s++] << l, l += 8; } if (c -= h, e.total_out += c, r.total += c, c && (e.adler = r.check = r.flags ? B(r.check, i, c, a - c) : O(r.check, i, c, a - c)), c = h, (r.flags ? u : L(u)) !== r.check) { e.msg = "incorrect data check", r.mode = 30; break; } l = u = 0; } r.mode = 28; case 28: if (r.wrap && r.flags) { for (; l < 32;) { if (0 === o) break e; o--, u += n[s++] << l, l += 8; } if (u !== (4294967295 & r.total)) { e.msg = "incorrect length check", r.mode = 30; break; } l = u = 0; } r.mode = 29; case 29: x = 1; break e; case 30: x = -3; break e; case 31: return -4; case 32: default: return U; } return e.next_out = a, e.avail_out = h, e.next_in = s, e.avail_in = o, r.hold = u, r.bits = l, (r.wsize || c !== e.avail_out && r.mode < 30 && (r.mode < 27 || 4 !== t)) && Z(e, e.output, e.next_out, c - e.avail_out) ? (r.mode = 31, -4) : (f -= e.avail_in, c -= e.avail_out, e.total_in += f, e.total_out += c, r.total += c, r.wrap && c && (e.adler = r.check = r.flags ? B(r.check, i, c, e.next_out - c) : O(r.check, i, c, e.next_out - c)), e.data_type = r.bits + (r.last ? 64 : 0) + (12 === r.mode ? 128 : 0) + (20 === r.mode || 15 === r.mode ? 256 : 0), (0 == f && 0 === c || 4 === t) && x === N && (x = -5), x); }, r.inflateEnd = function(e) { if (!e || !e.state) return U; var t = e.state; return t.window && (t.window = null), e.state = null, N; }, r.inflateGetHeader = function(e, t) { var r; return e && e.state ? 0 == (2 & (r = e.state).wrap) ? U : ((r.head = t).done = !1, N) : U; }, r.inflateSetDictionary = function(e, t) { var r, n = t.length; return e && e.state ? 0 !== (r = e.state).wrap && 11 !== r.mode ? U : 11 === r.mode && O(1, t, n, 0) !== r.check ? -3 : Z(e, t, n, n) ? (r.mode = 31, -4) : (r.havedict = 1, N) : U; }, r.inflateInfo = "pako inflate (from Nodeca project)"; }, { "../utils/common": 41, "./adler32": 43, "./crc32": 45, "./inffast": 48, "./inftrees": 50 }], 50: [function(e, t, r) { "use strict"; var D = e("../utils/common"), F = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ], N = [ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78 ], U = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0 ], P = [ 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64 ]; t.exports = function(e, t, r, n, i, s, a, o) { var h, u, l, f, c, d, p, m, _, g = o.bits, b = 0, v = 0, y = 0, w = 0, k = 0, x = 0, S = 0, z = 0, C = 0, E = 0, A = null, I = 0, O = new D.Buf16(16), B = new D.Buf16(16), R = null, T = 0; for (b = 0; b <= 15; b++) O[b] = 0; for (v = 0; v < n; v++) O[t[r + v]]++; for (k = g, w = 15; 1 <= w && 0 === O[w]; w--); if (w < k && (k = w), 0 === w) return i[s++] = 20971520, i[s++] = 20971520, o.bits = 1, 0; for (y = 1; y < w && 0 === O[y]; y++); for (k < y && (k = y), b = z = 1; b <= 15; b++) if (z <<= 1, (z -= O[b]) < 0) return -1; if (0 < z && (0 === e || 1 !== w)) return -1; for (B[1] = 0, b = 1; b < 15; b++) B[b + 1] = B[b] + O[b]; for (v = 0; v < n; v++) 0 !== t[r + v] && (a[B[t[r + v]]++] = v); if (d = 0 === e ? (A = R = a, 19) : 1 === e ? (A = F, I -= 257, R = N, T -= 257, 256) : (A = U, R = P, -1), b = y, c = s, S = v = E = 0, l = -1, f = (C = 1 << (x = k)) - 1, 1 === e && 852 < C || 2 === e && 592 < C) return 1; for (;;) { for (p = b - S, _ = a[v] < d ? (m = 0, a[v]) : a[v] > d ? (m = R[T + a[v]], A[I + a[v]]) : (m = 96, 0), h = 1 << b - S, y = u = 1 << x; i[c + (E >> S) + (u -= h)] = p << 24 | m << 16 | _ | 0, 0 !== u;); for (h = 1 << b - 1; E & h;) h >>= 1; if (0 !== h ? (E &= h - 1, E += h) : E = 0, v++, 0 == --O[b]) { if (b === w) break; b = t[r + a[v]]; } if (k < b && (E & f) !== l) { for (0 === S && (S = k), c += y, z = 1 << (x = b - S); x + S < w && !((z -= O[x + S]) <= 0);) x++, z <<= 1; if (C += 1 << x, 1 === e && 852 < C || 2 === e && 592 < C) return 1; i[l = E & f] = k << 24 | x << 16 | c - s | 0; } } return 0 !== E && (i[c + E] = b - S << 24 | 4194304), o.bits = k, 0; }; }, { "../utils/common": 41 }], 51: [function(e, t, r) { "use strict"; t.exports = { 2: "need dictionary", 1: "stream end", 0: "", "-1": "file error", "-2": "stream error", "-3": "data error", "-4": "insufficient memory", "-5": "buffer error", "-6": "incompatible version" }; }, {}], 52: [function(e, t, r) { "use strict"; var i = e("../utils/common"), o = 0, h = 1; function n(e) { for (var t = e.length; 0 <= --t;) e[t] = 0; } var s = 0, a = 29, u = 256, l = u + 1 + a, f = 30, c = 19, _ = 2 * l + 1, g = 15, d = 16, p = 7, m = 256, b = 16, v = 17, y = 18, w = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 ], k = [ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ], x = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7 ], S = [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ], z = new Array(2 * (l + 2)); n(z); var C = new Array(2 * f); n(C); var E = new Array(512); n(E); var A = new Array(256); n(A); var I = new Array(a); n(I); var O, B, R, T = new Array(f); function D(e, t, r, n, i) { this.static_tree = e, this.extra_bits = t, this.extra_base = r, this.elems = n, this.max_length = i, this.has_stree = e && e.length; } function F(e, t) { this.dyn_tree = e, this.max_code = 0, this.stat_desc = t; } function N(e) { return e < 256 ? E[e] : E[256 + (e >>> 7)]; } function U(e, t) { e.pending_buf[e.pending++] = 255 & t, e.pending_buf[e.pending++] = t >>> 8 & 255; } function P(e, t, r) { e.bi_valid > d - r ? (e.bi_buf |= t << e.bi_valid & 65535, U(e, e.bi_buf), e.bi_buf = t >> d - e.bi_valid, e.bi_valid += r - d) : (e.bi_buf |= t << e.bi_valid & 65535, e.bi_valid += r); } function L(e, t, r) { P(e, r[2 * t], r[2 * t + 1]); } function j(e, t) { for (var r = 0; r |= 1 & e, e >>>= 1, r <<= 1, 0 < --t;); return r >>> 1; } function Z(e, t, r) { var n, i, s = new Array(g + 1), a = 0; for (n = 1; n <= g; n++) s[n] = a = a + r[n - 1] << 1; for (i = 0; i <= t; i++) { var o = e[2 * i + 1]; 0 !== o && (e[2 * i] = j(s[o]++, o)); } } function W(e) { var t; for (t = 0; t < l; t++) e.dyn_ltree[2 * t] = 0; for (t = 0; t < f; t++) e.dyn_dtree[2 * t] = 0; for (t = 0; t < c; t++) e.bl_tree[2 * t] = 0; e.dyn_ltree[2 * m] = 1, e.opt_len = e.static_len = 0, e.last_lit = e.matches = 0; } function M(e) { 8 < e.bi_valid ? U(e, e.bi_buf) : 0 < e.bi_valid && (e.pending_buf[e.pending++] = e.bi_buf), e.bi_buf = 0, e.bi_valid = 0; } function H(e, t, r, n) { var i = 2 * t, s = 2 * r; return e[i] < e[s] || e[i] === e[s] && n[t] <= n[r]; } function G(e, t, r) { for (var n = e.heap[r], i = r << 1; i <= e.heap_len && (i < e.heap_len && H(t, e.heap[i + 1], e.heap[i], e.depth) && i++, !H(t, n, e.heap[i], e.depth));) e.heap[r] = e.heap[i], r = i, i <<= 1; e.heap[r] = n; } function K(e, t, r) { var n, i, s, a, o = 0; if (0 !== e.last_lit) for (; n = e.pending_buf[e.d_buf + 2 * o] << 8 | e.pending_buf[e.d_buf + 2 * o + 1], i = e.pending_buf[e.l_buf + o], o++, 0 === n ? L(e, i, t) : (L(e, (s = A[i]) + u + 1, t), 0 !== (a = w[s]) && P(e, i -= I[s], a), L(e, s = N(--n), r), 0 !== (a = k[s]) && P(e, n -= T[s], a)), o < e.last_lit;); L(e, m, t); } function Y(e, t) { var r, n, i, s = t.dyn_tree, a = t.stat_desc.static_tree, o = t.stat_desc.has_stree, h = t.stat_desc.elems, u = -1; for (e.heap_len = 0, e.heap_max = _, r = 0; r < h; r++) 0 !== s[2 * r] ? (e.heap[++e.heap_len] = u = r, e.depth[r] = 0) : s[2 * r + 1] = 0; for (; e.heap_len < 2;) s[2 * (i = e.heap[++e.heap_len] = u < 2 ? ++u : 0)] = 1, e.depth[i] = 0, e.opt_len--, o && (e.static_len -= a[2 * i + 1]); for (t.max_code = u, r = e.heap_len >> 1; 1 <= r; r--) G(e, s, r); for (i = h; r = e.heap[1], e.heap[1] = e.heap[e.heap_len--], G(e, s, 1), n = e.heap[1], e.heap[--e.heap_max] = r, e.heap[--e.heap_max] = n, s[2 * i] = s[2 * r] + s[2 * n], e.depth[i] = (e.depth[r] >= e.depth[n] ? e.depth[r] : e.depth[n]) + 1, s[2 * r + 1] = s[2 * n + 1] = i, e.heap[1] = i++, G(e, s, 1), 2 <= e.heap_len;); e.heap[--e.heap_max] = e.heap[1], function(e, t) { var r, n, i, s, a, o, h = t.dyn_tree, u = t.max_code, l = t.stat_desc.static_tree, f = t.stat_desc.has_stree, c = t.stat_desc.extra_bits, d = t.stat_desc.extra_base, p = t.stat_desc.max_length, m = 0; for (s = 0; s <= g; s++) e.bl_count[s] = 0; for (h[2 * e.heap[e.heap_max] + 1] = 0, r = e.heap_max + 1; r < _; r++) p < (s = h[2 * h[2 * (n = e.heap[r]) + 1] + 1] + 1) && (s = p, m++), h[2 * n + 1] = s, u < n || (e.bl_count[s]++, a = 0, d <= n && (a = c[n - d]), o = h[2 * n], e.opt_len += o * (s + a), f && (e.static_len += o * (l[2 * n + 1] + a))); if (0 !== m) { do { for (s = p - 1; 0 === e.bl_count[s];) s--; e.bl_count[s]--, e.bl_count[s + 1] += 2, e.bl_count[p]--, m -= 2; } while (0 < m); for (s = p; 0 !== s; s--) for (n = e.bl_count[s]; 0 !== n;) u < (i = e.heap[--r]) || (h[2 * i + 1] !== s && (e.opt_len += (s - h[2 * i + 1]) * h[2 * i], h[2 * i + 1] = s), n--); } }(e, t), Z(s, u, e.bl_count); } function X(e, t, r) { var n, i, s = -1, a = t[1], o = 0, h = 7, u = 4; for (0 === a && (h = 138, u = 3), t[2 * (r + 1) + 1] = 65535, n = 0; n <= r; n++) i = a, a = t[2 * (n + 1) + 1], ++o < h && i === a || (o < u ? e.bl_tree[2 * i] += o : 0 !== i ? (i !== s && e.bl_tree[2 * i]++, e.bl_tree[2 * b]++) : o <= 10 ? e.bl_tree[2 * v]++ : e.bl_tree[2 * y]++, s = i, u = (o = 0) === a ? (h = 138, 3) : i === a ? (h = 6, 3) : (h = 7, 4)); } function V(e, t, r) { var n, i, s = -1, a = t[1], o = 0, h = 7, u = 4; for (0 === a && (h = 138, u = 3), n = 0; n <= r; n++) if (i = a, a = t[2 * (n + 1) + 1], !(++o < h && i === a)) { if (o < u) for (; L(e, i, e.bl_tree), 0 != --o;); else 0 !== i ? (i !== s && (L(e, i, e.bl_tree), o--), L(e, b, e.bl_tree), P(e, o - 3, 2)) : o <= 10 ? (L(e, v, e.bl_tree), P(e, o - 3, 3)) : (L(e, y, e.bl_tree), P(e, o - 11, 7)); s = i, u = (o = 0) === a ? (h = 138, 3) : i === a ? (h = 6, 3) : (h = 7, 4); } } n(T); var q = !1; function J(e, t, r, n) { P(e, (s << 1) + (n ? 1 : 0), 3), function(e, t, r, n) { M(e), n && (U(e, r), U(e, ~r)), i.arraySet(e.pending_buf, e.window, t, r, e.pending), e.pending += r; }(e, t, r, !0); } r._tr_init = function(e) { q || (function() { var e, t, r, n, i, s = new Array(g + 1); for (n = r = 0; n < a - 1; n++) for (I[n] = r, e = 0; e < 1 << w[n]; e++) A[r++] = n; for (A[r - 1] = n, n = i = 0; n < 16; n++) for (T[n] = i, e = 0; e < 1 << k[n]; e++) E[i++] = n; for (i >>= 7; n < f; n++) for (T[n] = i << 7, e = 0; e < 1 << k[n] - 7; e++) E[256 + i++] = n; for (t = 0; t <= g; t++) s[t] = 0; for (e = 0; e <= 143;) z[2 * e + 1] = 8, e++, s[8]++; for (; e <= 255;) z[2 * e + 1] = 9, e++, s[9]++; for (; e <= 279;) z[2 * e + 1] = 7, e++, s[7]++; for (; e <= 287;) z[2 * e + 1] = 8, e++, s[8]++; for (Z(z, l + 1, s), e = 0; e < f; e++) C[2 * e + 1] = 5, C[2 * e] = j(e, 5); O = new D(z, w, u + 1, l, g), B = new D(C, k, 0, f, g), R = new D(new Array(0), x, 0, c, p); }(), q = !0), e.l_desc = new F(e.dyn_ltree, O), e.d_desc = new F(e.dyn_dtree, B), e.bl_desc = new F(e.bl_tree, R), e.bi_buf = 0, e.bi_valid = 0, W(e); }, r._tr_stored_block = J, r._tr_flush_block = function(e, t, r, n) { var i, s, a = 0; 0 < e.level ? (2 === e.strm.data_type && (e.strm.data_type = function(e) { var t, r = 4093624447; for (t = 0; t <= 31; t++, r >>>= 1) if (1 & r && 0 !== e.dyn_ltree[2 * t]) return o; if (0 !== e.dyn_ltree[18] || 0 !== e.dyn_ltree[20] || 0 !== e.dyn_ltree[26]) return h; for (t = 32; t < u; t++) if (0 !== e.dyn_ltree[2 * t]) return h; return o; }(e)), Y(e, e.l_desc), Y(e, e.d_desc), a = function(e) { var t; for (X(e, e.dyn_ltree, e.l_desc.max_code), X(e, e.dyn_dtree, e.d_desc.max_code), Y(e, e.bl_desc), t = c - 1; 3 <= t && 0 === e.bl_tree[2 * S[t] + 1]; t--); return e.opt_len += 3 * (t + 1) + 5 + 5 + 4, t; }(e), i = e.opt_len + 3 + 7 >>> 3, (s = e.static_len + 3 + 7 >>> 3) <= i && (i = s)) : i = s = r + 5, r + 4 <= i && -1 !== t ? J(e, t, r, n) : 4 === e.strategy || s === i ? (P(e, 2 + (n ? 1 : 0), 3), K(e, z, C)) : (P(e, 4 + (n ? 1 : 0), 3), function(e, t, r, n) { var i; for (P(e, t - 257, 5), P(e, r - 1, 5), P(e, n - 4, 4), i = 0; i < n; i++) P(e, e.bl_tree[2 * S[i] + 1], 3); V(e, e.dyn_ltree, t - 1), V(e, e.dyn_dtree, r - 1); }(e, e.l_desc.max_code + 1, e.d_desc.max_code + 1, a + 1), K(e, e.dyn_ltree, e.dyn_dtree)), W(e), n && M(e); }, r._tr_tally = function(e, t, r) { return e.pending_buf[e.d_buf + 2 * e.last_lit] = t >>> 8 & 255, e.pending_buf[e.d_buf + 2 * e.last_lit + 1] = 255 & t, e.pending_buf[e.l_buf + e.last_lit] = 255 & r, e.last_lit++, 0 === t ? e.dyn_ltree[2 * r]++ : (e.matches++, t--, e.dyn_ltree[2 * (A[r] + u + 1)]++, e.dyn_dtree[2 * N(t)]++), e.last_lit === e.lit_bufsize - 1; }, r._tr_align = function(e) { P(e, 2, 3), L(e, m, z), function(e) { 16 === e.bi_valid ? (U(e, e.bi_buf), e.bi_buf = 0, e.bi_valid = 0) : 8 <= e.bi_valid && (e.pending_buf[e.pending++] = 255 & e.bi_buf, e.bi_buf >>= 8, e.bi_valid -= 8); }(e); }; }, { "../utils/common": 41 }], 53: [function(e, t, r) { "use strict"; t.exports = function() { this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0; }; }, {}], 54: [function(e, t, r) { (function(e) { (function(r, n) { "use strict"; if (!r.setImmediate) { var i, s, t, a, o = 1, h = {}, u = !1, l = r.document, e = Object.getPrototypeOf && Object.getPrototypeOf(r); e = e && e.setTimeout ? e : r, i = "[object process]" === {}.toString.call(r.process) ? function(e) { process.nextTick(function() { c(e); }); } : function() { if (r.postMessage && !r.importScripts) { var e = !0, t = r.onmessage; return r.onmessage = function() { e = !1; }, r.postMessage("", "*"), r.onmessage = t, e; } }() ? (a = "setImmediate$" + Math.random() + "$", r.addEventListener ? r.addEventListener("message", d, !1) : r.attachEvent("onmessage", d), function(e) { r.postMessage(a + e, "*"); }) : r.MessageChannel ? ((t = new MessageChannel()).port1.onmessage = function(e) { c(e.data); }, function(e) { t.port2.postMessage(e); }) : l && "onreadystatechange" in l.createElement("script") ? (s = l.documentElement, function(e) { var t = l.createElement("script"); t.onreadystatechange = function() { c(e), t.onreadystatechange = null, s.removeChild(t), t = null; }, s.appendChild(t); }) : function(e) { setTimeout(c, 0, e); }, e.setImmediate = function(e) { "function" != typeof e && (e = new Function("" + e)); for (var t = new Array(arguments.length - 1), r = 0; r < t.length; r++) t[r] = arguments[r + 1]; return h[o] = { callback: e, args: t }, i(o), o++; }, e.clearImmediate = f; } function f(e) { delete h[e]; } function c(e) { if (u) setTimeout(c, 0, e); else { var t = h[e]; if (t) { u = !0; try { (function(e) { var t = e.callback, r = e.args; switch (r.length) { case 0: t(); break; case 1: t(r[0]); break; case 2: t(r[0], r[1]); break; case 3: t(r[0], r[1], r[2]); break; default: t.apply(n, r); } })(t); } finally { f(e), u = !1; } } } } function d(e) { e.source === r && "string" == typeof e.data && 0 === e.data.indexOf(a) && c(+e.data.slice(a.length)); } })("undefined" == typeof self ? void 0 === e ? this : e : self); }).call(this, "undefined" != typeof global ? global : "undefined" != typeof self ? self : "undefined" != typeof window ? window : {}); }, {}] }, {}, [10])(10); }); })))(), 1); /** * Generates a SHA-256 hash from a file blob. * * @param {Blob} fileBlob - The file blob to hash * @returns {Promise} - Returns a Promise that resolves to the hexadecimal hash string */ async function generateFileHash(fileBlob) { return sha256Hex(await fileBlob.arrayBuffer()); } /** * Hex-encodes the SHA-256 digest of an already-in-memory buffer. */ async function sha256Hex(buffer) { const hashBuffer = await crypto.subtle.digest("SHA-256", buffer); return Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join(""); } async function canUserUpload(currentUploadSize) { const { active, limit } = await trpc.getTotalUsedStorage.query(); return active + currentUploadSize >= limit; } /** * Returns a promise that resolves after an amount of time has passed. * * @param { number } delayMs - number of milliseconds that must pass before the promise resolves */ function delay(delayMs = 100) { return new Promise((resolve) => setTimeout(resolve, delayMs)); } /** * Runs a function at an interval until it succeeds or the maximum wait time is reached. * * @param {function(): any} fn - The function to retry. Function can be `async`. * @param {number} waitTimeMs - How long to wait between each retry. * @param {number} maxWaitTimeMs - The maximum amount of time to retry until we give up. */ async function retryUntilSuccessOrTimeout(fn, waitTimeMs = 1e3, maxWaitTimeMs = 6e4) { for (let waitTotalMs = 0; waitTotalMs < maxWaitTimeMs; waitTotalMs += waitTimeMs) { await delay(waitTimeMs); try { if (!!await fn()) return; } catch (e) { console.error(`Error on waiting for the file to show up in storage: ${e}`); } } } async function streamToArrayBuffer(stream, size) { const reader = stream.getReader(); let state = await reader.read(); if (size) { const result = new Uint8Array(size); let offset = 0; while (!state.done) { result.set(state.value, offset); offset += state.value.length; state = await reader.read(); } return result.buffer; } const parts = []; let len = 0; while (!state.done) { parts.push(state.value); len += state.value.length; state = await reader.read(); } let offset = 0; const result = new Uint8Array(len); for (const part of parts) { result.set(part, offset); offset += part.length; } return result.buffer; } var ConnectionError = class extends Error { constructor(canceled, duration, size) { super(canceled ? "0" : "connection closed"); this.canceled = canceled; this.duration = duration; this.size = size; } }; function asyncInitWebSocket(serverUrl) { return new Promise((resolve, reject) => { try { const ws = new WebSocket(serverUrl); ws.addEventListener("open", () => resolve(ws), { once: true }); } catch (e) { reject(new ConnectionError(false)); } }); } async function listenForResponse(ws, canceler) { return new Promise((resolve, reject) => { function handleClose() { ws.removeEventListener("message", handleMessage); reject(new ConnectionError(canceler.canceled)); } function handleMessage(msg) { ws.removeEventListener("close", handleClose); try { const response = JSON.parse(msg.data); if (response.error) throw new Error(response.error); else resolve(response); } catch (e) { reject(e); } } ws.addEventListener("message", handleMessage, { once: true }); ws.addEventListener("close", handleClose, { once: true }); }); } /** * Zips `blob` under `filename` and returns the archive as a Blob. * * Why this is not just `zip.generateAsync({ type: 'blob' })`: * JSZip's one-shot blob output builds the entire archive as a single * `Uint8Array` and then calls `new Blob([thatArray])`. Firefox rejects any * single ArrayBuffer/ArrayBufferView Blob member larger than 2 GB with * "can't construct the Blob ... larger than 2 GB" — so zipping a file bigger * than ~2 GB (e.g. a typeless file wrapped by {@link formatBlob}) throws before * a single byte is uploaded (#981). Note this is a hard per-member limit, not an * out-of-memory condition: the same Firefox happily allocates a 6 GiB * ArrayBuffer, but refuses a >2 GB Blob member. * * Instead we consume JSZip's streaming output and hand the (individually * sub-2 GB) chunks to the Blob constructor as separate members. A Blob's *total* * size may exceed 2 GB as long as no single member does, so the archive can be * arbitrarily large. * * Backwards compatibility: `generateAsync` is itself implemented on top of this * same internal stream with the same default settings (STORE, no compression), * so the archive bytes are identical to the previous implementation. Files * zipped before and after this change are byte-for-byte interchangeable and the * download/unzip path is unaffected — this only changes how the output Blob is * assembled in memory, not its contents. */ async function zipBlob(blob, filename) { const zip = new import_jszip_min.default(); zip.file(filename, blob); const chunks = []; await new Promise((resolve, reject) => { zip.generateInternalStream({ type: "uint8array" }).on("data", (chunk) => chunks.push(chunk)).on("error", reject).on("end", () => resolve()).resume(); }); return new Blob(chunks, { type: "application/zip" }); } async function unzipMultipartPiece(arrayBuffer) { try { const zip = new import_jszip_min.default(); const buffer = arrayBuffer instanceof ArrayBuffer ? arrayBuffer : new ArrayBuffer(arrayBuffer.byteLength); if (!(arrayBuffer instanceof ArrayBuffer)) new Uint8Array(buffer).set(new Uint8Array(arrayBuffer)); const zipData = await zip.loadAsync(buffer); const fileNames = Object.keys(zipData.files); if (fileNames.length === 0) throw new Error("No files found in zip archive"); const targetFileName = fileNames[0]; const isMultipart = false; const file = zipData.files[targetFileName]; if (file.dir) throw new Error("Expected file but found directory in zip archive"); return { content: await file.async("arraybuffer"), isMultipart, partNumber: void 0 }; } catch (error) { console.error("Error unzipping multipart content:", error); const buffer = arrayBuffer instanceof ArrayBuffer ? arrayBuffer : new ArrayBuffer(arrayBuffer.byteLength); if (!(arrayBuffer instanceof ArrayBuffer)) new Uint8Array(buffer).set(new Uint8Array(arrayBuffer)); return { content: buffer, isMultipart: false }; } } var formatBlob = async (blob) => { if (blob.type === "") { const zippedBlob = await zipBlob(blob, blob.name); const compressedBlob = new Blob([zippedBlob], { type: "application/zip" }); compressedBlob.name = `${blob.name}.zip`; return compressedBlob; } return blob; }; /** * Checks a precomputed file hash against the suspicious-files list and blocks * the upload (alert + throw) if it matches. */ var assertNotSuspicious = async (api, fileHash) => { const { isSuspicious } = await api.call(`uploads/check-upload-hash/${fileHash}`); if (isSuspicious) { alert("Warning: This file has been reported as suspicious. You cannot upload it. If you believe this is an error, please contact support."); throw new Error("Suspicious file detected"); } }; var hashAndCheck = async (api, fileBlob) => { const fileHash = await generateFileHash(fileBlob); console.log("File hash (SHA-256):", fileHash); await assertNotSuspicious(api, fileHash); return fileHash; }; var hashFiles = async (api, fileBlob, maxSize, onProgress) => { const hashFromChunk = []; if (fileBlob.size <= maxSize) { const hashedBlob = await hashAndCheck(api, fileBlob); onProgress?.(1, 1); return [hashedBlob]; } const totalSize = fileBlob.size; const numChunks = Math.ceil(totalSize / maxSize); for (let i = 0; i < numChunks; i++) { const start = i * maxSize; const end = Math.min(start + maxSize, totalSize); const chunk = fileBlob.slice(start, end); const chunkBlob = new Blob([chunk], { type: fileBlob.type }); chunkBlob.name = `${fileBlob.name}`; const zippedChunk = await hashAndCheck(api, chunkBlob); hashFromChunk.push(zippedChunk); onProgress?.(i + 1, numChunks); } return hashFromChunk; }; /** * Streams a large file into upload-ready parts, one `maxSize` window at a time. * * Crucially, it reads the file **sequentially from offset 0 via * `fileBlob.stream()`** and never calls `.slice()`/`.arrayBuffer()` at a high * byte offset. The previous approach (hashFiles + splitIntoMultipleZips) sliced * the file at offsets past ~2 GiB, which Firefox rejects with a NotReadableError * / "can't construct the Blob" on files larger than ~2 GB (#981). Reading via a * ReadableStream keeps each in-memory buffer bounded to one window and avoids * the 2^31 offset boundary entirely. * * Parts are yielded **in order as they become ready**, so a caller can begin * uploading window 0 while later windows are still being read/hashed/zipped * (#980). * * For each window it hashes the raw bytes, runs the suspicious-file check, then * zips the window — producing the exact same wire format as * splitIntoMultipleZips (a zip of the raw chunk, named after the original file). */ async function* streamZippedParts(api, fileBlob, maxSize, onBytesHashed) { const reader = fileBlob.stream().getReader(); let windowChunks = []; let windowSize = 0; let totalHashed = 0; const flushWindow = async () => { const windowBytes = new Uint8Array(windowSize); let offset = 0; for (const piece of windowChunks) { windowBytes.set(piece, offset); offset += piece.byteLength; } windowChunks = []; windowSize = 0; const hash = await sha256Hex(windowBytes.buffer); await assertNotSuspicious(api, hash); const rawBlob = new Blob([windowBytes], { type: fileBlob.type }); rawBlob.name = fileBlob.name; const zipped = await zipBlob(rawBlob, fileBlob.name); const zippedBlob = new Blob([zipped], { type: "application/zip" }); zippedBlob.name = fileBlob.name; return { blob: zippedBlob, hash }; }; try { while (true) { const { done, value } = await reader.read(); if (done) break; let chunk = value; while (windowSize + chunk.byteLength >= maxSize) { const take = maxSize - windowSize; windowChunks.push(chunk.subarray(0, take)); windowSize += take; totalHashed += take; onBytesHashed?.(totalHashed); yield await flushWindow(); chunk = chunk.subarray(take); } if (chunk.byteLength > 0) { windowChunks.push(chunk); windowSize += chunk.byteLength; } } if (windowSize > 0) { totalHashed += windowSize; onBytesHashed?.(totalHashed); yield await flushWindow(); } } finally { reader.releaseLock(); } } var checkBlobSize = async (blob) => { console.log(blob); if (blob.size > 2e10) { console.warn("File too big"); return false; } return true; }; //#endregion //#region ../send/frontend/src/lib/helpers.ts async function _download({ url, progressTracker, id }) { const endpoint = `https://send-backend.tb.pro/api/download`; const xhr = new XMLHttpRequest(); const { setProgress } = progressTracker; xhr.onprogress = (event) => { if (event.lengthComputable) { const downloadProgress = event.loaded; setProgress(downloadProgress); } }; return new Promise((resolve, reject) => { xhr.addEventListener("loadend", async function() { if (xhr.status !== 200) return reject(/* @__PURE__ */ new Error(`${xhr.status}`)); resolve(new Blob([xhr.response])); }); xhr.open("get", id ? `${endpoint}/${id}` : url); xhr.responseType = "blob"; xhr.send(); }); } async function _upload(stream, key, encryptedSize = -1, { canceler = {}, progressTracker }) { let host = "https://send-backend.tb.pro"; if (host) host = host.split("//")[1]; else throw new Error("no server url is set"); const ws = await asyncInitWebSocket(`wss://${host}/api/ws`); try { const fileMeta = { name: "filename", size: encryptedSize }; listenForResponse(ws, canceler); ws.send(JSON.stringify(fileMeta)); let size = 0; const completedResponse = listenForResponse(ws, canceler); if (key) stream = encryptStream(stream, key); const reader = stream.getReader(); let state = await reader.read(); while (!state.done) { if (canceler.cancelled) ws.close(); if (ws.readyState !== WebSocket.OPEN) break; const buf = state.value; ws.send(buf); size += buf.length; console.info("Uploaded", size, "bytes", "- timestamp:", Date.now()); progressTracker.setProgress(size); state = await reader.read(); while (ws.bufferedAmount > 65536 * 2 && ws.readyState === WebSocket.OPEN && !canceler.cancelled) await delay(); } if (ws.readyState === WebSocket.OPEN) ws.send(new Uint8Array([0])); return await completedResponse; } catch (e) { console.error(e); throw e; } finally { if (ws.readyState !== WebSocket.CLOSED && ws.readyState !== WebSocket.CLOSING) ws.close(); } } async function encrypt(stream, key) { try { let size = 0; const chunks = []; if (key) stream = encryptStream(stream, key); const reader = stream.getReader(); let state = await reader.read(); while (!state.done) { const buf = state.value; chunks.push(buf); size += buf.length; console.info("Encrypted", size, "bytes", "- timestamp:", Date.now()); state = await reader.read(); } return concatenateUint8Arrays(chunks); } catch (e) { console.error(e); } } function concatenateUint8Arrays(arrays) { const totalLength = arrays.reduce((acc, value) => acc + value.length, 0); const result = new Uint8Array(totalLength); let length = 0; for (const array of arrays) { result.set(array, length); length += array.length; } return result; } /** * Calculates the size of a file after encrypting. * * @param originalSize: number - the original file size. * @param recordSize: number - the size of each chunk of data that gets encrypted. * @returns number - the total size of the file after encryption. */ function calculateEncryptedSize(originalSize, recordSize = ECE_RECORD_SIZE) { const chunkSize = recordSize - 17; return originalSize + Math.ceil(originalSize / chunkSize) * 17 + 21; } async function dbUserSetup(userStore, keychain, folderStore) { if (!await userStore.populateFromBackend()) return; await userStore.store(); if (!await userStore.getPublicKey()) { await keychain.rsa.generateKeyPair(); await keychain.store(); const jwkPublicKey = await keychain.rsa.getPublicKeyJwk(); if (!await userStore.updatePublicKey(jwkPublicKey)) console.warn(`DEBUG: could not update user's public key`); } const initResult = await init(userStore, keychain, folderStore); if (initResult !== INIT_ERRORS.NONE) console.error(`User setup incomplete — init() returned error: ${Object.keys(INIT_ERRORS)[initResult]}`); } var UPLOAD_ABORTED = "UPLOAD_ABORTED"; var UPLOAD_HTTP_RETRY_BASE_DELAY_MS = 1e3; /** * Exponential backoff with jitter for the upload PUT retry schedule: * delay = base * 2^attempt * (0.5 + Math.random() / 2) * The jitter factor is in [0.5, 1.0), so with the default 1000ms base the * per-attempt delays grow roughly ~1s, ~2s, ~4s while staying de-synchronized * across clients (avoids a thundering herd when B2 recovers). * * @param attempt - zero-based index of the attempt that just failed * @param baseDelayMs - base delay; defaults to UPLOAD_HTTP_RETRY_BASE_DELAY_MS */ function getUploadRetryDelayMs(attempt, baseDelayMs = UPLOAD_HTTP_RETRY_BASE_DELAY_MS) { const exponential = baseDelayMs * 2 ** attempt; const jitter = .5 + Math.random() / 2; return Math.floor(exponential * jitter); } var uploadWithTracker = ({ url, readableStream, progressTracker, signal }) => { const { setProgress } = progressTracker; const XHR_TIMEOUT_MS = 18e4; const attemptPut = (blob, attempt) => { if (signal?.aborted) return Promise.reject(/* @__PURE__ */ new Error(UPLOAD_ABORTED)); if (attempt > 0) setProgress(0); return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.open("PUT", url, true); xhr.setRequestHeader("Content-Type", "application/octet-stream"); xhr.timeout = XHR_TIMEOUT_MS; const onAbort = () => xhr.abort(); signal?.addEventListener("abort", onAbort, { once: true }); const cleanup = () => signal?.removeEventListener("abort", onAbort); xhr.upload.onprogress = (event) => { if (event.lengthComputable) { const uploadProgress = event.loaded; setProgress(uploadProgress); } }; xhr.onload = () => { cleanup(); if (xhr.status >= 200 && xhr.status < 300) resolve(xhr.response); else { console.error("Upload failed:"); reject(/* @__PURE__ */ new Error("UPLOAD_FAILED")); } }; xhr.onabort = () => { cleanup(); reject(/* @__PURE__ */ new Error(UPLOAD_ABORTED)); }; xhr.onerror = () => { cleanup(); reject(/* @__PURE__ */ new Error("XHR: UPLOAD_FAILED")); }; xhr.ontimeout = () => { cleanup(); reject(/* @__PURE__ */ new Error(`Upload timed out after ${XHR_TIMEOUT_MS / 1e3}s`)); }; xhr.send(blob); }).catch((error) => { if (!(signal?.aborted || error?.message === "UPLOAD_ABORTED") && attempt < 3) { const delayMs = getUploadRetryDelayMs(attempt); console.warn(`HTTP PUT attempt ${attempt + 1} failed, retrying in ${delayMs}ms...`, error.message); return new Promise((resolve) => setTimeout(resolve, delayMs)).then(() => attemptPut(blob, attempt + 1)); } throw error; }); }; return new Response(readableStream).blob().then((uploadBlob) => { return attemptPut(uploadBlob, 0); }); }; //#endregion //#region ../send/frontend/src/lib/filesync.ts async function _saveFile(file) { return new Promise(function(resolve) { const dataView = new DataView(file.plaintext); const blob = new Blob([dataView], { type: file.type }); const downloadUrl = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = downloadUrl; a.download = file.name; document.body.appendChild(a); a.click(); setTimeout(() => { document.body.removeChild(a); window.URL.revokeObjectURL(downloadUrl); resolve(); }, 0); }); } async function getBlob(id, size, key, isBucketStorage = true, filename = "dummy.file", type = "text/plain", api, progressTracker) { const { isSuspicious } = await api.call(`download/check-upload-id/${id}`); if (isSuspicious) throw new Error("File has been reported as suspicious"); if (!isBucketStorage) { const downloadedBlob = await _download({ id, progressTracker }); let plaintext; if (key) plaintext = await streamToArrayBuffer(decryptStream(blobStream(downloadedBlob), key), size); else plaintext = await downloadedBlob.arrayBuffer(); return await _saveFile({ plaintext, name: decodeURIComponent(filename), type }); } try { const bucketResponse = await api.call(`download/${id}/signed`); if (!bucketResponse?.url) throw new Error("BUCKET_URL_NOT_FOUND"); progressTracker.setUploadSize(size); progressTracker.setText("Downloading file"); const downloadedBlob = await _download({ url: bucketResponse.url, progressTracker }); let plaintext; if (key) plaintext = await streamToArrayBuffer(decryptStream(blobStream(downloadedBlob), key), size); else plaintext = await downloadedBlob.arrayBuffer(); return await _saveFile({ plaintext, name: decodeURIComponent(filename), type }); } catch (error) { console.error("DOWNLOAD_FAILED", error); throw error; } } async function sendBlob(blob, aesKey, api, progressTracker, isBucketStorage = true, options = {}) { const { signal, onUploadId } = options; const stream = blobStream(blob); if (!isBucketStorage) { const result = await _upload(stream, aesKey, calculateEncryptedSize(blob.size), { progressTracker }); const id = Array.isArray(result) ? result[0].id : result.id; onUploadId?.(id); return id; } try { const { id, url } = await api.call("uploads/signed", { type: "application/octet-stream" }, "POST"); onUploadId?.(id); progressTracker.setProcessStage("encrypting"); progressTracker.setText("Encrypting file"); const encrypted = await encrypt(stream, aesKey); progressTracker.setProcessStage("uploading"); progressTracker.setText("Uploading file"); await uploadWithTracker({ url, readableStream: new ReadableStream({ start(controller) { controller.enqueue(encrypted); controller.close(); } }), progressTracker, signal }); return id; } catch (error) { throw new Error("UPLOAD_FAILED", { cause: error }); } } async function _saveFileStream(file) { if ("showSaveFilePicker" in window) try { const writable = await (await window.showSaveFilePicker({ suggestedName: file.name, types: [{ description: file.type, accept: { [file.type]: [] } }] })).createWritable(); const reader = file.stream.getReader(); while (true) { const { done, value } = await reader.read(); if (done) break; await writable.write(value); } await writable.close(); return; } catch (error) { console.warn("File System Access API failed, falling back to blob approach:", error); } const blob = await new Response(file.stream).blob(); const typedBlob = new Blob([blob], { type: file.type }); return new Promise(function(resolve) { const downloadUrl = URL.createObjectURL(typedBlob); const a = document.createElement("a"); a.href = downloadUrl; a.download = file.name; document.body.appendChild(a); a.click(); setTimeout(() => { document.body.removeChild(a); window.URL.revokeObjectURL(downloadUrl); resolve(); }, 0); }); } //#endregion //#region ../send/frontend/src/lib/download.ts var Downloader = class { constructor(keychain, api) { this.keychain = keychain; this.api = api; } async doDownload(id, folderId, wrappedKeyStr, filename, metrics, progressTracker) { if (!id) return false; if (!folderId) return false; const { isSuspicious } = await this.api.call(`download/check-upload-id/${id}`); if (isSuspicious) throw new Error("File has been reported as suspicious"); const wrappingKey = await this.keychain.get(folderId); if (!wrappingKey) return false; const { size, type } = await this.api.call(`uploads/${id}/metadata`); if (!size) return false; const contentKey = await this.keychain.container.unwrapContentKey(wrappedKeyStr, wrappingKey); const isBucketStorage = this.api.isBucketStorage; try { progressTracker.setFileName(filename); progressTracker.setProcessStage("downloading"); await getBlob(id, size, contentKey, isBucketStorage, filename, type, this.api, progressTracker); metrics.capture("download.size", { size, type }); return true; } catch (e) { return false; } } }; //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/version.js var SDK_VERSION = "8.55.2"; //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/worldwide.js /** Get's the global object for the current JavaScript runtime */ var GLOBAL_OBJ = globalThis; /** * Returns a global singleton contained in the global `__SENTRY__[]` object. * * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory * function and added to the `__SENTRY__` object. * * @param name name of the global singleton on __SENTRY__ * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__` * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value * @returns the singleton */ function getGlobalSingleton(name, creator, obj) { const gbl = obj || GLOBAL_OBJ; const __SENTRY__ = gbl.__SENTRY__ = gbl.__SENTRY__ || {}; const versionedCarrier = __SENTRY__[SDK_VERSION] = __SENTRY__["8.55.2"] || {}; return versionedCarrier[name] || (versionedCarrier[name] = creator()); } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/debug-build.js /** * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code. * * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking. */ var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__; //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/logger.js /** Prefix for logging strings */ var PREFIX = "Sentry Logger "; var CONSOLE_LEVELS = [ "debug", "info", "warn", "error", "log", "assert", "trace" ]; /** This may be mutated by the console instrumentation. */ var originalConsoleMethods = {}; /** JSDoc */ /** * Temporarily disable sentry console instrumentations. * * @param callback The function to run against the original `console` messages * @returns The results of the callback */ function consoleSandbox(callback) { if (!("console" in GLOBAL_OBJ)) return callback(); const console = GLOBAL_OBJ.console; const wrappedFuncs = {}; const wrappedLevels = Object.keys(originalConsoleMethods); wrappedLevels.forEach((level) => { const originalConsoleMethod = originalConsoleMethods[level]; wrappedFuncs[level] = console[level]; console[level] = originalConsoleMethod; }); try { return callback(); } finally { wrappedLevels.forEach((level) => { console[level] = wrappedFuncs[level]; }); } } function makeLogger() { let enabled = false; const logger = { enable: () => { enabled = true; }, disable: () => { enabled = false; }, isEnabled: () => enabled }; if (DEBUG_BUILD) CONSOLE_LEVELS.forEach((name) => { logger[name] = (...args) => { if (enabled) consoleSandbox(() => { GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args); }); }; }); else CONSOLE_LEVELS.forEach((name) => { logger[name] = () => void 0; }); return logger; } /** * This is a logger singleton which either logs things or no-ops if logging is not enabled. * The logger is a singleton on the carrier, to ensure that a consistent logger is used throughout the SDK. */ var logger$1 = getGlobalSingleton("logger", makeLogger); //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/carrier.js /** * An object that contains globally accessible properties and maintains a scope stack. * @hidden */ /** * Returns the global shim registry. * * FIXME: This function is problematic, because despite always returning a valid Carrier, * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there. **/ function getMainCarrier() { getSentryCarrier(GLOBAL_OBJ); return GLOBAL_OBJ; } /** Will either get the existing sentry carrier, or create a new one. */ function getSentryCarrier(carrier) { const __SENTRY__ = carrier.__SENTRY__ = carrier.__SENTRY__ || {}; __SENTRY__.version = __SENTRY__.version || "8.55.2"; return __SENTRY__[SDK_VERSION] = __SENTRY__["8.55.2"] || {}; } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/is.js var objectToString = Object.prototype.toString; /** * Checks whether given value is an instance of the given built-in class. * * @param wat The value to be checked * @param className * @returns A boolean representing the result. */ function isBuiltin(wat, className) { return objectToString.call(wat) === `[object ${className}]`; } /** * Checks whether given value's type is an object literal, or a class instance. * {@link isPlainObject}. * * @param wat A value to be checked. * @returns A boolean representing the result. */ function isPlainObject(wat) { return isBuiltin(wat, "Object"); } /** * Checks whether given value has a then function. * @param wat A value to be checked. */ function isThenable(wat) { return Boolean(wat && wat.then && typeof wat.then === "function"); } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/object.js /** * Defines a non-enumerable property on the given object. * * @param obj The object on which to set the property * @param name The name of the property to be set * @param value The value to which to set the property */ function addNonEnumerableProperty(obj, name, value) { try { Object.defineProperty(obj, name, { value, writable: true, configurable: true }); } catch (o_O) { DEBUG_BUILD && logger$1.log(`Failed to add non-enumerable property "${name}" to object`, obj); } } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/time.js var ONE_SECOND_IN_MS = 1e3; /** * A partial definition of the [Performance Web API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Performance} * for accessing a high-resolution monotonic clock. */ /** * Returns a timestamp in seconds since the UNIX epoch using the Date API. * * TODO(v8): Return type should be rounded. */ function dateTimestampInSeconds() { return Date.now() / ONE_SECOND_IN_MS; } /** * Returns a wrapper around the native Performance API browser implementation, or undefined for browsers that do not * support the API. * * Wrapping the native API works around differences in behavior from different browsers. */ function createUnixTimestampInSecondsFunc() { const { performance } = GLOBAL_OBJ; if (!performance || !performance.now) return dateTimestampInSeconds; const approxStartingTimeOrigin = Date.now() - performance.now(); const timeOrigin = performance.timeOrigin == void 0 ? approxStartingTimeOrigin : performance.timeOrigin; return () => { return (timeOrigin + performance.now()) / ONE_SECOND_IN_MS; }; } /** * Returns a timestamp in seconds since the UNIX epoch using either the Performance or Date APIs, depending on the * availability of the Performance API. * * BUG: Note that because of how browsers implement the Performance API, the clock might stop when the computer is * asleep. This creates a skew between `dateTimestampInSeconds` and `timestampInSeconds`. The * skew can grow to arbitrary amounts like days, weeks or months. * See https://github.com/getsentry/sentry-javascript/issues/2590. */ var timestampInSeconds = createUnixTimestampInSecondsFunc(); (() => { const { performance } = GLOBAL_OBJ; if (!performance || !performance.now) return; const threshold = 3600 * 1e3; const performanceNow = performance.now(); const dateNow = Date.now(); const timeOriginDelta = performance.timeOrigin ? Math.abs(performance.timeOrigin + performanceNow - dateNow) : threshold; const timeOriginIsReliable = timeOriginDelta < threshold; const navigationStart = performance.timing && performance.timing.navigationStart; const navigationStartDelta = typeof navigationStart === "number" ? Math.abs(navigationStart + performanceNow - dateNow) : threshold; if (timeOriginIsReliable || navigationStartDelta < threshold) if (timeOriginDelta <= navigationStartDelta) return performance.timeOrigin; else return navigationStart; return dateNow; })(); //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/misc.js /** * UUID4 generator * * @returns string Generated UUID4. */ function uuid4() { const gbl = GLOBAL_OBJ; const crypto = gbl.crypto || gbl.msCrypto; let getRandomByte = () => Math.random() * 16; try { if (crypto && crypto.randomUUID) return crypto.randomUUID().replace(/-/g, ""); if (crypto && crypto.getRandomValues) getRandomByte = () => { const typedArray = new Uint8Array(1); crypto.getRandomValues(typedArray); return typedArray[0]; }; } catch (_) {} return "10000000100040008000100000000000".replace(/[018]/g, (c) => (c ^ (getRandomByte() & 15) >> c / 4).toString(16)); } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/session.js /** * Updates a session object with the properties passed in the context. * * Note that this function mutates the passed object and returns void. * (Had to do this instead of returning a new and updated session because closing and sending a session * makes an update to the session after it was passed to the sending logic. * @see BaseClient.captureSession ) * * @param session the `Session` to update * @param context the `SessionContext` holding the properties that should be updated in @param session */ function updateSession(session, context = {}) { if (context.user) { if (!session.ipAddress && context.user.ip_address) session.ipAddress = context.user.ip_address; if (!session.did && !context.did) session.did = context.user.id || context.user.email || context.user.username; } session.timestamp = context.timestamp || timestampInSeconds(); if (context.abnormal_mechanism) session.abnormal_mechanism = context.abnormal_mechanism; if (context.ignoreDuration) session.ignoreDuration = context.ignoreDuration; if (context.sid) session.sid = context.sid.length === 32 ? context.sid : uuid4(); if (context.init !== void 0) session.init = context.init; if (!session.did && context.did) session.did = `${context.did}`; if (typeof context.started === "number") session.started = context.started; if (session.ignoreDuration) session.duration = void 0; else if (typeof context.duration === "number") session.duration = context.duration; else { const duration = session.timestamp - session.started; session.duration = duration >= 0 ? duration : 0; } if (context.release) session.release = context.release; if (context.environment) session.environment = context.environment; if (!session.ipAddress && context.ipAddress) session.ipAddress = context.ipAddress; if (!session.userAgent && context.userAgent) session.userAgent = context.userAgent; if (typeof context.errors === "number") session.errors = context.errors; if (context.status) session.status = context.status; } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils-hoist/propagationContext.js /** * Generate a random, valid trace ID. */ function generateTraceId() { return uuid4(); } /** * Generate a random, valid span ID. */ function generateSpanId() { return uuid4().substring(16); } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils/merge.js /** * Shallow merge two objects. * Does not mutate the passed in objects. * Undefined/empty values in the merge object will overwrite existing values. * * By default, this merges 2 levels deep. */ function merge(initialObj, mergeObj, levels = 2) { if (!mergeObj || typeof mergeObj !== "object" || levels <= 0) return mergeObj; if (initialObj && mergeObj && Object.keys(mergeObj).length === 0) return initialObj; const output = { ...initialObj }; for (const key in mergeObj) if (Object.prototype.hasOwnProperty.call(mergeObj, key)) output[key] = merge(output[key], mergeObj[key], levels - 1); return output; } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils/spanOnScope.js var SCOPE_SPAN_FIELD = "_sentrySpan"; /** * Set the active span for a given scope. * NOTE: This should NOT be used directly, but is only used internally by the trace methods. */ function _setSpanForScope(scope, span) { if (span) addNonEnumerableProperty(scope, SCOPE_SPAN_FIELD, span); else delete scope[SCOPE_SPAN_FIELD]; } /** * Get the active span for a given scope. * NOTE: This should NOT be used directly, but is only used internally by the trace methods. */ function _getSpanForScope(scope) { return scope[SCOPE_SPAN_FIELD]; } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/scope.js /** * Default value for maximum number of breadcrumbs added to an event. */ var DEFAULT_MAX_BREADCRUMBS = 100; /** * Holds additional event information. */ var Scope = class ScopeClass { /** Flag if notifying is happening. */ /** Callback for client to receive scope changes. */ /** Callback list that will be called during event processing. */ /** Array of breadcrumbs. */ /** User */ /** Tags */ /** Extra */ /** Contexts */ /** Attachments */ /** Propagation Context for distributed tracing */ /** * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get * sent to Sentry */ /** Fingerprint */ /** Severity */ /** * Transaction Name * * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects. * It's purpose is to assign a transaction to the scope that's added to non-transaction events. */ /** Session */ /** Request Mode Session Status */ /** The client on this scope */ /** Contains the last event id of a captured event. */ constructor() { this._notifyingListeners = false; this._scopeListeners = []; this._eventProcessors = []; this._breadcrumbs = []; this._attachments = []; this._user = {}; this._tags = {}; this._extra = {}; this._contexts = {}; this._sdkProcessingMetadata = {}; this._propagationContext = { traceId: generateTraceId(), spanId: generateSpanId() }; } /** * @inheritDoc */ clone() { const newScope = new ScopeClass(); newScope._breadcrumbs = [...this._breadcrumbs]; newScope._tags = { ...this._tags }; newScope._extra = { ...this._extra }; newScope._contexts = { ...this._contexts }; if (this._contexts.flags) newScope._contexts.flags = { values: [...this._contexts.flags.values] }; newScope._user = this._user; newScope._level = this._level; newScope._session = this._session; newScope._transactionName = this._transactionName; newScope._fingerprint = this._fingerprint; newScope._eventProcessors = [...this._eventProcessors]; newScope._requestSession = this._requestSession; newScope._attachments = [...this._attachments]; newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata }; newScope._propagationContext = { ...this._propagationContext }; newScope._client = this._client; newScope._lastEventId = this._lastEventId; _setSpanForScope(newScope, _getSpanForScope(this)); return newScope; } /** * @inheritDoc */ setClient(client) { this._client = client; } /** * @inheritDoc */ setLastEventId(lastEventId) { this._lastEventId = lastEventId; } /** * @inheritDoc */ getClient() { return this._client; } /** * @inheritDoc */ lastEventId() { return this._lastEventId; } /** * @inheritDoc */ addScopeListener(callback) { this._scopeListeners.push(callback); } /** * @inheritDoc */ addEventProcessor(callback) { this._eventProcessors.push(callback); return this; } /** * @inheritDoc */ setUser(user) { this._user = user || { email: void 0, id: void 0, ip_address: void 0, username: void 0 }; if (this._session) updateSession(this._session, { user }); this._notifyScopeListeners(); return this; } /** * @inheritDoc */ getUser() { return this._user; } /** * @inheritDoc */ getRequestSession() { return this._requestSession; } /** * @inheritDoc */ setRequestSession(requestSession) { this._requestSession = requestSession; return this; } /** * @inheritDoc */ setTags(tags) { this._tags = { ...this._tags, ...tags }; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ setTag(key, value) { this._tags = { ...this._tags, [key]: value }; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ setExtras(extras) { this._extra = { ...this._extra, ...extras }; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ setExtra(key, extra) { this._extra = { ...this._extra, [key]: extra }; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ setFingerprint(fingerprint) { this._fingerprint = fingerprint; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ setLevel(level) { this._level = level; this._notifyScopeListeners(); return this; } /** * Sets the transaction name on the scope so that the name of e.g. taken server route or * the page location is attached to future events. * * IMPORTANT: Calling this function does NOT change the name of the currently active * root span. If you want to change the name of the active root span, use * `Sentry.updateSpanName(rootSpan, 'new name')` instead. * * By default, the SDK updates the scope's transaction name automatically on sensible * occasions, such as a page navigation or when handling a new request on the server. */ setTransactionName(name) { this._transactionName = name; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ setContext(key, context) { if (context === null) delete this._contexts[key]; else this._contexts[key] = context; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ setSession(session) { if (!session) delete this._session; else this._session = session; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ getSession() { return this._session; } /** * @inheritDoc */ update(captureContext) { if (!captureContext) return this; const scopeToMerge = typeof captureContext === "function" ? captureContext(this) : captureContext; const [scopeInstance, requestSession] = scopeToMerge instanceof Scope ? [scopeToMerge.getScopeData(), scopeToMerge.getRequestSession()] : isPlainObject(scopeToMerge) ? [captureContext, captureContext.requestSession] : []; const { tags, extra, user, contexts, level, fingerprint = [], propagationContext } = scopeInstance || {}; this._tags = { ...this._tags, ...tags }; this._extra = { ...this._extra, ...extra }; this._contexts = { ...this._contexts, ...contexts }; if (user && Object.keys(user).length) this._user = user; if (level) this._level = level; if (fingerprint.length) this._fingerprint = fingerprint; if (propagationContext) this._propagationContext = propagationContext; if (requestSession) this._requestSession = requestSession; return this; } /** * @inheritDoc */ clear() { this._breadcrumbs = []; this._tags = {}; this._extra = {}; this._user = {}; this._contexts = {}; this._level = void 0; this._transactionName = void 0; this._fingerprint = void 0; this._requestSession = void 0; this._session = void 0; _setSpanForScope(this, void 0); this._attachments = []; this.setPropagationContext({ traceId: generateTraceId() }); this._notifyScopeListeners(); return this; } /** * @inheritDoc */ addBreadcrumb(breadcrumb, maxBreadcrumbs) { const maxCrumbs = typeof maxBreadcrumbs === "number" ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS; if (maxCrumbs <= 0) return this; const mergedBreadcrumb = { timestamp: dateTimestampInSeconds(), ...breadcrumb }; this._breadcrumbs.push(mergedBreadcrumb); if (this._breadcrumbs.length > maxCrumbs) { this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs); if (this._client) this._client.recordDroppedEvent("buffer_overflow", "log_item"); } this._notifyScopeListeners(); return this; } /** * @inheritDoc */ getLastBreadcrumb() { return this._breadcrumbs[this._breadcrumbs.length - 1]; } /** * @inheritDoc */ clearBreadcrumbs() { this._breadcrumbs = []; this._notifyScopeListeners(); return this; } /** * @inheritDoc */ addAttachment(attachment) { this._attachments.push(attachment); return this; } /** * @inheritDoc */ clearAttachments() { this._attachments = []; return this; } /** @inheritDoc */ getScopeData() { return { breadcrumbs: this._breadcrumbs, attachments: this._attachments, contexts: this._contexts, tags: this._tags, extra: this._extra, user: this._user, level: this._level, fingerprint: this._fingerprint || [], eventProcessors: this._eventProcessors, propagationContext: this._propagationContext, sdkProcessingMetadata: this._sdkProcessingMetadata, transactionName: this._transactionName, span: _getSpanForScope(this) }; } /** * @inheritDoc */ setSDKProcessingMetadata(newData) { this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2); return this; } /** * @inheritDoc */ setPropagationContext(context) { this._propagationContext = { spanId: generateSpanId(), ...context }; return this; } /** * @inheritDoc */ getPropagationContext() { return this._propagationContext; } /** * @inheritDoc */ captureException(exception, hint) { const eventId = hint && hint.event_id ? hint.event_id : uuid4(); if (!this._client) { logger$1.warn("No client configured on scope - will not capture exception!"); return eventId; } const syntheticException = /* @__PURE__ */ new Error("Sentry syntheticException"); this._client.captureException(exception, { originalException: exception, syntheticException, ...hint, event_id: eventId }, this); return eventId; } /** * @inheritDoc */ captureMessage(message, level, hint) { const eventId = hint && hint.event_id ? hint.event_id : uuid4(); if (!this._client) { logger$1.warn("No client configured on scope - will not capture message!"); return eventId; } const syntheticException = new Error(message); this._client.captureMessage(message, level, { originalException: message, syntheticException, ...hint, event_id: eventId }, this); return eventId; } /** * @inheritDoc */ captureEvent(event, hint) { const eventId = hint && hint.event_id ? hint.event_id : uuid4(); if (!this._client) { logger$1.warn("No client configured on scope - will not capture event!"); return eventId; } this._client.captureEvent(event, { ...hint, event_id: eventId }, this); return eventId; } /** * This will be called on every set call. */ _notifyScopeListeners() { if (!this._notifyingListeners) { this._notifyingListeners = true; this._scopeListeners.forEach((callback) => { callback(this); }); this._notifyingListeners = false; } } }; //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/defaultScopes.js /** Get the default current scope. */ function getDefaultCurrentScope() { return getGlobalSingleton("defaultCurrentScope", () => new Scope()); } /** Get the default isolation scope. */ function getDefaultIsolationScope() { return getGlobalSingleton("defaultIsolationScope", () => new Scope()); } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/asyncContext/stackStrategy.js /** * This is an object that holds a stack of scopes. */ var AsyncContextStack = class { constructor(scope, isolationScope) { let assignedScope; if (!scope) assignedScope = new Scope(); else assignedScope = scope; let assignedIsolationScope; if (!isolationScope) assignedIsolationScope = new Scope(); else assignedIsolationScope = isolationScope; this._stack = [{ scope: assignedScope }]; this._isolationScope = assignedIsolationScope; } /** * Fork a scope for the stack. */ withScope(callback) { const scope = this._pushScope(); let maybePromiseResult; try { maybePromiseResult = callback(scope); } catch (e) { this._popScope(); throw e; } if (isThenable(maybePromiseResult)) return maybePromiseResult.then((res) => { this._popScope(); return res; }, (e) => { this._popScope(); throw e; }); this._popScope(); return maybePromiseResult; } /** * Get the client of the stack. */ getClient() { return this.getStackTop().client; } /** * Returns the scope of the top stack. */ getScope() { return this.getStackTop().scope; } /** * Get the isolation scope for the stack. */ getIsolationScope() { return this._isolationScope; } /** * Returns the topmost scope layer in the order domain > local > process. */ getStackTop() { return this._stack[this._stack.length - 1]; } /** * Push a scope to the stack. */ _pushScope() { const scope = this.getScope().clone(); this._stack.push({ client: this.getClient(), scope }); return scope; } /** * Pop a scope from the stack. */ _popScope() { if (this._stack.length <= 1) return false; return !!this._stack.pop(); } }; /** * Get the global async context stack. * This will be removed during the v8 cycle and is only here to make migration easier. */ function getAsyncContextStack() { const sentry = getSentryCarrier(getMainCarrier()); return sentry.stack = sentry.stack || new AsyncContextStack(getDefaultCurrentScope(), getDefaultIsolationScope()); } function withScope(callback) { return getAsyncContextStack().withScope(callback); } function withSetScope(scope, callback) { const stack = getAsyncContextStack(); return stack.withScope(() => { stack.getStackTop().scope = scope; return callback(scope); }); } function withIsolationScope(callback) { return getAsyncContextStack().withScope(() => { return callback(getAsyncContextStack().getIsolationScope()); }); } /** * Get the stack-based async context strategy. */ function getStackAsyncContextStrategy() { return { withIsolationScope, withScope, withSetScope, withSetIsolationScope: (_isolationScope, callback) => { return withIsolationScope(callback); }, getCurrentScope: () => getAsyncContextStack().getScope(), getIsolationScope: () => getAsyncContextStack().getIsolationScope() }; } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/asyncContext/index.js /** * Get the current async context strategy. * If none has been setup, the default will be used. */ function getAsyncContextStrategy(carrier) { const sentry = getSentryCarrier(carrier); if (sentry.acs) return sentry.acs; return getStackAsyncContextStrategy(); } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/currentScopes.js /** * Get the currently active scope. */ function getCurrentScope() { return getAsyncContextStrategy(getMainCarrier()).getCurrentScope(); } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/utils/prepareEvent.js /** * Parse either an `EventHint` directly, or convert a `CaptureContext` to an `EventHint`. * This is used to allow to update method signatures that used to accept a `CaptureContext` but should now accept an `EventHint`. */ function parseEventHintOrCaptureContext(hint) { if (!hint) return; if (hintIsScopeOrFunction(hint)) return { captureContext: hint }; if (hintIsScopeContext(hint)) return { captureContext: hint }; return hint; } function hintIsScopeOrFunction(hint) { return hint instanceof Scope || typeof hint === "function"; } var captureContextKeys = [ "user", "level", "extra", "contexts", "tags", "fingerprint", "requestSession", "propagationContext" ]; function hintIsScopeContext(hint) { return Object.keys(hint).some((key) => captureContextKeys.includes(key)); } //#endregion //#region ../../node_modules/.pnpm/@sentry+core@8.55.2/node_modules/@sentry/core/build/esm/exports.js /** * Captures an exception event and sends it to Sentry. * * @param exception The exception to capture. * @param hint Optional additional data to attach to the Sentry event. * @returns the id of the captured Sentry event. */ function captureException(exception, hint) { return getCurrentScope().captureException(exception, parseEventHintOrCaptureContext(hint)); } //#endregion //#region ../send/frontend/src/lib/upload.ts /** * Turn the (optional) {@link ApiCallFailure} from the create-entry call into a * descriptive Error to use as the thrown error's `cause`, so the underlying * reason (network vs HTTP status/body) survives in Sentry instead of being a * bare "Failed to create upload entry". */ function createEntryFailureToCause(failure) { if (failure?.kind === "http") { const suffix = failure.body ? `: ${failure.body}` : ""; return /* @__PURE__ */ new Error(`create-entry HTTP ${failure.status} ${failure.statusText}${suffix}`); } if (failure?.kind === "network") return failure.error instanceof Error ? failure.error : /* @__PURE__ */ new Error(`create-entry network error: ${String(failure.error)}`); return /* @__PURE__ */ new Error("create-entry returned no result"); } var Uploader = class { constructor(user, keychain, api) { this.user = user; this.keychain = keychain; this.api = api; } /** * Asks the backend to delete every part this upload attempt wrote to storage. * Called when a multipart upload fails partway so that already-uploaded (and * partially-uploaded) parts don't linger as orphaned bytes in the bucket. */ async deleteWrittenUploads(api, ids) { if (ids.length === 0) return; await api.call("uploads/cleanup", { ids }, "POST"); } /** * Fire-and-forget cleanup for use during page teardown (pagehide), when an * upload is still in flight and the normal `if (fatalError)` cleanup will * never run. Uses a `keepalive` fetch so the request survives the page being * torn down, and cookie auth (`credentials: 'include'`) since requireJWT reads * the auth cookie — a Bearer header can't be attached reliably at unload time. * Best-effort only: hard kills/crashes still rely on the server-side reaper. */ teardownCleanup(api, ids) { if (ids.length === 0) return; try { fetch(`${api.serverUrl}/api/uploads/cleanup`, { method: "POST", keepalive: true, credentials: "include", headers: { "content-type": "application/json" }, body: JSON.stringify({ ids }) }); } catch {} } /** * Creates a multipart progress tracker that manages overall progress across all parts */ createMultipartProgressTracker(mainTracker, blobSizes, isMultipart, originalFileSize) { const totalBlobSize = blobSizes.reduce((sum, size) => sum + size, 0); const partProgress = new Array(blobSizes.length).fill(0); const updateOverallProgress = () => { if (!isMultipart || blobSizes.length === 1) mainTracker.setProgress(Math.min(partProgress[0], originalFileSize)); else { const overallProgress = partProgress.reduce((sum, progress) => sum + progress, 0) / totalBlobSize * originalFileSize; mainTracker.setProgress(Math.min(overallProgress, originalFileSize)); } }; return { getPartTracker: (partIndex) => { const partSize = blobSizes[partIndex]; return { total: mainTracker.total, progressed: mainTracker.progressed, percentage: mainTracker.percentage, error: mainTracker.error, text: mainTracker.text, fileName: mainTracker.fileName, processStage: mainTracker.processStage, initialize: () => {}, setUploadSize: () => {}, setFileName: (name) => { mainTracker.setFileName(name); }, setProcessStage: (stage) => { mainTracker.setProcessStage(stage); }, setText: (message) => { mainTracker.setText(message); }, setProgress: (progress) => { partProgress[partIndex] = Math.min(progress, partSize); updateOverallProgress(); } }; }, markPartComplete: (partIndex) => { partProgress[partIndex] = blobSizes[partIndex]; updateOverallProgress(); } }; } async doUpload(fileBlob, containerId, api, progressTracker) { if (!containerId) return null; if (!fileBlob) return null; const wrappingKey = await this.keychain.get(containerId); if (!wrappingKey) return null; const key = await this.keychain.content.generateKey(); const wrappedKeyStr = await this.keychain.container.wrapContentKey(key, wrappingKey); const shouldSplit = fileBlob.size > SPLIT_SIZE; const numChunks = shouldSplit ? Math.ceil(fileBlob.size / SPLIT_SIZE) : 1; const partSizes = Array.from({ length: numChunks }, (_, i) => Math.min(SPLIT_SIZE, fileBlob.size - i * SPLIT_SIZE)); progressTracker.setUploadSize(fileBlob.size); progressTracker.setProcessStage("hashing"); progressTracker.setText("Hashing file"); const parts = new Array(numChunks); const hashes = new Array(numChunks); const partReady = Array.from({ length: numChunks }, () => { let resolve; let reject; const promise = new Promise((res, rej) => { resolve = res; reject = rej; }); promise.catch(() => {}); return { promise, resolve, reject }; }); if (shouldSplit) (async () => { let produced = 0; try { for await (const part of streamZippedParts(api, fileBlob, SPLIT_SIZE, (bytesHashed) => { if (parts[0] !== void 0) return; const pct = Math.round(bytesHashed / fileBlob.size * 100); progressTracker.setText(`Hashing file (${pct}%)`); })) { parts[produced] = part.blob; hashes[produced] = part.hash; partReady[produced].resolve(); produced++; } if (produced < numChunks) { const err = /* @__PURE__ */ new Error(`Streaming produced ${produced} of ${numChunks} expected parts`); for (let i = produced; i < numChunks; i++) partReady[i].reject(err); } } catch (err) { for (let i = produced; i < numChunks; i++) partReady[i].reject(err); } })(); else { const [singleHash] = await hashFiles(api, fileBlob, SPLIT_SIZE); parts[0] = fileBlob; hashes[0] = singleHash; partReady[0].resolve(); } const multipartTracker = this.createMultipartProgressTracker(progressTracker, partSizes, shouldSplit, fileBlob.size); const abortController = new AbortController(); const writtenUploadIds = /* @__PURE__ */ new Set(); const uploadPart = async (blob, index) => { const filename = blob.name; const isBucketStorage = api.isBucketStorage; const partTracker = multipartTracker.getPartTracker(index); const part = shouldSplit ? index + 1 : void 0; const id = await sendBlob(blob, key, api, partTracker, isBucketStorage, { signal: abortController.signal, onUploadId: (uploadId) => writtenUploadIds.add(uploadId) }); if (!id) throw new Error("Failed to send blob"); await retryUntilSuccessOrTimeout(async () => { const { size } = await this.api.call(`uploads/${id}/stat`); return !!size; }, 2e3, 18e4); let uploadResult = null; let upload = null; let retryCount = 0; const maxRetries = 5; while (retryCount < maxRetries && !uploadResult) { if (abortController.signal.aborted) throw new Error("Upload aborted"); try { if (!upload) { let createEntryFailure; const result = await this.api.call("uploads", { id, size: blob.size, ownerId: this.user.id, type: blob.type, containerId, part, fileHash: hashes[index] }, "POST", {}, { onFailure: (failure) => { createEntryFailure = failure; } }); if (!result) { const cause = createEntryFailureToCause(createEntryFailure); captureException(cause, { tags: { upload_stage: "create_entry", create_entry_failure_kind: createEntryFailure?.kind ?? "unknown", ...createEntryFailure?.kind === "http" ? { create_entry_http_status: String(createEntryFailure.status) } : {} }, contexts: { create_entry: { kind: createEntryFailure?.kind ?? "unknown", status: createEntryFailure?.kind === "http" ? createEntryFailure.status : null, statusText: createEntryFailure?.kind === "http" ? createEntryFailure.statusText : void 0, body: createEntryFailure?.kind === "http" ? createEntryFailure.body : void 0 } } }); throw new Error("Failed to create upload entry", { cause }); } upload = result.upload; } const itemObj = await this.api.call(`containers/${containerId}/item`, { uploadId: upload.id, name: filename, type: "MESSAGE", wrappedKey: wrappedKeyStr, multipart: shouldSplit ? true : false, totalSize: fileBlob.size }, "POST"); if (!itemObj) throw new Error("Failed to create item object"); uploadResult = { upload, itemObj }; } catch (error) { retryCount++; console.error(`Create-entry attempt ${retryCount} failed:`, error); if (retryCount >= maxRetries) { const failureMessage = `Upload failed for ${fileBlob.name} after ${maxRetries} attempts` + (part ? ` (part ${part})` : ""); console.error(failureMessage, error); throw new Error(failureMessage); } await new Promise((resolve) => setTimeout(resolve, Math.pow(2, retryCount) * 1e3)); } } const { itemObj } = uploadResult; const item = { ...itemObj, upload: { size: blob.size, type: blob.type, part } }; multipartTracker.markPartComplete(index); return item; }; const uploadResponses = new Array(numChunks); let nextIndex = 0; let fatalError = null; const runWorker = async () => { while (true) { if (fatalError) return; const index = nextIndex++; if (index >= numChunks) return; try { await partReady[index].promise; const item = await uploadPart(parts[index], index); if (!item) throw new Error(`Upload part ${index} returned no item`); uploadResponses[index] = item; parts[index] = void 0; } catch (error) { if (!fatalError) fatalError = error; abortController.abort(); return; } } }; const onPageHide = () => this.teardownCleanup(api, [...writtenUploadIds]); window.addEventListener("pagehide", onPageHide); try { const workerCount = Math.min(4, numChunks); await Promise.all(Array.from({ length: workerCount }, () => runWorker())); if (fatalError) { await this.deleteWrittenUploads(api, [...writtenUploadIds]).catch(() => {}); const failureMessage = fatalError instanceof Error ? fatalError.message : `Upload failed for ${fileBlob.name}`; progressTracker.setProcessStage("error"); progressTracker.setText(failureMessage); progressTracker.error = failureMessage; throw fatalError instanceof Error ? fatalError : new Error(failureMessage); } return uploadResponses; } finally { window.removeEventListener("pagehide", onPageHide); } } }; //#endregion //#region ../send/frontend/src/stores/keychain-store.ts var useKeychainStore = defineStore("keychain", () => { const keychain = new Keychain(new Storage$1()); function resetKeychain() { keychain._init(); } async function addKey(id, key) { await keychain.add(id, key); } async function getKey(id) { return await keychain.get(id); } function removeKey(id) { keychain.remove(id); } async function newKeyForContainer(id) { await keychain.newKeyForContainer(id); } return { keychain, resetKeychain, addKey, getKey, removeKey, newKeyForContainer }; }); //#endregion //#region ../send/frontend/src/types.ts var UserTier = /* @__PURE__ */ function(UserTier) { UserTier[UserTier["FREE"] = 1] = "FREE"; UserTier[UserTier["EPHEMERAL"] = 2] = "EPHEMERAL"; UserTier[UserTier["PRO"] = 3] = "PRO"; return UserTier; }({}); //#endregion //#region ../send/frontend/src/stores/user-store.ts var EMPTY_USER = { id: void 0, tier: UserTier.FREE, email: "", thundermailEmail: "" }; var useUserStore = defineStore("user", () => { const { api } = useApiStore(); const storage = new Storage$1(); const user = /* @__PURE__ */ reactive({ ...EMPTY_USER }); function populateUser(userData) { user.id = userData.id; user.tier = userData.tier; user.email = userData.email; user.thundermailEmail = userData.thundermailEmail; user.name = userData.name; if (userData.uniqueHash) user.uniqueHash = userData.uniqueHash; if (userData.thundermailEmail) user.thundermailEmail = userData.thundermailEmail; } async function createUser(email, jwkPublicKey, isEphemeral = false) { const resp = await api.call(`users`, { email, publicKey: jwkPublicKey, tier: isEphemeral ? UserTier.EPHEMERAL : UserTier.PRO }, "POST"); if (!resp) return null; return { id: resp.user.id, tier: resp.user.tier, email, thundermailEmail: resp.user.thundermailEmail, uniqueHash: resp.user.uniqueHash }; } async function login(loginEmail = user.email) { console.log(`logging in as ${loginEmail}`); const resp = await api.call(`users/login`, { email: loginEmail }, "POST"); if (!resp) return null; populateUser(resp); return resp; } async function loadFromLocalStorage() { try { const userFromStorage = await storage.getUserFromLocalStorage(); if (!userFromStorage) return false; const { id, tier, email, thundermailEmail, name } = userFromStorage; populateUser({ id, email, tier, thundermailEmail, name }); return true; } catch (e) { return false; } } async function store(newId, newTier, newEmail, newThundermailEmail, newName) { let { id, tier, email, thundermailEmail, name } = user; id = newId ?? id; tier = newTier ?? tier; email = newEmail ?? email; name = newName ?? name; thundermailEmail = newThundermailEmail ?? thundermailEmail; if (!id) return; await storage.storeUser({ id, tier, email, thundermailEmail, name }); } async function populateFromBackend() { if (user.id) return true; const userResp = await api.call(`users/me`); if (!userResp?.user) return false; populateUser(userResp.user); return true; } async function getPublicKey() { return (await api.call(`users/publickey/${user.id}`)).publicKey; } async function updatePublicKey(jwkPublicKey) { return (await api.call(`users/publickey`, { publicKey: jwkPublicKey }, "POST")).update?.publicKey; } async function createBackup(userId, keys, keypair, keystring, salt) { return await api.call(`users/${userId}/backup`, { keys, keypair, keystring, salt }, "POST"); } async function getBackup() { return await api.call(`users/backup`); } async function setUserToDefault() { Object.entries(EMPTY_USER).forEach(([key, value]) => { user[key] = value; }); } async function clearUserFromStorage() { storage.clear(); setUserToDefault(); } return { user, createUser, login, store, loadFromLocalStorage, populateFromBackend, getPublicKey, updatePublicKey, createBackup, getBackup, clearUserFromStorage }; }); //#endregion //#region ../send/frontend/src/lib/messages.ts var CLIENT_MESSAGES = { SHOULD_LOG_IN: `You need to log into your mozilla account. Make sure you're in the allow list for alpha access.`, FILE_TOO_BIG: `Your file size is not supported, please try with files smaller than ${MAX_FILE_SIZE_HUMAN_READABLE}`, UPLOAD_FAILED: `Upload failed. Please try again.`, STORAGE_LIMIT_EXCEEDED: `Uploading this file would exceed your storage limit. Please delete some files and try again.` }; //#endregion //#region ../send/frontend/src/lib/folderView.ts /** * This function is meant for managing files in a folder, handling multipart file deduplication * @returns Computed property containing unique files with multipart suffix removed */ var organizeFiles = (files) => { const items = []; if (!files) return []; files.forEach((item) => { if (!item?.multipart) { items.push(item); return; } if (item.upload.part === 1) items.push({ ...item, upload: { ...item.upload, size: item.totalSize } }); }); return items; }; //#endregion //#region ../send/frontend/src/stores/metrics.ts var initializeClientMetrics = (uid) => { if (!uid) return; posthog_default.rest.identify(uid); }; var useMetricsStore = defineStore("metrics", () => { return { metrics: posthog_default.rest, initializeClientMetrics }; }); //#endregion //#region ../send/frontend/src/lib/validations.ts var validateToken = async (api) => { try { try { const authStore = await __vitePreload(() => Promise.resolve().then(() => auth_store_exports).then((m) => m.useAuthStore()), void 0); const isExtension = await __vitePreload(() => Promise.resolve().then(() => stores_exports).then((m) => m.useConfigStore().isExtension), void 0); const accessToken = await authStore.getAccessToken(); if (isExtension) await authStore.loadUser(); if (accessToken) { if ((await api.call("auth/oidc/me", {}, "GET", { Authorization: `Bearer ${accessToken}` }, { fullResponse: true }))?.ok) return true; console.log("OIDC token appears invalid, attempting refresh..."); const newToken = await authStore.refreshToken(); if (newToken) return !!(await api.call("auth/oidc/me", {}, "GET", { Authorization: `Bearer ${newToken}` }, { fullResponse: true }))?.ok; } } catch (error) { console.debug("OIDC validation failed, falling back to JWT:", error); } return !!await api.call("auth/me", {}, "GET", {}, { fullResponse: true }); } catch (err) { console.error("Error validating session", err); return false; } }; var validateUser = async (api) => { try { const userResponse = await api.call(`users/me`); if (userResponse?.user) return userResponse; } catch (error) { console.error("Error validating user", error); return null; } }; var validateBackedUpKeys = async (getBackup, keychain) => { const keybackup = await getBackup(); const hasBackedUpKeys = keychain.getPassphraseValue(); if (!keybackup || !hasBackedUpKeys) return false; return true; }; /** * Checks local storage for a user object */ var validateLocalStorageSession = ({ user }) => { if (user?.id != void 0) return true; else return false; }; var validator = async ({ api, keychain, userStore }) => { const validations = { hasBackedUpKeys: false, hasLocalStorageSession: false, isTokenValid: false, hasCorrectKeys: false, hasForcedLogin: false }; let shouldClearSessionAndStorage = false; const userIDFromBackend = (await validateUser(api))?.user?.id; const userIDFromStore = userStore?.user?.id; try { await restoreKeysUsingLocalStorage(keychain, api); validations.hasCorrectKeys = true; } catch { validations.hasCorrectKeys = false; shouldClearSessionAndStorage = true; console.error("Incorrect passphrase. Removing local storage data."); } if (userIDFromStore && userIDFromBackend && userIDFromBackend !== userIDFromStore) { console.error("User ID mismatch. Removing local storage data."); shouldClearSessionAndStorage = true; } else { validations.hasLocalStorageSession = validateLocalStorageSession(userStore); validations.isTokenValid = await validateToken(api); validations.hasBackedUpKeys = await validateBackedUpKeys(userStore.getBackup, keychain); } if (shouldClearSessionAndStorage) { await userStore.clearUserFromStorage(); validations.hasForcedLogin = true; try { location.reload(); } catch { console.warn("Failed to reload page"); } } return validations; }; //#endregion //#region ../send/frontend/src/apps/send/stores/status-store.ts var useStatusStore = defineStore("status", () => { const { api } = useApiStore(); const userStore = useUserStore(); const { keychain } = useKeychainStore(); const total = /* @__PURE__ */ ref(0); const progressed = /* @__PURE__ */ ref(0); const error = /* @__PURE__ */ ref(""); const text = /* @__PURE__ */ ref(""); const fileName = /* @__PURE__ */ ref(""); const processStage = /* @__PURE__ */ ref("idle"); const isRouterLoading = /* @__PURE__ */ ref(false); const debouncedUpdate = useDebounceFn((updatedValue) => { progressed.value = updatedValue; }, 1); function setText(message) { text.value = message; } function setUploadSize(size) { total.value = size; } function setProgress(number) { console.info("setting progress", number); debouncedUpdate(number); } function setFileName(name) { fileName.value = name; } function setProcessStage(stage) { processStage.value = stage; } function initialize() { total.value = 0; progressed.value = 0; error.value = ""; text.value = ""; fileName.value = ""; processStage.value = "idle"; } function setRouterLoading(loading) { isRouterLoading.value = loading; } const percentage = computed(() => { const result = progressed.value * 100 / total.value; if (Number.isNaN(result)) return 0; if (result > 100) return 100; return Math.round(result); }); const validators = () => validator({ api, keychain, userStore }); return { validators, setProgress, setUploadSize, setText, setFileName, setProcessStage, setRouterLoading, isRouterLoading, progress: { total, progressed, percentage, error, text, fileName, processStage, initialize, setProgress, setUploadSize, setText, setFileName, setProcessStage } }; }); //#endregion //#region ../send/frontend/src/apps/send/stores/folder-store.ts var useFolderStore = defineStore("folderManager", () => { const { api } = useApiStore(); const { user, populateFromBackend } = useUserStore(); const { progress } = useStatusStore(); const { metrics } = useMetricsStore(); const { keychain } = useKeychainStore(); const uploader = new Uploader(user, keychain, api); const downloader = new Downloader(keychain, api); const folders = /* @__PURE__ */ ref([]); const rootFolder = /* @__PURE__ */ ref(null); const msg = /* @__PURE__ */ ref(""); const selectedFolderId = /* @__PURE__ */ ref(null); const selectedFileId = /* @__PURE__ */ ref(null); const rootFolderId = /* @__PURE__ */ ref(null); onMounted(async () => { await getDefaultFolderId(); }); async function getDefaultFolderId() { try { const result = (await trpc.getDefaultFolder.query()).id || null; rootFolderId.value = result; return result; } catch { console.info("No default folder set for user"); return null; } } const defaultFolder = computed(() => { if (!folders?.value) return null; const total = folders.value.length; return total === 0 ? null : folders.value[total - 1]; }); const visibleFolders = computed(() => { if (folders.value.length === 0) return []; return calculateFolderSizes(folders.value); }); const selectedFolder = computed(() => { if (!selectedFolderId.value) return null; return findContainer(selectedFolderId.value, folders.value); }); const selectedFile = computed(() => { if (!selectedFileId.value || !rootFolder.value?.items) return null; return findItem(selectedFileId.value, rootFolder.value.items); }); function init() { console.log(`initializing the folderStore`); folders.value = []; rootFolder.value = null; selectedFolderId.value = null; selectedFileId.value = null; } async function fetchSubtree(rootFolderId) { const tree = await api.call(`containers/${rootFolderId}/`); folders.value = tree.children; rootFolder.value = tree; } async function fetchUserFolders() { folders.value = await api.call(`users/folders`); rootFolder.value = null; } async function goToRootFolder(folderId) { if (folderId) await fetchSubtree(folderId); else { await fetchUserFolders(); selectedFolderId.value = null; selectedFileId.value = null; } } function setSelectedFolder(folderId) { selectedFolderId.value = folderId; selectedFileId.value = null; } async function setSelectedFile(itemId) { selectedFolderId.value = null; selectedFileId.value = itemId; } async function createFolder(name = "Default", parentId, shareOnly = false) { if (rootFolder.value) parentId = rootFolder.value.id; const containerResponse = await api.call(`containers`, { name, type: CONTAINER_TYPE.FOLDER, parentId, shareOnly }, "POST"); if (containerResponse?.container) { const { container } = containerResponse; try { await keychain.newKeyForContainer(container.id); await backupKeys(keychain, api, msg); await keychain.store(); folders.value = [...folders.value, container]; return container; } catch (error) { console.error(`Failed to set up key for container ${container.id}, rolling back`, error); try { await api.call(`containers/${container.id}`, {}, "DELETE"); } catch (deleteError) { console.error("Failed to roll back container creation", deleteError); } return null; } } return null; } async function renameFolder(folderId, name) { const result = await api.call(`containers/${folderId}/rename`, { name }, "POST"); if (result) { const node = findContainer(folderId, folders.value); if (node) node.name = result.name; } return result; } async function renameItem(folderId, itemId, name) { const result = await api.call(`containers/${folderId}/item/${itemId}/rename`, { name }, "POST"); if (result && rootFolder.value?.items) { const node = findItem(itemId, rootFolder.value.items); if (node) node.name = result.name; } return result; } async function uploadItem(fileBlob, folderId, api) { progress.error = ""; if (!user.id) { console.warn("uploadItem: user.id missing; re-populating from backend"); await populateFromBackend(); } if (!user.id) { progress.error = "You are not fully signed in. Please sign in again."; throw new Error("Cannot upload: user session is missing a user id (ownerId would be empty)."); } const canUpload = await checkBlobSize(fileBlob); if (await canUserUpload(fileBlob.size)) { progress.error = CLIENT_MESSAGES.STORAGE_LIMIT_EXCEEDED; alert(`Error uploading ${fileBlob.name}; ${CLIENT_MESSAGES.STORAGE_LIMIT_EXCEEDED}`); throw new Error("Uploading this file would exceed your storage limit."); } if (!canUpload) { progress.error = CLIENT_MESSAGES.FILE_TOO_BIG; throw new Error("Too big"); } const formattedBlob = await formatBlob(fileBlob); progress.setFileName(formattedBlob.name); try { const newItems = await uploader.doUpload(formattedBlob, folderId, api, progress); if (!newItems || newItems.length === 0) throw new Error(`Upload failed for ${formattedBlob.name}`); if (rootFolder.value) rootFolder.value.items = [...rootFolder.value.items, ...newItems]; return newItems; } catch (error) { console.error("Upload failed in uploadItem:", error); const message = error instanceof Error ? error.message : "Unknown error"; progress.error = message; progress.setProcessStage("error"); throw new Error(`Upload failed: ${message}`); } } async function deleteFolder(folderId) { if ((await api.call(`containers/${folderId}`, {}, "DELETE"))?.result.length > 0) folders.value = [...folders.value.filter((f) => f.id !== folderId)]; } async function deleteItem(itemId, folderId) { const result = await api.call(`containers/${folderId}/item/${itemId}`, { shouldDeleteContent: true }, "DELETE"); if (result) { if (selectedFileId.value === itemId) setSelectedFile(null); if (rootFolder.value?.items) { const deletedKey = result.wrappedKey; rootFolder.value.items = [...rootFolder.value.items.filter((i) => i.wrappedKey !== deletedKey)]; } } } /** * Memory-Optimized Multipart Download Implementation * * This implementation replaces the previous memory-intensive approach that loaded all file pieces * into ArrayBuffer objects simultaneously. The key improvements include: * * 1. **Streaming Processing**: Each piece is processed as a stream, reducing peak memory usage * 2. **Sequential Download**: Pieces are downloaded and processed one at a time rather than all at once * 3. **Chunked Output**: Large pieces are streamed in 64KB chunks to prevent memory spikes * 4. **Progressive Enhancement**: Uses File System Access API when available for true streaming saves * 5. **Efficient Concatenation**: Combines pieces using ReadableStream without intermediate buffers * * For a 2GB file split into 10 pieces: * - Old approach: ~4GB+ peak memory usage (original + combined + intermediate buffers) * - New approach: ~200MB peak memory usage (single piece + processing overhead) */ async function downloadMultipart(upload, containerId, wrappedKeyStr, name, api, keychain, progressTracker) { const isBucketStorage = api.isBucketStorage; let combinedType = ""; const _uploads = await api.call(`uploads/${upload.at(0).id}/parts`); const wrappingKey = await keychain.get(containerId); if (!wrappingKey) throw new Error("Wrapping key not found"); const contentKey = await keychain.container.unwrapContentKey(wrappedKeyStr, wrappingKey); const validMetadata = (await Promise.all(_uploads.map(async ({ id, part }) => { if (!id) return null; const { size, type } = await api.call(`uploads/${id}/metadata`); if (!size) return null; if (!combinedType && type) combinedType = type; return { id, part, size, type }; }))).filter((meta) => meta !== null); if (validMetadata.length === 0) throw new Error("No valid pieces found"); const sortedMetadata = validMetadata.sort((a, b) => a.part - b.part); const totalSize = sortedMetadata.reduce((sum, meta) => sum + meta.size, 0); progressTracker.setUploadSize(totalSize); progressTracker.setProcessStage("downloading"); progressTracker.setText("Downloading file"); const multipartTracker = createMultipartDownloadProgressTracker(progressTracker, sortedMetadata, sortedMetadata.length > 1); const createPieceStream = async (metadata, partTracker) => { let downloadedBlob; if (!isBucketStorage) { downloadedBlob = await _download({ id: metadata.id, progressTracker: partTracker }); if (!downloadedBlob) throw new Error("DOWNLOAD_FAILED"); } else { const bucketResponse = await api.call(`download/${metadata.id}/signed`); if (!bucketResponse?.url) throw new Error("BUCKET_URL_NOT_FOUND"); downloadedBlob = await _download({ url: bucketResponse.url, progressTracker: partTracker }); } let pieceStream; if (contentKey) pieceStream = decryptStream(blobStream(downloadedBlob), contentKey); else pieceStream = blobStream(downloadedBlob); return new ReadableStream({ async start(controller) { const reader = pieceStream.getReader(); const chunks = []; let totalSize = 0; try { while (true) { const { done, value } = await reader.read(); if (done) break; chunks.push(value); totalSize += value.length; } const pieceBuffer = new Uint8Array(totalSize); let offset = 0; for (const chunk of chunks) { pieceBuffer.set(chunk, offset); offset += chunk.length; } const { content: unzippedContent } = await unzipMultipartPiece(pieceBuffer.buffer); const chunkSize = 64 * 1024; const unzippedView = new Uint8Array(unzippedContent); for (let i = 0; i < unzippedView.length; i += chunkSize) { const chunk = unzippedView.slice(i, i + chunkSize); controller.enqueue(chunk); } controller.close(); } catch (error) { controller.error(error); } } }); }; return await _saveFileStream({ stream: new ReadableStream({ async start(controller) { try { for (let index = 0; index < sortedMetadata.length; index++) { const metadata = sortedMetadata[index]; const reader = (await createPieceStream(metadata, multipartTracker.getPartTracker(index))).getReader(); while (true) { const { done, value } = await reader.read(); if (done) break; controller.enqueue(value); } multipartTracker.markPartComplete(index); } controller.close(); } catch (error) { controller.error(error); } } }), name: decodeURIComponent(name), type: combinedType }); } async function downloadContent(uploadId, containerId, wrappedKeyStr, name) { return await downloader.doDownload(uploadId, containerId, wrappedKeyStr, name, metrics, progress); } function print() { console.log(`rootFolder: ${rootFolder.value}`); console.log(`defaultFolder: ${defaultFolder.value}`); console.log(`visibleFolders: ${visibleFolders.value}`); console.log(`selectedFolder: ${selectedFolder.value}`); console.log(`selectedFile: ${selectedFile.value}`); } /** * Creates a multipart download progress tracker that manages overall progress across all parts */ function createMultipartDownloadProgressTracker(mainTracker, metadata, isMultipart) { const partSizes = metadata.map((meta) => meta.size); const totalSize = partSizes.reduce((sum, size) => sum + size, 0); let completedParts = 0; return { getPartTracker: (partIndex) => { const partSize = partSizes[partIndex]; return { total: mainTracker.total, progressed: mainTracker.progressed, percentage: mainTracker.percentage, error: mainTracker.error, text: mainTracker.text, fileName: mainTracker.fileName, processStage: mainTracker.processStage, initialize: () => {}, setUploadSize: () => {}, setFileName: (name) => { mainTracker.setFileName(name); }, setProcessStage: (stage) => { mainTracker.setProcessStage(stage); }, setText: (message) => { if (isMultipart) if (message.includes("Downloading")) mainTracker.setText("Downloading file"); else if (message.includes("Decrypting")) mainTracker.setText("Decrypting file"); else mainTracker.setText(message); else mainTracker.setText(message); }, setProgress: (partProgress) => { const overallProgress = completedParts / metadata.length * totalSize + Math.min(partProgress / partSize, 1) * (totalSize / metadata.length); mainTracker.setProgress(Math.min(overallProgress, totalSize)); } }; }, markPartComplete: (partIndex) => { completedParts = partIndex + 1; const progress = completedParts / metadata.length * totalSize; mainTracker.setProgress(progress); } }; } return { rootFolder: computed(() => { const rootFolderValue = rootFolder.value; if (!rootFolderValue) return null; return { ...rootFolderValue, items: organizeFiles(rootFolderValue?.items || []) }; }), defaultFolder: computed(() => { const defaultFolderValue = defaultFolder.value; if (!defaultFolderValue) return null; return defaultFolderValue ? { ...defaultFolderValue, items: organizeFiles(defaultFolderValue.items || []) } : null; }), visibleFolders: computed(() => visibleFolders.value), selectedFolder: computed(() => selectedFolder.value), selectedFile: computed(() => { if (!selectedFileId.value || !rootFolder.value?.items) return null; return organizeFiles([selectedFile.value])[0] || null; }), rootFolderId: computed(() => rootFolderId.value), getDefaultFolderId, print, init, fetchSubtree, fetchUserFolders, goToRootFolder, sync: async () => await goToRootFolder(null), setSelectedFolder, setSelectedFile, createFolder, renameFolder, deleteFolder, renameItem, uploadItem, deleteItem, downloadContent, downloadMultipart }; }); function calculateFolderSizes(folders) { return folders.map((folder) => { folder.size = folder.items?.reduce((total, { upload }) => total + upload?.size || 0, 0) || 0; return folder; }); } function findContainer(id, containers) { if (!containers) return null; return containers.find((container) => container.id === id) || null; } function findItem(id, items) { if (!items) return null; return items.find((item) => item.id === id) || null; } //#endregion //#region ../send/frontend/src/lib/challenge.ts async function getContainerKeyFromChallenge(hash, password, api, keychain) { const resp = await api.call(`sharing/${hash}/challenge`); if (!resp) return null; const { challengeKey: challengeKeyStr, challengeSalt: challengeSaltStr, challengeCiphertext } = resp; let challengeSalt; try { challengeSalt = Util.base64ToArrayBuffer(challengeSaltStr); } catch (e) { return null; } try { const unwrappedChallengeKey = await keychain.password.unwrapContentKey(challengeKeyStr, password, challengeSalt); const challengePlaintext = await keychain.challenge.decryptChallenge(challengeCiphertext, unwrappedChallengeKey, challengeSalt); const challengeResp = await api.call(`sharing/${hash}/challenge`, { challengePlaintext }, "POST"); if (!challengeResp.containerId) throw Error("Challenge unsuccessful"); const { containerId, wrappedKey: wrappedKeyStr, salt: saltStr } = challengeResp; return { unwrappedKey: await keychain.password.unwrapContainerKey(wrappedKeyStr, password, Util.base64ToArrayBuffer(saltStr)), containerId }; } catch (e) { console.log(e); return null; } } //#endregion //#region ../send/frontend/src/lib/share.ts var Sharer = class { constructor(user, keychain, api) { this.user = user; this.keychain = keychain; this.api = api; } async handleMultipartItems(item) { const ids = (await this.api.call(`uploads/parts`, { wrappedKey: item.wrappedKey }, "POST")).map((u) => u.id); console.log(`ids:`, ids); const _items = await this.api.call(`uploads/items`, { ids, wrappedKey: item.wrappedKey }, "POST"); console.log(`_items:`, _items); return _items; } async shareItemsWithPassword(items, password, expiration) { const __items = []; for (const item of items) if (item.multipart) { const _items = await this.handleMultipartItems(item); __items.push(..._items); } else __items.push(item); const containerId = await this.createShareOnlyContainer(__items, null); return await this.requestAccessLink(containerId, password, expiration); } async shareContainerWithInvitation(containerId, email) { const user = await this.api.call(`users/lookup/${email}/`); if (user) { let publicKey = user.publicKey; const recipientId = user.id; if (!publicKey) console.log(`Could not find public key for user ${email}`); console.warn("SOMETHING WEIRD IS HAPPENING WITH PUBLIC KEYS ON SERVER"); while (typeof publicKey !== "object") publicKey = JSON.parse(publicKey); const importedPublicKey = await crypto.subtle.importKey("jwk", publicKey, { name: "RSA-OAEP", hash: { name: "SHA-256" } }, true, ["wrapKey"]); const key = await this.keychain.get(containerId); const wrappedKey = await this.keychain.rsa.wrapContainerKey(key, importedPublicKey); if (!wrappedKey) { console.log(`no wrapped key for the invitation`); return null; } const resp = await this.api.call(`containers/${containerId}/member/invite`, { wrappedKey, recipientId, senderId: this.user.id }, "POST"); console.log(`Invitation creation response:`); console.log(resp); return resp; } } async createShareOnlyContainer(items = [], containerId = null) { if (items.length === 0 && !containerId) return null; if (!this.api?.call || !this.keychain?.store) return null; const itemsToShare = [...items]; let currentContainer = { name: "default" }; if (containerId) currentContainer = await this.api.call(`containers/${containerId}/info`); const response = await this.api.call(`containers`, { name: currentContainer.name, type: CONTAINER_TYPE.FOLDER, parentId: 0, shareOnly: true }, "POST"); if (!response.container?.id) return null; const { id: newContainerId } = response.container; await this.keychain.newKeyForContainer(newContainerId); await this.keychain.store(); await Promise.all(itemsToShare.map(async (item) => { const containerId = item.containerId ?? item.folderId; const filename = item.name ?? item.filename; const currentWrappingKey = await this.keychain.get(containerId); const { uploadId, wrappedKey, type } = item; const contentKey = await this.keychain.container.unwrapContentKey(wrappedKey, currentWrappingKey); const newWrappingKey = await this.keychain.get(newContainerId); const wrappedKeyStr = await this.keychain.container.wrapContentKey(contentKey, newWrappingKey); return await this.api.call(`containers/${newContainerId}/item`, { uploadId, name: filename, type, wrappedKey: wrappedKeyStr, multipart: item.multipart ?? false, totalSize: item.totalSize ?? void 0 }, "POST"); })); return newContainerId; } async requestAccessLink(containerId, password, expiration) { if (!(await this.api.call(`sharing/${containerId}/canCreateAccessLink`))?.canCreateLink) throw new Error("Cannot create access link for this container because it contains files that have been reported for abuse."); const unwrappedKey = await this.keychain.get(containerId); const salt = Util.generateSalt(); const passwordWrappedKeyStr = await this.keychain.password.wrapContainerKey(unwrappedKey, password, salt); const challengeKey = await this.keychain.challenge.generateKey(); const challengeSalt = Util.generateSalt(); const passwordWrappedChallengeKeyStr = await this.keychain.password.wrapContentKey(challengeKey, password, challengeSalt); const challengePlaintext = this.keychain.challenge.createChallenge(); const challengeCiphertext = await this.keychain.challenge.encryptChallenge(challengePlaintext, challengeKey, challengeSalt); const saltStr = Util.arrayBufferToBase64(salt); const challengeSaltStr = Util.arrayBufferToBase64(challengeSalt); const resp = await this.api.call(`sharing`, { containerId, wrappedKey: passwordWrappedKeyStr, salt: saltStr, challengeKey: passwordWrappedChallengeKeyStr, challengeSalt: challengeSaltStr, senderId: this.user.id, challengePlaintext, challengeCiphertext, expiration }, "POST"); if (!resp?.id) return null; return `https://send.tb.pro/share/${resp.id}`; } }; defineStore("sharingManager", () => { const { api } = useApiStore(); const { user } = useUserStore(); const { keychain } = useKeychainStore(); const sharer = new Sharer(user, keychain, api); const _links = /* @__PURE__ */ ref([]); const links = computed(() => { return [..._links.value]; }); async function createAccessLink(folderId, password, expiration) { let shouldAddPasswordAsHash = false; if (password.length === 0) { password = Util.generateRandomPassword(); shouldAddPasswordAsHash = true; } let url = await sharer.requestAccessLink(folderId, password, expiration); if (!url) return null; if (shouldAddPasswordAsHash) url = `${url}#${password}`; return url; } async function acceptAccessLink(linkId, password) { const containerKey = await getContainerKeyFromChallenge(linkId, password, api, keychain); if (!containerKey?.unwrappedKey) { await trpc.incrementPasswordRetryCount.mutate({ linkId }); return false; } const { unwrappedKey, containerId } = containerKey; await keychain.rsa.generateKeyPair(); await keychain.add(containerId, unwrappedKey); await keychain.store(); return true; } async function isAccessLinkValid(linkId) { return await api.call(`sharing/exists/${linkId}`); } async function fetchFolderAccessLinks(folderId) { _links.value = await api.call(`containers/${folderId}/links`); } async function fetchFileAccessLinks(uploadId) { _links.value = await api.call(`sharing/${uploadId}/links?type=file`); } async function shareItems(itemsArray, password, expiration) { let shouldAddPasswordAsHash = false; if (password.length === 0) { password = Util.generateRandomPassword(); shouldAddPasswordAsHash = true; } let url = await sharer.shareItemsWithPassword(itemsArray, password, expiration); if (!url) return null; if (shouldAddPasswordAsHash) url = `${url}#${password}`; return url; } async function getSharedFolder(hash) { return await api.call(`sharing/${hash}/`); } async function getInvitations(userId) { return await api.call(`users/${userId}/invitations/`); } async function getFoldersSharedWithUser(userId) { return await api.call(`users/${userId}/folders/sharedWithUser`); } async function getFoldersSharedByUser(userId) { return await api.call(`users/${userId}/folders/sharedByUser`); } async function getSharesForFolder(containerId, userId) { return await api.call(`containers/${containerId}/shares`, { userId }); } async function acceptInvitation(invitationId, containerId) { return await api.call(`containers/${containerId}/member/accept/${invitationId}`, {}, "POST"); } async function updateInvitationPermissions(containerId, userId, invitationId, permission) { return await api.call(`containers/${containerId}/shares/invitation/update`, { userId, invitationId, permission }, "POST"); } async function updateAccessLinkPermissions(containerId, userId, accessLinkId, permission) { return await api.call(`containers/${containerId}/shares/accessLink/update`, { userId, accessLinkId, permission }, "POST"); } return { links, createAccessLink, isAccessLinkValid, acceptAccessLink, fetchFolderAccessLinks, fetchFileAccessLinks, shareItems, getSharedFolder, getInvitations, getFoldersSharedWithUser, getFoldersSharedByUser, getSharesForFolder, acceptInvitation, updateInvitationPermissions, updateAccessLinkPermissions }; }); //#endregion //#region ../../node_modules/.pnpm/jwt-decode@4.0.0/node_modules/jwt-decode/build/esm/index.js var InvalidTokenError = class extends Error {}; InvalidTokenError.prototype.name = "InvalidTokenError"; function b64DecodeUnicode(str) { return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => { let code = p.charCodeAt(0).toString(16).toUpperCase(); if (code.length < 2) code = "0" + code; return "%" + code; })); } function base64UrlDecode(str) { let output = str.replace(/-/g, "+").replace(/_/g, "/"); switch (output.length % 4) { case 0: break; case 2: output += "=="; break; case 3: output += "="; break; default: throw new Error("base64 string is not of the correct length"); } try { return b64DecodeUnicode(output); } catch (err) { return atob(output); } } function jwtDecode(token, options) { if (typeof token !== "string") throw new InvalidTokenError("Invalid token specified: must be a string"); options || (options = {}); const pos = options.header === true ? 0 : 1; const part = token.split(".")[pos]; if (typeof part !== "string") throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`); let decoded; try { decoded = base64UrlDecode(part); } catch (e) { throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`); } try { return JSON.parse(decoded); } catch (e) { throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`); } } //#endregion //#region ../../node_modules/.pnpm/oidc-client-ts@3.5.0/node_modules/oidc-client-ts/dist/esm/oidc-client-ts.js var nopLogger = { debug: () => void 0, info: () => void 0, warn: () => void 0, error: () => void 0 }; var level; var logger; var Log = /* @__PURE__ */ ((Log2) => { Log2[Log2["NONE"] = 0] = "NONE"; Log2[Log2["ERROR"] = 1] = "ERROR"; Log2[Log2["WARN"] = 2] = "WARN"; Log2[Log2["INFO"] = 3] = "INFO"; Log2[Log2["DEBUG"] = 4] = "DEBUG"; return Log2; })(Log || {}); ((Log2) => { function reset() { level = 3; logger = nopLogger; } Log2.reset = reset; function setLevel(value) { if (!(0 <= value && value <= 4)) throw new Error("Invalid log level"); level = value; } Log2.setLevel = setLevel; function setLogger(value) { logger = value; } Log2.setLogger = setLogger; })(Log || (Log = {})); var Logger = class _Logger { constructor(_name) { this._name = _name; } debug(...args) { if (level >= 4) logger.debug(_Logger._format(this._name, this._method), ...args); } info(...args) { if (level >= 3) logger.info(_Logger._format(this._name, this._method), ...args); } warn(...args) { if (level >= 2) logger.warn(_Logger._format(this._name, this._method), ...args); } error(...args) { if (level >= 1) logger.error(_Logger._format(this._name, this._method), ...args); } throw(err) { this.error(err); throw err; } create(method) { const methodLogger = Object.create(this); methodLogger._method = method; methodLogger.debug("begin"); return methodLogger; } static createStatic(name, staticMethod) { const staticLogger = new _Logger(`${name}.${staticMethod}`); staticLogger.debug("begin"); return staticLogger; } static _format(name, method) { const prefix = `[${name}]`; return method ? `${prefix} ${method}:` : prefix; } static debug(name, ...args) { if (level >= 4) logger.debug(_Logger._format(name), ...args); } static info(name, ...args) { if (level >= 3) logger.info(_Logger._format(name), ...args); } static warn(name, ...args) { if (level >= 2) logger.warn(_Logger._format(name), ...args); } static error(name, ...args) { if (level >= 1) logger.error(_Logger._format(name), ...args); } }; Log.reset(); var JwtUtils = class { static decode(token) { try { return jwtDecode(token); } catch (err) { Logger.error("JwtUtils.decode", err); throw err; } } static async generateSignedJwt(header, payload, privateKey) { const encodedToken = `${CryptoUtils.encodeBase64Url(new TextEncoder().encode(JSON.stringify(header)))}.${CryptoUtils.encodeBase64Url(new TextEncoder().encode(JSON.stringify(payload)))}`; const signature = await window.crypto.subtle.sign({ name: "ECDSA", hash: { name: "SHA-256" } }, privateKey, new TextEncoder().encode(encodedToken)); return `${encodedToken}.${CryptoUtils.encodeBase64Url(new Uint8Array(signature))}`; } static async generateSignedJwtWithHmac(header, payload, secretKey) { const encodedToken = `${CryptoUtils.encodeBase64Url(new TextEncoder().encode(JSON.stringify(header)))}.${CryptoUtils.encodeBase64Url(new TextEncoder().encode(JSON.stringify(payload)))}`; const signature = await window.crypto.subtle.sign("HMAC", secretKey, new TextEncoder().encode(encodedToken)); return `${encodedToken}.${CryptoUtils.encodeBase64Url(new Uint8Array(signature))}`; } }; var UUID_V4_TEMPLATE = "10000000-1000-4000-8000-100000000000"; var toBase64 = (val) => btoa([...new Uint8Array(val)].map((chr) => String.fromCharCode(chr)).join("")); var _CryptoUtils = class _CryptoUtils { static _randomWord() { const arr = new Uint32Array(1); crypto.getRandomValues(arr); return arr[0]; } /** * Generates RFC4122 version 4 guid */ static generateUUIDv4() { return UUID_V4_TEMPLATE.replace(/[018]/g, (c) => (+c ^ _CryptoUtils._randomWord() & 15 >> +c / 4).toString(16)).replace(/-/g, ""); } /** * PKCE: Generate a code verifier */ static generateCodeVerifier() { return _CryptoUtils.generateUUIDv4() + _CryptoUtils.generateUUIDv4() + _CryptoUtils.generateUUIDv4(); } /** * PKCE: Generate a code challenge */ static async generateCodeChallenge(code_verifier) { if (!crypto.subtle) throw new Error("Crypto.subtle is available only in secure contexts (HTTPS)."); try { const data = new TextEncoder().encode(code_verifier); return toBase64(await crypto.subtle.digest("SHA-256", data)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); } catch (err) { Logger.error("CryptoUtils.generateCodeChallenge", err); throw err; } } /** * Generates a base64-encoded string for a basic auth header */ static generateBasicAuth(client_id, client_secret) { return toBase64(new TextEncoder().encode([client_id, client_secret].join(":"))); } /** * Generates a hash of a string using a given algorithm * @param alg * @param message */ static async hash(alg, message) { const msgUint8 = new TextEncoder().encode(message); const hashBuffer = await crypto.subtle.digest(alg, msgUint8); return new Uint8Array(hashBuffer); } /** * Generates a rfc7638 compliant jwk thumbprint * @param jwk */ static async customCalculateJwkThumbprint(jwk) { let jsonObject; switch (jwk.kty) { case "RSA": jsonObject = { "e": jwk.e, "kty": jwk.kty, "n": jwk.n }; break; case "EC": jsonObject = { "crv": jwk.crv, "kty": jwk.kty, "x": jwk.x, "y": jwk.y }; break; case "OKP": jsonObject = { "crv": jwk.crv, "kty": jwk.kty, "x": jwk.x }; break; case "oct": jsonObject = { "crv": jwk.k, "kty": jwk.kty }; break; default: throw new Error("Unknown jwk type"); } const utf8encodedAndHashed = await _CryptoUtils.hash("SHA-256", JSON.stringify(jsonObject)); return _CryptoUtils.encodeBase64Url(utf8encodedAndHashed); } static async generateDPoPProof({ url, accessToken, httpMethod, keyPair, nonce }) { let hashedToken; let encodedHash; const payload = { "jti": window.crypto.randomUUID(), "htm": httpMethod != null ? httpMethod : "GET", "htu": url, "iat": Math.floor(Date.now() / 1e3) }; if (accessToken) { hashedToken = await _CryptoUtils.hash("SHA-256", accessToken); encodedHash = _CryptoUtils.encodeBase64Url(hashedToken); payload.ath = encodedHash; } if (nonce) payload.nonce = nonce; try { const publicJwk = await crypto.subtle.exportKey("jwk", keyPair.publicKey); const header = { "alg": "ES256", "typ": "dpop+jwt", "jwk": { "crv": publicJwk.crv, "kty": publicJwk.kty, "x": publicJwk.x, "y": publicJwk.y } }; return await JwtUtils.generateSignedJwt(header, payload, keyPair.privateKey); } catch (err) { if (err instanceof TypeError) throw new Error(`Error exporting dpop public key: ${err.message}`); else throw err; } } static async generateDPoPJkt(keyPair) { try { const publicJwk = await crypto.subtle.exportKey("jwk", keyPair.publicKey); return await _CryptoUtils.customCalculateJwkThumbprint(publicJwk); } catch (err) { if (err instanceof TypeError) throw new Error(`Could not retrieve dpop keys from storage: ${err.message}`); else throw err; } } static async generateDPoPKeys() { return await window.crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, false, ["sign", "verify"]); } /** * Generates a client assertion JWT for client_secret_jwt authentication * @param client_id The client identifier * @param client_secret The client secret * @param audience The token endpoint URL (audience) * @param algorithm The HMAC algorithm to use (HS256, HS384, HS512). Defaults to HS256 */ static async generateClientAssertionJwt(client_id, client_secret, audience, algorithm = "HS256") { const now = Math.floor(Date.now() / 1e3); const header = { "alg": algorithm, "typ": "JWT" }; const payload = { "iss": client_id, "sub": client_id, "aud": audience, "jti": _CryptoUtils.generateUUIDv4(), "exp": now + 300, "iat": now }; const hashFunction = { "HS256": "SHA-256", "HS384": "SHA-384", "HS512": "SHA-512" }[algorithm]; if (!hashFunction) throw new Error(`Unsupported algorithm: ${algorithm}. Supported algorithms are: HS256, HS384, HS512`); const encoder = new TextEncoder(); const secretKey = await crypto.subtle.importKey("raw", encoder.encode(client_secret), { name: "HMAC", hash: hashFunction }, false, ["sign"]); return await JwtUtils.generateSignedJwtWithHmac(header, payload, secretKey); } }; /** * Generates a base64url encoded string */ _CryptoUtils.encodeBase64Url = (input) => { return toBase64(input).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_"); }; var CryptoUtils = _CryptoUtils; var Event$1 = class { constructor(_name) { this._name = _name; this._callbacks = []; this._logger = new Logger(`Event('${this._name}')`); } addHandler(cb) { this._callbacks.push(cb); return () => this.removeHandler(cb); } removeHandler(cb) { const idx = this._callbacks.lastIndexOf(cb); if (idx >= 0) this._callbacks.splice(idx, 1); } async raise(...ev) { this._logger.debug("raise:", ...ev); for (const cb of this._callbacks) await cb(...ev); } }; var PopupUtils = class { /** * Populates a map of window features with a placement centered in front of * the current window. If no explicit width is given, a default value is * binned into [800, 720, 600, 480, 360] based on the current window's width. */ static center({ ...features }) { var _a; if (features.width == null) features.width = (_a = [ 800, 720, 600, 480 ].find((width) => width <= window.outerWidth / 1.618)) != null ? _a : 360; features.left ??= Math.max(0, Math.round(window.screenX + (window.outerWidth - features.width) / 2)); if (features.height != null) features.top ??= Math.max(0, Math.round(window.screenY + (window.outerHeight - features.height) / 2)); return features; } static serialize(features) { return Object.entries(features).filter(([, value]) => value != null).map(([key, value]) => `${key}=${typeof value !== "boolean" ? value : value ? "yes" : "no"}`).join(","); } }; var Timer = class _Timer extends Event$1 { constructor() { super(...arguments); this._logger = new Logger(`Timer('${this._name}')`); this._timerHandle = null; this._expiration = 0; this._callback = () => { const diff = this._expiration - _Timer.getEpochTime(); this._logger.debug("timer completes in", diff); if (this._expiration <= _Timer.getEpochTime()) { this.cancel(); super.raise(); } }; } static getEpochTime() { return Math.floor(Date.now() / 1e3); } init(durationInSeconds) { const logger2 = this._logger.create("init"); durationInSeconds = Math.max(Math.floor(durationInSeconds), 1); const expiration = _Timer.getEpochTime() + durationInSeconds; if (this.expiration === expiration && this._timerHandle) { logger2.debug("skipping since already initialized for expiration at", this.expiration); return; } this.cancel(); logger2.debug("using duration", durationInSeconds); this._expiration = expiration; const timerDurationInSeconds = Math.min(durationInSeconds, 5); this._timerHandle = setInterval(this._callback, timerDurationInSeconds * 1e3); } get expiration() { return this._expiration; } cancel() { this._logger.create("cancel"); if (this._timerHandle) { clearInterval(this._timerHandle); this._timerHandle = null; } } }; var UrlUtils = class { static readParams(url, responseMode = "query") { if (!url) throw new TypeError("Invalid URL"); const params = new URL(url, "http://127.0.0.1")[responseMode === "fragment" ? "hash" : "search"]; return new URLSearchParams(params.slice(1)); } }; var URL_STATE_DELIMITER = ";"; var ErrorResponse = class extends Error { constructor(args, form) { var _a, _b, _c; super(args.error_description || args.error || ""); this.form = form; /** Marker to detect class: "ErrorResponse" */ this.name = "ErrorResponse"; if (!args.error) { Logger.error("ErrorResponse", "No error passed"); throw new Error("No error passed"); } this.error = args.error; this.error_description = (_a = args.error_description) != null ? _a : null; this.error_uri = (_b = args.error_uri) != null ? _b : null; this.state = args.userState; this.session_state = (_c = args.session_state) != null ? _c : null; this.url_state = args.url_state; } }; var ErrorTimeout = class extends Error { constructor(message) { super(message); /** Marker to detect class: "ErrorTimeout" */ this.name = "ErrorTimeout"; } }; var AccessTokenEvents = class { constructor(args) { this._logger = new Logger("AccessTokenEvents"); this._expiringTimer = new Timer("Access token expiring"); this._expiredTimer = new Timer("Access token expired"); this._expiringNotificationTimeInSeconds = args.expiringNotificationTimeInSeconds; } async load(container) { const logger2 = this._logger.create("load"); if (container.access_token && container.expires_in !== void 0) { const duration = container.expires_in; logger2.debug("access token present, remaining duration:", duration); if (duration > 0) { let expiring = duration - this._expiringNotificationTimeInSeconds; if (expiring <= 0) expiring = 1; logger2.debug("registering expiring timer, raising in", expiring, "seconds"); this._expiringTimer.init(expiring); } else { logger2.debug("canceling existing expiring timer because we're past expiration."); this._expiringTimer.cancel(); } const expired = duration + 1; logger2.debug("registering expired timer, raising in", expired, "seconds"); this._expiredTimer.init(expired); } else { this._expiringTimer.cancel(); this._expiredTimer.cancel(); } } async unload() { this._logger.debug("unload: canceling existing access token timers"); this._expiringTimer.cancel(); this._expiredTimer.cancel(); } /** * Add callback: Raised prior to the access token expiring. */ addAccessTokenExpiring(cb) { return this._expiringTimer.addHandler(cb); } /** * Remove callback: Raised prior to the access token expiring. */ removeAccessTokenExpiring(cb) { this._expiringTimer.removeHandler(cb); } /** * Add callback: Raised after the access token has expired. */ addAccessTokenExpired(cb) { return this._expiredTimer.addHandler(cb); } /** * Remove callback: Raised after the access token has expired. */ removeAccessTokenExpired(cb) { this._expiredTimer.removeHandler(cb); } }; var CheckSessionIFrame = class { constructor(_callback, _client_id, url, _intervalInSeconds, _stopOnError) { this._callback = _callback; this._client_id = _client_id; this._intervalInSeconds = _intervalInSeconds; this._stopOnError = _stopOnError; this._logger = new Logger("CheckSessionIFrame"); this._timer = null; this._session_state = null; this._message = (e) => { if (e.origin === this._frame_origin && e.source === this._frame.contentWindow) if (e.data === "error") { this._logger.error("error message from check session op iframe"); if (this._stopOnError) this.stop(); } else if (e.data === "changed") { this._logger.debug("changed message from check session op iframe"); this.stop(); this._callback(); } else this._logger.debug(e.data + " message from check session op iframe"); }; const parsedUrl = new URL(url); this._frame_origin = parsedUrl.origin; this._frame = window.document.createElement("iframe"); this._frame.style.visibility = "hidden"; this._frame.style.position = "fixed"; this._frame.style.left = "-1000px"; this._frame.style.top = "0"; this._frame.width = "0"; this._frame.height = "0"; this._frame.src = parsedUrl.href; } load() { return new Promise((resolve) => { this._frame.onload = () => { resolve(); }; window.document.body.appendChild(this._frame); window.addEventListener("message", this._message, false); }); } start(session_state) { if (this._session_state === session_state) return; this._logger.create("start"); this.stop(); this._session_state = session_state; const send = () => { if (!this._frame.contentWindow || !this._session_state) return; this._frame.contentWindow.postMessage(this._client_id + " " + this._session_state, this._frame_origin); }; send(); this._timer = setInterval(send, this._intervalInSeconds * 1e3); } stop() { this._logger.create("stop"); this._session_state = null; if (this._timer) { clearInterval(this._timer); this._timer = null; } } }; var InMemoryWebStorage = class { constructor() { this._logger = new Logger("InMemoryWebStorage"); this._data = {}; } clear() { this._logger.create("clear"); this._data = {}; } getItem(key) { this._logger.create(`getItem('${key}')`); return this._data[key]; } setItem(key, value) { this._logger.create(`setItem('${key}')`); this._data[key] = value; } removeItem(key) { this._logger.create(`removeItem('${key}')`); delete this._data[key]; } get length() { return Object.getOwnPropertyNames(this._data).length; } key(index) { return Object.getOwnPropertyNames(this._data)[index]; } }; var ErrorDPoPNonce = class extends Error { constructor(nonce, message) { super(message); /** Marker to detect class: "ErrorDPoPNonce" */ this.name = "ErrorDPoPNonce"; this.nonce = nonce; } }; var JsonService = class { constructor(additionalContentTypes = [], _jwtHandler = null, _extraHeaders = {}) { this._jwtHandler = _jwtHandler; this._extraHeaders = _extraHeaders; this._logger = new Logger("JsonService"); this._contentTypes = []; this._contentTypes.push(...additionalContentTypes, "application/json"); if (_jwtHandler) this._contentTypes.push("application/jwt"); } async fetchWithTimeout(input, init = {}) { const { timeoutInSeconds, ...initFetch } = init; if (!timeoutInSeconds) return await fetch(input, initFetch); const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), timeoutInSeconds * 1e3); try { return await fetch(input, { ...init, signal: controller.signal }); } catch (err) { if (err instanceof DOMException && err.name === "AbortError") throw new ErrorTimeout("Network timed out"); throw err; } finally { clearTimeout(timeoutId); } } async getJson(url, { token, credentials, timeoutInSeconds } = {}) { const logger2 = this._logger.create("getJson"); const headers = { "Accept": this._contentTypes.join(", ") }; if (token) { logger2.debug("token passed, setting Authorization header"); headers["Authorization"] = "Bearer " + token; } this._appendExtraHeaders(headers); let response; try { logger2.debug("url:", url); response = await this.fetchWithTimeout(url, { method: "GET", headers, timeoutInSeconds, credentials }); } catch (err) { logger2.error("Network Error"); throw err; } logger2.debug("HTTP response received, status", response.status); const contentType = response.headers.get("Content-Type"); if (contentType && !this._contentTypes.find((item) => contentType.startsWith(item))) logger2.throw(/* @__PURE__ */ new Error(`Invalid response Content-Type: ${contentType != null ? contentType : "undefined"}, from URL: ${url}`)); if (response.ok && this._jwtHandler && (contentType == null ? void 0 : contentType.startsWith("application/jwt"))) return await this._jwtHandler(await response.text()); let json; try { json = await response.json(); } catch (err) { logger2.error("Error parsing JSON response", err); if (response.ok) throw err; throw new Error(`${response.statusText} (${response.status})`); } if (!response.ok) { logger2.error("Error from server:", json); if (json.error) throw new ErrorResponse(json); throw new Error(`${response.statusText} (${response.status}): ${JSON.stringify(json)}`); } return json; } async postForm(url, { body, basicAuth, timeoutInSeconds, initCredentials, extraHeaders }) { const logger2 = this._logger.create("postForm"); const headers = { "Accept": this._contentTypes.join(", "), "Content-Type": "application/x-www-form-urlencoded", ...extraHeaders }; if (basicAuth !== void 0) headers["Authorization"] = "Basic " + basicAuth; this._appendExtraHeaders(headers); let response; try { logger2.debug("url:", url); response = await this.fetchWithTimeout(url, { method: "POST", headers, body, timeoutInSeconds, credentials: initCredentials }); } catch (err) { logger2.error("Network error"); throw err; } logger2.debug("HTTP response received, status", response.status); const contentType = response.headers.get("Content-Type"); if (contentType && !this._contentTypes.find((item) => contentType.startsWith(item))) throw new Error(`Invalid response Content-Type: ${contentType != null ? contentType : "undefined"}, from URL: ${url}`); const responseText = await response.text(); let json = {}; if (responseText) try { json = JSON.parse(responseText); } catch (err) { logger2.error("Error parsing JSON response", err); if (response.ok) throw err; throw new Error(`${response.statusText} (${response.status})`); } if (!response.ok) { logger2.error("Error from server:", json); if (response.headers.has("dpop-nonce")) throw new ErrorDPoPNonce(response.headers.get("dpop-nonce"), `${JSON.stringify(json)}`); if (json.error) throw new ErrorResponse(json, body); throw new Error(`${response.statusText} (${response.status}): ${JSON.stringify(json)}`); } return json; } _appendExtraHeaders(headers) { const logger2 = this._logger.create("appendExtraHeaders"); const customKeys = Object.keys(this._extraHeaders); const protectedHeaders = ["accept", "content-type"]; const preventOverride = ["authorization"]; if (customKeys.length === 0) return; customKeys.forEach((headerName) => { if (protectedHeaders.includes(headerName.toLocaleLowerCase())) { logger2.warn("Protected header could not be set", headerName, protectedHeaders); return; } if (preventOverride.includes(headerName.toLocaleLowerCase()) && Object.keys(headers).includes(headerName)) { logger2.warn("Header could not be overridden", headerName, preventOverride); return; } const content = typeof this._extraHeaders[headerName] === "function" ? this._extraHeaders[headerName]() : this._extraHeaders[headerName]; if (content && content !== "") headers[headerName] = content; }); } }; var MetadataService = class { constructor(_settings) { this._settings = _settings; this._logger = new Logger("MetadataService"); this._signingKeys = null; this._metadata = null; this._metadataUrl = this._settings.metadataUrl; this._jsonService = new JsonService(["application/jwk-set+json"], null, this._settings.extraHeaders); if (this._settings.signingKeys) { this._logger.debug("using signingKeys from settings"); this._signingKeys = this._settings.signingKeys; } if (this._settings.metadata) { this._logger.debug("using metadata from settings"); this._metadata = this._settings.metadata; } if (this._settings.fetchRequestCredentials) { this._logger.debug("using fetchRequestCredentials from settings"); this._fetchRequestCredentials = this._settings.fetchRequestCredentials; } } resetSigningKeys() { this._signingKeys = null; } async getMetadata() { const logger2 = this._logger.create("getMetadata"); if (this._metadata) { logger2.debug("using cached values"); return this._metadata; } if (!this._metadataUrl) { logger2.throw(/* @__PURE__ */ new Error("No authority or metadataUrl configured on settings")); throw null; } logger2.debug("getting metadata from", this._metadataUrl); const metadata = await this._jsonService.getJson(this._metadataUrl, { credentials: this._fetchRequestCredentials, timeoutInSeconds: this._settings.requestTimeoutInSeconds }); logger2.debug("merging remote JSON with seed metadata"); this._metadata = Object.assign({}, metadata, this._settings.metadataSeed); return this._metadata; } getIssuer() { return this._getMetadataProperty("issuer"); } getAuthorizationEndpoint() { return this._getMetadataProperty("authorization_endpoint"); } getUserInfoEndpoint() { return this._getMetadataProperty("userinfo_endpoint"); } getTokenEndpoint(optional = true) { return this._getMetadataProperty("token_endpoint", optional); } getCheckSessionIframe() { return this._getMetadataProperty("check_session_iframe", true); } getEndSessionEndpoint() { return this._getMetadataProperty("end_session_endpoint", true); } getRevocationEndpoint(optional = true) { return this._getMetadataProperty("revocation_endpoint", optional); } getKeysEndpoint(optional = true) { return this._getMetadataProperty("jwks_uri", optional); } async _getMetadataProperty(name, optional = false) { const logger2 = this._logger.create(`_getMetadataProperty('${name}')`); const metadata = await this.getMetadata(); logger2.debug("resolved"); if (metadata[name] === void 0) { if (optional === true) { logger2.warn("Metadata does not contain optional property"); return; } logger2.throw(/* @__PURE__ */ new Error("Metadata does not contain property " + name)); } return metadata[name]; } async getSigningKeys() { const logger2 = this._logger.create("getSigningKeys"); if (this._signingKeys) { logger2.debug("returning signingKeys from cache"); return this._signingKeys; } const jwks_uri = await this.getKeysEndpoint(false); logger2.debug("got jwks_uri", jwks_uri); const keySet = await this._jsonService.getJson(jwks_uri, { timeoutInSeconds: this._settings.requestTimeoutInSeconds }); logger2.debug("got key set", keySet); if (!Array.isArray(keySet.keys)) { logger2.throw(/* @__PURE__ */ new Error("Missing keys on keyset")); throw null; } this._signingKeys = keySet.keys; return this._signingKeys; } }; var WebStorageStateStore = class { constructor({ prefix = "oidc.", store = localStorage } = {}) { this._logger = new Logger("WebStorageStateStore"); this._store = store; this._prefix = prefix; } async set(key, value) { this._logger.create(`set('${key}')`); key = this._prefix + key; await this._store.setItem(key, value); } async get(key) { this._logger.create(`get('${key}')`); key = this._prefix + key; return await this._store.getItem(key); } async remove(key) { this._logger.create(`remove('${key}')`); key = this._prefix + key; const item = await this._store.getItem(key); await this._store.removeItem(key); return item; } async getAllKeys() { this._logger.create("getAllKeys"); const len = await this._store.length; const keys = []; for (let index = 0; index < len; index++) { const key = await this._store.key(index); if (key && key.indexOf(this._prefix) === 0) keys.push(key.substr(this._prefix.length)); } return keys; } }; var DefaultResponseType = "code"; var DefaultScope = "openid"; var DefaultClientAuthentication = "client_secret_post"; var DefaultStaleStateAgeInSeconds = 900; var OidcClientSettingsStore = class { constructor({ authority, metadataUrl, metadata, signingKeys, metadataSeed, client_id, client_secret, response_type = DefaultResponseType, scope = DefaultScope, redirect_uri, post_logout_redirect_uri, client_authentication = DefaultClientAuthentication, token_endpoint_auth_signing_alg = "HS256", prompt, display, max_age, ui_locales, acr_values, resource, response_mode, filterProtocolClaims = true, loadUserInfo = false, requestTimeoutInSeconds, staleStateAgeInSeconds = DefaultStaleStateAgeInSeconds, mergeClaimsStrategy = { array: "replace" }, disablePKCE = false, stateStore, revokeTokenAdditionalContentTypes, fetchRequestCredentials, refreshTokenAllowedScope, extraQueryParams = {}, extraTokenParams = {}, extraHeaders = {}, dpop, omitScopeWhenRequesting = false }) { var _a; this.authority = authority; if (metadataUrl) this.metadataUrl = metadataUrl; else { this.metadataUrl = authority; if (authority) { if (!this.metadataUrl.endsWith("/")) this.metadataUrl += "/"; this.metadataUrl += ".well-known/openid-configuration"; } } this.metadata = metadata; this.metadataSeed = metadataSeed; this.signingKeys = signingKeys; this.client_id = client_id; this.client_secret = client_secret; this.response_type = response_type; this.scope = scope; this.redirect_uri = redirect_uri; this.post_logout_redirect_uri = post_logout_redirect_uri; this.client_authentication = client_authentication; this.token_endpoint_auth_signing_alg = token_endpoint_auth_signing_alg; this.prompt = prompt; this.display = display; this.max_age = max_age; this.ui_locales = ui_locales; this.acr_values = acr_values; this.resource = resource; this.response_mode = response_mode; this.filterProtocolClaims = filterProtocolClaims != null ? filterProtocolClaims : true; this.loadUserInfo = !!loadUserInfo; this.staleStateAgeInSeconds = staleStateAgeInSeconds; this.mergeClaimsStrategy = mergeClaimsStrategy; this.omitScopeWhenRequesting = omitScopeWhenRequesting; this.disablePKCE = !!disablePKCE; this.revokeTokenAdditionalContentTypes = revokeTokenAdditionalContentTypes; this.fetchRequestCredentials = fetchRequestCredentials ? fetchRequestCredentials : "same-origin"; this.requestTimeoutInSeconds = requestTimeoutInSeconds; if (stateStore) this.stateStore = stateStore; else { const store = typeof window !== "undefined" ? window.localStorage : new InMemoryWebStorage(); this.stateStore = new WebStorageStateStore({ store }); } this.refreshTokenAllowedScope = refreshTokenAllowedScope; this.extraQueryParams = extraQueryParams; this.extraTokenParams = extraTokenParams; this.extraHeaders = extraHeaders; this.dpop = dpop; if (this.dpop && !((_a = this.dpop) == null ? void 0 : _a.store)) throw new Error("A DPoPStore is required when dpop is enabled"); } }; var UserInfoService = class { constructor(_settings, _metadataService) { this._settings = _settings; this._metadataService = _metadataService; this._logger = new Logger("UserInfoService"); this._getClaimsFromJwt = async (responseText) => { const logger2 = this._logger.create("_getClaimsFromJwt"); try { const payload = JwtUtils.decode(responseText); logger2.debug("JWT decoding successful"); return payload; } catch (err) { logger2.error("Error parsing JWT response"); throw err; } }; this._jsonService = new JsonService(void 0, this._getClaimsFromJwt, this._settings.extraHeaders); } async getClaims(token) { const logger2 = this._logger.create("getClaims"); if (!token) this._logger.throw(/* @__PURE__ */ new Error("No token passed")); const url = await this._metadataService.getUserInfoEndpoint(); logger2.debug("got userinfo url", url); const claims = await this._jsonService.getJson(url, { token, credentials: this._settings.fetchRequestCredentials, timeoutInSeconds: this._settings.requestTimeoutInSeconds }); logger2.debug("got claims", claims); return claims; } }; var TokenClient = class { constructor(_settings, _metadataService) { this._settings = _settings; this._metadataService = _metadataService; this._logger = new Logger("TokenClient"); this._jsonService = new JsonService(this._settings.revokeTokenAdditionalContentTypes, null, this._settings.extraHeaders); } /** * Exchange code. * * @see https://www.rfc-editor.org/rfc/rfc6749#section-4.1.3 */ async exchangeCode({ grant_type = "authorization_code", redirect_uri = this._settings.redirect_uri, client_id = this._settings.client_id, client_secret = this._settings.client_secret, extraHeaders, ...args }) { const logger2 = this._logger.create("exchangeCode"); if (!client_id) logger2.throw(/* @__PURE__ */ new Error("A client_id is required")); if (!redirect_uri) logger2.throw(/* @__PURE__ */ new Error("A redirect_uri is required")); if (!args.code) logger2.throw(/* @__PURE__ */ new Error("A code is required")); const params = new URLSearchParams({ grant_type, redirect_uri }); for (const [key, value] of Object.entries(args)) if (value != null) params.set(key, value); if ((this._settings.client_authentication === "client_secret_basic" || this._settings.client_authentication === "client_secret_jwt") && (client_secret === void 0 || client_secret === null)) { logger2.throw(/* @__PURE__ */ new Error("A client_secret is required")); throw null; } let basicAuth; const url = await this._metadataService.getTokenEndpoint(false); switch (this._settings.client_authentication) { case "client_secret_basic": basicAuth = CryptoUtils.generateBasicAuth(client_id, client_secret); break; case "client_secret_post": params.append("client_id", client_id); if (client_secret) params.append("client_secret", client_secret); break; case "client_secret_jwt": { const clientAssertion = await CryptoUtils.generateClientAssertionJwt(client_id, client_secret, url, this._settings.token_endpoint_auth_signing_alg); params.append("client_id", client_id); params.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"); params.append("client_assertion", clientAssertion); break; } } logger2.debug("got token endpoint"); const response = await this._jsonService.postForm(url, { body: params, basicAuth, timeoutInSeconds: this._settings.requestTimeoutInSeconds, initCredentials: this._settings.fetchRequestCredentials, extraHeaders }); logger2.debug("got response"); return response; } /** * Exchange credentials. * * @see https://www.rfc-editor.org/rfc/rfc6749#section-4.3.2 */ async exchangeCredentials({ grant_type = "password", client_id = this._settings.client_id, client_secret = this._settings.client_secret, scope = this._settings.scope, ...args }) { const logger2 = this._logger.create("exchangeCredentials"); if (!client_id) logger2.throw(/* @__PURE__ */ new Error("A client_id is required")); const params = new URLSearchParams({ grant_type }); if (!this._settings.omitScopeWhenRequesting) params.set("scope", scope); for (const [key, value] of Object.entries(args)) if (value != null) params.set(key, value); if ((this._settings.client_authentication === "client_secret_basic" || this._settings.client_authentication === "client_secret_jwt") && (client_secret === void 0 || client_secret === null)) { logger2.throw(/* @__PURE__ */ new Error("A client_secret is required")); throw null; } let basicAuth; const url = await this._metadataService.getTokenEndpoint(false); switch (this._settings.client_authentication) { case "client_secret_basic": basicAuth = CryptoUtils.generateBasicAuth(client_id, client_secret); break; case "client_secret_post": params.append("client_id", client_id); if (client_secret) params.append("client_secret", client_secret); break; case "client_secret_jwt": { const clientAssertion = await CryptoUtils.generateClientAssertionJwt(client_id, client_secret, url, this._settings.token_endpoint_auth_signing_alg); params.append("client_id", client_id); params.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"); params.append("client_assertion", clientAssertion); break; } } logger2.debug("got token endpoint"); const response = await this._jsonService.postForm(url, { body: params, basicAuth, timeoutInSeconds: this._settings.requestTimeoutInSeconds, initCredentials: this._settings.fetchRequestCredentials }); logger2.debug("got response"); return response; } /** * Exchange a refresh token. * * @see https://www.rfc-editor.org/rfc/rfc6749#section-6 */ async exchangeRefreshToken({ grant_type = "refresh_token", client_id = this._settings.client_id, client_secret = this._settings.client_secret, timeoutInSeconds, extraHeaders, ...args }) { const logger2 = this._logger.create("exchangeRefreshToken"); if (!client_id) logger2.throw(/* @__PURE__ */ new Error("A client_id is required")); if (!args.refresh_token) logger2.throw(/* @__PURE__ */ new Error("A refresh_token is required")); const params = new URLSearchParams({ grant_type }); for (const [key, value] of Object.entries(args)) if (Array.isArray(value)) value.forEach((param) => params.append(key, param)); else if (value != null) params.set(key, value); if ((this._settings.client_authentication === "client_secret_basic" || this._settings.client_authentication === "client_secret_jwt") && (client_secret === void 0 || client_secret === null)) { logger2.throw(/* @__PURE__ */ new Error("A client_secret is required")); throw null; } let basicAuth; const url = await this._metadataService.getTokenEndpoint(false); switch (this._settings.client_authentication) { case "client_secret_basic": basicAuth = CryptoUtils.generateBasicAuth(client_id, client_secret); break; case "client_secret_post": params.append("client_id", client_id); if (client_secret) params.append("client_secret", client_secret); break; case "client_secret_jwt": { const clientAssertion = await CryptoUtils.generateClientAssertionJwt(client_id, client_secret, url, this._settings.token_endpoint_auth_signing_alg); params.append("client_id", client_id); params.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"); params.append("client_assertion", clientAssertion); break; } } logger2.debug("got token endpoint"); const response = await this._jsonService.postForm(url, { body: params, basicAuth, timeoutInSeconds, initCredentials: this._settings.fetchRequestCredentials, extraHeaders }); logger2.debug("got response"); return response; } /** * Revoke an access or refresh token. * * @see https://datatracker.ietf.org/doc/html/rfc7009#section-2.1 */ async revoke(args) { var _a; const logger2 = this._logger.create("revoke"); if (!args.token) logger2.throw(/* @__PURE__ */ new Error("A token is required")); const url = await this._metadataService.getRevocationEndpoint(false); logger2.debug(`got revocation endpoint, revoking ${(_a = args.token_type_hint) != null ? _a : "default token type"}`); const params = new URLSearchParams(); for (const [key, value] of Object.entries(args)) if (value != null) params.set(key, value); params.set("client_id", this._settings.client_id); if (this._settings.client_secret) params.set("client_secret", this._settings.client_secret); await this._jsonService.postForm(url, { body: params, timeoutInSeconds: this._settings.requestTimeoutInSeconds }); logger2.debug("got response"); } }; var ResponseValidator = class { constructor(_settings, _metadataService, _claimsService) { this._settings = _settings; this._metadataService = _metadataService; this._claimsService = _claimsService; this._logger = new Logger("ResponseValidator"); this._userInfoService = new UserInfoService(this._settings, this._metadataService); this._tokenClient = new TokenClient(this._settings, this._metadataService); } async validateSigninResponse(response, state, extraHeaders) { const logger2 = this._logger.create("validateSigninResponse"); this._processSigninState(response, state); logger2.debug("state processed"); await this._processCode(response, state, extraHeaders); logger2.debug("code processed"); if (response.isOpenId) this._validateIdTokenAttributes(response, "", state.nonce); logger2.debug("tokens validated"); await this._processClaims(response, state == null ? void 0 : state.skipUserInfo, response.isOpenId); logger2.debug("claims processed"); } async validateCredentialsResponse(response, skipUserInfo) { const logger2 = this._logger.create("validateCredentialsResponse"); const shouldValidateSubClaim = response.isOpenId && !!response.id_token; if (shouldValidateSubClaim) this._validateIdTokenAttributes(response); logger2.debug("tokens validated"); await this._processClaims(response, skipUserInfo, shouldValidateSubClaim); logger2.debug("claims processed"); } async validateRefreshResponse(response, state) { const logger2 = this._logger.create("validateRefreshResponse"); response.userState = state.data; response.session_state ??= state.session_state; response.scope ??= state.scope; if (response.isOpenId && !!response.id_token) { this._validateIdTokenAttributes(response, state.id_token); logger2.debug("ID Token validated"); } if (!response.id_token) { response.id_token = state.id_token; response.profile = state.profile; } const hasIdToken = response.isOpenId && !!response.id_token; await this._processClaims(response, false, hasIdToken); logger2.debug("claims processed"); } validateSignoutResponse(response, state) { const logger2 = this._logger.create("validateSignoutResponse"); if (state.id !== response.state) logger2.throw(/* @__PURE__ */ new Error("State does not match")); logger2.debug("state validated"); response.userState = state.data; if (response.error) { logger2.warn("Response was error", response.error); throw new ErrorResponse(response); } } _processSigninState(response, state) { const logger2 = this._logger.create("_processSigninState"); if (state.id !== response.state) logger2.throw(/* @__PURE__ */ new Error("State does not match")); if (!state.client_id) logger2.throw(/* @__PURE__ */ new Error("No client_id on state")); if (!state.authority) logger2.throw(/* @__PURE__ */ new Error("No authority on state")); if (this._settings.authority !== state.authority) logger2.throw(/* @__PURE__ */ new Error("authority mismatch on settings vs. signin state")); if (this._settings.client_id && this._settings.client_id !== state.client_id) logger2.throw(/* @__PURE__ */ new Error("client_id mismatch on settings vs. signin state")); logger2.debug("state validated"); response.userState = state.data; response.url_state = state.url_state; response.scope ??= state.scope; if (response.error) { logger2.warn("Response was error", response.error); throw new ErrorResponse(response); } if (state.code_verifier && !response.code) logger2.throw(/* @__PURE__ */ new Error("Expected code in response")); } async _processClaims(response, skipUserInfo = false, validateSub = true) { const logger2 = this._logger.create("_processClaims"); response.profile = this._claimsService.filterProtocolClaims(response.profile); if (skipUserInfo || !this._settings.loadUserInfo || !response.access_token) { logger2.debug("not loading user info"); return; } logger2.debug("loading user info"); const claims = await this._userInfoService.getClaims(response.access_token); logger2.debug("user info claims received from user info endpoint"); if (validateSub && claims.sub !== response.profile.sub) logger2.throw(/* @__PURE__ */ new Error("subject from UserInfo response does not match subject in ID Token")); response.profile = this._claimsService.mergeClaims(response.profile, this._claimsService.filterProtocolClaims(claims)); logger2.debug("user info claims received, updated profile:", response.profile); } async _processCode(response, state, extraHeaders) { const logger2 = this._logger.create("_processCode"); if (response.code) { logger2.debug("Validating code"); const tokenResponse = await this._tokenClient.exchangeCode({ client_id: state.client_id, client_secret: state.client_secret, code: response.code, redirect_uri: state.redirect_uri, code_verifier: state.code_verifier, extraHeaders, ...state.extraTokenParams }); Object.assign(response, tokenResponse); } else logger2.debug("No code to process"); } _validateIdTokenAttributes(response, existingToken, nonce) { var _a; const logger2 = this._logger.create("_validateIdTokenAttributes"); logger2.debug("decoding ID Token JWT"); const incoming = JwtUtils.decode((_a = response.id_token) != null ? _a : ""); if (!incoming.sub) logger2.throw(/* @__PURE__ */ new Error("ID Token is missing a subject claim")); if (nonce && incoming.nonce !== nonce) logger2.throw(/* @__PURE__ */ new Error("nonce in id_token does not match nonce in client storage")); if (existingToken) { const existing = JwtUtils.decode(existingToken); if (incoming.sub !== existing.sub) logger2.throw(/* @__PURE__ */ new Error("sub in id_token does not match current sub")); if (incoming.auth_time && incoming.auth_time !== existing.auth_time) logger2.throw(/* @__PURE__ */ new Error("auth_time in id_token does not match original auth_time")); if (incoming.azp && incoming.azp !== existing.azp) logger2.throw(/* @__PURE__ */ new Error("azp in id_token does not match original azp")); if (!incoming.azp && existing.azp) logger2.throw(/* @__PURE__ */ new Error("azp not in id_token, but present in original id_token")); } response.profile = incoming; } }; var State = class _State { constructor(args) { this.id = args.id || CryptoUtils.generateUUIDv4(); this.data = args.data; if (args.created && args.created > 0) this.created = args.created; else this.created = Timer.getEpochTime(); this.request_type = args.request_type; this.url_state = args.url_state; } toStorageString() { new Logger("State").create("toStorageString"); return JSON.stringify({ id: this.id, data: this.data, created: this.created, request_type: this.request_type, url_state: this.url_state }); } static fromStorageString(storageString) { Logger.createStatic("State", "fromStorageString"); return Promise.resolve(new _State(JSON.parse(storageString))); } static async clearStaleState(storage, age) { const logger2 = Logger.createStatic("State", "clearStaleState"); const cutoff = Timer.getEpochTime() - age; const keys = await storage.getAllKeys(); logger2.debug("got keys", keys); for (let i = 0; i < keys.length; i++) { const key = keys[i]; const item = await storage.get(key); let remove = false; if (item) try { const state = await _State.fromStorageString(item); logger2.debug("got item from key:", key, state.created); if (state.created <= cutoff) remove = true; } catch (err) { logger2.error("Error parsing state for key:", key, err); remove = true; } else { logger2.debug("no item in storage for key:", key); remove = true; } if (remove) { logger2.debug("removed item for key:", key); storage.remove(key); } } } }; var SigninState = class _SigninState extends State { constructor(args) { super(args); this.code_verifier = args.code_verifier; this.code_challenge = args.code_challenge; this.authority = args.authority; this.client_id = args.client_id; this.redirect_uri = args.redirect_uri; this.scope = args.scope; this.client_secret = args.client_secret; this.extraTokenParams = args.extraTokenParams; this.response_mode = args.response_mode; this.skipUserInfo = args.skipUserInfo; this.nonce = args.nonce; } static async create(args) { const code_verifier = args.code_verifier === true ? CryptoUtils.generateCodeVerifier() : args.code_verifier || void 0; const code_challenge = code_verifier ? await CryptoUtils.generateCodeChallenge(code_verifier) : void 0; return new _SigninState({ ...args, code_verifier, code_challenge }); } toStorageString() { new Logger("SigninState").create("toStorageString"); return JSON.stringify({ id: this.id, data: this.data, created: this.created, request_type: this.request_type, url_state: this.url_state, code_verifier: this.code_verifier, authority: this.authority, client_id: this.client_id, redirect_uri: this.redirect_uri, scope: this.scope, client_secret: this.client_secret, extraTokenParams: this.extraTokenParams, response_mode: this.response_mode, skipUserInfo: this.skipUserInfo, nonce: this.nonce }); } static fromStorageString(storageString) { Logger.createStatic("SigninState", "fromStorageString"); const data = JSON.parse(storageString); return _SigninState.create(data); } }; var _SigninRequest = class _SigninRequest { constructor(args) { this.url = args.url; this.state = args.state; } static async create({ url, authority, client_id, redirect_uri, response_type, scope, state_data, response_mode, request_type, client_secret, nonce, url_state, resource, skipUserInfo, extraQueryParams, extraTokenParams, disablePKCE, dpopJkt, omitScopeWhenRequesting, ...optionalParams }) { if (!url) { this._logger.error("create: No url passed"); throw new Error("url"); } if (!client_id) { this._logger.error("create: No client_id passed"); throw new Error("client_id"); } if (!redirect_uri) { this._logger.error("create: No redirect_uri passed"); throw new Error("redirect_uri"); } if (!response_type) { this._logger.error("create: No response_type passed"); throw new Error("response_type"); } if (!scope) { this._logger.error("create: No scope passed"); throw new Error("scope"); } if (!authority) { this._logger.error("create: No authority passed"); throw new Error("authority"); } const state = await SigninState.create({ data: state_data, request_type, url_state, code_verifier: !disablePKCE, client_id, authority, redirect_uri, response_mode, client_secret, scope, extraTokenParams, skipUserInfo, nonce }); const parsedUrl = new URL(url); parsedUrl.searchParams.append("client_id", client_id); parsedUrl.searchParams.append("redirect_uri", redirect_uri); parsedUrl.searchParams.append("response_type", response_type); if (!omitScopeWhenRequesting) parsedUrl.searchParams.append("scope", scope); if (nonce) parsedUrl.searchParams.append("nonce", nonce); if (dpopJkt) parsedUrl.searchParams.append("dpop_jkt", dpopJkt); let stateParam = state.id; if (url_state) stateParam = `${stateParam}${URL_STATE_DELIMITER}${url_state}`; parsedUrl.searchParams.append("state", stateParam); if (state.code_challenge) { parsedUrl.searchParams.append("code_challenge", state.code_challenge); parsedUrl.searchParams.append("code_challenge_method", "S256"); } if (resource) (Array.isArray(resource) ? resource : [resource]).forEach((r) => parsedUrl.searchParams.append("resource", r)); for (const [key, value] of Object.entries({ response_mode, ...optionalParams, ...extraQueryParams })) if (value != null) parsedUrl.searchParams.append(key, value.toString()); return new _SigninRequest({ url: parsedUrl.href, state }); } }; _SigninRequest._logger = new Logger("SigninRequest"); var SigninRequest = _SigninRequest; var OidcScope = "openid"; var SigninResponse = class { constructor(params) { /** @see {@link User.access_token} */ this.access_token = ""; /** @see {@link User.token_type} */ this.token_type = ""; /** @see {@link User.profile} */ this.profile = {}; this.state = params.get("state"); this.session_state = params.get("session_state"); if (this.state) { const splitState = decodeURIComponent(this.state).split(URL_STATE_DELIMITER); this.state = splitState[0]; if (splitState.length > 1) this.url_state = splitState.slice(1).join(URL_STATE_DELIMITER); } this.error = params.get("error"); this.error_description = params.get("error_description"); this.error_uri = params.get("error_uri"); this.code = params.get("code"); } get expires_in() { if (this.expires_at === void 0) return; return this.expires_at - Timer.getEpochTime(); } set expires_in(value) { if (typeof value === "string") value = Number(value); if (value !== void 0 && value >= 0) this.expires_at = Math.floor(value) + Timer.getEpochTime(); } get isOpenId() { var _a; return ((_a = this.scope) == null ? void 0 : _a.split(" ").includes(OidcScope)) || !!this.id_token; } }; var SignoutRequest = class { constructor({ url, state_data, id_token_hint, post_logout_redirect_uri, extraQueryParams, request_type, client_id, url_state }) { this._logger = new Logger("SignoutRequest"); if (!url) { this._logger.error("ctor: No url passed"); throw new Error("url"); } const parsedUrl = new URL(url); if (id_token_hint) parsedUrl.searchParams.append("id_token_hint", id_token_hint); if (client_id) parsedUrl.searchParams.append("client_id", client_id); if (post_logout_redirect_uri) { parsedUrl.searchParams.append("post_logout_redirect_uri", post_logout_redirect_uri); if (state_data || url_state) { this.state = new State({ data: state_data, request_type, url_state }); let stateParam = this.state.id; if (url_state) stateParam = `${stateParam}${URL_STATE_DELIMITER}${url_state}`; parsedUrl.searchParams.append("state", stateParam); } } for (const [key, value] of Object.entries({ ...extraQueryParams })) if (value != null) parsedUrl.searchParams.append(key, value.toString()); this.url = parsedUrl.href; } }; var SignoutResponse = class { constructor(params) { this.state = params.get("state"); if (this.state) { const splitState = decodeURIComponent(this.state).split(URL_STATE_DELIMITER); this.state = splitState[0]; if (splitState.length > 1) this.url_state = splitState.slice(1).join(URL_STATE_DELIMITER); } this.error = params.get("error"); this.error_description = params.get("error_description"); this.error_uri = params.get("error_uri"); } }; var DefaultProtocolClaims = [ "nbf", "jti", "auth_time", "nonce", "acr", "amr", "azp", "at_hash" ]; var InternalRequiredProtocolClaims = [ "sub", "iss", "aud", "exp", "iat" ]; var ClaimsService = class { constructor(_settings) { this._settings = _settings; this._logger = new Logger("ClaimsService"); } filterProtocolClaims(claims) { const result = { ...claims }; if (this._settings.filterProtocolClaims) { let protocolClaims; if (Array.isArray(this._settings.filterProtocolClaims)) protocolClaims = this._settings.filterProtocolClaims; else protocolClaims = DefaultProtocolClaims; for (const claim of protocolClaims) if (!InternalRequiredProtocolClaims.includes(claim)) delete result[claim]; } return result; } mergeClaims(claims1, claims2) { const result = { ...claims1 }; for (const [claim, values] of Object.entries(claims2)) if (result[claim] !== values) if (Array.isArray(result[claim]) || Array.isArray(values)) if (this._settings.mergeClaimsStrategy.array == "replace") result[claim] = values; else { const mergedValues = Array.isArray(result[claim]) ? result[claim] : [result[claim]]; for (const value of Array.isArray(values) ? values : [values]) if (!mergedValues.includes(value)) mergedValues.push(value); result[claim] = mergedValues; } else if (typeof result[claim] === "object" && typeof values === "object") result[claim] = this.mergeClaims(result[claim], values); else result[claim] = values; return result; } }; var DPoPState = class { constructor(keys, nonce) { this.keys = keys; this.nonce = nonce; } }; var OidcClient = class { constructor(settings, metadataService) { this._logger = new Logger("OidcClient"); this.settings = settings instanceof OidcClientSettingsStore ? settings : new OidcClientSettingsStore(settings); this.metadataService = metadataService != null ? metadataService : new MetadataService(this.settings); this._claimsService = new ClaimsService(this.settings); this._validator = new ResponseValidator(this.settings, this.metadataService, this._claimsService); this._tokenClient = new TokenClient(this.settings, this.metadataService); } async createSigninRequest({ state, request, request_uri, request_type, id_token_hint, login_hint, skipUserInfo, nonce, url_state, response_type = this.settings.response_type, scope = this.settings.scope, redirect_uri = this.settings.redirect_uri, prompt = this.settings.prompt, display = this.settings.display, max_age = this.settings.max_age, ui_locales = this.settings.ui_locales, acr_values = this.settings.acr_values, resource = this.settings.resource, response_mode = this.settings.response_mode, extraQueryParams = this.settings.extraQueryParams, extraTokenParams = this.settings.extraTokenParams, dpopJkt, omitScopeWhenRequesting = this.settings.omitScopeWhenRequesting }) { const logger2 = this._logger.create("createSigninRequest"); if (response_type !== "code") throw new Error("Only the Authorization Code flow (with PKCE) is supported"); const url = await this.metadataService.getAuthorizationEndpoint(); logger2.debug("Received authorization endpoint", url); const signinRequest = await SigninRequest.create({ url, authority: this.settings.authority, client_id: this.settings.client_id, redirect_uri, response_type, scope, state_data: state, url_state, prompt, display, max_age, ui_locales, id_token_hint, login_hint, acr_values, dpopJkt, resource, request, request_uri, extraQueryParams, extraTokenParams, request_type, response_mode, client_secret: this.settings.client_secret, skipUserInfo, nonce, disablePKCE: this.settings.disablePKCE, omitScopeWhenRequesting }); await this.clearStaleState(); const signinState = signinRequest.state; await this.settings.stateStore.set(signinState.id, signinState.toStorageString()); return signinRequest; } async readSigninResponseState(url, removeState = false) { const logger2 = this._logger.create("readSigninResponseState"); const response = new SigninResponse(UrlUtils.readParams(url, this.settings.response_mode)); if (!response.state) { logger2.throw(/* @__PURE__ */ new Error("No state in response")); throw null; } const storedStateString = await this.settings.stateStore[removeState ? "remove" : "get"](response.state); if (!storedStateString) { logger2.throw(/* @__PURE__ */ new Error("No matching state found in storage")); throw null; } return { state: await SigninState.fromStorageString(storedStateString), response }; } async processSigninResponse(url, extraHeaders, removeState = true) { const logger2 = this._logger.create("processSigninResponse"); const { state, response } = await this.readSigninResponseState(url, removeState); logger2.debug("received state from storage; validating response"); if (this.settings.dpop && this.settings.dpop.store) { const dpopProof = await this.getDpopProof(this.settings.dpop.store); extraHeaders = { ...extraHeaders, "DPoP": dpopProof }; } try { await this._validator.validateSigninResponse(response, state, extraHeaders); } catch (err) { if (err instanceof ErrorDPoPNonce && this.settings.dpop) { const dpopProof = await this.getDpopProof(this.settings.dpop.store, err.nonce); extraHeaders["DPoP"] = dpopProof; await this._validator.validateSigninResponse(response, state, extraHeaders); } else throw err; } return response; } async getDpopProof(dpopStore, nonce) { let keyPair; let dpopState; if (!(await dpopStore.getAllKeys()).includes(this.settings.client_id)) { keyPair = await CryptoUtils.generateDPoPKeys(); dpopState = new DPoPState(keyPair, nonce); await dpopStore.set(this.settings.client_id, dpopState); } else { dpopState = await dpopStore.get(this.settings.client_id); if (dpopState.nonce !== nonce && nonce) { dpopState.nonce = nonce; await dpopStore.set(this.settings.client_id, dpopState); } } return await CryptoUtils.generateDPoPProof({ url: await this.metadataService.getTokenEndpoint(false), httpMethod: "POST", keyPair: dpopState.keys, nonce: dpopState.nonce }); } async processResourceOwnerPasswordCredentials({ username, password, skipUserInfo = false, extraTokenParams = {} }) { const tokenResponse = await this._tokenClient.exchangeCredentials({ username, password, ...extraTokenParams }); const signinResponse = new SigninResponse(new URLSearchParams()); Object.assign(signinResponse, tokenResponse); await this._validator.validateCredentialsResponse(signinResponse, skipUserInfo); return signinResponse; } async useRefreshToken({ state, redirect_uri, resource, timeoutInSeconds, extraHeaders, extraTokenParams }) { var _a; const logger2 = this._logger.create("useRefreshToken"); let scope; if (this.settings.refreshTokenAllowedScope === void 0) scope = state.scope; else { const allowableScopes = this.settings.refreshTokenAllowedScope.split(" "); scope = (((_a = state.scope) == null ? void 0 : _a.split(" ")) || []).filter((s) => allowableScopes.includes(s)).join(" "); } if (this.settings.dpop && this.settings.dpop.store) { const dpopProof = await this.getDpopProof(this.settings.dpop.store); extraHeaders = { ...extraHeaders, "DPoP": dpopProof }; } let result; try { result = await this._tokenClient.exchangeRefreshToken({ refresh_token: state.refresh_token, scope, redirect_uri, resource, timeoutInSeconds, extraHeaders, ...extraTokenParams }); } catch (err) { if (err instanceof ErrorDPoPNonce && this.settings.dpop) { extraHeaders["DPoP"] = await this.getDpopProof(this.settings.dpop.store, err.nonce); result = await this._tokenClient.exchangeRefreshToken({ refresh_token: state.refresh_token, scope, redirect_uri, resource, timeoutInSeconds, extraHeaders, ...extraTokenParams }); } else throw err; } const response = new SigninResponse(new URLSearchParams()); Object.assign(response, result); logger2.debug("validating response", response); await this._validator.validateRefreshResponse(response, { ...state, scope }); return response; } async createSignoutRequest({ state, id_token_hint, client_id, request_type, url_state, post_logout_redirect_uri = this.settings.post_logout_redirect_uri, extraQueryParams = this.settings.extraQueryParams } = {}) { const logger2 = this._logger.create("createSignoutRequest"); const url = await this.metadataService.getEndSessionEndpoint(); if (!url) { logger2.throw(/* @__PURE__ */ new Error("No end session endpoint")); throw null; } logger2.debug("Received end session endpoint", url); if (!client_id && post_logout_redirect_uri && !id_token_hint) client_id = this.settings.client_id; const request = new SignoutRequest({ url, id_token_hint, client_id, post_logout_redirect_uri, state_data: state, extraQueryParams, request_type, url_state }); await this.clearStaleState(); const signoutState = request.state; if (signoutState) { logger2.debug("Signout request has state to persist"); await this.settings.stateStore.set(signoutState.id, signoutState.toStorageString()); } return request; } async readSignoutResponseState(url, removeState = false) { const logger2 = this._logger.create("readSignoutResponseState"); const response = new SignoutResponse(UrlUtils.readParams(url, this.settings.response_mode)); if (!response.state) { logger2.debug("No state in response"); if (response.error) { logger2.warn("Response was error:", response.error); throw new ErrorResponse(response); } return { state: void 0, response }; } const storedStateString = await this.settings.stateStore[removeState ? "remove" : "get"](response.state); if (!storedStateString) { logger2.throw(/* @__PURE__ */ new Error("No matching state found in storage")); throw null; } return { state: await State.fromStorageString(storedStateString), response }; } async processSignoutResponse(url) { const logger2 = this._logger.create("processSignoutResponse"); const { state, response } = await this.readSignoutResponseState(url, true); if (state) { logger2.debug("Received state from storage; validating response"); this._validator.validateSignoutResponse(response, state); } else logger2.debug("No state from storage; skipping response validation"); return response; } clearStaleState() { this._logger.create("clearStaleState"); return State.clearStaleState(this.settings.stateStore, this.settings.staleStateAgeInSeconds); } async revokeToken(token, type) { this._logger.create("revokeToken"); return await this._tokenClient.revoke({ token, token_type_hint: type }); } }; var SessionMonitor = class { constructor(_userManager) { this._userManager = _userManager; this._logger = new Logger("SessionMonitor"); this._start = async (user) => { const session_state = user.session_state; if (!session_state) return; const logger2 = this._logger.create("_start"); if (user.profile) { this._sub = user.profile.sub; logger2.debug("session_state", session_state, ", sub", this._sub); } else { this._sub = void 0; logger2.debug("session_state", session_state, ", anonymous user"); } if (this._checkSessionIFrame) { this._checkSessionIFrame.start(session_state); return; } try { const url = await this._userManager.metadataService.getCheckSessionIframe(); if (url) { logger2.debug("initializing check session iframe"); const client_id = this._userManager.settings.client_id; const intervalInSeconds = this._userManager.settings.checkSessionIntervalInSeconds; const stopOnError = this._userManager.settings.stopCheckSessionOnError; const checkSessionIFrame = new CheckSessionIFrame(this._callback, client_id, url, intervalInSeconds, stopOnError); await checkSessionIFrame.load(); this._checkSessionIFrame = checkSessionIFrame; checkSessionIFrame.start(session_state); } else logger2.warn("no check session iframe found in the metadata"); } catch (err) { logger2.error("Error from getCheckSessionIframe:", err instanceof Error ? err.message : err); } }; this._stop = () => { const logger2 = this._logger.create("_stop"); this._sub = void 0; if (this._checkSessionIFrame) this._checkSessionIFrame.stop(); if (this._userManager.settings.monitorAnonymousSession) { const timerHandle = setInterval(async () => { clearInterval(timerHandle); try { const session = await this._userManager.querySessionStatus(); if (session) { const tmpUser = { session_state: session.session_state, profile: session.sub ? { sub: session.sub } : null }; this._start(tmpUser); } } catch (err) { logger2.error("error from querySessionStatus", err instanceof Error ? err.message : err); } }, 1e3); } }; this._callback = async () => { const logger2 = this._logger.create("_callback"); try { const session = await this._userManager.querySessionStatus(); let raiseEvent = true; if (session && this._checkSessionIFrame) if (session.sub === this._sub) { raiseEvent = false; this._checkSessionIFrame.start(session.session_state); logger2.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state", session.session_state); await this._userManager.events._raiseUserSessionChanged(); } else logger2.debug("different subject signed into OP", session.sub); else logger2.debug("subject no longer signed into OP"); if (raiseEvent) if (this._sub) await this._userManager.events._raiseUserSignedOut(); else await this._userManager.events._raiseUserSignedIn(); else logger2.debug("no change in session detected, no event to raise"); } catch (err) { if (this._sub) { logger2.debug("Error calling queryCurrentSigninSession; raising signed out event", err); await this._userManager.events._raiseUserSignedOut(); } } }; if (!_userManager) this._logger.throw(/* @__PURE__ */ new Error("No user manager passed")); this._userManager.events.addUserLoaded(this._start); this._userManager.events.addUserUnloaded(this._stop); this._init().catch((err) => { this._logger.error(err); }); } async _init() { this._logger.create("_init"); const user = await this._userManager.getUser(); if (user) this._start(user); else if (this._userManager.settings.monitorAnonymousSession) { const session = await this._userManager.querySessionStatus(); if (session) { const tmpUser = { session_state: session.session_state, profile: session.sub ? { sub: session.sub } : null }; this._start(tmpUser); } } } }; var User = class _User { constructor(args) { var _a; this.id_token = args.id_token; this.session_state = (_a = args.session_state) != null ? _a : null; this.access_token = args.access_token; this.refresh_token = args.refresh_token; this.token_type = args.token_type; this.scope = args.scope; this.profile = args.profile; this.expires_at = args.expires_at; this.state = args.userState; this.url_state = args.url_state; } /** Computed number of seconds the access token has remaining. */ get expires_in() { if (this.expires_at === void 0) return; return this.expires_at - Timer.getEpochTime(); } set expires_in(value) { if (value !== void 0) this.expires_at = Math.floor(value) + Timer.getEpochTime(); } /** Computed value indicating if the access token is expired. */ get expired() { const expires_in = this.expires_in; if (expires_in === void 0) return; return expires_in <= 0; } /** Array representing the parsed values from the `scope`. */ get scopes() { var _a, _b; return (_b = (_a = this.scope) == null ? void 0 : _a.split(" ")) != null ? _b : []; } toStorageString() { new Logger("User").create("toStorageString"); return JSON.stringify({ id_token: this.id_token, session_state: this.session_state, access_token: this.access_token, refresh_token: this.refresh_token, token_type: this.token_type, scope: this.scope, profile: this.profile, expires_at: this.expires_at }); } static fromStorageString(storageString) { Logger.createStatic("User", "fromStorageString"); return new _User(JSON.parse(storageString)); } }; var messageSource = "oidc-client"; var AbstractChildWindow = class { constructor() { this._abort = new Event$1("Window navigation aborted"); this._disposeHandlers = /* @__PURE__ */ new Set(); this._window = null; } async navigate(params) { const logger2 = this._logger.create("navigate"); if (!this._window) throw new Error("Attempted to navigate on a disposed window"); logger2.debug("setting URL in window"); this._window.location.replace(params.url); const { url, keepOpen } = await new Promise((resolve, reject) => { const listener = (e) => { var _a; const data = e.data; const origin = (_a = params.scriptOrigin) != null ? _a : window.location.origin; if (e.origin !== origin || (data == null ? void 0 : data.source) !== messageSource) return; try { const state = UrlUtils.readParams(data.url, params.response_mode).get("state"); if (!state) logger2.warn("no state found in response url"); if (e.source !== this._window && state !== params.state) return; } catch { this._dispose(); reject(/* @__PURE__ */ new Error("Invalid response from window")); } resolve(data); }; window.addEventListener("message", listener, false); this._disposeHandlers.add(() => window.removeEventListener("message", listener, false)); const channel = new BroadcastChannel(`oidc-client-popup-${params.state}`); channel.addEventListener("message", listener, false); this._disposeHandlers.add(() => channel.close()); this._disposeHandlers.add(this._abort.addHandler((reason) => { this._dispose(); reject(reason); })); }); logger2.debug("got response from window"); this._dispose(); if (!keepOpen) this.close(); return { url }; } _dispose() { this._logger.create("_dispose"); for (const dispose of this._disposeHandlers) dispose(); this._disposeHandlers.clear(); } static _notifyParent(parent, url, keepOpen = false, targetOrigin = window.location.origin) { const msgData = { source: messageSource, url, keepOpen }; const logger2 = new Logger("_notifyParent"); if (parent) { logger2.debug("With parent. Using parent.postMessage."); parent.postMessage(msgData, targetOrigin); } else { logger2.debug("No parent. Using BroadcastChannel."); const state = new URL(url).searchParams.get("state"); if (!state) throw new Error("No parent and no state in URL. Can't complete notification."); const channel = new BroadcastChannel(`oidc-client-popup-${state}`); channel.postMessage(msgData); channel.close(); } } }; var DefaultPopupWindowFeatures = { location: false, toolbar: false, height: 640, closePopupWindowAfterInSeconds: -1 }; var DefaultPopupTarget = "_blank"; var DefaultAccessTokenExpiringNotificationTimeInSeconds = 60; var DefaultCheckSessionIntervalInSeconds = 2; var DefaultSilentRequestTimeoutInSeconds = 10; var UserManagerSettingsStore = class extends OidcClientSettingsStore { constructor(args) { const { popup_redirect_uri = args.redirect_uri, popup_post_logout_redirect_uri = args.post_logout_redirect_uri, popupWindowFeatures = DefaultPopupWindowFeatures, popupWindowTarget = DefaultPopupTarget, redirectMethod = "assign", redirectTarget = "self", iframeNotifyParentOrigin = args.iframeNotifyParentOrigin, iframeScriptOrigin = args.iframeScriptOrigin, requestTimeoutInSeconds, silent_redirect_uri = args.redirect_uri, silentRequestTimeoutInSeconds, automaticSilentRenew = true, validateSubOnSilentRenew = true, includeIdTokenInSilentRenew = false, monitorSession = false, monitorAnonymousSession = false, checkSessionIntervalInSeconds = DefaultCheckSessionIntervalInSeconds, query_status_response_type = "code", stopCheckSessionOnError = true, revokeTokenTypes = ["access_token", "refresh_token"], revokeTokensOnSignout = false, includeIdTokenInSilentSignout = false, accessTokenExpiringNotificationTimeInSeconds = DefaultAccessTokenExpiringNotificationTimeInSeconds, maxSilentRenewTimeoutRetries, userStore } = args; super(args); this.popup_redirect_uri = popup_redirect_uri; this.popup_post_logout_redirect_uri = popup_post_logout_redirect_uri; this.popupWindowFeatures = popupWindowFeatures; this.popupWindowTarget = popupWindowTarget; this.redirectMethod = redirectMethod; this.redirectTarget = redirectTarget; this.iframeNotifyParentOrigin = iframeNotifyParentOrigin; this.iframeScriptOrigin = iframeScriptOrigin; this.silent_redirect_uri = silent_redirect_uri; this.silentRequestTimeoutInSeconds = silentRequestTimeoutInSeconds || requestTimeoutInSeconds || DefaultSilentRequestTimeoutInSeconds; this.automaticSilentRenew = automaticSilentRenew; this.validateSubOnSilentRenew = validateSubOnSilentRenew; this.includeIdTokenInSilentRenew = includeIdTokenInSilentRenew; this.monitorSession = monitorSession; this.monitorAnonymousSession = monitorAnonymousSession; this.checkSessionIntervalInSeconds = checkSessionIntervalInSeconds; this.stopCheckSessionOnError = stopCheckSessionOnError; this.query_status_response_type = query_status_response_type; this.revokeTokenTypes = revokeTokenTypes; this.revokeTokensOnSignout = revokeTokensOnSignout; this.includeIdTokenInSilentSignout = includeIdTokenInSilentSignout; this.accessTokenExpiringNotificationTimeInSeconds = accessTokenExpiringNotificationTimeInSeconds; this.maxSilentRenewTimeoutRetries = maxSilentRenewTimeoutRetries; if (userStore) this.userStore = userStore; else { const store = typeof window !== "undefined" ? window.sessionStorage : new InMemoryWebStorage(); this.userStore = new WebStorageStateStore({ store }); } } }; var IFrameWindow = class _IFrameWindow extends AbstractChildWindow { constructor({ silentRequestTimeoutInSeconds = DefaultSilentRequestTimeoutInSeconds }) { super(); this._logger = new Logger("IFrameWindow"); this._timeoutInSeconds = silentRequestTimeoutInSeconds; this._frame = _IFrameWindow.createHiddenIframe(); this._window = this._frame.contentWindow; } static createHiddenIframe() { const iframe = window.document.createElement("iframe"); iframe.style.visibility = "hidden"; iframe.style.position = "fixed"; iframe.style.left = "-1000px"; iframe.style.top = "0"; iframe.width = "0"; iframe.height = "0"; window.document.body.appendChild(iframe); return iframe; } async navigate(params) { this._logger.debug("navigate: Using timeout of:", this._timeoutInSeconds); const timer = setTimeout(() => void this._abort.raise(new ErrorTimeout("IFrame timed out without a response")), this._timeoutInSeconds * 1e3); this._disposeHandlers.add(() => clearTimeout(timer)); return await super.navigate(params); } close() { var _a; if (this._frame) { if (this._frame.parentNode) { this._frame.addEventListener("load", (ev) => { var _a2; const frame = ev.target; (_a2 = frame.parentNode) == null || _a2.removeChild(frame); this._abort.raise(/* @__PURE__ */ new Error("IFrame removed from DOM")); }, true); (_a = this._frame.contentWindow) == null || _a.location.replace("about:blank"); } this._frame = null; } this._window = null; } static notifyParent(url, targetOrigin) { return super._notifyParent(window.parent, url, false, targetOrigin); } }; var IFrameNavigator = class { constructor(_settings) { this._settings = _settings; this._logger = new Logger("IFrameNavigator"); } async prepare({ silentRequestTimeoutInSeconds = this._settings.silentRequestTimeoutInSeconds }) { return new IFrameWindow({ silentRequestTimeoutInSeconds }); } async callback(url) { this._logger.create("callback"); IFrameWindow.notifyParent(url, this._settings.iframeNotifyParentOrigin); } }; var checkForPopupClosedInterval = 500; var second = 1e3; var PopupWindow = class extends AbstractChildWindow { constructor({ popupWindowTarget = DefaultPopupTarget, popupWindowFeatures = {}, popupSignal, popupAbortOnClose }) { super(); this._logger = new Logger("PopupWindow"); const centeredPopup = PopupUtils.center({ ...DefaultPopupWindowFeatures, ...popupWindowFeatures }); this._window = window.open(void 0, popupWindowTarget, PopupUtils.serialize(centeredPopup)); this.abortOnClose = Boolean(popupAbortOnClose); if (popupSignal) popupSignal.addEventListener("abort", () => { var _a; this._abort.raise(new Error((_a = popupSignal.reason) != null ? _a : "Popup aborted")); }); if (popupWindowFeatures.closePopupWindowAfterInSeconds && popupWindowFeatures.closePopupWindowAfterInSeconds > 0) setTimeout(() => { if (!this._window || typeof this._window.closed !== "boolean" || this._window.closed) { this._abort.raise(/* @__PURE__ */ new Error("Popup blocked by user")); return; } this.close(); }, popupWindowFeatures.closePopupWindowAfterInSeconds * second); } async navigate(params) { var _a; (_a = this._window) == null || _a.focus(); const popupClosedInterval = setInterval(() => { if (!this._window || this._window.closed) { this._logger.debug("Popup closed by user or isolated by redirect"); clearPopupClosedInterval(); this._disposeHandlers.delete(clearPopupClosedInterval); if (this.abortOnClose) this._abort.raise(/* @__PURE__ */ new Error("Popup closed by user")); } }, checkForPopupClosedInterval); const clearPopupClosedInterval = () => clearInterval(popupClosedInterval); this._disposeHandlers.add(clearPopupClosedInterval); return await super.navigate(params); } close() { if (this._window) { if (!this._window.closed) { this._window.close(); this._abort.raise(/* @__PURE__ */ new Error("Popup closed")); } } this._window = null; } static notifyOpener(url, keepOpen) { super._notifyParent(window.opener, url, keepOpen); if (!keepOpen && !window.opener) window.close(); } }; var PopupNavigator = class { constructor(_settings) { this._settings = _settings; this._logger = new Logger("PopupNavigator"); } async prepare({ popupWindowFeatures = this._settings.popupWindowFeatures, popupWindowTarget = this._settings.popupWindowTarget, popupSignal, popupAbortOnClose }) { return new PopupWindow({ popupWindowFeatures, popupWindowTarget, popupSignal, popupAbortOnClose }); } async callback(url, { keepOpen = false }) { this._logger.create("callback"); PopupWindow.notifyOpener(url, keepOpen); } }; var RedirectNavigator = class { constructor(_settings) { this._settings = _settings; this._logger = new Logger("RedirectNavigator"); } async prepare({ redirectMethod = this._settings.redirectMethod, redirectTarget = this._settings.redirectTarget }) { var _a; this._logger.create("prepare"); let targetWindow = window.self; if (redirectTarget === "top") targetWindow = (_a = window.top) != null ? _a : window.self; const redirect = targetWindow.location[redirectMethod].bind(targetWindow.location); let abort; return { navigate: async (params) => { this._logger.create("navigate"); return await new Promise((resolve, reject) => { abort = reject; window.addEventListener("pageshow", () => resolve(window.location.href)); redirect(params.url); }); }, close: () => { this._logger.create("close"); abort?.(/* @__PURE__ */ new Error("Redirect aborted")); targetWindow.stop(); } }; } async callback() {} }; var UserManagerEvents = class extends AccessTokenEvents { constructor(settings) { super({ expiringNotificationTimeInSeconds: settings.accessTokenExpiringNotificationTimeInSeconds }); this._logger = new Logger("UserManagerEvents"); this._userLoaded = new Event$1("User loaded"); this._userUnloaded = new Event$1("User unloaded"); this._silentRenewError = new Event$1("Silent renew error"); this._userSignedIn = new Event$1("User signed in"); this._userSignedOut = new Event$1("User signed out"); this._userSessionChanged = new Event$1("User session changed"); } async load(user, raiseEvent = true) { await super.load(user); if (raiseEvent) await this._userLoaded.raise(user); } async unload() { await super.unload(); await this._userUnloaded.raise(); } /** * Add callback: Raised when a user session has been established (or re-established). */ addUserLoaded(cb) { return this._userLoaded.addHandler(cb); } /** * Remove callback: Raised when a user session has been established (or re-established). */ removeUserLoaded(cb) { return this._userLoaded.removeHandler(cb); } /** * Add callback: Raised when a user session has been terminated. */ addUserUnloaded(cb) { return this._userUnloaded.addHandler(cb); } /** * Remove callback: Raised when a user session has been terminated. */ removeUserUnloaded(cb) { return this._userUnloaded.removeHandler(cb); } /** * Add callback: Raised when the automatic silent renew has failed. */ addSilentRenewError(cb) { return this._silentRenewError.addHandler(cb); } /** * Remove callback: Raised when the automatic silent renew has failed. */ removeSilentRenewError(cb) { return this._silentRenewError.removeHandler(cb); } /** * @internal */ async _raiseSilentRenewError(e) { await this._silentRenewError.raise(e); } /** * Add callback: Raised when the user is signed in (when `monitorSession` is set). * @see {@link UserManagerSettings.monitorSession} */ addUserSignedIn(cb) { return this._userSignedIn.addHandler(cb); } /** * Remove callback: Raised when the user is signed in (when `monitorSession` is set). */ removeUserSignedIn(cb) { this._userSignedIn.removeHandler(cb); } /** * @internal */ async _raiseUserSignedIn() { await this._userSignedIn.raise(); } /** * Add callback: Raised when the user's sign-in status at the OP has changed (when `monitorSession` is set). * @see {@link UserManagerSettings.monitorSession} */ addUserSignedOut(cb) { return this._userSignedOut.addHandler(cb); } /** * Remove callback: Raised when the user's sign-in status at the OP has changed (when `monitorSession` is set). */ removeUserSignedOut(cb) { this._userSignedOut.removeHandler(cb); } /** * @internal */ async _raiseUserSignedOut() { await this._userSignedOut.raise(); } /** * Add callback: Raised when the user session changed (when `monitorSession` is set). * @see {@link UserManagerSettings.monitorSession} */ addUserSessionChanged(cb) { return this._userSessionChanged.addHandler(cb); } /** * Remove callback: Raised when the user session changed (when `monitorSession` is set). */ removeUserSessionChanged(cb) { this._userSessionChanged.removeHandler(cb); } /** * @internal */ async _raiseUserSessionChanged() { await this._userSessionChanged.raise(); } }; var SilentRenewService = class { constructor(_userManager) { this._userManager = _userManager; this._logger = new Logger("SilentRenewService"); this._isStarted = false; this._retryTimer = new Timer("Retry Silent Renew"); this._timeoutRetryCount = 0; this._tokenExpiring = async () => { const logger2 = this._logger.create("_tokenExpiring"); try { await this._userManager.signinSilent(); this._timeoutRetryCount = 0; logger2.debug("silent token renewal successful"); } catch (err) { if (err instanceof ErrorTimeout) { this._timeoutRetryCount++; const maxRetries = this._userManager.settings.maxSilentRenewTimeoutRetries; if (maxRetries !== void 0 && this._timeoutRetryCount > maxRetries) { logger2.error(`Timeout retry limit reached (${this._timeoutRetryCount} > ${maxRetries}), raising silentRenewError:`, err); this._timeoutRetryCount = 0; await this._userManager.events._raiseSilentRenewError(err); return; } logger2.warn(`ErrorTimeout from signinSilent (attempt ${this._timeoutRetryCount}), retry in 5s:`, err); this._retryTimer.init(5); return; } logger2.error("Error from signinSilent:", err); this._timeoutRetryCount = 0; await this._userManager.events._raiseSilentRenewError(err); } }; } async start() { const logger2 = this._logger.create("start"); if (!this._isStarted) { this._isStarted = true; this._userManager.events.addAccessTokenExpiring(this._tokenExpiring); this._retryTimer.addHandler(this._tokenExpiring); try { await this._userManager.getUser(); } catch (err) { logger2.error("getUser error", err); } } } stop() { if (this._isStarted) { this._retryTimer.cancel(); this._retryTimer.removeHandler(this._tokenExpiring); this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring); this._isStarted = false; } } }; var RefreshState = class { constructor(args) { this.refresh_token = args.refresh_token; this.id_token = args.id_token; this.session_state = args.session_state; this.scope = args.scope; this.profile = args.profile; this.data = args.state; } }; var UserManager = class { constructor(settings, redirectNavigator, popupNavigator, iframeNavigator) { this._logger = new Logger("UserManager"); this.settings = new UserManagerSettingsStore(settings); this._client = new OidcClient(settings); this._redirectNavigator = redirectNavigator != null ? redirectNavigator : new RedirectNavigator(this.settings); this._popupNavigator = popupNavigator != null ? popupNavigator : new PopupNavigator(this.settings); this._iframeNavigator = iframeNavigator != null ? iframeNavigator : new IFrameNavigator(this.settings); this._events = new UserManagerEvents(this.settings); this._silentRenewService = new SilentRenewService(this); if (this.settings.automaticSilentRenew) this.startSilentRenew(); this._sessionMonitor = null; if (this.settings.monitorSession) this._sessionMonitor = new SessionMonitor(this); } /** * Get object used to register for events raised by the `UserManager`. */ get events() { return this._events; } /** * Get object used to access the metadata configuration of the identity provider. */ get metadataService() { return this._client.metadataService; } /** * Load the `User` object for the currently authenticated user. * * @param raiseEvent - If `true`, the `UserLoaded` event will be raised. Defaults to false. * @returns A promise */ async getUser(raiseEvent = false) { const logger2 = this._logger.create("getUser"); const user = await this._loadUser(); if (user) { logger2.info("user loaded"); await this._events.load(user, raiseEvent); return user; } logger2.info("user not found in storage"); return null; } /** * Remove from any storage the currently authenticated user. * * @returns A promise */ async removeUser() { const logger2 = this._logger.create("removeUser"); await this.storeUser(null); logger2.info("user removed from storage"); await this._events.unload(); } /** * Trigger a redirect of the current window to the authorization endpoint. * * @returns A promise * * @throws `Error` In cases of wrong authentication. */ async signinRedirect(args = {}) { var _a; this._logger.create("signinRedirect"); const { redirectMethod, ...requestArgs } = args; let dpopJkt; if ((_a = this.settings.dpop) == null ? void 0 : _a.bind_authorization_code) dpopJkt = await this.generateDPoPJkt(this.settings.dpop); const handle = await this._redirectNavigator.prepare({ redirectMethod }); await this._signinStart({ request_type: "si:r", dpopJkt, ...requestArgs }, handle); } /** * Process the response (callback) from the authorization endpoint. * It is recommended to use {@link UserManager.signinCallback} instead. * * @returns A promise containing the authenticated `User`. * * @see {@link UserManager.signinCallback} */ async signinRedirectCallback(url = window.location.href) { const logger2 = this._logger.create("signinRedirectCallback"); const user = await this._signinEnd(url); if (user.profile && user.profile.sub) logger2.info("success, signed in subject", user.profile.sub); else logger2.info("no subject"); return user; } /** * Trigger the signin with user/password. * * @returns A promise containing the authenticated `User`. * @throws {@link ErrorResponse} In cases of wrong authentication. */ async signinResourceOwnerCredentials({ username, password, skipUserInfo = false }) { const logger2 = this._logger.create("signinResourceOwnerCredential"); const signinResponse = await this._client.processResourceOwnerPasswordCredentials({ username, password, skipUserInfo, extraTokenParams: this.settings.extraTokenParams }); logger2.debug("got signin response"); const user = await this._buildUser(signinResponse); if (user.profile && user.profile.sub) logger2.info("success, signed in subject", user.profile.sub); else logger2.info("no subject"); return user; } /** * Trigger a request (via a popup window) to the authorization endpoint. * * @returns A promise containing the authenticated `User`. * @throws `Error` In cases of wrong authentication. */ async signinPopup(args = {}) { var _a; const logger2 = this._logger.create("signinPopup"); let dpopJkt; if ((_a = this.settings.dpop) == null ? void 0 : _a.bind_authorization_code) dpopJkt = await this.generateDPoPJkt(this.settings.dpop); const { popupWindowFeatures, popupWindowTarget, popupSignal, popupAbortOnClose, ...requestArgs } = args; const url = this.settings.popup_redirect_uri; if (!url) logger2.throw(/* @__PURE__ */ new Error("No popup_redirect_uri configured")); const handle = await this._popupNavigator.prepare({ popupWindowFeatures, popupWindowTarget, popupSignal, popupAbortOnClose }); const user = await this._signin({ request_type: "si:p", redirect_uri: url, display: "popup", dpopJkt, ...requestArgs }, handle); if (user) if (user.profile && user.profile.sub) logger2.info("success, signed in subject", user.profile.sub); else logger2.info("no subject"); return user; } /** * Notify the opening window of response (callback) from the authorization endpoint. * It is recommended to use {@link UserManager.signinCallback} instead. * * @returns A promise * * @see {@link UserManager.signinCallback} */ async signinPopupCallback(url = window.location.href, keepOpen = false) { const logger2 = this._logger.create("signinPopupCallback"); await this._popupNavigator.callback(url, { keepOpen }); logger2.info("success"); } /** * Trigger a silent request (via refresh token or an iframe) to the authorization endpoint. * * @returns A promise that contains the authenticated `User`. */ async signinSilent(args = {}) { var _a, _b; const logger2 = this._logger.create("signinSilent"); const { silentRequestTimeoutInSeconds, ...requestArgs } = args; let user = await this._loadUser(); if (!args.forceIframeAuth && (user == null ? void 0 : user.refresh_token)) { logger2.debug("using refresh token"); const state = new RefreshState(user); return await this._useRefreshToken({ state, redirect_uri: requestArgs.redirect_uri, resource: requestArgs.resource, extraTokenParams: requestArgs.extraTokenParams, timeoutInSeconds: silentRequestTimeoutInSeconds }); } let dpopJkt; if ((_a = this.settings.dpop) == null ? void 0 : _a.bind_authorization_code) dpopJkt = await this.generateDPoPJkt(this.settings.dpop); const url = this.settings.silent_redirect_uri; if (!url) logger2.throw(/* @__PURE__ */ new Error("No silent_redirect_uri configured")); let verifySub; if (user && this.settings.validateSubOnSilentRenew) { logger2.debug("subject prior to silent renew:", user.profile.sub); verifySub = user.profile.sub; } const handle = await this._iframeNavigator.prepare({ silentRequestTimeoutInSeconds }); user = await this._signin({ request_type: "si:s", redirect_uri: url, prompt: "none", id_token_hint: this.settings.includeIdTokenInSilentRenew ? user == null ? void 0 : user.id_token : void 0, dpopJkt, ...requestArgs }, handle, verifySub); if (user) if ((_b = user.profile) == null ? void 0 : _b.sub) logger2.info("success, signed in subject", user.profile.sub); else logger2.info("no subject"); return user; } async _useRefreshToken(args) { const response = await this._client.useRefreshToken({ timeoutInSeconds: this.settings.silentRequestTimeoutInSeconds, ...args }); const user = new User({ ...args.state, ...response }); await this.storeUser(user); await this._events.load(user); return user; } /** * * Notify the parent window of response (callback) from the authorization endpoint. * It is recommended to use {@link UserManager.signinCallback} instead. * * @returns A promise * * @see {@link UserManager.signinCallback} */ async signinSilentCallback(url = window.location.href) { const logger2 = this._logger.create("signinSilentCallback"); await this._iframeNavigator.callback(url); logger2.info("success"); } /** * Process any response (callback) from the authorization endpoint, by dispatching the request_type * and executing one of the following functions: * - {@link UserManager.signinRedirectCallback} * - {@link UserManager.signinPopupCallback} * - {@link UserManager.signinSilentCallback} * * @throws `Error` If request_type is unknown or signin cannot be processed. */ async signinCallback(url = window.location.href) { const { state } = await this._client.readSigninResponseState(url); switch (state.request_type) { case "si:r": return await this.signinRedirectCallback(url); case "si:p": await this.signinPopupCallback(url); break; case "si:s": await this.signinSilentCallback(url); break; default: throw new Error("invalid request_type in state"); } } /** * Process any response (callback) from the end session endpoint, by dispatching the request_type * and executing one of the following functions: * - {@link UserManager.signoutRedirectCallback} * - {@link UserManager.signoutPopupCallback} * - {@link UserManager.signoutSilentCallback} * * @throws `Error` If request_type is unknown or signout cannot be processed. */ async signoutCallback(url = window.location.href, keepOpen = false) { const { state } = await this._client.readSignoutResponseState(url); if (!state) return; switch (state.request_type) { case "so:r": return await this.signoutRedirectCallback(url); case "so:p": await this.signoutPopupCallback(url, keepOpen); break; case "so:s": await this.signoutSilentCallback(url); break; default: throw new Error("invalid request_type in state"); } } /** * Query OP for user's current signin status. * * @returns A promise object with session_state and subject identifier. */ async querySessionStatus(args = {}) { const logger2 = this._logger.create("querySessionStatus"); const { silentRequestTimeoutInSeconds, ...requestArgs } = args; const url = this.settings.silent_redirect_uri; if (!url) logger2.throw(/* @__PURE__ */ new Error("No silent_redirect_uri configured")); const user = await this._loadUser(); const handle = await this._iframeNavigator.prepare({ silentRequestTimeoutInSeconds }); const navResponse = await this._signinStart({ request_type: "si:s", redirect_uri: url, prompt: "none", id_token_hint: this.settings.includeIdTokenInSilentRenew ? user == null ? void 0 : user.id_token : void 0, response_type: this.settings.query_status_response_type, scope: "openid", skipUserInfo: true, ...requestArgs }, handle); try { const signinResponse = await this._client.processSigninResponse(navResponse.url, {}); logger2.debug("got signin response"); if (signinResponse.session_state && signinResponse.profile.sub) { logger2.info("success for subject", signinResponse.profile.sub); return { session_state: signinResponse.session_state, sub: signinResponse.profile.sub }; } logger2.info("success, user not authenticated"); return null; } catch (err) { if (this.settings.monitorAnonymousSession && err instanceof ErrorResponse) switch (err.error) { case "login_required": case "consent_required": case "interaction_required": case "account_selection_required": logger2.info("success for anonymous user"); return { session_state: err.session_state }; } throw err; } } async _signin(args, handle, verifySub) { const navResponse = await this._signinStart(args, handle); return await this._signinEnd(navResponse.url, verifySub); } async _signinStart(args, handle) { const logger2 = this._logger.create("_signinStart"); try { const signinRequest = await this._client.createSigninRequest(args); logger2.debug("got signin request"); return await handle.navigate({ url: signinRequest.url, state: signinRequest.state.id, response_mode: signinRequest.state.response_mode, scriptOrigin: this.settings.iframeScriptOrigin }); } catch (err) { logger2.debug("error after preparing navigator, closing navigator window"); handle.close(); throw err; } } async _signinEnd(url, verifySub) { const logger2 = this._logger.create("_signinEnd"); const signinResponse = await this._client.processSigninResponse(url, {}); logger2.debug("got signin response"); return await this._buildUser(signinResponse, verifySub); } async _buildUser(signinResponse, verifySub) { const logger2 = this._logger.create("_buildUser"); const user = new User(signinResponse); if (verifySub) { if (verifySub !== user.profile.sub) { logger2.debug("current user does not match user returned from signin. sub from signin:", user.profile.sub); throw new ErrorResponse({ ...signinResponse, error: "login_required" }); } logger2.debug("current user matches user returned from signin"); } await this.storeUser(user); logger2.debug("user stored"); await this._events.load(user); return user; } /** * Trigger a redirect of the current window to the end session endpoint. * * @returns A promise */ async signoutRedirect(args = {}) { const logger2 = this._logger.create("signoutRedirect"); const { redirectMethod, ...requestArgs } = args; const handle = await this._redirectNavigator.prepare({ redirectMethod }); await this._signoutStart({ request_type: "so:r", post_logout_redirect_uri: this.settings.post_logout_redirect_uri, ...requestArgs }, handle); logger2.info("success"); } /** * Process response (callback) from the end session endpoint. * It is recommended to use {@link UserManager.signoutCallback} instead. * * @returns A promise containing signout response * * @see {@link UserManager.signoutCallback} */ async signoutRedirectCallback(url = window.location.href) { const logger2 = this._logger.create("signoutRedirectCallback"); const response = await this._signoutEnd(url); logger2.info("success"); return response; } /** * Trigger a redirect of a popup window to the end session endpoint. * * @returns A promise */ async signoutPopup(args = {}) { const logger2 = this._logger.create("signoutPopup"); const { popupWindowFeatures, popupWindowTarget, popupSignal, ...requestArgs } = args; const url = this.settings.popup_post_logout_redirect_uri; const handle = await this._popupNavigator.prepare({ popupWindowFeatures, popupWindowTarget, popupSignal }); await this._signout({ request_type: "so:p", post_logout_redirect_uri: url, state: url == null ? void 0 : {}, ...requestArgs }, handle); logger2.info("success"); } /** * Process response (callback) from the end session endpoint from a popup window. * It is recommended to use {@link UserManager.signoutCallback} instead. * * @returns A promise * * @see {@link UserManager.signoutCallback} */ async signoutPopupCallback(url = window.location.href, keepOpen = false) { const logger2 = this._logger.create("signoutPopupCallback"); await this._popupNavigator.callback(url, { keepOpen }); logger2.info("success"); } async _signout(args, handle) { const navResponse = await this._signoutStart(args, handle); return await this._signoutEnd(navResponse.url); } async _signoutStart(args = {}, handle) { var _a; const logger2 = this._logger.create("_signoutStart"); try { const user = await this._loadUser(); logger2.debug("loaded current user from storage"); if (this.settings.revokeTokensOnSignout) await this._revokeInternal(user); const id_token = args.id_token_hint || user && user.id_token; if (id_token) { logger2.debug("setting id_token_hint in signout request"); args.id_token_hint = id_token; } await this.removeUser(); logger2.debug("user removed, creating signout request"); const signoutRequest = await this._client.createSignoutRequest(args); logger2.debug("got signout request"); return await handle.navigate({ url: signoutRequest.url, state: (_a = signoutRequest.state) == null ? void 0 : _a.id, scriptOrigin: this.settings.iframeScriptOrigin }); } catch (err) { logger2.debug("error after preparing navigator, closing navigator window"); handle.close(); throw err; } } async _signoutEnd(url) { const logger2 = this._logger.create("_signoutEnd"); const signoutResponse = await this._client.processSignoutResponse(url); logger2.debug("got signout response"); return signoutResponse; } /** * Trigger a silent request (via an iframe) to the end session endpoint. * * @returns A promise */ async signoutSilent(args = {}) { var _a; const logger2 = this._logger.create("signoutSilent"); const { silentRequestTimeoutInSeconds, ...requestArgs } = args; const id_token_hint = this.settings.includeIdTokenInSilentSignout ? (_a = await this._loadUser()) == null ? void 0 : _a.id_token : void 0; const url = this.settings.popup_post_logout_redirect_uri; const handle = await this._iframeNavigator.prepare({ silentRequestTimeoutInSeconds }); await this._signout({ request_type: "so:s", post_logout_redirect_uri: url, id_token_hint, ...requestArgs }, handle); logger2.info("success"); } /** * Notify the parent window of response (callback) from the end session endpoint. * It is recommended to use {@link UserManager.signoutCallback} instead. * * @returns A promise * * @see {@link UserManager.signoutCallback} */ async signoutSilentCallback(url = window.location.href) { const logger2 = this._logger.create("signoutSilentCallback"); await this._iframeNavigator.callback(url); logger2.info("success"); } async revokeTokens(types) { const user = await this._loadUser(); await this._revokeInternal(user, types); } async _revokeInternal(user, types = this.settings.revokeTokenTypes) { const logger2 = this._logger.create("_revokeInternal"); if (!user) return; const typesPresent = types.filter((type) => typeof user[type] === "string"); if (!typesPresent.length) { logger2.debug("no need to revoke due to no token(s)"); return; } for (const type of typesPresent) { await this._client.revokeToken(user[type], type); logger2.info(`${type} revoked successfully`); if (type !== "access_token") user[type] = null; } await this.storeUser(user); logger2.debug("user stored"); await this._events.load(user); } /** * Enables silent renew for the `UserManager`. */ startSilentRenew() { this._logger.create("startSilentRenew"); this._silentRenewService.start(); } /** * Disables silent renew for the `UserManager`. */ stopSilentRenew() { this._silentRenewService.stop(); } get _userStoreKey() { return `user:${this.settings.authority}:${this.settings.client_id}`; } async _loadUser() { const logger2 = this._logger.create("_loadUser"); const storageString = await this.settings.userStore.get(this._userStoreKey); if (storageString) { logger2.debug("user storageString loaded"); return User.fromStorageString(storageString); } logger2.debug("no user storageString"); return null; } async storeUser(user) { const logger2 = this._logger.create("storeUser"); if (user) { logger2.debug("storing user"); const storageString = user.toStorageString(); await this.settings.userStore.set(this._userStoreKey, storageString); } else { this._logger.debug("removing user"); await this.settings.userStore.remove(this._userStoreKey); if (this.settings.dpop) await this.settings.dpop.store.remove(this.settings.client_id); } } /** * Removes stale state entries in storage for incomplete authorize requests. */ async clearStaleState() { await this._client.clearStaleState(); } /** * Dynamically generates a DPoP proof for a given user, URL and optional Http method. * This method is useful when you need to make a request to a resource server * with fetch or similar, and you need to include a DPoP proof in a DPoP header. * @param url - The URL to generate the DPoP proof for * @param user - The user to generate the DPoP proof for * @param httpMethod - Optional, defaults to "GET" * @param nonce - Optional nonce provided by the resource server * * @returns A promise containing the DPoP proof or undefined if DPoP is not enabled/no user is found. */ async dpopProof(url, user, httpMethod, nonce) { var _a, _b; const dpopState = await ((_b = (_a = this.settings.dpop) == null ? void 0 : _a.store) == null ? void 0 : _b.get(this.settings.client_id)); if (dpopState) return await CryptoUtils.generateDPoPProof({ url, accessToken: user == null ? void 0 : user.access_token, httpMethod, keyPair: dpopState.keys, nonce }); } async generateDPoPJkt(dpopSettings) { let dpopState = await dpopSettings.store.get(this.settings.client_id); if (!dpopState) { dpopState = new DPoPState(await CryptoUtils.generateDPoPKeys()); await dpopSettings.store.set(this.settings.client_id, dpopState); } return await CryptoUtils.generateDPoPJkt(dpopState.keys); } }; //#endregion //#region ../send/frontend/src/stores/auth-store.ts var auth_store_exports = /* @__PURE__ */ __exportAll({ useAuthStore: () => useAuthStore }); var settings = { authority: "https://auth.tb.pro/realms/tbpro/", client_id: "desktop", redirect_uri: `${window.location.origin}/post-login`, post_logout_redirect_uri: `https://send.tb.pro/logout`, response_type: "code", scope: "openid profile email offline_access", automaticSilentRenew: false, filterProtocolClaims: true, loadUserInfo: false }; var userManager = new UserManager(settings); /** * OIDC error codes that mean the session is genuinely over — the refresh token * was revoked or has expired. Any other failure (network, timeout, userinfo) * is transient and must NOT drop the user out of a still-valid session. */ var GENUINE_AUTH_FAILURE_CODES = [ "invalid_grant", "login_required", "session_expired" ]; function isGenuineAuthFailure(error) { const code = error?.error; return typeof code === "string" && GENUINE_AUTH_FAILURE_CODES.includes(code); } var forcedLogoutInProgress = false; var useAuthStore = defineStore("auth", () => { const { api } = useApiStore(); const { isExtension, isThunderbirdHost } = useConfigStore(); const isLoggedIn = /* @__PURE__ */ ref(false); const currentUser = /* @__PURE__ */ ref(null); watch(isLoggedIn, (newValue) => { console.info("isLoggedIn changed", newValue); }); let inFlightRefresh = null; let lastRefreshFailedGenuinely = false; /** * Notify the add-on background that the session is over so its menu reverts * to logged-out. Only meaningful inside Thunderbird, where the token-bridge * content script forwards window messages to background.ts — the same path * UserMenu.vue uses on explicit logout. */ function notifyAddonSignedOut() { if (!isThunderbirdHost) return; try { window.postMessage({ type: SIGN_OUT }, window.location.origin); } catch (error) { console.error("Failed to notify add-on of sign-out:", error); } } /** * Refresh the access token via the refresh_token, deduping concurrent callers. * * Returns the refreshed User on success. On a genuine auth failure (refresh * token revoked/expired) it clears local login state, notifies the add-on, * and returns null. On a transient failure (network/timeout) it leaves the * session intact and returns null so a later call can retry — we do not log * the user out over a blip. */ async function refreshAccessToken() { if (inFlightRefresh) return inFlightRefresh; inFlightRefresh = (async () => { lastRefreshFailedGenuinely = false; try { const user = await userManager.signinSilent(); currentUser.value = user; if (isExtension && user) await browser.storage.local.set({ [STORAGE_KEY_AUTH]: user }); return user; } catch (error) { if (isGenuineAuthFailure(error)) { lastRefreshFailedGenuinely = true; console.warn(`Silent token refresh failed — session ended (${error.error}). Signing out.`); isLoggedIn.value = false; currentUser.value = null; notifyAddonSignedOut(); } else console.warn("Silent token refresh hit a transient error; keeping session:", error); return null; } finally { inFlightRefresh = null; } })(); return inFlightRefresh; } async function getOIDCUser() { try { return await userManager.getUser(); } catch (error) { console.error("Failed to get OIDC user:", error); return null; } } /** * Web to add-on — Step 2: Start the OIDC login process. * * Redirects the browser (or extension popup) to accounts.tb.pro. * The OIDC provider authenticates the user and redirects back to * /post-login (or /post-login?isExtension=true) with an authorization code. * * Web flow : redirect_uri = /post-login * Extension : redirect_uri = /post-login?isExtension=true * The isExtension flag is read by PostLoginPage / the router * guard after login to skip the key-backup prompt. */ async function loginToOIDC({ onSuccess, isExtension }) { try { if (isExtension) await userManager.signinRedirect({ redirect_uri: `${window.location.origin}/post-login?isExtension=${isExtension}` }); else await userManager.signinRedirect(); if (onSuccess) onSuccess(); } catch (error) { console.error("OIDC login failed:", error); throw error; } } /** * Web to add-on — Steps 5–8: Handle the OIDC redirect callback. * * Called by PostLoginPage.vue after accounts.tb.pro redirects back to * /post-login with an authorization code in the URL. * * Step 5 — Token exchange: * signinCallback() reads the code from the URL and exchanges it with * the OIDC token endpoint for access_token, refresh_token, and id_token. * * Step 6 — Notify the background script via the token-bridge: * Because this page runs as a normal web tab, we cannot call * browser.runtime.sendMessage() directly. Instead we use window.postMessage * and rely on token-bridge.js (a content script injected into every tab) * to forward the messages to background.ts. * • OIDC_TOKEN → background creates/updates the Thundermail mail account * using the refresh token as the OAuth2 credential. * • OIDC_USER → background stores the full User object in * browser.storage.local[STORAGE_KEY_AUTH] so the add-on * popup/menu can read it back via loadUser(). * * Step 7 — Update background state (handled by background.ts, see there). * * Step 8 — Authenticate with the backend: * POSTs the access_token as a Bearer token to auth/oidc/authenticate. * The backend introspects it against the OIDC provider, finds or creates * the user record, and responds with httpOnly JWT session cookies that * all subsequent API calls use. */ async function handleOIDCCallback() { try { const user = await userManager.signinCallback(); currentUser.value = user; window.addEventListener("message", (e) => { if (e.origin === window.location.origin && e.data?.type === "TB/BRIDGE_READY") console.log("[web app] bridge says: ready"); }); window.postMessage({ type: BRIDGE_PING, text: "hello from auth store 👋" }, window.location.origin); window.postMessage({ type: OIDC_TOKEN, token: user.refresh_token, email: user.profile.preferred_username, name: user.profile.name || user.profile.given_name }, window.location.origin); window.postMessage({ type: OIDC_USER, user }, window.location.origin); const response = await api.call("auth/oidc/authenticate", { method: "POST", headers: { Authorization: `Bearer ${user.access_token}`, "Content-Type": "application/json" } }); if (response?.user) { isLoggedIn.value = true; return response.user; } else throw new Error("Backend authentication failed"); } catch (error) { console.error("OIDC callback handling failed:", error); throw error; } } /** * Check if user is currently authenticated and get user info */ async function checkAuthStatus() { try { if (isExtension) await loadUser(); let user = await userManager.getUser(); if (user?.expired) { user = await refreshAccessToken(); if (!user) return null; } if (user && !user.expired) { currentUser.value = user; const response = await api.call("auth/oidc/me", { headers: { Authorization: `Bearer ${user.access_token}` } }); if (response?.user) { isLoggedIn.value = true; return response.user; } } isLoggedIn.value = false; currentUser.value = null; return null; } catch (error) { console.error("Auth status check failed:", error); isLoggedIn.value = false; currentUser.value = null; return null; } } /** * Get the current access token for API requests. * Transparently refreshes the token if it has expired. */ async function getAccessToken() { try { let user = await userManager.getUser(); if (!user) return null; if (user.expired) user = await refreshAccessToken(); return user?.access_token || null; } catch (error) { console.error("Failed to get access token:", error); return null; } } /** * Forced logout in response to the backend's x-logout header (#960): the * session was ended server-side (logout elsewhere, password change, admin * revoke). Clear local auth and return to a clean state. Deliberately does * NOT call the API (that path is what surfaced x-logout, so calling it again * would loop); it only clears client state and redirects. */ async function handleForcedLogout() { if (forcedLogoutInProgress) return; forcedLogoutInProgress = true; try { isLoggedIn.value = false; currentUser.value = null; try { await userManager.removeUser(); } catch {} try { if (typeof browser !== "undefined") { await browser.storage.local.remove(STORAGE_KEY_AUTH); browser.runtime.sendMessage({ type: SIGN_OUT }); } } catch {} if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("tbpro:force-logout")); } finally { forcedLogoutInProgress = false; } } /** * Logout from OIDC and clear local state */ async function logoutFromOIDC() { try { await api.call("auth/oidc/logout", {}, "POST"); await userManager.signoutRedirect(); } catch (error) { console.error("OIDC logout failed:", error); isLoggedIn.value = false; currentUser.value = null; } finally { await browser.storage.local.remove(STORAGE_KEY_AUTH); browser.runtime.sendMessage({ type: SIGN_OUT }); } } /** * Silent refresh of the access token. Delegates to the deduped * refreshAccessToken(), which owns state/notification on genuine failure and * preserves the session on transient errors. */ async function refreshToken() { return (await refreshAccessToken())?.access_token ?? null; } /** * The backend reported the current access token revoked (x-logout, #960). * Before tearing the session down, try a silent refresh: a revoked/expired * *access* token can often be replaced using a still-valid *refresh* token, * so the session keeps rolling instead of bouncing the user to login (PR #974 * review). Only force logout when the refresh token is also gone; on a * transient refresh error keep the session (fail open). * * Goes through refreshAccessToken() — an unconditional signinSilent — rather * than getAccessToken(), because the token behind x-logout is still within * its lifetime (the backend exp-gates the signal), so getAccessToken() would * hand back the same stale, revoked token without refreshing. * * @returns `true` if the session was recovered — the caller should retry the * request with the fresh token — and `false` otherwise (forced logout on a * genuine failure, or session kept on a transient error). */ async function recoverOrForceLogout() { const user = await refreshAccessToken(); if (user && !user.expired) return true; if (lastRefreshFailedGenuinely) await handleForcedLogout(); return false; } async function loadUser() { try { const result = await browser.storage.local.get(STORAGE_KEY_AUTH); if (result["STORAGE_KEY_AUTH"]) { const userInstance = new User(result[STORAGE_KEY_AUTH]); await userManager.storeUser(userInstance); } else { await userManager.removeUser(); isLoggedIn.value = false; currentUser.value = null; } } catch (e) { console.log(`No error. Only works if running in add-on.`); console.log(e); } } /** * Add-On to Web — Steps 3–8: Authenticate using a token set provided by the add-on. * * Called by AddonAuthPage.vue when the /addon-auth route loads. The add-on * already obtained an OIDC token set from accounts.tb.pro and staged it in * browser.storage.local via triggerAddonLogin(). Because this page runs as a * normal web tab, it cannot access browser.storage.local directly — instead * it requests the token via message-passing through the token-bridge content * script, then uses it to authenticate with the backend. * * Full flow (Add-On to Web): * 1. background.ts – triggerAddonLogin() stores token, opens /addon-auth * 2. AddonAuthPage.vue loads, calls this function * 3. POST GET_PENDING_ADDON_TOKEN → token-bridge → background * 4. background reads storage, responds with PENDING_ADDON_TOKEN_RESPONSE, * then deletes the staging key * 5. token-bridge forwards response → window.postMessage → Promise resolves * 6. User object is reconstructed (or obtained via signinSilent) * 7. OIDC_TOKEN + OIDC_USER are posted so the background keeps its own * state in sync (Thundermail account setup, STORAGE_KEY_AUTH) * 8. POST auth/oidc/authenticate — backend issues session cookies * 9. AddonAuthPage posts SIGN_IN_COMPLETE → background closes tab */ async function authenticateWithAddonToken() { const tokenSet = await new Promise((resolve, reject) => { const timeout = setTimeout(() => { window.removeEventListener("message", handler); reject(/* @__PURE__ */ new Error("Timed out waiting for pending addon token")); }, 5e3); function handler(e) { if (e.origin === window.location.origin && e.data?.type === "TB/PENDING_ADDON_TOKEN_RESPONSE") { clearTimeout(timeout); window.removeEventListener("message", handler); resolve(e.data.tokenSet ?? null); } } window.addEventListener("message", handler); window.postMessage({ type: GET_PENDING_ADDON_TOKEN }, window.location.origin); }); if (!tokenSet?.refresh_token) throw new Error("No pending addon token found in storage"); let user; if (tokenSet.access_token && tokenSet.id_token) { const idTokenPayload = JSON.parse(atob(tokenSet.id_token.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"))); user = new User({ access_token: tokenSet.access_token, refresh_token: tokenSet.refresh_token, id_token: tokenSet.id_token, token_type: "Bearer", scope: tokenSet.scope ?? "openid profile email offline_access", expires_at: tokenSet.expires_at ?? idTokenPayload.exp, profile: idTokenPayload }); await userManager.storeUser(user); if (user.expired) user = await userManager.signinSilent(); } else { await userManager.storeUser(new User({ access_token: "", token_type: "Bearer", refresh_token: tokenSet.refresh_token, scope: tokenSet.scope ?? "openid profile email offline_access", expires_at: 0, profile: { sub: "", iss: settings.authority ?? "", aud: settings.client_id ?? "", exp: 0, iat: 0 } })); user = await userManager.signinSilent(); } currentUser.value = user; window.postMessage({ type: OIDC_TOKEN, token: user.refresh_token, email: user.profile.preferred_username ?? user.profile.email, name: user.profile.name ?? user.profile.given_name }, window.location.origin); window.postMessage({ type: OIDC_USER, user }, window.location.origin); const response = await api.call("auth/oidc/authenticate", { method: "POST", headers: { Authorization: `Bearer ${user.access_token}`, "Content-Type": "application/json" } }); if (response?.user) { isLoggedIn.value = true; return response.user; } else throw new Error("Backend authentication failed"); } return { isLoggedIn, currentUser, loginToOIDC, handleOIDCCallback, checkAuthStatus, getAccessToken, logoutFromOIDC, handleForcedLogout, recoverOrForceLogout, refreshToken, loginToKeyCloak: loginToOIDC, loadUser, getOIDCUser, authenticateWithAddonToken }; }); //#endregion //#region ../send/frontend/src/stores/index.ts var stores_exports = /* @__PURE__ */ __exportAll({ useConfigStore: () => useConfigStore }); //#endregion //#region ../send/frontend/src/lib/auth.ts /** * useAuth is a composable that manages authentication state and actions. * It returns the login status and methods to refetch and log out. * It's important to note that this composable should only be used inside vue components. */ function useAuth() { const { api } = useApiStore(); const authStore = useAuthStore(); const { isLoggedIn } = storeToRefs(authStore); const { refetch: refetchAuth, isLoading } = useQuery({ queryKey: ["session"], queryFn: async () => { try { if (await authStore.checkAuthStatus()) { isLoggedIn.value = true; return true; } } catch (error) { console.debug("OIDC auth check failed:", error); } const isValid = await validateToken(api); isLoggedIn.value = isValid; return isValid; }, refetchOnMount: !isLoggedIn.value ? true : false, refetchOnWindowFocus: !isLoggedIn.value ? true : false }); const logOutAuth = async () => { try { await authStore.logoutFromOIDC(); } catch (error) { console.error("OIDC logout failed:", error); } try { await api.removeAuthToken(); } catch (error) { console.error("Legacy logout failed:", error); } isLoggedIn.value = false; }; return { isLoggedIn, refetchAuth, logOutAuth, isLoadingAuth: isLoading }; } //#endregion //#region ../send/frontend/src/apps/common/FeedbackBox.vue var _sfc_main$1 = {}; var _hoisted_1$5 = { class: "mx-4 mb-4", "data-testid": "feedback-box" }; function _sfc_render$1(_ctx, _cache) { return openBlock(), createElementBlock("section", _hoisted_1$5, [..._cache[0] || (_cache[0] = [createBaseVNode("a", { href: "https://support.tb.pro" }, [createBaseVNode("p", { class: "text" }, "Need help? Visit Support")], -1)])]); } var FeedbackBox_default = /*#__PURE__*/ _plugin_vue_export_helper_default(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-c0a54125"]]); //#endregion //#region ../send/frontend/src/apps/common/RightArrowIcon.vue var _sfc_main = {}; var _hoisted_1$4 = { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" }; function _sfc_render(_ctx, _cache) { return openBlock(), createElementBlock("svg", _hoisted_1$4, [..._cache[0] || (_cache[0] = [createBaseVNode("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M12.663 14.75a.833.833 0 0 0 1.178.011l4.243-4.166a.833.833 0 0 0 0-1.19L13.84 5.24a.833.833 0 1 0-1.167 1.189l2.788 2.739H2.5a.833.833 0 1 0 0 1.666h12.962l-2.788 2.74a.833.833 0 0 0-.011 1.178z", fill: "#1A202C" }, null, -1)])]); } var RightArrowIcon_default = /*#__PURE__*/ _plugin_vue_export_helper_default(_sfc_main, [["render", _sfc_render]]), Tn = /* @__PURE__ */ ((e) => (e.None = "pos-none", e.Top = "pos-top", e.Bottom = "pos-bottom", e.Left = "pos-left", e.Right = "pos-right", e))(Tn || {}), et = /* @__PURE__ */ ((e) => (e.Info = "info", e.Success = "success", e.Warning = "warning", e.Critical = "critical", e))(et || {}), Ia = /* @__PURE__ */ ((e) => (e.Set = "set", e.Primary = "primary", e.Subscription = "subscription", e.Pending = "pending", e.NotSet = "not-set", e.Verified = "verified", e.Emails = "emails", e.Default = "default", e.Counter = "counter", e))(Ia || {}), pe = /* @__PURE__ */ ((e) => (e.Seconds = "second", e.Minutes = "minute", e.Hours = "hour", e.Days = "day", e.Weeks = "week", e.Months = "month", e.Years = "year", e))(pe || {}), ka = /* @__PURE__ */ ((e) => (e.Scan = "scan", e.Pulse = "pulse", e))(ka || {}); Ia.Primary; //#endregion //#region ../../node_modules/.pnpm/@thunderbirdops+services-ui@1.6.3_@vue+compiler-dom@3.5.33_@vue+server-renderer@3.5.33__7f12b2df956c7db6c20fac70750457af/node_modules/@thunderbirdops/services-ui/index.js var z = (e, t) => { const n = e.__vccOpts || e; for (const [s, a] of t) n[s] = a; return n; }; function Ae(e, t) { typeof console < "u" && (console.warn("[intlify] " + e), t && console.warn(t.stack)); } var ke = typeof window < "u"; var Me = (e, t = !1) => t ? Symbol.for(e) : Symbol(e), Ds = (e, t, n) => Ps({ l: e, k: t, s: n }), Ps = (e) => JSON.stringify(e).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/\u0027/g, "\\u0027"), oe = (e) => typeof e == "number" && isFinite(e), Oa = (e) => In(e) === "[object Date]", at = (e) => In(e) === "[object RegExp]", xt = (e) => U(e) && Object.keys(e).length === 0, ce = Object.assign, Rs = Object.create, Z = (e = null) => Rs(e); var Hn; var je = () => Hn || (Hn = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : Z()); function Wn(e) { return e.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/\//g, "/").replace(/=/g, "="); } function Bn(e) { return e.replace(/&(?![a-zA-Z0-9#]{2,6};)/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(//g, ">"); } function $s(e) { return e = e.replace(/(\w+)\s*=\s*"([^"]*)"/g, (s, a, r) => `${a}="${Bn(r)}"`), e = e.replace(/(\w+)\s*=\s*'([^']*)'/g, (s, a, r) => `${a}='${Bn(r)}'`), /\s*on\w+\s*=\s*["']?[^"'>]+["']?/gi.test(e) && (e = e.replace(/(\s+)(on)(\w+\s*=)/gi, "$1on$3")), [/(\s+(?:href|src|action|formaction)\s*=\s*["']?)\s*javascript:/gi, /(style\s*=\s*["'][^"']*url\s*\(\s*)javascript:/gi].forEach((s) => { e = e.replace(s, "$1javascript:"); }), e; } var Vs = Object.prototype.hasOwnProperty; function Te(e, t) { return Vs.call(e, t); } var ee = Array.isArray, q = (e) => typeof e == "function", A = (e) => typeof e == "string", B = (e) => typeof e == "boolean", G = (e) => e !== null && typeof e == "object", xs = (e) => G(e) && q(e.then) && q(e.catch), Sa = Object.prototype.toString, In = (e) => Sa.call(e), U = (e) => In(e) === "[object Object]", Fs = (e) => e == null ? "" : ee(e) || U(e) && e.toString === Sa ? JSON.stringify(e, null, 2) : String(e); function kn(e, t = "") { return e.reduce((n, s, a) => a === 0 ? n + s : n + t + s, ""); } var kt = (e) => !G(e) || ee(e); function At(e, t) { if (kt(e) || kt(t)) throw new Error("Invalid value"); const n = [{ src: e, des: t }]; for (; n.length;) { const { src: s, des: a } = n.pop(); Object.keys(s).forEach((r) => { r !== "__proto__" && (G(s[r]) && !G(a[r]) && (a[r] = Array.isArray(s[r]) ? [] : Z()), kt(a[r]) || kt(s[r]) ? a[r] = s[r] : n.push({ src: s[r], des: a[r] })); }); } } function Hs(e, t, n) { return { line: e, column: t, offset: n }; } function dn(e, t, n) { return { start: e, end: t }; } var R = { EXPECTED_TOKEN: 1, INVALID_TOKEN_IN_PLACEHOLDER: 2, UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER: 3, UNKNOWN_ESCAPE_SEQUENCE: 4, INVALID_UNICODE_ESCAPE_SEQUENCE: 5, UNBALANCED_CLOSING_BRACE: 6, UNTERMINATED_CLOSING_BRACE: 7, EMPTY_PLACEHOLDER: 8, NOT_ALLOW_NEST_PLACEHOLDER: 9, INVALID_LINKED_FORMAT: 10, MUST_HAVE_MESSAGES_IN_PLURAL: 11, UNEXPECTED_EMPTY_LINKED_MODIFIER: 12, UNEXPECTED_EMPTY_LINKED_KEY: 13, UNEXPECTED_LEXICAL_ANALYSIS: 14, UNHANDLED_CODEGEN_NODE_TYPE: 15, UNHANDLED_MINIFIER_NODE_TYPE: 16 }, Ws = 17; R.EXPECTED_TOKEN, R.INVALID_TOKEN_IN_PLACEHOLDER, R.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, R.UNKNOWN_ESCAPE_SEQUENCE, R.INVALID_UNICODE_ESCAPE_SEQUENCE, R.UNBALANCED_CLOSING_BRACE, R.UNTERMINATED_CLOSING_BRACE, R.EMPTY_PLACEHOLDER, R.NOT_ALLOW_NEST_PLACEHOLDER, R.INVALID_LINKED_FORMAT, R.MUST_HAVE_MESSAGES_IN_PLURAL, R.UNEXPECTED_EMPTY_LINKED_MODIFIER, R.UNEXPECTED_EMPTY_LINKED_KEY, R.UNEXPECTED_LEXICAL_ANALYSIS, R.UNHANDLED_CODEGEN_NODE_TYPE, R.UNHANDLED_MINIFIER_NODE_TYPE; function ot(e, t, n = {}) { const { domain: s, messages: a, args: r } = n, o = new SyntaxError(String(e)); return o.code = e, t && (o.location = t), o.domain = s, o; } function Gs(e) { throw e; } var Oe = " ", js = "\r", fe = ` `, Zs = "\u2028", Xs = "\u2029"; function qs(e) { const t = e; let n = 0, s = 1, a = 1, r = 0; const l = (b) => t[b] === js && t[b + 1] === fe, o = (b) => t[b] === fe, i = (b) => t[b] === Xs, f = (b) => t[b] === Zs, _ = (b) => l(b) || o(b) || i(b) || f(b), C = () => n, h = () => s, k = () => a, D = () => r, O = (b) => l(b) || i(b) || f(b) ? fe : t[b], v = () => O(n), d = () => O(n + r); function m() { return r = 0, _(n) && (s++, a = 0), l(n) && n++, n++, a++, t[n]; } function y() { return l(n + r) && r++, r++, t[n + r]; } function g() { n = 0, s = 1, a = 1, r = 0; } function w(b = 0) { r = b; } function S() { const b = n + r; for (; b !== n;) m(); r = 0; } return { index: C, line: h, column: k, peekOffset: D, charAt: O, currentChar: v, currentPeek: d, next: m, peek: y, reset: g, resetPeek: w, skipToPeek: S }; } var Pe = void 0, Yn = "'", Qs = "tokenizer"; function zs(e, t = {}) { const n = t.location !== !1, s = qs(e), a = () => s.index(), r = () => Hs(s.line(), s.column(), s.index()), l = r(), o = a(), i = { currentType: 13, offset: o, startLoc: l, endLoc: l, lastType: 13, lastOffset: o, lastStartLoc: l, lastEndLoc: l, braceNest: 0, inLinked: !1, text: "" }, f = () => i, { onError: _ } = t; function C(c, u, L, ...M) { const J = f(); if (u.column += L, u.offset += L, _) _(ot(c, n ? dn(J.startLoc, u) : null, { domain: Qs, args: M })); } function h(c, u, L) { c.endLoc = r(), c.currentType = u; const M = { type: u }; return n && (M.loc = dn(c.startLoc, c.endLoc)), L != null && (M.value = L), M; } const k = (c) => h(c, 13); function D(c, u) { return c.currentChar() === u ? (c.next(), u) : (C(R.EXPECTED_TOKEN, r(), 0, u), ""); } function O(c) { let u = ""; for (; c.currentPeek() === Oe || c.currentPeek() === fe;) u += c.currentPeek(), c.peek(); return u; } function v(c) { const u = O(c); return c.skipToPeek(), u; } function d(c) { if (c === Pe) return !1; const u = c.charCodeAt(0); return u >= 97 && u <= 122 || u >= 65 && u <= 90 || u === 95; } function m(c) { if (c === Pe) return !1; const u = c.charCodeAt(0); return u >= 48 && u <= 57; } function y(c, u) { const { currentType: L } = u; if (L !== 2) return !1; O(c); const M = d(c.currentPeek()); return c.resetPeek(), M; } function g(c, u) { const { currentType: L } = u; if (L !== 2) return !1; O(c); const J = m(c.currentPeek() === "-" ? c.peek() : c.currentPeek()); return c.resetPeek(), J; } function w(c, u) { const { currentType: L } = u; if (L !== 2) return !1; O(c); const M = c.currentPeek() === Yn; return c.resetPeek(), M; } function S(c, u) { const { currentType: L } = u; if (L !== 7) return !1; O(c); const M = c.currentPeek() === "."; return c.resetPeek(), M; } function b(c, u) { const { currentType: L } = u; if (L !== 8) return !1; O(c); const M = d(c.currentPeek()); return c.resetPeek(), M; } function V(c, u) { const { currentType: L } = u; if (!(L === 7 || L === 11)) return !1; O(c); const M = c.currentPeek() === ":"; return c.resetPeek(), M; } function x(c, u) { const { currentType: L } = u; if (L !== 9) return !1; const M = () => { const re = c.currentPeek(); return re === "{" ? d(c.peek()) : re === "@" || re === "|" || re === ":" || re === "." || re === Oe || !re ? !1 : re === fe ? (c.peek(), M()) : ve(c, !1); }, J = M(); return c.resetPeek(), J; } function te(c) { O(c); const u = c.currentPeek() === "|"; return c.resetPeek(), u; } function ve(c, u = !0) { const L = (J = !1, re = "") => { const Y = c.currentPeek(); return Y === "{" || Y === "@" || !Y ? J : Y === "|" ? !(re === Oe || re === fe) : Y === Oe ? (c.peek(), L(!0, Oe)) : Y === fe ? (c.peek(), L(!0, fe)) : !0; }, M = L(); return u && c.resetPeek(), M; } function ne(c, u) { const L = c.currentChar(); return L === Pe ? Pe : u(L) ? (c.next(), L) : null; } function Je(c) { const u = c.charCodeAt(0); return u >= 97 && u <= 122 || u >= 65 && u <= 90 || u >= 48 && u <= 57 || u === 95 || u === 36; } function Ht(c) { return ne(c, Je); } function Wt(c) { const u = c.charCodeAt(0); return u >= 97 && u <= 122 || u >= 65 && u <= 90 || u >= 48 && u <= 57 || u === 95 || u === 36 || u === 45; } function Bt(c) { return ne(c, Wt); } function Gt(c) { const u = c.charCodeAt(0); return u >= 48 && u <= 57; } function Yt(c) { return ne(c, Gt); } function Kt(c) { const u = c.charCodeAt(0); return u >= 48 && u <= 57 || u >= 65 && u <= 70 || u >= 97 && u <= 102; } function De(c) { return ne(c, Kt); } function it(c) { let u = "", L = ""; for (; u = Yt(c);) L += u; return L; } function jt(c) { let u = ""; for (;;) { const L = c.currentChar(); if (L === "\\") { const M = c.peek(); M === "{" || M === "}" || M === "@" || M === "|" || M === "\\" ? (u += L + M, c.next(), c.next()) : (c.resetPeek(), u += L, c.next()); } else { if (L === "{" || L === "}" || L === "@" || L === "|" || !L) break; if (L === Oe || L === fe) if (ve(c)) u += L, c.next(); else { if (te(c)) break; u += L, c.next(); } else u += L, c.next(); } } return u; } function Zt(c) { v(c); let u = "", L = ""; for (; u = Bt(c);) L += u; const M = c.currentChar(); if (M && M !== "}" && M !== Pe && M !== Oe && M !== fe && M !== " ") { const J = It(c); return C(R.INVALID_TOKEN_IN_PLACEHOLDER, r(), 0, L + J), L + J; } return c.currentChar() === Pe && C(R.UNTERMINATED_CLOSING_BRACE, r(), 0), L; } function Xt(c) { v(c); let u = ""; return c.currentChar() === "-" ? (c.next(), u += `-${it(c)}`) : u += it(c), c.currentChar() === Pe && C(R.UNTERMINATED_CLOSING_BRACE, r(), 0), u; } function qt(c) { return c !== Yn && c !== fe; } function xn(c) { v(c), D(c, "'"); let u = "", L = ""; for (; u = ne(c, qt);) u === "\\" ? L += Jt(c) : L += u; const M = c.currentChar(); return M === fe || M === Pe ? (C(R.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER, r(), 0), M === fe && (c.next(), D(c, "'")), L) : (D(c, "'"), L); } function Jt(c) { const u = c.currentChar(); switch (u) { case "\\": case "'": return c.next(), `\\${u}`; case "u": return yt(c, u, 4); case "U": return yt(c, u, 6); default: return C(R.UNKNOWN_ESCAPE_SEQUENCE, r(), 0, u), ""; } } function yt(c, u, L) { D(c, u); let M = ""; for (let J = 0; J < L; J++) { const re = De(c); if (!re) { C(R.INVALID_UNICODE_ESCAPE_SEQUENCE, r(), 0, `\\${u}${M}${c.currentChar()}`); break; } M += re; } return `\\${u}${M}`; } function Qt(c) { return c !== "{" && c !== "}" && c !== Oe && c !== fe; } function It(c) { v(c); let u = "", L = ""; for (; u = ne(c, Qt);) L += u; return L; } function zt(c) { let u = "", L = ""; for (; u = Ht(c);) L += u; return L; } function en(c) { const u = (L) => { const M = c.currentChar(); return M === "{" || M === "@" || M === "|" || M === "(" || M === ")" || !M || M === Oe ? L : (L += M, c.next(), u(L)); }; return u(""); } function ct(c) { v(c); const u = D(c, "|"); return v(c), u; } function ut(c, u) { let L = null; switch (c.currentChar()) { case "{": return u.braceNest >= 1 && C(R.NOT_ALLOW_NEST_PLACEHOLDER, r(), 0), c.next(), L = h(u, 2, "{"), v(c), u.braceNest++, L; case "}": return u.braceNest > 0 && u.currentType === 2 && C(R.EMPTY_PLACEHOLDER, r(), 0), c.next(), L = h(u, 3, "}"), u.braceNest--, u.braceNest > 0 && v(c), u.inLinked && u.braceNest === 0 && (u.inLinked = !1), L; case "@": return u.braceNest > 0 && C(R.UNTERMINATED_CLOSING_BRACE, r(), 0), L = Be(c, u) || k(u), u.braceNest = 0, L; default: { let J = !0, re = !0, Y = !0; if (te(c)) return u.braceNest > 0 && C(R.UNTERMINATED_CLOSING_BRACE, r(), 0), L = h(u, 1, ct(c)), u.braceNest = 0, u.inLinked = !1, L; if (u.braceNest > 0 && (u.currentType === 4 || u.currentType === 5 || u.currentType === 6)) return C(R.UNTERMINATED_CLOSING_BRACE, r(), 0), u.braceNest = 0, dt(c, u); if (J = y(c, u)) return L = h(u, 4, Zt(c)), v(c), L; if (re = g(c, u)) return L = h(u, 5, Xt(c)), v(c), L; if (Y = w(c, u)) return L = h(u, 6, xn(c)), v(c), L; if (!J && !re && !Y) return L = h(u, 12, It(c)), C(R.INVALID_TOKEN_IN_PLACEHOLDER, r(), 0, L.value), v(c), L; break; } } return L; } function Be(c, u) { const { currentType: L } = u; let M = null; const J = c.currentChar(); switch ((L === 7 || L === 8 || L === 11 || L === 9) && (J === fe || J === Oe) && C(R.INVALID_LINKED_FORMAT, r(), 0), J) { case "@": return c.next(), M = h(u, 7, "@"), u.inLinked = !0, M; case ".": return v(c), c.next(), h(u, 8, "."); case ":": return v(c), c.next(), h(u, 9, ":"); default: return te(c) ? (M = h(u, 1, ct(c)), u.braceNest = 0, u.inLinked = !1, M) : S(c, u) || V(c, u) ? (v(c), Be(c, u)) : b(c, u) ? (v(c), h(u, 11, zt(c))) : x(c, u) ? (v(c), J === "{" ? ut(c, u) || M : h(u, 10, en(c))) : (L === 7 && C(R.INVALID_LINKED_FORMAT, r(), 0), u.braceNest = 0, u.inLinked = !1, dt(c, u)); } } function dt(c, u) { let L = { type: 13 }; if (u.braceNest > 0) return ut(c, u) || k(u); if (u.inLinked) return Be(c, u) || k(u); switch (c.currentChar()) { case "{": return ut(c, u) || k(u); case "}": return C(R.UNBALANCED_CLOSING_BRACE, r(), 0), c.next(), h(u, 3, "}"); case "@": return Be(c, u) || k(u); default: if (te(c)) return L = h(u, 1, ct(c)), u.braceNest = 0, u.inLinked = !1, L; if (ve(c)) return h(u, 0, jt(c)); break; } return L; } function tn() { const { currentType: c, offset: u, startLoc: L, endLoc: M } = i; return i.lastType = c, i.lastOffset = u, i.lastStartLoc = L, i.lastEndLoc = M, i.offset = a(), i.startLoc = r(), s.currentChar() === Pe ? h(i, 13) : dt(s, i); } return { nextToken: tn, currentOffset: a, currentPosition: r, context: f }; } var er = "parser", tr = /(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g, nr = /\\([\\@{}|])/g; function ar(e, t) { return t; } function sr(e, t, n) { switch (e) { case "\\\\": return "\\"; case "\\'": return "'"; default: { const s = parseInt(t || n, 16); return s <= 55295 || s >= 57344 ? String.fromCodePoint(s) : "�"; } } } function rr(e = {}) { const t = e.location !== !1, { onError: n } = e; function s(d, m, y, g, ...w) { const S = d.currentPosition(); if (S.offset += g, S.column += g, n) n(ot(m, t ? dn(y, S) : null, { domain: er, args: w })); } function a(d, m, y) { const g = { type: d }; return t && (g.start = m, g.end = m, g.loc = { start: y, end: y }), g; } function r(d, m, y, g) { t && (d.end = m, d.loc && (d.loc.end = y)); } function l(d, m) { const y = d.context(), g = a(3, y.offset, y.startLoc); return g.value = m.replace(nr, ar), r(g, d.currentOffset(), d.currentPosition()), g; } function o(d, m) { const { lastOffset: g, lastStartLoc: w } = d.context(), S = a(5, g, w); return S.index = parseInt(m, 10), d.nextToken(), r(S, d.currentOffset(), d.currentPosition()), S; } function i(d, m) { const { lastOffset: g, lastStartLoc: w } = d.context(), S = a(4, g, w); return S.key = m, d.nextToken(), r(S, d.currentOffset(), d.currentPosition()), S; } function f(d, m) { const { lastOffset: g, lastStartLoc: w } = d.context(), S = a(9, g, w); return S.value = m.replace(tr, sr), d.nextToken(), r(S, d.currentOffset(), d.currentPosition()), S; } function _(d) { const m = d.nextToken(), y = d.context(), { lastOffset: g, lastStartLoc: w } = y, S = a(8, g, w); return m.type !== 11 ? (s(d, R.UNEXPECTED_EMPTY_LINKED_MODIFIER, y.lastStartLoc, 0), S.value = "", r(S, g, w), { nextConsumeToken: m, node: S }) : (m.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, y.lastStartLoc, 0, Se(m)), S.value = m.value || "", r(S, d.currentOffset(), d.currentPosition()), { node: S }); } function C(d, m) { const y = d.context(), g = a(7, y.offset, y.startLoc); return g.value = m, r(g, d.currentOffset(), d.currentPosition()), g; } function h(d) { const m = d.context(), y = a(6, m.offset, m.startLoc); let g = d.nextToken(); if (g.type === 8) { const w = _(d); y.modifier = w.node, g = w.nextConsumeToken || d.nextToken(); } switch (g.type !== 9 && s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(g)), g = d.nextToken(), g.type === 2 && (g = d.nextToken()), g.type) { case 10: g.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(g)), y.key = C(d, g.value || ""); break; case 4: g.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(g)), y.key = i(d, g.value || ""); break; case 5: g.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(g)), y.key = o(d, g.value || ""); break; case 6: g.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(g)), y.key = f(d, g.value || ""); break; default: { s(d, R.UNEXPECTED_EMPTY_LINKED_KEY, m.lastStartLoc, 0); const w = d.context(), S = a(7, w.offset, w.startLoc); return S.value = "", r(S, w.offset, w.startLoc), y.key = S, r(y, w.offset, w.startLoc), { nextConsumeToken: g, node: y }; } } return r(y, d.currentOffset(), d.currentPosition()), { node: y }; } function k(d) { const m = d.context(), w = a(2, m.currentType === 1 ? d.currentOffset() : m.offset, m.currentType === 1 ? m.endLoc : m.startLoc); w.items = []; let S = null; do { const x = S || d.nextToken(); switch (S = null, x.type) { case 0: x.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(x)), w.items.push(l(d, x.value || "")); break; case 5: x.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(x)), w.items.push(o(d, x.value || "")); break; case 4: x.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(x)), w.items.push(i(d, x.value || "")); break; case 6: x.value ?? s(d, R.UNEXPECTED_LEXICAL_ANALYSIS, m.lastStartLoc, 0, Se(x)), w.items.push(f(d, x.value || "")); break; case 7: { const te = h(d); w.items.push(te.node), S = te.nextConsumeToken || null; break; } } } while (m.currentType !== 13 && m.currentType !== 1); return r(w, m.currentType === 1 ? m.lastOffset : d.currentOffset(), m.currentType === 1 ? m.lastEndLoc : d.currentPosition()), w; } function D(d, m, y, g) { const w = d.context(); let S = g.items.length === 0; const b = a(1, m, y); b.cases = [], b.cases.push(g); do { const V = k(d); S || (S = V.items.length === 0), b.cases.push(V); } while (w.currentType !== 13); return S && s(d, R.MUST_HAVE_MESSAGES_IN_PLURAL, y, 0), r(b, d.currentOffset(), d.currentPosition()), b; } function O(d) { const m = d.context(), { offset: y, startLoc: g } = m, w = k(d); return m.currentType === 13 ? w : D(d, y, g, w); } function v(d) { const m = zs(d, ce({}, e)), y = m.context(), g = a(0, y.offset, y.startLoc); return t && g.loc && (g.loc.source = d), g.body = O(m), e.onCacheKey && (g.cacheKey = e.onCacheKey(d)), y.currentType !== 13 && s(m, R.UNEXPECTED_LEXICAL_ANALYSIS, y.lastStartLoc, 0, d[y.offset] || ""), r(g, m.currentOffset(), m.currentPosition()), g; } return { parse: v }; } function Se(e) { if (e.type === 13) return "EOF"; const t = (e.value || "").replace(/\r?\n/gu, "\\n"); return t.length > 10 ? t.slice(0, 9) + "…" : t; } function lr(e, t = {}) { const n = { ast: e, helpers: /* @__PURE__ */ new Set() }; return { context: () => n, helper: (r) => (n.helpers.add(r), r) }; } function Kn(e, t) { for (let n = 0; n < e.length; n++) Sn(e[n], t); } function Sn(e, t) { switch (e.type) { case 1: Kn(e.cases, t), t.helper("plural"); break; case 2: Kn(e.items, t); break; case 6: Sn(e.key, t), t.helper("linked"), t.helper("type"); break; case 5: t.helper("interpolate"), t.helper("list"); break; case 4: t.helper("interpolate"), t.helper("named"); break; } } function or(e, t = {}) { const n = lr(e); n.helper("normalize"), e.body && Sn(e.body, n); const s = n.context(); e.helpers = Array.from(s.helpers); } function ir(e) { const t = e.body; return t.type === 2 ? jn(t) : t.cases.forEach((n) => jn(n)), e; } function jn(e) { if (e.items.length === 1) { const t = e.items[0]; (t.type === 3 || t.type === 9) && (e.static = t.value, delete t.value); } else { const t = []; for (let n = 0; n < e.items.length; n++) { const s = e.items[n]; if (!(s.type === 3 || s.type === 9) || s.value == null) break; t.push(s.value); } if (t.length === e.items.length) { e.static = kn(t); for (let n = 0; n < e.items.length; n++) { const s = e.items[n]; (s.type === 3 || s.type === 9) && delete s.value; } } } } function tt(e) { switch (e.t = e.type, e.type) { case 0: { const t = e; tt(t.body), t.b = t.body, delete t.body; break; } case 1: { const t = e, n = t.cases; for (let s = 0; s < n.length; s++) tt(n[s]); t.c = n, delete t.cases; break; } case 2: { const t = e, n = t.items; for (let s = 0; s < n.length; s++) tt(n[s]); t.i = n, delete t.items, t.static && (t.s = t.static, delete t.static); break; } case 3: case 9: case 8: case 7: { const t = e; t.value && (t.v = t.value, delete t.value); break; } case 6: { const t = e; tt(t.key), t.k = t.key, delete t.key, t.modifier && (tt(t.modifier), t.m = t.modifier, delete t.modifier); break; } case 5: { const t = e; t.i = t.index, delete t.index; break; } case 4: { const t = e; t.k = t.key, delete t.key; break; } default: } delete e.type; } function dr(e, t) { const { filename: n, breakLineCode: s, needIndent: a } = t, r = t.location !== !1, l = { filename: n, code: "", column: 1, line: 1, offset: 0, map: void 0, breakLineCode: s, needIndent: a, indentLevel: 0 }; r && e.loc && (l.source = e.loc.source); const o = () => l; function i(O, v) { l.code += O; } function f(O, v = !0) { const d = v ? s : ""; i(a ? d + " ".repeat(O) : d); } function _(O = !0) { const v = ++l.indentLevel; O && f(v); } function C(O = !0) { const v = --l.indentLevel; O && f(v); } function h() { f(l.indentLevel); } return { context: o, push: i, indent: _, deindent: C, newline: h, helper: (O) => `_${O}`, needIndent: () => l.needIndent }; } function fr(e, t) { const { helper: n } = e; e.push(`${n("linked")}(`), st(e, t.key), t.modifier ? (e.push(", "), st(e, t.modifier), e.push(", _type")) : e.push(", undefined, _type"), e.push(")"); } function mr(e, t) { const { helper: n, needIndent: s } = e; e.push(`${n("normalize")}([`), e.indent(s()); const a = t.items.length; for (let r = 0; r < a && (st(e, t.items[r]), r !== a - 1); r++) e.push(", "); e.deindent(s()), e.push("])"); } function _r(e, t) { const { helper: n, needIndent: s } = e; if (t.cases.length > 1) { e.push(`${n("plural")}([`), e.indent(s()); const a = t.cases.length; for (let r = 0; r < a && (st(e, t.cases[r]), r !== a - 1); r++) e.push(", "); e.deindent(s()), e.push("])"); } } function pr(e, t) { t.body ? st(e, t.body) : e.push("null"); } function st(e, t) { const { helper: n } = e; switch (t.type) { case 0: pr(e, t); break; case 1: _r(e, t); break; case 2: mr(e, t); break; case 6: fr(e, t); break; case 8: e.push(JSON.stringify(t.value), t); break; case 7: e.push(JSON.stringify(t.value), t); break; case 5: e.push(`${n("interpolate")}(${n("list")}(${t.index}))`, t); break; case 4: e.push(`${n("interpolate")}(${n("named")}(${JSON.stringify(t.key)}))`, t); break; case 9: e.push(JSON.stringify(t.value), t); break; case 3: e.push(JSON.stringify(t.value), t); break; default: } } var hr = (e, t = {}) => { const n = A(t.mode) ? t.mode : "normal", s = A(t.filename) ? t.filename : "message.intl"; t.sourceMap; const a = t.breakLineCode != null ? t.breakLineCode : n === "arrow" ? ";" : ` `, r = t.needIndent ? t.needIndent : n !== "arrow", l = e.helpers || [], o = dr(e, { filename: s, breakLineCode: a, needIndent: r }); o.push(n === "normal" ? "function __msg__ (ctx) {" : "(ctx) => {"), o.indent(r), l.length > 0 && (o.push(`const { ${kn(l.map((_) => `${_}: _${_}`), ", ")} } = ctx`), o.newline()), o.push("return "), st(o, e), o.deindent(r), o.push("}"), delete e.helpers; const { code: i, map: f } = o.context(); return { ast: e, code: i, map: f ? f.toJSON() : void 0 }; }; function gr(e, t = {}) { const n = ce({}, t), s = !!n.jit, a = !!n.minify, r = n.optimize == null ? !0 : n.optimize, o = rr(n).parse(e); return s ? (r && ir(o), a && tt(o), { ast: o, code: "" }) : (or(o, n), hr(o, n)); } function Cr() { typeof __INTLIFY_PROD_DEVTOOLS__ != "boolean" && (je().__INTLIFY_PROD_DEVTOOLS__ = !1), typeof __INTLIFY_DROP_MESSAGE_COMPILER__ != "boolean" && (je().__INTLIFY_DROP_MESSAGE_COMPILER__ = !1); } function ye(e) { return G(e) && An(e) === 0 && (Te(e, "b") || Te(e, "body")); } var Aa = ["b", "body"]; function vr(e) { return He(e, Aa); } var wa = ["c", "cases"]; function Er(e) { return He(e, wa, []); } var Ma = ["s", "static"]; function br(e) { return He(e, Ma); } var Da = ["i", "items"]; function Lr(e) { return He(e, Da, []); } var Pa = ["t", "type"]; function An(e) { return He(e, Pa); } var Ra = ["v", "value"]; function Ot(e, t) { const n = He(e, Ra); if (n != null) return n; throw _t(t); } var $a = ["m", "modifier"]; function Nr(e) { return He(e, $a); } var Va = ["k", "key"]; function Tr(e) { const t = He(e, Va); if (t) return t; throw _t(6); } function He(e, t, n) { for (let s = 0; s < t.length; s++) { const a = t[s]; if (Te(e, a) && e[a] != null) return e[a]; } return n; } var xa = [ ...Aa, ...wa, ...Ma, ...Da, ...Va, ...$a, ...Ra, ...Pa ]; function _t(e) { return /* @__PURE__ */ new Error(`unhandled node type: ${e}`); } function an(e) { return (n) => yr(n, e); } function yr(e, t) { const n = vr(t); if (n == null) throw _t(0); if (An(n) === 1) { const r = Er(n); return e.plural(r.reduce((l, o) => [...l, Zn(e, o)], [])); } else return Zn(e, n); } function Zn(e, t) { const n = br(t); if (n != null) return e.type === "text" ? n : e.normalize([n]); { const s = Lr(t).reduce((a, r) => [...a, fn(e, r)], []); return e.normalize(s); } } function fn(e, t) { const n = An(t); switch (n) { case 3: return Ot(t, n); case 9: return Ot(t, n); case 4: { const s = t; if (Te(s, "k") && s.k) return e.interpolate(e.named(s.k)); if (Te(s, "key") && s.key) return e.interpolate(e.named(s.key)); throw _t(n); } case 5: { const s = t; if (Te(s, "i") && oe(s.i)) return e.interpolate(e.list(s.i)); if (Te(s, "index") && oe(s.index)) return e.interpolate(e.list(s.index)); throw _t(n); } case 6: { const s = t, a = Nr(s), r = Tr(s); return e.linked(fn(e, r), a ? fn(e, a) : void 0, e.type); } case 7: return Ot(t, n); case 8: return Ot(t, n); default: throw new Error(`unhandled node on format message part: ${n}`); } } var Or = (e) => e; var St = Z(); function Sr(e, t = {}) { let n = !1; const s = t.onError || Gs; return t.onError = (a) => { n = !0, s(a); }, { ...gr(e, t), detectError: n }; } // @__NO_SIDE_EFFECTS__ function Ar(e, t) { if (!__INTLIFY_DROP_MESSAGE_COMPILER__ && A(e)) { B(t.warnHtmlMessage) && t.warnHtmlMessage; const a = (t.onCacheKey || Or)(e), r = St[a]; if (r) return r; const { ast: l, detectError: o } = Sr(e, { ...t, location: false, jit: !0 }), i = an(l); return o ? i : St[a] = i; } else { const n = e.cacheKey; if (n) return St[n] || (St[n] = an(e)); else return an(e); } } var pt = null; function wr(e) { pt = e; } function Mr(e, t, n) { pt && pt.emit("i18n:init", { timestamp: Date.now(), i18n: e, version: t, meta: n }); } var Dr = /* @__PURE__ */ Pr("function:translate"); function Pr(e) { return (t) => pt && pt.emit(e, t); } var me = { INVALID_ARGUMENT: Ws, INVALID_DATE_ARGUMENT: 18, INVALID_ISO_DATE_ARGUMENT: 19, NOT_SUPPORT_NON_STRING_MESSAGE: 20, NOT_SUPPORT_LOCALE_PROMISE_VALUE: 21, NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 22, NOT_SUPPORT_LOCALE_TYPE: 23 }, Rr = 24; function Re(e) { return ot(e, null, void 0); } me.INVALID_ARGUMENT, me.INVALID_DATE_ARGUMENT, me.INVALID_ISO_DATE_ARGUMENT, me.NOT_SUPPORT_NON_STRING_MESSAGE, me.NOT_SUPPORT_LOCALE_PROMISE_VALUE, me.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION, me.NOT_SUPPORT_LOCALE_TYPE; function wn(e, t) { return t.locale != null ? Xn(t.locale) : Xn(e.locale); } var sn; function Xn(e) { if (A(e)) return e; if (q(e)) { if (e.resolvedOnce && sn != null) return sn; if (e.constructor.name === "Function") { const t = e(); if (xs(t)) throw Re(me.NOT_SUPPORT_LOCALE_PROMISE_VALUE); return sn = t; } else throw Re(me.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION); } else throw Re(me.NOT_SUPPORT_LOCALE_TYPE); } function Vr(e, t, n) { return [.../* @__PURE__ */ new Set([n, ...ee(t) ? t : G(t) ? Object.keys(t) : A(t) ? [t] : [n]])]; } function mn(e, t, n) { const s = A(n) ? n : ht, a = e; a.__localeChainCache || (a.__localeChainCache = /* @__PURE__ */ new Map()); let r = a.__localeChainCache.get(s); if (!r) { r = []; let l = [n]; for (; ee(l);) l = qn(r, l, t); const o = ee(t) || !U(t) ? t : t.default ? t.default : null; l = A(o) ? [o] : o, ee(l) && qn(r, l, !1), a.__localeChainCache.set(s, r); } return r; } function qn(e, t, n) { let s = !0; for (let a = 0; a < t.length && B(s); a++) { const r = t[a]; A(r) && (s = xr(e, t[a], n)); } return s; } function xr(e, t, n) { let s; const a = t.split("-"); do s = Fr(e, a.join("-"), n), a.splice(-1, 1); while (a.length && s === !0); return s; } function Fr(e, t, n) { let s = !1; if (!e.includes(t) && (s = !0, t)) { s = t[t.length - 1] !== "!"; const a = t.replace(/!/g, ""); e.push(a), (ee(n) || U(n)) && n[a] && (s = n[a]); } return s; } var We = []; We[0] = { w: [0], i: [3, 0], "[": [4], o: [7] }; We[1] = { w: [1], ".": [2], "[": [4], o: [7] }; We[2] = { w: [2], i: [3, 0], 0: [3, 0] }; We[3] = { i: [3, 0], 0: [3, 0], w: [1, 1], ".": [2, 1], "[": [4, 1], o: [7, 1] }; We[4] = { "'": [5, 0], "\"": [6, 0], "[": [4, 2], "]": [1, 3], o: 8, l: [4, 0] }; We[5] = { "'": [4, 0], o: 8, l: [5, 0] }; We[6] = { "\"": [4, 0], o: 8, l: [6, 0] }; var Ur = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/; function Hr(e) { return Ur.test(e); } function Wr(e) { const t = e.charCodeAt(0); return t === e.charCodeAt(e.length - 1) && (t === 34 || t === 39) ? e.slice(1, -1) : e; } function Br(e) { if (e == null) return "o"; switch (e.charCodeAt(0)) { case 91: case 93: case 46: case 34: case 39: return e; case 95: case 36: case 45: return "i"; case 9: case 10: case 13: case 160: case 65279: case 8232: case 8233: return "w"; } return "i"; } function Gr(e) { const t = e.trim(); return e.charAt(0) === "0" && isNaN(parseInt(e)) ? !1 : Hr(t) ? Wr(t) : "*" + t; } function Yr(e) { const t = []; let n = -1, s = 0, a = 0, r, l, o, i, f, _, C; const h = []; h[0] = () => { l === void 0 ? l = o : l += o; }, h[1] = () => { l !== void 0 && (t.push(l), l = void 0); }, h[2] = () => { h[0](), a++; }, h[3] = () => { if (a > 0) a--, s = 4, h[0](); else { if (a = 0, l === void 0 || (l = Gr(l), l === !1)) return !1; h[1](); } }; function k() { const D = e[n + 1]; if (s === 5 && D === "'" || s === 6 && D === "\"") return n++, o = "\\" + D, h[0](), !0; } for (; s !== null;) if (n++, r = e[n], !(r === "\\" && k())) { if (i = Br(r), C = We[s], f = C[i] || C.l || 8, f === 8 || (s = f[0], f[1] !== void 0 && (_ = h[f[1]], _ && (o = r, _() === !1)))) return; if (s === 7) return t; } } var Jn = /* @__PURE__ */ new Map(); function Kr(e, t) { return G(e) ? e[t] : null; } function jr(e, t) { if (!G(e)) return null; let n = Jn.get(t); if (n || (n = Yr(t), n && Jn.set(t, n)), !n) return null; const s = n.length; let a = e, r = 0; for (; r < s;) { const l = n[r]; if (xa.includes(l) && ye(a) || !G(a) || !Te(a, l)) return null; const o = a[l]; if (o === void 0 || q(a)) return null; a = o, r++; } return a; } var de = { NOT_FOUND_KEY: 1, FALLBACK_TO_TRANSLATE: 2, CANNOT_FORMAT_NUMBER: 3, FALLBACK_TO_NUMBER_FORMAT: 4, CANNOT_FORMAT_DATE: 5, FALLBACK_TO_DATE_FORMAT: 6, EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: 7, INVALID_NUMBER_ARGUMENT: 8, INVALID_DATE_ARGUMENT: 9 }, Qe = 10; de.NOT_FOUND_KEY, de.FALLBACK_TO_TRANSLATE, de.CANNOT_FORMAT_NUMBER, de.FALLBACK_TO_NUMBER_FORMAT, de.CANNOT_FORMAT_DATE, de.FALLBACK_TO_DATE_FORMAT, de.EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER, de.INVALID_NUMBER_ARGUMENT, de.INVALID_DATE_ARGUMENT; var Xr = "11.3.2", Ft = -1, ht = "en-US", rt = "", Qn = (e) => `${e.charAt(0).toLocaleUpperCase()}${e.substr(1)}`; function qr() { return { upper: (e, t) => t === "text" && A(e) ? e.toUpperCase() : t === "vnode" && G(e) && "__v_isVNode" in e ? e.children.toUpperCase() : e, lower: (e, t) => t === "text" && A(e) ? e.toLowerCase() : t === "vnode" && G(e) && "__v_isVNode" in e ? e.children.toLowerCase() : e, capitalize: (e, t) => t === "text" && A(e) ? Qn(e) : t === "vnode" && G(e) && "__v_isVNode" in e ? Qn(e.children) : e }; } var Fa; function Jr(e) { Fa = e; } var Ua; function Qr(e) { Ua = e; } var Ha; function zr(e) { Ha = e; } var Wa = null; var tl = /* @__NO_SIDE_EFFECTS__ */ () => Wa; var Ba = null; var zn = (e) => { Ba = e; }, nl = () => Ba; var ea = 0; function al(e = {}) { const t = q(e.onWarn) ? e.onWarn : Ae, n = A(e.version) ? e.version : Xr, s = A(e.locale) || q(e.locale) ? e.locale : ht, a = q(s) ? ht : s, r = ee(e.fallbackLocale) || U(e.fallbackLocale) || A(e.fallbackLocale) || e.fallbackLocale === !1 ? e.fallbackLocale : a, l = U(e.messages) ? e.messages : rn(a), o = U(e.datetimeFormats) ? e.datetimeFormats : rn(a), i = U(e.numberFormats) ? e.numberFormats : rn(a), f = ce(Z(), e.modifiers, qr()), _ = e.pluralRules || Z(), C = q(e.missing) ? e.missing : null, h = B(e.missingWarn) || at(e.missingWarn) ? e.missingWarn : !0, k = B(e.fallbackWarn) || at(e.fallbackWarn) ? e.fallbackWarn : !0, D = !!e.fallbackFormat, O = !!e.unresolving, v = q(e.postTranslation) ? e.postTranslation : null, d = U(e.processor) ? e.processor : null, m = B(e.warnHtmlMessage) ? e.warnHtmlMessage : !0, y = !!e.escapeParameter, g = q(e.messageCompiler) ? e.messageCompiler : Fa; const w = q(e.messageResolver) ? e.messageResolver : Ua || Kr, S = q(e.localeFallbacker) ? e.localeFallbacker : Ha || Vr, b = G(e.fallbackContext) ? e.fallbackContext : void 0, V = e, x = G(V.__datetimeFormatters) ? V.__datetimeFormatters : /* @__PURE__ */ new Map(), te = G(V.__numberFormatters) ? V.__numberFormatters : /* @__PURE__ */ new Map(), ve = G(V.__meta) ? V.__meta : {}; ea++; const ne = { version: n, cid: ea, locale: s, fallbackLocale: r, messages: l, modifiers: f, pluralRules: _, missing: C, missingWarn: h, fallbackWarn: k, fallbackFormat: D, unresolving: O, postTranslation: v, processor: d, warnHtmlMessage: m, escapeParameter: y, messageCompiler: g, messageResolver: w, localeFallbacker: S, fallbackContext: b, onWarn: t, __meta: ve }; return ne.datetimeFormats = o, ne.numberFormats = i, ne.__datetimeFormatters = x, ne.__numberFormatters = te, __INTLIFY_PROD_DEVTOOLS__ && Mr(ne, n, ve), ne; } var rn = (e) => ({ [e]: Z() }); function Mn(e, t, n, s, a) { const { missing: r, onWarn: l } = e; if (r !== null) { const o = r(e, n, t, a); return A(o) ? o : t; } else return t; } function ft(e, t, n) { const s = e; s.__localeChainCache = /* @__PURE__ */ new Map(), e.localeFallbacker(e, n, t); } function Ya(e, t) { return e === t ? !1 : e.split("-")[0] === t.split("-")[0]; } function sl(e, t) { const n = t.indexOf(e); if (n === -1) return !1; for (let s = n + 1; s < t.length; s++) if (Ya(e, t[s])) return !0; return !1; } var ta = typeof Intl < "u"; ta && Intl.DateTimeFormat, ta && Intl.NumberFormat; function na(e, ...t) { const { datetimeFormats: n, unresolving: s, fallbackLocale: a, onWarn: r, localeFallbacker: l } = e, { __datetimeFormatters: o } = e; if (!A(t[0]) && !Oa(t[0]) && !oe(t[0])) return rt; const [i, f, _, C] = _n(...t), h = B(_.missingWarn) ? _.missingWarn : e.missingWarn; B(_.fallbackWarn) ? _.fallbackWarn : e.fallbackWarn; const D = !!_.part, O = wn(e, _), v = l(e, a, O); if (!A(i) || i === "") return new Intl.DateTimeFormat(O.replace(/!/g, ""), C).format(f); let d = {}, m, y = null; const S = "datetime format"; for (let x = 0; x < v.length; x++) { if (m = v[x], false); if (d = n[m] || {}, y = d[i], U(y)) break; Mn(e, i, m, h, S); } if (!U(y) || !A(m)) return s ? Ft : i; let b = `${m}__${i}`; xt(C) || (b = `${b}__${JSON.stringify(C)}`); let V = o.get(b); return V || (V = new Intl.DateTimeFormat(m, ce({}, y, C)), o.set(b, V)), D ? V.formatToParts(f) : V.format(f); } var ja = [ "localeMatcher", "weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName", "formatMatcher", "hour12", "timeZone", "dateStyle", "timeStyle", "calendar", "dayPeriod", "numberingSystem", "hourCycle", "fractionalSecondDigits" ]; function _n(...e) { const [t, n, s, a] = e, r = Z(); let l = Z(), o; if (A(t)) { const i = t.match(/(\d{4}-\d{2}-\d{2})(T|\s)?(.*)/); if (!i) throw Re(me.INVALID_ISO_DATE_ARGUMENT); const f = i[3] ? i[3].trim().startsWith("T") ? `${i[1].trim()}${i[3].trim()}` : `${i[1].trim()}T${i[3].trim()}` : i[1].trim(); o = new Date(f); try { o.toISOString(); } catch { throw Re(me.INVALID_ISO_DATE_ARGUMENT); } } else if (Oa(t)) { if (isNaN(t.getTime())) throw Re(me.INVALID_DATE_ARGUMENT); o = t; } else if (oe(t)) o = t; else throw Re(me.INVALID_ARGUMENT); return A(n) ? r.key = n : U(n) && Object.keys(n).forEach((i) => { ja.includes(i) ? l[i] = n[i] : r[i] = n[i]; }), A(s) ? r.locale = s : U(s) && (l = s), U(a) && (l = a), [ r.key || "", o, r, l ]; } function aa(e, t, n) { const s = e; for (const a in n) { const r = `${t}__${a}`; s.__datetimeFormatters.has(r) && s.__datetimeFormatters.delete(r); } } function sa(e, ...t) { const { numberFormats: n, unresolving: s, fallbackLocale: a, onWarn: r, localeFallbacker: l } = e, { __numberFormatters: o } = e; if (!oe(t[0])) return rt; const [i, f, _, C] = pn(...t), h = B(_.missingWarn) ? _.missingWarn : e.missingWarn; B(_.fallbackWarn) ? _.fallbackWarn : e.fallbackWarn; const D = !!_.part, O = wn(e, _), v = l(e, a, O); if (!A(i) || i === "") return new Intl.NumberFormat(O.replace(/!/g, ""), C).format(f); let d = {}, m, y = null; const S = "number format"; for (let x = 0; x < v.length; x++) { if (m = v[x], false); if (d = n[m] || {}, y = d[i], U(y)) break; Mn(e, i, m, h, S); } if (!U(y) || !A(m)) return s ? Ft : i; let b = `${m}__${i}`; xt(C) || (b = `${b}__${JSON.stringify(C)}`); let V = o.get(b); return V || (V = new Intl.NumberFormat(m, ce({}, y, C)), o.set(b, V)), D ? V.formatToParts(f) : V.format(f); } var Za = [ "localeMatcher", "style", "currency", "currencyDisplay", "currencySign", "useGrouping", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", "minimumSignificantDigits", "maximumSignificantDigits", "compactDisplay", "notation", "signDisplay", "unit", "unitDisplay", "roundingMode", "roundingPriority", "roundingIncrement", "trailingZeroDisplay" ]; function pn(...e) { const [t, n, s, a] = e, r = Z(); let l = Z(); if (!oe(t)) throw Re(me.INVALID_ARGUMENT); const o = t; return A(n) ? r.key = n : U(n) && Object.keys(n).forEach((i) => { Za.includes(i) ? l[i] = n[i] : r[i] = n[i]; }), A(s) ? r.locale = s : U(s) && (l = s), U(a) && (l = a), [ r.key || "", o, r, l ]; } function ra(e, t, n) { const s = e; for (const a in n) { const r = `${t}__${a}`; s.__numberFormatters.has(r) && s.__numberFormatters.delete(r); } } var rl = (e) => e, ll = (e) => "", ol = "text", il = (e) => e.length === 0 ? "" : kn(e), cl = Fs; function ln(e, t) { return e = Math.abs(e), t === 2 ? e === 1 ? 0 : 1 : Math.min(e, 2); } function ul(e) { const t = oe(e.pluralIndex) ? e.pluralIndex : -1; return oe(e.named?.count) ? e.named.count : oe(e.named?.n) ? e.named.n : t; } function dl(e = {}) { const t = e.locale, n = ul(e), s = A(t) && q(e.pluralRules?.[t]) ? e.pluralRules[t] : ln, a = s === ln ? void 0 : ln, r = (d) => d[s(n, d.length, a)], l = e.list || [], o = (d) => l[d], i = e.named || Z(); oe(e.pluralIndex) && (i.count ||= e.pluralIndex, i.n ||= e.pluralIndex); const f = (d) => i[d]; function _(d, m) { return (q(e.messages) ? e.messages(d, !!m) : G(e.messages) ? e.messages[d] : !1) || (e.parent ? e.parent.message(d) : ll); } const C = (d) => e.modifiers ? e.modifiers[d] : rl, h = q(e.processor?.normalize) ? e.processor.normalize : il, k = q(e.processor?.interpolate) ? e.processor.interpolate : cl, v = { list: o, named: f, plural: r, linked: (d, ...m) => { const [y, g] = m; let w = "text", S = ""; m.length === 1 ? G(y) ? (S = y.modifier || S, w = y.type || w) : A(y) && (S = y || S) : m.length === 2 && (A(y) && (S = y || S), A(g) && (w = g || w)); const b = _(d, !0)(v), V = b === "" || b === void 0 ? d : b, x = w === "vnode" && ee(V) && S ? V[0] : V; return S ? C(S)(x, w) : x; }, message: _, type: A(e.processor?.type) ? e.processor.type : ol, interpolate: k, normalize: h, values: ce(Z(), l, i) }; return v; } var la = () => "", Le = (e) => q(e); function oa(e, ...t) { const { fallbackFormat: n, postTranslation: s, unresolving: a, messageCompiler: r, fallbackLocale: l, messages: o } = e, [i, f] = hn(...t), _ = B(f.missingWarn) ? f.missingWarn : e.missingWarn, C = B(f.fallbackWarn) ? f.fallbackWarn : e.fallbackWarn, h = B(f.escapeParameter) ? f.escapeParameter : e.escapeParameter, k = !!f.resolvedMessage, D = A(f.default) || B(f.default) ? B(f.default) ? r ? i : () => i : f.default : n ? r ? i : () => i : null, O = n || D != null && (A(D) || q(D)), v = wn(e, f); h && fl(f); let [d, m, y] = k ? [ i, v, o[v] || Z() ] : Xa(e, i, v, l, C, _), g = d, w = i; if (!k && !(A(g) || ye(g) || Le(g)) && O && (g = D, w = g), !k && (!(A(g) || ye(g) || Le(g)) || !A(m))) return a ? Ft : i; let S = !1; const b = () => { S = !0; }, V = Le(g) ? g : qa(e, i, m, g, w, b); if (S) return g; const ve = ml(e, V, dl(hl(e, m, y, f))); let ne = s ? s(ve, i) : ve; if (h && A(ne) && (ne = $s(ne)), __INTLIFY_PROD_DEVTOOLS__) { const Je = { timestamp: Date.now(), key: A(i) ? i : Le(g) ? g.key : "", locale: m || (Le(g) ? g.locale : ""), format: A(g) ? g : Le(g) ? g.source : "", message: ne }; Je.meta = ce({}, e.__meta, /* @__PURE__ */ tl() || {}), Dr(Je); } return ne; } function fl(e) { ee(e.list) ? e.list = e.list.map((t) => A(t) ? Wn(t) : t) : G(e.named) && Object.keys(e.named).forEach((t) => { A(e.named[t]) && (e.named[t] = Wn(e.named[t])); }); } function Xa(e, t, n, s, a, r) { const { messages: l, onWarn: o, messageResolver: i, localeFallbacker: f } = e, _ = f(e, s, n); let C = Z(), h, k = null; const v = "translate"; for (let d = 0; d < _.length; d++) { h = _[d]; C = l[h] || Z(); if ((k = i(C, t)) === null && (k = C[t]), false); if (A(k) || ye(k) || Le(k)) break; if (!sl(h, _)) { const S = Mn(e, t, h, r, v); S !== t && (k = S); } } return [ k, h, C ]; } function qa(e, t, n, s, a, r) { const { messageCompiler: l, warnHtmlMessage: o } = e; if (Le(s)) { const k = s; return k.locale = k.locale || n, k.key = k.key || t, k; } if (l == null) { const k = (() => s); return k.locale = n, k.key = t, k; } const h = l(s, _l(e, n, a, s, o, r)); return h.locale = n, h.key = t, h.source = s, h; } function ml(e, t, n) { return t(n); } function hn(...e) { const [t, n, s] = e, a = Z(); if (!A(t) && !oe(t) && !Le(t) && !ye(t)) throw Re(me.INVALID_ARGUMENT); const r = oe(t) ? String(t) : (Le(t), t); return oe(n) ? a.plural = n : A(n) ? a.default = n : U(n) && !xt(n) ? a.named = n : ee(n) && (a.list = n), oe(s) ? a.plural = s : A(s) ? a.default = s : U(s) && ce(a, s), [r, a]; } function _l(e, t, n, s, a, r) { return { locale: t, key: n, warnHtmlMessage: a, onError: (l) => { if (r && r(l), false); throw l; }, onCacheKey: (l) => Ds(t, n, l) }; } function hl(e, t, n, s) { const { modifiers: a, pluralRules: r, messageResolver: l, fallbackLocale: o, fallbackWarn: i, missingWarn: f, fallbackContext: _ } = e, h = { locale: t, modifiers: a, pluralRules: r, messages: (k, D) => { let O = l(n, k); if (O == null && (_ || D)) { const [v, , d] = Xa(_ || e, k, t, o, i, f); O = v ?? l(d, k); } if (A(O) || ye(O)) { let v = !1; const m = qa(e, k, t, O, k, () => { v = !0; }); return v ? la : m; } else return Le(O) ? O : la; } }; return e.processor && (h.processor = e.processor), s.list && (h.list = s.list), s.named && (h.named = s.named), oe(s.plural) && (h.pluralIndex = s.plural), h; } Cr(); var yl = "11.3.2"; function Il() { typeof __VUE_I18N_FULL_INSTALL__ != "boolean" && (je().__VUE_I18N_FULL_INSTALL__ = !0), typeof __VUE_I18N_LEGACY_API__ != "boolean" && (je().__VUE_I18N_LEGACY_API__ = !0), typeof __INTLIFY_DROP_MESSAGE_COMPILER__ != "boolean" && (je().__INTLIFY_DROP_MESSAGE_COMPILER__ = !1), typeof __INTLIFY_PROD_DEVTOOLS__ != "boolean" && (je().__INTLIFY_PROD_DEVTOOLS__ = !1); } var X = { UNEXPECTED_RETURN_TYPE: Rr, INVALID_ARGUMENT: 25, MUST_BE_CALL_SETUP_TOP: 26, NOT_INSTALLED: 27, REQUIRED_VALUE: 28, INVALID_VALUE: 29, CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: 30, NOT_INSTALLED_WITH_PROVIDE: 31, UNEXPECTED_ERROR: 32, NOT_COMPATIBLE_LEGACY_VUE_I18N: 33, NOT_AVAILABLE_COMPOSITION_IN_LEGACY: 34 }; function Ce(e, ...t) { return ot(e, null, void 0); } X.UNEXPECTED_RETURN_TYPE, X.INVALID_ARGUMENT, X.MUST_BE_CALL_SETUP_TOP, X.NOT_INSTALLED, X.UNEXPECTED_ERROR, X.REQUIRED_VALUE, X.INVALID_VALUE, X.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN, X.NOT_INSTALLED_WITH_PROVIDE, X.NOT_COMPATIBLE_LEGACY_VUE_I18N, X.NOT_AVAILABLE_COMPOSITION_IN_LEGACY; var Cn = /* @__PURE__ */ Me("__translateVNode"), vn = /* @__PURE__ */ Me("__datetimeParts"), En = /* @__PURE__ */ Me("__numberParts"), Qa = Me("__setPluralRules"), za = /* @__PURE__ */ Me("__injectWithOption"), bn = /* @__PURE__ */ Me("__dispose"), Ne = { FALLBACK_TO_ROOT: Qe, NOT_FOUND_PARENT_SCOPE: 11, IGNORE_OBJ_FLATTEN: 12, /** * @deprecated will be removed at vue-i18n v12 */ DEPRECATE_LEGACY_MODE: 13, /** * @deprecated will be removed at vue-i18n v12 */ DEPRECATE_TRANSLATE_CUSTOME_DIRECTIVE: 14, DUPLICATE_USE_I18N_CALLING: 15 }; Ne.FALLBACK_TO_ROOT, Ne.NOT_FOUND_PARENT_SCOPE, Ne.IGNORE_OBJ_FLATTEN, Ne.DEPRECATE_LEGACY_MODE, Ne.DEPRECATE_TRANSLATE_CUSTOME_DIRECTIVE, Ne.DUPLICATE_USE_I18N_CALLING; function Ct(e) { if (!G(e) || ye(e)) return e; for (const t in e) if (Te(e, t)) if (!t.includes(".")) G(e[t]) && Ct(e[t]); else { const n = t.split("."), s = n.length - 1; let a = e, r = !1; for (let l = 0; l < s; l++) { if (n[l] === "__proto__") throw new Error(`unsafe key: ${n[l]}`); if (n[l] in a || (a[n[l]] = Z()), !G(a[n[l]])) { r = !0; break; } a = a[n[l]]; } if (r || (ye(a) ? xa.includes(n[s]) || delete e[t] : (a[n[s]] = e[t], delete e[t])), !ye(a)) { const l = a[n[s]]; G(l) && Ct(l); } } return e; } function Dn(e, t) { const { messages: n, __i18n: s, messageResolver: a, flatJson: r } = t, l = U(n) ? n : ee(s) ? Z() : { [e]: Z() }; if (ee(s) && s.forEach((o) => { if ("locale" in o && "resource" in o) { const { locale: i, resource: f } = o; i ? (l[i] = l[i] || Z(), At(f, l[i])) : At(f, l); } else A(o) && At(JSON.parse(o), l); }), a == null && r) for (const o in l) Te(l, o) && Ct(l[o]); return l; } function es(e) { return e.type; } function ts(e, t, n) { let s = G(t.messages) ? t.messages : Z(); "__i18nGlobal" in n && (s = Dn(e.locale.value, { messages: s, __i18n: n.__i18nGlobal })); const a = Object.keys(s); a.length && a.forEach((r) => { e.mergeLocaleMessage(r, s[r]); }); if (G(t.datetimeFormats)) { const r = Object.keys(t.datetimeFormats); r.length && r.forEach((l) => { e.mergeDateTimeFormat(l, t.datetimeFormats[l]); }); } if (G(t.numberFormats)) { const r = Object.keys(t.numberFormats); r.length && r.forEach((l) => { e.mergeNumberFormat(l, t.numberFormats[l]); }); } } function ia(e) { return createVNode(Text, null, e, 0); } function nt() { const e = "currentInstance"; return e in vue_runtime_esm_bundler_exports ? vue_runtime_esm_bundler_exports[e] : getCurrentInstance(); } var ua = () => [], Sl = () => !1; var da = 0; function fa(e) { return ((t, n, s, a) => e(n, s, nt() || void 0, a)); } function Pn(e = {}) { const { __root: t, __injectWithOption: n } = e, s = t === void 0, a = e.flatJson, r = ke ? ref : shallowRef; let l = B(e.inheritLocale) ? e.inheritLocale : !0; const o = r(t && l ? t.locale.value : A(e.locale) ? e.locale : ht), i = r(t && l ? t.fallbackLocale.value : A(e.fallbackLocale) || ee(e.fallbackLocale) || U(e.fallbackLocale) || e.fallbackLocale === !1 ? e.fallbackLocale : o.value), f = r(Dn(o.value, e)), _ = r(U(e.datetimeFormats) ? e.datetimeFormats : { [o.value]: {} }), C = r(U(e.numberFormats) ? e.numberFormats : { [o.value]: {} }); let h = t ? t.missingWarn : B(e.missingWarn) || at(e.missingWarn) ? e.missingWarn : !0, k = t ? t.fallbackWarn : B(e.fallbackWarn) || at(e.fallbackWarn) ? e.fallbackWarn : !0, D = t ? t.fallbackRoot : B(e.fallbackRoot) ? e.fallbackRoot : !0, O = !!e.fallbackFormat, v = q(e.missing) ? e.missing : null, d = q(e.missing) ? fa(e.missing) : null, m = q(e.postTranslation) ? e.postTranslation : null, y = t ? t.warnHtmlMessage : B(e.warnHtmlMessage) ? e.warnHtmlMessage : !0, g = !!e.escapeParameter; const w = t ? t.modifiers : U(e.modifiers) ? e.modifiers : {}; let S = e.pluralRules || t && t.pluralRules, b; b = (() => { s && zn(null); const p = { version: yl, locale: o.value, fallbackLocale: i.value, messages: f.value, modifiers: w, pluralRules: S, missing: d === null ? void 0 : d, missingWarn: h, fallbackWarn: k, fallbackFormat: O, unresolving: !0, postTranslation: m === null ? void 0 : m, warnHtmlMessage: y, escapeParameter: g, messageResolver: e.messageResolver, messageCompiler: e.messageCompiler, __meta: { framework: "vue" } }; p.datetimeFormats = _.value, p.numberFormats = C.value, p.__datetimeFormatters = U(b) ? b.__datetimeFormatters : void 0, p.__numberFormatters = U(b) ? b.__numberFormatters : void 0; const I = al(p); return s && zn(I), I; })(), ft(b, o.value, i.value); function x() { return [ o.value, i.value, f.value, _.value, C.value ]; } const te = computed({ get: () => o.value, set: (p) => { b.locale = p, o.value = p; } }), ve = computed({ get: () => i.value, set: (p) => { b.fallbackLocale = p, i.value = p, ft(b, o.value, p); } }), ne = computed(() => f.value), Je = /* @__PURE__ */ computed(() => _.value), Ht = /* @__PURE__ */ computed(() => C.value); function Wt() { return q(m) ? m : null; } function Bt(p) { m = p, b.postTranslation = p; } function Gt() { return v; } function Yt(p) { p !== null && (d = fa(p)), v = p, b.missing = d; } const De = (p, I, K, ae, Ge, Ye) => { x(); let be; try { __INTLIFY_PROD_DEVTOOLS__, s || (b.fallbackContext = t ? nl() : void 0), be = p(b); } finally { __INTLIFY_PROD_DEVTOOLS__, s || (b.fallbackContext = void 0); } if (K !== "translate exists" && oe(be) && be === Ft || K === "translate exists" && !be) { const [Ke, os] = I(); return t && D ? ae(t) : Ge(Ke); } else { if (Ye(be)) return be; throw Ce(X.UNEXPECTED_RETURN_TYPE); } }; function it(...p) { return De((I) => Reflect.apply(oa, null, [I, ...p]), () => hn(...p), "translate", (I) => Reflect.apply(I.t, I, [...p]), (I) => I, (I) => A(I)); } function jt(...p) { const [I, K, ae] = p; if (ae && !G(ae)) throw Ce(X.INVALID_ARGUMENT); return it(I, K, ce({ resolvedMessage: !0 }, ae || {})); } function Zt(...p) { return De((I) => Reflect.apply(na, null, [I, ...p]), () => _n(...p), "datetime format", (I) => Reflect.apply(I.d, I, [...p]), () => rt, (I) => A(I) || ee(I)); } function Xt(...p) { return De((I) => Reflect.apply(sa, null, [I, ...p]), () => pn(...p), "number format", (I) => Reflect.apply(I.n, I, [...p]), () => rt, (I) => A(I) || ee(I)); } function qt(p) { return p.map((I) => A(I) || oe(I) || B(I) ? ia(String(I)) : I); } const Jt = { normalize: qt, interpolate: (p) => p, type: "vnode" }; function yt(...p) { return De((I) => { let K; const ae = I; try { ae.processor = Jt, K = Reflect.apply(oa, null, [ae, ...p]); } finally { ae.processor = null; } return K; }, () => hn(...p), "translate", (I) => I[Cn](...p), (I) => [ia(I)], (I) => ee(I)); } function Qt(...p) { return De((I) => Reflect.apply(sa, null, [I, ...p]), () => pn(...p), "number format", (I) => I[En](...p), ua, (I) => A(I) || ee(I)); } function It(...p) { return De((I) => Reflect.apply(na, null, [I, ...p]), () => _n(...p), "datetime format", (I) => I[vn](...p), ua, (I) => A(I) || ee(I)); } function zt(p) { S = p, b.pluralRules = S; } function en(p, I) { return De(() => { if (!p) return !1; const K = A(I) ? I : o.value, ae = A(I) ? [K] : mn(b, i.value, K); for (let Ge = 0; Ge < ae.length; Ge++) { const Ye = Be(ae[Ge]); let be = b.messageResolver(Ye, p); if (be === null && (be = Ye[p]), ye(be) || Le(be) || A(be)) return !0; } return !1; }, () => [p], "translate exists", (K) => Reflect.apply(K.te, K, [p, I]), Sl, (K) => B(K)); } function ct(p) { let I = null; const K = mn(b, i.value, o.value); for (let ae = 0; ae < K.length; ae++) { const Ge = f.value[K[ae]] || {}, Ye = b.messageResolver(Ge, p); if (Ye != null) { I = Ye; break; } } return I; } function ut(p) { return ct(p) ?? (t ? t.tm(p) || {} : {}); } function Be(p) { return f.value[p] || {}; } function dt(p, I) { if (a) { const K = { [p]: I }; for (const ae in K) Te(K, ae) && Ct(K[ae]); I = K[p]; } f.value[p] = I, b.messages = f.value; } function tn(p, I) { f.value[p] = f.value[p] || {}; const K = { [p]: I }; if (a) for (const ae in K) Te(K, ae) && Ct(K[ae]); I = K[p], At(I, f.value[p]), b.messages = f.value; } function c(p) { return _.value[p] || {}; } function u(p, I) { _.value[p] = I, b.datetimeFormats = _.value, aa(b, p, I); } function L(p, I) { _.value[p] = ce(_.value[p] || {}, I), b.datetimeFormats = _.value, aa(b, p, I); } function M(p) { return C.value[p] || {}; } function J(p, I) { C.value[p] = I, b.numberFormats = C.value, ra(b, p, I); } function re(p, I) { C.value[p] = ce(C.value[p] || {}, I), b.numberFormats = C.value, ra(b, p, I); } da++, t && ke && (watch(t.locale, (p) => { l && (o.value = p, b.locale = p, ft(b, o.value, i.value)); }), watch(t.fallbackLocale, (p) => { l && (i.value = p, b.fallbackLocale = p, ft(b, o.value, i.value)); })); const Y = { id: da, locale: te, fallbackLocale: ve, get inheritLocale() { return l; }, set inheritLocale(p) { l = p, p && t && (o.value = t.locale.value, i.value = t.fallbackLocale.value, ft(b, o.value, i.value)); }, get availableLocales() { return Object.keys(f.value).sort(); }, messages: ne, get modifiers() { return w; }, get pluralRules() { return S || {}; }, get isGlobal() { return s; }, get missingWarn() { return h; }, set missingWarn(p) { h = p, b.missingWarn = h; }, get fallbackWarn() { return k; }, set fallbackWarn(p) { k = p, b.fallbackWarn = k; }, get fallbackRoot() { return D; }, set fallbackRoot(p) { D = p; }, get fallbackFormat() { return O; }, set fallbackFormat(p) { O = p, b.fallbackFormat = O; }, get warnHtmlMessage() { return y; }, set warnHtmlMessage(p) { y = p, b.warnHtmlMessage = p; }, get escapeParameter() { return g; }, set escapeParameter(p) { g = p, b.escapeParameter = p; }, t: it, getLocaleMessage: Be, setLocaleMessage: dt, mergeLocaleMessage: tn, getPostTranslationHandler: Wt, setPostTranslationHandler: Bt, getMissingHandler: Gt, setMissingHandler: Yt, [Qa]: zt }; return Y.datetimeFormats = Je, Y.numberFormats = Ht, Y.rt = jt, Y.te = en, Y.tm = ut, Y.d = Zt, Y.n = Xt, Y.getDateTimeFormat = c, Y.setDateTimeFormat = u, Y.mergeDateTimeFormat = L, Y.getNumberFormat = M, Y.setNumberFormat = J, Y.mergeNumberFormat = re, Y[za] = n, Y[Cn] = yt, Y[vn] = It, Y[En] = Qt, Y; } function Gl(e) { const t = A(e.locale) ? e.locale : ht, n = A(e.fallbackLocale) || ee(e.fallbackLocale) || U(e.fallbackLocale) || e.fallbackLocale === !1 ? e.fallbackLocale : t, s = q(e.missing) ? e.missing : void 0, a = B(e.silentTranslationWarn) || at(e.silentTranslationWarn) ? !e.silentTranslationWarn : !0, r = B(e.silentFallbackWarn) || at(e.silentFallbackWarn) ? !e.silentFallbackWarn : !0, l = B(e.fallbackRoot) ? e.fallbackRoot : !0, o = !!e.formatFallbackMessages, i = U(e.modifiers) ? e.modifiers : {}, f = e.pluralizationRules, _ = q(e.postTranslation) ? e.postTranslation : void 0, C = A(e.warnHtmlInMessage) ? e.warnHtmlInMessage !== "off" : !0, h = !!e.escapeParameterHtml, k = B(e.sync) ? e.sync : !0; let D = e.messages; if (U(e.sharedMessages)) { const w = e.sharedMessages; D = Object.keys(w).reduce((b, V) => { return ce(b[V] || (b[V] = {}), w[V]), b; }, D || {}); } const { __i18n: O, __root: v, __injectWithOption: d } = e, m = e.datetimeFormats, y = e.numberFormats, g = e.flatJson; return { locale: t, fallbackLocale: n, messages: D, flatJson: g, datetimeFormats: m, numberFormats: y, missing: s, missingWarn: a, fallbackWarn: r, fallbackRoot: l, fallbackFormat: o, modifiers: i, pluralRules: f, postTranslation: _, warnHtmlMessage: C, escapeParameter: h, messageResolver: e.messageResolver, inheritLocale: k, __i18n: O, __root: v, __injectWithOption: d }; } function Nn(e = {}) { const t = Pn(Gl(e)), { __extender: n } = e, s = { id: t.id, get locale() { return t.locale.value; }, set locale(a) { t.locale.value = a; }, get fallbackLocale() { return t.fallbackLocale.value; }, set fallbackLocale(a) { t.fallbackLocale.value = a; }, get messages() { return t.messages.value; }, get datetimeFormats() { return t.datetimeFormats.value; }, get numberFormats() { return t.numberFormats.value; }, get availableLocales() { return t.availableLocales; }, get missing() { return t.getMissingHandler(); }, set missing(a) { t.setMissingHandler(a); }, get silentTranslationWarn() { return B(t.missingWarn) ? !t.missingWarn : t.missingWarn; }, set silentTranslationWarn(a) { t.missingWarn = B(a) ? !a : a; }, get silentFallbackWarn() { return B(t.fallbackWarn) ? !t.fallbackWarn : t.fallbackWarn; }, set silentFallbackWarn(a) { t.fallbackWarn = B(a) ? !a : a; }, get modifiers() { return t.modifiers; }, get formatFallbackMessages() { return t.fallbackFormat; }, set formatFallbackMessages(a) { t.fallbackFormat = a; }, get postTranslation() { return t.getPostTranslationHandler(); }, set postTranslation(a) { t.setPostTranslationHandler(a); }, get sync() { return t.inheritLocale; }, set sync(a) { t.inheritLocale = a; }, get warnHtmlInMessage() { return t.warnHtmlMessage ? "warn" : "off"; }, set warnHtmlInMessage(a) { t.warnHtmlMessage = a !== "off"; }, get escapeParameterHtml() { return t.escapeParameter; }, set escapeParameterHtml(a) { t.escapeParameter = a; }, get pluralizationRules() { return t.pluralRules || {}; }, __composer: t, t(...a) { return Reflect.apply(t.t, t, [...a]); }, rt(...a) { return Reflect.apply(t.rt, t, [...a]); }, te(a, r) { return t.te(a, r); }, tm(a) { return t.tm(a); }, getLocaleMessage(a) { return t.getLocaleMessage(a); }, setLocaleMessage(a, r) { t.setLocaleMessage(a, r); }, mergeLocaleMessage(a, r) { t.mergeLocaleMessage(a, r); }, d(...a) { return Reflect.apply(t.d, t, [...a]); }, getDateTimeFormat(a) { return t.getDateTimeFormat(a); }, setDateTimeFormat(a, r) { t.setDateTimeFormat(a, r); }, mergeDateTimeFormat(a, r) { t.mergeDateTimeFormat(a, r); }, n(...a) { return Reflect.apply(t.n, t, [...a]); }, getNumberFormat(a) { return t.getNumberFormat(a); }, setNumberFormat(a, r) { t.setNumberFormat(a, r); }, mergeNumberFormat(a, r) { t.mergeNumberFormat(a, r); } }; return s.__extender = n, s; } function Yl(e, t, n) { return { beforeCreate() { const s = nt(); if (!s) throw Ce(X.UNEXPECTED_ERROR); const a = this.$options; if (a.i18n) { const r = a.i18n; if (a.__i18n && (r.__i18n = a.__i18n), r.__root = t, this === this.$root) this.$i18n = _a(e, r); else { r.__injectWithOption = !0, r.__extender = n.__vueI18nExtend, this.$i18n = Nn(r); const l = this.$i18n; l.__extender && (l.__disposer = l.__extender(this.$i18n)); } } else if (a.__i18n) if (this === this.$root) this.$i18n = _a(e, a); else { this.$i18n = Nn({ __i18n: a.__i18n, __injectWithOption: !0, __extender: n.__vueI18nExtend, __root: t }); const r = this.$i18n; r.__extender && (r.__disposer = r.__extender(this.$i18n)); } else this.$i18n = e; a.__i18nGlobal && ts(t, a, a), this.$t = (...r) => this.$i18n.t(...r), this.$rt = (...r) => this.$i18n.rt(...r), this.$te = (r, l) => this.$i18n.te(r, l), this.$d = (...r) => this.$i18n.d(...r), this.$n = (...r) => this.$i18n.n(...r), this.$tm = (r) => this.$i18n.tm(r), n.__setInstance(s, this.$i18n); }, mounted() {}, unmounted() { const s = nt(); if (!s) throw Ce(X.UNEXPECTED_ERROR); const a = this.$i18n; delete this.$t, delete this.$rt, delete this.$te, delete this.$d, delete this.$n, delete this.$tm, a.__disposer && (a.__disposer(), delete a.__disposer, delete a.__extender), n.__deleteInstance(s), delete this.$i18n; } }; } function _a(e, t) { e.locale = t.locale || e.locale, e.fallbackLocale = t.fallbackLocale || e.fallbackLocale, e.missing = t.missing || e.missing, e.silentTranslationWarn = t.silentTranslationWarn || e.silentFallbackWarn, e.silentFallbackWarn = t.silentFallbackWarn || e.silentFallbackWarn, e.formatFallbackMessages = t.formatFallbackMessages || e.formatFallbackMessages, e.postTranslation = t.postTranslation || e.postTranslation, e.warnHtmlInMessage = t.warnHtmlInMessage || e.warnHtmlInMessage, e.escapeParameterHtml = t.escapeParameterHtml || e.escapeParameterHtml, e.sync = t.sync || e.sync, e.__composer[Qa](t.pluralizationRules || e.pluralizationRules); const n = Dn(e.locale, { messages: t.messages, __i18n: t.__i18n }); return Object.keys(n).forEach((s) => e.mergeLocaleMessage(s, n[s])), t.datetimeFormats && Object.keys(t.datetimeFormats).forEach((s) => e.mergeDateTimeFormat(s, t.datetimeFormats[s])), t.numberFormats && Object.keys(t.numberFormats).forEach((s) => e.mergeNumberFormat(s, t.numberFormats[s])), e; } var $n = { tag: { type: [String, Object] }, locale: { type: String }, scope: { type: String, validator: (e) => e === "parent" || e === "global", default: "parent" }, i18n: { type: Object } }; function Kl({ slots: e }, t) { return t.length === 1 && t[0] === "default" ? (e.default ? e.default() : []).reduce((s, a) => [...s, ...a.type === Fragment ? a.children : [a]], []) : t.reduce((n, s) => { const a = e[s]; return a && (n[s] = a()), n; }, Z()); } function rs() { return Fragment; } var pa = /* @__PURE__ */ defineComponent({ name: "i18n-t", props: ce({ keypath: { type: String, required: !0 }, plural: { type: [Number, String], validator: (e) => oe(e) || !isNaN(e) } }, $n), setup(e, t) { const { slots: n, attrs: s } = t, a = e.i18n || Vn({ useScope: e.scope, __useComponent: !0 }); return () => { const r = Object.keys(n).filter((C) => C[0] !== "_"), l = Z(); e.locale && (l.locale = e.locale), e.plural !== void 0 && (l.plural = A(e.plural) ? +e.plural : e.plural); const o = Kl(t, r), i = a[Cn](e.keypath, o, l), f = ce(Z(), s); return h$2(A(e.tag) || G(e.tag) ? e.tag : rs(), f, i); }; } }); function Zl(e) { return ee(e) && !A(e[0]); } function ls(e, t, n, s) { const { slots: a, attrs: r } = t; return () => { const l = { part: !0 }; let o = Z(); e.locale && (l.locale = e.locale), A(e.format) ? l.key = e.format : G(e.format) && (A(e.format.key) && (l.key = e.format.key), o = Object.keys(e.format).reduce((h, k) => n.includes(k) ? ce(Z(), h, { [k]: e.format[k] }) : h, Z())); const i = s(e.value, l, o); let f = [l.key]; ee(i) ? f = i.map((h, k) => { const D = a[h.type], O = D ? D({ [h.type]: h.value, index: k, parts: i }) : [h.value]; return Zl(O) && (O[0].key = `${h.type}-${k}`), O; }) : A(i) && (f = [i]); const _ = ce(Z(), r); return h$2(A(e.tag) || G(e.tag) ? e.tag : rs(), _, f); }; } var ha = /* @__PURE__ */ defineComponent({ name: "i18n-n", props: ce({ value: { type: Number, required: !0 }, format: { type: [String, Object] } }, $n), setup(e, t) { const n = e.i18n || Vn({ useScope: e.scope, __useComponent: !0 }); return ls(e, t, Za, (...s) => n[En](...s)); } }); function ql(e, t) { const n = e; if (e.mode === "composition") return n.__getInstance(t) || e.global; { const s = n.__getInstance(t); return s != null ? s.__composer : e.global.__composer; } } function Jl(e) { const t = (l) => { const { instance: o, value: i } = l; if (!o || !o.$) throw Ce(X.UNEXPECTED_ERROR); const f = ql(e, o.$), _ = ga(i); return [Reflect.apply(f.t, f, [...Ca(_)]), f]; }; return { created: (l, o) => { const [i, f] = t(o); ke && (l.__i18nWatcher = watch(f.locale, () => { o.instance && o.instance.$forceUpdate(); })), l.__composer = f, l.textContent = i; }, unmounted: (l) => { ke && l.__i18nWatcher && (l.__i18nWatcher(), l.__i18nWatcher = void 0, delete l.__i18nWatcher), l.__composer && (l.__composer = void 0, delete l.__composer); }, beforeUpdate: (l, { value: o }) => { if (l.__composer) { const i = l.__composer, f = ga(o); l.textContent = Reflect.apply(i.t, i, [...Ca(f)]); } }, getSSRProps: (l) => { const [o] = t(l); return { textContent: o }; } }; } function ga(e) { if (A(e)) return { path: e }; if (U(e)) { if (!("path" in e)) throw Ce(X.REQUIRED_VALUE, "path"); return e; } else throw Ce(X.INVALID_VALUE); } function Ca(e) { const { path: t, locale: n, args: s, choice: a, plural: r } = e, l = {}, o = s || {}; return A(n) && (l.locale = n), oe(a) && (l.plural = a), oe(r) && (l.plural = r), [ t, o, l ]; } function Ql(e, t, ...n) { const s = U(n[0]) ? n[0] : {}; (!B(s.globalInstall) || s.globalInstall) && ([pa.name, "I18nT"].forEach((r) => e.component(r, pa)), [ha.name, "I18nN"].forEach((r) => e.component(r, ha)), [Ea.name, "I18nD"].forEach((r) => e.component(r, Ea))), e.directive("t", Jl(t)); } var zl = /* @__PURE__ */ Me("global-vue-i18n"); function eo(e = {}) { const t = __VUE_I18N_LEGACY_API__ && B(e.legacy) ? e.legacy : __VUE_I18N_LEGACY_API__; const n = B(e.globalInjection) ? e.globalInjection : !0, s = /* @__PURE__ */ new Map(), [a, r] = to(e, t), l = /* @__PURE__ */ Me(""); function o(C) { return s.get(C) || null; } function i(C, h) { s.set(C, h); } function f(C) { s.delete(C); } const _ = { get mode() { return __VUE_I18N_LEGACY_API__ && t ? "legacy" : "composition"; }, async install(C, ...h) { if (C.__VUE_I18N_SYMBOL__ = l, C.provide(C.__VUE_I18N_SYMBOL__, _), U(h[0])) { const O = h[0]; _.__composerExtend = O.__composerExtend, _.__vueI18nExtend = O.__vueI18nExtend; } let k = null; !t && n && (k = co(C, _.global)), __VUE_I18N_FULL_INSTALL__ && Ql(C, _, ...h), __VUE_I18N_LEGACY_API__ && t && C.mixin(Yl(r, r.__composer, _)); const D = C.unmount; if (C.unmount = () => { k && k(), _.dispose(), D(); }, false); }, get global() { return r; }, dispose() { a.stop(); }, __instances: s, __getInstance: o, __setInstance: i, __deleteInstance: f }; return _; } function Vn(e = {}) { const t = nt(); if (t == null) throw Ce(X.MUST_BE_CALL_SETUP_TOP); if (!t.isCE && t.appContext.app != null && !t.appContext.app.__VUE_I18N_SYMBOL__) throw Ce(X.NOT_INSTALLED); const n = no(t), s = so(n), a = es(t), r = ao(e, a); if (r === "global") return ts(s, e, a), s; if (r === "parent") { let i = ro(n, t, e.__useComponent); return i ??= s, i; } const l = n; let o = l.__getInstance(t); if (o == null) { const i = ce({}, e); "__i18n" in a && (i.__i18n = a.__i18n), s && (i.__root = s), o = Pn(i), l.__composerExtend && (o[bn] = l.__composerExtend(o)), oo(l, t, o), l.__setInstance(t, o); } return o; } function to(e, t) { const n = effectScope(), s = __VUE_I18N_LEGACY_API__ && t ? n.run(() => Nn(e)) : n.run(() => Pn(e)); if (s == null) throw Ce(X.UNEXPECTED_ERROR); return [n, s]; } function no(e) { const t = inject(e.isCE ? zl : e.appContext.app.__VUE_I18N_SYMBOL__); if (!t) throw Ce(e.isCE ? X.NOT_INSTALLED_WITH_PROVIDE : X.UNEXPECTED_ERROR); return t; } function ao(e, t) { return xt(e) ? "__i18n" in t ? "local" : "global" : e.useScope ? e.useScope : "local"; } function so(e) { return e.mode === "composition" ? e.global : e.global.__composer; } function ro(e, t, n = !1) { let s = null; const a = t.root; let r = lo(t, n); for (; r != null;) { const l = e; if (e.mode === "composition") s = l.__getInstance(r); else if (__VUE_I18N_LEGACY_API__) { const o = l.__getInstance(r); o != null && (s = o.__composer, n && s && !s[za] && (s = null)); } if (s != null || a === r) break; r = r.parent; } return s; } function lo(e, t = !1) { return e == null ? null : t && e.vnode.ctx || e.parent; } function oo(e, t, n) { onMounted(() => {}, t), onUnmounted(() => { const a = n; e.__deleteInstance(t); const r = a[bn]; r && (r(), delete a[bn]); }, t); } var io = [ "locale", "fallbackLocale", "availableLocales" ], va = [ "t", "rt", "d", "n", "tm", "te" ]; function co(e, t) { const n = /* @__PURE__ */ Object.create(null); return io.forEach((a) => { const r = Object.getOwnPropertyDescriptor(t, a); if (!r) throw Ce(X.UNEXPECTED_ERROR); const l = /* @__PURE__ */ isRef(r.value) ? { get() { return r.value.value; }, set(o) { r.value.value = o; } } : { get() { return r.get && r.get(); } }; Object.defineProperty(n, a, l); }), e.config.globalProperties.$i18n = n, va.forEach((a) => { const r = Object.getOwnPropertyDescriptor(t, a); if (!r || !r.value) throw Ce(X.UNEXPECTED_ERROR); Object.defineProperty(e.config.globalProperties, `$${a}`, r); }), () => { delete e.config.globalProperties.$i18n, va.forEach((a) => { delete e.config.globalProperties[`$${a}`]; }); }; } var Ea = /* @__PURE__ */ defineComponent({ name: "i18n-d", props: ce({ value: { type: [Number, Date], required: !0 }, format: { type: [String, Object] } }, $n), setup(e, t) { const n = e.i18n || Vn({ useScope: e.scope, __useComponent: !0 }); return ls(e, t, ja, (...s) => n[vn](...s)); } }); Il(); Jr(Ar); Qr(jr); zr(mn); if (__INTLIFY_PROD_DEVTOOLS__) { const e = je(); e.__INTLIFY__ = !0, wr(e.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__); } var H = eo({ legacy: !1, globalInjection: !0, locale: localStorage?.getItem("locale") ?? navigator.language.split("-")[0], fallbackLocale: "en", messages: { de: { bubbleSelect: { error: "Bitte mindestens eine Option wählen." }, copyIcon: { copyLink: "Link kopieren" }, copyToClipboard: { default: "Link kopieren", copied: "Link kopiert", error: "Fehler beim Kopieren des Links" }, refreshIcon: { refreshLink: "Link ändern" }, expiryIndicator: { expired: "Abgelaufen", second: "Läuft ab in {n} Sekunden | Läuft ab in {n} Sekunde | Läuft ab in {n} Sekunden", minute: "Läuft ab in {n} Minuten | Läuft ab in {n} Minute | Läuft ab in {n} Minuten", hour: "Läuft ab in {n} Stunden | Läuft ab in {n} Stunde | Läuft ab in {n} Stunden", day: "Läuft ab in {n} Tagen | Läuft ab in {n} Tag | Läuft ab in {n} Tagen", week: "Läuft ab in {n} Wochen | Läuft ab in {n} Woche | Läuft ab in {n} Wochen", month: "Läuft ab in {n} Monaten | Läuft ab in {n} Monat | Läuft ab in {n} Monaten", year: "Läuft ab in {n} Jahren | Läuft ab in {n} Jahr | Läuft ab in {n} Jahren", and: { second: "und {n} Sekunden | und {n} Sekunde | und {n} Sekunden", minute: "und {n} Minuten | und {n} Minute | und {n} Minuten", hour: "und {n} Stunden | und {n} Stunde | und {n} Stunden", day: "und {n} Tagen | und {n} Tag | und {n} Tagen", week: "und {n} Wochen | und {n} Woche | und {n} Wochen", month: "und {n} Monaten | und {n} Monat | und {n} Monaten" } }, footer: { privacyPolicy: "Datenschutzerklärung", cookies: "Cookies", legal: "Impressum", sendDMCANotice: "DMCA-Benachrichtigung senden", reportFraud: "Missbrauch melden", participationGuidelines: "Teilnahmebestimmungen", contributeToThisSite: "Zum Inhalt beitragen", mzlaLinkText: "MZLA Technologies Corporation", creativeCommonsLinkText: "Creative-Commons-Lizenz", copywrite: "Thunderbird gehört zu {mzlaLink}, einer vollständigen Tochtergesellschaft der Nonprofit-Organisation Mozilla.org. Teile dieses Inhalts unterliegen dem Copyright ©1998-{currentYear} einzelner Mitwirkender. Der Inhalt ist unter einer {creativeCommonsLink} verfügbar." }, icons: { calendar: "Kalender", critical: "Kritisch", info: "Information", success: "Erfolg", warning: "Warnung", expires: "Die Gültigkeit dieser Datei läuft ab", check: "Häkchen" }, syncCard: { itemsSelected: "{count} ausgewählt", selectAll: "Alle auswählen", selectAllCalendars: "Alle Kalender auswählen" }, switchToggle: { off: "Aus", on: "An" }, textInput: { passwordIndicator: { show: "Passwort anzeigen", hide: "Passwort ausblenden" }, maxLengthAlt: "{currentCount} von {maxCount} Zeichen verbleiben." }, userAvatar: { altText: "Avatar von {username}" }, loadingSkeleton: { loadingMessage: "Laden." } }, en: { bubbleSelect: { error: "Please select at least one option." }, copyIcon: { copyLink: "Copy link" }, copyToClipboard: { default: "Copy to clipboard", copied: "Copied", error: "There was an error copying to clipboard" }, refreshIcon: { refreshLink: "Refresh link" }, expiryIndicator: { expired: "Expired", second: "Expires in {n} seconds | Expires in {n} second | Expires in {n} seconds", minute: "Expires in {n} minutes | Expires in {n} minute | Expires in {n} minutes", hour: "Expires in {n} hours | Expires in {n} hour | Expires in {n} hours", day: "Expires in {n} days | Expires in {n} day | Expires in {n} days", week: "Expires in {n} weeks | Expires in {n} week | Expires in {n} weeks", month: "Expires in {n} months | Expires in {n} month | Expires in {n} months", year: "Expires in {n} years | Expires in {n} year | Expires in {n} years", and: { second: "and {n} seconds | and {n} second | and {n} seconds", minute: "and {n} minutes | and {n} minute | and {n} minutes", hour: "and {n} hours | and {n} hour | and {n} hours", day: "and {n} days | and {n} day | and {n} days", week: "and {n} weeks | and {n} week | and {n} weeks", month: "and {n} months | and {n} month | and {n} months" } }, footer: { privacyPolicy: "Privacy Policy", cookies: "Cookies", legal: "Legal", sendDMCANotice: "Send DMCA Notice", reportFraud: "Report Fraud", participationGuidelines: "Participation Guidelines", contributeToThisSite: "Contribute to this site", mzlaLinkText: "MZLA Technologies Corporation", creativeCommonsLinkText: "Creative Commons license", copywrite: "Thunderbird is part of {mzlaLink}, a wholly owned subsidiary of the not-for-profit Mozilla.org. Portions of this content are ©1998–{currentYear} by individual contributors. Content available under a {creativeCommonsLink}." }, icons: { calendar: "Calendar", critical: "Critical", info: "Information", success: "Success", warning: "Warning", expires: "This File Expires", check: "Check" }, syncCard: { itemsSelected: "{count} Selected", selectAll: "Select All", selectAllCalendars: "Select All Calendars" }, switchToggle: { off: "Off", on: "On" }, textInput: { passwordIndicator: { show: "Show password", hide: "Hide password" }, maxLengthAlt: "{currentCount} out of {maxCount} characters remaining." }, userAvatar: { altText: "{username}'s avatar." }, loadingSkeleton: { loadingMessage: "Loading." } } } }).global.t; pe.Days; var Zo = ["aria-label", "data-testid"], Xo = { class: "tooltip-container" }, qo = { class: "tooltip-body" }, Qo = /* @__PURE__ */ z(/* @__PURE__ */ defineComponent({ __name: "ToolTip", props: { alt: { default: "" }, position: { default: Tn.Bottom }, dataTestid: { default: "tool-tip" } }, setup(e) { return (t, n) => (openBlock(), createElementBlock("div", { class: "tooltip", "aria-label": e.alt, "data-testid": e.dataTestid }, [createBaseVNode("div", Xo, [createBaseVNode("div", qo, [renderSlot(t.$slots, "default", {}, void 0, !0)]), (openBlock(), createElementBlock("svg", { class: normalizeClass(["beak", e.position]), width: "29", height: "6", viewBox: "0 0 29 6", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, [...n[0] || (n[0] = [createBaseVNode("path", { d: "M15.9142 4.58579C15.1332 5.36683 13.8668 5.36683 13.0858 4.58579L8.5 0L20.5 0L15.9142 4.58579Z", fill: "currentColor" }, null, -1)])], 2))])], 8, Zo)); } }), [["__scopeId", "data-v-95b82bf9"]]), zo = { key: 0, class: "icon" }, ei = { class: "text" }, ti = { key: 1, class: "icon" }, Nt = /* @__PURE__ */ z(/* @__PURE__ */ defineComponent({ __name: "BaseButton", props: { type: { default: "primary" }, size: { default: "default" }, variant: { default: "filled" }, href: {}, tooltip: {}, forceTooltip: { type: Boolean, default: !1 }, formAction: { default: "none" }, dataTestid: { default: "button" }, disabled: { type: Boolean, default: !1 } }, setup(e) { return (t, n) => (openBlock(), createBlock(resolveDynamicComponent(e.href ? "a" : "button"), { href: e.href, class: normalizeClass(["base", { [e.type]: e.type, small: e.size === "small", [e.variant]: e.variant }]), type: e.formAction === "none" ? "button" : e.formAction, "data-testid": e.dataTestid, disabled: e.disabled }, { default: withCtx(() => [ t.$slots?.iconLeft ? (openBlock(), createElementBlock("span", zo, [renderSlot(t.$slots, "iconLeft", {}, void 0, !0)])) : createCommentVNode("", !0), createBaseVNode("span", ei, [renderSlot(t.$slots, "default", {}, void 0, !0)]), t.$slots?.iconRight ? (openBlock(), createElementBlock("span", ti, [renderSlot(t.$slots, "iconRight", {}, void 0, !0)])) : createCommentVNode("", !0), e.tooltip ? (openBlock(), createBlock(Qo, { key: 2, class: normalizeClass(["tooltip", { "display-tooltip": e.forceTooltip }]), position: unref(Tn).Bottom, onClick: n[0] || (n[0] = withModifiers(() => {}, ["prevent"])) }, { default: withCtx(() => [createTextVNode(toDisplayString(e.tooltip), 1)]), _: 1 }, 8, ["class", "position"])) : createCommentVNode("", !0) ]), _: 3 }, 8, [ "href", "class", "type", "data-testid", "disabled" ])); } }), [["__scopeId", "data-v-1a1b9d0c"]]), si = /* @__PURE__ */ defineComponent({ __name: "PrimaryButton", setup(e) { return (t, n) => (openBlock(), createBlock(Nt, { type: "primary" }, createSlots({ default: withCtx(() => [renderSlot(t.$slots, "default")]), _: 2 }, [renderList(t.$slots, (s, a) => ({ name: a, fn: withCtx((r) => [renderSlot(t.$slots, a, normalizeProps(guardReactiveProps(r)))]) }))]), 1024)); } }); typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope; ka.Scan; et.Info; H("copyToClipboard.default"); //#endregion //#region ../send/frontend/src/lib/auth/AuthButtons.vue?vue&type=script&setup=true&lang.ts var _hoisted_1$3 = { class: "auth-buttons" }; var _hoisted_2$2 = { class: "buttons-container" }; var _hoisted_3 = { class: "button-text" }; var _hoisted_4 = { class: "buttons-container" }; var _hoisted_5 = { class: "button-text" }; //#endregion //#region ../send/frontend/src/lib/auth/AuthButtons.vue var AuthButtons_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({ __name: "AuthButtons", props: { isExtension: { type: Boolean }, loginToOidc: { type: Function }, loginToOidcForExtension: { type: Function } }, setup(__props) { const loginText = /* @__PURE__ */ ref("Sign In"); return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [createBaseVNode("div", _hoisted_1$3, [!__props.isExtension ? (openBlock(), createBlock(unref(si), { key: 0, "data-testid": "login-button-tbpro", onClickCapture: __props.loginToOidc }, { default: withCtx(() => [createBaseVNode("div", _hoisted_2$2, [createBaseVNode("span", _hoisted_3, toDisplayString(loginText.value), 1), createVNode(RightArrowIcon_default)])]), _: 1 }, 8, ["onClickCapture"])) : createCommentVNode("", true), __props.isExtension ? (openBlock(), createBlock(unref(si), { key: 1, "data-testid": "extension-management-button", onClickCapture: __props.loginToOidcForExtension }, { default: withCtx(() => [createBaseVNode("div", _hoisted_4, [createBaseVNode("span", _hoisted_5, toDisplayString(loginText.value), 1), createVNode(RightArrowIcon_default)])]), _: 1 }, 8, ["onClickCapture"])) : createCommentVNode("", true)]), createVNode(FeedbackBox_default)], 64); }; } }), [["__scopeId", "data-v-38d68ad7"]]); //#endregion //#region ../send/frontend/src/apps/common/VersionTag.vue?vue&type=script&setup=true&lang.ts var _hoisted_1$2 = { class: "addon-version-tag", "data-testid": "addon-version" }; //#endregion //#region ../send/frontend/src/apps/common/VersionTag.vue var VersionTag_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({ __name: "VersionTag", setup(__props) { const version = "2.0.5"; return (_ctx, _cache) => { return openBlock(), createElementBlock("span", _hoisted_1$2, " v" + toDisplayString(unref(version)), 1); }; } }), [["__scopeId", "data-v-46c038cc"]]); //#endregion //#region ../send/frontend/src/composables/useSendConfig.ts function useSendConfig() { const userStore = useUserStore(); const { keychain } = useKeychainStore(); const { api } = useApiStore(); const folderStore = useFolderStore(); const { validators } = useStatusStore(); const { configureExtension } = useExtensionStore(); const { initializeClientMetrics } = useMetricsStore(); const { isLoggedIn } = storeToRefs(useAuthStore()); /** * Pulls a passphrase shared from the web app via the token bridge into the * keychain (delegates to pullBridgedPassphrase). Called before the login * checks in loadLogin so the passphrase is present when keys are restored. */ const checkAndTransferBridgeMessage = async () => { return pullBridgedPassphrase(keychain); }; try { browser.runtime.onMessage.addListener(async (message) => { if (message.type === "TRANSFER_BRIDGE_MESSAGE") { console.log("📨 Received transfer trigger from background"); await loadLogin(); } return false; }); } catch { console.log("ℹ️ Running in non-extension context"); } const loadLogin = async () => { await checkAndTransferBridgeMessage(); const { hasForcedLogin } = await validators(); if (hasForcedLogin) { isLoggedIn.value = false; return false; } await userStore.loadFromLocalStorage(); try { if (!await userStore.populateFromBackend()) return false; await init(userStore, keychain, folderStore); await finishLogin(); } catch (e) { console.log(e); } const uid = userStore?.user?.uniqueHash; initializeClientMetrics(uid); return true; }; async function finishLogin() { if (!await validateToken(api)) { console.error("Session is not valid"); return; } await dbUserSetup(userStore, keychain, folderStore); const { isTokenValid, hasBackedUpKeys } = await validators(); if (isTokenValid && hasBackedUpKeys) try { await configureExtension(); } catch (error) { console.warn("You are running this outside TB", error); } console.log("isTokenValid", isTokenValid); isLoggedIn.value = true; } const useLoginQuery = () => { return useQuery({ queryKey: ["getLoginStatus"], queryFn: async () => await loadLogin(), refetchOnWindowFocus: "always", refetchOnMount: true, refetchOnReconnect: true }); }; const clearSendStorage = async () => { try { localStorage.clear(); console.log("✅ Cleared Send localStorage"); } catch (error) { console.error("Error clearing Send localStorage:", error); } }; /** * Queries the addon's login state via bidirectional message passing. * Returns a promise that resolves with the login state or times out after 5 seconds. * @returns Promise<{isLoggedIn: boolean, username: string | null}> */ const queryAddonLoginState = () => { return new Promise((resolve, reject) => { const timeout = setTimeout(() => { cleanup(); reject(/* @__PURE__ */ new Error("Timed out waiting for addon login state")); }, 5e3); const messageHandler = (event) => { if (event.data?.type === "LOGIN_STATE_RESPONSE") { cleanup(); resolve({ isLoggedIn: event.data.isLoggedIn, username: event.data.username }); } }; const cleanup = () => { clearTimeout(timeout); window.removeEventListener("message", messageHandler); }; window.addEventListener("message", messageHandler); window.postMessage({ type: GET_LOGIN_STATE }, window.location.origin); }); }; return { /** * Loads and validates user login state from local storage and backend. * On success, initializes app state and configures the extension. * Sets isLoggedIn to false if forced login is required. */ loadLogin, /** * Completes the login process by validating the session token, * setting up the database user, validating credentials, and configuring * the extension if running in Thunderbird environment. */ finishLogin, /** * Vue Query composable for managing login status. * Automatically refetches on window focus, mount, and reconnect. */ useLoginQuery, /** * Pulls a passphrase shared from the web app via the token bridge into the * keychain (delegates to pullBridgedPassphrase). */ checkAndTransferBridgeMessage, /** * Clears Send-related data from localStorage. */ clearSendStorage, /** * Queries the addon's login state via bidirectional message passing. * Returns a promise that resolves with the login state or times out after 5 seconds. */ queryAddonLoginState }; } //#endregion //#region ../send/frontend/src/apps/common/ProButton.vue var ProButton_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({ __name: "ProButton", props: { type: { default: "primary" } }, emits: ["click"], setup(__props) { return (_ctx, _cache) => { return openBlock(), createElementBlock("button", { class: normalizeClass(["pro-button", { "pro-button--primary": __props.type === "primary", "pro-button--secondary": __props.type === "secondary" }]), onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("click")) }, [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 2); }; } }), [["__scopeId", "data-v-eb342a1c"]]); //#endregion //#region ../send/frontend/src/apps/send/views/SendAddonDashboard.vue var SendAddonDashboard_default = /* @__PURE__ */ defineComponent({ __name: "SendAddonDashboard", setup(__props) { async function menuManageSend() { await browser.tabs.create({ url: `${BASE_URL}/send/profile?showDashboard=true` }); } return (_ctx, _cache) => { return openBlock(), createElementBlock(Fragment, null, [_cache[1] || (_cache[1] = createBaseVNode("p", null, " Encrypted Storage: Manage your files and settings in the Send dashboard. ", -1)), createVNode(ProButton_default, { onClick: menuManageSend }, { default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Open Dashboard", -1)])]), _: 1 })], 64); }; } }); //#endregion //#region ../send/frontend/src/apps/send/views/SendDashboardView.vue var SendDashboardView_default = /* @__PURE__ */ defineComponent({ __name: "SendDashboardView", props: { isTbproExtension: { type: Boolean } }, setup(__props) { const { useLoginQuery } = useSendConfig(); onMounted(() => { if (__props.isTbproExtension) useLoginQuery(); }); return (_ctx, _cache) => { return openBlock(), createBlock(SendAddonDashboard_default); }; } }); //#endregion //#region src/apps/AdminPage.vue?vue&type=script&setup=true&lang.ts var _hoisted_1$1 = { class: "admin-container" }; var _hoisted_2$1 = { key: 0, class: "service-section", "data-testid": "send-section" }; //#endregion //#region src/apps/AdminPage.vue var AdminPage_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({ __name: "AdminPage", setup(__props) { const showSend = /* @__PURE__ */ ref(true); const isTbproExtension = computed(() => true); console.log("isTbproExtension", isTbproExtension.value); return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1$1, [showSend.value ? (openBlock(), createElementBlock("div", _hoisted_2$1, [createVNode(SendDashboardView_default, { "is-tbpro-extension": isTbproExtension.value }, null, 8, ["is-tbpro-extension"])])) : createCommentVNode("", true)]); }; } }), [["__scopeId", "data-v-9d479c00"]]); //#endregion //#region src/apps/AddonManagementPage.vue?vue&type=script&setup=true&lang.ts var _hoisted_1 = { class: "content" }; var _hoisted_2 = { key: 0, class: "login-section" }; //#endregion //#region src/apps/management.js var app = createApp(/* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({ __name: "AddonManagementPage", setup(__props) { const authStore = useAuthStore(); const { isLoggedIn, refetchAuth, isLoadingAuth } = useAuth(); const { loginToOIDC } = authStore; async function _loginToOIDC() { loginToOIDC({ onSuccess: refetchAuth, isExtension: true }); } async function openLoginPage() { await browser.tabs.create({ url: `${BASE_URL}/login?isExtension=true` }); } return (_ctx, _cache) => { return openBlock(), createElementBlock("div", _hoisted_1, [ createVNode(TbproLogo_default), createVNode(WithLoader_default, { "is-loading": unref(isLoadingAuth) }, { default: withCtx(() => [!unref(isLoggedIn) ? (openBlock(), createElementBlock("div", _hoisted_2, [_cache[0] || (_cache[0] = createBaseVNode("p", { class: "description" }, " Sign in with Thundermail to use Send or restore access to your encrypted files. ", -1)), createVNode(AuthButtons_default, { "is-extension": true, "login-to-oidc": _loginToOIDC, "login-to-oidc-for-extension": openLoginPage })])) : (openBlock(), createBlock(AdminPage_default, { key: 1 }))]), _: 1 }, 8, ["is-loading"]), createVNode(VersionTag_default) ]); }; } }), [["__scopeId", "data-v-45c3ae9c"]])); setupApp(app); mountApp(app, "#management-page"); //#endregion