var n = new Map(); var s = /.+:wasm-function\[[0-9]+]:0x([0-9a-f]+).*/; function D(e) { let t = n.get(e); if (typeof t === "undefined") { t = new Function("return " + e + ";"); n.set(e, t); } return t(); } function O(e, t) { new Function("value", e + " = value;")(t); } function x(e, t, n) { const r = { exports: null, userExports: t, stackDeobfuscator: null }; if (!n) { o(e); } a(e); l(e); i(e, r); u(e); f(e, r, n); e.teavmMath = Math; return { supplyExports(e) { r.exports = e; }, supplyStackDeobfuscator(e) { r.stackDeobfuscator = e; }, }; } var _ = Symbol("javaException"); var E = class extends Error { #context; [_]; constructor(e, t) { super(); this.#context = e; this[_] = t; e.exports["teavm.setJsException"](t, this); } get message() { const e = this.#context.exports["teavm.exceptionMessage"]; const t = this.#context.exports["teavm.stringToJs"]; if (typeof e === "function" && typeof t === "function") { const n = e(this[_]); if (n != null) { return t(n); } } return "(could not fetch message)"; } }; function o(e) { e["wasm:js-string"] = { fromCharCode: (e) => String.fromCharCode(e), fromCharCodeArray: () => { throw new Error("Not supported"); }, intoCharCodeArray: () => { throw new Error("Not supported"); }, concat: (e, t) => e + t, charCodeAt: (e, t) => e.charCodeAt(t), length: (e) => e.length, substring: (e, t, n) => e.substring(t, n), }; } function a(e) { e.teavmDate = { currentTimeMillis: () => new Date().getTime(), dateToString: (e) => new Date(e).toString(), getYear: (e) => new Date(e).getFullYear(), setYear(e, t) { const n = new Date(e); n.setFullYear(t); return n.getTime(); }, getMonth: (e) => new Date(e).getMonth(), setMonth(e, t) { const n = new Date(e); n.setMonth(t); return n.getTime(); }, getDate: (e) => new Date(e).getDate(), setDate(e, t) { const n = new Date(e); n.setDate(t); return n.getTime(); }, create: (e, t, n, r, o, a) => new Date(e, t, n, r, o, a).getTime(), createFromUTC: (e, t, n, r, o, a) => Date.UTC(e, t, n, r, o, a), }; } function l(e) { let t = ""; let n = ""; e.teavmConsole = { putcharStderr(e) { if (e === 10) { console.error(t); t = ""; } else { t += String.fromCharCode(e); } }, putcharStdout(e) { if (e === 10) { console.log(n); n = ""; } else { n += String.fromCharCode(e); } }, }; } function k(e, t) { return (((e - 1) >> t) + 1) << t; } async function A(u, e, t, n) { const r = e.memory ?? {}; const o = t ? M(t) : {}; let f = r.external; const a = e.stack ?? 2 * (1 << 20); let s = o.dataSize ?? 0; let l = 0; for (const h of n) { const d = C(h.wasmModule); const g = d.memorySize ?? 0; const v = d.memoryAlignment ?? 1; const x = d.tableSize ?? 0; const A = d.tableAlignment ?? 1; if (g > 0) { s = k(s, v); h.memoryOffset = s; s += g; } if (x > 0) { l = k(l, A); h.tableOffset = l; l += x; } } let p = -1; let m = -1; let y = -1; if (n.length > 0) { s = k(s, 4); p = s; m = s; s += a; s = k(s, 4); y = s; } let c = r.maxSize; s = k(s, 8); const i = s; if (!f) { const j = o.min ?? 0; s += j; s = Math.max(s, r.minSize ?? 0); const J = r.shared ?? o.shared ?? false; c ??= ((1 << 31) - 1) | 0; const S = Math.max(j, n.length === 0 ? 1 : 256); const W = J ? S : ((c - 1) >> 16) + 1; f = new WebAssembly.Memory({ shared: J, initial: S, maximum: W }); } const b = l > 0 ? new WebAssembly.Table({ initial: l, element: "anyfunc" }) : null; u.env = { memory: f }; u.teavmMemory = { linearMemory() { return f.buffer; }, notifyHeapResized: r.onResize ?? function () {}, heapOffset: new WebAssembly.Global({ value: "i32", mutable: false }, i), maxSize: new WebAssembly.Global({ value: "i32", mutable: false }, c), }; const w = { malloc: null, free: null, realloc: null }; await Promise.all( n.map(async ({ name: e, wasmModule: n, jsLoader: t, tableOffset: r, memoryOffset: o }) => { const a = await t({ wasmMemory: f, instantiateWasm(e, t) { e.env = { memory: f, malloc: (e) => w.malloc(e), free: (e) => w.free(e), realloc: (e, t) => w.realloc(e, t), __indirect_function_table: b, __memory_base: new WebAssembly.Global({ value: "i32", mutable: false }, o ?? 0), __table_base: new WebAssembly.Global({ value: "i32", mutable: false }, r ?? 0), __stack_pointer: new WebAssembly.Global({ value: "i32", mutable: true }, p), }; e["GOT.mem"] = { __stack_low: new WebAssembly.Global({ value: "i32", mutable: true }, m), __stack_high: new WebAssembly.Global({ value: "i32", mutable: true }, y), }; WebAssembly.instantiate(n, e).then(t); }, }); const s = {}; for (const { name: l, kind: c } of WebAssembly.Module.exports(n)) { if (c === "function") { const i = a["_" + l]; if (typeof i === "function") { s[l] = i; } } } u[e] = s; }), ); return w; } var c = class { ptr = 0; array; constructor(e) { this.array = e; } readVarInt() { let e = 0; let t = 0; while (true) { const n = this.array[this.ptr++]; e |= (n & 127) << t; if ((n & 128) === 0) { return e; } t += 7; } } }; function C(e) { const t = WebAssembly.Module.customSections(e, "dylink.0"); if (t.length !== 1) { return {}; } const n = new c(new Int8Array(t[0])); const r = {}; while (n.ptr < n.array.length) { const o = n.array[n.ptr++]; const a = n.ptr + n.readVarInt(); switch (o) { case 1: r.memorySize = n.readVarInt(); r.memoryAlignment = n.readVarInt(); r.tableSize = n.readVarInt(); r.tableAlignment = n.readVarInt(); break; } n.ptr = a; } return r; } function i(e, a) { const r = new FinalizationRegistry((e) => { const t = a.exports["teavm.reportGarbageCollectedValue"]; if (typeof t !== "undefined") { t(e.queue, e.ref); } }); const n = new FinalizationRegistry((e) => { const t = a.exports?.["teavm.reportGarbageCollectedString"]; if (typeof t === "function") { t(e); } }); e.teavm = { createWeakRef(e, t, n) { if (n !== null) { r.register(e, { ref: t, queue: n }); } return new WeakRef(e); }, deref: (e) => { const t = e.deref(); return t !== void 0 ? t : null; }, createStringWeakRef(e, t) { n.register(e, t); return new WeakRef(e); }, stringDeref: (e) => e.deref(), takeStackTrace(r) { const e = new Error().stack ?? ""; const t = []; for (const n of e.split("\n")) { const o = s.exec(n); if (o !== null && o.length >= 2) { t.push(parseInt(o[1], 16)); } } return { getStack() { let n; if (a.stackDeobfuscator) { try { n = a.stackDeobfuscator(t); } catch (e) { console.warn("Could not deobfuscate stack", e); } } if (!n) { n = t.map((e) => ({ className: "java.lang.Throwable$FakeClass", method: "fakeMethod", file: "Throwable.java", line: e, })); } else if (r !== null) { if ( n.length > 0 && n[0].className === "java.lang.Throwable" && n[0].method === "fillInStackTrace" ) { n.shift(); } let t = -1; for (let e = 0; e < n.length; ++e) { if (n[e].method !== "") { break; } if (n[e].className === r) { t = e + 1; break; } } if (t >= 0) { n.splice(0, t); } } return n; }, }; }, decorateException(e) { new E(a, e); }, }; } function u(e) { e.teavmAsync = { offer(e, t, n) { const r = Math.max(0, n - Date.now()); return setTimeout(() => { t(e); }, r); }, kill(e) { clearTimeout(e); }, }; } function M(e) { const t = WebAssembly.Module.customSections(e, "teavm.memoryRequirements"); if (t.length !== 1) { return {}; } return JSON.parse(new TextDecoder().decode(t[0])); } function f(t, s, e) { const l = Symbol("javaObject"); const c = Symbol("functions"); const o = Symbol("functionOrigin"); const i = Symbol("wrapperCallMarker"); const a = new WeakMap(); const r = new WeakMap(); const u = new Map(); const f = new FinalizationRegistry((e) => u.delete(e)); const n = new WeakMap(); let p = 2463534242; const m = () => { let e = p; e ^= e << 13; e ^= e >>> 17; e ^= e << 5; p = e; return e; }; function y(e) { return e; } function b(t) { let n = ""; const e = t.charAt(0); n += w(e) ? e : "_"; for (let e = 1; e < t.length; ++e) { const r = t.charAt(e); n += h(r) ? r : "_"; } return n; } function w(e) { return (e >= "A" && e <= "Z") || (e >= "a" && e <= "z") || e === "_" || e === "$"; } function h(e) { return w(e) || (e >= "0" && e <= "9"); } function d(e, t, n) { if (e === null) { O(t, n); } else { e[t] = n; } } function g(t) { if (t instanceof WebAssembly.Exception) { const n = s.exports["teavm.javaException"]; const r = s.exports["teavm.getJsException"]; if (t.is(n)) { const o = t.getArg(n, 0); const a = A(o); if (a !== null) { return a; } let e = r(o); if (typeof e === "undefined") { e = new E(s, o); } return e; } } return t; } function v(e) { if (_ in e) { return e[_]; } else { return s.exports["teavm.js.wrapException"](e); } } function x(e) { s.exports["teavm.js.throwException"](v(e)); throw e; } function A(e) { return s.exports["teavm.js.extractException"](e); } function j(e) { throw g(e); } function J(e, t) { try { return e !== null ? e[t] : D(t); } catch (e) { x(e); } } function S(t, e) { const n = []; const r = []; for (let e = 0; e < t.length; ++e) { const a = "p" + e; n.push(a); r.push(a); } if (e) { const s = r.length - 1; r[s] = "..." + r[s]; } const o = r.join(", "); return new Function( "rethrowJavaAsJs", "fn", `return function(${o}) { try { return fn(${n.join(", ")}); } catch (e) { rethrowJavaAsJs(e); } };`, )(j, t); } function W(e, t) { return new Function( "constructor", `return function ${e}(marker, javaObject) { return constructor.call(this, marker, javaObject); } `, )(t); } t.teavmJso = { stringBuiltinsSupported: () => e, isUndefined: (e) => typeof e === "undefined", emptyArray: () => [], appendToArray: (e, t) => e.push(t), unwrapBoolean: (e) => (e ? 1 : 0), wrapBoolean: (e) => !!e, getProperty: J, setProperty: d, setPropertyPure: d, global(e) { try { return D(e); } catch (e) { x(e); } }, createClass(e, t, r) { e = b(e ?? "JavaObject"); let o; const n = W(e, function e(t, n) { if (t === i) { o.call(this, n); } else if (r === null) { throw new Error("This class can't be instantiated directly"); } else { try { return r.apply(null, arguments); } catch (e) { j(e); } } }); if (t === null) { o = function (e) { this[l] = e; this[c] = null; }; } else { o = function (e) { t.call(this, e); }; } n.prototype = Object.create(t ? t.prototype : Object.prototype); n.prototype.constructor = n; const a = W(e, function (e) { return n.call(this, i, e); }); a[i] = n; a.prototype = n.prototype; return a; }, exportClass(e) { return e[i]; }, defineMethod(e, t, n, r) { const o = []; const a = []; for (let e = 1; e < n.length; ++e) { const l = "p" + e; o.push(l); a.push(l); } if (r) { const c = a.length - 1; a[c] = "..." + a[c]; } const s = a.join(", "); e.prototype[t] = new Function( "rethrowJavaAsJs", "fn", `return function(${s}) { try { return fn(${["this", ...o].join(", ")}); } catch (e) { rethrowJavaAsJs(e); } };`, )(j, n); }, defineStaticMethod(e, t, n, r) { e[t] = S(n, r); }, defineFunction: S, defineProperty(e, t, n, r) { const o = { get() { try { return n(this); } catch (e) { j(e); } }, }; if (r !== null) { o.set = function (e) { try { r(this, e); } catch (e) { j(e); } }; } Object.defineProperty(e.prototype, t, o); }, defineStaticProperty(e, t, n, r) { const o = { get() { try { return n(); } catch (e) { j(e); } }, }; if (r !== null) { o.set = function (e) { try { r(e); } catch (e) { j(e); } }; } Object.defineProperty(e, t, o); }, javaObjectToJS(e, t) { if (e === null) { return null; } const n = a.get(e); if (typeof n != "undefined") { const o = n.deref(); if (typeof o !== "undefined") { return o; } } const r = new t(e); a.set(e, new WeakRef(r)); return r; }, unwrapJavaObject(e) { return e[l]; }, asFunction(e, t) { if (e === null || e === void 0) { return null; } let n = e[c]; if (n === null) { n = Object.create(null); e[c] = n; } let r = n[t]; if (typeof r !== "function") { r = function () { return e[t].apply(e, arguments); }; r[o] = e; n[t] = r; } return r; }, functionAsObject(t, e) { if (t === null || t === void 0) { return null; } const n = t[o]; if (typeof n !== "undefined") { const r = n[c]; if (r !== void 0 && r[e] === t) { return n; } } return { [e]: function (...e) { try { return t(...e); } catch (e) { j(e); } }, }; }, wrapObject(t) { if (t === null) { return null; } if (typeof t === "object" || typeof t === "function" || typeof t === "symbol") { const n = t; let e = n[l]; if (typeof e === "object") { return e; } e = r.get(t)?.deref(); if (e !== void 0) { return e; } e = s.exports["teavm.jso.createWrapper"](t); r.set(t, new WeakRef(e)); return e; } else { let e = u.get(t)?.deref(); if (e !== void 0) { return e; } e = s.exports["teavm.jso.createWrapper"](t); u.set(t, new WeakRef(e)); f.register(e, t); return e; } }, isPrimitive: (e, t) => typeof e === t || e === null, instanceOf: (e, t) => e instanceof t, instanceOfOrNull: (e, t) => e === null || e instanceof t, sameRef: (e, t) => e === t, hashCode: (t) => { if (typeof t === "object" || typeof t === "function" || typeof t === "symbol") { let e = n.get(t); if (typeof e === "number") { return e; } e = m(); n.set(t, e); return e; } else if (typeof t === "number") { return t | 0; } else if (typeof t === "bigint") { return Number(BigInt.asIntN(32, t)); } else if (typeof t === "boolean") { return t ? 1 : 0; } else { return 0; } }, apply: (e, t, n) => { try { if (e === null) { const r = D(t); return r(...n); } else { return e[t](...n); } } catch (e) { x(e); } }, concatArray: (e, t) => [...e, ...t], getJavaException: (e) => e[_], getJSException: (e) => { const t = s.exports["teavm.getJsException"]; return t(e); }, jsExports: () => s.userExports, }; for (const M of [ "wrapByte", "wrapShort", "wrapChar", "wrapInt", "wrapLong", "wrapFloat", "wrapDouble", "unwrapByte", "unwrapShort", "unwrapChar", "unwrapInt", "unwrapLong", "unwrapFloat", "unwrapDouble", ]) { t.teavmJso[M] = y; } function k(e) { try { return e(); } catch (e) { x(e); } } const C = []; for (let e = 0; e < 32; ++e) { const F = C.length === 0 ? "" : C.join(", "); const T = [...C, "body"].join(", "); t.teavmJso["createFunction" + e] = new Function( "wrapCallFromJavaToJs", ...C, "body", `return new Function('wrapCallFromJavaToJs', ${T}).bind(this, wrapCallFromJavaToJs);`, ).bind(null, k); t.teavmJso["bindFunction" + e] = (e, ...t) => e.bind(null, ...t); t.teavmJso["callFunction" + e] = new Function( "rethrowJsAsJava", "fn", ...C, `try { return fn(${F}); } catch (e) { rethrowJsAsJava(e); }`, ).bind(null, x); t.teavmJso["callMethod" + e] = new Function( "rethrowJsAsJava", "getGlobalName", "instance", "method", ...C, `try { return instance !== null ? instance[method](${F}) : getGlobalName(method)(${F}); } catch (e) { rethrowJsAsJava(e); }`, ).bind(null, x, D); t.teavmJso["construct" + e] = new Function( "rethrowJsAsJava", "constructor", ...C, `try { return new constructor(${F}); } catch (e) { rethrowJsAsJava(e); }`, ).bind(null, x); t.teavmJso["arrayOf" + e] = new Function(...C, "return [" + F + "]"); C.push("p" + (e + 1)); } } function e(e) { return new Proxy(e, { get(e, t) { const n = e[t]; return new WebAssembly.Global({ value: "externref", mutable: false }, n); }, }); } async function j(e, o) { const t = []; const n = {}; for (const { module: a, name: r } of p(e)) { if (a in o) { continue; } let e = n[a]; if (e === void 0) { const s = []; e = s; n[a] = e; t.push( (async () => { const e = await import(a); const t = {}; for (const n of s) { const r = n === "__self__" ? e : e[n]; t[n] = new WebAssembly.Global({ value: "externref", mutable: false }, r); } o[a] = t; })(), ); } e.push(r); } if (t.length === 0) { return; } await Promise.all(t); } function p(e) { const t = WebAssembly.Module.customSections(e, "teavm.imports"); if (t.length !== 1) { return WebAssembly.Module.imports(e).filter((e) => e.kind === "global"); } return JSON.parse(new TextDecoder().decode(t[0])); } async function t(e, t) { if (!t) { t = {}; } const n = t.nodejs || typeof process !== "undefined"; const r = t.emscriptenModules ?? {}; const o = t.stackDeobfuscator ?? {}; const a = o.infoLocation ?? "auto"; const s = J(e, n); const [l, c, i, u] = await Promise.all([ o.enabled ? W(e, o, n) : Promise.resolve(null), s, T(e, a, o, n), I(r, n), ]); const f = {}; const p = {}; const m = x(f, p, await S()); const y = await A(f, t, c, u); if (typeof t.installImports !== "undefined") { t.installImports(f); } if (!t.noAutoImports) { await j(c, f); } const b = await WebAssembly.instantiate(c, f); y.malloc = b.exports["teavm.malloc"]; y.free = b.exports["teavm.free"]; y.realloc = b.exports["teavm.realloc"]; m.supplyExports(b.exports); if (l) { const h = a === "auto" || a === "embedded" ? c : null; const d = F(h, i, l); if (d !== null) { m.supplyStackDeobfuscator(d); } } const w = { exports: p, instance: b, module: c }; for (const g in b.exports) { const v = b.exports[g]; if (v instanceof WebAssembly.Global) { Object.defineProperty(p, g, { get: () => v.value }); } } return w; } async function J(e, t) { if (typeof e !== "string") { return await WebAssembly.compile(e, { builtins: ["js-string"] }); } const [n, r] = await m(e, t); const o = await WebAssembly.compileStreaming(n, { builtins: ["js-string"] }); r(); return o; } var r = null; function S() { if (r === null) { r = (async () => { const e = new Int8Array([ 0, 97, 115, 109, 1, 0, 0, 0, 1, 7, 1, 96, 1, 127, 1, 100, 111, 2, 31, 1, 14, 119, 97, 115, 109, 58, 106, 115, 45, 115, 116, 114, 105, 110, 103, 12, 102, 114, 111, 109, 67, 104, 97, 114, 67, 111, 100, 101, 0, 0, 3, 1, 0, 5, 4, 1, 1, 0, 0, 7, 10, 1, 6, 109, 101, 109, 111, 114, 121, 2, 0, 10, -127, -128, -128, 0, 0, ]); try { const t = new Response(e, { headers: { "Content-Type": "application/wasm" } }); const n = await WebAssembly.compileStreaming(t, { builtins: ["js-string"] }); await WebAssembly.instantiate(n, {}); return true; } catch (e) { return false; } })(); } return r; } async function W(e, t, n) { if (typeof e !== "string" && !t.path) { return null; } try { const r = {}; const o = await J(t.path ?? `${e}-deobfuscator.wasm`, n); const a = x(r, {}, await S()); await A(r, {}, o, []); const s = await WebAssembly.instantiate(o, r); a.supplyExports(s.exports); return s; } catch (e) { console.warn("Could not load deobfuscator", e); return null; } } async function m(e, t) { if (!t) { const n = await fetch(e); return [n, () => {}]; } else { const r = await b(); const o = await r.open(e, "r"); const a = await o.readableWebStream(); const n = new Response(a, { headers: { "Content-Type": "application/wasm" } }); return [n, () => o.close()]; } } var y; async function b() { if (!y) { y = import("node:fs/promises"); } return await y; } function F(e, t, n) { let r = null; let o = false; function a() { if (!o) { o = true; if (t !== null) { try { r = n.exports["createFromExternalFile"].value(t); } catch (e) { console.warn("Could not load create deobfuscator", e); } } if (r == null && e !== null) { try { r = n.exports["createForModule"].value(e); } catch (e) { console.warn("Could not create deobfuscator from module data", e); } } } } return (e) => { a(); return r !== null ? r.deobfuscate(e) : []; }; } async function T(e, t, n, r) { if (!n.enabled) { return null; } if (typeof e !== "string" && !n.externalInfoPath) { return null; } if (t !== "auto" && t !== "external") { return null; } if (typeof n.externalInfoPath === "object" && n.externalInfoPath instanceof Int8Array) { return n.externalInfoPath; } const o = n.externalInfoPath ?? e + ".teadbg"; let a; if (!r) { const s = await fetch(o); if (!s.ok) { return null; } a = await s.arrayBuffer(); } else { const l = await b(); a = (await l.readFile(o)).buffer; } return new Int8Array(a); } async function I(e, c) { const t = Object.entries(e); return Promise.all( t.map(async ([e, { pathToJs: t, pathToWasm: n }]) => { const [r, o] = await m(n, c); const [a, s] = await Promise.all([import(t), WebAssembly.compileStreaming(r)]); const l = { name: e, jsLoader: a.default, wasmModule: s }; o(); return l; }), ); } export { x as defaults, t as load, e as wrapImport };