react-three-nurbs
Version:
A React component library for NURBS (Non-Uniform Rational B-Spline) curves, surfaces, and solids in Three.js. Built with React Three Fiber, zero external NURBS dependencies — all math implemented from scratch. Boolean operations powered by OpenCASCADE WAS
1,247 lines (1,246 loc) • 115 kB
JavaScript
var Wo = (() => {
var wr = typeof document < "u" && document.currentScript ? document.currentScript.src : void 0;
return typeof __filename < "u" && (wr = wr || __filename), function(l) {
l = l || {};
var l = typeof l < "u" ? l : {}, me, qr;
l.ready = new Promise(function(r, e) {
me = r, qr = e;
});
var _e = Object.assign({}, l), Xr = "./this.program", ye = typeof window == "object", ar = typeof importScripts == "function", Er = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string", I = "";
function et(r) {
return l.locateFile ? l.locateFile(r, I) : I + r;
}
var lr, cr, br, Pr, kr, Kr;
Er ? (ar ? I = require("path").dirname(I) + "/" : I = __dirname + "/", Kr = () => {
kr || (Pr = require("fs"), kr = require("path"));
}, lr = function(e, t) {
return Kr(), e = kr.normalize(e), Pr.readFileSync(e, t ? void 0 : "utf8");
}, br = (r) => {
var e = lr(r, !0);
return e.buffer || (e = new Uint8Array(e)), e;
}, cr = (r, e, t) => {
Kr(), r = kr.normalize(r), Pr.readFile(r, function(n, o) {
n ? t(n) : e(o.buffer);
});
}, process.argv.length > 1 && (Xr = process.argv[1].replace(/\\/g, "/")), process.argv.slice(2), process.on("uncaughtException", function(r) {
if (!(r instanceof Uo))
throw r;
}), process.on("unhandledRejection", function(r) {
throw r;
}), l.inspect = function() {
return "[Emscripten Module object]";
}) : (ye || ar) && (ar ? I = self.location.href : typeof document < "u" && document.currentScript && (I = document.currentScript.src), wr && (I = wr), I.indexOf("blob:") !== 0 ? I = I.substr(0, I.replace(/[?#].*/, "").lastIndexOf("/") + 1) : I = "", lr = (r) => {
var e = new XMLHttpRequest();
return e.open("GET", r, !1), e.send(null), e.responseText;
}, ar && (br = (r) => {
var e = new XMLHttpRequest();
return e.open("GET", r, !1), e.responseType = "arraybuffer", e.send(null), new Uint8Array(e.response);
}), cr = (r, e, t) => {
var n = new XMLHttpRequest();
n.open("GET", r, !0), n.responseType = "arraybuffer", n.onload = () => {
if (n.status == 200 || n.status == 0 && n.response) {
e(n.response);
return;
}
t();
}, n.onerror = t, n.send(null);
});
var Sr = l.print || console.log.bind(console), K = l.printErr || console.warn.bind(console);
Object.assign(l, _e), _e = null, l.arguments && l.arguments, l.thisProgram && (Xr = l.thisProgram), l.quit && l.quit;
var tt = 4, dr;
l.wasmBinary && (dr = l.wasmBinary), l.noExitRuntime, typeof WebAssembly != "object" && Q("no native wasm support detected");
var Ar, ge = !1;
function we(r, e) {
r || Q(e);
}
var Ee = typeof TextDecoder < "u" ? new TextDecoder("utf8") : void 0;
function sr(r, e, t) {
for (var n = e + t, o = e; r[o] && !(o >= n); ) ++o;
if (o - e > 16 && r.buffer && Ee)
return Ee.decode(r.subarray(e, o));
for (var a = ""; e < o; ) {
var s = r[e++];
if (!(s & 128)) {
a += String.fromCharCode(s);
continue;
}
var u = r[e++] & 63;
if ((s & 224) == 192) {
a += String.fromCharCode((s & 31) << 6 | u);
continue;
}
var f = r[e++] & 63;
if ((s & 240) == 224 ? s = (s & 15) << 12 | u << 6 | f : s = (s & 7) << 18 | u << 12 | f << 6 | r[e++] & 63, s < 65536)
a += String.fromCharCode(s);
else {
var c = s - 65536;
a += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
}
}
return a;
}
function z(r, e) {
return r ? sr(x, r, e) : "";
}
function Jr(r, e, t, n) {
if (!(n > 0)) return 0;
for (var o = t, a = t + n - 1, s = 0; s < r.length; ++s) {
var u = r.charCodeAt(s);
if (u >= 55296 && u <= 57343) {
var f = r.charCodeAt(++s);
u = 65536 + ((u & 1023) << 10) | f & 1023;
}
if (u <= 127) {
if (t >= a) break;
e[t++] = u;
} else if (u <= 2047) {
if (t + 1 >= a) break;
e[t++] = 192 | u >> 6, e[t++] = 128 | u & 63;
} else if (u <= 65535) {
if (t + 2 >= a) break;
e[t++] = 224 | u >> 12, e[t++] = 128 | u >> 6 & 63, e[t++] = 128 | u & 63;
} else {
if (t + 3 >= a) break;
e[t++] = 240 | u >> 18, e[t++] = 128 | u >> 12 & 63, e[t++] = 128 | u >> 6 & 63, e[t++] = 128 | u & 63;
}
}
return e[t] = 0, t - o;
}
function nt(r, e, t) {
return Jr(r, x, e, t);
}
function Qr(r) {
for (var e = 0, t = 0; t < r.length; ++t) {
var n = r.charCodeAt(t);
n >= 55296 && n <= 57343 && (n = 65536 + ((n & 1023) << 10) | r.charCodeAt(++t) & 1023), n <= 127 ? ++e : n <= 2047 ? e += 2 : n <= 65535 ? e += 3 : e += 4;
}
return e;
}
var be = typeof TextDecoder < "u" ? new TextDecoder("utf-16le") : void 0;
function ot(r, e) {
for (var t = r, n = t >> 1, o = n + e / 2; !(n >= o) && vr[n]; ) ++n;
if (t = n << 1, t - r > 32 && be)
return be.decode(x.subarray(r, t));
for (var a = "", s = 0; !(s >= e / 2); ++s) {
var u = J[r + s * 2 >> 1];
if (u == 0) break;
a += String.fromCharCode(u);
}
return a;
}
function it(r, e, t) {
if (t === void 0 && (t = 2147483647), t < 2) return 0;
t -= 2;
for (var n = e, o = t < r.length * 2 ? t / 2 : r.length, a = 0; a < o; ++a) {
var s = r.charCodeAt(a);
J[e >> 1] = s, e += 2;
}
return J[e >> 1] = 0, e - n;
}
function at(r) {
return r.length * 2;
}
function st(r, e) {
for (var t = 0, n = ""; !(t >= e / 4); ) {
var o = _[r + t * 4 >> 2];
if (o == 0) break;
if (++t, o >= 65536) {
var a = o - 65536;
n += String.fromCharCode(55296 | a >> 10, 56320 | a & 1023);
} else
n += String.fromCharCode(o);
}
return n;
}
function ut(r, e, t) {
if (t === void 0 && (t = 2147483647), t < 4) return 0;
for (var n = e, o = n + t - 4, a = 0; a < r.length; ++a) {
var s = r.charCodeAt(a);
if (s >= 55296 && s <= 57343) {
var u = r.charCodeAt(++a);
s = 65536 + ((s & 1023) << 10) | u & 1023;
}
if (_[e >> 2] = s, e += 4, e + 4 > o) break;
}
return _[e >> 2] = 0, e - n;
}
function ft(r) {
for (var e = 0, t = 0; t < r.length; ++t) {
var n = r.charCodeAt(t);
n >= 55296 && n <= 57343 && ++t, e += 4;
}
return e;
}
function lt(r, e) {
$.set(r, e);
}
function ct(r, e, t) {
for (var n = 0; n < r.length; ++n)
$[e++ >> 0] = r.charCodeAt(n);
$[e >> 0] = 0;
}
var Tr, $, x, J, vr, _, S, W, Pe;
function ke(r) {
Tr = r, l.HEAP8 = $ = new Int8Array(r), l.HEAP16 = J = new Int16Array(r), l.HEAP32 = _ = new Int32Array(r), l.HEAPU8 = x = new Uint8Array(r), l.HEAPU16 = vr = new Uint16Array(r), l.HEAPU32 = S = new Uint32Array(r), l.HEAPF32 = W = new Float32Array(r), l.HEAPF64 = Pe = new Float64Array(r);
}
l.INITIAL_MEMORY;
var Se, Ae = [], Te = [], De = [];
function dt() {
if (l.preRun)
for (typeof l.preRun == "function" && (l.preRun = [l.preRun]); l.preRun.length; )
ht(l.preRun.shift());
re(Ae);
}
function vt() {
!l.noFSInit && !i.init.initialized && i.init(), i.ignorePermissions = !1, re(Te);
}
function pt() {
if (l.postRun)
for (typeof l.postRun == "function" && (l.postRun = [l.postRun]); l.postRun.length; )
_t(l.postRun.shift());
re(De);
}
function ht(r) {
Ae.unshift(r);
}
function mt(r) {
Te.unshift(r);
}
function _t(r) {
De.unshift(r);
}
var er = 0, pr = null;
function Io(r) {
return r;
}
function Zr(r) {
er++, l.monitorRunDependencies && l.monitorRunDependencies(er);
}
function Dr(r) {
if (er--, l.monitorRunDependencies && l.monitorRunDependencies(er), er == 0 && pr) {
var e = pr;
pr = null, e();
}
}
function Q(r) {
l.onAbort && l.onAbort(r), r = "Aborted(" + r + ")", K(r), ge = !0, r += ". Build with -sASSERTIONS for more info.";
var e = new WebAssembly.RuntimeError(r);
throw qr(e), e;
}
var yt = "data:application/octet-stream;base64,";
function Fe(r) {
return r.startsWith(yt);
}
function Ce(r) {
return r.startsWith("file://");
}
var B;
B = "occtBooleans.wasm", Fe(B) || (B = et(B));
function Re(r) {
try {
if (r == B && dr)
return new Uint8Array(dr);
if (br)
return br(r);
throw "both async and sync fetching of the wasm failed";
} catch (e) {
Q(e);
}
}
function gt() {
if (!dr && (ye || ar)) {
if (typeof fetch == "function" && !Ce(B))
return fetch(B, { credentials: "same-origin" }).then(function(r) {
if (!r.ok)
throw "failed to load wasm binary file at '" + B + "'";
return r.arrayBuffer();
}).catch(function() {
return Re(B);
});
if (cr)
return new Promise(function(r, e) {
cr(B, function(t) {
r(new Uint8Array(t));
}, e);
});
}
return Promise.resolve().then(function() {
return Re(B);
});
}
function wt() {
var r = { a: Bo };
function e(s, u) {
var f = s.exports;
l.asm = f, Ar = l.asm.ha, ke(Ar.buffer), Se = l.asm.oa, mt(l.asm.ia), Dr();
}
Zr();
function t(s) {
e(s.instance);
}
function n(s) {
return gt().then(function(u) {
return WebAssembly.instantiate(u, r);
}).then(function(u) {
return u;
}).then(s, function(u) {
K("failed to asynchronously prepare wasm: " + u), Q(u);
});
}
function o() {
return !dr && typeof WebAssembly.instantiateStreaming == "function" && !Fe(B) && !Ce(B) && !Er && typeof fetch == "function" ? fetch(B, { credentials: "same-origin" }).then(function(s) {
var u = WebAssembly.instantiateStreaming(s, r);
return u.then(t, function(f) {
return K("wasm streaming compile failed: " + f), K("falling back to ArrayBuffer instantiation"), n(t);
});
}) : n(t);
}
if (l.instantiateWasm)
try {
var a = l.instantiateWasm(r, e);
return a;
} catch (s) {
return K("Module.instantiateWasm callback failed with error: " + s), !1;
}
return o().catch(qr), {};
}
var O, V;
function Et() {
return l.HEAP8.length;
}
function re(r) {
for (; r.length > 0; ) {
var e = r.shift();
if (typeof e == "function") {
e(l);
continue;
}
var t = e.func;
typeof t == "number" ? e.arg === void 0 ? Cr(t)() : Cr(t)(e.arg) : t(e.arg === void 0 ? null : e.arg);
}
}
var Fr = [];
function Cr(r) {
var e = Fr[r];
return e || (r >= Fr.length && (Fr.length = r + 1), Fr[r] = e = Se.get(r)), e;
}
function bt(r, e, t, n) {
Q("Assertion failed: " + z(r) + ", at: " + [e ? z(e) : "unknown filename", t, n ? z(n) : "unknown function"]);
}
function Pt(r) {
return Gr(r + 24) + 24;
}
function kt(r) {
this.excPtr = r, this.ptr = r - 24, this.set_type = function(e) {
S[this.ptr + 4 >> 2] = e;
}, this.get_type = function() {
return S[this.ptr + 4 >> 2];
}, this.set_destructor = function(e) {
S[this.ptr + 8 >> 2] = e;
}, this.get_destructor = function() {
return S[this.ptr + 8 >> 2];
}, this.set_refcount = function(e) {
_[this.ptr >> 2] = e;
}, this.set_caught = function(e) {
e = e ? 1 : 0, $[this.ptr + 12 >> 0] = e;
}, this.get_caught = function() {
return $[this.ptr + 12 >> 0] != 0;
}, this.set_rethrown = function(e) {
e = e ? 1 : 0, $[this.ptr + 13 >> 0] = e;
}, this.get_rethrown = function() {
return $[this.ptr + 13 >> 0] != 0;
}, this.init = function(e, t) {
this.set_adjusted_ptr(0), this.set_type(e), this.set_destructor(t), this.set_refcount(0), this.set_caught(!1), this.set_rethrown(!1);
}, this.add_ref = function() {
var e = _[this.ptr >> 2];
_[this.ptr >> 2] = e + 1;
}, this.release_ref = function() {
var e = _[this.ptr >> 2];
return _[this.ptr >> 2] = e - 1, e === 1;
}, this.set_adjusted_ptr = function(e) {
S[this.ptr + 16 >> 2] = e;
}, this.get_adjusted_ptr = function() {
return S[this.ptr + 16 >> 2];
}, this.get_exception_ptr = function() {
var e = rt(this.get_type());
if (e)
return S[this.excPtr >> 2];
var t = this.get_adjusted_ptr();
return t !== 0 ? t : this.excPtr;
};
}
function St(r, e, t) {
var n = new kt(r);
throw n.init(e, t), r;
}
var E = { isAbs: (r) => r.charAt(0) === "/", splitPath: (r) => {
var e = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
return e.exec(r).slice(1);
}, normalizeArray: (r, e) => {
for (var t = 0, n = r.length - 1; n >= 0; n--) {
var o = r[n];
o === "." ? r.splice(n, 1) : o === ".." ? (r.splice(n, 1), t++) : t && (r.splice(n, 1), t--);
}
if (e)
for (; t; t--)
r.unshift("..");
return r;
}, normalize: (r) => {
var e = E.isAbs(r), t = r.substr(-1) === "/";
return r = E.normalizeArray(r.split("/").filter((n) => !!n), !e).join("/"), !r && !e && (r = "."), r && t && (r += "/"), (e ? "/" : "") + r;
}, dirname: (r) => {
var e = E.splitPath(r), t = e[0], n = e[1];
return !t && !n ? "." : (n && (n = n.substr(0, n.length - 1)), t + n);
}, basename: (r) => {
if (r === "/") return "/";
r = E.normalize(r), r = r.replace(/\/$/, "");
var e = r.lastIndexOf("/");
return e === -1 ? r : r.substr(e + 1);
}, join: function() {
var r = Array.prototype.slice.call(arguments, 0);
return E.normalize(r.join("/"));
}, join2: (r, e) => E.normalize(r + "/" + e) };
function At() {
if (typeof crypto == "object" && typeof crypto.getRandomValues == "function") {
var r = new Uint8Array(1);
return function() {
return crypto.getRandomValues(r), r[0];
};
} else if (Er)
try {
var e = require("crypto");
return function() {
return e.randomBytes(1)[0];
};
} catch {
}
return function() {
Q("randomDevice");
};
}
var G = { resolve: function() {
for (var r = "", e = !1, t = arguments.length - 1; t >= -1 && !e; t--) {
var n = t >= 0 ? arguments[t] : i.cwd();
if (typeof n != "string")
throw new TypeError("Arguments to path.resolve must be strings");
if (!n)
return "";
r = n + "/" + r, e = E.isAbs(n);
}
return r = E.normalizeArray(r.split("/").filter((o) => !!o), !e).join("/"), (e ? "/" : "") + r || ".";
}, relative: (r, e) => {
r = G.resolve(r).substr(1), e = G.resolve(e).substr(1);
function t(c) {
for (var p = 0; p < c.length && c[p] === ""; p++)
;
for (var h = c.length - 1; h >= 0 && c[h] === ""; h--)
;
return p > h ? [] : c.slice(p, h - p + 1);
}
for (var n = t(r.split("/")), o = t(e.split("/")), a = Math.min(n.length, o.length), s = a, u = 0; u < a; u++)
if (n[u] !== o[u]) {
s = u;
break;
}
for (var f = [], u = s; u < n.length; u++)
f.push("..");
return f = f.concat(o.slice(s)), f.join("/");
} }, tr = { ttys: [], init: function() {
}, shutdown: function() {
}, register: function(r, e) {
tr.ttys[r] = { input: [], output: [], ops: e }, i.registerDevice(r, tr.stream_ops);
}, stream_ops: { open: function(r) {
var e = tr.ttys[r.node.rdev];
if (!e)
throw new i.ErrnoError(43);
r.tty = e, r.seekable = !1;
}, close: function(r) {
r.tty.ops.flush(r.tty);
}, flush: function(r) {
r.tty.ops.flush(r.tty);
}, read: function(r, e, t, n, o) {
if (!r.tty || !r.tty.ops.get_char)
throw new i.ErrnoError(60);
for (var a = 0, s = 0; s < n; s++) {
var u;
try {
u = r.tty.ops.get_char(r.tty);
} catch {
throw new i.ErrnoError(29);
}
if (u === void 0 && a === 0)
throw new i.ErrnoError(6);
if (u == null) break;
a++, e[t + s] = u;
}
return a && (r.node.timestamp = Date.now()), a;
}, write: function(r, e, t, n, o) {
if (!r.tty || !r.tty.ops.put_char)
throw new i.ErrnoError(60);
try {
for (var a = 0; a < n; a++)
r.tty.ops.put_char(r.tty, e[t + a]);
} catch {
throw new i.ErrnoError(29);
}
return n && (r.node.timestamp = Date.now()), a;
} }, default_tty_ops: { get_char: function(r) {
if (!r.input.length) {
var e = null;
if (Er) {
var t = 256, n = Buffer.alloc(t), o = 0;
try {
o = Pr.readSync(process.stdin.fd, n, 0, t, -1);
} catch (a) {
if (a.toString().includes("EOF")) o = 0;
else throw a;
}
o > 0 ? e = n.slice(0, o).toString("utf-8") : e = null;
} else typeof window < "u" && typeof window.prompt == "function" ? (e = window.prompt("Input: "), e !== null && (e += `
`)) : typeof readline == "function" && (e = readline(), e !== null && (e += `
`));
if (!e)
return null;
r.input = Vr(e, !0);
}
return r.input.shift();
}, put_char: function(r, e) {
e === null || e === 10 ? (Sr(sr(r.output, 0)), r.output = []) : e != 0 && r.output.push(e);
}, flush: function(r) {
r.output && r.output.length > 0 && (Sr(sr(r.output, 0)), r.output = []);
} }, default_tty1_ops: { put_char: function(r, e) {
e === null || e === 10 ? (K(sr(r.output, 0)), r.output = []) : e != 0 && r.output.push(e);
}, flush: function(r) {
r.output && r.output.length > 0 && (K(sr(r.output, 0)), r.output = []);
} } };
function Tt(r, e) {
x.fill(0, r, r + e);
}
function Dt(r, e) {
return Math.ceil(r / e) * e;
}
function Me(r) {
r = Dt(r, 65536);
var e = Ze(65536, r);
return e ? (Tt(e, r), e) : 0;
}
var w = { ops_table: null, mount: function(r) {
return w.createNode(null, "/", 16895, 0);
}, createNode: function(r, e, t, n) {
if (i.isBlkdev(t) || i.isFIFO(t))
throw new i.ErrnoError(63);
w.ops_table || (w.ops_table = { dir: { node: { getattr: w.node_ops.getattr, setattr: w.node_ops.setattr, lookup: w.node_ops.lookup, mknod: w.node_ops.mknod, rename: w.node_ops.rename, unlink: w.node_ops.unlink, rmdir: w.node_ops.rmdir, readdir: w.node_ops.readdir, symlink: w.node_ops.symlink }, stream: { llseek: w.stream_ops.llseek } }, file: { node: { getattr: w.node_ops.getattr, setattr: w.node_ops.setattr }, stream: { llseek: w.stream_ops.llseek, read: w.stream_ops.read, write: w.stream_ops.write, allocate: w.stream_ops.allocate, mmap: w.stream_ops.mmap, msync: w.stream_ops.msync } }, link: { node: { getattr: w.node_ops.getattr, setattr: w.node_ops.setattr, readlink: w.node_ops.readlink }, stream: {} }, chrdev: { node: { getattr: w.node_ops.getattr, setattr: w.node_ops.setattr }, stream: i.chrdev_stream_ops } });
var o = i.createNode(r, e, t, n);
return i.isDir(o.mode) ? (o.node_ops = w.ops_table.dir.node, o.stream_ops = w.ops_table.dir.stream, o.contents = {}) : i.isFile(o.mode) ? (o.node_ops = w.ops_table.file.node, o.stream_ops = w.ops_table.file.stream, o.usedBytes = 0, o.contents = null) : i.isLink(o.mode) ? (o.node_ops = w.ops_table.link.node, o.stream_ops = w.ops_table.link.stream) : i.isChrdev(o.mode) && (o.node_ops = w.ops_table.chrdev.node, o.stream_ops = w.ops_table.chrdev.stream), o.timestamp = Date.now(), r && (r.contents[e] = o, r.timestamp = o.timestamp), o;
}, getFileDataAsTypedArray: function(r) {
return r.contents ? r.contents.subarray ? r.contents.subarray(0, r.usedBytes) : new Uint8Array(r.contents) : new Uint8Array(0);
}, expandFileStorage: function(r, e) {
var t = r.contents ? r.contents.length : 0;
if (!(t >= e)) {
var n = 1024 * 1024;
e = Math.max(e, t * (t < n ? 2 : 1.125) >>> 0), t != 0 && (e = Math.max(e, 256));
var o = r.contents;
r.contents = new Uint8Array(e), r.usedBytes > 0 && r.contents.set(o.subarray(0, r.usedBytes), 0);
}
}, resizeFileStorage: function(r, e) {
if (r.usedBytes != e)
if (e == 0)
r.contents = null, r.usedBytes = 0;
else {
var t = r.contents;
r.contents = new Uint8Array(e), t && r.contents.set(t.subarray(0, Math.min(e, r.usedBytes))), r.usedBytes = e;
}
}, node_ops: { getattr: function(r) {
var e = {};
return e.dev = i.isChrdev(r.mode) ? r.id : 1, e.ino = r.id, e.mode = r.mode, e.nlink = 1, e.uid = 0, e.gid = 0, e.rdev = r.rdev, i.isDir(r.mode) ? e.size = 4096 : i.isFile(r.mode) ? e.size = r.usedBytes : i.isLink(r.mode) ? e.size = r.link.length : e.size = 0, e.atime = new Date(r.timestamp), e.mtime = new Date(r.timestamp), e.ctime = new Date(r.timestamp), e.blksize = 4096, e.blocks = Math.ceil(e.size / e.blksize), e;
}, setattr: function(r, e) {
e.mode !== void 0 && (r.mode = e.mode), e.timestamp !== void 0 && (r.timestamp = e.timestamp), e.size !== void 0 && w.resizeFileStorage(r, e.size);
}, lookup: function(r, e) {
throw i.genericErrors[44];
}, mknod: function(r, e, t, n) {
return w.createNode(r, e, t, n);
}, rename: function(r, e, t) {
if (i.isDir(r.mode)) {
var n;
try {
n = i.lookupNode(e, t);
} catch {
}
if (n)
for (var o in n.contents)
throw new i.ErrnoError(55);
}
delete r.parent.contents[r.name], r.parent.timestamp = Date.now(), r.name = t, e.contents[t] = r, e.timestamp = r.parent.timestamp, r.parent = e;
}, unlink: function(r, e) {
delete r.contents[e], r.timestamp = Date.now();
}, rmdir: function(r, e) {
var t = i.lookupNode(r, e);
for (var n in t.contents)
throw new i.ErrnoError(55);
delete r.contents[e], r.timestamp = Date.now();
}, readdir: function(r) {
var e = [".", ".."];
for (var t in r.contents)
r.contents.hasOwnProperty(t) && e.push(t);
return e;
}, symlink: function(r, e, t) {
var n = w.createNode(r, e, 41471, 0);
return n.link = t, n;
}, readlink: function(r) {
if (!i.isLink(r.mode))
throw new i.ErrnoError(28);
return r.link;
} }, stream_ops: { read: function(r, e, t, n, o) {
var a = r.node.contents;
if (o >= r.node.usedBytes) return 0;
var s = Math.min(r.node.usedBytes - o, n);
if (s > 8 && a.subarray)
e.set(a.subarray(o, o + s), t);
else
for (var u = 0; u < s; u++) e[t + u] = a[o + u];
return s;
}, write: function(r, e, t, n, o, a) {
if (e.buffer === $.buffer && (a = !1), !n) return 0;
var s = r.node;
if (s.timestamp = Date.now(), e.subarray && (!s.contents || s.contents.subarray)) {
if (a)
return s.contents = e.subarray(t, t + n), s.usedBytes = n, n;
if (s.usedBytes === 0 && o === 0)
return s.contents = e.slice(t, t + n), s.usedBytes = n, n;
if (o + n <= s.usedBytes)
return s.contents.set(e.subarray(t, t + n), o), n;
}
if (w.expandFileStorage(s, o + n), s.contents.subarray && e.subarray)
s.contents.set(e.subarray(t, t + n), o);
else
for (var u = 0; u < n; u++)
s.contents[o + u] = e[t + u];
return s.usedBytes = Math.max(s.usedBytes, o + n), n;
}, llseek: function(r, e, t) {
var n = e;
if (t === 1 ? n += r.position : t === 2 && i.isFile(r.node.mode) && (n += r.node.usedBytes), n < 0)
throw new i.ErrnoError(28);
return n;
}, allocate: function(r, e, t) {
w.expandFileStorage(r.node, e + t), r.node.usedBytes = Math.max(r.node.usedBytes, e + t);
}, mmap: function(r, e, t, n, o) {
if (!i.isFile(r.node.mode))
throw new i.ErrnoError(43);
var a, s, u = r.node.contents;
if (!(o & 2) && u.buffer === Tr)
s = !1, a = u.byteOffset;
else {
if ((t > 0 || t + e < u.length) && (u.subarray ? u = u.subarray(t, t + e) : u = Array.prototype.slice.call(u, t, t + e)), s = !0, a = Me(e), !a)
throw new i.ErrnoError(48);
$.set(u, a);
}
return { ptr: a, allocated: s };
}, msync: function(r, e, t, n, o) {
if (!i.isFile(r.node.mode))
throw new i.ErrnoError(43);
return o & 2 || w.stream_ops.write(r, e, 0, n, t, !1), 0;
} } };
function Ft(r, e, t, n) {
var o = "al " + r;
cr(r, function(a) {
we(a, 'Loading data file "' + r + '" failed (no arrayBuffer).'), e(new Uint8Array(a)), o && Dr();
}, function(a) {
if (t)
t();
else
throw 'Loading data file "' + r + '" failed.';
}), o && Zr();
}
var i = { root: null, mounts: [], devices: {}, streams: [], nextInode: 1, nameTable: null, currentPath: "/", initialized: !1, ignorePermissions: !0, ErrnoError: null, genericErrors: {}, filesystems: null, syncFSRequests: 0, lookupPath: (r, e = {}) => {
if (r = G.resolve(i.cwd(), r), !r) return { path: "", node: null };
var t = { follow_mount: !0, recurse_count: 0 };
if (e = Object.assign(t, e), e.recurse_count > 8)
throw new i.ErrnoError(32);
for (var n = E.normalizeArray(r.split("/").filter((h) => !!h), !1), o = i.root, a = "/", s = 0; s < n.length; s++) {
var u = s === n.length - 1;
if (u && e.parent)
break;
if (o = i.lookupNode(o, n[s]), a = E.join2(a, n[s]), i.isMountpoint(o) && (!u || u && e.follow_mount) && (o = o.mounted.root), !u || e.follow)
for (var f = 0; i.isLink(o.mode); ) {
var c = i.readlink(a);
a = G.resolve(E.dirname(a), c);
var p = i.lookupPath(a, { recurse_count: e.recurse_count + 1 });
if (o = p.node, f++ > 40)
throw new i.ErrnoError(32);
}
}
return { path: a, node: o };
}, getPath: (r) => {
for (var e; ; ) {
if (i.isRoot(r)) {
var t = r.mount.mountpoint;
return e ? t[t.length - 1] !== "/" ? t + "/" + e : t + e : t;
}
e = e ? r.name + "/" + e : r.name, r = r.parent;
}
}, hashName: (r, e) => {
for (var t = 0, n = 0; n < e.length; n++)
t = (t << 5) - t + e.charCodeAt(n) | 0;
return (r + t >>> 0) % i.nameTable.length;
}, hashAddNode: (r) => {
var e = i.hashName(r.parent.id, r.name);
r.name_next = i.nameTable[e], i.nameTable[e] = r;
}, hashRemoveNode: (r) => {
var e = i.hashName(r.parent.id, r.name);
if (i.nameTable[e] === r)
i.nameTable[e] = r.name_next;
else
for (var t = i.nameTable[e]; t; ) {
if (t.name_next === r) {
t.name_next = r.name_next;
break;
}
t = t.name_next;
}
}, lookupNode: (r, e) => {
var t = i.mayLookup(r);
if (t)
throw new i.ErrnoError(t, r);
for (var n = i.hashName(r.id, e), o = i.nameTable[n]; o; o = o.name_next) {
var a = o.name;
if (o.parent.id === r.id && a === e)
return o;
}
return i.lookup(r, e);
}, createNode: (r, e, t, n) => {
var o = new i.FSNode(r, e, t, n);
return i.hashAddNode(o), o;
}, destroyNode: (r) => {
i.hashRemoveNode(r);
}, isRoot: (r) => r === r.parent, isMountpoint: (r) => !!r.mounted, isFile: (r) => (r & 61440) === 32768, isDir: (r) => (r & 61440) === 16384, isLink: (r) => (r & 61440) === 40960, isChrdev: (r) => (r & 61440) === 8192, isBlkdev: (r) => (r & 61440) === 24576, isFIFO: (r) => (r & 61440) === 4096, isSocket: (r) => (r & 49152) === 49152, flagModes: { r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090 }, modeStringToFlags: (r) => {
var e = i.flagModes[r];
if (typeof e > "u")
throw new Error("Unknown file open mode: " + r);
return e;
}, flagsToPermissionString: (r) => {
var e = ["r", "w", "rw"][r & 3];
return r & 512 && (e += "w"), e;
}, nodePermissions: (r, e) => i.ignorePermissions ? 0 : e.includes("r") && !(r.mode & 292) || e.includes("w") && !(r.mode & 146) || e.includes("x") && !(r.mode & 73) ? 2 : 0, mayLookup: (r) => {
var e = i.nodePermissions(r, "x");
return e || (r.node_ops.lookup ? 0 : 2);
}, mayCreate: (r, e) => {
try {
var t = i.lookupNode(r, e);
return 20;
} catch {
}
return i.nodePermissions(r, "wx");
}, mayDelete: (r, e, t) => {
var n;
try {
n = i.lookupNode(r, e);
} catch (a) {
return a.errno;
}
var o = i.nodePermissions(r, "wx");
if (o)
return o;
if (t) {
if (!i.isDir(n.mode))
return 54;
if (i.isRoot(n) || i.getPath(n) === i.cwd())
return 10;
} else if (i.isDir(n.mode))
return 31;
return 0;
}, mayOpen: (r, e) => r ? i.isLink(r.mode) ? 32 : i.isDir(r.mode) && (i.flagsToPermissionString(e) !== "r" || e & 512) ? 31 : i.nodePermissions(r, i.flagsToPermissionString(e)) : 44, MAX_OPEN_FDS: 4096, nextfd: (r = 0, e = i.MAX_OPEN_FDS) => {
for (var t = r; t <= e; t++)
if (!i.streams[t])
return t;
throw new i.ErrnoError(33);
}, getStream: (r) => i.streams[r], createStream: (r, e, t) => {
i.FSStream || (i.FSStream = function() {
this.shared = {};
}, i.FSStream.prototype = {}, Object.defineProperties(i.FSStream.prototype, { object: { get: function() {
return this.node;
}, set: function(o) {
this.node = o;
} }, isRead: { get: function() {
return (this.flags & 2097155) !== 1;
} }, isWrite: { get: function() {
return (this.flags & 2097155) !== 0;
} }, isAppend: { get: function() {
return this.flags & 1024;
} }, flags: { get: function() {
return this.shared.flags;
}, set: function(o) {
this.shared.flags = o;
} }, position: { get: function() {
return this.shared.position;
}, set: function(o) {
this.shared.position = o;
} } })), r = Object.assign(new i.FSStream(), r);
var n = i.nextfd(e, t);
return r.fd = n, i.streams[n] = r, r;
}, closeStream: (r) => {
i.streams[r] = null;
}, chrdev_stream_ops: { open: (r) => {
var e = i.getDevice(r.node.rdev);
r.stream_ops = e.stream_ops, r.stream_ops.open && r.stream_ops.open(r);
}, llseek: () => {
throw new i.ErrnoError(70);
} }, major: (r) => r >> 8, minor: (r) => r & 255, makedev: (r, e) => r << 8 | e, registerDevice: (r, e) => {
i.devices[r] = { stream_ops: e };
}, getDevice: (r) => i.devices[r], getMounts: (r) => {
for (var e = [], t = [r]; t.length; ) {
var n = t.pop();
e.push(n), t.push.apply(t, n.mounts);
}
return e;
}, syncfs: (r, e) => {
typeof r == "function" && (e = r, r = !1), i.syncFSRequests++, i.syncFSRequests > 1 && K("warning: " + i.syncFSRequests + " FS.syncfs operations in flight at once, probably just doing extra work");
var t = i.getMounts(i.root.mount), n = 0;
function o(s) {
return i.syncFSRequests--, e(s);
}
function a(s) {
if (s)
return a.errored ? void 0 : (a.errored = !0, o(s));
++n >= t.length && o(null);
}
t.forEach((s) => {
if (!s.type.syncfs)
return a(null);
s.type.syncfs(s, r, a);
});
}, mount: (r, e, t) => {
var n = t === "/", o = !t, a;
if (n && i.root)
throw new i.ErrnoError(10);
if (!n && !o) {
var s = i.lookupPath(t, { follow_mount: !1 });
if (t = s.path, a = s.node, i.isMountpoint(a))
throw new i.ErrnoError(10);
if (!i.isDir(a.mode))
throw new i.ErrnoError(54);
}
var u = { type: r, opts: e, mountpoint: t, mounts: [] }, f = r.mount(u);
return f.mount = u, u.root = f, n ? i.root = f : a && (a.mounted = u, a.mount && a.mount.mounts.push(u)), f;
}, unmount: (r) => {
var e = i.lookupPath(r, { follow_mount: !1 });
if (!i.isMountpoint(e.node))
throw new i.ErrnoError(28);
var t = e.node, n = t.mounted, o = i.getMounts(n);
Object.keys(i.nameTable).forEach((s) => {
for (var u = i.nameTable[s]; u; ) {
var f = u.name_next;
o.includes(u.mount) && i.destroyNode(u), u = f;
}
}), t.mounted = null;
var a = t.mount.mounts.indexOf(n);
t.mount.mounts.splice(a, 1);
}, lookup: (r, e) => r.node_ops.lookup(r, e), mknod: (r, e, t) => {
var n = i.lookupPath(r, { parent: !0 }), o = n.node, a = E.basename(r);
if (!a || a === "." || a === "..")
throw new i.ErrnoError(28);
var s = i.mayCreate(o, a);
if (s)
throw new i.ErrnoError(s);
if (!o.node_ops.mknod)
throw new i.ErrnoError(63);
return o.node_ops.mknod(o, a, e, t);
}, create: (r, e) => (e = e !== void 0 ? e : 438, e &= 4095, e |= 32768, i.mknod(r, e, 0)), mkdir: (r, e) => (e = e !== void 0 ? e : 511, e &= 1023, e |= 16384, i.mknod(r, e, 0)), mkdirTree: (r, e) => {
for (var t = r.split("/"), n = "", o = 0; o < t.length; ++o)
if (t[o]) {
n += "/" + t[o];
try {
i.mkdir(n, e);
} catch (a) {
if (a.errno != 20) throw a;
}
}
}, mkdev: (r, e, t) => (typeof t > "u" && (t = e, e = 438), e |= 8192, i.mknod(r, e, t)), symlink: (r, e) => {
if (!G.resolve(r))
throw new i.ErrnoError(44);
var t = i.lookupPath(e, { parent: !0 }), n = t.node;
if (!n)
throw new i.ErrnoError(44);
var o = E.basename(e), a = i.mayCreate(n, o);
if (a)
throw new i.ErrnoError(a);
if (!n.node_ops.symlink)
throw new i.ErrnoError(63);
return n.node_ops.symlink(n, o, r);
}, rename: (r, e) => {
var t = E.dirname(r), n = E.dirname(e), o = E.basename(r), a = E.basename(e), s, u, f;
if (s = i.lookupPath(r, { parent: !0 }), u = s.node, s = i.lookupPath(e, { parent: !0 }), f = s.node, !u || !f) throw new i.ErrnoError(44);
if (u.mount !== f.mount)
throw new i.ErrnoError(75);
var c = i.lookupNode(u, o), p = G.relative(r, n);
if (p.charAt(0) !== ".")
throw new i.ErrnoError(28);
if (p = G.relative(e, t), p.charAt(0) !== ".")
throw new i.ErrnoError(55);
var h;
try {
h = i.lookupNode(f, a);
} catch {
}
if (c !== h) {
var v = i.isDir(c.mode), m = i.mayDelete(u, o, v);
if (m)
throw new i.ErrnoError(m);
if (m = h ? i.mayDelete(f, a, v) : i.mayCreate(f, a), m)
throw new i.ErrnoError(m);
if (!u.node_ops.rename)
throw new i.ErrnoError(63);
if (i.isMountpoint(c) || h && i.isMountpoint(h))
throw new i.ErrnoError(10);
if (f !== u && (m = i.nodePermissions(u, "w"), m))
throw new i.ErrnoError(m);
i.hashRemoveNode(c);
try {
u.node_ops.rename(c, f, a);
} catch (g) {
throw g;
} finally {
i.hashAddNode(c);
}
}
}, rmdir: (r) => {
var e = i.lookupPath(r, { parent: !0 }), t = e.node, n = E.basename(r), o = i.lookupNode(t, n), a = i.mayDelete(t, n, !0);
if (a)
throw new i.ErrnoError(a);
if (!t.node_ops.rmdir)
throw new i.ErrnoError(63);
if (i.isMountpoint(o))
throw new i.ErrnoError(10);
t.node_ops.rmdir(t, n), i.destroyNode(o);
}, readdir: (r) => {
var e = i.lookupPath(r, { follow: !0 }), t = e.node;
if (!t.node_ops.readdir)
throw new i.ErrnoError(54);
return t.node_ops.readdir(t);
}, unlink: (r) => {
var e = i.lookupPath(r, { parent: !0 }), t = e.node;
if (!t)
throw new i.ErrnoError(44);
var n = E.basename(r), o = i.lookupNode(t, n), a = i.mayDelete(t, n, !1);
if (a)
throw new i.ErrnoError(a);
if (!t.node_ops.unlink)
throw new i.ErrnoError(63);
if (i.isMountpoint(o))
throw new i.ErrnoError(10);
t.node_ops.unlink(t, n), i.destroyNode(o);
}, readlink: (r) => {
var e = i.lookupPath(r), t = e.node;
if (!t)
throw new i.ErrnoError(44);
if (!t.node_ops.readlink)
throw new i.ErrnoError(28);
return G.resolve(i.getPath(t.parent), t.node_ops.readlink(t));
}, stat: (r, e) => {
var t = i.lookupPath(r, { follow: !e }), n = t.node;
if (!n)
throw new i.ErrnoError(44);
if (!n.node_ops.getattr)
throw new i.ErrnoError(63);
return n.node_ops.getattr(n);
}, lstat: (r) => i.stat(r, !0), chmod: (r, e, t) => {
var n;
if (typeof r == "string") {
var o = i.lookupPath(r, { follow: !t });
n = o.node;
} else
n = r;
if (!n.node_ops.setattr)
throw new i.ErrnoError(63);
n.node_ops.setattr(n, { mode: e & 4095 | n.mode & -4096, timestamp: Date.now() });
}, lchmod: (r, e) => {
i.chmod(r, e, !0);
}, fchmod: (r, e) => {
var t = i.getStream(r);
if (!t)
throw new i.ErrnoError(8);
i.chmod(t.node, e);
}, chown: (r, e, t, n) => {
var o;
if (typeof r == "string") {
var a = i.lookupPath(r, { follow: !n });
o = a.node;
} else
o = r;
if (!o.node_ops.setattr)
throw new i.ErrnoError(63);
o.node_ops.setattr(o, { timestamp: Date.now() });
}, lchown: (r, e, t) => {
i.chown(r, e, t, !0);
}, fchown: (r, e, t) => {
var n = i.getStream(r);
if (!n)
throw new i.ErrnoError(8);
i.chown(n.node, e, t);
}, truncate: (r, e) => {
if (e < 0)
throw new i.ErrnoError(28);
var t;
if (typeof r == "string") {
var n = i.lookupPath(r, { follow: !0 });
t = n.node;
} else
t = r;
if (!t.node_ops.setattr)
throw new i.ErrnoError(63);
if (i.isDir(t.mode))
throw new i.ErrnoError(31);
if (!i.isFile(t.mode))
throw new i.ErrnoError(28);
var o = i.nodePermissions(t, "w");
if (o)
throw new i.ErrnoError(o);
t.node_ops.setattr(t, { size: e, timestamp: Date.now() });
}, ftruncate: (r, e) => {
var t = i.getStream(r);
if (!t)
throw new i.ErrnoError(8);
if (!(t.flags & 2097155))
throw new i.ErrnoError(28);
i.truncate(t.node, e);
}, utime: (r, e, t) => {
var n = i.lookupPath(r, { follow: !0 }), o = n.node;
o.node_ops.setattr(o, { timestamp: Math.max(e, t) });
}, open: (r, e, t) => {
if (r === "")
throw new i.ErrnoError(44);
e = typeof e == "string" ? i.modeStringToFlags(e) : e, t = typeof t > "u" ? 438 : t, e & 64 ? t = t & 4095 | 32768 : t = 0;
var n;
if (typeof r == "object")
n = r;
else {
r = E.normalize(r);
try {
var o = i.lookupPath(r, { follow: !(e & 131072) });
n = o.node;
} catch {
}
}
var a = !1;
if (e & 64)
if (n) {
if (e & 128)
throw new i.ErrnoError(20);
} else
n = i.mknod(r, t, 0), a = !0;
if (!n)
throw new i.ErrnoError(44);
if (i.isChrdev(n.mode) && (e &= -513), e & 65536 && !i.isDir(n.mode))
throw new i.ErrnoError(54);
if (!a) {
var s = i.mayOpen(n, e);
if (s)
throw new i.ErrnoError(s);
}
e & 512 && !a && i.truncate(n, 0), e &= -131713;
var u = i.createStream({ node: n, path: i.getPath(n), flags: e, seekable: !0, position: 0, stream_ops: n.stream_ops, ungotten: [], error: !1 });
return u.stream_ops.open && u.stream_ops.open(u), l.logReadFiles && !(e & 1) && (i.readFiles || (i.readFiles = {}), r in i.readFiles || (i.readFiles[r] = 1)), u;
}, close: (r) => {
if (i.isClosed(r))
throw new i.ErrnoError(8);
r.getdents && (r.getdents = null);
try {
r.stream_ops.close && r.stream_ops.close(r);
} catch (e) {
throw e;
} finally {
i.closeStream(r.fd);
}
r.fd = null;
}, isClosed: (r) => r.fd === null, llseek: (r, e, t) => {
if (i.isClosed(r))
throw new i.ErrnoError(8);
if (!r.seekable || !r.stream_ops.llseek)
throw new i.ErrnoError(70);
if (t != 0 && t != 1 && t != 2)
throw new i.ErrnoError(28);
return r.position = r.stream_ops.llseek(r, e, t), r.ungotten = [], r.position;
}, read: (r, e, t, n, o) => {
if (n < 0 || o < 0)
throw new i.ErrnoError(28);
if (i.isClosed(r))
throw new i.ErrnoError(8);
if ((r.flags & 2097155) === 1)
throw new i.ErrnoError(8);
if (i.isDir(r.node.mode))
throw new i.ErrnoError(31);
if (!r.stream_ops.read)
throw new i.ErrnoError(28);
var a = typeof o < "u";
if (!a)
o = r.position;
else if (!r.seekable)
throw new i.ErrnoError(70);
var s = r.stream_ops.read(r, e, t, n, o);
return a || (r.position += s), s;
}, write: (r, e, t, n, o, a) => {
if (n < 0 || o < 0)
throw new i.ErrnoError(28);
if (i.isClosed(r))
throw new i.ErrnoError(8);
if (!(r.flags & 2097155))
throw new i.ErrnoError(8);
if (i.isDir(r.node.mode))
throw new i.ErrnoError(31);
if (!r.stream_ops.write)
throw new i.ErrnoError(28);
r.seekable && r.flags & 1024 && i.llseek(r, 0, 2);
var s = typeof o < "u";
if (!s)
o = r.position;
else if (!r.seekable)
throw new i.ErrnoError(70);
var u = r.stream_ops.write(r, e, t, n, o, a);
return s || (r.position += u), u;
}, allocate: (r, e, t) => {
if (i.isClosed(r))
throw new i.ErrnoError(8);
if (e < 0 || t <= 0)
throw new i.ErrnoError(28);
if (!(r.flags & 2097155))
throw new i.ErrnoError(8);
if (!i.isFile(r.node.mode) && !i.isDir(r.node.mode))
throw new i.ErrnoError(43);
if (!r.stream_ops.allocate)
throw new i.ErrnoError(138);
r.stream_ops.allocate(r, e, t);
}, mmap: (r, e, t, n, o) => {
if (n & 2 && !(o & 2) && (r.flags & 2097155) !== 2)
throw new i.ErrnoError(2);
if ((r.flags & 2097155) === 1)
throw new i.ErrnoError(2);
if (!r.stream_ops.mmap)
throw new i.ErrnoError(43);
return r.stream_ops.mmap(r, e, t, n, o);
}, msync: (r, e, t, n, o) => !r || !r.stream_ops.msync ? 0 : r.stream_ops.msync(r, e, t, n, o), munmap: (r) => 0, ioctl: (r, e, t) => {
if (!r.stream_ops.ioctl)
throw new i.ErrnoError(59);
return r.stream_ops.ioctl(r, e, t);
}, readFile: (r, e = {}) => {
if (e.flags = e.flags || 0, e.encoding = e.encoding || "binary", e.encoding !== "utf8" && e.encoding !== "binary")
throw new Error('Invalid encoding type "' + e.encoding + '"');
var t, n = i.open(r, e.flags), o = i.stat(r), a = o.size, s = new Uint8Array(a);
return i.read(n, s, 0, a, 0), e.encoding === "utf8" ? t = sr(s, 0) : e.encoding === "binary" && (t = s), i.close(n), t;
}, writeFile: (r, e, t = {}) => {
t.flags = t.flags || 577;
var n = i.open(r, t.flags, t.mode);
if (typeof e == "string") {
var o = new Uint8Array(Qr(e) + 1), a = Jr(e, o, 0, o.length);
i.write(n, o, 0, a, void 0, t.canOwn);
} else if (ArrayBuffer.isView(e))
i.write(n, e, 0, e.byteLength, void 0, t.canOwn);
else
throw new Error("Unsupported data type");
i.close(n);
}, cwd: () => i.currentPath, chdir: (r) => {
var e = i.lookupPath(r, { follow: !0 });
if (e.node === null)
throw new i.ErrnoError(44);
if (!i.isDir(e.node.mode))
throw new i.ErrnoError(54);
var t = i.nodePermissions(e.node, "x");
if (t)
throw new i.ErrnoError(t);
i.currentPath = e.path;
}, createDefaultDirectories: () => {
i.mkdir("/tmp"), i.mkdir("/home"), i.mkdir("/home/web_user");
}, createDefaultDevices: () => {
i.mkdir("/dev"), i.registerDevice(i.makedev(1, 3), { read: () => 0, write: (e, t, n, o, a) => o }), i.mkdev("/dev/null", i.makedev(1, 3)), tr.register(i.makedev(5, 0), tr.default_tty_ops), tr.register(i.makedev(6, 0), tr.default_tty1_ops), i.mkdev("/dev/tty", i.makedev(5, 0)), i.mkdev("/dev/tty1", i.makedev(6, 0));
var r = At();
i.createDevice("/dev", "random", r), i.createDevice("/dev", "urandom", r), i.mkdir("/dev/shm"), i.mkdir("/dev/shm/tmp");
}, createSpecialDirectories: () => {
i.mkdir("/proc");
var r = i.mkdir("/proc/self");
i.mkdir("/proc/self/fd"), i.mount({ mount: () => {
var e = i.createNode(r, "fd", 16895, 73);
return e.node_ops = { lookup: (t, n) => {
var o = +n, a = i.getStream(o);
if (!a) throw new i.ErrnoError(8);
var s = { parent: null, mount: { mountpoint: "fake" }, node_ops: { readlink: () => a.path } };
return s.parent = s, s;
} }, e;
} }, {}, "/proc/self/fd");
}, createStandardStreams: () => {
l.stdin ? i.createDevice("/dev", "stdin", l.stdin) : i.symlink("/dev/tty", "/dev/stdin"), l.stdout ? i.createDevice("/dev", "stdout", null, l.stdout) : i.symlink("/dev/tty", "/dev/stdout"), l.stderr ? i.createDevice("/dev", "stderr", null, l.stderr) : i.symlink("/dev/tty1", "/dev/stderr"), i.open("/dev/stdin", 0), i.open("/dev/stdout", 1), i.open("/dev/stderr", 1);
}, ensureErrnoError: () => {
i.ErrnoError || (i.ErrnoError = function(e, t) {
this.node = t, this.setErrno = function(n) {
this.errno = n;
}, this.setErrno(e), this.message = "FS error";
}, i.ErrnoError.prototype = new Error(), i.ErrnoError.prototype.constructor = i.ErrnoError, [44].forEach((r) => {
i.genericErrors[r] = new i.ErrnoError(r), i.genericErrors[r].stack = "<generic error, no stack>";
}));
}, staticInit: () => {
i.ensureErrnoError(), i.nameTable = new Array(4096), i.mount(w, {}, "/"), i.createDefaultDirectories(), i.createDefaultDevices(), i.createSpecialDirectories(), i.filesystems = { MEMFS: w };
}, init: (r, e, t) => {
i.init.initialized = !0, i.ensureErrnoError(), l.stdin = r || l.stdin, l.stdout = e || l.stdout, l.stderr = t || l.stderr, i.createStandardStreams();
}, quit: () => {
i.init.initialized = !1;
for (var r = 0; r < i.streams.length; r++) {
var e = i.streams[r];
e && i.close(e);
}
}, getMode: (r, e) => {
var t = 0;
return r && (t |= 365), e && (t |= 146), t;
}, findObject: (r, e) => {
var t = i.analyzePath(r, e);
return t.exists ? t.object : null;
}, analyzePath: (r, e) => {
try {
var t = i.lookupPath(r, { follow: !e });
r = t.path;
} catch {
}
var n = { isRoot: !1, exists: !1, error: 0, name: null, path: null, object: null, parentExists: !1, parentPath: null, parentObject: null };
try {
var t = i.lookupPath(r, { parent: !0 });
n.parentExists = !0, n.parentPath = t.path, n.parentObject = t.node, n.name = E.basename(r), t = i.lookupPath(r, { follow: !e }), n.exists = !0, n.path = t.path, n.object = t.node, n.name = t.node.name, n.isRoot = t.path === "/";
} catch (o) {
n.error = o.errno;
}
return n;
}, createPath: (r, e, t, n) => {
r = typeof r == "string" ? r : i.getPath(r);
for (var o = e.split("/").reverse(); o.length; ) {
var a = o.pop();
if (a) {
var s = E.join2(r, a);
try {
i.mkdir(s);
} catch {
}
r = s;
}
}
return s;
}, createFile: (r, e, t, n, o) => {
var a = E.join2(typeof r == "string" ? r : i.getPath(r), e), s = i.getMode(n, o);
return i.create(a, s);
}, createDataFile: (r, e, t, n, o, a) => {
var s = e;
r && (r = typeof r == "string" ? r : i.getPath(r), s = e ? E.join2(r, e) : r);
var u = i.getMode(n, o), f = i.create(s, u);
if (t) {
if (typeof t == "string") {
for (var c = new Array(t.length), p = 0, h = t.length; p < h; ++p) c[p] = t.charCodeAt(p);
t = c;
}
i.chmod(f, u | 146);
var v = i.open(f, 577);
i.write(v, t, 0, t.length, 0, a), i.close(v), i.chmod(f, u);
}
return f;
}, createDevice: (r, e, t, n) => {
var o = E.join2(typeof r == "string" ? r : i.getPath(r), e), a = i.getMode(!!t, !!n);
i.createDevice.major || (i.createDevice.major = 64);
var s = i.makedev(i.createDevice.major++, 0);
return i.registerDevice(s, { open: (u) => {
u.seekable = !1;
}, close: (u) => {
n && n.buffer && n.buffer.length && n(10);
}, read: (u, f, c, p, h) => {