var ce = Object.defineProperty; var le = (r, e, t) => e in r ? ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t; var v = (r, e, t) => (le(r, typeof e != "symbol" ? e + "" : e, t), t), re = (r, e, t) => { if (!e.has(r)) throw TypeError("Cannot " + t); }; var i = (r, e, t) => (re(r, e, "read from private field"), t ? t.call(r) : e.get(r)), E = (r, e, t) => { if (e.has(r)) throw TypeError("Cannot add the same private member more than once"); e instanceof WeakSet ? e.add(r) : e.set(r, t); }, A = (r, e, t, n) => (re(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t); function he(r) { return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r; } var oe = {}; (function(r) { (function(e) { e([], function() { var t = -1, n = -2, s = -3, c = -4, l = -5, C = function(h, o) { o = o || {}; var d = o.verbose || !1; d && console.log("Normalize the JSON Object"), h = typeof h == "string" ? this.JSON.parse(h) : h, d && console.log("Creating a empty dictionary"); var u = { strings: [], integers: [], floats: [] }; d && console.log("Creating the AST"); var g = function P(a) { d && console.log("Calling recursiveAstBuilder with " + this.JSON.stringify(a)); var w = typeof a; if (a === null) return { type: "null", index: s }; if (typeof a > "u") return { type: "undefined", index: l }; if (a instanceof Array) { var x = ["@"]; for (var y in a) a.hasOwnProperty(y) && x.push(P(a[y])); return x; } if (w === "object") { var x = ["$"]; for (var $ in a) a.hasOwnProperty($) && (x.push(P($)), x.push(P(a[$]))); return x; } if (a === "") return { type: "empty", index: c }; if (w === "string") { var O = T.call(u.strings, a); return O == -1 && (u.strings.push(G(a)), O = u.strings.length - 1), { type: "strings", index: O }; } if (w === "number" && a % 1 === 0) { var O = T.call(u.integers, a); return O == -1 && (u.integers.push(F(a)), O = u.integers.length - 1), { type: "integers", index: O }; } if (w === "number") { var O = T.call(u.floats, a); return O == -1 && (u.floats.push(a), O = u.floats.length - 1), { type: "floats", index: O }; } if (w === "boolean") return { type: "boolean", index: a ? t : n }; throw new Error("Unexpected argument of type " + typeof a); }(h), b = u.strings.length, I = u.integers.length; u.floats.length, d && console.log("Parsing the dictionary"); var N = u.strings.join("|"); return N += "^" + u.integers.join("|"), N += "^" + u.floats.join("|"), d && console.log("Parsing the structure"), N += "^" + function P(a) { if (d && console.log("Calling a recursiveParser with " + this.JSON.stringify(a)), a instanceof Array) { var w = a.shift(); for (var x in a) a.hasOwnProperty(x) && (w += P(a[x]) + "|"); return (w[w.length - 1] === "|" ? w.slice(0, -1) : w) + "]"; } var y = a.type, $ = a.index; if (y === "strings") return F($); if (y === "integers") return F(b + $); if (y === "floats") return F(b + I + $); if (y === "boolean") return a.index; if (y === "null") return s; if (y === "undefined") return l; if (y === "empty") return c; throw new TypeError("The item is alien!"); }(g), d && console.log("Ending parser"), o.debug ? { dictionary: u, ast: g, packed: N } : N; }, M = function(h, o) { o = o || {}; var d = h.split("^"); o.verbose && console.log("Building dictionary"); var u = [], g = d[0]; if (g !== "") { g = g.split("|"), o.verbose && console.log("Parse the strings dictionary"); for (var b = 0, I = g.length; b < I; b++) u.push(z(g[b])); } if (g = d[1], g !== "") { g = g.split("|"), o.verbose && console.log("Parse the integers dictionary"); for (var b = 0, I = g.length; b < I; b++) u.push(f(g[b])); } if (g = d[2], g !== "") { g = g.split("|"), o.verbose && console.log("Parse the floats dictionary"); for (var b = 0, I = g.length; b < I; b++) u.push(parseFloat(g[b])); } g = null, o.verbose && console.log("Tokenizing the structure"); for (var N = "", P = [], a = d[3].length, b = 0; b < a; b++) { var w = d[3].charAt(b); w === "|" || w === "$" || w === "@" || w === "]" ? (N && (P.push(f(N)), N = ""), w !== "|" && P.push(w)) : N += w; } var x = P.length, y = 0; return o.verbose && console.log("Starting recursive parser"), function $() { var O = P[y++]; if (o.verbose && console.log("Reading collection type " + (O === "$" ? "object" : "Array")), O === "@") { for (var p = []; y < x; y++) { var _ = P[y]; if (o.verbose && console.log("Read " + _ + " symbol"), _ === "]") return p; if (_ === "@" || _ === "$") p.push($()); else switch (_) { case t: p.push(!0); break; case n: p.push(!1); break; case s: p.push(null); break; case l: p.push(void 0); break; case c: p.push(""); break; default: p.push(u[_]); } } return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p; } if (O === "$") { for (var p = {}; y < x; y++) { var S = P[y]; if (S === "]") return p; S === c ? S = "" : S = u[S]; var _ = P[++y]; if (_ === "@" || _ === "$") p[S] = $(); else switch (_) { case t: p[S] = !0; break; case n: p[S] = !1; break; case s: p[S] = null; break; case l: p[S] = void 0; break; case c: p[S] = ""; break; default: p[S] = u[_]; } } return o.verbose && console.log("Parsed " + this.JSON.stringify(p)), p; } throw new TypeError("Bad token " + O + " isn't a type"); }(); }, G = function(h) { return typeof h != "string" ? h : h.replace(/[\+ \|\^\%]/g, function(o) { return { " ": "+", "+": "%2B", "|": "%7C", "^": "%5E", "%": "%25" }[o]; }); }, z = function(h) { return typeof h != "string" ? h : h.replace(/\+|%2B|%7C|%5E|%25/g, function(o) { return { "+": " ", "%2B": "+", "%7C": "|", "%5E": "^", "%25": "%" }[o]; }); }, F = function(h) { return Number.prototype.toString.call(h, 36).toUpperCase(); }, f = function(h) { return parseInt(h, 36); }, T = Array.prototype.indexOf || function(h, o) { for (var d = o || 0, u = this.length; d < u; d++) if (this[d] === h) return d; return -1; }; return { JSON, pack: C, unpack: M }; }); })(function(e, t) { var n = t(); for (var s in n) r[s] = n[s]; }); })(oe); const ne = /* @__PURE__ */ he(oe); var j, B, D, U, Y, Q, J, W, X; class ee { constructor(e, t, n, s, c) { v(this, "code", 0); v(this, "message", "操作成功"); v(this, "data", null); v(this, "url", ""); v(this, "res", ""); // static [Symbol.hasInstance](self) { return self?.IS_ECHO_MSG !== undefined } E(this, j, null); // 判断返回 Response 对象, 还是 Response 中的 data E(this, B, !0); // 判罚是否已经给出错误提示 E(this, D, !0); E(this, U, { get: (e, t) => i(this, Y).call(this, t), ownKeys: () => Object.keys(i(this, U).getPrototypeOf() || {}), getPrototypeOf: () => i(this, B) ? this : this.data, getOwnPropertyDescriptor: () => ({ configurable: !0, enumerable: !0, writable: !0, value: i(this, U).getPrototypeOf() }) }); E(this, Y, (e) => e === "$echoMsg" ? i(this, J) : e === "msg" ? i(this, Q) : e === "then" || e === "resp" ? (A(this, D, !0), A(this, B, e === "resp"), i(this, W)) : e === "catch" ? i(this, X) : e === "IS_ECHO_MSG" ? i(this, D) : Reflect.get(this, e)); E(this, Q, (e = (n) => n, t = !1) => (i(this, J).call(this), A(this, B, t), Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf())))); E(this, J, () => { i(this, D) && (A(this, D, !1), Pe.onMsg(this.code, this.message)); }); E(this, W, (e) => [0, 1].includes(this.code) ? Promise.resolve(e == null ? void 0 : e(i(this, U).getPrototypeOf())) : Promise.reject(i(this, j))); E(this, X, (e) => Promise.resolve(e(i(this, j)))); return this.code = e, this.message = t, this.data = n, this.url = s, this.res = c, A(this, j, new Proxy(this, i(this, U))); } } j = new WeakMap(), B = new WeakMap(), D = new WeakMap(), U = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), J = new WeakMap(), W = new WeakMap(), X = new WeakMap(); const k = (r, e, t, n = "/", s = "") => new ee(r, e, t, n, s); var ie = [ "utf8", "utf-8", "unicode-1-1-utf-8" ]; function fe(r) { if (ie.indexOf(r) < 0 && typeof r < "u" && r != null) throw new RangeError("Invalid encoding type. Only utf-8 is supported"); this.encoding = "utf-8", this.encode = function(e) { if (typeof e != "string") throw new TypeError("passed argument must be of tye string"); var t = unescape(encodeURIComponent(e)), n = new Uint8Array(t.length); const s = t.split(""); for (let c = 0; c < s.length; c++) n[c] = s[c].charCodeAt(0); return n; }; } function ue(r) { if (ie.indexOf(r) < 0 && typeof r < "u" && r != null) throw new RangeError("Invalid encoding type. Only utf-8 is supported"); this.encoding = "utf-8", this.decode = function(e, t) { if (typeof e > "u") return ""; var n = typeof t < "u" && n in t ? t.stream : !1; if (typeof n != "boolean") throw new TypeError("stream option must be boolean"); if (ArrayBuffer.isView(e)) { var s = new Uint8Array(e.buffer, e.byteOffset, e.byteLength), c = new Array(s.length); for (let l = 0; l < s.length; l++) c[l] = String.fromCharCode(s[l]); return decodeURIComponent(escape(c.join(""))); } else throw new TypeError("passed argument must be an array buffer view"); }; } var ae = { TextEncoder: fe, TextDecoder: ue }; const de = new ae.TextEncoder("utf8"), ge = new ae.TextDecoder("utf8"), pe = (r) => { let e = 5381; for (let t = 0; t < r.length; t++) e = e * 33 ^ r.charCodeAt(t); return (e >>> 0).toString(16); }, ve = (r, e) => r.replace(new RegExp(`^${e}+|${e}+$`, "g"), ""), we = (r) => de.encode(r || ""), Se = (r) => ge.decode(new DataView(r), {}), ye = 62, V = 30, se = 31, be = 63; class Ee { constructor(e) { v(this, "encodeTable", []); v(this, "decodeMap", new Uint8Array(256).fill(255)); if (e.length !== ye) throw new Error("Encoding alphabet must be 62 characters long"); if (e.includes(` `) || e.includes("\r")) throw new Error("Encoding alphabet contains newline character"); this.encodeTable = e.split(""), this.decodeMap = new Uint8Array(256).fill(255); for (let t = 0; t < e.length; t++) this.decodeMap[e.charCodeAt(t)] = t; } // 编码方法 encode(e) { if (!e || e.length === 0) return []; const t = new Oe(this).encodeV2(e); return String.fromCharCode(...t); } // 解码方法 decode(e) { if (!e || e.length === 0) return new Uint8Array(); const t = new Te(this).decode(e); return new TextDecoder().decode(t); } } var K; class Oe { constructor(e) { E(this, K, null); A(this, K, e); } get6bits() { let e = this.pos & 7, t = this.pos >> 3; e === 0 && (t -= 1, e = 8); let n = this.src[t] >> 8 - e; return e < 6 && t > 0 && (n |= this.src[t - 1] << e), n & be; } encodeV2(e) { this.src = we(e), this.pos = this.src.length * 8; const t = []; for (; this.pos > 0; ) { let n = 6, s = this.get6bits(); (s & V) === V && ((this.pos > 6 || s > se) && (n = 5), s &= se), t.push(i(this, K).encodeTable[s].charCodeAt(0)), this.pos -= n; } return t; } } K = new WeakMap(); var H; class Te { constructor(e) { E(this, H, null); A(this, H, e); } decode(e) { const t = new Uint8Array(Math.ceil(e.length * 6 / 8) + 1); let n = t.length, s = 0, c = 0; for (let l = 0; l < e.length; l++) { const C = e[l].charCodeAt(0), M = i(this, H).decodeMap[C]; if (M === 255) throw new Error(`CorruptInputError at index ${l}`); l === e.length - 1 ? (c |= M << s, s += Math.ceil(Math.log2(M + 1))) : (M & V) === V ? (c |= M << s, s += 5) : (c |= M << s, s += 6), s >= 8 && (n--, t[n] = c & 255, s %= 8, c >>= 8); } return s > 0 && (n--, t[n] = c & 255), t.slice(n); } } H = new WeakMap(); Promise.withResolvers || (Promise.withResolvers = function() { let r, e; return { promise: new Promise((n, s) => { r = n, e = s; }), resolve: r, reject: e }; }); var L, q, Z, m, R; class te { constructor(e, t, n = ({}) => Promise.reject({ code: -1, msg: "请初始化HTTP请求方法主体" })) { E(this, L, void 0); E(this, q, void 0); E(this, Z, void 0); E(this, m, { "#": /* @__PURE__ */ new Map(), // 系统缓存 $: /* @__PURE__ */ new Map() // 普通缓存 }); E(this, R, /* @__PURE__ */ new Map()); v(this, "request", ({ url: e = "/", method: t = "GET", ...n }, s = !1) => { var F; e = ve(e, "/"); const c = t.toUpperCase(), l = pe(JSON.stringify([e, c, n])), C = (F = e == null ? void 0 : e.includes) != null && F.call(e, "/_/") ? "#" : "$", { promise: M, resolve: G, reject: z } = Promise.withResolvers(); return i(this, m)[C].has(l) ? (console.log("cache", e), G(i(this, m)[C].get(l))) : i(this, R).has(l) ? i(this, R).get(l).push([G, z]) : (i(this, R).set(l, [[G, z]]), i(this, L).call(this, { url: e, method: c, ...n }).then((f) => { if (![0, 1].includes(f.code)) throw k(f.code, f.msg, f.data, e, f == null ? void 0 : f.res); return [f.code, f.msg, f.data, e, f == null ? void 0 : f.res]; }).then((f) => ((C == "#" || c == "GET") && i(this, m)[C].set(l, f), C != "#" && c == "GET" && !s && setTimeout(() => { i(this, m)[C].delete(l); }, 300), f)).then((f) => { var T; return (T = i(this, R).get(l)) == null ? void 0 : T.forEach((h, o, d) => { h && h[0](f), delete d[o]; }); }).catch((f) => { var T; i(this, m)[C].delete(l), (T = i(this, R).get(l)) == null || T.forEach((h, o, d) => { h && h[1](f instanceof ee ? f : k(-1, f, null, e)), delete d[o]; }); }).finally(() => i(this, R).delete(l))), new Proxy(M, { get: (f, T) => (...h) => f.then((o) => k(...o)[T](...h)).catch((o) => { if (!o instanceof ee) throw o; return typeof o[T] == "function" ? o[T](...h) : o[T]; }) }); }); v(this, "get", (e, t = {}) => this.request({ url: e, method: "GET", params: t })); v(this, "post", (e, t = {}, n = {}) => this.request({ url: e, method: "POST", data: t, params: n })); v(this, "put", (e, t = {}, n = {}) => this.request({ url: e, method: "PUT", data: t, params: n })); v(this, "del", (e, t = {}, n = {}) => this.request({ url: e, method: "DELETE", data: t, params: n })); v(this, "download", (e, t) => { }); v(this, "cache", (e, t = {}) => this.request({ url: e, method: "GET", params: t }, !0)); v(this, "list", (e, t = {}) => this.get(`/api/${e}/${this.encode(t)}`)); v(this, "getAppInfo", () => { }); v(this, "refreshCache", (e = !1) => { e && i(this, m)["#"].clear(), i(this, m).$.clear(); }); v(this, "decode", (e = "", t = {}) => { if (e === void 0 || e === "" || e === null) return t; try { const n = i(this, q).decode(e); return ne.unpack(n); } catch { return console.warn("core.decode", e), t; } }); v(this, "encode", (e = {}) => { const t = JSON.stringify(e, (n, s) => s === void 0 ? null : s); return i(this, q).encode(ne.pack(t)); }); A(this, Z, e), A(this, L, n), A(this, q, new Ee(t)); } } L = new WeakMap(), q = new WeakMap(), Z = new WeakMap(), m = new WeakMap(), R = new WeakMap(); const Pe = te; te.onUnhandledRejection = (r) => { var e, t, n, s, c, l; r != null && r.IS_ECHO_MSG ? ((e = r == null ? void 0 : r.$echoMsg) == null || e.call(r), (t = r == null ? void 0 : r.preventDefault) == null || t.call(r)) : (n = r.reason) != null && n.IS_ECHO_MSG && ((c = (s = r.reason) == null ? void 0 : s.$echoMsg) == null || c.call(s), (l = r == null ? void 0 : r.preventDefault) == null || l.call(r)); }; te.onMsg = (r, e) => [0, 1].includes(r) ? console.log(e) : console.warn(e); export { Pe as default, pe as signature, we as str2uint8array, ve as trim, Se as uint8array2str };