PageSourceSearch

https://arxtect.github.io/stellar-latex/stellarlatexpdftex.js

js arxtect.github.io collected 2026-10-03 08:39:51 UTC 124,648 bytes, 4,536 lines download raw bytes

1/* eslint-disable */
2var Module = typeof Module != "undefined" ? Module : {};
3var ENVIRONMENT_IS_WEB = true;
4var ENVIRONMENT_IS_WORKER = false;
5const TEXCACHEROOT = "/tex";
6const TEXPKGCACHEROOT = "/tex/pkg";
7const WORKROOT = "/work";
8const OUTPUTROOT = "/output";
9var Module = {};
10self.memlog = "";
11self.initmem = undefined;
12self.mainfile = "main.tex";
13self.texlive_endpoint =
14  "https://latex.arxtect.cn/latex6/arxtect_version_20251120/";
15self.ctan_mirror = "https://mirrors.ustc.edu.cn/CTAN/";
16Module["print"] = function (a) {
17  if (
18    a.includes("Package epstopdf Warning: Shell escape feature is not enabled")
19  ) {
20    return;
21  }
22  if (a.startsWith("[WASM ENGINE]")) {
23    console.log("[Compile Engine] " + a);
24    return;
25  }
26  const engineIndex = a.indexOf("[WASM ENGINE]");
27  if (engineIndex > 0) {
28    a = a.substring(0, engineIndex);
29  }
30  self.memlog += a + "\n";
31};
32Module["printErr"] = function (a) {
33  if (
34    a.includes("Package epstopdf Warning: Shell escape feature is not enabled")
35  ) {
36    return;
37  }
38  if (a.startsWith("[WASM ENGINE]")) {
39    console.log("[Compile Engine] " + a);
40    return;
41  }
42  const engineIndex = a.indexOf("[WASM ENGINE]");
43  if (engineIndex > 0) {
44    a = a.substring(0, engineIndex);
45  }
46  self.memlog += a + "\n";
47  console.log("[Compile Engine] " + a);
48};
49Module["preRun"] = function () {
50  FS.mkdir(TEXCACHEROOT);
51  FS.mkdir(TEXPKGCACHEROOT);
52  FS.mkdir(WORKROOT);
53  FS.mkdir(OUTPUTROOT);
54};
55function _allocate(content) {
56  let res = _malloc(content.length);
57  HEAPU8.set(new Uint8Array(content), res);
58  return res;
59}
60function dumpHeapMemory() {
61  var src = wasmMemory.buffer;
62  var dst = new Uint8Array(src.byteLength);
63  dst.set(new Uint8Array(src));
64  return dst;
65}
66function restoreHeapMemory() {
67  if (self.initmem) {
68    var dst = new Uint8Array(wasmMemory.buffer);
69    dst.set(self.initmem);
70  }
71}
72function closeFSStreams() {
73  for (var i = 0; i < FS.streams.length; i++) {
74    var stream = FS.streams[i];
75    if (!stream || stream.fd <= 2) {
76      continue;
77    }
78    FS.close(stream);
79  }
80}
81function prepareExecutionContext() {
82  self.memlog = "";
83  restoreHeapMemory();
84  FS.chdir(WORKROOT);
85  return 0;
86}
87Module["postRun"] = function () {
88  self.postMessage({ result: "ok" });
89  self.initmem = dumpHeapMemory();
90};
91function cleanDir(dir) {
92  let l = FS.readdir(dir);
93  for (let i in l) {
94    let item = l[i];
95    if (item === "." || item === "..") {
96      continue;
97    }
98    item = dir + "/" + item;
99    let fsStat = undefined;
100    try {
101      fsStat = FS.stat(item);
102    } catch (err) {
103      console.error("Not able to fsstat " + item);
104      continue;
105    }
106    if (FS.isDir(fsStat.mode)) {
107      cleanDir(item);
108    } else {
109      try {
110        FS.unlink(item);
111      } catch (err) {
112        console.error("Not able to unlink " + item);
113      }
114    }
115  }
116  if (
117    dir !== WORKROOT &&
118    dir !== TEXCACHEROOT &&
119    dir !== TEXPKGCACHEROOT &&
120    dir !== OUTPUTROOT &&
121    dir !== "/tmp"
122  ) {
123    try {
124      FS.rmdir(dir);
125    } catch (err) {
126      console.error("Not able to top level " + dir);
127    }
128  }
129}
130Module["onAbort"] = function () {
131  self.memlog += "Engine crashed";
132  self.postMessage({
133    result: "failed",
134    status: -254,
135    log: self.memlog,
136    cmd: "compile",
137  });
138  return;
139};
140function compileLaTeXRoutine() {
141  prepareExecutionContext();
142  closeFSStreams();
143  let lastSlash = self.mainfile.lastIndexOf("/");
144  let filename =
145    lastSlash >= 0 ? self.mainfile.substring(lastSlash + 1) : self.mainfile;
146  let pdfurl =
147    OUTPUTROOT +
148    "/" +
149    filename.substring(0, filename.lastIndexOf(".")) +
150    ".pdf";
151  let synctexurl =
152    OUTPUTROOT +
153    "/" +
154    filename.substring(0, filename.lastIndexOf(".")) +
155    ".synctex.gz";
156  FS.writeFile("/tmp/mainfile.txt", self.mainfile);
157  const compileLaTeXFunction = cwrap("compileLaTeX", "number");
158  let status = compileLaTeXFunction();
159  if (status === 0) {
160    if (FS.analyzePath("/tmp/no_compile").exists) {
161      FS.unlink("/tmp/no_compile");
162      self.postMessage({
163        result: "ok",
164        status: 0,
165        log: "not compiled",
166        cmd: "compile",
167      });
168    }
169    let pdfArrayBuffer = null;
170    let synctexArrayBuffer = null;
171    try {
172      pdfArrayBuffer = FS.readFile(pdfurl, { encoding: "binary" });
173      synctexArrayBuffer = FS.readFile(synctexurl, { encoding: "binary" });
174    } catch (err) {
175      console.error("Fetch content failed. " + pdfurl);
176      status = -253;
177      self.postMessage({
178        result: "failed",
179        status,
180        log: self.memlog,
181        cmd: "compile",
182      });
183      return;
184    }
185    self.postMessage(
186      {
187        result: "ok",
188        status,
189        log: self.memlog,
190        pdf: pdfArrayBuffer.buffer,
191        synctex: synctexArrayBuffer.buffer,
192        cmd: "compile",
193      },
194      [pdfArrayBuffer.buffer]
195    );
196  } else {
197    let pdfArrayBuffer = null;
198    let synctexArrayBuffer = null;
199    try {
200      pdfArrayBuffer = FS.readFile(pdfurl, { encoding: "binary" });
201      synctexArrayBuffer = FS.readFile(synctexurl, { encoding: "binary" });
202    } catch (err) {
203      console.error("Fetch content failed. " + pdfurl);
204      status = -253;
205      self.postMessage({
206        result: "failed",
207        status,
208        log: self.memlog,
209        cmd: "compile",
210      });
211      return;
212    }
213    console.error("Compilation failed, with status code " + status);
214    self.postMessage(
215      {
216        result: "failed",
217        status,
218        log: self.memlog,
219        pdf: pdfArrayBuffer.buffer,
220        synctex: synctexArrayBuffer.buffer,
221        cmd: "compile",
222      },
223      [pdfArrayBuffer.buffer]
224    );
225  }
226}
227function compileFormatRoutine() {
228  prepareExecutionContext();
229  FS.writeFile("/tmp/mainfile.txt", "*pdflatex.ini");
230  const compileLaTeXFunction = cwrap("compileLaTeX", "number");
231  let status = compileLaTeXFunction();
232  let pdfArrayBuffer = null;
233  let pdfurl = OUTPUTROOT + "/pdflatex.fmt";
234  try {
235    pdfArrayBuffer = FS.readFile(pdfurl, { encoding: "binary" });
236  } catch (err) {
237    console.error("Fetch content failed." + pdfurl);
238    status = -253;
239    self.postMessage({
240      result: "failed",
241      status,
242      log: self.memlog,
243      cmd: "compile",
244    });
245    return;
246  }
247  if (status === 0) {
248    self.postMessage(
249      {
250        result: "ok",
251        status,
252        log: self.memlog,
253        pdf: pdfArrayBuffer.buffer,
254        cmd: "compile",
255      },
256      [pdfArrayBuffer.buffer]
257    );
258  } else {
259    console.error("Compilation format failed, with status code " + status);
260    self.postMessage(
261      {
262        result: "failed",
263        status,
264        log: self.memlog,
265        pdf: pdfArrayBuffer.buffer,
266        cmd: "compile",
267      },
268      [pdfArrayBuffer.buffer]
269    );
270  }
271}
272function mkdirRoutine(dirname) {
273  try {
274    const targetDir = WORKROOT + "/" + dirname;
275    if (FS.analyzePath(targetDir).exists) {
276      self.postMessage({ result: "ok", cmd: "mkdir" });
277      return;
278    }
279    FS.mkdir(targetDir);
280    self.postMessage({ result: "ok", cmd: "mkdir" });
281  } catch (err) {
282    console.error("Not able to mkdir " + dirname);
283    self.postMessage({ result: "failed", cmd: "mkdir" });
284  }
285}
286function writeFileRoutine(filename, content) {
287  try {
288    FS.writeFile(WORKROOT + "/" + filename, content);
289    self.postMessage({ result: "ok", cmd: "writefile" });
290  } catch (err) {
291    console.error("Unable to write mem file");
292    self.postMessage({ result: "failed", cmd: "writefile" });
293  }
294}
295function synctexViewRoutine(pdf_path, tex_path, line, column) {
296  const synctexViewFunction = cwrap("synctex_view", "string", [
297    "string",
298    "string",
299    "number",
300    "number",
301  ]);
302  try {
303    let res = synctexViewFunction(pdf_path, tex_path, line, column);
304    if (res) {
305      let parts = res.split("�");
306      if (parts.length === 7) {
307        self.postMessage({
308          result: "ok",
309          page: parseInt(parts[0]),
310          x: parseFloat(parts[1]),
311          y: parseFloat(parts[2]),
312          h: parseFloat(parts[3]),
313          v: parseFloat(parts[4]),
314          W: parseFloat(parts[5]),
315          H: parseFloat(parts[6]),
316          cmd: "synctex_view",
317        });
318        return;
319      }
320    }
321    self.postMessage({ result: "failed", cmd: "synctex_view" });
322    return;
323  } catch (err) {
324    console.error("Unable to run synctex view");
325    self.postMessage({ result: "failed", cmd: "synctex_view" });
326  }
327}
328function synctexEditRoutine(pdf_path, page, x, y) {
329  const synctexEditFunction = cwrap("synctex_edit", "string", [
330    "string",
331    "number",
332    "number",
333    "number",
334  ]);
335  try {
336    let res = synctexEditFunction(pdf_path, page, x, y);
337    if (res) {
338      let parts = res.split("�");
339      if (parts.length === 3) {
340        let file = parts[0];
341        let line = parseInt(parts[1]);
342        let column = parseInt(parts[2]);
343        self.postMessage({
344          result: "ok",
345          file,
346          line,
347          column,
348          cmd: "synctex_edit",
349        });
350        return;
351      }
352    }
353    self.postMessage({ result: "failed", cmd: "synctex_edit" });
354    return;
355  } catch (err) {
356    console.error("Unable to run synctex edit");
357    self.postMessage({ result: "failed", cmd: "synctex_edit" });
358  }
359}
360function setTexliveEndpoint(url) {
361  if (url) {
362    if (!url.endsWith("/")) {
363      url += "/";
364    }
365    self.texlive_endpoint = url;
366  }
367}
368self["onmessage"] = function (ev) {
369  let data = ev["data"];
370  let cmd = data["cmd"];
371  if (cmd === "compilelatex") {
372    compileLaTeXRoutine();
373  } else if (cmd === "compileformat") {
374    compileFormatRoutine();
375  } else if (cmd === "settexliveurl") {
376    setTexliveEndpoint(data["url"]);
377  } else if (cmd === "mkdir") {
378    mkdirRoutine(data["url"]);
379  } else if (cmd === "writefile") {
380    writeFileRoutine(data["url"], data["src"]);
381  } else if (cmd === "setmainfile") {
382    self.mainfile = data["url"];
383  } else if (cmd === "grace") {
384    console.error("Gracefully Close");
385    self.close();
386  } else if (cmd === "flushwork") {
387    cleanDir(WORKROOT);
388  } else if (cmd === "flushbuild") {
389    cleanDir(OUTPUTROOT);
390    cleanDir("/tmp");
391  } else if (cmd == "predownload") {
392    self.postMessage({ result: "failed", cmd: "predownload" });
393  } else if (cmd == "synctex_view") {
394    synctexViewRoutine(
395      data["pdfPath"],
396      data["texPath"],
397      data["line"],
398      data["column"]
399    );
400  } else if (cmd == "synctex_edit") {
401    synctexEditRoutine(data["pdfPath"], data["page"], data["x"], data["y"]);
402  } else {
403    console.error("Unknown command " + cmd);
404  }
405};
406let texlive404_cache = {};
407let texlive200_cache = {};
408function kpse_find_file_impl(nameptr, format, _mustexist) {
409  const reqname = UTF8ToString(nameptr);
410  if (reqname.includes("/")) {
411    return 0;
412  }
413  const cacheKey = format + "/" + reqname;
414  if (cacheKey in texlive404_cache) {
415    return 0;
416  }
417  if (cacheKey in texlive200_cache) {
418    const savepath = texlive200_cache[cacheKey];
419    return _allocate(intArrayFromString(savepath));
420  }
421  const remote_url = self.texlive_endpoint + "pdftex/" + cacheKey;
422  let xhr = new XMLHttpRequest();
423  xhr.open("GET", remote_url, false);
424  xhr.timeout = 15e4;
425  xhr.responseType = "arraybuffer";
426  postMessage({
427    cmd: "engine_compiling_log",
428    level: "info",
429    message: "Loading resource " + reqname,
430  });
431  console.log("[Compile Engine] Start downloading texlive file " + remote_url);
432  try {
433    xhr.send();
434  } catch (err) {
435    console.log("[Compile Engine] TexLive Download Failed " + remote_url);
436    return 0;
437  }
438  if (xhr.status === 200) {
439    let arraybuffer = xhr.response;
440    const fileid = xhr.getResponseHeader("fileid");
441    const savepath =
442      (format === 99 ? TEXPKGCACHEROOT : TEXCACHEROOT) + "/" + fileid;
443    FS.writeFile(savepath, new Uint8Array(arraybuffer));
444    texlive200_cache[cacheKey] = savepath;
445    return _allocate(intArrayFromString(savepath));
446  } else if (xhr.status === 301) {
447    console.log("[Compile Engine] TexLive File not exists " + remote_url);
448    texlive404_cache[cacheKey] = 1;
449    return 0;
450  }
451  return 0;
452}
453let pk404_cache = {};
454let pk200_cache = {};
455function kpse_find_pk_impl(nameptr, dpi) {
456  const reqname = UTF8ToString(nameptr);
457  if (reqname.includes("/")) {
458    return 0;
459  }
460  const cacheKey = dpi + "/" + reqname;
461  if (cacheKey in pk404_cache) {
462    return 0;
463  }
464  if (cacheKey in pk200_cache) {
465    const savepath = pk200_cache[cacheKey];
466    return _allocate(intArrayFromString(savepath));
467  }
468  const remote_url = self.texlive_endpoint + "pdftex/pk/" + cacheKey;
469  let xhr = new XMLHttpRequest();
470  xhr.open("GET", remote_url, false);
471  xhr.timeout = 15e4;
472  xhr.responseType = "arraybuffer";
473  console.log("[Compile Engine] Start downloading texlive file " + remote_url);
474  try {
475    xhr.send();
476  } catch (err) {
477    console.log("[Compile Engine] TexLive Download Failed " + remote_url);
478    return 0;
479  }
480  if (xhr.status === 200) {
481    let arraybuffer = xhr.response;
482    const pkid = xhr.getResponseHeader("pkid");
483    const savepath = TEXCACHEROOT + "/" + pkid;
484    FS.writeFile(savepath, new Uint8Array(arraybuffer));
485    pk200_cache[cacheKey] = savepath;
486    return _allocate(intArrayFromString(savepath));
487  } else if (xhr.status === 301) {
488    console.log("[Compile Engine] TexLive File not exists " + remote_url);
489    pk404_cache[cacheKey] = 1;
490    return 0;
491  }
492  return 0;
493}
494var moduleOverrides = Object.assign({}, Module);
495var arguments_ = [];
496var thisProgram = "./this.program";
497var quit_ = (status, toThrow) => {
498  throw toThrow;
499};
500var scriptDirectory = "";
501function locateFile(path) {
502  if (Module["locateFile"]) {
503    return Module["locateFile"](path, scriptDirectory);
504  }
505  return scriptDirectory + path;
506}
507var readAsync, readBinary;
508if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
509  if (ENVIRONMENT_IS_WORKER) {
510    scriptDirectory = self.location.href;
511  } else if (typeof document != "undefined" && document.currentScript) {
512    scriptDirectory = document.currentScript.src;
513  }
514  if (scriptDirectory.startsWith("blob:")) {
515    scriptDirectory = "";
516  } else {
517    scriptDirectory = scriptDirectory.slice(
518      0,
519      scriptDirectory.replace(/[?#].*/, "").lastIndexOf("/") + 1
520    );
521  }
522  {
523    readAsync = async (url) => {
524      var response = await fetch(url, { credentials: "same-origin" });
525      if (response.ok) {
526        return response.arrayBuffer();
527      }
528      throw new Error(response.status + " : " + response.url);
529    };
530  }
531} else {
532}
533var out = Module["print"] || console.log.bind(console);
534var err = Module["printErr"] || console.error.bind(console);
535Object.assign(Module, moduleOverrides);
536moduleOverrides = null;
537if (Module["arguments"]) arguments_ = Module["arguments"];
538if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
539var wasmBinary = Module["wasmBinary"];
540var wasmMemory;
541var ABORT = false;
542var EXITSTATUS;
543var HEAP8,
544  HEAPU8,
545  HEAP16,
546  HEAPU16,
547  HEAP32,
548  HEAPU32,
549  HEAPF32,
550  HEAP64,
551  HEAPU64,
552  HEAPF64;
553var runtimeInitialized = false;
554function updateMemoryViews() {
555  var b = wasmMemory.buffer;
556  Module["HEAP8"] = HEAP8 = new Int8Array(b);
557  Module["HEAP16"] = HEAP16 = new Int16Array(b);
558  Module["HEAPU8"] = HEAPU8 = new Uint8Array(b);
559  Module["HEAPU16"] = HEAPU16 = new Uint16Array(b);
560  Module["HEAP32"] = HEAP32 = new Int32Array(b);
561  Module["HEAPU32"] = HEAPU32 = new Uint32Array(b);
562  Module["HEAPF32"] = HEAPF32 = new Float32Array(b);
563  Module["HEAPF64"] = HEAPF64 = new Float64Array(b);
564  Module["HEAP64"] = HEAP64 = new BigInt64Array(b);
565  Module["HEAPU64"] = HEAPU64 = new BigUint64Array(b);
566}
567function preRun() {
568  if (Module["preRun"]) {
569    if (typeof Module["preRun"] == "function")
570      Module["preRun"] = [Module["preRun"]];
571    while (Module["preRun"].length) {
572      addOnPreRun(Module["preRun"].shift());
573    }
574  }
575  callRuntimeCallbacks(onPreRuns);
576}
577function initRuntime() {
578  runtimeInitialized = true;
579  if (!Module["noFSInit"] && !FS.initialized) FS.init();
580  TTY.init();
581  wasmExports["Aa"]();
582  FS.ignorePermissions = false;
583}
584function preMain() {}
585function postRun() {
586  if (Module["postRun"]) {
587    if (typeof Module["postRun"] == "function")
588      Module["postRun"] = [Module["postRun"]];
589    while (Module["postRun"].length) {
590      addOnPostRun(Module["postRun"].shift());
591    }
592  }
593  callRuntimeCallbacks(onPostRuns);
594}
595var runDependencies = 0;
596var dependenciesFulfilled = null;
597function getUniqueRunDependency(id) {
598  return id;
599}
600function addRunDependency(id) {
601  runDependencies++;
602  Module["monitorRunDependencies"]?.(runDependencies);
603}
604function removeRunDependency(id) {
605  runDependencies--;
606  Module["monitorRunDependencies"]?.(runDependencies);
607  if (runDependencies == 0) {
608    if (dependenciesFulfilled) {
609      var callback = dependenciesFulfilled;
610      dependenciesFulfilled = null;
611      callback();
612    }
613  }
614}
615function abort(what) {
616  Module["onAbort"]?.(what);
617  what = "Aborted(" + what + ")";
618  err(what);
619  ABORT = true;
620  what += ". Build with -sASSERTIONS for more info.";
621  var e = new WebAssembly.RuntimeError(what);
622  throw e;
623}
624var wasmBinaryFile;
625function findWasmBinary() {
626  return locateFile("stellarlatexpdftex.wasm");
627}
628function getBinarySync(file) {
629  if (file == wasmBinaryFile && wasmBinary) {
630    return new Uint8Array(wasmBinary);
631  }
632  if (readBinary) {
633    return readBinary(file);
634  }
635  throw "both async and sync fetching of the wasm failed";
636}
637async function getWasmBinary(binaryFile) {
638  if (!wasmBinary) {
639    try {
640      var response = await readAsync(binaryFile);
641      return new Uint8Array(response);
642    } catch {}
643  }
644  return getBinarySync(binaryFile);
645}
646async function instantiateArrayBuffer(binaryFile, imports) {
647  try {
648    var binary = await getWasmBinary(binaryFile);
649    var instance = await WebAssembly.instantiate(binary, imports);
650    return instance;
651  } catch (reason) {
652    err(`failed to asynchronously prepare wasm: ${reason}`);
653    abort(reason);
654  }
655}
656async function instantiateAsync(binary, binaryFile, imports) {
657  if (!binary && typeof WebAssembly.instantiateStreaming == "function") {
658    try {
659      var response = fetch(binaryFile, { credentials: "same-origin" });
660      var instantiationResult = await WebAssembly.instantiateStreaming(
661        response,
662        imports
663      );
664      return instantiationResult;
665    } catch (reason) {
666      err(`wasm streaming compile failed: ${reason}`);
667      err("falling back to ArrayBuffer instantiation");
668    }
669  }
670  return instantiateArrayBuffer(binaryFile, imports);
671}
672function getWasmImports() {
673  return { a: wasmImports };
674}
675async function createWasm() {
676  function receiveInstance(instance, module) {
677    wasmExports = instance.exports;
678    wasmMemory = wasmExports["za"];
679    updateMemoryViews();
680    wasmTable = wasmExports["Ba"];
681    removeRunDependency("wasm-instantiate");
682    return wasmExports;
683  }
684  addRunDependency("wasm-instantiate");
685  function receiveInstantiationResult(result) {
686    return receiveInstance(result["instance"]);
687  }
688  var info = getWasmImports();
689  if (Module["instantiateWasm"]) {
690    return new Promise((resolve, reject) => {
691      Module["instantiateWasm"](info, (mod, inst) => {
692        receiveInstance(mod, inst);
693        resolve(mod.exports);
694      });
695    });
696  }
697  wasmBinaryFile ??= findWasmBinary();
698  var result = await instantiateAsync(wasmBinary, wasmBinaryFile, info);
699  var exports = receiveInstantiationResult(result);
700  return exports;
701}
702class ExitStatus {
703  name = "ExitStatus";
704  constructor(status) {
705    this.message = `Program terminated with exit(${status})`;
706    this.status = status;
707  }
708}
709var callRuntimeCallbacks = (callbacks) => {
710  while (callbacks.length > 0) {
711    callbacks.shift()(Module);
712  }
713};
714var onPostRuns = [];
715var addOnPostRun = (cb) => onPostRuns.unshift(cb);
716var onPreRuns = [];
717var addOnPreRun = (cb) => onPreRuns.unshift(cb);
718var noExitRuntime = Module["noExitRuntime"] || true;
719var stackRestore = (val) => __emscripten_stack_restore(val);
720var stackSave = () => _emscripten_stack_get_current();
721var UTF8Decoder =
722  typeof TextDecoder != "undefined" ? new TextDecoder() : undefined;
723var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead = NaN) => {
724  var endIdx = idx + maxBytesToRead;
725  var endPtr = idx;
726  while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
727  if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
728    return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
729  }
730  var str = "";
731  while (idx < endPtr) {
732    var u0 = heapOrArray[idx++];
733    if (!(u0 & 128)) {
734      str += String.fromCharCode(u0);
735      continue;
736    }
737    var u1 = heapOrArray[idx++] & 63;
738    if ((u0 & 224) == 192) {
739      str += String.fromCharCode(((u0 & 31) << 6) | u1);
740      continue;
741    }
742    var u2 = heapOrArray[idx++] & 63;
743    if ((u0 & 240) == 224) {
744      u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
745    } else {
746      u0 =
747        ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
748    }
749    if (u0 < 65536) {
750      str += String.fromCharCode(u0);
751    } else {
752      var ch = u0 - 65536;
753      str += String.fromCharCode(55296 | (ch >> 10), 56320 | (ch & 1023));
754    }
755  }
756  return str;
757};
758var UTF8ToString = (ptr, maxBytesToRead) =>
759  ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : "";
760var ___assert_fail = (condition, filename, line, func) =>
761  abort(
762    `Assertion failed: ${UTF8ToString(condition)}, at: ` +
763      [
764        filename ? UTF8ToString(filename) : "unknown filename",
765        line,
766        func ? UTF8ToString(func) : "unknown function",
767      ]
768  );
769var exceptionCaught = [];
770var uncaughtExceptionCount = 0;
771var ___cxa_begin_catch = (ptr) => {
772  var info = new ExceptionInfo(ptr);
773  if (!info.get_caught()) {
774    info.set_caught(true);
775    uncaughtExceptionCount--;
776  }
777  info.set_rethrown(false);
778  exceptionCaught.push(info);
779  ___cxa_increment_exception_refcount(ptr);
780  return ___cxa_get_exception_ptr(ptr);
781};
782var exceptionLast = 0;
783var ___cxa_end_catch = () => {
784  _setThrew(0, 0);
785  var info = exceptionCaught.pop();
786  ___cxa_decrement_exception_refcount(info.excPtr);
787  exceptionLast = 0;
788};
789class ExceptionInfo {
790  constructor(excPtr) {
791    this.excPtr = excPtr;
792    this.ptr = excPtr - 24;
793  }
794  set_type(type) {
795    HEAPU32[(this.ptr + 4) >> 2] = type;
796  }
797  get_type() {
798    return HEAPU32[(this.ptr + 4) >> 2];
799  }
800  set_destructor(destructor) {
801    HEAPU32[(this.ptr + 8) >> 2] = destructor;
802  }
803  get_destructor() {
804    return HEAPU32[(this.ptr + 8) >> 2];
805  }
806  set_caught(caught) {
807    caught = caught ? 1 : 0;
808    HEAP8[this.ptr + 12] = caught;
809  }
810  get_caught() {
811    return HEAP8[this.ptr + 12] != 0;
812  }
813  set_rethrown(rethrown) {
814    rethrown = rethrown ? 1 : 0;
815    HEAP8[this.ptr + 13] = rethrown;
816  }
817  get_rethrown() {
818    return HEAP8[this.ptr + 13] != 0;
819  }
820  init(type, destructor) {
821    this.set_adjusted_ptr(0);
822    this.set_type(type);
823    this.set_destructor(destructor);
824  }
825  set_adjusted_ptr(adjustedPtr) {
826    HEAPU32[(this.ptr + 16) >> 2] = adjustedPtr;
827  }
828  get_adjusted_ptr() {
829    return HEAPU32[(this.ptr + 16) >> 2];
830  }
831}
832var ___resumeException = (ptr) => {
833  if (!exceptionLast) {
834    exceptionLast = ptr;
835  }
836  throw exceptionLast;
837};
838var setTempRet0 = (val) => __emscripten_tempret_set(val);
839var findMatchingCatch = (args) => {
840  var thrown = exceptionLast;
841  if (!thrown) {
842    setTempRet0(0);
843    return 0;
844  }
845  var info = new ExceptionInfo(thrown);
846  info.set_adjusted_ptr(thrown);
847  var thrownType = info.get_type();
848  if (!thrownType) {
849    setTempRet0(0);
850    return thrown;
851  }
852  for (var caughtType of args) {
853    if (caughtType === 0 || caughtType === thrownType) {
854      break;
855    }
856    var adjusted_ptr_addr = info.ptr + 16;
857    if (___cxa_can_catch(caughtType, thrownType, adjusted_ptr_addr)) {
858      setTempRet0(caughtType);
859      return thrown;
860    }
861  }
862  setTempRet0(thrownType);
863  return thrown;
864};
865var ___cxa_find_matching_catch_2 = () => findMatchingCatch([]);
866var ___cxa_find_matching_catch_3 = (arg0) => findMatchingCatch([arg0]);
867var ___cxa_find_matching_catch_4 = (arg0, arg1) =>
868  findMatchingCatch([arg0, arg1]);
869var ___cxa_rethrow = () => {
870  var info = exceptionCaught.pop();
871  if (!info) {
872    abort("no exception to throw");
873  }
874  var ptr = info.excPtr;
875  if (!info.get_rethrown()) {
876    exceptionCaught.push(info);
877    info.set_rethrown(true);
878    info.set_caught(false);
879    uncaughtExceptionCount++;
880  }
881  exceptionLast = ptr;
882  throw exceptionLast;
883};
884var ___cxa_throw = (ptr, type, destructor) => {
885  var info = new ExceptionInfo(ptr);
886  info.init(type, destructor);
887  exceptionLast = ptr;
888  uncaughtExceptionCount++;
889  throw exceptionLast;
890};
891var ___cxa_uncaught_exceptions = () => uncaughtExceptionCount;
892var PATH = {
893  isAbs: (path) => path.charAt(0) === "/",
894  splitPath: (filename) => {
895    var splitPathRe =
896      /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
897    return splitPathRe.exec(filename).slice(1);
898  },
899  normalizeArray: (parts, allowAboveRoot) => {
900    var up = 0;
901    for (var i = parts.length - 1; i >= 0; i--) {
902      var last = parts[i];
903      if (last === ".") {
904        parts.splice(i, 1);
905      } else if (last === "..") {
906        parts.splice(i, 1);
907        up++;
908      } else if (up) {
909        parts.splice(i, 1);
910        up--;
911      }
912    }
913    if (allowAboveRoot) {
914      for (; up; up--) {
915        parts.unshift("..");
916      }
917    }
918    return parts;
919  },
920  normalize: (path) => {
921    var isAbsolute = PATH.isAbs(path),
922      trailingSlash = path.slice(-1) === "/";
923    path = PATH.normalizeArray(
924      path.split("/").filter((p) => !!p),
925      !isAbsolute
926    ).join("/");
927    if (!path && !isAbsolute) {
928      path = ".";
929    }
930    if (path && trailingSlash) {
931      path += "/";
932    }
933    return (isAbsolute ? "/" : "") + path;
934  },
935  dirname: (path) => {
936    var result = PATH.splitPath(path),
937      root = result[0],
938      dir = result[1];
939    if (!root && !dir) {
940      return ".";
941    }
942    if (dir) {
943      dir = dir.slice(0, -1);
944    }
945    return root + dir;
946  },
947  basename: (path) => path && path.match(/([^\/]+|\/)\/*$/)[1],
948  join: (...paths) => PATH.normalize(paths.join("/")),
949  join2: (l, r) =>
949 PATH.normalize(l + "/" + r),
950};
951var initRandomFill = () => (view) => crypto.getRandomValues(view);
952var randomFill = (view) => {
953  (randomFill = initRandomFill())(view);
954};
955var PATH_FS = {
956  resolve: (...args) => {
957    var resolvedPath = "",
958      resolvedAbsolute = false;
959    for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
960      var path = i >= 0 ? args[i] : FS.cwd();
961      if (typeof path != "string") {
962        throw new TypeError("Arguments to path.resolve must be strings");
963      } else if (!path) {
964        return "";
965      }
966      resolvedPath = path + "/" + resolvedPath;
967      resolvedAbsolute = PATH.isAbs(path);
968    }
969    resolvedPath = PATH.normalizeArray(
970      resolvedPath.split("/").filter((p) => !!p),
971      !resolvedAbsolute
972    ).join("/");
973    return (resolvedAbsolute ? "/" : "") + resolvedPath || ".";
974  },
975  relative: (from, to) => {
976    from = PATH_FS.resolve(from).slice(1);
977    to = PATH_FS.resolve(to).slice(1);
978    function trim(arr) {
979      var start = 0;
980      for (; start < arr.length; start++) {
981        if (arr[start] !== "") break;
982      }
983      var end = arr.length - 1;
984      for (; end >= 0; end--) {
985        if (arr[end] !== "") break;
986      }
987      if (start > end) return [];
988      return arr.slice(start, end - start + 1);
989    }
990    var fromParts = trim(from.split("/"));
991    var toParts = trim(to.split("/"));
992    var length = Math.min(fromParts.length, toParts.length);
993    var samePartsLength = length;
994    for (var i = 0; i < length; i++) {
995      if (fromParts[i] !== toParts[i]) {
996        samePartsLength = i;
997        break;
998      }
999    }
1000    var outputParts = [];
1001    for (var i = samePartsLength; i < fromParts.length; i++) {
1002      outputParts.push("..");
1003    }
1004    outputParts = outputParts.concat(toParts.slice(samePartsLength));
1005    return outputParts.join("/");
1006  },
1007};
1008var FS_stdin_getChar_buffer = [];
1009var lengthBytesUTF8 = (str) => {
1010  var len = 0;
1011  for (var i = 0; i < str.length; ++i) {
1012    var c = str.charCodeAt(i);
1013    if (c <= 127) {
1014      len++;
1015    } else if (c <= 2047) {
1016      len += 2;
1017    } else if (c >= 55296 && c <= 57343) {
1018      len += 4;
1019      ++i;
1020    } else {
1021      len += 3;
1022    }
1023  }
1024  return len;
1025};
1026var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
1027  if (!(maxBytesToWrite > 0)) return 0;
1028  var startIdx = outIdx;
1029  var endIdx = outIdx + maxBytesToWrite - 1;
1030  for (var i = 0; i < str.length; ++i) {
1031    var u = str.charCodeAt(i);
1032    if (u >= 55296 && u <= 57343) {
1033      var u1 = str.charCodeAt(++i);
1034      u = (65536 + ((u & 1023) << 10)) | (u1 & 1023);
1035    }
1036    if (u <= 127) {
1037      if (outIdx >= endIdx) break;
1038      heap[outIdx++] = u;
1039    } else if (u <= 2047) {
1040      if (outIdx + 1 >= endIdx) break;
1041      heap[outIdx++] = 192 | (u >> 6);
1042      heap[outIdx++] = 128 | (u & 63);
1043    } else if (u <= 65535) {
1044      if (outIdx + 2 >= endIdx) break;
1045      heap[outIdx++] = 224 | (u >> 12);
1046      heap[outIdx++] = 128 | ((u >> 6) & 63);
1047      heap[outIdx++] = 128 | (u & 63);
1048    } else {
1049      if (outIdx + 3 >= endIdx) break;
1050      heap[outIdx++] = 240 | (u >> 18);
1051      heap[outIdx++] = 128 | ((u >> 12) & 63);
1052      heap[outIdx++] = 128 | ((u >> 6) & 63);
1053      heap[outIdx++] = 128 | (u & 63);
1054    }
1055  }
1056  heap[outIdx] = 0;
1057  return outIdx - startIdx;
1058};
1059var intArrayFromString = (stringy, dontAddNull, length) => {
1060  var len = length > 0 ? length : lengthBytesUTF8(stringy) + 1;
1061  var u8array = new Array(len);
1062  var numBytesWritten = stringToUTF8Array(stringy, u8array, 0, u8array.length);
1063  if (dontAddNull) u8array.length = numBytesWritten;
1064  return u8array;
1065};
1066var FS_stdin_getChar = () => {
1067  if (!FS_stdin_getChar_buffer.length) {
1068    var result = null;
1069    if (typeof window != "undefined" && typeof window.prompt == "function") {
1070      result = window.prompt("Input: ");
1071      if (result !== null) {
1072        result += "\n";
1073      }
1074    } else {
1075    }
1076    if (!result) {
1077      return null;
1078    }
1079    FS_stdin_getChar_buffer = intArrayFromString(result, true);
1080  }
1081  return FS_stdin_getChar_buffer.shift();
1082};
1083var TTY = {
1084  ttys: [],
1085  init() {},
1086  shutdown() {},
1087  register(dev, ops) {
1088    TTY.ttys[dev] = { input: [], output: [], ops };
1089    FS.registerDevice(dev, TTY.stream_ops);
1090  },
1091  stream_ops: {
1092    open(stream) {
1093      var tty = TTY.ttys[stream.node.rdev];
1094      if (!tty) {
1095        throw new FS.ErrnoError(43);
1096      }
1097      stream.tty = tty;
1098      stream.seekable = false;
vendor: 4,446 bytes, lines 1099-1264
1099    },
1100    close(stream) {
1101      stream.tty.ops.fsync(stream.tty);
1102    },
1103    fsync(stream) {
1104      stream.tty.ops.fsync(stream.tty);
1105    },
1106    read(stream, buffer, offset, length, pos) {
1107      if (!stream.tty || !stream.tty.ops.get_char) {
1108        throw new FS.ErrnoError(60);
1109      }
1110      var bytesRead = 0;
1111      for (var i = 0; i < length; i++) {
1112        var result;
1113        try {
1114          result = stream.tty.ops.get_char(stream.tty);
1115        } catch (e) {
1116          throw new FS.ErrnoError(29);
1117        }
1118        if (result === undefined && bytesRead === 0) {
1119          throw new FS.ErrnoError(6);
1120        }
1121        if (result === null || result === undefined) break;
1122        bytesRead++;
1123        buffer[offset + i] = result;
1124      }
1125      if (bytesRead) {
1126        stream.node.atime = Date.now();
1127      }
1128      return bytesRead;
1129    },
1130    write(stream, buffer, offset, length, pos) {
1131      if (!stream.tty || !stream.tty.ops.put_char) {
1132        throw new FS.ErrnoError(60);
1133      }
1134      try {
1135        for (var i = 0; i < length; i++) {
1136          stream.tty.ops.put_char(stream.tty, buffer[offset + i]);
1137        }
1138      } catch (e) {
1139        throw new FS.ErrnoError(29);
1140      }
1141      if (length) {
1142        stream.node.mtime = stream.node.ctime = Date.now();
1143      }
1144      return i;
1145    },
1146  },
1147  default_tty_ops: {
1148    get_char(tty) {
1149      return FS_stdin_getChar();
1150    },
1151    put_char(tty, val) {
1152      if (val === null || val === 10) {
1153        out(UTF8ArrayToString(tty.output));
1154        tty.output = [];
1155      } else {
1156        if (val != 0) tty.output.push(val);
1157      }
1158    },
1159    fsync(tty) {
1160      if (tty.output?.length > 0) {
1161        out(UTF8ArrayToString(tty.output));
1162        tty.output = [];
1163      }
1164    },
1165    ioctl_tcgets(tty) {
1166      return {
1167        c_iflag: 25856,
1168        c_oflag: 5,
1169        c_cflag: 191,
1170        c_lflag: 35387,
1171        c_cc: [
1172          3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0,
1173          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1174        ],
1175      };
1176    },
1177    ioctl_tcsets(tty, optional_actions, data) {
1178      return 0;
1179    },
1180    ioctl_tiocgwinsz(tty) {
1181      return [24, 80];
1182    },
1183  },
1184  default_tty1_ops: {
1185    put_char(tty, val) {
1186      if (val === null || val === 10) {
1187        err(UTF8ArrayToString(tty.output));
1188        tty.output = [];
1189      } else {
1190        if (val != 0) tty.output.push(val);
1191      }
1192    },
1193    fsync(tty) {
1194      if (tty.output?.length > 0) {
1195        err(UTF8ArrayToString(tty.output));
1196        tty.output = [];
1197      }
1198    },
1199  },
1200};
1201var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
1202var mmapAlloc = (size) => {
1203  abort();
1204};
1205var MEMFS = {
1206  ops_table: null,
1207  mount(mount) {
1208    return MEMFS.createNode(null, "/", 16895, 0);
1209  },
1210  createNode(parent, name, mode, dev) {
1211    if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
1212      throw new FS.ErrnoError(63);
1213    }
1214    MEMFS.ops_table ||= {
1215      dir: {
1216        node: {
1217          getattr: MEMFS.node_ops.getattr,
1218          setattr: MEMFS.node_ops.setattr,
1219          lookup: MEMFS.node_ops.lookup,
1220          mknod: MEMFS.node_ops.mknod,
1221          rename: MEMFS.node_ops.rename,
1222          unlink: MEMFS.node_ops.unlink,
1223          rmdir: MEMFS.node_ops.rmdir,
1224          readdir: MEMFS.node_ops.readdir,
1225          symlink: MEMFS.node_ops.symlink,
1226        },
1227        stream: { llseek: MEMFS.stream_ops.llseek },
1228      },
1229      file: {
1230        node: {
1231          getattr: MEMFS.node_ops.getattr,
1232          setattr: MEMFS.node_ops.setattr,
1233        },
1234        stream: {
1235          llseek: MEMFS.stream_ops.llseek,
1236          read: MEMFS.stream_ops.read,
1237          write: MEMFS.stream_ops.write,
1238          allocate: MEMFS.stream_ops.allocate,
1239          mmap: MEMFS.stream_ops.mmap,
1240          msync: MEMFS.stream_ops.msync,
1241        },
1242      },
1243      link: {
1244        node: {
1245          getattr: MEMFS.node_ops.getattr,
1246          setattr: MEMFS.node_ops.setattr,
1247          readlink: MEMFS.node_ops.readlink,
1248        },
1249        stream: {},
1250      },
1251      chrdev: {
1252        node: {
1253          getattr: MEMFS.node_ops.getattr,
1254          setattr: MEMFS.node_ops.setattr,
1255        },
1256        stream: FS.chrdev_stream_ops,
1257      },
1258    };
1259    var node = FS.createNode(parent, name, mode, dev);
1260    if (FS.isDir(node.mode)) {
1261      node.node_ops = MEMFS.ops_table.dir.node;
1262      node.stream_ops = MEMFS.ops_table.dir.stream;
1263      node.contents = {};
1264    } else if (FS.isFile(node.mode)) {
vendor: 5,095 bytes, lines 1265-1425
1265      node.node_ops = MEMFS.ops_table.file.node;
1266      node.stream_ops = MEMFS.ops_table.file.stream;
1267      node.usedBytes = 0;
1268      node.contents = null;
1269    } else if (FS.isLink(node.mode)) {
1270      node.node_ops = MEMFS.ops_table.link.node;
1271      node.stream_ops = MEMFS.ops_table.link.stream;
1272    } else if (FS.isChrdev(node.mode)) {
1273      node.node_ops = MEMFS.ops_table.chrdev.node;
1274      node.stream_ops = MEMFS.ops_table.chrdev.stream;
1275    }
1276    node.atime = node.mtime = node.ctime = Date.now();
1277    if (parent) {
1278      parent.contents[name] = node;
1279      parent.atime = parent.mtime = parent.ctime = node.atime;
1280    }
1281    return node;
1282  },
1283  getFileDataAsTypedArray(node) {
1284    if (!node.contents) return new Uint8Array(0);
1285    if (node.contents.subarray)
1286      return node.contents.subarray(0, node.usedBytes);
1287    return new Uint8Array(node.contents);
1288  },
1289  expandFileStorage(node, newCapacity) {
1290    var prevCapacity = node.contents ? node.contents.length : 0;
1291    if (prevCapacity >= newCapacity) return;
1292    var CAPACITY_DOUBLING_MAX = 1024 * 1024;
1293    newCapacity = Math.max(
1294      newCapacity,
1295      (prevCapacity * (prevCapacity < CAPACITY_DOUBLING_MAX ? 2 : 1.125)) >>> 0
1296    );
1297    if (prevCapacity != 0) newCapacity = Math.max(newCapacity, 256);
1298    var oldContents = node.contents;
1299    node.contents = new Uint8Array(newCapacity);
1300    if (node.usedBytes > 0)
1301      node.contents.set(oldContents.subarray(0, node.usedBytes), 0);
1302  },
1303  resizeFileStorage(node, newSize) {
1304    if (node.usedBytes == newSize) return;
1305    if (newSize == 0) {
1306      node.contents = null;
1307      node.usedBytes = 0;
1308    } else {
1309      var oldContents = node.contents;
1310      node.contents = new Uint8Array(newSize);
1311      if (oldContents) {
1312        node.contents.set(
1313          oldContents.subarray(0, Math.min(newSize, node.usedBytes))
1314        );
1315      }
1316      node.usedBytes = newSize;
1317    }
1318  },
1319  node_ops: {
1320    getattr(node) {
1321      var attr = {};
1322      attr.dev = FS.isChrdev(node.mode) ? node.id : 1;
1323      attr.ino = node.id;
1324      attr.mode = node.mode;
1325      attr.nlink = 1;
1326      attr.uid = 0;
1327      attr.gid = 0;
1328      attr.rdev = node.rdev;
1329      if (FS.isDir(node.mode)) {
1330        attr.size = 4096;
1331      } else if (FS.isFile(node.mode)) {
1332        attr.size = node.usedBytes;
1333      } else if (FS.isLink(node.mode)) {
1334        attr.size = node.link.length;
1335      } else {
1336        attr.size = 0;
1337      }
1338      attr.atime = new Date(node.atime);
1339      attr.mtime = new Date(node.mtime);
1340      attr.ctime = new Date(node.ctime);
1341      attr.blksize = 4096;
1342      attr.blocks = Math.ceil(attr.size / attr.blksize);
1343      return attr;
1344    },
1345    setattr(node, attr) {
1346      for (const key of ["mode", "atime", "mtime", "ctime"]) {
1347        if (attr[key] != null) {
1348          node[key] = attr[key];
1349        }
1350      }
1351      if (attr.size !== undefined) {
1352        MEMFS.resizeFileStorage(node, attr.size);
1353      }
1354    },
1355    lookup(parent, name) {
1356      throw MEMFS.doesNotExistError;
1357    },
1358    mknod(parent, name, mode, dev) {
1359      return MEMFS.createNode(parent, name, mode, dev);
1360    },
1361    rename(old_node, new_dir, new_name) {
1362      var new_node;
1363      try {
1364        new_node = FS.lookupNode(new_dir, new_name);
1365      } catch (e) {}
1366      if (new_node) {
1367        if (FS.isDir(old_node.mode)) {
1368          for (var i in new_node.contents) {
1369            throw new FS.ErrnoError(55);
1370          }
1371        }
1372        FS.hashRemoveNode(new_node);
1373      }
1374      delete old_node.parent.contents[old_node.name];
1375      new_dir.contents[new_name] = old_node;
1376      old_node.name = new_name;
1377      new_dir.ctime =
1378        new_dir.mtime =
1379        old_node.parent.ctime =
1380        old_node.parent.mtime =
1381          Date.now();
1382    },
1383    unlink(parent, name) {
1384      delete parent.contents[name];
1385      parent.ctime = parent.mtime = Date.now();
1386    },
1387    rmdir(parent, name) {
1388      var node = FS.lookupNode(parent, name);
1389      for (var i in node.contents) {
1390        throw new FS.ErrnoError(55);
1391      }
1392      delete parent.contents[name];
1393      parent.ctime = parent.mtime = Date.now();
1394    },
1395    readdir(node) {
1396      return [".", "..", ...Object.keys(node.contents)];
1397    },
1398    symlink(parent, newname, oldpath) {
1399      var node = MEMFS.createNode(parent, newname, 511 | 40960, 0);
1400      node.link = oldpath;
1401      return node;
1402    },
1403    readlink(node) {
1404      if (!FS.isLink(node.mode)) {
1405        throw new FS.ErrnoError(28);
1406      }
1407      return node.link;
1408    },
1409  },
1410  stream_ops: {
1411    read(stream, buffer, offset, length, position) {
1412      var contents = stream.node.contents;
1413      if (position >= stream.node.usedBytes) return 0;
1414      var size = Math.min(stream.node.usedBytes - position, length);
1415      if (size > 8 && contents.subarray) {
1416        buffer.set(contents.subarray(position, position + size), offset);
1417      } else {
1418        for (var i = 0; i < size; i++)
1419          buffer[offset + i] = contents[position + i];
1420      }
1421      return size;
1422    },
1423    write(stream, buffer, offset, length, position, canOwn) {
1424      if (buffer.buffer === HEAP8.buffer) {
1425        canOwn = false;
vendor: 16,204 bytes, lines 1426-2043
1426      }
1427      if (!length) return 0;
1428      var node = stream.node;
1429      node.mtime = node.ctime = Date.now();
1430      if (buffer.subarray && (!node.contents || node.contents.subarray)) {
1431        if (canOwn) {
1432          node.contents = buffer.subarray(offset, offset + length);
1433          node.usedBytes = length;
1434          return length;
1435        } else if (node.usedBytes === 0 && position === 0) {
1436          node.contents = buffer.slice(offset, offset + length);
1437          node.usedBytes = length;
1438          return length;
1439        } else if (position + length <= node.usedBytes) {
1440          node.contents.set(buffer.subarray(offset, offset + length), position);
1441          return length;
1442        }
1443      }
1444      MEMFS.expandFileStorage(node, position + length);
1445      if (node.contents.subarray && buffer.subarray) {
1446        node.contents.set(buffer.subarray(offset, offset + length), position);
1447      } else {
1448        for (var i = 0; i < length; i++) {
1449          node.contents[position + i] = buffer[offset + i];
1450        }
1451      }
1452      node.usedBytes = Math.max(node.usedBytes, position + length);
1453      return length;
1454    },
1455    llseek(stream, offset, whence) {
1456      var position = offset;
1457      if (whence === 1) {
1458        position += stream.position;
1459      } else if (whence === 2) {
1460        if (FS.isFile(stream.node.mode)) {
1461          position += stream.node.usedBytes;
1462        }
1463      }
1464      if (position < 0) {
1465        throw new FS.ErrnoError(28);
1466      }
1467      return position;
1468    },
1469    allocate(stream, offset, length) {
1470      MEMFS.expandFileStorage(stream.node, offset + length);
1471      stream.node.usedBytes = Math.max(stream.node.usedBytes, offset + length);
1472    },
1473    mmap(stream, length, position, prot, flags) {
1474      if (!FS.isFile(stream.node.mode)) {
1475        throw new FS.ErrnoError(43);
1476      }
1477      var ptr;
1478      var allocated;
1479      var contents = stream.node.contents;
1480      if (!(flags & 2) && contents && contents.buffer === HEAP8.buffer) {
1481        allocated = false;
1482        ptr = contents.byteOffset;
1483      } else {
1484        allocated = true;
1485        ptr = mmapAlloc(length);
1486        if (!ptr) {
1487          throw new FS.ErrnoError(48);
1488        }
1489        if (contents) {
1490          if (position > 0 || position + length < contents.length) {
1491            if (contents.subarray) {
1492              contents = contents.subarray(position, position + length);
1493            } else {
1494              contents = Array.prototype.slice.call(
1495                contents,
1496                position,
1497                position + length
1498              );
1499            }
1500          }
1501          HEAP8.set(contents, ptr);
1502        }
1503      }
1504      return { ptr, allocated };
1505    },
1506    msync(stream, buffer, offset, length, mmapFlags) {
1507      MEMFS.stream_ops.write(stream, buffer, 0, length, offset, false);
1508      return 0;
1509    },
1510  },
1511};
1512var asyncLoad = async (url) => {
1513  var arrayBuffer = await readAsync(url);
1514  return new Uint8Array(arrayBuffer);
1515};
1516var FS_createDataFile = (parent, name, fileData, canRead, canWrite, canOwn) => {
1517  FS.createDataFile(parent, name, fileData, canRead, canWrite, canOwn);
1518};
1519var preloadPlugins = Module["preloadPlugins"] || [];
1520var FS_handledByPreloadPlugin = (byteArray, fullname, finish, onerror) => {
1521  if (typeof Browser != "undefined") Browser.init();
1522  var handled = false;
1523  preloadPlugins.forEach((plugin) => {
1524    if (handled) return;
1525    if (plugin["canHandle"](fullname)) {
1526      plugin["handle"](byteArray, fullname, finish, onerror);
1527      handled = true;
1528    }
1529  });
1530  return handled;
1531};
1532var FS_createPreloadedFile = (
1533  parent,
1534  name,
1535  url,
1536  canRead,
1537  canWrite,
1538  onload,
1539  onerror,
1540  dontCreateFile,
1541  canOwn,
1542  preFinish
1543) => {
1544  var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;
1545  var dep = getUniqueRunDependency(`cp ${fullname}`);
1546  function processData(byteArray) {
1547    function finish(byteArray) {
1548      preFinish?.();
1549      if (!dontCreateFile) {
1550        FS_createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);
1551      }
1552      onload?.();
1553      removeRunDependency(dep);
1554    }
1555    if (
1556      FS_handledByPreloadPlugin(byteArray, fullname, finish, () => {
1557        onerror?.();
1558        removeRunDependency(dep);
1559      })
1560    ) {
1561      return;
1562    }
1563    finish(byteArray);
1564  }
1565  addRunDependency(dep);
1566  if (typeof url == "string") {
1567    asyncLoad(url).then(processData, onerror);
1568  } else {
1569    processData(url);
1570  }
1571};
1572var FS_modeStringToFlags = (str) => {
1573  var flagModes = {
1574    r: 0,
1575    "r+": 2,
1576    w: 512 | 64 | 1,
1577    "w+": 512 | 64 | 2,
1578    a: 1024 | 64 | 1,
1579    "a+": 1024 | 64 | 2,
1580  };
1581  var flags = flagModes[str];
1582  if (typeof flags == "undefined") {
1583    throw new Error(`Unknown file open mode: ${str}`);
1584  }
1585  return flags;
1586};
1587var FS_getMode = (canRead, canWrite) => {
1588  var mode = 0;
1589  if (canRead) mode |= 292 | 73;
1590  if (canWrite) mode |= 146;
1591  return mode;
1592};
1593var FS = {
1594  root: null,
1595  mounts: [],
1596  devices: {},
1597  streams: [],
1598  nextInode: 1,
1599  nameTable: null,
1600  currentPath: "/",
1601  initialized: false,
1602  ignorePermissions: true,
1603  ErrnoError: class {
1604    name = "ErrnoError";
1605    constructor(errno) {
1606      this.errno = errno;
1607    }
1608  },
1609  filesystems: null,
1610  syncFSRequests: 0,
1611  readFiles: {},
1612  FSStream: class {
1613    shared = {};
1614    get object() {
1615      return this.node;
1616    }
1617    set object(val) {
1618      this.node = val;
1619    }
1620    get isRead() {
1621      return (this.flags & 2097155) !== 1;
1622    }
1623    get isWrite() {
1624      return (this.flags & 2097155) !== 0;
1625    }
1626    get isAppend() {
1627      return this.flags & 1024;
1628    }
1629    get flags() {
1630      return this.shared.flags;
1631    }
1632    set flags(val) {
1633      this.shared.flags = val;
1634    }
1635    get position() {
1636      return this.shared.position;
1637    }
1638    set position(val) {
1639      this.shared.position = val;
1640    }
1641  },
1642  FSNode: class {
1643    node_ops = {};
1644    stream_ops = {};
1645    readMode = 292 | 73;
1646    writeMode = 146;
1647    mounted = null;
1648    constructor(parent, name, mode, rdev) {
1649      if (!parent) {
1650        parent = this;
1651      }
1652      this.parent = parent;
1653      this.mount = parent.mount;
1654      this.id = FS.nextInode++;
1655      this.name = name;
1656      this.mode = mode;
1657      this.rdev = rdev;
1658      this.atime = this.mtime = this.ctime = Date.now();
1659    }
1660    get read() {
1661      return (this.mode & this.readMode) === this.readMode;
1662    }
1663    set read(val) {
1664      val ? (this.mode |= this.readMode) : (this.mode &= ~this.readMode);
1665    }
1666    get write() {
1667      return (this.mode & this.writeMode) === this.writeMode;
1668    }
1669    set write(val) {
1670      val ? (this.mode |= this.writeMode) : (this.mode &= ~this.writeMode);
1671    }
1672    get isFolder() {
1673      return FS.isDir(this.mode);
1674    }
1675    get isDevice() {
1676      return FS.isChrdev(this.mode);
1677    }
1678  },
1679  lookupPath(path, opts = {}) {
1680    if (!path) {
1681      throw new FS.ErrnoError(44);
1682    }
1683    opts.follow_mount ??= true;
1684    if (!PATH.isAbs(path)) {
1685      path = FS.cwd() + "/" + path;
1686    }
1687    linkloop: for (var nlinks = 0; nlinks < 40; nlinks++) {
1688      var parts = path.split("/").filter((p) => !!p);
1689      var current = FS.root;
1690      var current_path = "/";
1691      for (var i = 0; i < parts.length; i++) {
1692        var islast = i === parts.length - 1;
1693        if (islast && opts.parent) {
1694          break;
1695        }
1696        if (parts[i] === ".") {
1697          continue;
1698        }
1699        if (parts[i] === "..") {
1700          current_path = PATH.dirname(current_path);
1701          current = current.parent;
1702          continue;
1703        }
1704        current_path = PATH.join2(current_path, parts[i]);
1705        try {
1706          current = FS.lookupNode(current, parts[i]);
1707        } catch (e) {
1708          if (e?.errno === 44 && islast && opts.noent_okay) {
1709            return { path: current_path };
1710          }
1711          throw e;
1712        }
1713        if (FS.isMountpoint(current) && (!islast || opts.follow_mount)) {
1714          current = current.mounted.root;
1715        }
1716        if (FS.isLink(current.mode) && (!islast || opts.follow)) {
1717          if (!current.node_ops.readlink) {
1718            throw new FS.ErrnoError(52);
1719          }
1720          var link = current.node_ops.readlink(current);
1721          if (!PATH.isAbs(link)) {
1722            link = PATH.dirname(current_path) + "/" + link;
1723          }
1724          path = link + "/" + parts.slice(i + 1).join("/");
1725          continue linkloop;
1726        }
1727      }
1728      return { path: current_path, node: current };
1729    }
1730    throw new FS.ErrnoError(32);
1731  },
1732  getPath(node) {
1733    var path;
1734    while (true) {
1735      if (FS.isRoot(node)) {
1736        var mount = node.mount.mountpoint;
1737        if (!path) return mount;
1738        return mount[mount.length - 1] !== "/"
1739          ? `${mount}/${path}`
1740          : mount + path;
1741      }
1742      path = path ? `${node.name}/${path}` : node.name;
1743      node = node.parent;
1744    }
1745  },
1746  hashName(parentid, name) {
1747    var hash = 0;
1748    for (var i = 0; i < name.length; i++) {
1749      hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;
1750    }
1751    return ((parentid + hash) >>> 0) % FS.nameTable.length;
1752  },
1753  hashAddNode(node) {
1754    var hash = FS.hashName(node.parent.id, node.name);
1755    node.name_next = FS.nameTable[hash];
1756    FS.nameTable[hash] = node;
1757  },
1758  hashRemoveNode(node) {
1759    var hash = FS.hashName(node.parent.id, node.name);
1760    if (FS.nameTable[hash] === node) {
1761      FS.nameTable[hash] = node.name_next;
1762    } else {
1763      var current = FS.nameTable[hash];
1764      while (current) {
1765        if (current.name_next === node) {
1766          current.name_next = node.name_next;
1767          break;
1768        }
1769        current = current.name_next;
1770      }
1771    }
1772  },
1773  lookupNode(parent, name) {
1774    var errCode = FS.mayLookup(parent);
1775    if (errCode) {
1776      throw new FS.ErrnoError(errCode);
1777    }
1778    var hash = FS.hashName(parent.id, name);
1779    for (var node = FS.nameTable[hash]; node; node = node.name_next) {
1780      var nodeName = node.name;
1781      if (node.parent.id === parent.id && nodeName === name) {
1782        return node;
1783      }
1784    }
1785    return FS.lookup(parent, name);
1786  },
1787  createNode(parent, name, mode, rdev) {
1788    var node = new FS.FSNode(parent, name, mode, rdev);
1789    FS.hashAddNode(node);
1790    return node;
1791  },
1792  destroyNode(node) {
1793    FS.hashRemoveNode(node);
1794  },
1795  isRoot(node) {
1796    return node === node.parent;
1797  },
1798  isMountpoint(node) {
1799    return !!node.mounted;
1800  },
1801  isFile(mode) {
1802    return (mode & 61440) === 32768;
1803  },
1804  isDir(mode) {
1805    return (mode & 61440) === 16384;
1806  },
1807  isLink(mode) {
1808    return (mode & 61440) === 40960;
1809  },
1810  isChrdev(mode) {
1811    return (mode & 61440) === 8192;
1812  },
1813  isBlkdev(mode) {
1814    return (mode & 61440) === 24576;
1815  },
1816  isFIFO(mode) {
1817    return (mode & 61440) === 4096;
1818  },
1819  isSocket(mode) {
1820    return (mode & 49152) === 49152;
1821  },
1822  flagsToPermissionString(flag) {
1823    var perms = ["r", "w", "rw"][flag & 3];
1824    if (flag & 512) {
1825      perms += "w";
1826    }
1827    return perms;
1828  },
1829  nodePermissions(node, perms) {
1830    if (FS.ignorePermissions) {
1831      return 0;
1832    }
1833    if (perms.includes("r") && !(node.mode & 292)) {
1834      return 2;
1835    } else if (perms.includes("w") && !(node.mode & 146)) {
1836      return 2;
1837    } else if (perms.includes("x") && !(node.mode & 73)) {
1838      return 2;
1839    }
1840    return 0;
1841  },
1842  mayLookup(dir) {
1843    if (!FS.isDir(dir.mode)) return 54;
1844    var errCode = FS.nodePermissions(dir, "x");
1845    if (errCode) return errCode;
1846    if (!dir.node_ops.lookup) return 2;
1847    return 0;
1848  },
1849  mayCreate(dir, name) {
1850    if (!FS.isDir(dir.mode)) {
1851      return 54;
1852    }
1853    try {
1854      var node = FS.lookupNode(dir, name);
1855      return 20;
1856    } catch (e) {}
1857    return FS.nodePermissions(dir, "wx");
1858  },
1859  mayDelete(dir, name, isdir) {
1860    var node;
1861    try {
1862      node = FS.lookupNode(dir, name);
1863    } catch (e) {
1864      return e.errno;
1865    }
1866    var errCode = FS.nodePermissions(dir, "wx");
1867    if (errCode) {
1868      return errCode;
1869    }
1870    if (isdir) {
1871      if (!FS.isDir(node.mode)) {
1872        return 54;
1873      }
1874      if (FS.isRoot(node) || FS.getPath(node) === FS.cwd()) {
1875        return 10;
1876      }
1877    } else {
1878      if (FS.isDir(node.mode)) {
1879        return 31;
1880      }
1881    }
1882    return 0;
1883  },
1884  mayOpen(node, flags) {
1885    if (!node) {
1886      return 44;
1887    }
1888    if (FS.isLink(node.mode)) {
1889      return 32;
1890    } else if (FS.isDir(node.mode)) {
1891      if (FS.flagsToPermissionString(flags) !== "r" || flags & (512 | 64)) {
1892        return 31;
1893      }
1894    }
1895    return FS.nodePermissions(node, FS.flagsToPermissionString(flags));
1896  },
1897  checkOpExists(op, err) {
1898    if (!op) {
1899      throw new FS.ErrnoError(err);
1900    }
1901    return op;
1902  },
1903  MAX_OPEN_FDS: 4096,
1904  nextfd() {
1905    for (var fd = 0; fd <= FS.MAX_OPEN_FDS; fd++) {
1906      if (!FS.streams[fd]) {
1907        return fd;
1908      }
1909    }
1910    throw new FS.ErrnoError(33);
1911  },
1912  getStreamChecked(fd) {
1913    var stream = FS.getStream(fd);
1914    if (!stream) {
1915      throw new FS.ErrnoError(8);
1916    }
1917    return stream;
1918  },
1919  getStream: (fd) => FS.streams[fd],
1920  createStream(stream, fd = -1) {
1921    stream = Object.assign(new FS.FSStream(), stream);
1922    if (fd == -1) {
1923      fd = FS.nextfd();
1924    }
1925    stream.fd = fd;
1926    FS.streams[fd] = stream;
1927    return stream;
1928  },
1929  closeStream(fd) {
1930    FS.streams[fd] = null;
1931  },
1932  dupStream(origStream, fd = -1) {
1933    var stream = FS.createStream(origStream, fd);
1934    stream.stream_ops?.dup?.(stream);
1935    return stream;
1936  },
1937  doSetAttr(stream, node, attr) {
1938    var setattr = stream?.stream_ops.setattr;
1939    var arg = setattr ? stream : node;
1940    setattr ??= node.node_ops.setattr;
1941    FS.checkOpExists(setattr, 63);
1942    setattr(arg, attr);
1943  },
1944  chrdev_stream_ops: {
1945    open(stream) {
1946      var device = FS.getDevice(stream.node.rdev);
1947      stream.stream_ops = device.stream_ops;
1948      stream.stream_ops.open?.(stream);
1949    },
1950    llseek() {
1951      throw new FS.ErrnoError(70);
1952    },
1953  },
1954  major: (dev) => dev >> 8,
1955  minor: (dev) => dev & 255,
1956  makedev: (ma, mi) => (ma << 8) | mi,
1957  registerDevice(dev, ops) {
1958    FS.devices[dev] = { stream_ops: ops };
1959  },
1960  getDevice: (dev) => FS.devices[dev],
1961  getMounts(mount) {
1962    var mounts = [];
1963    var check = [mount];
1964    while (check.length) {
1965      var m = check.pop();
1966      mounts.push(m);
1967      check.push(...m.mounts);
1968    }
1969    return mounts;
1970  },
1971  syncfs(populate, callback) {
1972    if (typeof populate == "function") {
1973      callback = populate;
1974      populate = false;
1975    }
1976    FS.syncFSRequests++;
1977    if (FS.syncFSRequests > 1) {
1978      err(
1979        `warning: ${FS.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`
1980      );
1981    }
1982    var mounts = FS.getMounts(FS.root.mount);
1983    var completed = 0;
1984    function doCallback(errCode) {
1985      FS.syncFSRequests--;
1986      return callback(errCode);
1987    }
1988    function done(errCode) {
1989      if (errCode) {
1990        if (!done.errored) {
1991          done.errored = true;
1992          return doCallback(errCode);
1993        }
1994        return;
1995      }
1996      if (++completed >= mounts.length) {
1997        doCallback(null);
1998      }
1999    }
2000    mounts.forEach((mount) => {
2001      if (!mount.type.syncfs) {
2002        return done(null);
2003      }
2004      mount.type.syncfs(mount, populate, done);
2005    });
2006  },
2007  mount(type, opts, mountpoint) {
2008    var root = mountpoint === "/";
2009    var pseudo = !mountpoint;
2010    var node;
2011    if (root && FS.root) {
2012      throw new FS.ErrnoError(10);
2013    } else if (!root && !pseudo) {
2014      var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
2015      mountpoint = lookup.path;
2016      node = lookup.node;
2017      if (FS.isMountpoint(node)) {
2018        throw new FS.ErrnoError(10);
2019      }
2020      if (!FS.isDir(node.mode)) {
2021        throw new FS.ErrnoError(54);
2022      }
2023    }
2024    var mount = { type, opts, mountpoint, mounts: [] };
2025    var mountRoot = type.mount(mount);
2026    mountRoot.mount = mount;
2027    mount.root = mountRoot;
2028    if (root) {
2029      FS.root = mountRoot;
2030    } else if (node) {
2031      node.mounted = mount;
2032      if (node.mount) {
2033        node.mount.mounts.push(mount);
2034      }
2035    }
2036    return mountRoot;
2037  },
2038  unmount(mountpoint) {
2039    var lookup = FS.lookupPath(mountpoint, { follow_mount: false });
2040    if (!FS.isMountpoint(lookup.node)) {
2041      throw new FS.ErrnoError(28);
2042    }
2043    var node = lookup.node;
vendor: 6,601 bytes, lines 2044-2281
2044    var mount = node.mounted;
2045    var mounts = FS.getMounts(mount);
2046    Object.keys(FS.nameTable).forEach((hash) => {
2047      var current = FS.nameTable[hash];
2048      while (current) {
2049        var next = current.name_next;
2050        if (mounts.includes(current.mount)) {
2051          FS.destroyNode(current);
2052        }
2053        current = next;
2054      }
2055    });
2056    node.mounted = null;
2057    var idx = node.mount.mounts.indexOf(mount);
2058    node.mount.mounts.splice(idx, 1);
2059  },
2060  lookup(parent, name) {
2061    return parent.node_ops.lookup(parent, name);
2062  },
2063  mknod(path, mode, dev) {
2064    var lookup = FS.lookupPath(path, { parent: true });
2065    var parent = lookup.node;
2066    var name = PATH.basename(path);
2067    if (!name) {
2068      throw new FS.ErrnoError(28);
2069    }
2070    if (name === "." || name === "..") {
2071      throw new FS.ErrnoError(20);
2072    }
2073    var errCode = FS.mayCreate(parent, name);
2074    if (errCode) {
2075      throw new FS.ErrnoError(errCode);
2076    }
2077    if (!parent.node_ops.mknod) {
2078      throw new FS.ErrnoError(63);
2079    }
2080    return parent.node_ops.mknod(parent, name, mode, dev);
2081  },
2082  statfs(path) {
2083    return FS.statfsNode(FS.lookupPath(path, { follow: true }).node);
2084  },
2085  statfsStream(stream) {
2086    return FS.statfsNode(stream.node);
2087  },
2088  statfsNode(node) {
2089    var rtn = {
2090      bsize: 4096,
2091      frsize: 4096,
2092      blocks: 1e6,
2093      bfree: 5e5,
2094      bavail: 5e5,
2095      files: FS.nextInode,
2096      ffree: FS.nextInode - 1,
2097      fsid: 42,
2098      flags: 2,
2099      namelen: 255,
2100    };
2101    if (node.node_ops.statfs) {
2102      Object.assign(rtn, node.node_ops.statfs(node.mount.opts.root));
2103    }
2104    return rtn;
2105  },
2106  create(path, mode = 438) {
2107    mode &= 4095;
2108    mode |= 32768;
2109    return FS.mknod(path, mode, 0);
2110  },
2111  mkdir(path, mode = 511) {
2112    mode &= 511 | 512;
2113    mode |= 16384;
2114    return FS.mknod(path, mode, 0);
2115  },
2116  mkdirTree(path, mode) {
2117    var dirs = path.split("/");
2118    var d = "";
2119    for (var i = 0; i < dirs.length; ++i) {
2120      if (!dirs[i]) continue;
2121      d += "/" + dirs[i];
2122      try {
2123        FS.mkdir(d, mode);
2124      } catch (e) {
2125        if (e.errno != 20) throw e;
2126      }
2127    }
2128  },
2129  mkdev(path, mode, dev) {
2130    if (typeof dev == "undefined") {
2131      dev = mode;
2132      mode = 438;
2133    }
2134    mode |= 8192;
2135    return FS.mknod(path, mode, dev);
2136  },
2137  symlink(oldpath, newpath) {
2138    if (!PATH_FS.resolve(oldpath)) {
2139      throw new FS.ErrnoError(44);
2140    }
2141    var lookup = FS.lookupPath(newpath, { parent: true });
2142    var parent = lookup.node;
2143    if (!parent) {
2144      throw new FS.ErrnoError(44);
2145    }
2146    var newname = PATH.basename(newpath);
2147    var errCode = FS.mayCreate(parent, newname);
2148    if (errCode) {
2149      throw new FS.ErrnoError(errCode);
2150    }
2151    if (!parent.node_ops.symlink) {
2152      throw new FS.ErrnoError(63);
2153    }
2154    return parent.node_ops.symlink(parent, newname, oldpath);
2155  },
2156  rename(old_path, new_path) {
2157    var old_dirname = PATH.dirname(old_path);
2158    var new_dirname = PATH.dirname(new_path);
2159    var old_name = PATH.basename(old_path);
2160    var new_name = PATH.basename(new_path);
2161    var lookup, old_dir, new_dir;
2162    lookup = FS.lookupPath(old_path, { parent: true });
2163    old_dir = lookup.node;
2164    lookup = FS.lookupPath(new_path, { parent: true });
2165    new_dir = lookup.node;
2166    if (!old_dir || !new_dir) throw new FS.ErrnoError(44);
2167    if (old_dir.mount !== new_dir.mount) {
2168      throw new FS.ErrnoError(75);
2169    }
2170    var old_node = FS.lookupNode(old_dir, old_name);
2171    var relative = PATH_FS.relative(old_path, new_dirname);
2172    if (relative.charAt(0) !== ".") {
2173      throw new FS.ErrnoError(28);
2174    }
2175    relative = PATH_FS.relative(new_path, old_dirname);
2176    if (relative.charAt(0) !== ".") {
2177      throw new FS.ErrnoError(55);
2178    }
2179    var new_node;
2180    try {
2181      new_node = FS.lookupNode(new_dir, new_name);
2182    } catch (e) {}
2183    if (old_node === new_node) {
2184      return;
2185    }
2186    var isdir = FS.isDir(old_node.mode);
2187    var errCode = FS.mayDelete(old_dir, old_name, isdir);
2188    if (errCode) {
2189      throw new FS.ErrnoError(errCode);
2190    }
2191    errCode = new_node
2192      ? FS.mayDelete(new_dir, new_name, isdir)
2193      : FS.mayCreate(new_dir, new_name);
2194    if (errCode) {
2195      throw new FS.ErrnoError(errCode);
2196    }
2197    if (!old_dir.node_ops.rename) {
2198      throw new FS.ErrnoError(63);
2199    }
2200    if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {
2201      throw new FS.ErrnoError(10);
2202    }
2203    if (new_dir !== old_dir) {
2204      errCode = FS.nodePermissions(old_dir, "w");
2205      if (errCode) {
2206        throw new FS.ErrnoError(errCode);
2207      }
2208    }
2209    FS.hashRemoveNode(old_node);
2210    try {
2211      old_dir.node_ops.rename(old_node, new_dir, new_name);
2212      old_node.parent = new_dir;
2213    } catch (e) {
2214      throw e;
2215    } finally {
2216      FS.hashAddNode(old_node);
2217    }
2218  },
2219  rmdir(path) {
2220    var lookup = FS.lookupPath(path, { parent: true });
2221    var parent = lookup.node;
2222    var name = PATH.basename(path);
2223    var node = FS.lookupNode(parent, name);
2224    var errCode = FS.mayDelete(parent, name, true);
2225    if (errCode) {
2226      throw new FS.ErrnoError(errCode);
2227    }
2228    if (!parent.node_ops.rmdir) {
2229      throw new FS.ErrnoError(63);
2230    }
2231    if (FS.isMountpoint(node)) {
2232      throw new FS.ErrnoError(10);
2233    }
2234    parent.node_ops.rmdir(parent, name);
2235    FS.destroyNode(node);
2236  },
2237  readdir(path) {
2238    var lookup = FS.lookupPath(path, { follow: true });
2239    var node = lookup.node;
2240    var readdir = FS.checkOpExists(node.node_ops.readdir, 54);
2241    return readdir(node);
2242  },
2243  unlink(path) {
2244    var lookup = FS.lookupPath(path, { parent: true });
2245    var parent = lookup.node;
2246    if (!parent) {
2247      throw new FS.ErrnoError(44);
2248    }
2249    var name = PATH.basename(path);
2250    var node = FS.lookupNode(parent, name);
2251    var errCode = FS.mayDelete(parent, name, false);
2252    if (errCode) {
2253      throw new FS.ErrnoError(errCode);
2254    }
2255    if (!parent.node_ops.unlink) {
2256      throw new FS.ErrnoError(63);
2257    }
2258    if (FS.isMountpoint(node)) {
2259      throw new FS.ErrnoError(10);
2260    }
2261    parent.node_ops.unlink(parent, name);
2262    FS.destroyNode(node);
2263  },
2264  readlink(path) {
2265    var lookup = FS.lookupPath(path);
2266    var link = lookup.node;
2267    if (!link) {
2268      throw new FS.ErrnoError(44);
2269    }
2270    if (!link.node_ops.readlink) {
2271      throw new FS.ErrnoError(28);
2272    }
2273    return link.node_ops.readlink(link);
2274  },
2275  stat(path, dontFollow) {
2276    var lookup = FS.lookupPath(path, { follow: !dontFollow });
2277    var node = lookup.node;
2278    var getattr = FS.checkOpExists(node.node_ops.getattr, 63);
2279    return getattr(node);
2280  },
2281  fstat(fd) {
vendor: 25,653 bytes, lines 2282-3149
2282    var stream = FS.getStreamChecked(fd);
2283    var node = stream.node;
2284    var getattr = stream.stream_ops.getattr;
2285    var arg = getattr ? stream : node;
2286    getattr ??= node.node_ops.getattr;
2287    FS.checkOpExists(getattr, 63);
2288    return getattr(arg);
2289  },
2290  lstat(path) {
2291    return FS.stat(path, true);
2292  },
2293  doChmod(stream, node, mode, dontFollow) {
2294    FS.doSetAttr(stream, node, {
2295      mode: (mode & 4095) | (node.mode & ~4095),
2296      ctime: Date.now(),
2297      dontFollow,
2298    });
2299  },
2300  chmod(path, mode, dontFollow) {
2301    var node;
2302    if (typeof path == "string") {
2303      var lookup = FS.lookupPath(path, { follow: !dontFollow });
2304      node = lookup.node;
2305    } else {
2306      node = path;
2307    }
2308    FS.doChmod(null, node, mode, dontFollow);
2309  },
2310  lchmod(path, mode) {
2311    FS.chmod(path, mode, true);
2312  },
2313  fchmod(fd, mode) {
2314    var stream = FS.getStreamChecked(fd);
2315    FS.doChmod(stream, stream.node, mode, false);
2316  },
2317  doChown(stream, node, dontFollow) {
2318    FS.doSetAttr(stream, node, { timestamp: Date.now(), dontFollow });
2319  },
2320  chown(path, uid, gid, dontFollow) {
2321    var node;
2322    if (typeof path == "string") {
2323      var lookup = FS.lookupPath(path, { follow: !dontFollow });
2324      node = lookup.node;
2325    } else {
2326      node = path;
2327    }
2328    FS.doChown(null, node, dontFollow);
2329  },
2330  lchown(path, uid, gid) {
2331    FS.chown(path, uid, gid, true);
2332  },
2333  fchown(fd, uid, gid) {
2334    var stream = FS.getStreamChecked(fd);
2335    FS.doChown(stream, stream.node, false);
2336  },
2337  doTruncate(stream, node, len) {
2338    if (FS.isDir(node.mode)) {
2339      throw new FS.ErrnoError(31);
2340    }
2341    if (!FS.isFile(node.mode)) {
2342      throw new FS.ErrnoError(28);
2343    }
2344    var errCode = FS.nodePermissions(node, "w");
2345    if (errCode) {
2346      throw new FS.ErrnoError(errCode);
2347    }
2348    FS.doSetAttr(stream, node, { size: len, timestamp: Date.now() });
2349  },
2350  truncate(path, len) {
2351    if (len < 0) {
2352      throw new FS.ErrnoError(28);
2353    }
2354    var node;
2355    if (typeof path == "string") {
2356      var lookup = FS.lookupPath(path, { follow: true });
2357      node = lookup.node;
2358    } else {
2359      node = path;
2360    }
2361    FS.doTruncate(null, node, len);
2362  },
2363  ftruncate(fd, len) {
2364    var stream = FS.getStreamChecked(fd);
2365    if (len < 0 || (stream.flags & 2097155) === 0) {
2366      throw new FS.ErrnoError(28);
2367    }
2368    FS.doTruncate(stream, stream.node, len);
2369  },
2370  utime(path, atime, mtime) {
2371    var lookup = FS.lookupPath(path, { follow: true });
2372    var node = lookup.node;
2373    var setattr = FS.checkOpExists(node.node_ops.setattr, 63);
2374    setattr(node, { atime, mtime });
2375  },
2376  open(path, flags, mode = 438) {
2377    if (path === "") {
2378      throw new FS.ErrnoError(44);
2379    }
2380    flags = typeof flags == "string" ? FS_modeStringToFlags(flags) : flags;
2381    if (flags & 64) {
2382      mode = (mode & 4095) | 32768;
2383    } else {
2384      mode = 0;
2385    }
2386    var node;
2387    var isDirPath;
2388    if (typeof path == "object") {
2389      node = path;
2390    } else {
2391      isDirPath = path.endsWith("/");
2392      var lookup = FS.lookupPath(path, {
2393        follow: !(flags & 131072),
2394        noent_okay: true,
2395      });
2396      node = lookup.node;
2397      path = lookup.path;
2398    }
2399    var created = false;
2400    if (flags & 64) {
2401      if (node) {
2402        if (flags & 128) {
2403          throw new FS.ErrnoError(20);
2404        }
2405      } else if (isDirPath) {
2406        throw new FS.ErrnoError(31);
2407      } else {
2408        node = FS.mknod(path, mode | 511, 0);
2409        created = true;
2410      }
2411    }
2412    if (!node) {
2413      throw new FS.ErrnoError(44);
2414    }
2415    if (FS.isChrdev(node.mode)) {
2416      flags &= ~512;
2417    }
2418    if (flags & 65536 && !FS.isDir(node.mode)) {
2419      throw new FS.ErrnoError(54);
2420    }
2421    if (!created) {
2422      var errCode = FS.mayOpen(node, flags);
2423      if (errCode) {
2424        throw new FS.ErrnoError(errCode);
2425      }
2426    }
2427    if (flags & 512 && !created) {
2428      FS.truncate(node, 0);
2429    }
2430    flags &= ~(128 | 512 | 131072);
2431    var stream = FS.createStream({
2432      node,
2433      path: FS.getPath(node),
2434      flags,
2435      seekable: true,
2436      position: 0,
2437      stream_ops: node.stream_ops,
2438      ungotten: [],
2439      error: false,
2440    });
2441    if (stream.stream_ops.open) {
2442      stream.stream_ops.open(stream);
2443    }
2444    if (created) {
2445      FS.chmod(node, mode & 511);
2446    }
2447    if (Module["logReadFiles"] && !(flags & 1)) {
2448      if (!(path in FS.readFiles)) {
2449        FS.readFiles[path] = 1;
2450      }
2451    }
2452    return stream;
2453  },
2454  close(stream) {
2455    if (FS.isClosed(stream)) {
2456      throw new FS.ErrnoError(8);
2457    }
2458    if (stream.getdents) stream.getdents = null;
2459    try {
2460      if (stream.stream_ops.close) {
2461        stream.stream_ops.close(stream);
2462      }
2463    } catch (e) {
2464      throw e;
2465    } finally {
2466      FS.closeStream(stream.fd);
2467    }
2468    stream.fd = null;
2469  },
2470  isClosed(stream) {
2471    return stream.fd === null;
2472  },
2473  llseek(stream, offset, whence) {
2474    if (FS.isClosed(stream)) {
2475      throw new FS.ErrnoError(8);
2476    }
2477    if (!stream.seekable || !stream.stream_ops.llseek) {
2478      throw new FS.ErrnoError(70);
2479    }
2480    if (whence != 0 && whence != 1 && whence != 2) {
2481      throw new FS.ErrnoError(28);
2482    }
2483    stream.position = stream.stream_ops.llseek(stream, offset, whence);
2484    stream.ungotten = [];
2485    return stream.position;
2486  },
2487  read(stream, buffer, offset, length, position) {
2488    if (length < 0 || position < 0) {
2489      throw new FS.ErrnoError(28);
2490    }
2491    if (FS.isClosed(stream)) {
2492      throw new FS.ErrnoError(8);
2493    }
2494    if ((stream.flags & 2097155) === 1) {
2495      throw new FS.ErrnoError(8);
2496    }
2497    if (FS.isDir(stream.node.mode)) {
2498      throw new FS.ErrnoError(31);
2499    }
2500    if (!stream.stream_ops.read) {
2501      throw new FS.ErrnoError(28);
2502    }
2503    var seeking = typeof position != "undefined";
2504    if (!seeking) {
2505      position = stream.position;
2506    } else if (!stream.seekable) {
2507      throw new FS.ErrnoError(70);
2508    }
2509    var bytesRead = stream.stream_ops.read(
2510      stream,
2511      buffer,
2512      offset,
2513      length,
2514      position
2515    );
2516    if (!seeking) stream.position += bytesRead;
2517    return bytesRead;
2518  },
2519  write(stream, buffer, offset, length, position, canOwn) {
2520    if (length < 0 || position < 0) {
2521      throw new FS.ErrnoError(28);
2522    }
2523    if (FS.isClosed(stream)) {
2524      throw new FS.ErrnoError(8);
2525    }
2526    if ((stream.flags & 2097155) === 0) {
2527      throw new FS.ErrnoError(8);
2528    }
2529    if (FS.isDir(stream.node.mode)) {
2530      throw new FS.ErrnoError(31);
2531    }
2532    if (!stream.stream_ops.write) {
2533      throw new FS.ErrnoError(28);
2534    }
2535    if (stream.seekable && stream.flags & 1024) {
2536      FS.llseek(stream, 0, 2);
2537    }
2538    var seeking = typeof position != "undefined";
2539    if (!seeking) {
2540      position = stream.position;
2541    } else if (!stream.seekable) {
2542      throw new FS.ErrnoError(70);
2543    }
2544    var bytesWritten = stream.stream_ops.write(
2545      stream,
2546      buffer,
2547      offset,
2548      length,
2549      position,
2550      canOwn
2551    );
2552    if (!seeking) stream.position += bytesWritten;
2553    return bytesWritten;
2554  },
2555  allocate(stream, offset, length) {
2556    if (FS.isClosed(stream)) {
2557      throw new FS.ErrnoError(8);
2558    }
2559    if (offset < 0 || length <= 0) {
2560      throw new FS.ErrnoError(28);
2561    }
2562    if ((stream.flags & 2097155) === 0) {
2563      throw new FS.ErrnoError(8);
2564    }
2565    if (!FS.isFile(stream.node.mode) && !FS.isDir(stream.node.mode)) {
2566      throw new FS.ErrnoError(43);
2567    }
2568    if (!stream.stream_ops.allocate) {
2569      throw new FS.ErrnoError(138);
2570    }
2571    stream.stream_ops.allocate(stream, offset, length);
2572  },
2573  mmap(stream, length, position, prot, flags) {
2574    if (
2575      (prot & 2) !== 0 &&
2576      (flags & 2) === 0 &&
2577      (stream.flags & 2097155) !== 2
2578    ) {
2579      throw new FS.ErrnoError(2);
2580    }
2581    if ((stream.flags & 2097155) === 1) {
2582      throw new FS.ErrnoError(2);
2583    }
2584    if (!stream.stream_ops.mmap) {
2585      throw new FS.ErrnoError(43);
2586    }
2587    if (!length) {
2588      throw new FS.ErrnoError(28);
2589    }
2590    return stream.stream_ops.mmap(stream, length, position, prot, flags);
2591  },
2592  msync(stream, buffer, offset, length, mmapFlags) {
2593    if (!stream.stream_ops.msync) {
2594      return 0;
2595    }
2596    return stream.stream_ops.msync(stream, buffer, offset, length, mmapFlags);
2597  },
2598  ioctl(stream, cmd, arg) {
2599    if (!stream.stream_ops.ioctl) {
2600      throw new FS.ErrnoError(59);
2601    }
2602    return stream.stream_ops.ioctl(stream, cmd, arg);
2603  },
2604  readFile(path, opts = {}) {
2605    opts.flags = opts.flags || 0;
2606    opts.encoding = opts.encoding || "binary";
2607    if (opts.encoding !== "utf8" && opts.encoding !== "binary") {
2608      throw new Error(`Invalid encoding type "${opts.encoding}"`);
2609    }
2610    var ret;
2611    var stream = FS.open(path, opts.flags);
2612    var stat = FS.stat(path);
2613    var length = stat.size;
2614    var buf = new Uint8Array(length);
2615    FS.read(stream, buf, 0, length, 0);
2616    if (opts.encoding === "utf8") {
2617      ret = UTF8ArrayToString(buf);
2618    } else if (opts.encoding === "binary") {
2619      ret = buf;
2620    }
2621    FS.close(stream);
2622    return ret;
2623  },
2624  writeFile(path, data, opts = {}) {
2625    opts.flags = opts.flags || 577;
2626    var stream = FS.open(path, opts.flags, opts.mode);
2627    if (typeof data == "string") {
2628      var buf = new Uint8Array(lengthBytesUTF8(data) + 1);
2629      var actualNumBytes = stringToUTF8Array(data, buf, 0, buf.length);
2630      FS.write(stream, buf, 0, actualNumBytes, undefined, opts.canOwn);
2631    } else if (ArrayBuffer.isView(data)) {
2632      FS.write(stream, data, 0, data.byteLength, undefined, opts.canOwn);
2633    } else {
2634      throw new Error("Unsupported data type");
2635    }
2636    FS.close(stream);
2637  },
2638  cwd: () => FS.currentPath,
2639  chdir(path) {
2640    var lookup = FS.lookupPath(path, { follow: true });
2641    if (lookup.node === null) {
2642      throw new FS.ErrnoError(44);
2643    }
2644    if (!FS.isDir(lookup.node.mode)) {
2645      throw new FS.ErrnoError(54);
2646    }
2647    var errCode = FS.nodePermissions(lookup.node, "x");
2648    if (errCode) {
2649      throw new FS.ErrnoError(errCode);
2650    }
2651    FS.currentPath = lookup.path;
2652  },
2653  createDefaultDirectories() {
2654    FS.mkdir("/tmp");
2655    FS.mkdir("/home");
2656    FS.mkdir("/home/web_user");
2657  },
2658  createDefaultDevices() {
2659    FS.mkdir("/dev");
2660    FS.registerDevice(FS.makedev(1, 3), {
2661      read: () => 0,
2662      write: (stream, buffer, offset, length, pos) => length,
2663      llseek: () => 0,
2664    });
2665    FS.mkdev("/dev/null", FS.makedev(1, 3));
2666    TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);
2667    TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);
2668    FS.mkdev("/dev/tty", FS.makedev(5, 0));
2669    FS.mkdev("/dev/tty1", FS.makedev(6, 0));
2670    var randomBuffer = new Uint8Array(1024),
2671      randomLeft = 0;
2672    var randomByte = () => {
2673      if (randomLeft === 0) {
2674        randomFill(randomBuffer);
2675        randomLeft = randomBuffer.byteLength;
2676      }
2677      return randomBuffer[--randomLeft];
2678    };
2679    FS.createDevice("/dev", "random", randomByte);
2680    FS.createDevice("/dev", "urandom", randomByte);
2681    FS.mkdir("/dev/shm");
2682    FS.mkdir("/dev/shm/tmp");
2683  },
2684  createSpecialDirectories() {
2685    FS.mkdir("/proc");
2686    var proc_self = FS.mkdir("/proc/self");
2687    FS.mkdir("/proc/self/fd");
2688    FS.mount(
2689      {
2690        mount() {
2691          var node = FS.createNode(proc_self, "fd", 16895, 73);
2692          node.stream_ops = { llseek: MEMFS.stream_ops.llseek };
2693          node.node_ops = {
2694            lookup(parent, name) {
2695              var fd = +name;
2696              var stream = FS.getStreamChecked(fd);
2697              var ret = {
2698                parent: null,
2699                mount: { mountpoint: "fake" },
2700                node_ops: { readlink: () => stream.path },
2701                id: fd + 1,
2702              };
2703              ret.parent = ret;
2704              return ret;
2705            },
2706            readdir() {
2707              return Array.from(FS.streams.entries())
2708                .filter(([k, v]) => v)
2709                .map(([k, v]) => k.toString());
2710            },
2711          };
2712          return node;
2713        },
2714      },
2715      {},
2716      "/proc/self/fd"
2717    );
2718  },
2719  createStandardStreams(input, output, error) {
2720    if (input) {
2721      FS.createDevice("/dev", "stdin", input);
2722    } else {
2723      FS.symlink("/dev/tty", "/dev/stdin");
2724    }
2725    if (output) {
2726      FS.createDevice("/dev", "stdout", null, output);
2727    } else {
2728      FS.symlink("/dev/tty", "/dev/stdout");
2729    }
2730    if (error) {
2731      FS.createDevice("/dev", "stderr", null, error);
2732    } else {
2733      FS.symlink("/dev/tty1", "/dev/stderr");
2734    }
2735    var stdin = FS.open("/dev/stdin", 0);
2736    var stdout = FS.open("/dev/stdout", 1);
2737    var stderr = FS.open("/dev/stderr", 1);
2738  },
2739  staticInit() {
2740    FS.nameTable = new Array(4096);
2741    FS.mount(MEMFS, {}, "/");
2742    FS.createDefaultDirectories();
2743    FS.createDefaultDevices();
2744    FS.createSpecialDirectories();
2745    FS.filesystems = { MEMFS };
2746  },
2747  init(input, output, error) {
2748    FS.initialized = true;
2749    input ??= Module["stdin"];
2750    output ??= Module["stdout"];
2751    error ??= Module["stderr"];
2752    FS.createStandardStreams(input, output, error);
2753  },
2754  quit() {
2755    FS.initialized = false;
2756    for (var i = 0; i < FS.streams.length; i++) {
2757      var stream = FS.streams[i];
2758      if (!stream) {
2759        continue;
2760      }
2761      FS.close(stream);
2762    }
2763  },
2764  findObject(path, dontResolveLastLink) {
2765    var ret = FS.analyzePath(path, dontResolveLastLink);
2766    if (!ret.exists) {
2767      return null;
2768    }
2769    return ret.object;
2770  },
2771  analyzePath(path, dontResolveLastLink) {
2772    try {
2773      var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
2774      path = lookup.path;
2775    } catch (e) {}
2776    var ret = {
2777      isRoot: false,
2778      exists: false,
2779      error: 0,
2780      name: null,
2781      path: null,
2782      object: null,
2783      parentExists: false,
2784      parentPath: null,
2785      parentObject: null,
2786    };
2787    try {
2788      var lookup = FS.lookupPath(path, { parent: true });
2789      ret.parentExists = true;
2790      ret.parentPath = lookup.path;
2791      ret.parentObject = lookup.node;
2792      ret.name = PATH.basename(path);
2793      lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });
2794      ret.exists = true;
2795      ret.path = lookup.path;
2796      ret.object = lookup.node;
2797      ret.name = lookup.node.name;
2798      ret.isRoot = lookup.path === "/";
2799    } catch (e) {
2800      ret.error = e.errno;
2801    }
2802    return ret;
2803  },
2804  createPath(parent, path, canRead, canWrite) {
2805    parent = typeof parent == "string" ? parent : FS.getPath(parent);
2806    var parts = path.split("/").reverse();
2807    while (parts.length) {
2808      var part = parts.pop();
2809      if (!part) continue;
2810      var current = PATH.join2(parent, part);
2811      try {
2812        FS.mkdir(current);
2813      } catch (e) {}
2814      parent = current;
2815    }
2816    return current;
2817  },
2818  createFile(parent, name, properties, canRead, canWrite) {
2819    var path = PATH.join2(
2820      typeof parent == "string" ? parent : FS.getPath(parent),
2821      name
2822    );
2823    var mode = FS_getMode(canRead, canWrite);
2824    return FS.create(path, mode);
2825  },
2826  createDataFile(parent, name, data, canRead, canWrite, canOwn) {
2827    var path = name;
2828    if (parent) {
2829      parent = typeof parent == "string" ? parent : FS.getPath(parent);
2830      path = name ? PATH.join2(parent, name) : parent;
2831    }
2832    var mode = FS_getMode(canRead, canWrite);
2833    var node = FS.create(path, mode);
2834    if (data) {
2835      if (typeof data == "string") {
2836        var arr = new Array(data.length);
2837        for (var i = 0, len = data.length; i < len; ++i)
2838          arr[i] = data.charCodeAt(i);
2839        data = arr;
2840      }
2841      FS.chmod(node, mode | 146);
2842      var stream = FS.open(node, 577);
2843      FS.write(stream, data, 0, data.length, 0, canOwn);
2844      FS.close(stream);
2845      FS.chmod(node, mode);
2846    }
2847  },
2848  createDevice(parent, name, input, output) {
2849    var path = PATH.join2(
2850      typeof parent == "string" ? parent : FS.getPath(parent),
2851      name
2852    );
2853    var mode = FS_getMode(!!input, !!output);
2854    FS.createDevice.major ??= 64;
2855    var dev = FS.makedev(FS.createDevice.major++, 0);
2856    FS.registerDevice(dev, {
2857      open(stream) {
2858        stream.seekable = false;
2859      },
2860      close(stream) {
2861        if (output?.buffer?.length) {
2862          output(10);
2863        }
2864      },
2865      read(stream, buffer, offset, length, pos) {
2866        var bytesRead = 0;
2867        for (var i = 0; i < length; i++) {
2868          var result;
2869          try {
2870            result = input();
2871          } catch (e) {
2872            throw new FS.ErrnoError(29);
2873          }
2874          if (result === undefined && bytesRead === 0) {
2875            throw new FS.ErrnoError(6);
2876          }
2877          if (result === null || result === undefined) break;
2878          bytesRead++;
2879          buffer[offset + i] = result;
2880        }
2881        if (bytesRead) {
2882          stream.node.atime = Date.now();
2883        }
2884        return bytesRead;
2885      },
2886      write(stream, buffer, offset, length, pos) {
2887        for (var i = 0; i < length; i++) {
2888          try {
2889            output(buffer[offset + i]);
2890          } catch (e) {
2891            throw new FS.ErrnoError(29);
2892          }
2893        }
2894        if (length) {
2895          stream.node.mtime = stream.node.ctime = Date.now();
2896        }
2897        return i;
2898      },
2899    });
2900    return FS.mkdev(path, mode, dev);
2901  },
2902  forceLoadFile(obj) {
2903    if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;
2904    if (typeof XMLHttpRequest != "undefined") {
2905      throw new Error(
2906        "Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread."
2907      );
2908    } else {
2909      try {
2910        obj.contents = readBinary(obj.url);
2911        obj.usedBytes = obj.contents.length;
2912      } catch (e) {
2913        throw new FS.ErrnoError(29);
2914      }
2915    }
2916  },
2917  createLazyFile(parent, name, url, canRead, canWrite) {
2918    class LazyUint8Array {
2919      lengthKnown = false;
2920      chunks = [];
2921      get(idx) {
2922        if (idx > this.length - 1 || idx < 0) {
2923          return undefined;
2924        }
2925        var chunkOffset = idx % this.chunkSize;
2926        var chunkNum = (idx / this.chunkSize) | 0;
2927        return this.getter(chunkNum)[chunkOffset];
2928      }
2929      setDataGetter(getter) {
2930        this.getter = getter;
2931      }
2932      cacheLength() {
2933        var xhr = new XMLHttpRequest();
2934        xhr.open("HEAD", url, false);
2935        xhr.send(null);
2936        if (!((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304))
2937          throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
2938        var datalength = Number(xhr.getResponseHeader("Content-length"));
2939        var header;
2940        var hasByteServing =
2941          (header = xhr.getResponseHeader("Accept-Ranges")) &&
2942          header === "bytes";
2943        var usesGzip =
2944          (header = xhr.getResponseHeader("Content-Encoding")) &&
2945          header === "gzip";
2946        var chunkSize = 1024 * 1024;
2947        if (!hasByteServing) chunkSize = datalength;
2948        var doXHR = (from, to) => {
2949          if (from > to)
2950            throw new Error(
2951              "invalid range (" + from + ", " + to + ") or no bytes requested!"
2952            );
2953          if (to > datalength - 1)
2954            throw new Error(
2955              "only " + datalength + " bytes available! programmer error!"
2956            );
2957          var xhr = new XMLHttpRequest();
2958          xhr.open("GET", url, false);
2959          if (datalength !== chunkSize)
2960            xhr.setRequestHeader("Range", "bytes=" + from + "-" + to);
2961          xhr.responseType = "arraybuffer";
2962          if (xhr.overrideMimeType) {
2963            xhr.overrideMimeType("text/plain; charset=x-user-defined");
2964          }
2965          xhr.send(null);
2966          if (!((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304))
2967            throw new Error("Couldn't load " + url + ". Status: " + xhr.status);
2968          if (xhr.response !== undefined) {
2969            return new Uint8Array(xhr.response || []);
2970          }
2971          return intArrayFromString(xhr.responseText || "", true);
2972        };
2973        var lazyArray = this;
2974        lazyArray.setDataGetter((chunkNum) => {
2975          var start = chunkNum * chunkSize;
2976          var end = (chunkNum + 1) * chunkSize - 1;
2977          end = Math.min(end, datalength - 1);
2978          if (typeof lazyArray.chunks[chunkNum] == "undefined") {
2979            lazyArray.chunks[chunkNum] = doXHR(start, end);
2980          }
2981          if (typeof lazyArray.chunks[chunkNum] == "undefined")
2982            throw new Error("doXHR failed!");
2983          return lazyArray.chunks[chunkNum];
2984        });
2985        if (usesGzip || !datalength) {
2986          chunkSize = datalength = 1;
2987          datalength = this.getter(0).length;
2988          chunkSize = datalength;
2989          out(
2990            "LazyFiles on gzip forces download of the whole file when length is accessed"
2991          );
2992        }
2993        this._length = datalength;
2994        this._chunkSize = chunkSize;
2995        this.lengthKnown = true;
2996      }
2997      get length() {
2998        if (!this.lengthKnown) {
2999          this.cacheLength();
3000        }
3001        return this._length;
3002      }
3003      get chunkSize() {
3004        if (!this.lengthKnown) {
3005          this.cacheLength();
3006        }
3007        return this._chunkSize;
3008      }
3009    }
3010    if (typeof XMLHttpRequest != "undefined") {
3011      if (!ENVIRONMENT_IS_WORKER)
3012        throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";
3013      var lazyArray = new LazyUint8Array();
3014      var properties = { isDevice: false, contents: lazyArray };
3015    } else {
3016      var properties = { isDevice: false, url };
3017    }
3018    var node = FS.createFile(parent, name, properties, canRead, canWrite);
3019    if (properties.contents) {
3020      node.contents = properties.contents;
3021    } else if (properties.url) {
3022      node.contents = null;
3023      node.url = properties.url;
3024    }
3025    Object.defineProperties(node, {
3026      usedBytes: {
3027        get: function () {
3028          return this.contents.length;
3029        },
3030      },
3031    });
3032    var stream_ops = {};
3033    var keys = Object.keys(node.stream_ops);
3034    keys.forEach((key) => {
3035      var fn = node.stream_ops[key];
3036      stream_ops[key] = (...args) => {
3037        FS.forceLoadFile(node);
3038        return fn(...args);
3039      };
3040    });
3041    function writeChunks(stream, buffer, offset, length, position) {
3042      var contents = stream.node.contents;
3043      if (position >= contents.length) return 0;
3044      var size = Math.min(contents.length - position, length);
3045      if (contents.slice) {
3046        for (var i = 0; i < size; i++) {
3047          buffer[offset + i] = contents[position + i];
3048        }
3049      } else {
3050        for (var i = 0; i < size; i++) {
3051          buffer[offset + i] = contents.get(position + i);
3052        }
3053      }
3054      return size;
3055    }
3056    stream_ops.read = (stream, buffer, offset, length, position) => {
3057      FS.forceLoadFile(node);
3058      return writeChunks(stream, buffer, offset, length, position);
3059    };
3060    stream_ops.mmap = (stream, length, position, prot, flags) => {
3061      FS.forceLoadFile(node);
3062      var ptr = mmapAlloc(length);
3063      if (!ptr) {
3064        throw new FS.ErrnoError(48);
3065      }
3066      writeChunks(stream, HEAP8, ptr, length, position);
3067      return { ptr, allocated: true };
3068    };
3069    node.stream_ops = stream_ops;
3070    return node;
3071  },
3072};
3073var SYSCALLS = {
3074  DEFAULT_POLLMASK: 5,
3075  calculateAt(dirfd, path, allowEmpty) {
3076    if (PATH.isAbs(path)) {
3077      return path;
3078    }
3079    var dir;
3080    if (dirfd === -100) {
3081      dir = FS.cwd();
3082    } else {
3083      var dirstream = SYSCALLS.getStreamFromFD(dirfd);
3084      dir = dirstream.path;
3085    }
3086    if (path.length == 0) {
3087      if (!allowEmpty) {
3088        throw new FS.ErrnoError(44);
3089      }
3090      return dir;
3091    }
3092    return dir + "/" + path;
3093  },
3094  writeStat(buf, stat) {
3095    HEAP32[buf >> 2] = stat.dev;
3096    HEAP32[(buf + 4) >> 2] = stat.mode;
3097    HEAPU32[(buf + 8) >> 2] = stat.nlink;
3098    HEAP32[(buf + 12) >> 2] = stat.uid;
3099    HEAP32[(buf + 16) >> 2] = stat.gid;
3100    HEAP32[(buf + 20) >> 2] = stat.rdev;
3101    HEAP64[(buf + 24) >> 3] = BigInt(stat.size);
3102    HEAP32[(buf + 32) >> 2] = 4096;
3103    HEAP32[(buf + 36) >> 2] = stat.blocks;
3104    var atime = stat.atime.getTime();
3105    var mtime = stat.mtime.getTime();
3106    var ctime = stat.ctime.getTime();
3107    HEAP64[(buf + 40) >> 3] = BigInt(Math.floor(atime / 1e3));
3108    HEAPU32[(buf + 48) >> 2] = (atime % 1e3) * 1e3 * 1e3;
3109    HEAP64[(buf + 56) >> 3] = BigInt(Math.floor(mtime / 1e3));
3110    HEAPU32[(buf + 64) >> 2] = (mtime % 1e3) * 1e3 * 1e3;
3111    HEAP64[(buf + 72) >> 3] = BigInt(Math.floor(ctime / 1e3));
3112    HEAPU32[(buf + 80) >> 2] = (ctime % 1e3) * 1e3 * 1e3;
3113    HEAP64[(buf + 88) >> 3] = BigInt(stat.ino);
3114    return 0;
3115  },
3116  writeStatFs(buf, stats) {
3117    HEAP32[(buf + 4) >> 2] = stats.bsize;
3118    HEAP32[(buf + 40) >> 2] = stats.bsize;
3119    HEAP32[(buf + 8) >> 2] = stats.blocks;
3120    HEAP32[(buf + 12) >> 2] = stats.bfree;
3121    HEAP32[(buf + 16) >> 2] = stats.bavail;
3122    HEAP32[(buf + 20) >> 2] = stats.files;
3123    HEAP32[(buf + 24) >> 2] = stats.ffree;
3124    HEAP32[(buf + 28) >> 2] = stats.fsid;
3125    HEAP32[(buf + 44) >> 2] = stats.flags;
3126    HEAP32[(buf + 36) >> 2] = stats.namelen;
3127  },
3128  doMsync(addr, stream, len, flags, offset) {
3129    if (!FS.isFile(stream.node.mode)) {
3130      throw new FS.ErrnoError(43);
3131    }
3132    if (flags & 2) {
3133      return 0;
3134    }
3135    var buffer = HEAPU8.slice(addr, addr + len);
3136    FS.msync(stream, buffer, offset, len, flags);
3137  },
3138  getStreamFromFD(fd) {
3139    var stream = FS.getStreamChecked(fd);
3140    return stream;
3141  },
3142  varargs: undefined,
3143  getStr(ptr) {
3144    var ret = UTF8ToString(ptr);
3145    return ret;
3146  },
3147};
3148function ___syscall_chdir(path) {
3149  try {
3150    path = SYSCALLS.getStr(path);
3151    FS.chdir(path);
3152    return 0;
3153  } catch (e) {
3154    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3155    return -e.errno;
3156  }
3157}
3158function ___syscall_chmod(path, mode) {
3159  try {
3160    path = SYSCALLS.getStr(path);
3161    FS.chmod(path, mode);
3162    return 0;
3163  } catch (e) {
3164    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3165    return -e.errno;
3166  }
3167}
3168function ___syscall_faccessat(dirfd, path, amode, flags) {
3169  try {
3170    path = SYSCALLS.getStr(path);
3171    path = SYSCALLS.calculateAt(dirfd, path);
3172    if (amode & ~7) {
3173      return -28;
3174    }
3175    var lookup = FS.lookupPath(path, { follow: true });
3176    var node = lookup.node;
3177    if (!node) {
3178      return -44;
3179    }
3180    var perms = "";
3181    if (amode & 4) perms += "r";
3182    if (amode & 2) perms += "w";
3183    if (amode & 1) perms += "x";
3184    if (perms && FS.nodePermissions(node, perms)) {
3185      return -2;
3186    }
3187    return 0;
3188  } catch (e) {
3189    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3190    return -e.errno;
3191  }
3192}
3193function ___syscall_fchdir(fd) {
3194  try {
3195    var stream = SYSCALLS.getStreamFromFD(fd);
3196    FS.chdir(stream.path);
3197    return 0;
3198  } catch (e) {
3199    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3200    return -e.errno;
3201  }
3202}
3203function ___syscall_fchmod(fd, mode) {
3204  try {
3205    FS.fchmod(fd, mode);
3206    return 0;
3207  } catch (e) {
3208    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3209    return -e.errno;
3210  }
3211}
3212function ___syscall_fchmodat2(dirfd, path, mode, flags) {
3213  try {
3214    var nofollow = flags & 256;
3215    path = SYSCALLS.getStr(path);
3216    path = SYSCALLS.calculateAt(dirfd, path);
3217    FS.chmod(path, mode, nofollow);
3218    return 0;
3219  } catch (e) {
3220    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3221    return -e.errno;
3222  }
3223}
3224function ___syscall_fchown32(fd, owner, group) {
3225  try {
3226    FS.fchown(fd, owner, group);
3227    return 0;
3228  } catch (e) {
3229    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3230    return -e.errno;
3231  }
3232}
3233function ___syscall_fchownat(dirfd, path, owner, group, flags) {
3234  try {
3235    path = SYSCALLS.getStr(path);
3236    var nofollow = flags & 256;
3237    flags = flags & ~256;
3238    path = SYSCALLS.calculateAt(dirfd, path);
3239    (nofollow ? FS.lchown : FS.chown)(path, owner, group);
3240    return 0;
3241  } catch (e) {
3242    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3243    return -e.errno;
3244  }
3245}
3246var syscallGetVarargI = () => {
3247  var ret = HEAP32[+SYSCALLS.varargs >> 2];
3248  SYSCALLS.varargs += 4;
3249  return ret;
3250};
3251var syscallGetVarargP = syscallGetVarargI;
3252function ___syscall_fcntl64(fd, cmd, varargs) {
3253  SYSCALLS.varargs = varargs;
3254  try {
3255    var stream = SYSCALLS.getStreamFromFD(fd);
3256    switch (cmd) {
3257      case 0: {
3258        var arg = syscallGetVarargI();
3259        if (arg < 0) {
3260          return -28;
3261        }
3262        while (FS.streams[arg]) {
3263          arg++;
3264        }
3265        var newStream;
3266        newStream = FS.dupStream(stream, arg);
3267        return newStream.fd;
3268      }
3269      case 1:
3270      case 2:
3271        return 0;
3272      case 3:
3273        return stream.flags;
3274      case 4: {
3275        var arg = syscallGetVarargI();
3276        stream.flags |= arg;
3277        return 0;
3278      }
3279      case 12: {
3280        var arg = syscallGetVarargP();
3281        var offset = 0;
3282        HEAP16[(arg + offset) >> 1] = 2;
3283        return 0;
3284      }
3285      case 13:
3286      case 14:
3287        return 0;
3288    }
3289    return -28;
3290  } catch (e) {
3291    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3292    return -e.errno;
3293  }
3294}
3295function ___syscall_fstat64(fd, buf) {
3296  try {
3297    return SYSCALLS.writeStat(buf, FS.fstat(fd));
3298  } catch (e) {
3299    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3300    return -e.errno;
3301  }
3302}
3303var INT53_MAX = 9007199254740992;
3304var INT53_MIN = -9007199254740992;
3305var bigintToI53Checked = (num) =>
3306  num < INT53_MIN || num > INT53_MAX ? NaN : Number(num);
3307function ___syscall_ftruncate64(fd, length) {
3308  length = bigintToI53Checked(length);
3309  try {
3310    if (isNaN(length)) return 61;
3311    FS.ftruncate(fd, length);
3312    return 0;
3313  } catch (e) {
vendor: 4,782 bytes, lines 3314-3479
3314    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3315    return -e.errno;
3316  }
3317}
3318var stringToUTF8 = (str, outPtr, maxBytesToWrite) =>
3319  stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
3320function ___syscall_getcwd(buf, size) {
3321  try {
3322    if (size === 0) return -28;
3323    var cwd = FS.cwd();
3324    var cwdLengthInBytes = lengthBytesUTF8(cwd) + 1;
3325    if (size < cwdLengthInBytes) return -68;
3326    stringToUTF8(cwd, buf, size);
3327    return cwdLengthInBytes;
3328  } catch (e) {
3329    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3330    return -e.errno;
3331  }
3332}
3333function ___syscall_getdents64(fd, dirp, count) {
3334  try {
3335    var stream = SYSCALLS.getStreamFromFD(fd);
3336    stream.getdents ||= FS.readdir(stream.path);
3337    var struct_size = 280;
3338    var pos = 0;
3339    var off = FS.llseek(stream, 0, 1);
3340    var startIdx = Math.floor(off / struct_size);
3341    var endIdx = Math.min(
3342      stream.getdents.length,
3343      startIdx + Math.floor(count / struct_size)
3344    );
3345    for (var idx = startIdx; idx < endIdx; idx++) {
3346      var id;
3347      var type;
3348      var name = stream.getdents[idx];
3349      if (name === ".") {
3350        id = stream.node.id;
3351        type = 4;
3352      } else if (name === "..") {
3353        var lookup = FS.lookupPath(stream.path, { parent: true });
3354        id = lookup.node.id;
3355        type = 4;
3356      } else {
3357        var child;
3358        try {
3359          child = FS.lookupNode(stream.node, name);
3360        } catch (e) {
3361          if (e?.errno === 28) {
3362            continue;
3363          }
3364          throw e;
3365        }
3366        id = child.id;
3367        type = FS.isChrdev(child.mode)
3368          ? 2
3369          : FS.isDir(child.mode)
3370            ? 4
3371            : FS.isLink(child.mode)
3372              ? 10
3373              : 8;
3374      }
3375      HEAP64[(dirp + pos) >> 3] = BigInt(id);
3376      HEAP64[(dirp + pos + 8) >> 3] = BigInt((idx + 1) * struct_size);
3377      HEAP16[(dirp + pos + 16) >> 1] = 280;
3378      HEAP8[dirp + pos + 18] = type;
3379      stringToUTF8(name, dirp + pos + 19, 256);
3380      pos += struct_size;
3381    }
3382    FS.llseek(stream, idx * struct_size, 0);
3383    return pos;
3384  } catch (e) {
3385    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3386    return -e.errno;
3387  }
3388}
3389function ___syscall_ioctl(fd, op, varargs) {
3390  SYSCALLS.varargs = varargs;
3391  try {
3392    var stream = SYSCALLS.getStreamFromFD(fd);
3393    switch (op) {
3394      case 21509: {
3395        if (!stream.tty) return -59;
3396        return 0;
3397      }
3398      case 21505: {
3399        if (!stream.tty) return -59;
3400        if (stream.tty.ops.ioctl_tcgets) {
3401          var termios = stream.tty.ops.ioctl_tcgets(stream);
3402          var argp = syscallGetVarargP();
3403          HEAP32[argp >> 2] = termios.c_iflag || 0;
3404          HEAP32[(argp + 4) >> 2] = termios.c_oflag || 0;
3405          HEAP32[(argp + 8) >> 2] = termios.c_cflag || 0;
3406          HEAP32[(argp + 12) >> 2] = termios.c_lflag || 0;
3407          for (var i = 0; i < 32; i++) {
3408            HEAP8[argp + i + 17] = termios.c_cc[i] || 0;
3409          }
3410          return 0;
3411        }
3412        return 0;
3413      }
3414      case 21510:
3415      case 21511:
3416      case 21512: {
3417        if (!stream.tty) return -59;
3418        return 0;
3419      }
3420      case 21506:
3421      case 21507:
3422      case 21508: {
3423        if (!stream.tty) return -59;
3424        if (stream.tty.ops.ioctl_tcsets) {
3425          var argp = syscallGetVarargP();
3426          var c_iflag = HEAP32[argp >> 2];
3427          var c_oflag = HEAP32[(argp + 4) >> 2];
3428          var c_cflag = HEAP32[(argp + 8) >> 2];
3429          var c_lflag = HEAP32[(argp + 12) >> 2];
3430          var c_cc = [];
3431          for (var i = 0; i < 32; i++) {
3432            c_cc.push(HEAP8[argp + i + 17]);
3433          }
3434          return stream.tty.ops.ioctl_tcsets(stream.tty, op, {
3435            c_iflag,
3436            c_oflag,
3437            c_cflag,
3438            c_lflag,
3439            c_cc,
3440          });
3441        }
3442        return 0;
3443      }
3444      case 21519: {
3445        if (!stream.tty) return -59;
3446        var argp = syscallGetVarargP();
3447        HEAP32[argp >> 2] = 0;
3448        return 0;
3449      }
3450      case 21520: {
3451        if (!stream.tty) return -59;
3452        return -28;
3453      }
3454      case 21531: {
3455        var argp = syscallGetVarargP();
3456        return FS.ioctl(stream, op, argp);
3457      }
3458      case 21523: {
3459        if (!stream.tty) return -59;
3460        if (stream.tty.ops.ioctl_tiocgwinsz) {
3461          var winsize = stream.tty.ops.ioctl_tiocgwinsz(stream.tty);
3462          var argp = syscallGetVarargP();
3463          HEAP16[argp >> 1] = winsize[0];
3464          HEAP16[(argp + 2) >> 1] = winsize[1];
3465        }
3466        return 0;
3467      }
3468      case 21524: {
3469        if (!stream.tty) return -59;
3470        return 0;
3471      }
3472      case 21515: {
3473        if (!stream.tty) return -59;
3474        return 0;
3475      }
3476      default:
3477        return -28;
3478    }
3479  } catch (e) {
3480    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3481    return -e.errno;
3482  }
3483}
3484function ___syscall_lstat64(path, buf) {
3485  try {
3486    path = SYSCALLS.getStr(path);
3487    return SYSCALLS.writeStat(buf, FS.lstat(path));
3488  } catch (e) {
3489    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3490    return -e.errno;
3491  }
3492}
3493function ___syscall_mkdirat(dirfd, path, mode) {
3494  try {
3495    path = SYSCALLS.getStr(path);
3496    path = SYSCALLS.calculateAt(dirfd, path);
3497    FS.mkdir(path, mode, 0);
3498    return 0;
3499  } catch (e) {
3500    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3501    return -e.errno;
3502  }
3503}
3504function ___syscall_mknodat(dirfd, path, mode, dev) {
3505  try {
3506    path = SYSCALLS.getStr(path);
3507    path = SYSCALLS.calculateAt(dirfd, path);
3508    switch (mode & 61440) {
3509      case 32768:
3510      case 8192:
3511      case 24576:
3512      case 4096:
3513      case 49152:
3514        break;
3515      default:
3516        return -28;
3517    }
3518    FS.mknod(path, mode, dev);
3519    return 0;
3520  } catch (e) {
3521    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3522    return -e.errno;
3523  }
3524}
3525function ___syscall_newfstatat(dirfd, path, buf, flags) {
3526  try {
3527    path = SYSCALLS.getStr(path);
3528    var nofollow = flags & 256;
3529    var allowEmpty = flags & 4096;
3530    flags = flags & ~6400;
3531    path = SYSCALLS.calculateAt(dirfd, path, allowEmpty);
3532    return SYSCALLS.writeStat(buf, nofollow ? FS.lstat(path) : FS.stat(path));
3533  } catch (e) {
3534    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3535    return -e.errno;
3536  }
3537}
3538function ___syscall_openat(dirfd, path, flags, varargs) {
3539  SYSCALLS.varargs = varargs;
3540  try {
3541    path = SYSCALLS.getStr(path);
3542    path = SYSCALLS.calculateAt(dirfd, path);
3543    var mode = varargs ? syscallGetVarargI() : 0;
3544    return FS.open(path, flags, mode).fd;
3545  } catch (e) {
3546    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3547    return -e.errno;
3548  }
3549}
3550function ___syscall_renameat(olddirfd, oldpath, newdirfd, newpath) {
3551  try {
3552    oldpath = SYSCALLS.getStr(oldpath);
3553    newpath = SYSCALLS.getStr(newpath);
3554    oldpath = SYSCALLS.calculateAt(olddirfd, oldpath);
3555    newpath = SYSCALLS.calculateAt(newdirfd, newpath);
3556    FS.rename(oldpath, newpath);
3557    return 0;
3558  } catch (e) {
3559    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3560    return -e.errno;
3561  }
3562}
3563function ___syscall_rmdir(path) {
3564  try {
3565    path = SYSCALLS.getStr(path);
3566    FS.rmdir(path);
3567    return 0;
3568  } catch (e) {
3569    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3570    return -e.errno;
3571  }
3572}
3573function ___syscall_stat64(path, buf) {
3574  try {
3575    path = SYSCALLS.getStr(path);
3576    return SYSCALLS.writeStat(buf, FS.stat(path));
3577  } catch (e) {
3578    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3579    return -e.errno;
3580  }
3581}
3582function ___syscall_symlinkat(target, dirfd, linkpath) {
3583  try {
3584    target = SYSCALLS.getStr(target);
3585    linkpath = SYSCALLS.getStr(linkpath);
3586    linkpath = SYSCALLS.calculateAt(dirfd, linkpath);
3587    FS.symlink(target, linkpath);
3588    return 0;
3589  } catch (e) {
3590    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3591    return -e.errno;
3592  }
3593}
3594function ___syscall_unlinkat(dirfd, path, flags) {
3595  try {
3596    path = SYSCALLS.getStr(path);
3597    path = SYSCALLS.calculateAt(dirfd, path);
3598    if (flags === 0) {
3599      FS.unlink(path);
3600    } else if (flags === 512) {
3601      FS.rmdir(path);
3602    } else {
3603      abort("Invalid flags passed to unlinkat");
3604    }
3605    return 0;
3606  } catch (e) {
3607    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3608    return -e.errno;
3609  }
3610}
3611var readI53FromI64 = (ptr) =>
3612  HEAPU32[ptr >> 2] + HEAP32[(ptr + 4) >> 2] * 4294967296;
3613function ___syscall_utimensat(dirfd, path, times, flags) {
3614  try {
3615    path = SYSCALLS.getStr(path);
3616    path = SYSCALLS.calculateAt(dirfd, path, true);
3617    var now = Date.now(),
3618      atime,
3619      mtime;
3620    if (!times) {
3621      atime = now;
3622      mtime = now;
3623    } else {
3624      var seconds = readI53FromI64(times);
3625      var nanoseconds = HEAP32[(times + 8) >> 2];
3626      if (nanoseconds == 1073741823) {
3627        atime = now;
3628      } else if (nanoseconds == 1073741822) {
3629        atime = null;
3630      } else {
3631        atime = seconds * 1e3 + nanoseconds / (1e3 * 1e3);
3632      }
3633      times += 16;
3634      seconds = readI53FromI64(times);
3635      nanoseconds = HEAP32[(times + 8) >> 2];
3636      if (nanoseconds == 1073741823) {
3637        mtime = now;
3638      } else if (nanoseconds == 1073741822) {
3639        mtime = null;
3640      } else {
3641        mtime = seconds * 1e3 + nanoseconds / (1e3 * 1e3);
3642      }
3643    }
3644    if ((mtime ?? atime) !== null) {
3645      FS.utime(path, atime, mtime);
3646    }
3647    return 0;
3648  } catch (e) {
3649    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3650    return -e.errno;
3651  }
3652}
3653var __abort_js = () => abort("");
3654var __emscripten_throw_longjmp = () => {
3655  throw Infinity;
3656};
3657var isLeapYear = (year) =>
3658  year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
3659var MONTH_DAYS_LEAP_CUMULATIVE = [
3660  0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335,
3661];
3662var MONTH_DAYS_REGULAR_CUMULATIVE = [
3663  0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
3664];
3665var ydayFromDate = (date) => {
3666  var leap = isLeapYear(date.getFullYear());
3667  var monthDaysCumulative = leap
3668    ? MONTH_DAYS_LEAP_CUMULATIVE
3669    : MONTH_DAYS_REGULAR_CUMULATIVE;
3670  var yday = monthDaysCumulative[date.getMonth()] + date.getDate() - 1;
3671  return yday;
3672};
3673function __localtime_js(time, tmPtr) {
3674  time = bigintToI53Checked(time);
3675  var date = new Date(time * 1e3);
3676  HEAP32[tmPtr >> 2] = date.getSeconds();
3677  HEAP32[(tmPtr + 4) >> 2] = date.getMinutes();
3678  HEAP32[(tmPtr + 8) >> 2] = date.getHours();
3679  HEAP32[(tmPtr + 12) >> 2] = date.getDate();
3680  HEAP32[(tmPtr + 16) >> 2] = date.getMonth();
3681  HEAP32[(tmPtr + 20) >> 2] = date.getFullYear() - 1900;
3682  HEAP32[(tmPtr + 24) >> 2] = date.getDay();
3683  var yday = ydayFromDate(date) | 0;
3684  HEAP32[(tmPtr + 28) >> 2] = yday;
3685  HEAP32[(tmPtr + 36) >> 2] = -(date.getTimezoneOffset() * 60);
3686  var start = new Date(date.getFullYear(), 0, 1);
3687  var summerOffset = new Date(date.getFullYear(), 6, 1).getTimezoneOffset();
3688  var winterOffset = start.getTimezoneOffset();
3689  var dst =
3690    (summerOffset != winterOffset &&
3691      date.getTimezoneOffset() == Math.min(winterOffset, summerOffset)) | 0;
3692  HEAP32[(tmPtr + 32) >> 2] = dst;
3693}
3694var __tzset_js = (timezone, daylight, std_name, dst_name) => {
3695  var currentYear = new Date().getFullYear();
3696  var winter = new Date(currentYear, 0, 1);
3697  var summer = new Date(currentYear, 6, 1);
3698  var winterOffset = winter.getTimezoneOffset();
3699  var summerOffset = summer.getTimezoneOffset();
3700  var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
3701  HEAPU32[timezone >> 2] = stdTimezoneOffset * 60;
3702  HEAP32[daylight >> 2] = Number(winterOffset != summerOffset);
3703  var extractZone = (timezoneOffset) => {
3704    var sign = timezoneOffset >= 0 ? "-" : "+";
3705    var absOffset = Math.abs(timezoneOffset);
3706    var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
3707    var minutes = String(absOffset % 60).padStart(2, "0");
3708    return `UTC${sign}${hours}${minutes}`;
3709  };
3710  var winterName = extractZone(winterOffset);
3711  var summerName = extractZone(summerOffset);
3712  if (summerOffset < winterOffset) {
3713    stringToUTF8(winterName, std_name, 17);
3714    stringToUTF8(summerName, dst_name, 17);
3715  } else {
3716    stringToUTF8(winterName, dst_name, 17);
3717    stringToUTF8(summerName, std_name, 17);
3718  }
3719};
3720var _emscripten_get_now = () => performance.now();
3721var _emscripten_date_now = () => Date.now();
3722var nowIsMonotonic = 1;
3723var checkWasiClock = (clock_id) => clock_id >= 0 && clock_id <= 3;
3724function _clock_time_get(clk_id, ignored_precision, ptime) {
3725  ignored_precision = bigintToI53Checked(ignored_precision);
3726  if (!checkWasiClock(clk_id)) {
3727    return 28;
3728  }
3729  var now;
3730  if (clk_id === 0) {
3731    now = _emscripten_date_now();
3732  } else if (nowIsMonotonic) {
3733    now = _emscripten_get_now();
3734  } else {
3735    return 52;
3736  }
3737  var nsec = Math.round(now * 1e3 * 1e3);
3738  HEAP64[ptime >> 3] = BigInt(nsec);
3739  return 0;
3740}
3741var getHeapMax = () => 2147483648;
3742var growMemory = (size) => {
3743  var b = wasmMemory.buffer;
3744  var pages = ((size - b.byteLength + 65535) / 65536) | 0;
3745  try {
3746    wasmMemory.grow(pages);
3747    updateMemoryViews();
3748    return 1;
3749  } catch (e) {}
3750};
3751var _emscripten_resize_heap = (requestedSize) => {
3752  var oldSize = HEAPU8.length;
3753  requestedSize >>>= 0;
3754  var maxHeapSize = getHeapMax();
3755  if (requestedSize > maxHeapSize) {
3756    return false;
3757  }
3758  for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
3759    var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown);
3760    overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
3761    var newSize = Math.min(
3762      maxHeapSize,
3763      alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536)
3764    );
3765    var replacement = growMemory(newSize);
3766    if (replacement) {
3767      return true;
3768    }
3769  }
3770  return false;
3771};
3772var ENV = {};
3773var getExecutableName = () => thisProgram || "./this.program";
3774var getEnvStrings = () => {
3775  if (!getEnvStrings.strings) {
3776    var lang =
3777      (
3778        (typeof navigator == "object" &&
3779          navigator.languages &&
3780          navigator.languages[0]) ||
3781        "C"
3782      ).replace("-", "_") + ".UTF-8";
3783    var env = {
3784      USER: "web_user",
3785      LOGNAME: "web_user",
3786      PATH: "/",
3787      PWD: "/",
3788      HOME: "/home/web_user",
3789      LANG: lang,
3790      _: getExecutableName(),
3791    };
3792    for (var x in ENV) {
3793      if (ENV[x] === undefined) delete env[x];
3794      else env[x] = ENV[x];
3795    }
3796    var strings = [];
3797    for (var x in env) {
3798      strings.push(`${x}=${env[x]}`);
3799    }
3800    getEnvStrings.strings = strings;
3801  }
3802  return getEnvStrings.strings;
3803};
3804var stringToAscii = (str, buffer) => {
3805  for (var i = 0; i < str.length; ++i) {
3806    HEAP8[buffer++] = str.charCodeAt(i);
3807  }
3808  HEAP8[buffer] = 0;
3809};
3810var _environ_get = (__environ, environ_buf) => {
3811  var bufSize = 0;
3812  getEnvStrings().forEach((string, i) => {
3813    var ptr = environ_buf + bufSize;
3814    HEAPU32[(__environ + i * 4) >> 2] = ptr;
3815    stringToAscii(string, ptr);
3816    bufSize += string.length + 1;
3817  });
3818  return 0;
3819};
3820var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
3821  var strings = getEnvStrings();
3822  HEAPU32[penviron_count >> 2] = strings.length;
3823  var bufSize = 0;
3824  strings.forEach((string) => (bufSize += string.length + 1));
3825  HEAPU32[penviron_buf_size >> 2] = bufSize;
3826  return 0;
3827};
3828var runtimeKeepaliveCounter = 0;
3829var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
3830var _proc_exit = (code) => {
3831  EXITSTATUS = code;
3832  if (!keepRuntimeAlive()) {
3833    Module["onExit"]?.(code);
3834    ABORT = true;
3835  }
3836  quit_(code, new ExitStatus(code));
3837};
3838var exitJS = (status, implicit) => {
3839  EXITSTATUS = status;
3840  _proc_exit(status);
3841};
3842var _exit = exitJS;
3843function _fd_close(fd) {
3844  try {
3845    var stream = SYSCALLS.getStreamFromFD(fd);
3846    FS.close(stream);
3847    return 0;
3848  } catch (e) {
3849    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3850    return e.errno;
3851  }
3852}
3853function _fd_fdstat_get(fd, pbuf) {
3854  try {
3855    var rightsBase = 0;
3856    var rightsInheriting = 0;
3857    var flags = 0;
3858    {
3859      var stream = SYSCALLS.getStreamFromFD(fd);
3860      var type = stream.tty
3861        ? 2
3862        : FS.isDir(stream.mode)
3863          ? 3
3864          : FS.isLink(stream.mode)
3865            ? 7
3866            : 4;
3867    }
3868    HEAP8[pbuf] = type;
3869    HEAP16[(pbuf + 2) >> 1] = flags;
3870    HEAP64[(pbuf + 8) >> 3] = BigInt(rightsBase);
3871    HEAP64[(pbuf + 16) >> 3] = BigInt(rightsInheriting);
3872    return 0;
3873  } catch (e) {
3874    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3875    return e.errno;
3876  }
3877}
3878var doReadv = (stream, iov, iovcnt, offset) => {
3879  var ret = 0;
3880  for (var i = 0; i < iovcnt; i++) {
3881    var ptr = HEAPU32[iov >> 2];
3882    var len = HEAPU32[(iov + 4) >> 2];
3883    iov += 8;
3884    var curr = FS.read(stream, HEAP8, ptr, len, offset);
3885    if (curr < 0) return -1;
3886    ret += curr;
3887    if (curr < len) break;
3888    if (typeof offset != "undefined") {
3889      offset += curr;
3890    }
3891  }
3892  return ret;
3893};
3894function _fd_read(fd, iov, iovcnt, pnum) {
3895  try {
3896    var stream = SYSCALLS.getStreamFromFD(fd);
3897    var num = doReadv(stream, iov, iovcnt);
3898    HEAPU32[pnum >> 2] = num;
3899    return 0;
3900  } catch (e) {
3901    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3902    return e.errno;
3903  }
3904}
3905function _fd_seek(fd, offset, whence, newOffset) {
3906  offset = bigintToI53Checked(offset);
3907  try {
3908    if (isNaN(offset)) return 61;
3909    var stream = SYSCALLS.getStreamFromFD(fd);
3910    FS.llseek(stream, offset, whence);
3911    HEAP64[newOffset >> 3] = BigInt(stream.position);
3912    if (stream.getdents && offset === 0 && whence === 0) stream.getdents = null;
3913    return 0;
3914  } catch (e) {
3915    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3916    return e.errno;
3917  }
3918}
3919var doWritev = (stream, iov, iovcnt, offset) => {
3920  var ret = 0;
3921  for (var i = 0; i < iovcnt; i++) {
3922    var ptr = HEAPU32[iov >> 2];
3923    var len = HEAPU32[(iov + 4) >> 2];
3924    iov += 8;
3925    var curr = FS.write(stream, HEAP8, ptr, len, offset);
3926    if (curr < 0) return -1;
3927    ret += curr;
3928    if (curr < len) {
3929      break;
3930    }
3931    if (typeof offset != "undefined") {
3932      offset += curr;
3933    }
3934  }
3935  return ret;
3936};
3937function _fd_write(fd, iov, iovcnt, pnum) {
3938  try {
3939    var stream = SYSCALLS.getStreamFromFD(fd);
3940    var num = doWritev(stream, iov, iovcnt);
3941    HEAPU32[pnum >> 2] = num;
3942    return 0;
3943  } catch (e) {
3944    if (typeof FS == "undefined" || !(e.name === "ErrnoError")) throw e;
3945    return e.errno;
3946  }
3947}
3948function _kpse_find_file_js(nameptr, format, mustexist) {
3949  return kpse_find_file_impl(nameptr, format, mustexist);
3950}
3951function _kpse_find_pk_js(nameptr, dpi) {
3952  return kpse_find_pk_impl(nameptr, dpi);
3953}
3954var _llvm_eh_typeid_for = (type) => type;
3955function _prepareExecutionContext_js() {
3956  return prepareExecutionContext();
3957}
3958var handleException = (e) => {
3959  if (e instanceof ExitStatus || e == "unwind") {
3960    return EXITSTATUS;
3961  }
3962  quit_(1, e);
3963};
3964var stackAlloc = (sz) => __emscripten_stack_alloc(sz);
3965var stringToUTF8OnStack = (str) => {
3966  var size = lengthBytesUTF8(str) + 1;
3967  var ret = stackAlloc(size);
3968  stringToUTF8(str, ret, size);
3969  return ret;
3970};
3971var wasmTableMirror = [];
3972var wasmTable;
3973var getWasmTableEntry = (funcPtr) => {
3974  var func = wasmTableMirror[funcPtr];
3975  if (!func) {
3976    if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
3977    wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
3978  }
3979  return func;
3980};
3981var getCFunc = (ident) => {
3982  var func = Module["_" + ident];
3983  return func;
3984};
3985var writeArrayToMemory = (array, buffer) => {
3986  HEAP8.set(array, buffer);
3987};
3988var ccall = (ident, returnType, argTypes, args, opts) => {
3989  var toC = {
3990    string: (str) => {
3991      var ret = 0;
3992      if (str !== null && str !== undefined && str !== 0) {
3993        ret = stringToUTF8OnStack(str);
3994      }
3995      return ret;
3996    },
3997    array: (arr) => {
3998      var ret = stackAlloc(arr.length);
3999      writeArrayToMemory(arr, ret);
4000      return ret;
4001    },
4002  };
4003  function convertReturnValue(ret) {
4004    if (returnType === "string") {
4005      return UTF8ToString(ret);
4006    }
4007    if (returnType === "boolean") return Boolean(ret);
4008    return ret;
4009  }
4010  var func = getCFunc(ident);
4011  var cArgs = [];
4012  var stack = 0;
4013  if (args) {
4014    for (var i = 0; i < args.length; i++) {
4015      var converter = toC[argTypes[i]];
4016      if (converter) {
4017        if (stack === 0) stack = stackSave();
4018        cArgs[i] = converter(args[i]);
4019      } else {
4020        cArgs[i] = args[i];
4021      }
4022    }
4023  }
4024  var ret = func(...cArgs);
4025  function onDone(ret) {
4026    if (stack !== 0) stackRestore(stack);
4027    return convertReturnValue(ret);
4028  }
4029  ret = onDone(ret);
4030  return ret;
4031};
4032var cwrap = (ident, returnType, argTypes, opts) => {
4033  var numericArgs =
4034    !argTypes ||
4035    argTypes.every((type) => type === "number" || type === "boolean");
4036  var numericRet = returnType !== "string";
4037  if (numericRet && numericArgs && !opts) {
4038    return getCFunc(ident);
4039  }
4040  return (...args) => ccall(ident, returnType, argTypes, args, opts);
4041};
4042FS.createPreloadedFile = FS_createPreloadedFile;
4043FS.staticInit();
4044MEMFS.doesNotExistError = new FS.ErrnoError(44);
4045MEMFS.doesNotExistError.stack = "<generic error, no stack>";
4046var wasmImports = {
4047  j: ___assert_fail,
4048  r: ___cxa_begin_catch,
4049  u: ___cxa_end_catch,
4050  a: ___cxa_find_matching_catch_2,
4051  h: ___cxa_find_matching_catch_3,
4052  t: ___cxa_find_matching_catch_4,
4053  T: ___cxa_rethrow,
4054  q: ___cxa_throw,
4055  V: ___cxa_uncaught_exceptions,
4056  e: ___resumeException,
4057  Q: ___syscall_chdir,
4058  P: ___syscall_chmod,
4059  ta: ___syscall_faccessat,
4060  sa: ___syscall_fchdir,
4061  ra: ___syscall_fchmod,
4062  N: ___syscall_fchmodat2,
4063  qa: ___syscall_fchown32,
4064  ha: ___syscall_fchownat,
4065  x: ___syscall_fcntl64,
4066  pa: ___syscall_fstat64,
4067  la: ___syscall_ftruncate64,
4068  ka: ___syscall_getcwd,
4069  aa: ___syscall_getdents64,
4070  va: ___syscall_ioctl,
4071  ma: ___syscall_lstat64,
4072  fa: ___syscall_mkdirat,
4073  ea: ___syscall_mknodat,
4074  na: ___syscall_newfstatat,
4075  D: ___syscall_openat,
4076  $: ___syscall_renameat,
4077  M: ___syscall_rmdir,
4078  oa: ___syscall_stat64,
4079  _: ___syscall_symlinkat,
4080  F: ___syscall_unlinkat,
4081  Z: ___syscall_utimensat,
4082  ua: __abort_js,
4083  W: __emscripten_throw_longjmp,
4084  ba: __localtime_js,
4085  ca: __tzset_js,
4086  da: _clock_time_get,
4087  O: _emscripten_date_now,
4088  X: _emscripten_resize_heap,
4089  ia: _environ_get,
4090  ja: _environ_sizes_get,
4091  H: _exit,
4092  z: _fd_close,
4093  Y: _fd_fdstat_get,
4094  R: _fd_read,
4095  ga: _fd_seek,
4096  G: _fd_write,
4097  J: invoke_diii,
4098  K: invoke_fiii,
4099  p: invoke_i,
4100  c: invoke_ii,
4101  b: invoke_iii,
4102  g: invoke_iiii,
4103  l: invoke_iiiii,
4104  n: invoke_iiiiii,
4105  s: invoke_iiiiiii,
4106  L: invoke_iiiiiiii,
4107  B: invoke_iiiiiiiiiiii,
4108  xa: invoke_ji,
4109  E: invoke_jii,
4110  U: invoke_jiii,
4111  C: invoke_jiiii,
4112  m: invoke_v,
4113  i: invoke_vi,
4114  d: invoke_vii,
4115  f: invoke_viii,
4116  k: invoke_viiii,
4117  o: invoke_viiiii,
4118  v: invoke_viiiiii,
4119  w: invoke_viiiiiii,
4120  y: invoke_viiiiiiiiii,
4121  A: invoke_viiiiiiiiiiiiiii,
4122  I: _kpse_find_file_js,
4123  ya: _kpse_find_pk_js,
4124  S: _llvm_eh_typeid_for,
4125  wa: _prepareExecutionContext_js,
4126};
4127var wasmExports;
4128createWasm();
4129var ___wasm_call_ctors = () => (___wasm_call_ctors = wasmExports["Aa"])();
4130var _malloc = (Module["_malloc"] = (a0) =>
4131  (_malloc = Module["_malloc"] = wasmExports["Ca"])(a0));
4132var _compileLaTeX = (Module["_compileLaTeX"] = () =>
4133  (_compileLaTeX = Module["_compileLaTeX"] = wasmExports["Da"])());
4134var _synctex_view = (Module["_synctex_view"] = (a0, a1, a2, a3) =>
4135  (_synctex_view = Module["_synctex_view"] = wasmExports["Ea"])(
4136    a0,
4137    a1,
4138    a2,
4139    a3
4140  ));
4141var _synctex_edit = (Module["_synctex_edit"] = (a0, a1, a2, a3) =>
4142  (_synctex_edit = Module["_synctex_edit"] = wasmExports["Fa"])(
4143    a0,
4144    a1,
4145    a2,
4146    a3
4147  ));
4148var _main = (Module["_main"] = (a0, a1) =>
4149  (_main = Module["_main"] = wasmExports["Ga"])(a0, a1));
4150var _setThrew = (a0, a1) => (_setThrew = wasmExports["Ha"])(a0, a1);
4151var __emscripten_tempret_set = (a0) =>
4152  (__emscripten_tempret_set = wasmExports["Ia"])(a0);
4153var __emscripten_stack_restore = (a0) =>
4154  (__emscripten_stack_restore = wasmExports["Ja"])(a0);
4155var __emscripten_stack_alloc = (a0) =>
4156  (__emscripten_stack_alloc = wasmExports["Ka"])(a0);
4157var _emscripten_stack_get_current = () =>
4158  (_emscripten_stack_get_current = wasmExports["La"])();
4159var ___cxa_decrement_exception_refcount = (a0) =>
4160  (___cxa_decrement_exception_refcount = wasmExports["Ma"])(a0);
4161var ___cxa_increment_exception_refcount = (a0) =>
4162  (___cxa_increment_exception_refcount = wasmExports["Na"])(a0);
4163var ___cxa_can_catch = (a0, a1, a2) =>
4164  (___cxa_can_catch = wasmExports["Oa"])(a0, a1, a2);
4165var ___cxa_get_exception_ptr = (a0) =>
4166  (___cxa_get_exception_ptr = wasmExports["Pa"])(a0);
4167function invoke_iii(index, a1, a2) {
4168  var sp = stackSave();
4169  try {
4170    return getWasmTableEntry(index)(a1, a2);
4171  } catch (e) {
4172    stackRestore(sp);
4173    if (e !== e + 0) throw e;
4174    _setThrew(1, 0);
4175  }
4176}
4177function invoke_iiiiii(index, a1, a2, a3, a4, a5) {
4178  var sp = stackSave();
4179  try {
4180    return getWasmTableEntry(index)(a1, a2, a3, a4, a5);
4181  } catch (e) {
4182    stackRestore(sp);
4183    if (e !== e + 0) throw e;
4184    _setThrew(1, 0);
4185  }
4186}
4187function invoke_ii(index, a1) {
4188  var sp = stackSave();
4189  try {
4190    return getWasmTableEntry(index)(a1);
4191  } catch (e) {
4192    stackRestore(sp);
4193    if (e !== e + 0) throw e;
4194    _setThrew(1, 0);
4195  }
4196}
4197function invoke_iiiii(index, a1, a2, a3, a4) {
4198  var sp = stackSave();
4199  try {
4200    return getWasmTableEntry(index)(a1, a2, a3, a4);
4201  } catch (e) {
4202    stackRestore(sp);
4203    if (e !== e + 0) throw e;
4204    _setThrew(1, 0);
4205  }
4206}
4207function invoke_vi(index, a1) {
4208  var sp = stackSave();
4209  try {
4210    getWasmTableEntry(index)(a1);
4211  } catch (e) {
4212    stackRestore(sp);
4213    if (e !== e + 0) throw e;
4214    _setThrew(1, 0);
4215  }
4216}
4217function invoke_v(index) {
4218  var sp = stackSave();
4219  try {
4220    getWasmTableEntry(index)();
4221  } catch (e) {
4222    stackRestore(sp);
4223    if (e !== e + 0) throw e;
4224    _setThrew(1, 0);
4225  }
4226}
4227function invoke_vii(index, a1, a2) {
4228  var sp = stackSave();
4229  try {
4230    getWasmTableEntry(index)(a1, a2);
4231  } catch (e) {
4232    stackRestore(sp);
4233    if (e !== e + 0) throw e;
4234    _setThrew(1, 0);
4235  }
4236}
4237function invoke_iiii(index, a1, a2, a3) {
4238  var sp = stackSave();
4239  try {
4240    return getWasmTableEntry(index)(a1, a2, a3);
4241  } catch (e) {
4242    stackRestore(sp);
4243    if (e !== e + 0) throw e;
4244    _setThrew(1, 0);
4245  }
4246}
4247function invoke_viii(index, a1, a2, a3) {
4248  var sp = stackSave();
4249  try {
4250    getWasmTableEntry(index)(a1, a2, a3);
4251  } catch (e) {
4252    stackRestore(sp);
4253    if (e !== e + 0) throw e;
4254    _setThrew(1, 0);
4255  }
4256}
4257function invoke_viiiiii(index, a1, a2, a3, a4, a5, a6) {
4258  var sp = stackSave();
4259  try {
4260    getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6);
4261  } catch (e) {
4262    stackRestore(sp);
4263    if (e !== e + 0) throw e;
4264    _setThrew(1, 0);
4265  }
4266}
4267function invoke_viiii(index, a1, a2, a3, a4) {
4268  var sp = stackSave();
4269  try {
4270    getWasmTableEntry(index)(a1, a2, a3, a4);
4271  } catch (e) {
4272    stackRestore(sp);
4273    if (e !== e + 0) throw e;
4274    _setThrew(1, 0);
4275  }
4276}
4277function invoke_iiiiiii(index, a1, a2, a3, a4, a5, a6) {
4278  var sp = stackSave();
4279  try {
4280    return getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6);
4281  } catch (e) {
4282    stackRestore(sp);
4283    if (e !== e + 0) throw e;
4284    _setThrew(1, 0);
4285  }
4286}
4287function invoke_jii(index, a1, a2) {
4288  var sp = stackSave();
4289  try {
4290    return getWasmTableEntry(index)(a1, a2);
4291  } catch (e) {
4292    stackRestore(sp);
4293    if (e !== e + 0) throw e;
4294    _setThrew(1, 0);
4295    return 0n;
4296  }
4297}
4298function invoke_viiiii(index, a1, a2, a3, a4, a5) {
4299  var sp = stackSave();
4300  try {
4301    getWasmTableEntry(index)(a1, a2, a3, a4, a5);
4302  } catch (e) {
4303    stackRestore(sp);
4304    if (e !== e + 0) throw e;
4305    _setThrew(1, 0);
4306  }
4307}
4308function invoke_i(index) {
4309  var sp = stackSave();
4310  try {
4311    return getWasmTableEntry(index)();
4312  } catch (e) {
4313    stackRestore(sp);
4314    if (e !== e + 0) throw e;
4315    _setThrew(1, 0);
4316  }
4317}
4318function invoke_ji(index, a1) {
4319  var sp = stackSave();
4320  try {
4321    return getWasmTableEntry(index)(a1);
4322  } catch (e) {
4323    stackRestore(sp);
4324    if (e !== e + 0) throw e;
4325    _setThrew(1, 0);
4326    return 0n;
4327  }
4328}
4329function invoke_iiiiiiii(index, a1, a2, a3, a4, a5, a6, a7) {
4330  var sp = stackSave();
4331  try {
4332    return getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7);
4333  } catch (e) {
4334    stackRestore(sp);
4335    if (e !== e + 0) throw e;
4336    _setThrew(1, 0);
4337  }
4338}
4339function invoke_jiiii(index, a1, a2, a3, a4) {
4340  var sp = stackSave();
4341  try {
4342    return getWasmTableEntry(index)(a1, a2, a3, a4);
4343  } catch (e) {
4344    stackRestore(sp);
4345    if (e !== e + 0) throw e;
4346    _setThrew(1, 0);
4347    return 0n;
4348  }
4349}
4350function invoke_fiii(index, a1, a2, a3) {
4351  var sp = stackSave();
4352  try {
4353    return getWasmTableEntry(index)(a1, a2, a3);
4354  } catch (e) {
4355    stackRestore(sp);
4356    if (e !== e + 0) throw e;
4357    _setThrew(1, 0);
4358  }
4359}
4360function invoke_diii(index, a1, a2, a3) {
4361  var sp = stackSave();
4362  try {
4363    return getWasmTableEntry(index)(a1, a2, a3);
4364  } catch (e) {
4365    stackRestore(sp);
4366    if (e !== e + 0) throw e;
4367    _setThrew(1, 0);
4368  }
4369}
4370function invoke_viiiiiii(index, a1, a2, a3, a4, a5, a6, a7) {
4371  var sp = stackSave();
4372  try {
4373    getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7);
4374  } catch (e) {
4375    stackRestore(sp);
4376    if (e !== e + 0) throw e;
4377    _setThrew(1, 0);
4378  }
4379}
4380function invoke_iiiiiiiiiiii(
4381  index,
4382  a1,
4383  a2,
4384  a3,
4385  a4,
4386  a5,
4387  a6,
4388  a7,
4389  a8,
4390  a9,
4391  a10,
4392  a11
4393) {
4394  var sp = stackSave();
4395  try {
4396    return getWasmTableEntry(index)(
4397      a1,
4398      a2,
4399      a3,
4400      a4,
4401      a5,
4402      a6,
4403      a7,
4404      a8,
4405      a9,
4406      a10,
4407      a11
4408    );
4409  } catch (e) {
4410    stackRestore(sp);
4411    if (e !== e + 0) throw e;
4412    _setThrew(1, 0);
4413  }
4414}
4415function invoke_viiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
4416  var sp = stackSave();
4417  try {
4418    getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
4419  } catch (e) {
4420    stackRestore(sp);
4421    if (e !== e + 0) throw e;
4422    _setThrew(1, 0);
4423  }
4424}
4425function invoke_viiiiiiiiiiiiiii(
4426  index,
4427  a1,
4428  a2,
4429  a3,
4430  a4,
4431  a5,
4432  a6,
4433  a7,
4434  a8,
4435  a9,
4436  a10,
4437  a11,
4438  a12,
4439  a13,
4440  a14,
4441  a15
4442) {
4443  var sp = stackSave();
4444  try {
4445    getWasmTableEntry(index)(
4446      a1,
4447      a2,
4448      a3,
4449      a4,
4450      a5,
4451      a6,
4452      a7,
4453      a8,
4454      a9,
4455      a10,
4456      a11,
4457      a12,
4458      a13,
4459      a14,
4460      a15
4461    );
4462  } catch (e) {
4463    stackRestore(sp);
4464    if (e !== e + 0) throw e;
4465    _setThrew(1, 0);
4466  }
4467}
4468function invoke_jiii(index, a1, a2, a3) {
4469  var sp = stackSave();
4470  try {
4471    return getWasmTableEntry(index)(a1, a2, a3);
4472  } catch (e) {
4473    stackRestore(sp);
4474    if (e !== e + 0) throw e;
4475    _setThrew(1, 0);
4476    return 0n;
4477  }
4478}
4479Module["cwrap"] = cwrap;
4480function callMain(args = []) {
4481  var entryFunction = _main;
4482  args.unshift(thisProgram);
4483  var argc = args.length;
4484  var argv = stackAlloc((argc + 1) * 4);
4485  var argv_ptr = argv;
4486  args.forEach((arg) => {
4487    HEAPU32[argv_ptr >> 2] = stringToUTF8OnStack(arg);
4488    argv_ptr += 4;
4489  });
4490  HEAPU32[argv_ptr >> 2] = 0;
4491  try {
4492    var ret = entryFunction(argc, argv);
4493    exitJS(ret, true);
4494    return ret;
4495  } catch (e) {
4496    return handleException(e);
4497  }
4498}
4499function run(args = arguments_) {
4500  if (runDependencies > 0) {
4501    dependenciesFulfilled = run;
4502    return;
4503  }
4504  preRun();
4505  if (runDependencies > 0) {
4506    dependenciesFulfilled = run;
4507    return;
4508  }
4509  function doRun() {
4510    Module["calledRun"] = true;
4511    if (ABORT) return;
4512    initRuntime();
4513    preMain();
4514    Module["onRuntimeInitialized"]?.();
4515    var noInitialRun = Module["noInitialRun"];
4516    if (!noInitialRun) callMain(args);
4517    postRun();
4518  }
4519  if (Module["setStatus"]) {
4520    Module["setStatus"]("Running...");
4521    setTimeout(() => {
4522      setTimeout(() => Module["setStatus"](""), 1);
4523      doRun();
4524    }, 1);
4525  } else {
4526    doRun();
4527  }
4528}
4529if (Module["preInit"]) {
4530  if (typeof Module["preInit"] == "function")
4531    Module["preInit"] = [Module["preInit"]];
4532  while (Module["preInit"].length > 0) {
4533    Module["preInit"].pop()();
4534  }
4535}
4536run();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.