Spaces:
Running
Running
first
Browse files- LICENSE +21 -0
- README.md +0 -1
- bert-text-tokenizer.js +0 -0
- debug-onnx-several-image-sessions-at-once.html +68 -0
- enable-threads.js +75 -0
- index.html +636 -16
- vips/vips.d.ts +0 -0
- vips/vips.js +1 -0
- vips/vips.wasm +3 -0
- vips/vips.worker.js +1 -0
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2022 josephrocca
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -7,4 +7,3 @@ sdk: static
|
|
7 |
pinned: false
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
7 |
pinned: false
|
8 |
---
|
9 |
|
|
bert-text-tokenizer.js
ADDED
The diff for this file is too large to render.
See raw diff
|
|
debug-onnx-several-image-sessions-at-once.html
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8">
|
5 |
+
<meta name="viewport" content="width=device-width">
|
6 |
+
<title>ONNX Bug(?): Loading Several Image Model Sessions at Once</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<style> body * { font-family: monospace; } </style>
|
10 |
+
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.10.0/dist/ort.js"></script>
|
11 |
+
|
12 |
+
Choose number of sessions to create: <input id="numWorkersEl" type="range" min="1" max="10" value="8" oninput="numWorkersDisplayEl.textContent=this.value"> <span id="numWorkersDisplayEl"></span> <script>numWorkersEl.max = navigator.hardwareConcurrency; numWorkersDisplayEl.textContent=numWorkersEl.value;</script>
|
13 |
+
<br>
|
14 |
+
Downloading model: <progress id="imageModelLoadingProgressBarEl" value="0"></progress> <span id="imageModelLoadingMbEl"></span>
|
15 |
+
<br>
|
16 |
+
Number of initialized sessions so far: <span id="workerInitProgressEl"></span>
|
17 |
+
<br>
|
18 |
+
<button onclick="initializeWorkers()">click here to start</button>
|
19 |
+
<br>
|
20 |
+
(see browser console for errors)
|
21 |
+
|
22 |
+
<script>
|
23 |
+
let onnxImageSessions = [];
|
24 |
+
async function initializeWorkers() {
|
25 |
+
numWorkersEl.disabled = true;
|
26 |
+
|
27 |
+
let imageOnnxBlob = await downloadBlobWithProgress('https://huggingface.co/rocca/openai-clip-js/resolve/main/clip-image-vit-32-float32.onnx', function(e) {
|
28 |
+
let ratio = e.loaded / e.total;
|
29 |
+
imageModelLoadingProgressBarEl.value = ratio;
|
30 |
+
imageModelLoadingMbEl.innerHTML = Math.round(ratio*352)+" MB";
|
31 |
+
});
|
32 |
+
|
33 |
+
let imageModelUrl = window.URL.createObjectURL(imageOnnxBlob);
|
34 |
+
|
35 |
+
let numImageWorkers = Number(numWorkersEl.value);
|
36 |
+
|
37 |
+
ort.env.wasm.numThreads = 1;
|
38 |
+
|
39 |
+
for(let i = 0; i < numImageWorkers; i++) {
|
40 |
+
let session = await ort.InferenceSession.create(imageModelUrl, { executionProviders: ["wasm"] }); // webgl is not compatible with this model (need to tweak conversion data/op types)
|
41 |
+
onnxImageSessions.push(session);
|
42 |
+
workerInitProgressEl.innerHTML = i+1;
|
43 |
+
}
|
44 |
+
|
45 |
+
window.URL.revokeObjectURL(imageModelUrl);
|
46 |
+
|
47 |
+
console.log("FINISHED");
|
48 |
+
}
|
49 |
+
|
50 |
+
function downloadBlobWithProgress(url, onProgress) {
|
51 |
+
return new Promise((res, rej) => {
|
52 |
+
var blob;
|
53 |
+
var xhr = new XMLHttpRequest();
|
54 |
+
xhr.open('GET', url, true);
|
55 |
+
xhr.responseType = 'arraybuffer';
|
56 |
+
xhr.onload = function(e) {
|
57 |
+
blob = new Blob([this.response]);
|
58 |
+
};
|
59 |
+
xhr.onprogress = onProgress;
|
60 |
+
xhr.onloadend = function(e){
|
61 |
+
res(blob);
|
62 |
+
}
|
63 |
+
xhr.send();
|
64 |
+
});
|
65 |
+
}
|
66 |
+
</script>
|
67 |
+
</body>
|
68 |
+
</html>
|
enable-threads.js
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// NOTE: This file creates a service worker that cross-origin-isolates the page (read more here: https://web.dev/coop-coep/) which allows us to use wasm threads.
|
2 |
+
// Normally you would set the COOP and COEP headers on the server to do this, but Github Pages doesn't allow this, so this is a hack to do that.
|
3 |
+
|
4 |
+
/* Edited version of: coi-serviceworker v0.1.6 - Guido Zuidhof, licensed under MIT */
|
5 |
+
// From here: https://github.com/gzuidhof/coi-serviceworker
|
6 |
+
if(typeof window === 'undefined') {
|
7 |
+
self.addEventListener("install", () => self.skipWaiting());
|
8 |
+
self.addEventListener("activate", e => e.waitUntil(self.clients.claim()));
|
9 |
+
|
10 |
+
async function handleFetch(request) {
|
11 |
+
if(request.cache === "only-if-cached" && request.mode !== "same-origin") {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
|
15 |
+
if(request.mode === "no-cors") { // We need to set `credentials` to "omit" for no-cors requests, per this comment: https://bugs.chromium.org/p/chromium/issues/detail?id=1309901#c7
|
16 |
+
request = new Request(request.url, {
|
17 |
+
cache: request.cache,
|
18 |
+
credentials: "omit",
|
19 |
+
headers: request.headers,
|
20 |
+
integrity: request.integrity,
|
21 |
+
destination: request.destination,
|
22 |
+
keepalive: request.keepalive,
|
23 |
+
method: request.method,
|
24 |
+
mode: request.mode,
|
25 |
+
redirect: request.redirect,
|
26 |
+
referrer: request.referrer,
|
27 |
+
referrerPolicy: request.referrerPolicy,
|
28 |
+
signal: request.signal,
|
29 |
+
});
|
30 |
+
}
|
31 |
+
|
32 |
+
let r = await fetch(request).catch(e => console.error(e));
|
33 |
+
|
34 |
+
if(r.status === 0) {
|
35 |
+
return r;
|
36 |
+
}
|
37 |
+
|
38 |
+
const headers = new Headers(r.headers);
|
39 |
+
headers.set("Cross-Origin-Embedder-Policy", "credentialless"); // or: require-corp
|
40 |
+
headers.set("Cross-Origin-Opener-Policy", "same-origin");
|
41 |
+
|
42 |
+
return new Response(r.body, { status: r.status, statusText: r.statusText, headers });
|
43 |
+
}
|
44 |
+
|
45 |
+
self.addEventListener("fetch", function(e) {
|
46 |
+
e.respondWith(handleFetch(e.request)); // respondWith must be executed synchonously (but can be passed a Promise)
|
47 |
+
});
|
48 |
+
|
49 |
+
} else {
|
50 |
+
(async function() {
|
51 |
+
if(window.crossOriginIsolated !== false) return;
|
52 |
+
|
53 |
+
let registration = await navigator.serviceWorker.register(window.document.currentScript.src).catch(e => console.error("COOP/COEP Service Worker failed to register:", e));
|
54 |
+
if(registration) {
|
55 |
+
console.log("COOP/COEP Service Worker registered", registration.scope);
|
56 |
+
|
57 |
+
registration.addEventListener("updatefound", () => {
|
58 |
+
console.log("Reloading page to make use of updated COOP/COEP Service Worker.");
|
59 |
+
window.location.reload();
|
60 |
+
});
|
61 |
+
|
62 |
+
// If the registration is active, but it's not controlling the page
|
63 |
+
if(registration.active && !navigator.serviceWorker.controller) {
|
64 |
+
console.log("Reloading page to make use of COOP/COEP Service Worker.");
|
65 |
+
window.location.reload();
|
66 |
+
}
|
67 |
+
}
|
68 |
+
})();
|
69 |
+
}
|
70 |
+
|
71 |
+
// Code to deregister:
|
72 |
+
// let registrations = await navigator.serviceWorker.getRegistrations();
|
73 |
+
// for(let registration of registrations) {
|
74 |
+
// await registration.unregister();
|
75 |
+
// }
|
index.html
CHANGED
@@ -1,19 +1,639 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8">
|
5 |
+
<meta name="viewport" content="width=device-width">
|
6 |
+
<title>OpenAI CLIP Image Search in JavaScript (Using ONNX Web Runtime)</title>
|
7 |
+
<script src="enable-threads.js"></script>
|
8 |
+
<script src="./vips/vips.js"></script>
|
9 |
+
</head>
|
10 |
+
<body>
|
11 |
+
<style>
|
12 |
+
body * {
|
13 |
+
font-family: monospace;
|
14 |
+
}
|
15 |
+
</style>
|
16 |
+
<script src="https://cdn.jsdelivr.net/npm/onnxruntime-web@1.12.0/dist/ort.js"></script>
|
17 |
+
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@3.17.0/dist/tf.min.js"></script> <!-- NOTE: tfjs is currently only used for image preprocessing stuff. -->
|
18 |
+
|
19 |
+
<div>
|
20 |
+
<h1 style="font-size:1rem;">Sort/search images using OpenAI's CLIP in your browser</h1>
|
21 |
+
<p>This web app sorts/searches through images in a directory on your computer using OpenAI's CLIP model, and the new File System Access API. <a href="https://github.com/josephrocca/clip-image-sorter">Here's the Github repo</a> for this web app, and <a href="https://github.com/josephrocca/openai-clip-js">here's the Github repo</a> for the web-ported CLIP models. Feel free to open an issue or <a href="https://twitter.com/rocca27" target="_blank">DM me on Twitter</a> if you have any questions about this demo.</p>
|
22 |
+
<p>All processing happens in your browser, on your device - i.e. your images are <b>not</b> uploaded to a server for processing.</p>
|
23 |
+
<p id="browserCompatibilityWarning" style="padding:0.25rem; background:rgb(255, 227, 160); display:none;"><b>Note</b>: This page uses new browser features (File System Access API, and credentialless COEP) that are currently only available in some browsers. As of writing, it works in Chrome, Edge and Brave. Other browsers like Firefox and Safari are often a bit slower in implementing cutting-edge features.</p>
|
24 |
+
<script>
|
25 |
+
if(Date.now() < 1648725949710+1000*60*60*24*365) { // display until start of April 2023
|
26 |
+
browserCompatibilityWarning.style.display = "";
|
27 |
+
}
|
28 |
+
</script>
|
29 |
+
<hr>
|
30 |
+
|
31 |
+
<div id="modelNameSelectCtn" style="padding:0.5rem; background:lightgrey; margin:0.5rem;">
|
32 |
+
<b>Step 1:</b> Choose model:
|
33 |
+
<select onchange="window.MODEL_NAME=this.value;">
|
34 |
+
<option value="clip_vit_32">CLIP ViT-B/32 (recommended)</option>
|
35 |
+
<option value="clip_vit_32_uint8">CLIP ViT-B/32 (quantized - inaccurate embeddings)</option>
|
36 |
+
<option value="lit_b16b">LiT B16B</option>
|
37 |
+
</select>
|
38 |
+
</div>
|
39 |
+
|
40 |
+
<div id="initCtnEl" style="padding:0.5rem; background:lightgrey; margin:0.5rem;">
|
41 |
+
<b>Step 2:</b> Download and initialize the models.
|
42 |
+
<br>
|
43 |
+
Download image model: <progress id="imageModelLoadingProgressBarEl" value="0"></progress> <span id="imageModelLoadingMbEl"></span>
|
44 |
+
<br>
|
45 |
+
Download text model: <progress id="textModelLoadingProgressBarEl" value="0"></progress> <span id="textModelLoadingMbEl"></span>
|
46 |
+
<br>
|
47 |
+
Initialize workers: <progress id="workerInitProgressBarEl" value="0"></progress>
|
48 |
+
<div style="display:none;"> <!-- more workers (dividing threads between them) doesn't seem to make things faster -->
|
49 |
+
Number of image embedding workers/threads: <input id="numThreadsEl" type="range" min="1" max="4" value="1" oninput="numThreadsDisplayEl.textContent=this.value"> <span id="numThreadsDisplayEl"></span> <script>numThreadsEl.max = navigator.hardwareConcurrency; numThreadsDisplayEl.textContent=numThreadsEl.value;</script>
|
50 |
+
</div>
|
51 |
+
<br>
|
52 |
+
<button id="initWorkersBtn" onclick="modelNameSelectCtn.style.pointerEvents='none'; modelNameSelectCtn.style.opacity=0.5; initializeWorkers()">initialize workers</button>
|
53 |
+
</div>
|
54 |
+
|
55 |
+
<div id="pickDirCtnEl" style="opacity:0.5; pointer-events:none; padding:0.5rem; background:lightgrey; margin:0.5rem;">
|
56 |
+
<b>Step 3:</b> Pick a directory of images (images in subdirectories will be included).
|
57 |
+
<br>
|
58 |
+
<button id="pickDirectoryBtn" onclick="pickDirectory({source:'local'})">pick directory</button> or <button id="useRedditImagesBtn" onclick="pickDirectory({source:'reddit'})">use ~200k reddit images</button> (remove nsfw:<input id="removeRedditNsfwEl" type="checkbox" checked>)
|
59 |
+
<br>
|
60 |
+
<div id="redditLoadProgressCtn" style="display:none;">Download progress: <progress id="redditProgressBarEl" value="0"></progress> <span id="redditProgressMbEl"></span></div>
|
61 |
+
<div id="existingEmbeddingsProgressCtn" style="display:none;">Loading existing embeddings: <span id="existingEmbeddingsLoadedEl">none</span></div>
|
62 |
+
</div>
|
63 |
+
|
64 |
+
<div id="computeEmbeddingsCtnEl" style="opacity:0.5; pointer-events:none; padding:0.5rem; background:lightgrey; margin:0.5rem;">
|
65 |
+
<b>Step 4:</b> Compute image embeddings. <span style="opacity:0.5;">(they will be saved as <ModelName>_embeddings.tsv in the selected directory)</span>
|
66 |
+
<br>
|
67 |
+
<button id="computeEmbeddingsBtn" onclick="computeImageEmbeddings(); this.disabled=true;">compute image embeddings</button>
|
68 |
+
<br>
|
69 |
+
<span id="computeEmbeddingsProgressEl">0</span> images embedded (<span id="computeEmbeddingsSpeedEl">?</span> ms per image) <span id="preexistingEmbeddingsEl"></span>
|
70 |
+
</div>
|
71 |
+
|
72 |
+
<div id="existingEmbeddingsFoundCtnEl" style="display:none; padding:0.5rem; background:lightgrey; margin:0.5rem;">
|
73 |
+
<b>Step 5:</b> <b>Existing embeddings found.</b>
|
74 |
+
<br>
|
75 |
+
Only needed if you've added or changed images: <button onclick="existingEmbeddingsFoundCtnEl.style.display='none'; computeEmbeddingsCtnEl.style.display=''; disableCtn(searchCtnEl); computeEmbeddingsBtn.click()">(re)compute image embeddings</button>
|
76 |
+
<input id="onlyEmbedNewImagesCheckbox" type="checkbox" checked> Only new images?
|
77 |
+
</div>
|
78 |
+
|
79 |
+
<div id="searchCtnEl" style="opacity:0.5; pointer-events:none; padding:0.5rem; background:lightgrey; margin:0.5rem;">
|
80 |
+
<b>Step 6:</b> Enter a search term.
|
81 |
+
<br>
|
82 |
+
<input id="searchTextEl" style="width:300px;" value="" placeholder="Enter search text here..." onkeyup="if(event.which==13) searchSort()">
|
83 |
+
<button id="searchBtn" onclick="searchSort()">search</button>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
|
87 |
+
<hr>
|
88 |
+
<b>Results</b> <span style="opacity:0.5;">(hover for cosine similarities)</span>
|
89 |
+
<div id="resultsEl" style="margin-top:1rem; min-height:100vh;"><span style="opacity:0.5;">Click the search button to compute the results.</span></div>
|
90 |
+
|
91 |
+
<script>
|
92 |
+
/////////////
|
93 |
+
// STEP 1 //
|
94 |
+
/////////////
|
95 |
+
window.MODEL_NAME = "clip_vit_32";
|
96 |
+
window.modelData = {
|
97 |
+
clip_vit_32: {
|
98 |
+
image: {
|
99 |
+
modelUrl: (quantized) => `https://huggingface.co/rocca/openai-clip-js/resolve/main/clip-image-vit-32-${quantized ? "uint8" : "float32"}.onnx`,
|
100 |
+
embed: async function(blob, session) {
|
101 |
+
let rgbData = await getRgbData(blob);
|
102 |
+
const feeds = {input: new ort.Tensor('float32', rgbData, [1,3,224,224])};
|
103 |
+
const results = await session.run(feeds);
|
104 |
+
const embedVec = results["output"].data; // Float32Array
|
105 |
+
return embedVec;
|
106 |
+
}
|
107 |
+
},
|
108 |
+
text: {
|
109 |
+
modelUrl: (quantized) => `https://huggingface.co/rocca/openai-clip-js/resolve/main/clip-text-vit-32-${quantized ? "uint8" : "float32-int32"}.onnx`,
|
110 |
+
embed: async function(text, session) {
|
111 |
+
if(!window.textTokenizerClip) {
|
112 |
+
let Tokenizer = (await import("https://deno.land/x/clip_bpe@v0.0.6/mod.js")).default;
|
113 |
+
window.textTokenizerClip = new Tokenizer();
|
114 |
+
}
|
115 |
+
let textTokens = window.textTokenizerClip.encodeForCLIP(text);
|
116 |
+
textTokens = Int32Array.from(textTokens);
|
117 |
+
const feeds = {input: new ort.Tensor('int32', textTokens, [1, 77])};
|
118 |
+
const results = await session.run(feeds);
|
119 |
+
return [...results["output"].data];
|
120 |
+
},
|
121 |
+
}
|
122 |
+
},
|
123 |
+
lit_b16b: {
|
124 |
+
image: {
|
125 |
+
modelUrl: () => 'https://huggingface.co/rocca/lit-web/resolve/main/embed_images.onnx',
|
126 |
+
embed: async function(blob, session) {
|
127 |
+
|
128 |
+
// TODO: Maybe remove tf from this code so you can remove the whole tfjs dependency
|
129 |
+
blob = await bicubicResizeAndCenterCrop(blob);
|
130 |
+
let inputImg = new Image();
|
131 |
+
await new Promise(r => inputImg.onload=r, inputImg.src=URL.createObjectURL(blob));
|
132 |
+
let img = tf.browser.fromPixels(inputImg);
|
133 |
+
img = tf.sub(tf.div(tf.expandDims(img), 127.5), 1);
|
134 |
+
let float32RgbData = img.dataSync();
|
135 |
+
|
136 |
+
const feeds = {'images': new ort.Tensor('float32', float32RgbData, [1,224,224,3])};
|
137 |
+
const results = await session.run(feeds);
|
138 |
+
return results["Identity_1:0"].data;
|
139 |
+
},
|
140 |
+
},
|
141 |
+
text: {
|
142 |
+
modelUrl: () => 'https://huggingface.co/rocca/lit-web/resolve/main/embed_text_tokens.onnx',
|
143 |
+
embed: async function(text, session) {
|
144 |
+
if(!window.bertTextTokenizerLit) {
|
145 |
+
window.bertTextTokenizerLit = await import("./bert-text-tokenizer.js").then(m => new m.BertTokenizer());
|
146 |
+
await window.bertTextTokenizerLit.load();
|
147 |
+
}
|
148 |
+
let textTokens = window.bertTextTokenizerLit.tokenize(text);
|
149 |
+
textTokens.unshift(101); // manually put CLS token at the start
|
150 |
+
textTokens.length = 16;
|
151 |
+
textTokens = [...textTokens.slice(0, 16)].map(e => e == undefined ? 0 : e); // pad with zeros to length of 16
|
152 |
+
textTokens = Int32Array.from(textTokens);
|
153 |
+
const feeds = {'text_tokens': new ort.Tensor('int32', textTokens, [1,16])};
|
154 |
+
const results = await session.run(feeds);
|
155 |
+
return [...results["Identity_1:0"].data];
|
156 |
+
}
|
157 |
+
}
|
158 |
+
},
|
159 |
+
};
|
160 |
+
let imageWorkers = [];
|
161 |
+
let onnxImageSessions = [];
|
162 |
+
let onnxTextSession;
|
163 |
+
let textTokenizer;
|
164 |
+
async function initializeWorkers() {
|
165 |
+
initWorkersBtn.disabled = true;
|
166 |
+
numThreadsEl.disabled = true;
|
167 |
+
|
168 |
+
let useQuantizedModel = false;
|
169 |
+
|
170 |
+
if(MODEL_NAME.endsWith("_uint8")) {
|
171 |
+
MODEL_NAME = MODEL_NAME.replace(/_uint8$/g, "");
|
172 |
+
useQuantizedModel = true;
|
173 |
+
}
|
174 |
+
|
175 |
+
let imageOnnxBlobPromise = downloadBlobWithProgress(window.modelData[MODEL_NAME].image.modelUrl(useQuantizedModel), function(e) {
|
176 |
+
let ratio = e.loaded / e.total;
|
177 |
+
imageModelLoadingProgressBarEl.value = ratio;
|
178 |
+
imageModelLoadingMbEl.innerHTML = Math.round(ratio*e.total/1e6)+" MB";
|
179 |
+
});
|
180 |
+
|
181 |
+
let textOnnxBlobPromise = downloadBlobWithProgress(window.modelData[MODEL_NAME].text.modelUrl(useQuantizedModel), function(e) {
|
182 |
+
let ratio = e.loaded / e.total;
|
183 |
+
textModelLoadingProgressBarEl.value = ratio;
|
184 |
+
textModelLoadingMbEl.innerHTML = Math.round(ratio*e.total/1e6)+" MB";
|
185 |
+
});
|
186 |
+
|
187 |
+
let [imageOnnxBlob, textOnnxBlob] = await Promise.all([imageOnnxBlobPromise, textOnnxBlobPromise])
|
188 |
+
|
189 |
+
let imageModelUrl = window.URL.createObjectURL(imageOnnxBlob);
|
190 |
+
let textModelUrl = window.URL.createObjectURL(textOnnxBlob);
|
191 |
+
|
192 |
+
let numImageWorkers = Number(numThreadsEl.value);
|
193 |
+
|
194 |
+
// Inference latency is about 5x faster with wasm threads, but this requires these headers: https://web.dev/coop-coep/ I'm using this as a hack (in enable-threads.js) since Github pages doesn't allow setting headers: https://github.com/gzuidhof/coi-serviceworker
|
195 |
+
if(self.crossOriginIsolated) {
|
196 |
+
ort.env.wasm.numThreads = Math.ceil(navigator.hardwareConcurrency / numImageWorkers) / 2; // divide by two to utilise only half the CPU's threads because trying to use all the cpu's threads actually makes it slower
|
197 |
+
}
|
198 |
+
|
199 |
+
workerInitProgressBarEl.max = numImageWorkers + 2; // +2 because of text model and bpe library
|
200 |
+
|
201 |
+
let imageModelExecutionProviders = ["wasm"]; // webgl is not compatible with this model (need to tweak conversion data/op types)
|
202 |
+
|
203 |
+
for(let i = 0; i < numImageWorkers; i++) {
|
204 |
+
let session = await ort.InferenceSession.create(imageModelUrl, { executionProviders: imageModelExecutionProviders });
|
205 |
+
onnxImageSessions.push(session);
|
206 |
+
imageWorkers.push({
|
207 |
+
session,
|
208 |
+
busy: false,
|
209 |
+
});
|
210 |
+
workerInitProgressBarEl.value = Number(workerInitProgressBarEl.value) + 1;
|
211 |
+
}
|
212 |
+
console.log("Image model loaded.");
|
213 |
+
|
214 |
+
onnxTextSession = await ort.InferenceSession.create(textModelUrl, { executionProviders: ["wasm"] }); // webgl is not compatible with this model (need to tweak conversion data/op types)
|
215 |
+
console.log("Text model loaded.");
|
216 |
+
workerInitProgressBarEl.value = Number(workerInitProgressBarEl.value) + 1;
|
217 |
+
|
218 |
+
window.URL.revokeObjectURL(imageModelUrl);
|
219 |
+
window.URL.revokeObjectURL(textModelUrl);
|
220 |
+
|
221 |
+
window.vips = await Vips(); // for bicubicly resizing images (since that's what CLIP expects)
|
222 |
+
window.vips.EMBIND_AUTOMATIC_DELETELATER = false;
|
223 |
+
|
224 |
+
workerInitProgressBarEl.value = Number(workerInitProgressBarEl.value) + 1;
|
225 |
+
|
226 |
+
disableCtn(initCtnEl);
|
227 |
+
enableCtn(pickDirCtnEl);
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
/////////////
|
232 |
+
// STEP 2 //
|
233 |
+
/////////////
|
234 |
+
let directoryHandle;
|
235 |
+
let embeddingsFileHandle;
|
236 |
+
let embeddings;
|
237 |
+
let dataSource;
|
238 |
+
async function pickDirectory(opts={}) {
|
239 |
+
dataSource = opts.source;
|
240 |
+
|
241 |
+
if(dataSource === "local") {
|
242 |
+
if(!window.showDirectoryPicker) return alert("Your browser does not support some modern features (specifically, File System Access API) required to use this web app. Please try updating your browser, or switching to Chrome, Edge, or Brave.");
|
243 |
+
directoryHandle = await window.showDirectoryPicker();
|
244 |
+
embeddingsFileHandle = await directoryHandle.getFileHandle(`${window.MODEL_NAME}_embeddings.tsv`, {create:true});
|
245 |
+
|
246 |
+
pickDirectoryBtn.disabled = true;
|
247 |
+
useRedditImagesBtn.disabled = true;
|
248 |
+
pickDirectoryBtn.textContent = "Loading...";
|
249 |
+
}
|
250 |
+
|
251 |
+
let redditEmbeddingsBlob;
|
252 |
+
if(dataSource === "reddit") {
|
253 |
+
if(window.MODEL_NAME !== "clip_vit_32") return alert("Sorry, there are only pre-computed Reddit image embeddings for the CLIP ViT-B/32 model at the moment.");
|
254 |
+
if(!removeRedditNsfwEl.checked && !confirm("Are you sure you'd like to see NSFW Reddit images?")) return;
|
255 |
+
if(removeRedditNsfwEl.checked) alert("Note that NSFW images are filtered from Reddit using CLIP, and CLIP can make mistakes, so some NSFW images may still be shown.");
|
256 |
+
|
257 |
+
pickDirectoryBtn.disabled = true;
|
258 |
+
useRedditImagesBtn.disabled = true;
|
259 |
+
useRedditImagesBtn.textContent = "Loading...";
|
260 |
+
redditLoadProgressCtn.style.display = "";
|
261 |
+
|
262 |
+
redditEmbeddingsBlob = await downloadBlobWithProgress("https://huggingface.co/datasets/rocca/top-reddit-posts/resolve/main/clip_embeddings_top_50_images_per_subreddit.tsv.gz", function(e) {
|
263 |
+
let ratio = e.loaded / e.total;
|
264 |
+
redditProgressBarEl.value = ratio;
|
265 |
+
redditProgressMbEl.innerHTML = Math.round(ratio*213)+" MB";
|
266 |
+
});
|
267 |
+
}
|
268 |
+
|
269 |
+
try {
|
270 |
+
existingEmbeddingsProgressCtn.style.display = "";
|
271 |
+
|
272 |
+
embeddings = {};
|
273 |
+
let file, opts;
|
274 |
+
if(dataSource === "local") {
|
275 |
+
file = await embeddingsFileHandle.getFile();
|
276 |
+
opts = {};
|
277 |
+
}
|
278 |
+
if(dataSource === "reddit") {
|
279 |
+
file = redditEmbeddingsBlob;
|
280 |
+
opts = {decompress:"gzip"};
|
281 |
+
}
|
282 |
+
|
283 |
+
let i = 0;
|
284 |
+
for await (let line of makeTextFileLineIterator(file, opts)) {
|
285 |
+
if(!line || !line.trim()) continue; // <-- to skip final new line (not sure if this is needed)
|
286 |
+
let [filePath, embeddingVec] = line.split("\t");
|
287 |
+
embeddings[filePath] = JSON.parse(embeddingVec);
|
288 |
+
i++;
|
289 |
+
if(i % 1000 === 0) {
|
290 |
+
existingEmbeddingsLoadedEl.innerHTML = i;
|
291 |
+
await sleep(10);
|
292 |
+
}
|
293 |
+
}
|
294 |
+
} catch(e) {
|
295 |
+
embeddings = undefined;
|
296 |
+
console.log("No existing embedding found, or the embeddings file was corrupted:", e);
|
297 |
+
existingEmbeddingsProgressCtn.style.display = "none";
|
298 |
+
}
|
299 |
+
|
300 |
+
pickDirectoryBtn.textContent = "Done.";
|
301 |
+
useRedditImagesBtn.textContent = "Done.";
|
302 |
+
|
303 |
+
disableCtn(pickDirCtnEl);
|
304 |
+
enableCtn(computeEmbeddingsCtnEl);
|
305 |
+
enableCtn(searchCtnEl);
|
306 |
+
|
307 |
+
if(embeddings && Object.keys(embeddings).length > 0) {
|
308 |
+
computeEmbeddingsCtnEl.style.display = "none";
|
309 |
+
existingEmbeddingsFoundCtnEl.style.display = "";
|
310 |
+
}
|
311 |
+
|
312 |
+
if(dataSource === "reddit") {
|
313 |
+
disableCtn(existingEmbeddingsFoundCtnEl);
|
314 |
+
}
|
315 |
+
|
316 |
+
}
|
317 |
+
|
318 |
+
|
319 |
+
/////////////
|
320 |
+
// STEP 3 //
|
321 |
+
/////////////
|
322 |
+
let totalEmbeddingsCount = 0;
|
323 |
+
let imagesEmbedded;
|
324 |
+
let recentEmbeddingTimes = []; // how long each embed took in ms, newest at end
|
325 |
+
let recomputeAllEmbeddings;
|
326 |
+
let imagesBeingProcessedNow = 0;
|
327 |
+
let needToSaveEmbeddings = false;
|
328 |
+
async function computeImageEmbeddings() {
|
329 |
+
imagesEmbedded = 0;
|
330 |
+
totalEmbeddingsCount = Object.keys(embeddings).length;
|
331 |
+
|
332 |
+
recomputeAllEmbeddings = !onlyEmbedNewImagesCheckbox.checked;
|
333 |
+
let gotSomeExistingEmbeddings = totalEmbeddingsCount > 0;
|
334 |
+
|
335 |
+
if(onlyEmbedNewImagesCheckbox.checked && gotSomeExistingEmbeddings) {
|
336 |
+
preexistingEmbeddingsEl.innerHTML = `(loaded ${Object.keys(embeddings).length} existing embeddings)`;
|
337 |
+
}
|
338 |
+
|
339 |
+
if(recomputeAllEmbeddings || !gotSomeExistingEmbeddings) {
|
340 |
+
embeddings = {}; // <-- maps file path (relative to top/selected directory) to embedding
|
341 |
+
}
|
342 |
+
|
343 |
+
try {
|
344 |
+
await recursivelyProcessImagesInDir(directoryHandle);
|
345 |
+
await saveEmbeddings();
|
346 |
+
} catch(e) {
|
347 |
+
console.error(e);
|
348 |
+
alert(e.message);
|
349 |
+
}
|
350 |
+
|
351 |
+
disableCtn(computeEmbeddingsCtnEl);
|
352 |
+
enableCtn(searchCtnEl);
|
353 |
+
}
|
354 |
+
async function recursivelyProcessImagesInDir(dirHandle, currentPath="") {
|
355 |
+
for await (let [name, handle] of dirHandle) {
|
356 |
+
const {kind} = handle;
|
357 |
+
let path = `${currentPath}/${name}`;
|
358 |
+
if (handle.kind === 'directory') {
|
359 |
+
await recursivelyProcessImagesInDir(handle, path);
|
360 |
+
} else {
|
361 |
+
let isImage = /\.(png|jpg|jpeg|webp)$/.test(path);
|
362 |
+
if(!isImage) continue;
|
363 |
+
|
364 |
+
let alreadyGotEmbedding = !!embeddings[path];
|
365 |
+
if(alreadyGotEmbedding && !recomputeAllEmbeddings) continue;
|
366 |
+
|
367 |
+
if(needToSaveEmbeddings) {
|
368 |
+
await saveEmbeddings();
|
369 |
+
needToSaveEmbeddings = false;
|
370 |
+
}
|
371 |
+
|
372 |
+
while(imageWorkers.filter(w => !w.busy).length === 0) await sleep(1);
|
373 |
+
|
374 |
+
let worker = imageWorkers.filter(w => !w.busy)[0];
|
375 |
+
worker.busy = true;
|
376 |
+
imagesBeingProcessedNow++;
|
377 |
+
|
378 |
+
(async function() {
|
379 |
+
let startTime = Date.now();
|
380 |
+
|
381 |
+
let blob = await handle.getFile();
|
382 |
+
const embedVec = await modelData[MODEL_NAME].image.embed(blob, worker.session);
|
383 |
+
|
384 |
+
embeddings[path] = [...embedVec];
|
385 |
+
worker.busy = false;
|
386 |
+
|
387 |
+
imagesEmbedded++;
|
388 |
+
totalEmbeddingsCount++;
|
389 |
+
|
390 |
+
computeEmbeddingsProgressEl.innerHTML = imagesEmbedded;
|
391 |
+
|
392 |
+
let saveInterval = totalEmbeddingsCount > 50_000 ? 10_000 : 1000; // since saves take longer if there are lots of embeddings
|
393 |
+
if(imagesEmbedded % saveInterval === 0) {
|
394 |
+
needToSaveEmbeddings = true;
|
395 |
+
}
|
396 |
+
|
397 |
+
recentEmbeddingTimes.push(Date.now()-startTime);
|
398 |
+
if(recentEmbeddingTimes.length > 100) recentEmbeddingTimes = recentEmbeddingTimes.slice(-50);
|
399 |
+
if(recentEmbeddingTimes.length > 10) computeEmbeddingsSpeedEl.innerHTML = Math.round(recentEmbeddingTimes.slice(-20).reduce((a,v) => a+v, 0)/20);
|
400 |
+
|
401 |
+
imagesBeingProcessedNow--;
|
402 |
+
})();
|
403 |
+
}
|
404 |
+
}
|
405 |
+
while(imagesBeingProcessedNow > 0) await sleep(10);
|
406 |
+
}
|
407 |
+
|
408 |
+
|
409 |
+
/////////////
|
410 |
+
// STEP 4 //
|
411 |
+
/////////////
|
412 |
+
async function searchSort() {
|
413 |
+
searchBtn.disabled = true;
|
414 |
+
|
415 |
+
if(dataSource === "local") {
|
416 |
+
for(let imgEl of [...document.querySelectorAll("img")]) {
|
417 |
+
URL.revokeObjectURL(imgEl.src);
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
resultsEl.innerHTML = "Loading...";
|
422 |
+
await sleep(50);
|
423 |
+
|
424 |
+
let searchTextEmbedding = await modelData[MODEL_NAME].text.embed(searchTextEl.value, onnxTextSession);
|
425 |
+
let similarities = {};
|
426 |
+
for(let [path, embedding] of Object.entries(embeddings)) {
|
427 |
+
similarities[path] = cosineSimilarity(searchTextEmbedding, embedding);
|
428 |
+
}
|
429 |
+
let similarityEntries = Object.entries(similarities).sort((a,b) => b[1]-a[1]).slice(0, 5000);
|
430 |
+
|
431 |
+
if(dataSource === "reddit" && removeRedditNsfwEl.checked) {
|
432 |
+
let nsfwTextEmbedding = await modelData[MODEL_NAME].text.embed(atob('cG9ybiBuYWtlZCBwZW5pcyB2YWdpbmEgbnVkZSBzZXggZGljayBwdXNzeSBzZXh1YWwgcG9ybm9ncmFwaGljIGFzcyBib29icw=='), onnxTextSession); // nsfw words (hidden with `btoa`)
|
433 |
+
let nsfwSimilarities = {};
|
434 |
+
for(let [path, similarity] of similarityEntries) {
|
435 |
+
let embedding = embeddings[path];
|
436 |
+
nsfwSimilarities[path] = cosineSimilarity(nsfwTextEmbedding, embedding);
|
437 |
+
}
|
438 |
+
similarityEntries = similarityEntries.filter(e => nsfwSimilarities[e[0]] < 0.2093);
|
439 |
+
}
|
440 |
+
|
441 |
+
let resultHtml = "";
|
442 |
+
let numResults = 0;
|
443 |
+
for(let [path, score] of similarityEntries.slice(0, 500)) {
|
444 |
+
if(dataSource === "local") {
|
445 |
+
let handle = await getFileHandleByPath(path);
|
446 |
+
let url = URL.createObjectURL(await handle.getFile());
|
447 |
+
resultHtml += `<img src="${url}" style="max-height:400px;" title="${path}: ${score}" loading="lazy"/>`;
|
448 |
+
}
|
449 |
+
if(dataSource === "reddit") {
|
450 |
+
let imageUrl = `https://i.redd.it/${path.split("__")[1]}`;
|
451 |
+
let postUrl = `https://reddit.com/comments/${path.split("__")[0].split("/")[1]}`;
|
452 |
+
resultHtml += `<a href="${postUrl}" target="_blank"><img src="${imageUrl}" onload="this.style.height='';this.style.width='';this.style.border='';" style="max-height:400px; height:300px; width:300px; border:1px solid black;" title="${path}: ${score}" loading="lazy"/></a>`;
|
453 |
+
}
|
454 |
+
numResults++;
|
455 |
+
}
|
456 |
+
|
457 |
+
if(!resultHtml) {
|
458 |
+
resultsEl.innerHTML = "No results found after filtering NSFW.";
|
459 |
+
} else {
|
460 |
+
resultsEl.innerHTML = resultHtml;
|
461 |
+
}
|
462 |
+
|
463 |
+
searchBtn.disabled = false;
|
464 |
+
}
|
465 |
+
|
466 |
+
|
467 |
+
|
468 |
+
|
469 |
+
/////////////////////////////
|
470 |
+
// FUNCTIONS / UTILITIES //
|
471 |
+
/////////////////////////////
|
472 |
+
|
473 |
+
async function getFileHandleByPath(path) {
|
474 |
+
let handle = directoryHandle;
|
475 |
+
let chunks = path.split("/").slice(1);
|
476 |
+
for(let i = 0; i < chunks.length; i++) {
|
477 |
+
let chunk = chunks[i];
|
478 |
+
if(i === chunks.length-1) {
|
479 |
+
handle = await handle.getFileHandle(chunk);
|
480 |
+
} else {
|
481 |
+
handle = await handle.getDirectoryHandle(chunk);
|
482 |
+
}
|
483 |
+
}
|
484 |
+
return handle;
|
485 |
+
}
|
486 |
+
|
487 |
+
async function getRgbData(blob) {
|
488 |
+
// let blob = await fetch(imgUrl, {referrer:""}).then(r => r.blob());
|
489 |
+
|
490 |
+
let resizedBlob = await bicubicResizeAndCenterCrop(blob);
|
491 |
+
let img = await createImageBitmap(resizedBlob);
|
492 |
+
|
493 |
+
let canvas = new OffscreenCanvas(224, 224);
|
494 |
+
let ctx = canvas.getContext("2d");
|
495 |
+
ctx.drawImage(img, 0, 0);
|
496 |
+
let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
497 |
+
|
498 |
+
let rgbData = [[], [], []]; // [r, g, b]
|
499 |
+
// remove alpha and put into correct shape:
|
500 |
+
let d = imageData.data;
|
501 |
+
for(let i = 0; i < d.length; i += 4) {
|
502 |
+
let x = (i/4) % canvas.width;
|
503 |
+
let y = Math.floor((i/4) / canvas.width)
|
504 |
+
if(!rgbData[0][y]) rgbData[0][y] = [];
|
505 |
+
if(!rgbData[1][y]) rgbData[1][y] = [];
|
506 |
+
if(!rgbData[2][y]) rgbData[2][y] = [];
|
507 |
+
rgbData[0][y][x] = d[i+0]/255;
|
508 |
+
rgbData[1][y][x] = d[i+1]/255;
|
509 |
+
rgbData[2][y][x] = d[i+2]/255;
|
510 |
+
// From CLIP repo: Normalize(mean=(0.48145466, 0.4578275, 0.40821073), std=(0.26862954, 0.26130258, 0.27577711))
|
511 |
+
rgbData[0][y][x] = (rgbData[0][y][x] - 0.48145466) / 0.26862954;
|
512 |
+
rgbData[1][y][x] = (rgbData[1][y][x] - 0.4578275) / 0.26130258;
|
513 |
+
rgbData[2][y][x] = (rgbData[2][y][x] - 0.40821073) / 0.27577711;
|
514 |
+
}
|
515 |
+
rgbData = Float32Array.from(rgbData.flat().flat());
|
516 |
+
return rgbData;
|
517 |
+
}
|
518 |
+
|
519 |
+
async function bicubicResizeAndCenterCrop(blob) {
|
520 |
+
let im1 = vips.Image.newFromBuffer(await blob.arrayBuffer());
|
521 |
+
|
522 |
+
// Resize so smallest side is 224px:
|
523 |
+
const scale = 224 / Math.min(im1.height, im1.width);
|
524 |
+
let im2 = im1.resize(scale, { kernel: vips.Kernel.cubic });
|
525 |
+
|
526 |
+
// crop to 224x224:
|
527 |
+
let left = (im2.width - 224) / 2;
|
528 |
+
let top = (im2.height - 224) / 2;
|
529 |
+
let im3 = im2.crop(left, top, 224, 224)
|
530 |
+
|
531 |
+
let outBuffer = new Uint8Array(im3.writeToBuffer('.png'));
|
532 |
+
im1.delete(), im2.delete(), im3.delete();
|
533 |
+
return new Blob([outBuffer], { type: 'image/png' });
|
534 |
+
}
|
535 |
+
|
536 |
+
|
537 |
+
function downloadBlobWithProgress(url, onProgress) {
|
538 |
+
return new Promise((res, rej) => {
|
539 |
+
var blob;
|
540 |
+
var xhr = new XMLHttpRequest();
|
541 |
+
xhr.open('GET', url, true);
|
542 |
+
xhr.responseType = 'arraybuffer';
|
543 |
+
xhr.onload = function(e) {
|
544 |
+
blob = new Blob([this.response]);
|
545 |
+
};
|
546 |
+
xhr.onprogress = onProgress;
|
547 |
+
xhr.onloadend = function(e){
|
548 |
+
res(blob);
|
549 |
+
}
|
550 |
+
xhr.send();
|
551 |
+
});
|
552 |
+
}
|
553 |
+
|
554 |
+
async function saveEmbeddings(opts={}) {
|
555 |
+
let writable = await embeddingsFileHandle.createWritable();
|
556 |
+
let textBatch = "";
|
557 |
+
let i = 0;
|
558 |
+
for(let [filePath, embeddingVec] of Object.entries(embeddings)) {
|
559 |
+
let vecString = opts.compress ? JSON.stringify(embeddingVec.map(n => n.toFixed(3))).replace(/"/g, "") : JSON.stringify(embeddingVec);
|
560 |
+
textBatch += `${filePath}\t${vecString}\n`;
|
561 |
+
i++;
|
562 |
+
if(i % 1000 === 0) {
|
563 |
+
await writable.write(textBatch);
|
564 |
+
textBatch = "";
|
565 |
+
}
|
566 |
+
}
|
567 |
+
await writable.write(textBatch);
|
568 |
+
await writable.close();
|
569 |
+
}
|
570 |
+
|
571 |
+
// Tweaked version of example from here: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader/read
|
572 |
+
async function* makeTextFileLineIterator(blob, opts={}) {
|
573 |
+
const utf8Decoder = new TextDecoder("utf-8");
|
574 |
+
let stream = await blob.stream();
|
575 |
+
|
576 |
+
if(opts.decompress === "gzip") stream = stream.pipeThrough(new DecompressionStream("gzip"));
|
577 |
+
|
578 |
+
let reader = stream.getReader();
|
579 |
+
|
580 |
+
let {value: chunk, done: readerDone} = await reader.read();
|
581 |
+
chunk = chunk ? utf8Decoder.decode(chunk, {stream: true}) : "";
|
582 |
+
|
583 |
+
let re = /\r\n|\n|\r/gm;
|
584 |
+
let startIndex = 0;
|
585 |
+
|
586 |
+
while (true) {
|
587 |
+
let result = re.exec(chunk);
|
588 |
+
if (!result) {
|
589 |
+
if (readerDone) {
|
590 |
+
break;
|
591 |
+
}
|
592 |
+
let remainder = chunk.substr(startIndex);
|
593 |
+
({value: chunk, done: readerDone} = await reader.read());
|
594 |
+
chunk = remainder + (chunk ? utf8Decoder.decode(chunk, {stream: true}) : "");
|
595 |
+
startIndex = re.lastIndex = 0;
|
596 |
+
continue;
|
597 |
+
}
|
598 |
+
yield chunk.substring(startIndex, result.index);
|
599 |
+
startIndex = re.lastIndex;
|
600 |
+
}
|
601 |
+
if (startIndex < chunk.length) {
|
602 |
+
// last line didn't end in a newline char
|
603 |
+
yield chunk.substr(startIndex);
|
604 |
+
}
|
605 |
+
}
|
606 |
+
|
607 |
+
function cosineSimilarity(A, B) {
|
608 |
+
if(A.length !== B.length) throw new Error("A.length !== B.length");
|
609 |
+
let dotProduct = 0, mA = 0, mB = 0;
|
610 |
+
for(let i = 0; i < A.length; i++){
|
611 |
+
dotProduct += A[i] * B[i];
|
612 |
+
mA += A[i] * A[i];
|
613 |
+
mB += B[i] * B[i];
|
614 |
+
}
|
615 |
+
mA = Math.sqrt(mA);
|
616 |
+
mB = Math.sqrt(mB);
|
617 |
+
let similarity = dotProduct / (mA * mB);
|
618 |
+
return similarity;
|
619 |
+
}
|
620 |
+
|
621 |
+
function sleep(ms) {
|
622 |
+
return new Promise(r => setTimeout(r, ms));
|
623 |
+
}
|
624 |
+
|
625 |
+
function enableCtn(el) {
|
626 |
+
el.style.opacity = 1;
|
627 |
+
el.style.pointerEvents = "";
|
628 |
+
}
|
629 |
+
function disableCtn(el) {
|
630 |
+
el.style.opacity = 0.5;
|
631 |
+
el.style.pointerEvents = "none";
|
632 |
+
}
|
633 |
+
|
634 |
+
// From the PyTorch model running on CUDA:
|
635 |
+
// Text: "a portrait of an astronaut with the American flag"
|
636 |
+
// Embedding: [-1.6626e-01, 5.2277e-02, -1.5332e-01, 4.4946e-01, 2.0667e-01, -2.9565e-01, 4.0588e-02, -4.1016e-01, -1.5027e-01, 3.1934e-01, -6.9702e-02, -2.5488e-01, 1.2335e-01, -9.5337e-02, 2.4109e-01, -4.8950e-02, 2.6074e-01, 5.3835e-04, 2.1033e-01, 3.7012e-01, 4.5679e-01, 3.9795e-01, 3.1641e-01, 3.9551e-01, 1.3931e-02, -4.3060e-02, 4.8798e-02, 3.7158e-01, 1.1731e-01, -3.7256e-01, -2.7295e-01, 3.3130e-01, 5.4980e-01, -2.9816e-02, -2.5806e-01, -1.0016e-01, 8.0750e-02, -6.7139e-02, -2.4072e-01, 2.4353e-01, -3.2202e-01, -1.0327e-01, 1.1566e-01, 6.2646e-01, 1.8262e-01, 2.7539e-01, -1.1816e-01, 4.9512e-01, 8.9539e-02, 5.6299e-01, 2.1313e-01, -1.5625e-01, 1.9958e-01, -5.0049e-01, -2.5854e-01, -4.0430e-01, -1.1298e-01, -6.6338e-03, 2.5391e-01, -5.0629e-02, 2.2253e-01, -2.7295e-01, -5.8289e-03, -4.8804e-01, -7.7820e-02, -3.5187e-02, -3.7537e-02, 4.3213e-01, 3.8300e-02, 2.1045e-01, -3.0347e-01, -9.8999e-02, -1.7407e-01, 2.8882e-01, 1.1322e-01, -1.0883e-01, 1.7065e-01, -2.1191e-01, 1.7920e-01, -1.2805e-01, -4.6924e-01, 1.1957e-01, -1.1829e-01, -1.1902e-01, -2.4353e-01, -9.6008e-02, 2.2913e-01, -1.0948e-02, -1.5686e-01, -2.0483e-01, -2.4756e-01, 9.1125e-02, -9.5557e-01, -4.2511e-02, 4.6356e-02, 4.3481e-01, 2.3633e-01, -3.3252e-01, 3.7231e-01, -5.5695e-02, 7.1777e-02, -1.0370e-01, -2.1912e-01, -1.3733e-01, 1.2048e-01, 1.7151e-01, -1.2659e-01, 2.3523e-01, 2.6001e-01, -4.0381e-01, 1.1761e-01, -4.1626e-02, 1.0974e-01, -5.5206e-02, 4.9713e-02, 5.2197e-01, 3.9124e-02, 5.7959e-01, 9.9609e-02, -3.3740e-01, -2.7295e-01, -7.3389e-01, 1.0962e-01, -3.2178e-01, 6.5869e-01, 2.3460e-03, 2.6733e-02, 3.2471e-02, -2.4500e-01, 7.9041e-02, 1.5405e-01, -3.5547e-01, -1.5625e-01, 4.2695e+00, -1.6113e-01, 1.6467e-01, -3.8794e-01, 2.1545e-02, 1.5771e-01, 2.0068e-01, -3.4741e-01, 2.5244e-01, 1.2201e-01, -3.9795e-02, 3.2471e-01, 2.6562e-01, 1.2915e-01, 1.4465e-02, -2.1265e-01, -2.5055e-02, 5.6689e-01, -6.5125e-02, 1.1652e-01, -5.1025e-01, 1.0712e-01, 8.8867e-02, 1.6882e-01, -6.5125e-02, 4.5929e-02, 2.9517e-01, 6.5479e-01, -9.0881e-02, -4.6417e-02, -3.0713e-01, -5.1537e-03, 4.9390e-01, 5.4492e-01, -3.1812e-01, -6.0577e-02, 3.6591e-02, 7.6782e-02, -3.5181e-01, 4.9487e-01, -4.1040e-01, 4.3970e-01, 1.6553e-01, -3.7329e-01, 3.3594e-01, -1.9263e-01, -1.8225e-01, -1.9623e-02, -4.0454e-01, 1.6187e-01, 1.5259e-01, 2.5122e-01, 1.1993e-01, -8.4595e-02, -4.1016e-01, -1.8225e-01, 1.8555e-01, -3.9124e-02, 2.5122e-01, -2.2949e-01, 5.3125e-01, -1.0504e-01, -2.1439e-02, -2.2559e-01, 5.9357e-02, -3.9160e-01, -3.3716e-01, -9.0393e-02, -1.7493e-01, -2.5952e-01, 2.3401e-01, 3.8013e-01, 1.2927e-01, 1.5491e-01, 1.1920e-01, -1.5906e-01, 5.7487e-03, 7.6172e-02, 1.5552e-01, 2.1790e-01, 9.9304e-02, -3.8025e-02, -1.1829e-01, -1.3293e-01, -2.2278e-01, -2.1472e-01, 3.0957e-01, -1.0254e-01, -2.0264e-01, -2.6840e-02, 8.8379e-02, -8.2092e-02, 1.3647e-01, -2.1399e-01, -2.5684e-01, 1.3745e-01, 6.1371e-02, -1.2988e-01, 6.2683e-02, 1.2964e-01, -3.3112e-02, 1.4111e-01, -2.6440e-01, 4.7379e-03, -1.0815e-01, -4.4971e-01, -3.5583e-02, 1.1469e-01, 6.7871e-02, -5.8350e-02, 1.0297e-01, -6.3086e-01, -8.3350e-01, 4.3481e-01, -1.7383e-01, -1.5491e-01, -5.5176e-01, 5.9766e-01, -2.6880e-01, 5.6976e-02, -2.6318e-01, -4.0466e-02, 2.4927e-01, -1.4893e-01, -2.0032e-01, -2.7515e-01, -1.2598e-01, 3.2440e-02, -1.2939e-01, 6.8018e-01, -3.6060e-01, -3.3496e-01, 9.8267e-02, -1.0010e-01, 1.9653e-01, -3.3032e-01, -2.0032e-01, 1.9116e-01, 8.2214e-02, 3.2397e-01, 1.3708e-01, 3.0899e-02, 1.5454e-01, 3.2422e-01, 1.0693e-01, 3.1714e-01, 3.7280e-01, -2.3401e-01, -5.0171e-02, 7.6758e-01, 2.2046e-01, 3.3997e-02, 1.0231e-02, -2.3999e-01, -1.3672e-01, 5.2002e-01, -6.5552e-02, 6.9275e-02, 2.3706e-01, -3.8257e-01, 1.4990e-01, -2.2656e-01, 4.3018e-01, -4.4678e-01, 2.5977e-01, 3.8208e-01, 9.5215e-02, -2.0239e-01, -2.3169e-01, -3.1396e-01, 3.2806e-02, -2.7905e-01, -1.0361e+00, 3.8147e-02, -1.0278e-01, 2.8369e-01, -3.8623e-01, -2.3132e-01, 1.5784e-01, 4.2734e+00, -1.5820e-01, -1.4758e-01, 2.0032e-01, -1.9678e-01, -7.5586e-01, 1.0712e-01, -2.1777e-01, -4.0552e-01, -1.0919e-01, 1.1932e-01, 7.3486e-01, -1.7700e-01, 5.0732e-01, -9.7351e-02, -4.7192e-01, 5.9052e-02, -7.0117e-01, -1.8774e-01, 2.4329e-01, 3.5083e-01, -2.3633e-01, 2.2205e-01, -2.4719e-03, 4.4507e-01, -1.1005e-01, 5.6494e-01, -1.4697e-01, -8.5022e-02, -2.6050e-01, -8.3679e-02, 3.0615e-01, 1.0181e-01, -2.2266e-01, -1.2054e-01, 1.0094e-02, -1.6382e-01, 3.7671e-01, 1.1371e-01, 8.8959e-03, -1.2866e-01, 7.5500e-02, -3.1177e-01, 9.0698e-02, 2.4139e-02, 2.7124e-01, 4.1382e-01, 9.3872e-02, -3.5815e-01, -1.0602e-01, -2.7637e-01, 1.5613e-01, 2.6025e-01, -1.3428e-01, -2.1509e-01, -3.0005e-01, 7.7515e-02, -2.2253e-01, -1.2634e-01, 1.0114e-01, 2.9395e-01, 4.2065e-01, -4.6425e-03, -6.3721e-01, -4.0308e-01, -5.1849e-02, -9.1309e-02, 1.0577e-01, -1.6800e-02, -4.4823e-03, 2.4231e-01, -1.3635e-01, 1.7041e-01, -9.9243e-02, -1.2439e-01, 1.5247e-01, 1.4717e-02, -1.6785e-01, -3.0615e-01, 2.6074e-01, 1.0938e-01, 4.9487e-01, 1.0529e-01, 3.1799e-02, 7.5928e-02, -1.1212e-01, -3.1201e-01, 5.8740e-01, -1.3171e-01, -1.1090e-01, 5.8887e-01, -1.1420e-01, -2.0056e-01, 1.0425e-01, 2.7710e-01, -5.8098e-03, 5.7324e-01, -1.4417e-01, 1.4575e-01, -2.7466e-01, -2.1313e-01, -1.7627e-01, 1.5466e-01, 3.8013e-01, -1.4612e-01, -2.7246e-01, -1.8604e-01, 1.0394e-01, 1.6016e-01, -1.1017e-01, 1.8140e-01, -3.0078e-01, 6.0303e-01, -1.3904e-01, 1.7322e-01, 2.2510e-01, 2.3303e-01, -5.0879e-01, -2.3462e-01, -2.0544e-01, -2.4768e-01, -2.4121e-01, -7.2754e-01, 7.2754e-01, -4.4312e-02, -1.4198e-02, -1.1475e-01, -1.3684e-01, -3.5278e-01, 1.2347e-01, -2.9602e-02, 4.0550e-03, 1.1951e-01, -6.5575e-03, -7.1228e-02, -3.8062e-01, 6.5125e-02, -1.6541e-01, -3.0289e-02, 8.6609e-02, -1.2134e-01, -1.2164e-01, 3.0319e-02, -1.5173e-01, -7.9834e-02, 1.4148e-01, 2.7319e-01, -2.1545e-01, -1.6382e-01, -2.9419e-01, -2.6611e-01, -7.5102e-04, 1.3135e-01, 9.8389e-02, 3.1812e-01, 5.5115e-02, -5.3253e-02, 4.3823e-02, 3.6957e-02, -1.3599e-01, 1.1023e-01, 9.8267e-02, 2.1643e-01, 9.3567e-02, 1.2718e-02, 1.6406e-01, -1.0338e-02, 1.9019e-01, 1.4392e-01, 3.3081e-02, 1.0138e-01, -1.6943e-01, 8.6136e-03, 1.4478e-01, 1.0941e-02, 1.3635e-01, -8.1543e-01, -3.4912e-01, 7.4959e-03, 2.1997e-01, -2.5681e-02, 2.3206e-01, 3.7622e-01, 3.6401e-01, -1.6357e-01, -2.0984e-01, -1.3220e-01, -6.7322e-02, 2.0117e-01, -4.7583e-01, 6.8054e-02, 2.2437e-01, 2.6709e-01, -5.4626e-02, -4.0741e-02, 5.2002e-02, -1.8872e-01, 3.1372e-01, -1.3574e-01, -2.6538e-01];
|
637 |
+
</script>
|
638 |
+
</body>
|
639 |
</html>
|
vips/vips.d.ts
ADDED
The diff for this file is too large to render.
See raw diff
|
|
vips/vips.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
var Vips=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return function(t){var n,r,o,i;t=t||{},n||(n=void 0!==t?t:{}),n.ready=new Promise((function(e,t){r=e,o=t})),n.locateFile=n.locateFile||function(e,t){return(e=t+e).endsWith(".worker.js")?i||(i=URL.createObjectURL(new Blob([`importScripts('${e}');`],{type:"application/javascript"}))):e};var a,c,u,s=Object.assign({},n),f=[],l="./this.program",d=(e,t)=>{throw t},h="object"==typeof window,b="function"==typeof importScripts,p="object"==typeof process&&"object"==typeof process.Pf&&"string"==typeof process.Pf.node,m=n.ENVIRONMENT_IS_PTHREAD||!1,v="";function w(e){return n.locateFile?n.locateFile(e,v):v+e}(h||b)&&(b?v=self.location.href:"undefined"!=typeof document&&document.currentScript&&(v=document.currentScript.src),e&&(v=e),v=0!==v.indexOf("blob:")?v.substr(0,v.replace(/[?#].*/,"").lastIndexOf("/")+1):"",a=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},b&&(u=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),c=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var y=n.print||console.log.bind(console),g=n.printErr||console.warn.bind(console);function k(e){_||(_={}),_[e]||(_[e]=1,g(e))}Object.assign(n,s),s=null,n.arguments&&(f=n.arguments),n.thisProgram&&(l=n.thisProgram),n.quit&&(d=n.quit);var _,P,A,T=[],N=0;n.wasmBinary&&(A=n.wasmBinary);var E=n.noExitRuntime||!1;"object"!=typeof WebAssembly&&Ae("no native wasm support detected");var O,S,D,R=!1;function F(e){var t=new TextDecoder(e);this.fc=e=>(e.buffer instanceof SharedArrayBuffer&&(e=new Uint8Array(e)),t.decode.call(t,e))}var M=new F("utf8");function x(e){for(var t=0;e[t]&&!(NaN<=t);)++t;return M.fc(e.subarray?e.subarray(0,t):new Uint8Array(e.slice(0,t)))}function L(e,t){if(!e)return"";t=e+t;for(var n=e;!(n>=t)&&B[n];)++n;return M.fc(B.subarray(e,n))}function U(e,t,n,r){if(!(0<r))return 0;var o=n;r=n+r-1;for(var i=0;i<e.length;++i){var a=e.charCodeAt(i);if(55296<=a&&57343>=a)a=65536+((1023&a)<<10)|1023&e.charCodeAt(++i);if(127>=a){if(n>=r)break;t[n++]=a}else{if(2047>=a){if(n+1>=r)break;t[n++]=192|a>>6}else{if(65535>=a){if(n+2>=r)break;t[n++]=224|a>>12}else{if(n+3>=r)break;t[n++]=240|a>>18,t[n++]=128|a>>12&63}t[n++]=128|a>>6&63}t[n++]=128|63&a}}return t[n]=0,n-o}function W(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);55296<=r&&57343>=r&&(r=65536+((1023&r)<<10)|1023&e.charCodeAt(++n)),127>=r?++t:t=2047>=r?t+2:65535>=r?t+3:t+4}return t}var C,j,B,I,V,z,Q,q,H,Y,X,G=new F("utf-16le");function Z(e,t){var n=e>>1;for(t=n+t/2;!(n>=t)&&V[n];)++n;return G.fc(B.subarray(e,n<<1))}function $(e,t,n){if(void 0===n&&(n=2147483647),2>n)return 0;var r=t;n=(n-=2)<2*e.length?n/2:e.length;for(var o=0;o<n;++o)I[t>>1]=e.charCodeAt(o),t+=2;return I[t>>1]=0,t-r}function J(e){return 2*e.length}function K(e,t){for(var n=0,r="";!(n>=t/4);){var o=z[e+4*n>>2];if(0==o)break;++n,65536<=o?(o-=65536,r+=String.fromCharCode(55296|o>>10,56320|1023&o)):r+=String.fromCharCode(o)}return r}function ee(e,t,n){if(void 0===n&&(n=2147483647),4>n)return 0;var r=t;n=r+n-4;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(55296<=i&&57343>=i)i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o);if(z[t>>2]=i,(t+=4)+4>n)break}return z[t>>2]=0,t-r}function te(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);55296<=r&&57343>=r&&++n,t+=4}return t}function ne(e){var t=W(e)+1,n=Kr(t);return n&&U(e,j,n,t),n}function re(e){var t=W(e)+1,n=go(t);return U(e,j,n,t),n}m&&(C=n.buffer);var oe=n.INITIAL_MEMORY||1073741824;if(m)O=n.wasmMemory,C=n.buffer;else if(n.wasmMemory)O=n.wasmMemory;else if(!((O=new WebAssembly.Memory({initial:oe/65536,maximum:oe/65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw g("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),p&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");O&&(C=O.buffer),oe=C.byteLength;var ie=C;C=ie,n.HEAP8=j=new Int8Array(ie),n.HEAP16=I=new Int16Array(ie),n.HEAP32=z=new Int32Array(ie),n.HEAPU8=B=new Uint8Array(ie),n.HEAPU16=V=new Uint16Array(ie),n.HEAPU32=Q=new Uint32Array(ie),n.HEAPF32=q=new Float32Array(ie),n.HEAPF64=X=new Float64Array(ie),n.HEAP64=H=new BigInt64Array(ie),n.HEAPU64=Y=new BigUint64Array(ie);var ae,ce=[],ue=[],se=[],fe=[],le=[],de=!1,he=0;function be(){return E||0<he}function pe(){m||(n.noFSInit||Rt.init.vd||Rt.init(),Rt.be=!1,Yt.root=Rt.mount(Yt,{},null),st(ue))}function me(){m||(io(),st(fe),Rt.vf(),dt.me(),de=!0)}function ve(){var e=n.preRun.shift();ce.unshift(e)}var we,ye=0,ge=null,ke=null;function _e(){ye++,n.monitorRunDependencies&&n.monitorRunDependencies(ye)}function Pe(){if(ye--,n.monitorRunDependencies&&n.monitorRunDependencies(ye),0==ye&&(null!==ge&&(clearInterval(ge),ge=null),ke)){var e=ke;ke=null,e()}}function Ae(e){throw m?postMessage({cmd:"onAbort",arg:e}):n.onAbort&&n.onAbort(e),g(e="Aborted("+e+")"),R=!0,D=1,e=new WebAssembly.RuntimeError(e+". Build with -s ASSERTIONS=1 for more info."),o(e),e}function Te(){return we.startsWith("data:application/octet-stream;base64,")}function Ne(){var e=we;try{if(e==we&&A)return new Uint8Array(A);if(u)return u(e);throw"both async and sync fetching of the wasm failed"}catch(e){Ae(e)}}n.preloadedImages={},n.preloadedAudios={},we="vips.wasm",Te()||(we=w(we));var Ee,Oe={};function Se(e){for(var t=V[e+6>>1];13===t;){var n=Q[e+8>>2],r=Q[n>>2];if(0===r){t=0;break}if(0!==Q[1+(n>>2)])break;e=r,t=V[r+6>>1]}return[e,t]}function De(e){e instanceof _o||"unwind"==e||d(1,e)}function Re(){if(!be())try{m?po(D):Ao(D)}catch(e){De(e)}}function Fe(e){if(!de&&!R)try{e(),Re()}catch(e){De(e)}}Ee=m?()=>performance.now()-n.__performance_now_clock_drift:()=>performance.now();var Me,xe,Le,Ue=!1,We=null,Ce=0,je=null,Be=0,Ie=0,Ve=0,ze=[],Qe={},qe=!1,He=!1,Ye=[];function Xe(){function e(){He=document.pointerLockElement===n.canvas||document.mozPointerLockElement===n.canvas||document.webkitPointerLockElement===n.canvas||document.msPointerLockElement===n.canvas}if(n.preloadPlugins||(n.preloadPlugins=[]),!nt){nt=!0;try{rt=!0}catch(e){rt=!1,y("warning: no blob constructor, cannot create blobs with mimetypes")}ot="undefined"!=typeof MozBlobBuilder?MozBlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:rt?null:y("warning: no BlobBuilder"),it="undefined"!=typeof window?window.URL?window.URL:window.webkitURL:void 0,n.ge||void 0!==it||(y("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),n.ge=!0),n.preloadPlugins.push({canHandle:function(e){return!n.ge&&/\.(jpg|jpeg|png|bmp)$/i.test(e)},handle:function(e,t,r,o){var i=null;if(rt)try{(i=new Blob([e],{type:tt(t)})).size!==e.length&&(i=new Blob([new Uint8Array(e).buffer],{type:tt(t)}))}catch(e){k("Blob constructor present but fails: "+e+"; falling back to blob builder")}i||((i=new ot).append(new Uint8Array(e).buffer),i=i.getBlob());var a=it.createObjectURL(i),c=new Image;c.onload=()=>{c.complete||Ae("Image "+t+" could not be decoded");var o=document.createElement("canvas");o.width=c.width,o.height=c.height,o.getContext("2d").drawImage(c,0,0),n.preloadedImages[t]=o,it.revokeObjectURL(a),r&&r(e)},c.onerror=()=>{y("Image "+a+" could not be decoded"),o&&o()},c.src=a}}),n.preloadPlugins.push({canHandle:function(e){return!n.hg&&e.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},handle:function(e,t,r,o){function i(o){c||(c=!0,n.preloadedAudios[t]=o,r&&r(e))}function a(){c||(c=!0,n.preloadedAudios[t]=new Audio,o&&o())}var c=!1;if(!rt)return a();try{var u=new Blob([e],{type:tt(t)})}catch(e){return a()}u=it.createObjectURL(u);var s=new Audio;s.addEventListener("canplaythrough",(function(){i(s)}),!1),s.onerror=function(){if(!c){y("warning: browser could not fully decode audio "+t+", trying slower base64 approach");for(var n="",r=0,o=0,a=0;a<e.length;a++)for(r=r<<8|e[a],o+=8;6<=o;){var u=r>>o-6&63;o-=6,n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u]}2==o?(n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&r)<<4],n+="=="):4==o&&(n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&r)<<2],n+="="),s.src="data:audio/x-"+t.substr(-3)+";base64,"+n,i(s)}},s.src=u,function(e){he+=1,setTimeout((function(){--he,Fe(e)}),1e4)}((function(){i(s)}))}});var t=n.canvas;t&&(t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock||t.msRequestPointerLock||function(){},t.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||function(){},t.exitPointerLock=t.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",e,!1),document.addEventListener("mozpointerlockchange",e,!1),document.addEventListener("webkitpointerlockchange",e,!1),document.addEventListener("mspointerlockchange",e,!1),n.elementPointerLock&&t.addEventListener("click",(function(e){!He&&n.canvas.requestPointerLock&&(n.canvas.requestPointerLock(),e.preventDefault())}),!1))}}var Ge=!1,Ze=void 0,$e=void 0;function Je(){return!!qe&&((document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||function(){}).apply(document,[]),!0)}var Ke=0;function et(e){if("function"==typeof requestAnimationFrame)requestAnimationFrame(e);else{var t=Date.now();if(0===Ke)Ke=t+1e3/60;else for(;t+2>=Ke;)Ke+=1e3/60;setTimeout(e,Math.max(Ke-t,0))}}function tt(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]}var nt,rt,ot,it,at=[];function ct(){var e=n.canvas;at.forEach((function(t){t(e.width,e.height)}))}function ut(e,t,r){t&&r?(e.Qf=t,e.Ze=r):(t=e.Qf,r=e.Ze);var o=t,i=r;if(n.forcedAspectRatio&&0<n.forcedAspectRatio&&(o/i<n.forcedAspectRatio?o=Math.round(i*n.forcedAspectRatio):i=Math.round(o/n.forcedAspectRatio)),(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e.parentNode&&"undefined"!=typeof screen){var a=Math.min(screen.width/o,screen.height/i);o=Math.round(o*a),i=Math.round(i*a)}$e?(e.width!=o&&(e.width=o),e.height!=i&&(e.height=i),void 0!==e.style&&(e.style.removeProperty("width"),e.style.removeProperty("height"))):(e.width!=t&&(e.width=t),e.height!=r&&(e.height=r),void 0!==e.style&&(o!=t||i!=r?(e.style.setProperty("width",o+"px","important"),e.style.setProperty("height",i+"px","important")):(e.style.removeProperty("width"),e.style.removeProperty("height"))))}function st(e){for(;0<e.length;){var t=e.shift();if("function"==typeof t)t(n);else{var r=t.Re;"number"==typeof r?void 0===t.Cc?pt(r)():pt(r)(t.Cc):r(void 0===t.Cc?null:t.Cc)}}}function ft(e){var t=wo();return e=e(),yo(t),e}function lt(e){var t=dt.pc[e];t&&(z[e>>2]=0,dt.le(t.worker))}var dt={qc:[],Vc:[],gd:[],init:function(){m?dt.cf():dt.bf()},bf:function(){for(var e=wr()+3,t=0;t<e;++t)dt.Kd()},cf:function(){dt.receiveObjectTransfer=dt.yf,dt.threadInit=dt.ne,dt.setExitStatus=dt.Cf,E=!1},pc:{},Cf:function(e){D=e},me:function(){for(var e in dt.pc){var t=dt.pc[e];t&&t.worker&&dt.le(t.worker)}for(e=0;e<dt.qc.length;++e)dt.qc[e].terminate();dt.qc=[]},le:function(e){dt.Af((function(){delete dt.pc[e.Ic.Hd],dt.qc.push(e),dt.Vc.splice(dt.Vc.indexOf(e),1),bo(e.Ic.Hd),e.Ic=void 0}))},Af:function(e){z[ko>>2]=0;try{e()}finally{z[ko>>2]=1}},yf:function(){},ne:function(){for(var e in dt.gd)dt.gd.hasOwnProperty(e)&&dt.gd[e]()},de:function(t,r){t.onmessage=e=>{var o=(e=e.data).cmd;if(t.Ic&&(dt.Je=t.Ic.Hd),e.targetThread&&e.targetThread!=ao()){var i=dt.pc[e.ng];i?i.worker.postMessage(e,e.transferList):g('Internal error! Worker sent a message "'+o+'" to target pthread '+e.targetThread+", but that thread no longer exists!")}else"processQueuedMainThreadWork"===o?co():"spawnThread"===o?vt(e):"cleanupThread"===o?lt(e.thread):"killThread"===o?(e=e.thread,z[e>>2]=0,o=dt.pc[e],delete dt.pc[e],o.worker.terminate(),bo(e),dt.Vc.splice(dt.Vc.indexOf(o.worker),1),o.worker.Ic=void 0):"cancelThread"===o?dt.pc[e.thread].worker.postMessage({cmd:"cancel"}):"loaded"===o?(t.loaded=!0,r&&r(t),t.Uc&&(t.Uc(),delete t.Uc)):"print"===o?y("Thread "+e.threadId+": "+e.text):"printErr"===o?g("Thread "+e.threadId+": "+e.text):"alert"===o?alert("Thread "+e.threadId+": "+e.text):"setimmediate"===e.target?t.postMessage(e):"onAbort"===o?n.onAbort&&n.onAbort(e.arg):g("worker sent an unknown command "+o);dt.Je=void 0},t.onerror=e=>{throw g("worker sent an error! "+e.filename+":"+e.lineno+": "+e.message),e},t.postMessage({cmd:"load",urlOrBlob:n.mainScriptUrlOrBlob||e,wasmMemory:O,wasmModule:S})},Kd:function(){var e=w("vips.worker.js");dt.qc.push(new Worker(e))},Ue:function(){return 0==dt.qc.length&&(dt.Kd(),dt.de(dt.qc[0])),dt.qc.pop()}};function ht(e){if(m)return yr(1,0,e);try{Ao(e)}catch(e){De(e)}}n.establishStackSpace=function(){var e=ao(),t=z[e+44>>2];vo(t,t-z[e+48>>2]),yo(t)};var bt=[];function pt(e){var t=bt[e];return t||(e>=bt.length&&(bt.length=e+1),bt[e]=t=ae.get(e)),t}function mt(e,t){if(0===e)e=Date.now();else{if(1!==e&&4!==e)return z[to()>>2]=28,-1;e=Ee()}return z[t>>2]=e/1e3|0,z[t+4>>2]=e%1e3*1e6|0,0}function vt(e){var t=dt.Ue();if(!t)return 6;dt.Vc.push(t);var n=dt.pc[e.Bd]={worker:t,Hd:e.Bd};t.Ic=n;var r={cmd:"run",start_routine:e.Hf,arg:e.Cc,threadInfoStruct:e.Bd};return t.Uc=()=>{r.time=performance.now(),t.postMessage(r,e.Nf)},t.loaded&&(t.Uc(),delete t.Uc),0}function wt(e,t){for(var n=0,r=e.length-1;0<=r;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift("..");return e}function yt(e){var t="/"===e.charAt(0),n="/"===e.substr(-1);return(e=wt(e.split("/").filter((function(e){return!!e})),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e}function gt(e){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."}function kt(e){if("/"===e)return"/";var t=(e=(e=yt(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)}function _t(e,t){return yt(e+"/"+t)}function Pt(){for(var e="",t=!1,n=arguments.length-1;-1<=n&&!t;n--){if("string"!=typeof(t=0<=n?arguments[n]:Rt.cwd()))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=wt(e.split("/").filter((function(e){return!!e})),!t).join("/"))||"."}function At(e,t){function n(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;0<=n&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=Pt(e).substr(1),t=Pt(t).substr(1),e=n(e.split("/")),t=n(t.split("/"));for(var r=Math.min(e.length,t.length),o=r,i=0;i<r;i++)if(e[i]!==t[i]){o=i;break}for(r=[],i=o;i<e.length;i++)r.push("..");return(r=r.concat(t.slice(o))).join("/")}n.invokeEntryPoint=function(e,t){return pt(e)(t)};var Tt=[];function Nt(e,t){Tt[e]={input:[],ac:[],Hc:t},Rt.registerDevice(e,Et)}var Et={open:function(e){var t=Tt[e.node.Sc];if(!t)throw new Rt.Nb(43);e.Yb=t,e.seekable=!1},close:function(e){e.Yb.Hc.flush(e.Yb)},flush:function(e){e.Yb.Hc.flush(e.Yb)},read:function(e,t,n,r){if(!e.Yb||!e.Yb.Hc.Zd)throw new Rt.Nb(60);for(var o=0,i=0;i<r;i++){try{var a=e.Yb.Hc.Zd(e.Yb)}catch(e){throw new Rt.Nb(29)}if(void 0===a&&0===o)throw new Rt.Nb(6);if(null==a)break;o++,t[n+i]=a}return o&&(e.node.timestamp=Date.now()),o},write:function(e,t,n,r){if(!e.Yb||!e.Yb.Hc.Cd)throw new Rt.Nb(60);try{for(var o=0;o<r;o++)e.Yb.Hc.Cd(e.Yb,t[n+o])}catch(e){throw new Rt.Nb(29)}return r&&(e.node.timestamp=Date.now()),o}},Ot={Zd:function(e){if(!e.input.length){var t=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&(null!==(t=readline())&&(t+="\n")),!t)return null;e.input=$r(t,!0)}return e.input.shift()},Cd:function(e,t){null===t||10===t?(y(x(e.ac)),e.ac=[]):0!=t&&e.ac.push(t)},flush:function(e){e.ac&&0<e.ac.length&&(y(x(e.ac)),e.ac=[])}},St={Cd:function(e,t){null===t||10===t?(g(x(e.ac)),e.ac=[]):0!=t&&e.ac.push(t)},flush:function(e){e.ac&&0<e.ac.length&&(g(x(e.ac)),e.ac=[])}},Dt={oc:null,mount:function(){return Dt.createNode(null,"/",16895,0)},createNode:function(e,t,n,r){if(Rt.isBlkdev(n)||Rt.df(n))throw new Rt.Nb(63);return Dt.oc||(Dt.oc={dir:{node:{mc:Dt.Pb.mc,$b:Dt.Pb.$b,zc:Dt.Pb.zc,sc:Dt.Pb.sc,rename:Dt.Pb.rename,unlink:Dt.Pb.unlink,rmdir:Dt.Pb.rmdir,Tc:Dt.Pb.Tc,symlink:Dt.Pb.symlink},stream:{llseek:Dt.Qb.llseek}},file:{node:{mc:Dt.Pb.mc,$b:Dt.Pb.$b},stream:{llseek:Dt.Qb.llseek,read:Dt.Qb.read,write:Dt.Qb.write,Lc:Dt.Qb.Lc,Fc:Dt.Qb.Fc,Gc:Dt.Qb.Gc}},link:{node:{mc:Dt.Pb.mc,$b:Dt.Pb.$b,readlink:Dt.Pb.readlink},stream:{}},Md:{node:{mc:Dt.Pb.mc,$b:Dt.Pb.$b},stream:Rt.ze}}),n=Rt.createNode(e,t,n,r),Rt.isDir(n.mode)?(n.Pb=Dt.oc.dir.node,n.Qb=Dt.oc.dir.stream,n.Rb={}):Rt.isFile(n.mode)?(n.Pb=Dt.oc.file.node,n.Qb=Dt.oc.file.stream,n.Vb=0,n.Rb=null):Rt.isLink(n.mode)?(n.Pb=Dt.oc.link.node,n.Qb=Dt.oc.link.stream):Rt.isChrdev(n.mode)&&(n.Pb=Dt.oc.Md.node,n.Qb=Dt.oc.Md.stream),n.timestamp=Date.now(),e&&(e.Rb[t]=n,e.timestamp=n.timestamp),n},$f:function(e){return e.Rb?e.Rb.subarray?e.Rb.subarray(0,e.Vb):new Uint8Array(e.Rb):new Uint8Array(0)},Ud:function(e,t){var n=e.Rb?e.Rb.length:0;n>=t||(t=Math.max(t,n*(1048576>n?2:1.125)>>>0),0!=n&&(t=Math.max(t,256)),n=e.Rb,e.Rb=new Uint8Array(t),0<e.Vb&&e.Rb.set(n.subarray(0,e.Vb),0))},zf:function(e,t){if(e.Vb!=t)if(0==t)e.Rb=null,e.Vb=0;else{var n=e.Rb;e.Rb=new Uint8Array(t),n&&e.Rb.set(n.subarray(0,Math.min(t,e.Vb))),e.Vb=t}},Pb:{mc:function(e){var t={};return t.Ke=Rt.isChrdev(e.mode)?e.id:1,t.ce=e.id,t.mode=e.mode,t.nf=1,t.uid=0,t.Ye=0,t.Sc=e.Sc,Rt.isDir(e.mode)?t.size=4096:Rt.isFile(e.mode)?t.size=e.Vb:Rt.isLink(e.mode)?t.size=e.link.length:t.size=0,t.ue=new Date(e.timestamp),t.kf=new Date(e.timestamp),t.Ie=new Date(e.timestamp),t.ve=4096,t.we=Math.ceil(t.size/t.ve),t},$b:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&Dt.zf(e,t.size)},zc:function(){throw Rt.rd[44]},sc:function(e,t,n,r){return Dt.createNode(e,t,n,r)},rename:function(e,t,n){if(Rt.isDir(e.mode)){try{var r=Rt.rc(t,n)}catch(e){}if(r)for(var o in r.Rb)throw new Rt.Nb(55)}delete e.parent.Rb[e.name],e.parent.timestamp=Date.now(),e.name=n,t.Rb[n]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink:function(e,t){delete e.Rb[t],e.timestamp=Date.now()},rmdir:function(e,t){var n,r=Rt.rc(e,t);for(n in r.Rb)throw new Rt.Nb(55);delete e.Rb[t],e.timestamp=Date.now()},Tc:function(e){var t,n=[".",".."];for(t in e.Rb)e.Rb.hasOwnProperty(t)&&n.push(t);return n},symlink:function(e,t,n){return(e=Dt.createNode(e,t,41471,0)).link=n,e},readlink:function(e){if(!Rt.isLink(e.mode))throw new Rt.Nb(28);return e.link}},Qb:{read:function(e,t,n,r,o){var i=e.node.Rb;if(o>=e.node.Vb)return 0;if(8<(e=Math.min(e.node.Vb-o,r))&&i.subarray)t.set(i.subarray(o,o+e),n);else for(r=0;r<e;r++)t[n+r]=i[o+r];return e},write:function(e,t,n,r,o,i){if(!r)return 0;if((e=e.node).timestamp=Date.now(),t.subarray&&(!e.Rb||e.Rb.subarray)){if(i)return e.Rb=t.subarray(n,n+r),e.Vb=r;if(0===e.Vb&&0===o)return e.Rb=t.slice(n,n+r),e.Vb=r;if(o+r<=e.Vb)return e.Rb.set(t.subarray(n,n+r),o),r}if(Dt.Ud(e,o+r),e.Rb.subarray&&t.subarray)e.Rb.set(t.subarray(n,n+r),o);else for(i=0;i<r;i++)e.Rb[o+i]=t[n+i];return e.Vb=Math.max(e.Vb,o+r),r},llseek:function(e,t,n){if(1===n?t+=e.position:2===n&&Rt.isFile(e.node.mode)&&(t+=e.node.Vb),0>t)throw new Rt.Nb(28);return t},Lc:function(e,t,n){Dt.Ud(e.node,t+n),e.node.Vb=Math.max(e.node.Vb,t+n)},Fc:function(e,t,n,r,o,i){if(0!==t)throw new Rt.Nb(28);if(!Rt.isFile(e.node.mode))throw new Rt.Nb(43);if(e=e.node.Rb,2&i||e.buffer!==C){if((0<r||r+n<e.length)&&(e=e.subarray?e.subarray(r,r+n):Array.prototype.slice.call(e,r,r+n)),r=!0,n=65536*Math.ceil(n/65536),(i=no(65536,n))?(B.fill(0,i,i+n),n=i):n=0,!n)throw new Rt.Nb(48);j.set(e,n)}else r=!1,n=e.byteOffset;return{Ub:n,te:r}},Gc:function(e,t,n,r,o){if(!Rt.isFile(e.node.mode))throw new Rt.Nb(43);return 2&o||Dt.Qb.write(e,t,0,r,n,!1),0}}};var Rt={root:null,Oc:[],Rd:{},streams:[],lf:1,nc:null,Pd:"/",vd:!1,be:!0,Nb:null,rd:{},Pe:null,fd:0,lookupPath:(e,t={})=>{if(!(e=Pt(Rt.cwd(),e)))return{path:"",node:null};if(8<(t=Object.assign({qd:!0,Fd:0},t)).Fd)throw new Rt.Nb(32);e=wt(e.split("/").filter((e=>!!e)),!1);for(var n=Rt.root,r="/",o=0;o<e.length;o++){var i=o===e.length-1;if(i&&t.parent)break;if(n=Rt.rc(n,e[o]),r=_t(r,e[o]),Rt.yc(n)&&(!i||i&&t.qd)&&(n=n.Nc.root),!i||t.follow)for(i=0;Rt.isLink(n.mode);)if(n=Rt.readlink(r),r=Pt(gt(r),n),n=Rt.lookupPath(r,{Fd:t.Fd+1}).node,40<i++)throw new Rt.Nb(32)}return{path:r,node:n}},getPath:e=>{for(var t;;){if(Rt.cd(e))return e=e.mount.fe,t?"/"!==e[e.length-1]?e+"/"+t:e+t:e;t=t?e.name+"/"+t:e.name,e=e.parent}},ud:(e,t)=>{for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%Rt.nc.length},$d:e=>{var t=Rt.ud(e.parent.id,e.name);e.Ac=Rt.nc[t],Rt.nc[t]=e},ae:e=>{var t=Rt.ud(e.parent.id,e.name);if(Rt.nc[t]===e)Rt.nc[t]=e.Ac;else for(t=Rt.nc[t];t;){if(t.Ac===e){t.Ac=e.Ac;break}t=t.Ac}},rc:(e,t)=>{var n=Rt.gf(e);if(n)throw new Rt.Nb(n,e);for(n=Rt.nc[Rt.ud(e.id,t)];n;n=n.Ac){var r=n.name;if(n.parent.id===e.id&&r===t)return n}return Rt.zc(e,t)},createNode:(e,t,n,r)=>(e=new Rt.oe(e,t,n,r),Rt.$d(e),e),od:e=>{Rt.ae(e)},cd:e=>e===e.parent,yc:e=>!!e.Nc,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),df:e=>4096==(61440&e),isSocket:e=>49152==(49152&e),Qe:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},jf:e=>{var t=Rt.Qe[e];if(void 0===t)throw Error("Unknown file open mode: "+e);return t},Wd:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},wc:(e,t)=>Rt.be?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2,gf:e=>{var t=Rt.wc(e,"x");return t||(e.Pb.zc?0:2)},Ad:(e,t)=>{try{return Rt.rc(e,t),20}catch(e){}return Rt.wc(e,"wx")},ed:(e,t,n)=>{try{var r=Rt.rc(e,t)}catch(e){return e.Tb}if(e=Rt.wc(e,"wx"))return e;if(n){if(!Rt.isDir(r.mode))return 54;if(Rt.cd(r)||Rt.getPath(r)===Rt.cwd())return 10}else if(Rt.isDir(r.mode))return 31;return 0},hf:(e,t)=>e?Rt.isLink(e.mode)?32:Rt.isDir(e.mode)&&("r"!==Rt.Wd(t)||512&t)?31:Rt.wc(e,Rt.Wd(t)):44,pe:4096,mf:(e=0,t=Rt.pe)=>{for(;e<=t;e++)if(!Rt.streams[e])return e;throw new Rt.Nb(33)},lc:e=>Rt.streams[e],md:(e,t,n)=>(Rt.ld||(Rt.ld=function(){},Rt.ld.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}}}),e=Object.assign(new Rt.ld,e),t=Rt.mf(t,n),e.kc=t,Rt.streams[t]=e),Ae:e=>{Rt.streams[e]=null},ze:{open:e=>{e.Qb=Rt.Te(e.node.Sc).Qb,e.Qb.open&&e.Qb.open(e)},llseek:()=>{throw new Rt.Nb(70)}},zd:e=>e>>8,cg:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{Rt.Rd[e]={Qb:t}},Te:e=>Rt.Rd[e],Yd:e=>{var t=[];for(e=[e];e.length;){var n=e.pop();t.push(n),e.push.apply(e,n.Oc)}return t},syncfs:(e,t)=>{function n(e){return Rt.fd--,t(e)}function r(e){if(e){if(!r.Me)return r.Me=!0,n(e)}else++i>=o.length&&n(null)}"function"==typeof e&&(t=e,e=!1),Rt.fd++,1<Rt.fd&&g("warning: "+Rt.fd+" FS.syncfs operations in flight at once, probably just doing extra work");var o=Rt.Yd(Rt.root.mount),i=0;o.forEach((t=>{if(!t.type.syncfs)return r(null);t.type.syncfs(t,e,r)}))},mount:(e,t,n)=>{var r="/"===n,o=!n;if(r&&Rt.root)throw new Rt.Nb(10);if(!r&&!o){var i=Rt.lookupPath(n,{qd:!1});if(n=i.path,i=i.node,Rt.yc(i))throw new Rt.Nb(10);if(!Rt.isDir(i.mode))throw new Rt.Nb(54)}return t={type:e,jg:t,fe:n,Oc:[]},(e=e.mount(t)).mount=t,t.root=e,r?Rt.root=e:i&&(i.Nc=t,i.mount&&i.mount.Oc.push(t)),e},unmount:e=>{if(e=Rt.lookupPath(e,{qd:!1}),!Rt.yc(e.node))throw new Rt.Nb(28);var t=(e=e.node).Nc,n=Rt.Yd(t);Object.keys(Rt.nc).forEach((e=>{for(e=Rt.nc[e];e;){var t=e.Ac;n.includes(e.mount)&&Rt.od(e),e=t}})),e.Nc=null,e.mount.Oc.splice(e.mount.Oc.indexOf(t),1)},zc:(e,t)=>e.Pb.zc(e,t),sc:(e,t,n)=>{var r=Rt.lookupPath(e,{parent:!0}).node;if(!(e=kt(e))||"."===e||".."===e)throw new Rt.Nb(28);var o=Rt.Ad(r,e);if(o)throw new Rt.Nb(o);if(!r.Pb.sc)throw new Rt.Nb(63);return r.Pb.sc(r,e,t,n)},create:(e,t)=>Rt.sc(e,4095&(void 0!==t?t:438)|32768,0),mkdir:(e,t)=>Rt.sc(e,1023&(void 0!==t?t:511)|16384,0),eg:(e,t)=>{e=e.split("/");for(var n="",r=0;r<e.length;++r)if(e[r]){n+="/"+e[r];try{Rt.mkdir(n,t)}catch(e){if(20!=e.Tb)throw e}}},mkdev:(e,t,n)=>(void 0===n&&(n=t,t=438),Rt.sc(e,8192|t,n)),symlink:(e,t)=>{if(!Pt(e))throw new Rt.Nb(44);var n=Rt.lookupPath(t,{parent:!0}).node;if(!n)throw new Rt.Nb(44);t=kt(t);var r=Rt.Ad(n,t);if(r)throw new Rt.Nb(r);if(!n.Pb.symlink)throw new Rt.Nb(63);return n.Pb.symlink(n,t,e)},rename:(e,t)=>{var n=gt(e),r=gt(t),o=kt(e),i=kt(t),a=Rt.lookupPath(e,{parent:!0}),c=a.node;if(a=(a=Rt.lookupPath(t,{parent:!0})).node,!c||!a)throw new Rt.Nb(44);if(c.mount!==a.mount)throw new Rt.Nb(75);var u=Rt.rc(c,o);if("."!==(e=At(e,r)).charAt(0))throw new Rt.Nb(28);if("."!==(e=At(t,n)).charAt(0))throw new Rt.Nb(55);try{var s=Rt.rc(a,i)}catch(e){}if(u!==s){if(t=Rt.isDir(u.mode),o=Rt.ed(c,o,t))throw new Rt.Nb(o);if(o=s?Rt.ed(a,i,t):Rt.Ad(a,i))throw new Rt.Nb(o);if(!c.Pb.rename)throw new Rt.Nb(63);if(Rt.yc(u)||s&&Rt.yc(s))throw new Rt.Nb(10);if(a!==c&&(o=Rt.wc(c,"w")))throw new Rt.Nb(o);Rt.ae(u);try{c.Pb.rename(u,a,i)}catch(e){throw e}finally{Rt.$d(u)}}},rmdir:e=>{var t=Rt.lookupPath(e,{parent:!0}).node;e=kt(e);var n=Rt.rc(t,e),r=Rt.ed(t,e,!0);if(r)throw new Rt.Nb(r);if(!t.Pb.rmdir)throw new Rt.Nb(63);if(Rt.yc(n))throw new Rt.Nb(10);t.Pb.rmdir(t,e),Rt.od(n)},Tc:e=>{if(!(e=Rt.lookupPath(e,{follow:!0}).node).Pb.Tc)throw new Rt.Nb(54);return e.Pb.Tc(e)},unlink:e=>{var t=Rt.lookupPath(e,{parent:!0}).node;if(!t)throw new Rt.Nb(44);e=kt(e);var n=Rt.rc(t,e),r=Rt.ed(t,e,!1);if(r)throw new Rt.Nb(r);if(!t.Pb.unlink)throw new Rt.Nb(63);if(Rt.yc(n))throw new Rt.Nb(10);t.Pb.unlink(t,e),Rt.od(n)},readlink:e=>{if(!(e=Rt.lookupPath(e).node))throw new Rt.Nb(44);if(!e.Pb.readlink)throw new Rt.Nb(28);return Pt(Rt.getPath(e.parent),e.Pb.readlink(e))},stat:(e,t)=>{if(!(e=Rt.lookupPath(e,{follow:!t}).node))throw new Rt.Nb(44);if(!e.Pb.mc)throw new Rt.Nb(63);return e.Pb.mc(e)},lstat:e=>Rt.stat(e,!0),chmod:(e,t,n)=>{if(!(e="string"==typeof e?Rt.lookupPath(e,{follow:!n}).node:e).Pb.$b)throw new Rt.Nb(63);e.Pb.$b(e,{mode:4095&t|-4096&e.mode,timestamp:Date.now()})},lchmod:(e,t)=>{Rt.chmod(e,t,!0)},fchmod:(e,t)=>{if(!(e=Rt.lc(e)))throw new Rt.Nb(8);Rt.chmod(e.node,t)},chown:(e,t,n,r)=>{if(!(e="string"==typeof e?Rt.lookupPath(e,{follow:!r}).node:e).Pb.$b)throw new Rt.Nb(63);e.Pb.$b(e,{timestamp:Date.now()})},lchown:(e,t,n)=>{Rt.chown(e,t,n,!0)},fchown:(e,t,n)=>{if(!(e=Rt.lc(e)))throw new Rt.Nb(8);Rt.chown(e.node,t,n)},truncate:(e,t)=>{if(0>t)throw new Rt.Nb(28);if(!(e="string"==typeof e?Rt.lookupPath(e,{follow:!0}).node:e).Pb.$b)throw new Rt.Nb(63);if(Rt.isDir(e.mode))throw new Rt.Nb(31);if(!Rt.isFile(e.mode))throw new Rt.Nb(28);var n=Rt.wc(e,"w");if(n)throw new Rt.Nb(n);e.Pb.$b(e,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{if(!(e=Rt.lc(e)))throw new Rt.Nb(8);if(0==(2097155&e.flags))throw new Rt.Nb(28);Rt.truncate(e.node,t)},utime:(e,t,n)=>{(e=Rt.lookupPath(e,{follow:!0}).node).Pb.$b(e,{timestamp:Math.max(t,n)})},open:(e,t,r,o,i)=>{if(""===e)throw new Rt.Nb(44);if(r=64&(t="string"==typeof t?Rt.jf(t):t)?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var a=e;else{e=yt(e);try{a=Rt.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var c=!1;if(64&t)if(a){if(128&t)throw new Rt.Nb(20)}else a=Rt.sc(e,r,0),c=!0;if(!a)throw new Rt.Nb(44);if(Rt.isChrdev(a.mode)&&(t&=-513),65536&t&&!Rt.isDir(a.mode))throw new Rt.Nb(54);if(!c&&(r=Rt.hf(a,t)))throw new Rt.Nb(r);return 512&t&&Rt.truncate(a,0),t&=-131713,(o=Rt.md({node:a,path:Rt.getPath(a),flags:t,seekable:!0,position:0,Qb:a.Qb,Of:[],error:!1},o,i)).Qb.open&&o.Qb.open(o),!n.logReadFiles||1&t||(Rt.Ed||(Rt.Ed={}),e in Rt.Ed||(Rt.Ed[e]=1)),o},close:e=>{if(Rt.Mc(e))throw new Rt.Nb(8);e.td&&(e.td=null);try{e.Qb.close&&e.Qb.close(e)}catch(e){throw e}finally{Rt.Ae(e.kc)}e.kc=null},Mc:e=>null===e.kc,llseek:(e,t,n)=>{if(Rt.Mc(e))throw new Rt.Nb(8);if(!e.seekable||!e.Qb.llseek)throw new Rt.Nb(70);if(0!=n&&1!=n&&2!=n)throw new Rt.Nb(28);return e.position=e.Qb.llseek(e,t,n),e.Of=[],e.position},read:(e,t,n,r,o)=>{if(0>r||0>o)throw new Rt.Nb(28);if(Rt.Mc(e))throw new Rt.Nb(8);if(1==(2097155&e.flags))throw new Rt.Nb(8);if(Rt.isDir(e.node.mode))throw new Rt.Nb(31);if(!e.Qb.read)throw new Rt.Nb(28);var i=void 0!==o;if(i){if(!e.seekable)throw new Rt.Nb(70)}else o=e.position;return t=e.Qb.read(e,t,n,r,o),i||(e.position+=t),t},write:(e,t,n,r,o,i)=>{if(0>r||0>o)throw new Rt.Nb(28);if(Rt.Mc(e))throw new Rt.Nb(8);if(0==(2097155&e.flags))throw new Rt.Nb(8);if(Rt.isDir(e.node.mode))throw new Rt.Nb(31);if(!e.Qb.write)throw new Rt.Nb(28);e.seekable&&1024&e.flags&&Rt.llseek(e,0,2);var a=void 0!==o;if(a){if(!e.seekable)throw new Rt.Nb(70)}else o=e.position;return t=e.Qb.write(e,t,n,r,o,i),a||(e.position+=t),t},Lc:(e,t,n)=>{if(Rt.Mc(e))throw new Rt.Nb(8);if(0>t||0>=n)throw new Rt.Nb(28);if(0==(2097155&e.flags))throw new Rt.Nb(8);if(!Rt.isFile(e.node.mode)&&!Rt.isDir(e.node.mode))throw new Rt.Nb(43);if(!e.Qb.Lc)throw new Rt.Nb(138);e.Qb.Lc(e,t,n)},Fc:(e,t,n,r,o,i)=>{if(0!=(2&o)&&0==(2&i)&&2!=(2097155&e.flags))throw new Rt.Nb(2);if(1==(2097155&e.flags))throw new Rt.Nb(2);if(!e.Qb.Fc)throw new Rt.Nb(43);return e.Qb.Fc(e,t,n,r,o,i)},Gc:(e,t,n,r,o)=>e&&e.Qb.Gc?e.Qb.Gc(e,t,n,r,o):0,gg:()=>0,ad:(e,t,n)=>{if(!e.Qb.ad)throw new Rt.Nb(59);return e.Qb.ad(e,t,n)},readFile:(e,t={})=>{if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw Error('Invalid encoding type "'+t.encoding+'"');var n,r=Rt.open(e,t.flags);e=Rt.stat(e).size;var o=new Uint8Array(e);return Rt.read(r,o,0,e,0),"utf8"===t.encoding?n=x(o):"binary"===t.encoding&&(n=o),Rt.close(r),n},writeFile:(e,t,n={})=>{if(n.flags=n.flags||577,e=Rt.open(e,n.flags,n.mode),"string"==typeof t){var r=new Uint8Array(W(t)+1);t=U(t,r,0,r.length),Rt.write(e,r,0,t,void 0,n.ye)}else{if(!ArrayBuffer.isView(t))throw Error("Unsupported data type");Rt.write(e,t,0,t.byteLength,void 0,n.ye)}Rt.close(e)},cwd:()=>Rt.Pd,chdir:e=>{if(null===(e=Rt.lookupPath(e,{follow:!0})).node)throw new Rt.Nb(44);if(!Rt.isDir(e.node.mode))throw new Rt.Nb(54);var t=Rt.wc(e.node,"x");if(t)throw new Rt.Nb(t);Rt.Pd=e.path},De:()=>{Rt.mkdir("/tmp"),Rt.mkdir("/home"),Rt.mkdir("/home/web_user")},Ce:()=>{Rt.mkdir("/dev"),Rt.registerDevice(Rt.makedev(1,3),{read:()=>0,write:(e,t,n,r)=>r}),Rt.mkdev("/dev/null",Rt.makedev(1,3)),Nt(Rt.makedev(5,0),Ot),Nt(Rt.makedev(6,0),St),Rt.mkdev("/dev/tty",Rt.makedev(5,0)),Rt.mkdev("/dev/tty1",Rt.makedev(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}return function(){Ae("randomDevice")}}();Rt.uc("/dev","random",e),Rt.uc("/dev","urandom",e),Rt.mkdir("/dev/shm"),Rt.mkdir("/dev/shm/tmp")},Ge:()=>{Rt.mkdir("/proc");var e=Rt.mkdir("/proc/self");Rt.mkdir("/proc/self/fd"),Rt.mount({mount:()=>{var t=Rt.createNode(e,"fd",16895,73);return t.Pb={zc:(e,t)=>{var n=Rt.lc(+t);if(!n)throw new Rt.Nb(8);return(e={parent:null,mount:{fe:"fake"},Pb:{readlink:()=>n.path}}).parent=e}},t}},{},"/proc/self/fd")},He:()=>{n.stdin?Rt.uc("/dev","stdin",n.stdin):Rt.symlink("/dev/tty","/dev/stdin"),n.stdout?Rt.uc("/dev","stdout",null,n.stdout):Rt.symlink("/dev/tty","/dev/stdout"),n.stderr?Rt.uc("/dev","stderr",null,n.stderr):Rt.symlink("/dev/tty1","/dev/stderr"),Rt.open("/dev/stdin",0),Rt.open("/dev/stdout",1),Rt.open("/dev/stderr",1)},Td:()=>{Rt.Nb||(Rt.Nb=function(e,t){this.node=t,this.Bf=function(e){this.Tb=e},this.Bf(e),this.message="FS error"},Rt.Nb.prototype=Error(),Rt.Nb.prototype.constructor=Rt.Nb,[44].forEach((e=>{Rt.rd[e]=new Rt.Nb(e),Rt.rd[e].stack="<generic error, no stack>"})))},If:()=>{Rt.Td(),Rt.nc=Array(4096),Rt.mount(Dt,{},"/"),Rt.De(),Rt.Ce(),Rt.Ge(),Rt.Pe={MEMFS:Dt}},init:(e,t,r)=>{Rt.init.vd=!0,Rt.Td(),n.stdin=e||n.stdin,n.stdout=t||n.stdout,n.stderr=r||n.stderr,Rt.He()},vf:()=>{Rt.init.vd=!1,oo();for(var e=0;e<Rt.streams.length;e++){var t=Rt.streams[e];t&&Rt.close(t)}},sd:(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},Yf:(e,t)=>(e=Rt.analyzePath(e,t)).pd?e.object:null,analyzePath:(e,t)=>{try{var n=Rt.lookupPath(e,{follow:!t});e=n.path}catch(e){}var r={cd:!1,pd:!1,error:0,name:null,path:null,object:null,pf:!1,rf:null,qf:null};try{n=Rt.lookupPath(e,{parent:!0}),r.pf=!0,r.rf=n.path,r.qf=n.node,r.name=kt(e),n=Rt.lookupPath(e,{follow:!t}),r.pd=!0,r.path=n.path,r.object=n.node,r.name=n.node.name,r.cd="/"===n.path}catch(e){r.error=e.Tb}return r},Vf:(e,t)=>{for(e="string"==typeof e?e:Rt.getPath(e),t=t.split("/").reverse();t.length;){var n=t.pop();if(n){var r=_t(e,n);try{Rt.mkdir(r)}catch(e){}e=r}}return r},Ee:(e,t,n,r,o)=>(e=_t("string"==typeof e?e:Rt.getPath(e),t),Rt.create(e,Rt.sd(r,o))),Od:(e,t,n,r,o,i)=>{var a=t;if(e&&(e="string"==typeof e?e:Rt.getPath(e),a=t?_t(e,t):e),e=Rt.sd(r,o),a=Rt.create(a,e),n){if("string"==typeof n){for(t=Array(n.length),r=0,o=n.length;r<o;++r)t[r]=n.charCodeAt(r);n=t}Rt.chmod(a,146|e),t=Rt.open(a,577),Rt.write(t,n,0,n.length,0,i),Rt.close(t),Rt.chmod(a,e)}return a},uc:(e,t,n,r)=>{e=_t("string"==typeof e?e:Rt.getPath(e),t),t=Rt.sd(!!n,!!r),Rt.uc.zd||(Rt.uc.zd=64);var o=Rt.makedev(Rt.uc.zd++,0);return Rt.registerDevice(o,{open:e=>{e.seekable=!1},close:()=>{r&&r.buffer&&r.buffer.length&&r(10)},read:(e,t,r,o)=>{for(var i=0,a=0;a<o;a++){try{var c=n()}catch(e){throw new Rt.Nb(29)}if(void 0===c&&0===i)throw new Rt.Nb(6);if(null==c)break;i++,t[r+a]=c}return i&&(e.node.timestamp=Date.now()),i},write:(e,t,n,o)=>{for(var i=0;i<o;i++)try{r(t[n+i])}catch(e){throw new Rt.Nb(29)}return o&&(e.node.timestamp=Date.now()),i}}),Rt.mkdev(e,t,o)},Xd:e=>{if(e.wd||e.ef||e.link||e.Rb)return!0;if("undefined"!=typeof XMLHttpRequest)throw Error("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.");if(!a)throw Error("Cannot load without read() or XMLHttpRequest.");try{e.Rb=$r(a(e.url),!0),e.Vb=e.Rb.length}catch(e){throw new Rt.Nb(29)}},createLazyFile:(e,t,n,r,o)=>{function i(){this.yd=!1,this.fc=[]}if(i.prototype.get=function(e){if(!(e>this.length-1||0>e)){var t=e%this.Nd;return this.$c(e/this.Nd|0)[t]}},i.prototype.qe=function(e){this.$c=e},i.prototype.Ld=function(){var e=new XMLHttpRequest;if(e.open("HEAD",n,!1),e.send(null),!(200<=e.status&&300>e.status||304===e.status))throw Error("Couldn't load "+n+". Status: "+e.status);var t,r=Number(e.getResponseHeader("Content-length")),o=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t;e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t;var i=1048576;o||(i=r);var a=this;a.qe((e=>{var t=e*i,o=(e+1)*i-1;if(o=Math.min(o,r-1),void 0===a.fc[e]){var c=a.fc;if(t>o)throw Error("invalid range ("+t+", "+o+") or no bytes requested!");if(o>r-1)throw Error("only "+r+" bytes available! programmer error!");var u=new XMLHttpRequest;if(u.open("GET",n,!1),r!==i&&u.setRequestHeader("Range","bytes="+t+"-"+o),u.responseType="arraybuffer",u.overrideMimeType&&u.overrideMimeType("text/plain; charset=x-user-defined"),u.send(null),!(200<=u.status&&300>u.status||304===u.status))throw Error("Couldn't load "+n+". Status: "+u.status);t=void 0!==u.response?new Uint8Array(u.response||[]):$r(u.responseText||"",!0),c[e]=t}if(void 0===a.fc[e])throw Error("doXHR failed!");return a.fc[e]})),!e&&r||(i=r=1,i=r=this.$c(0).length,y("LazyFiles on gzip forces download of the whole file when length is accessed")),this.se=r,this.re=i,this.yd=!0},"undefined"!=typeof XMLHttpRequest){if(!b)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new i;Object.defineProperties(a,{length:{get:function(){return this.yd||this.Ld(),this.se}},Nd:{get:function(){return this.yd||this.Ld(),this.re}}}),a={wd:!1,Rb:a}}else a={wd:!1,url:n};var c=Rt.Ee(e,t,a,r,o);a.Rb?c.Rb=a.Rb:a.url&&(c.Rb=null,c.url=a.url),Object.defineProperties(c,{Vb:{get:function(){return this.Rb.length}}});var u={};return Object.keys(c.Qb).forEach((e=>{var t=c.Qb[e];u[e]=function(){return Rt.Xd(c),t.apply(null,arguments)}})),u.read=(e,t,n,r,o)=>{if(Rt.Xd(c),o>=(e=e.node.Rb).length)return 0;if(r=Math.min(e.length-o,r),e.slice)for(var i=0;i<r;i++)t[n+i]=e[o+i];else for(i=0;i<r;i++)t[n+i]=e.get(o+i);return r},c.Qb=u,c},createPreloadedFile:(e,t,r,o,i,a,u,s,f,l)=>{function d(r){function c(n){l&&l(),s||Rt.Od(e,t,n,o,i,f),a&&a(),Pe()}(function(e,t,r,o){Xe();var i=!1;return n.preloadPlugins.forEach((function(n){!i&&n.canHandle(t)&&(n.handle(e,t,r,o),i=!0)})),i})(r,h,c,(()=>{u&&u(),Pe()}))||c(r)}var h=t?Pt(_t(e,t)):e;_e(),"string"==typeof r?function(e,t,n){var r="al "+e;c(e,(function(n){n||Ae('Loading data file "'+e+'" failed (no arrayBuffer).'),t(new Uint8Array(n)),r&&Pe()}),(function(){if(!n)throw'Loading data file "'+e+'" failed.';n()})),r&&_e()}(r,(e=>d(e)),u):d(r)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,Id:()=>"EM_FS_"+window.location.pathname,Jd:20,Kc:"FILE_DATA",mg:(e,t,n)=>{t=t||(()=>{}),n=n||(()=>{});var r=Rt.indexedDB();try{var o=r.open(Rt.Id(),Rt.Jd)}catch(e){return n(e)}o.onupgradeneeded=()=>{y("creating db"),o.result.createObjectStore(Rt.Kc)},o.onsuccess=()=>{var r=o.result.transaction([Rt.Kc],"readwrite"),i=r.objectStore(Rt.Kc),a=0,c=0,u=e.length;e.forEach((e=>{(e=i.put(Rt.analyzePath(e).object.Rb,e)).onsuccess=()=>{++a+c==u&&(0==c?t():n())},e.onerror=()=>{c++,a+c==u&&(0==c?t():n())}})),r.onerror=n},o.onerror=n},bg:(e,t,n)=>{t=t||(()=>{}),n=n||(()=>{});var r=Rt.indexedDB();try{var o=r.open(Rt.Id(),Rt.Jd)}catch(e){return n(e)}o.onupgradeneeded=n,o.onsuccess=()=>{var r=o.result;try{var i=r.transaction([Rt.Kc],"readonly")}catch(e){return void n(e)}var a=i.objectStore(Rt.Kc),c=0,u=0,s=e.length;e.forEach((e=>{var r=a.get(e);r.onsuccess=()=>{Rt.analyzePath(e).pd&&Rt.unlink(e),Rt.Od(gt(e),kt(e),r.result,!0,!0,!0),++c+u==s&&(0==u?t():n())},r.onerror=()=>{u++,c+u==s&&(0==u?t():n())}})),i.onerror=n},o.onerror=n}};function Ft(e,t,n){if("/"===t[0])return t;if(-100===e)e=Rt.cwd();else{if(!(e=Rt.lc(e)))throw new Rt.Nb(8);e=e.path}if(0==t.length){if(!n)throw new Rt.Nb(44);return e}return _t(e,t)}function Mt(e,t,n){try{var r=e(t)}catch(e){if(e&&e.node&&yt(t)!==yt(Rt.getPath(e.node)))return-54;throw e}return z[n>>2]=r.Ke,z[n+4>>2]=0,z[n+8>>2]=r.ce,z[n+12>>2]=r.mode,z[n+16>>2]=r.nf,z[n+20>>2]=r.uid,z[n+24>>2]=r.Ye,z[n+28>>2]=r.Sc,z[n+32>>2]=0,H[n+40>>3]=BigInt(r.size),z[n+48>>2]=4096,z[n+52>>2]=r.we,z[n+56>>2]=r.ue.getTime()/1e3|0,z[n+60>>2]=0,z[n+64>>2]=r.kf.getTime()/1e3|0,z[n+68>>2]=0,z[n+72>>2]=r.Ie.getTime()/1e3|0,z[n+76>>2]=0,H[n+80>>3]=BigInt(r.ce),0}var xt=void 0;function Lt(){return z[(xt+=4)-4>>2]}function Ut(e){if(!(e=Rt.lc(e)))throw new Rt.Nb(8);return e}function Wt(e){if(m)return yr(3,1,e);try{var t=Ut(e);return Rt.open(t.path,t.flags,0).kc}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Ct(e,t,n,r){if(m)return yr(5,1,e,t,n,r);try{if(t=Ft(e,t=L(t)),-8&n)var o=-28;else{var i=Rt.lookupPath(t,{follow:!0}).node;i?(e="",4&n&&(e+="r"),2&n&&(e+="w"),1&n&&(e+="x"),o=e&&Rt.wc(i,e)?-2:0):o=-44}return o}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function jt(e,t,n){if(m)return yr(6,1,e,t,n);xt=n;try{var r=Ut(e);switch(t){case 0:var o=Lt();return 0>o?-28:Rt.open(r.path,r.flags,0,o).kc;case 1:case 2:case 6:case 7:return 0;case 3:return r.flags;case 4:return o=Lt(),r.flags|=o,0;case 5:return o=Lt(),I[o+0>>1]=2,0;default:return-28;case 9:return z[to()>>2]=28,-1}}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Bt(e,t){if(m)return yr(7,1,e,t);try{var n=Ut(e);return Mt(Rt.stat,n.path,t)}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function It(e,t,n,r){if(m)return yr(8,1,e,t,n,r);try{t=L(t);var o=256&r;return t=Ft(e,t,4096&r),Mt(o?Rt.lstat:Rt.stat,t,n)}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Vt(e,t,n){if(m)return yr(9,1,e,t,n);try{return Rt.ftruncate(e,t),0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function zt(e,t){if(m)return yr(10,1,e,t);try{if(0===t)return-28;var n=Rt.cwd();return t<W(n)+1?-68:(U(n,B,e,t),e)}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Qt(e,t,n){if(m)return yr(11,1,e,t,n);xt=n;try{var r=Ut(e);switch(t){case 21509:case 21505:case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:case 21523:case 21524:return r.Yb?0:-59;case 21519:if(!r.Yb)return-59;var o=Lt();return z[o>>2]=0;case 21520:return r.Yb?-28:-59;case 21531:return o=Lt(),Rt.ad(r,t,o);default:Ae("bad ioctl syscall "+t)}}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function qt(e,t){if(m)return yr(12,1,e,t);try{return e=L(e),Mt(Rt.lstat,e,t)}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Ht(e,t,n){if(m)return yr(13,1,e,t,n);xt=n;try{var r=L(e),o=n?Lt():0;return Rt.open(r,t,o).kc}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}var Yt={ec:8192,mount:function(){return Rt.createNode(null,"/",16895,0)},Fe:function(){var e={Wb:[],ke:2};e.Wb.push({buffer:new Uint8Array(Yt.ec),offset:0,hc:0});var t=Yt.Pc(),n=Yt.Pc(),r=Rt.createNode(Yt.root,t,4096,0),o=Rt.createNode(Yt.root,n,4096,0);return r.Qc=e,o.Qc=e,e=Rt.md({path:t,node:r,flags:0,seekable:!1,Qb:Yt.Qb}),r.stream=e,n=Rt.md({path:n,node:o,flags:1,seekable:!1,Qb:Yt.Qb}),o.stream=n,{xf:e.kc,Rf:n.kc}},Qb:{ie:function(e){var t=e.node.Qc;if(1==(2097155&e.flags))return 260;if(0<t.Wb.length)for(e=0;e<t.Wb.length;e++){var n=t.Wb[e];if(0<n.offset-n.hc)return 65}return 0},ad:function(){return 28},Zf:function(){return 28},read:function(e,t,n,r){e=e.node.Qc;for(var o=0,i=0;i<e.Wb.length;i++){var a=e.Wb[i];o+=a.offset-a.hc}if(t instanceof ArrayBuffer||t instanceof SharedArrayBuffer||ArrayBuffer.isView(t)||Ae(void 0),t=t.subarray(n,n+r),0>=r)return 0;if(0==o)throw new Rt.Nb(6);for(n=r=Math.min(o,r),i=o=0;i<e.Wb.length;i++){var c=(a=e.Wb[i]).offset-a.hc;if(r<=c){var u=a.buffer.subarray(a.hc,a.offset);r<c?(u=u.subarray(0,r),a.hc+=r):o++,t.set(u);break}u=a.buffer.subarray(a.hc,a.offset),t.set(u),t=t.subarray(u.byteLength),r-=u.byteLength,o++}return o&&o==e.Wb.length&&(o--,e.Wb[o].offset=0,e.Wb[o].hc=0),e.Wb.splice(0,o),n},write:function(e,t,n,r){if(e=e.node.Qc,t instanceof ArrayBuffer||t instanceof SharedArrayBuffer||ArrayBuffer.isView(t)||Ae(void 0),0>=(n=(t=t.subarray(n,n+r)).byteLength))return 0;0==e.Wb.length?(r={buffer:new Uint8Array(Yt.ec),offset:0,hc:0},e.Wb.push(r)):r=e.Wb[e.Wb.length-1],r.offset<=Yt.ec||Ae(void 0);var o=Yt.ec-r.offset;if(o>=n)return r.buffer.set(t,r.offset),r.offset+=n,n;0<o&&(r.buffer.set(t.subarray(0,o),r.offset),r.offset+=o,t=t.subarray(o,t.byteLength)),r=t.byteLength/Yt.ec|0,o=t.byteLength%Yt.ec;for(var i=0;i<r;i++){var a={buffer:new Uint8Array(Yt.ec),offset:Yt.ec,hc:0};e.Wb.push(a),a.buffer.set(t.subarray(0,Yt.ec)),t=t.subarray(Yt.ec,t.byteLength)}return 0<o&&(a={buffer:new Uint8Array(Yt.ec),offset:t.byteLength,hc:0},e.Wb.push(a),a.buffer.set(t)),n},close:function(e){(e=e.node.Qc).ke--,0===e.ke&&(e.Wb=null)}},Pc:function(){return Yt.Pc.current||(Yt.Pc.current=0),"pipe["+Yt.Pc.current+++"]"}};function Xt(e){if(m)return yr(14,1,e);try{if(0==e)throw new Rt.Nb(21);var t=Yt.Fe();return z[e>>2]=t.xf,z[e+4>>2]=t.Rf,0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Gt(e,t,n){if(m)return yr(15,1,e,t,n);try{for(var r=n=0;r<t;r++){var o=e+8*r,i=I[o+4>>1],a=32,c=Rt.lc(z[o>>2]);c&&(a=5,c.Qb.ie&&(a=c.Qb.ie(c))),(a&=24|i)&&n++,I[o+6>>1]=a}return n}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Zt(e,t,n){if(m)return yr(16,1,e,t,n);try{if(e=L(e),0>=n)var r=-28;else{var o=Rt.readlink(e),i=Math.min(n,W(o)),a=j[t+i];U(o,B,t,n+1),j[t+i]=a,r=i}return r}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function $t(e){if(m)return yr(17,1,e);try{return e=L(e),Rt.rmdir(e),0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Jt(e,t){if(m)return yr(18,1,e,t);try{return e=L(e),Mt(Rt.stat,e,t)}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function Kt(e){if(m)return yr(19,1,e);try{return e=L(e),Rt.unlink(e),0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}var en={};function tn(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function nn(e){return this.fromWireType(Q[e>>2])}var rn={},on={},an={};function cn(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=t&&57>=t?"_"+e:e}function un(e,t){return e=cn(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}function sn(e){var t=Error,n=un(e,(function(t){this.name=e,this.message=t,void 0!==(t=Error(t).stack)&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}));return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},n}var fn=void 0;function ln(e){throw new fn(e)}function dn(e,t,n){function r(t){(t=n(t)).length!==e.length&&ln("Mismatched type converter count");for(var r=0;r<e.length;++r)vn(e[r],t[r])}e.forEach((function(e){an[e]=t}));var o=Array(t.length),i=[],a=0;t.forEach((function(e,t){on.hasOwnProperty(e)?o[t]=on[e]:(i.push(e),rn.hasOwnProperty(e)||(rn[e]=[]),rn[e].push((function(){o[t]=on[e],++a===i.length&&r(o)})))})),0===i.length&&r(o)}var hn=void 0;function bn(e){for(var t="";B[e];)t+=hn[B[e++]];return t}var pn=void 0;function mn(e){throw new pn(e)}function vn(e,t,n={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var r=t.name;if(e||mn('type "'+r+'" must have a positive integer typeid pointer'),on.hasOwnProperty(e)){if(n.$e)return;mn("Cannot register type '"+r+"' twice")}on[e]=t,delete an[e],rn.hasOwnProperty(e)&&(t=rn[e],delete rn[e],t.forEach((function(e){e()})))}function wn(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}function yn(e,t){switch(t){case 2:return q;case 3:return X;default:throw new TypeError("Unknown float type: "+e)}}function gn(e,t,n){switch(t){case 0:return n?j:B;case 1:return n?I:V;case 2:return n?z:Q;case 3:return n?H:Y;default:throw new TypeError("Unknown integer type: "+e)}}function kn(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function _n(e,t,n){var r=gn(e,t,n);switch(t){case 0:return function(e){return r[e]};case 1:return function(e){return r[e>>1]};case 2:return function(e){return r[e>>2]};case 3:return function(e){return r[e>>3]}}}function Pn(e){mn(e.Ob.Xb.Sb.name+" instance already deleted")}var An=!1,Tn=!1;function Nn(){}function En(e){--e.count.value,0===e.count.value&&(e.cc?e.ic.tc(e.cc):e.Xb.Sb.tc(e.Ub))}function On(e,t,n){return t===n?e:void 0===n.jc||null===(e=On(e,t,n.jc))?null:n.Le(e)}var Sn={},Dn=[];function Rn(){for(;Dn.length;){var e=Dn.pop();e.Ob.Ec=!1,e.delete()}}var Fn=void 0,Mn={};function xn(e,t){return t.Xb&&t.Ub||ln("makeClassHandle requires ptr and ptrType"),!!t.ic!=!!t.cc&&ln("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Ln(Object.create(e,{Ob:{value:t}}))}function Ln(e){return An?(Ln=e=>e.deleteLater())(e):"undefined"==typeof FinalizationRegistry?(Ln=e=>e,e):(Tn=new FinalizationRegistry((e=>{En(e.Ob)})),Nn=e=>{Tn.unregister(e)},(Ln=e=>{var t=e.Ob;return t.cc&&Tn.register(e,{Ob:t},e),e})(e))}function Un(){}function Wn(e,t,n){if(void 0===e[t].Zb){var r=e[t];e[t]=function(){return e[t].Zb.hasOwnProperty(arguments.length)||mn("Function '"+n+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].Zb+")!"),e[t].Zb[arguments.length].apply(this,arguments)},e[t].Zb=[],e[t].Zb[r.Dc]=r}}function Cn(e,t,r){n.hasOwnProperty(e)?((void 0===r||void 0!==n[e].Zb&&void 0!==n[e].Zb[r])&&mn("Cannot register public name '"+e+"' twice"),Wn(n,e,e),n.hasOwnProperty(r)&&mn("Cannot register multiple overloads of a function with the same number of arguments ("+r+")!"),n[e].Zb[r]=t):(n[e]=t,void 0!==r&&(n[e].ig=r))}function jn(e,t,n,r,o,i,a,c){this.name=e,this.constructor=t,this.vc=n,this.tc=r,this.jc=o,this.Se=i,this.Xc=a,this.Le=c,this.tf=[]}function Bn(e,t,n){for(;t!==n;)t.Xc||mn("Expected null or instance of "+n.name+", got an instance of "+t.name),e=t.Xc(e),t=t.jc;return e}function In(e,t){return null===t?(this.xd&&mn("null is not a valid "+this.name),0):(t.Ob||mn('Cannot pass "'+kn(t)+'" as a '+this.name),t.Ob.Ub||mn("Cannot pass deleted object as a pointer of type "+this.name),Bn(t.Ob.Ub,t.Ob.Xb.Sb,this.Sb))}function Vn(e,t){if(null===t){if(this.xd&&mn("null is not a valid "+this.name),this.dd){var n=this.Dd();return null!==e&&e.push(this.tc,n),n}return 0}if(t.Ob||mn('Cannot pass "'+kn(t)+'" as a '+this.name),t.Ob.Ub||mn("Cannot pass deleted object as a pointer of type "+this.name),!this.bd&&t.Ob.Xb.bd&&mn("Cannot convert argument of type "+(t.Ob.ic?t.Ob.ic.name:t.Ob.Xb.name)+" to parameter type "+this.name),n=Bn(t.Ob.Ub,t.Ob.Xb.Sb,this.Sb),this.dd)switch(void 0===t.Ob.cc&&mn("Passing raw pointer to smart pointer is illegal"),this.Gf){case 0:t.Ob.ic===this?n=t.Ob.cc:mn("Cannot convert argument of type "+(t.Ob.ic?t.Ob.ic.name:t.Ob.Xb.name)+" to parameter type "+this.name);break;case 1:n=t.Ob.cc;break;case 2:if(t.Ob.ic===this)n=t.Ob.cc;else{var r=t.clone();n=this.wf(n,or((function(){r.delete()}))),null!==e&&e.push(this.tc,n)}break;default:mn("Unsupporting sharing policy")}return n}function zn(e,t){return null===t?(this.xd&&mn("null is not a valid "+this.name),0):(t.Ob||mn('Cannot pass "'+kn(t)+'" as a '+this.name),t.Ob.Ub||mn("Cannot pass deleted object as a pointer of type "+this.name),t.Ob.Xb.bd&&mn("Cannot convert argument of type "+t.Ob.Xb.name+" to parameter type "+this.name),Bn(t.Ob.Ub,t.Ob.Xb.Sb,this.Sb))}function Qn(e,t,n,r){this.name=e,this.Sb=t,this.xd=n,this.bd=r,this.dd=!1,this.tc=this.wf=this.Dd=this.je=this.Gf=this.sf=void 0,void 0!==t.jc?this.toWireType=Vn:(this.toWireType=r?In:zn,this.bc=null)}function qn(e,t,r){n.hasOwnProperty(e)||ln("Replacing nonexistant public symbol"),void 0!==n[e].Zb&&void 0!==r?n[e].Zb[r]=t:(n[e]=t,n[e].Dc=r)}function Hn(e,t){e=bn(e);var n=pt(t);return"function"!=typeof n&&mn("unknown function pointer with signature "+e+": "+t),n}var Yn=void 0;function Xn(e){var t=bn(e=ro(e));return eo(e),t}function Gn(e,t){var n=[],r={};throw t.forEach((function e(t){r[t]||on[t]||(an[t]?an[t].forEach(e):(n.push(t),r[t]=!0))})),new Yn(e+": "+n.map(Xn).join([", "]))}function Zn(e){var t=Function;if(!(t instanceof Function))throw new TypeError("new_ called with constructor type "+typeof t+" which is not a function");var n=un(t.name||"unknownFunctionName",(function(){}));return n.prototype=t.prototype,n=new n,(e=t.apply(n,e))instanceof Object?e:n}function $n(e,t,n,r,o){var i=t.length;2>i&&mn("argTypes array size mismatch! Must at least get return value and 'this' types!");var a=null!==t[1]&&null!==n,c=!1;for(n=1;n<t.length;++n)if(null!==t[n]&&void 0===t[n].bc){c=!0;break}var u="void"!==t[0].name,s="",f="";for(n=0;n<i-2;++n)s+=(0!==n?", ":"")+"arg"+n,f+=(0!==n?", ":"")+"arg"+n+"Wired";e="return function "+cn(e)+"("+s+") {\nif (arguments.length !== "+(i-2)+") {\nthrowBindingError('function "+e+" called with ' + arguments.length + ' arguments, expected "+(i-2)+" args!');\n}\n",c&&(e+="var destructors = [];\n");var l=c?"destructors":"null";for(s="throwBindingError invoker fn runDestructors retType classParam".split(" "),r=[mn,r,o,tn,t[0],t[1]],a&&(e+="var thisWired = classParam.toWireType("+l+", this);\n"),n=0;n<i-2;++n)e+="var arg"+n+"Wired = argType"+n+".toWireType("+l+", arg"+n+"); // "+t[n+2].name+"\n",s.push("argType"+n),r.push(t[n+2]);if(a&&(f="thisWired"+(0<f.length?", ":"")+f),e+=(u?"var rv = ":"")+"invoker(fn"+(0<f.length?", ":"")+f+");\n",c)e+="runDestructors(destructors);\n";else for(n=a?1:2;n<t.length;++n)i=1===n?"thisWired":"arg"+(n-2)+"Wired",null!==t[n].bc&&(e+=i+"_dtor("+i+"); // "+t[n].name+"\n",s.push(i+"_dtor"),r.push(t[n].bc));return u&&(e+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),s.push(e+"}\n"),Zn(s).apply(null,r)}function Jn(e,t){for(var n=[],r=0;r<e;r++)n.push(z[(t>>2)+r]);return n}function Kn(e,t,n){return e instanceof Object||mn(n+' with invalid "this": '+e),e instanceof t.Sb.constructor||mn(n+' incompatible with "this" of type '+e.constructor.name),e.Ob.Ub||mn("cannot call emscripten binding method "+n+" on deleted object"),Bn(e.Ob.Ub,e.Ob.Xb.Sb,t.Sb)}var er=[],tr=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function nr(e){4<e&&0==--tr[e].Gd&&(tr[e]=void 0,er.push(e))}function rr(e){return e||mn("Cannot use deleted val. handle = "+e),tr[e].value}function or(e){switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=er.length?er.pop():tr.length;return tr[t]={Gd:1,value:e},t}}function ir(e,t,n){var r=gn(e,t,n);switch(t){case 0:return function(e){return this.fromWireType(r[e])};case 1:return function(e){return this.fromWireType(r[e>>1])};case 2:return function(e){return this.fromWireType(r[e>>2])}}}function ar(e,t){var n=on[e];return void 0===n&&mn(t+" has unknown type "+Xn(e)),n}function cr(e,t){var n=yn(e,t);switch(t){case 2:return function(e){return this.fromWireType(n[e>>2])};case 3:return function(e){return this.fromWireType(n[e>>3])}}}function ur(e,t){for(var n=Array(e),r=0;r<e;++r)n[r]=ar(z[(t>>2)+r],"parameter "+r);return n}var sr={};function fr(e){var t=sr[e];return void 0===t?bn(e):t}var lr=[];function dr(){return"object"==typeof globalThis?globalThis:Function("return this")()}var hr=[],br={};function pr(e,t,n,r,o,i,a,c){if(m)return yr(20,1,e,t,n,r,o,i,a,c);try{var u=Rt.lc(o);if(!u)return-8;var s=Rt.Fc(u,e,t,i,n,r),f=s.Ub;return z[a>>2]=s.te,f}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function mr(e,t,n,r,o,i){if(m)return yr(21,1,e,t,n,r,o,i);try{var a=Rt.lc(o);a&&2&n&&Rt.Gc(a,B.slice(e,e+t),i,t,r)}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}}function vr(e,t,n){function r(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}if(m)return yr(22,1,e,t,n);var o=(new Date).getFullYear(),i=new Date(o,0,1),a=new Date(o,6,1);o=i.getTimezoneOffset();var c=a.getTimezoneOffset();z[e>>2]=60*Math.max(o,c),z[t>>2]=Number(o!=c),e=r(i),t=r(a),e=ne(e),t=ne(t),c<o?(z[n>>2]=e,z[n+4>>2]=t):(z[n>>2]=t,z[n+4>>2]=e)}function wr(){return navigator.hardwareConcurrency}function yr(e,t){var n=arguments.length-2,r=arguments;return ft((function(){for(var o=2*n,i=go(8*o),a=i>>3,c=0;c<n;c++){var u=r[2+c];"bigint"==typeof u?(H[a+2*c]=BigInt(1),H[a+2*c+1]=u):(H[a+2*c]=BigInt(0),X[a+2*c+1]=u)}return lo(e,o,i,t)}))}var gr=[];var kr=[0,"undefined"!=typeof document?document:0,"undefined"!=typeof window?window:0];function _r(e){return e=2<e?L(e):e,kr[e]||("undefined"!=typeof document?document.querySelector(e):void 0)}function Pr(e,t,n){var r=_r(e);return r?(r.Zc&&(z[r.Zc>>2]=t,z[r.Zc+4>>2]=n),!r.he&&r.Tf?r.Zc?(function(e,t,n,r){ft((function(){var o=go(12),i=0;if(t){i=W(t)+1;var a=Kr(i);U(t,B,a,i),i=a}z[o>>2]=i,z[o+4>>2]=n,z[o+8>>2]=r,ho(e,657457152,0,i,o)}))}(r=z[r.Zc+8>>2],e=e?L(e):"",t,n),1):-4:(r.he&&(r=r.he),e=!1,r.Yc&&r.Yc.Bc&&(e=0===(e=r.Yc.Bc.getParameter(2978))[0]&&0===e[1]&&e[2]===r.width&&e[3]===r.height),r.width=t,r.height=n,e&&r.Yc.Bc.viewport(0,0,t,n),0)):-4}function Ar(e,t,n){return m?yr(23,1,e,t,n):Pr(e,t,n)}var Tr={};function Nr(e,t){e.fc||(e.fc=e.getContext,e.getContext=function(t,n){return"webgl"==t==(n=e.fc(t,n))instanceof WebGLRenderingContext?n:null});var n=e.getContext("webgl",t);return n?function(e,t){var n=Kr(8);z[n+4>>2]=ao();var r={ag:n,attributes:t,version:t.ee,Bc:e};return e.canvas&&(e.canvas.Yc=r),Tr[n]=r,(void 0===t.Sd||t.Sd)&&function(e){if(e||(e=Er),!e.af){e.af=!0;var t=e.Bc;!function(e){var t=e.getExtension("ANGLE_instanced_arrays");t&&(e.vertexAttribDivisor=function(e,n){t.vertexAttribDivisorANGLE(e,n)},e.drawArraysInstanced=function(e,n,r,o){t.drawArraysInstancedANGLE(e,n,r,o)},e.drawElementsInstanced=function(e,n,r,o,i){t.drawElementsInstancedANGLE(e,n,r,o,i)})}(t),function(e){var t=e.getExtension("OES_vertex_array_object");t&&(e.createVertexArray=function(){return t.createVertexArrayOES()},e.deleteVertexArray=function(e){t.deleteVertexArrayOES(e)},e.bindVertexArray=function(e){t.bindVertexArrayOES(e)},e.isVertexArray=function(e){return t.isVertexArrayOES(e)})}(t),function(e){var t=e.getExtension("WEBGL_draw_buffers");t&&(e.drawBuffers=function(e,n){t.drawBuffersWEBGL(e,n)})}(t),t.Wf=t.getExtension("EXT_disjoint_timer_query"),t.fg=t.getExtension("WEBGL_multi_draw"),(t.getSupportedExtensions()||[]).forEach((function(e){e.includes("lose_context")||e.includes("debug")||t.getExtension(e)}))}}(r),n}(n,t):0}var Er,Or,Sr={},Dr=["default","low-power","high-performance"],Rr={};function Fr(){if(!Or){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:l||"./this.program"};for(e in Rr)void 0===Rr[e]?delete t[e]:t[e]=Rr[e];var n=[];for(e in t)n.push(e+"="+t[e]);Or=n}return Or}function Mr(e,t){if(m)return yr(24,1,e,t);var n=0;return Fr().forEach((function(r,o){var i=t+n;for(o=z[e+4*o>>2]=i,i=0;i<r.length;++i)j[o++>>0]=r.charCodeAt(i);j[o>>0]=0,n+=r.length+1})),0}function xr(e,t){if(m)return yr(25,1,e,t);var n=Fr();z[e>>2]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),z[t>>2]=r,0}function Lr(e){if(m)return yr(26,1,e);try{var t=Ut(e);return Rt.close(t),0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return e.Tb}}function Ur(e,t){if(m)return yr(27,1,e,t);try{var n=Ut(e),r=n.Yb?2:Rt.isDir(n.mode)?3:Rt.isLink(n.mode)?7:4;return j[t>>0]=r,0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return e.Tb}}function Wr(e,t,n,r){if(m)return yr(28,1,e,t,n,r);try{e:{for(var o=Ut(e),i=e=0;i<n;i++){var a=z[t+(8*i+4)>>2],c=Rt.read(o,j,z[t+8*i>>2],a,void 0);if(0>c){var u=-1;break e}if(e+=c,c<a)break}u=e}return z[r>>2]=u,0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return e.Tb}}function Cr(e,t,n,r){if(m)return yr(29,1,e,t,n,r);try{var o=0|Number(t&BigInt(4294967295)),i=0|Number(t>>BigInt(32)),a=Ut(e);return-9007199254740992>=(e=4294967296*i+(o>>>0))||9007199254740992<=e?-61:(Rt.llseek(a,e,n),H[r>>3]=BigInt(a.position),a.td&&0===e&&0===n&&(a.td=null),0)}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return e.Tb}}function jr(e,t,n,r){if(m)return yr(30,1,e,t,n,r);try{e:{for(var o=Ut(e),i=e=0;i<n;i++){var a=Rt.write(o,j,z[t+8*i>>2],z[t+(8*i+4)>>2],void 0);if(0>a){var c=-1;break e}e+=a}c=e}return z[r>>2]=c,0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return e.Tb}}function Br(e){if(m)return yr(31,1,e);To(e)}function Ir(e){return 0==e%4&&(0!=e%100||0==e%400)}function Vr(e,t){for(var n=0,r=0;r<=t;n+=e[r++]);return n}var zr=[31,29,31,30,31,30,31,31,30,31,30,31],Qr=[31,28,31,30,31,30,31,31,30,31,30,31];function qr(e,t){for(e=new Date(e.getTime());0<t;){var n=e.getMonth(),r=(Ir(e.getFullYear())?zr:Qr)[n];if(!(t>r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return e}function Hr(e,t,n,r){e||(e=this),this.parent=e,this.mount=e.mount,this.Nc=null,this.id=Rt.lf++,this.name=t,this.mode=n,this.Pb={},this.Qb={},this.Sc=r}n.requestFullscreen=function(e,t){!function(e,t){function r(){qe=!1;var e=o.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e?(o.exitFullscreen=Je,Ze&&o.requestPointerLock(),qe=!0,$e?("undefined"!=typeof SDL&&(z[SDL.screen>>2]=8388608|Q[SDL.screen>>2]),ut(n.canvas),ct()):ut(o)):(e.parentNode.insertBefore(o,e),e.parentNode.removeChild(e),$e?("undefined"!=typeof SDL&&(z[SDL.screen>>2]=-8388609&Q[SDL.screen>>2]),ut(n.canvas),ct()):ut(o)),n.onFullScreen&&n.onFullScreen(qe),n.onFullscreen&&n.onFullscreen(qe)}void 0===(Ze=e)&&(Ze=!0),void 0===($e=t)&&($e=!1);var o=n.canvas;Ge||(Ge=!0,document.addEventListener("fullscreenchange",r,!1),document.addEventListener("mozfullscreenchange",r,!1),document.addEventListener("webkitfullscreenchange",r,!1),document.addEventListener("MSFullscreenChange",r,!1));var i=document.createElement("div");o.parentNode.insertBefore(i,o),i.appendChild(o),i.requestFullscreen=i.requestFullscreen||i.mozRequestFullScreen||i.msRequestFullscreen||(i.webkitRequestFullscreen?function(){i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)}:null)||(i.webkitRequestFullScreen?function(){i.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:null),i.requestFullscreen()}(e,t)},n.requestAnimationFrame=function(e){et(e)},n.setCanvasSize=function(e,t,r){ut(n.canvas,e,t),r||ct()},n.pauseMainLoop=function(){We=null,Ce++},n.resumeMainLoop=function(){Ce++;var e=Be,t=Ie,r=je;je=null,function(e){function t(){return!(r<Ce&&(--he,Re(),1))}!je||Ae("emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),je=e;var r=Ce;Ue=!1,xe=function(){if(!R)if(0<ze.length){var r=Date.now(),o=ze.shift();if(o.Re(o.Cc),Le){var i=Le,a=0==i%1?i-1:Math.floor(i);Le=o.Uf?a:(8*i+(a+.5))/9}y('main loop blocker "'+o.name+'" took '+(Date.now()-r)+" ms"),n.setStatus&&(r=n.statusMessage||"Please wait...",o=Le,i=Qe.Xf,o?o<i?n.setStatus(r+" ("+(i-o)+"/"+i+")"):n.setStatus(r):n.setStatus("")),t()&&setTimeout(xe,0)}else t()&&(Ve=Ve+1|0,1==Be&&1<Ie&&0!=Ve%Ie?We():(0==Be&&(Me=Ee()),R||n.preMainLoop&&!1===n.preMainLoop()||(Fe(e),n.postMainLoop&&n.postMainLoop()),t()&&("object"==typeof SDL&&SDL.audio&&SDL.audio.uf&&SDL.audio.uf(),We())))}}(r),function(e,t){if(Be=e,Ie=t,je)if(Ue||(he+=1,Ue=!0),0==e)We=function(){var e=0|Math.max(0,Me+t-Ee());setTimeout(xe,e)};else if(1==e)We=function(){et(xe)};else if(2==e){if("undefined"==typeof setImmediate){var r=[];addEventListener("message",(function(e){"setimmediate"!==e.data&&"setimmediate"!==e.data.target||(e.stopPropagation(),r.shift()())}),!0),setImmediate=function(e){r.push(e),b?(void 0===n.setImmediates&&(n.setImmediates=[]),n.setImmediates.push(e),postMessage({target:"setimmediate"})):postMessage("setimmediate","*")}}We=function(){setImmediate(xe)}}}(e,t),We()},n.getUserMedia=function(){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(void 0)},n.createContext=function(e,t,r,o){return function(e,t,r,o){if(t&&n.nd&&e==n.canvas)return n.nd;var i;if(t){var a={antialias:!1,alpha:!1,ee:1};if(o)for(var c in o)a[c]=o[c];if(void 0!==Sr&&(i=Nr(e,a)))var u=Tr[i].Bc}else u=e.getContext("2d");return u?(r&&(t||void 0===Gr||Ae("cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),n.nd=u,t&&(Er=Tr[i],n.nd=Gr=Er&&Er.Bc),n.pg=t,Ye.forEach((function(e){e()})),Xe()),u):null}(e,t,r,o)},dt.init(),Object.defineProperties(Hr.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},ef:{get:function(){return Rt.isDir(this.mode)}},wd:{get:function(){return Rt.isChrdev(this.mode)}}}),Rt.oe=Hr,Rt.If(),fn=n.InternalError=sn("InternalError");for(var Yr=Array(256),Xr=0;256>Xr;++Xr)Yr[Xr]=String.fromCharCode(Xr);hn=Yr,pn=n.BindingError=sn("BindingError"),Un.prototype.isAliasOf=function(e){if(!(this instanceof Un&&e instanceof Un))return!1;var t=this.Ob.Xb.Sb,n=this.Ob.Ub,r=e.Ob.Xb.Sb;for(e=e.Ob.Ub;t.jc;)n=t.Xc(n),t=t.jc;for(;r.jc;)e=r.Xc(e),r=r.jc;return t===r&&n===e},Un.prototype.clone=function(){if(this.Ob.Ub||Pn(this),this.Ob.Rc)return this.Ob.count.value+=1,this;var e=Ln,t=Object,n=t.create,r=Object.getPrototypeOf(this),o=this.Ob;return(e=e(n.call(t,r,{Ob:{value:{count:o.count,Ec:o.Ec,Rc:o.Rc,Ub:o.Ub,Xb:o.Xb,cc:o.cc,ic:o.ic}}}))).Ob.count.value+=1,e.Ob.Ec=!1,e},Un.prototype.delete=function(){this.Ob.Ub||Pn(this),this.Ob.Ec&&!this.Ob.Rc&&mn("Object already scheduled for deletion"),Nn(this),En(this.Ob),this.Ob.Rc||(this.Ob.cc=void 0,this.Ob.Ub=void 0)},Un.prototype.isDeleted=function(){return!this.Ob.Ub},Un.prototype.deleteLater=function(){return this.Ob.Ub||Pn(this),this.Ob.Ec&&!this.Ob.Rc&&mn("Object already scheduled for deletion"),Dn.push(this),1===Dn.length&&Fn&&Fn(Rn),this.Ob.Ec=!0,this},n.getInheritedInstanceCount=function(){return Object.keys(Mn).length},n.getLiveInheritedInstances=function(){var e,t=[];for(e in Mn)Mn.hasOwnProperty(e)&&t.push(Mn[e]);return t},n.setAutoDeleteLater=function(e){An=e},n.flushPendingDeletes=Rn,n.setDelayFunction=function(e){Fn=e,Dn.length&&Fn&&Fn(Rn)},Qn.prototype.Ve=function(e){return this.je&&(e=this.je(e)),e},Qn.prototype.Qd=function(e){this.tc&&this.tc(e)},Qn.prototype.argPackAdvance=8,Qn.prototype.readValueFromPointer=nn,Qn.prototype.deleteObject=function(e){null!==e&&e.delete()},Qn.prototype.fromWireType=function(e){function t(){return this.dd?xn(this.Sb.vc,{Xb:this.sf,Ub:n,ic:this,cc:e}):xn(this.Sb.vc,{Xb:this,Ub:e})}var n=this.Ve(e);if(!n)return this.Qd(e),null;var r=function(e,t){for(void 0===t&&mn("ptr should not be undefined");e.jc;)t=e.Xc(t),e=e.jc;return Mn[t]}(this.Sb,n);if(void 0!==r)return 0===r.Ob.count.value?(r.Ob.Ub=n,r.Ob.cc=e,r.clone()):(r=r.clone(),this.Qd(e),r);if(r=this.Sb.Se(n),!(r=Sn[r]))return t.call(this);r=this.bd?r.Be:r.pointerType;var o=On(n,this.Sb,r.Sb);return null===o?t.call(this):this.dd?xn(r.Sb.vc,{Xb:r,Ub:o,ic:this,cc:e}):xn(r.Sb.vc,{Xb:r,Ub:o})},Yn=n.UnboundTypeError=sn("UnboundTypeError"),n.count_emval_handles=function(){for(var e=0,t=5;t<tr.length;++t)void 0!==tr[t]&&++e;return e},n.get_first_emval=function(){for(var e=5;e<tr.length;++e)if(void 0!==tr[e])return tr[e];return null};var Gr,Zr=[null,ht,function(e){if(m)return yr(2,1,e);try{return e=L(e),Rt.chdir(e),0}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}},Wt,function(e,t,n){if(m)return yr(4,1,e,t,n);try{var r=Ut(e);if(r.kc===t)var o=-28;else{var i=r.path,a=r.flags,c=Rt.lc(t);c&&Rt.close(c),o=Rt.open(i,a,0,t,t).kc}return o}catch(e){if(void 0===Rt||!(e instanceof Rt.Nb))throw e;return-e.Tb}},Ct,jt,Bt,It,Vt,zt,Qt,qt,Ht,Xt,Gt,Zt,$t,Jt,Kt,pr,mr,vr,Ar,Mr,xr,Lr,Ur,Wr,Cr,jr,Br];function $r(e,t){var n=Array(W(e)+1);return e=U(e,n,0,n.length),t&&(n.length=e),n}var Jr={e:function(e,t,n,r){Ae("Assertion failed: "+L(e)+", at: "+[t?L(t):"unknown filename",n,r?L(r):"unknown function"])},$a:function(e,t){pt(e)(t)},db:function(e,t){return mt(e,t)},jb:function(e){uo(e,!b,1,!h),dt.ne()},ka:function(e){m?postMessage({cmd:"cleanupThread",thread:e}):lt(e)},Z:function(){return z[to()>>2]=63,-1},la:function(e,t,n,r){if("undefined"==typeof SharedArrayBuffer)return g("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var o=[];return m&&0===o.length?fo(687865856,e,t,n,r):(e={Hf:n,Bd:e,Cc:r,Nf:o},m?(e.Sf="spawnThread",postMessage(e,o),0):vt(e))},Ca:Wt,Ea:Ct,B:jt,wa:Bt,ua:It,sa:Vt,ra:zt,qa:function(){return 0},Ga:Qt,ta:qt,Y:Ht,fb:Xt,eb:Gt,_a:Zt,Za:$t,va:Jt,ja:Kt,ga:function(e){var t=en[e];delete en[e];var n=t.Dd,r=t.tc,o=t.Vd;dn([e],o.map((function(e){return e.Xe})).concat(o.map((function(e){return e.Ef}))),(function(e){var i={};return o.forEach((function(t,n){var r=e[n],a=t.$c,c=t.We,u=e[n+o.length],s=t.Df,f=t.Ff;i[t.Oe]={read:function(e){return r.fromWireType(a(c,e))},write:function(e,t){var n=[];s(f,e,u.toWireType(n,t)),tn(n)}}})),[{name:t.name,fromWireType:function(e){var t,n={};for(t in i)n[t]=i[t].read(e);return r(e),n},toWireType:function(e,t){for(var o in i)if(!(o in t))throw new TypeError('Missing field: "'+o+'"');var a=n();for(o in i)i[o].write(a,t[o]);return null!==e&&e.push(r,a),a},argPackAdvance:8,readValueFromPointer:nn,bc:r}]}))},fa:function(e,t,n,r,o){t=bn(t);var i=wn(n);vn(e,{name:t,fromWireType:function(e){for(var a=Q[e>>2],c=r?yn(t,i):gn(t,i,o),u=Array(a),s=e+n,f=0;f<a;++f)u[f]=c[(s>>i)+f];return eo(e),u},toWireType:function(e,a){"number"==typeof a&&(a=[a]),Array.isArray(a)||mn("Cannot pass non-array to C++ vector type "+t);var c=(a=Array.prototype.concat.apply([],a)).length,u=r?yn(t,i):gn(t,i,o),s=Kr(n+c*n);Q[s>>2]=c;for(var f=s+n,l=0;l<c;++l)u[(f>>i)+l]=a[l];return null!==e&&e.push(eo,s),s},argPackAdvance:8,readValueFromPointer:nn,bc:function(e){eo(e)}})},ba:function(e,t,n,r,o){t=bn(t),n=wn(n);var i=t.includes("u");i&&(o=(BigInt(1)<<BigInt(64))-BigInt(1)),vn(e,{name:t,fromWireType:function(e){return e},toWireType:function(e,n){if("bigint"!=typeof n)throw new TypeError('Cannot convert "'+kn(n)+'" to '+this.name);if(n<r||n>o)throw new TypeError('Passing a number "'+kn(n)+'" from JS side to C/C++ side to an argument of type "'+t+'", which is outside the valid range ['+r+", "+o+"]!");return n},argPackAdvance:8,readValueFromPointer:_n(t,n,!i),bc:null})},La:function(e,t,n,r,o){var i=wn(n);vn(e,{name:t=bn(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:o},argPackAdvance:8,readValueFromPointer:function(e){var n=gn(t,i,!0);return this.fromWireType(n[e>>i])},bc:null})},z:function(e,t,n,r,o,i,a,c,u,s,f,l,d){f=bn(f),i=Hn(o,i),c&&(c=Hn(a,c)),s&&(s=Hn(u,s)),d=Hn(l,d);var h=cn(f);Cn(h,(function(){Gn("Cannot construct "+f+" due to unbound types",[r])})),dn([e,t,n],r?[r]:[],(function(t){if(t=t[0],r)var n=t.Sb,o=n.vc;else o=Un.prototype;t=un(h,(function(){if(Object.getPrototypeOf(this)!==a)throw new pn("Use 'new' to construct "+f);if(void 0===u.xc)throw new pn(f+" has no accessible constructor");var e=u.xc[arguments.length];if(void 0===e)throw new pn("Tried to invoke ctor of "+f+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(u.xc).toString()+") parameters instead!");return e.apply(this,arguments)}));var a=Object.create(o,{constructor:{value:t}});t.prototype=a;var u=new jn(f,t,a,d,n,i,c,s);n=new Qn(f,u,!0,!1),o=new Qn(f+"*",u,!1,!1);var l=new Qn(f+" const*",u,!1,!0);return Sn[e]={pointerType:o,Be:l},qn(h,t),[n,o,l]}))},h:function(e,t,n,r,o,i,a){var c=Jn(n,r);t=bn(t),i=Hn(o,i),dn([],[e],(function(e){function r(){Gn("Cannot call "+o+" due to unbound types",c)}var o=(e=e[0]).name+"."+t;t.startsWith("@@")&&(t=Symbol[t.substring(2)]);var u=e.Sb.constructor;return void 0===u[t]?(r.Dc=n-1,u[t]=r):(Wn(u,t,o),u[t].Zb[n-1]=r),dn([],c,(function(e){return e=$n(o,[e[0],null].concat(e.slice(1)),null,i,a),void 0===u[t].Zb?(e.Dc=n-1,u[t]=e):u[t].Zb[n-1]=e,[]})),[]}))},A:function(e,t,n,r,o,i){0<t||Ae(void 0);var a=Jn(t,n);o=Hn(r,o),dn([],[e],(function(e){var n="constructor "+(e=e[0]).name;if(void 0===e.Sb.xc&&(e.Sb.xc=[]),void 0!==e.Sb.xc[t-1])throw new pn("Cannot register multiple constructors with identical number of parameters ("+(t-1)+") for class '"+e.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return e.Sb.xc[t-1]=()=>{Gn("Cannot construct "+e.name+" due to unbound types",a)},dn([],a,(function(r){return r.splice(1,0,null),e.Sb.xc[t-1]=$n(n,r,null,o,i),[]})),[]}))},d:function(e,t,n,r,o,i,a,c){var u=Jn(n,r);t=bn(t),i=Hn(o,i),dn([],[e],(function(e){function r(){Gn("Cannot call "+o+" due to unbound types",u)}var o=(e=e[0]).name+"."+t;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),c&&e.Sb.tf.push(t);var s=e.Sb.vc,f=s[t];return void 0===f||void 0===f.Zb&&f.className!==e.name&&f.Dc===n-2?(r.Dc=n-2,r.className=e.name,s[t]=r):(Wn(s,t,o),s[t].Zb[n-2]=r),dn([],u,(function(r){return r=$n(o,r,e,i,a),void 0===s[t].Zb?(r.Dc=n-2,s[t]=r):s[t].Zb[n-2]=r,[]})),[]}))},w:function(e,t,n,r,o,i,a,c,u,s){t=bn(t),o=Hn(r,o),dn([],[e],(function(e){var r=(e=e[0]).name+"."+t,f={get:function(){Gn("Cannot access "+r+" due to unbound types",[n,a])},enumerable:!0,configurable:!0};return f.set=u?()=>{Gn("Cannot access "+r+" due to unbound types",[n,a])}:()=>{mn(r+" is a read-only property")},Object.defineProperty(e.Sb.vc,t,f),dn([],u?[n,a]:[n],(function(n){var a=n[0],f={get:function(){var t=Kn(this,e,r+" getter");return a.fromWireType(o(i,t))},enumerable:!0};if(u){u=Hn(c,u);var l=n[1];f.set=function(t){var n=Kn(this,e,r+" setter"),o=[];u(s,n,l.toWireType(o,t)),tn(o)}}return Object.defineProperty(e.Sb.vc,t,f),[]})),[]}))},Ka:function(e,t){vn(e,{name:t=bn(t),fromWireType:function(e){var t=rr(e);return nr(e),t},toWireType:function(e,t){return or(t)},argPackAdvance:8,readValueFromPointer:nn,bc:null})},p:function(e,t,n,r){function o(){}n=wn(n),t=bn(t),o.values={},vn(e,{name:t,constructor:o,fromWireType:function(e){return this.constructor.values[e]},toWireType:function(e,t){return t.value},argPackAdvance:8,readValueFromPointer:ir(t,n,r),bc:null}),Cn(t,o)},f:function(e,t,n){var r=ar(e,"enum");t=bn(t),e=r.constructor,r=Object.create(r.constructor.prototype,{value:{value:n},constructor:{value:un(r.name+"_"+t,(function(){}))}}),e.values[n]=r,e[t]=r},aa:function(e,t,n){n=wn(n),vn(e,{name:t=bn(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:cr(t,n),bc:null})},H:function(e,t,n,r,o,i){var a=Jn(t,n);e=bn(e),o=Hn(r,o),Cn(e,(function(){Gn("Cannot call "+e+" due to unbound types",a)}),t-1),dn([],a,(function(n){return qn(e,$n(e,[n[0],null].concat(n.slice(1)),null,o,i),t-1),[]}))},E:function(e,t,n,r,o){t=bn(t),-1===o&&(o=4294967295),o=wn(n);var i=e=>e;if(0===r){var a=32-8*n;i=e=>e<<a>>>a}n=t.includes("unsigned")?function(e,t){return t>>>0}:function(e,t){return t},vn(e,{name:t,fromWireType:i,toWireType:n,argPackAdvance:8,readValueFromPointer:_n(t,o,0!==r),bc:null})},v:function(e,t,n){function r(e){return new o(C,Q[(e>>=2)+1],Q[e])}var o=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array][t];vn(e,{name:n=bn(n),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{$e:!0})},$:function(e,t){var n="std::string"===(t=bn(t));vn(e,{name:t,fromWireType:function(e){var t=Q[e>>2];if(n)for(var r=e+4,o=0;o<=t;++o){var i=e+4+o;if(o==t||0==B[i]){if(r=L(r,i-r),void 0===a)var a=r;else a+=String.fromCharCode(0),a+=r;r=i+1}}else{for(a=Array(t),o=0;o<t;++o)a[o]=String.fromCharCode(B[e+4+o]);a=a.join("")}return eo(e),a},toWireType:function(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r="string"==typeof t;r||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||mn("Cannot pass non-string to std::string");var o=(n&&r?()=>W(t):()=>t.length)(),i=Kr(4+o+1);if(Q[i>>2]=o,n&&r)U(t,B,i+4,o+1);else if(r)for(r=0;r<o;++r){var a=t.charCodeAt(r);255<a&&(eo(i),mn("String has UTF-16 code units that do not fit in 8 bits")),B[i+4+r]=a}else for(r=0;r<o;++r)B[i+4+r]=t[r];return null!==e&&e.push(eo,i),i},argPackAdvance:8,readValueFromPointer:nn,bc:function(e){eo(e)}})},R:function(e,t,n){if(n=bn(n),2===t)var r=Z,o=$,i=J,a=1;else 4===t&&(r=K,o=ee,i=te,a=2);vn(e,{name:n,fromWireType:function(e){for(var o,i=Q[e>>2],c=gn(n,a,!1),u=e+4,s=0;s<=i;++s){var f=e+4+s*t;s!=i&&0!=c[f>>a]||(u=r(u,f-u),void 0===o?o=u:(o+=String.fromCharCode(0),o+=u),u=f+t)}return eo(e),o},toWireType:function(e,r){"string"!=typeof r&&mn("Cannot pass non-string to C++ string type "+n);var c=i(r),u=Kr(4+c+t);return Q[u>>2]=c>>a,o(r,u+4,c+t),null!==e&&e.push(eo,u),u},argPackAdvance:8,readValueFromPointer:nn,bc:function(e){eo(e)}})},ha:function(e,t,n,r,o,i){en[e]={name:bn(t),Dd:Hn(n,r),tc:Hn(o,i),Vd:[]}},J:function(e,t,n,r,o,i,a,c,u,s){en[e].Vd.push({Oe:bn(t),Xe:n,$c:Hn(r,o),We:i,Ef:a,Df:Hn(c,u),Ff:s})},Ma:function(e,t){vn(e,{ff:!0,name:t=bn(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},cb:function(){return 2097152},oa:function(e,t){if(e==t)postMessage({cmd:"processQueuedMainThreadWork"});else if(m)postMessage({targetThread:e,cmd:"processThreadQueue"});else{if(!(e=(e=dt.pc[e])&&e.worker))return;e.postMessage({cmd:"processThreadQueue"})}return 1},Wa:function(){throw 1/0},l:function(e,t,n){e=rr(e),t=ar(t,"emval::as");var r=[],o=or(r);return z[n>>2]=o,t.toWireType(r,e)},W:function(e,t,n,r){e=rr(e),n=ur(t,n);for(var o=Array(t),i=0;i<t;++i){var a=n[i];o[i]=a.readValueFromPointer(r),r+=a.argPackAdvance}return or(e=e.apply(void 0,o))},bb:function(e,t,n,r,o){e=lr[e],t=rr(t),n=fr(n);var i=[];return z[r>>2]=or(i),e(t,n,i,o)},b:nr,o:function(e){return 0===e?or(dr()):(e=fr(e),or(dr()[e]))},lb:function(e,t){var n=ur(e,t),r=n[0];t=r.name+"_$"+n.slice(1).map((function(e){return e.name})).join("_")+"$";var o=hr[t];if(void 0!==o)return o;o=["retType"];for(var i=[r],a="",c=0;c<e-1;++c)a+=(0!==c?", ":"")+"arg"+c,o.push("argType"+c),i.push(n[1+c]);var u="return function "+cn("methodCaller_"+t)+"(handle, name, destructors, args) {\n",s=0;for(c=0;c<e-1;++c)u+=" var arg"+c+" = argType"+c+".readValueFromPointer(args"+(s?"+"+s:"")+");\n",s+=n[c+1].argPackAdvance;for(u+=" var rv = handle[name]("+a+");\n",c=0;c<e-1;++c)n[c+1].deleteObject&&(u+=" argType"+c+".deleteObject(arg"+c+");\n");return r.ff||(u+=" return retType.toWireType(destructors, rv);\n"),o.push(u+"};\n"),o=function(e){var t=lr.length;return lr.push(e),t}(e=Zn(o).apply(null,i)),hr[t]=o},X:function(e){return e=fr(e),or(n[e])},m:function(e,t){return or((e=rr(e))[t=rr(t)])},c:function(e){4<e&&(tr[e].Gd+=1)},G:function(e,t){return(e=rr(e))instanceof(t=rr(t))},O:function(e){return"number"==typeof(e=rr(e))},ia:function(e){return"string"==typeof(e=rr(e))},x:function(e,t,r,o){e=rr(e);var i=br[t];if(!i){i="";for(var a=0;a<t;++a)i+=(0!==a?", ":"")+"arg"+a;var c="return function emval_allocator_"+t+"(constructor, argTypes, args) {\n";for(a=0;a<t;++a)c+="var argType"+a+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+a+'], "parameter '+a+'");\nvar arg'+a+" = argType"+a+".readValueFromPointer(args);\nargs += argType"+a+"['argPackAdvance'];\n";i=new Function("requireRegisteredType","Module","valueToHandle",c+"var obj = new constructor("+i+");\nreturn valueToHandle(obj);\n}\n")(ar,n,or),br[t]=i}return i(e,r,o)},n:function(e){return or(fr(e))},k:function(e){tn(rr(e)),nr(e)},K:function(e,t,n){e=rr(e),t=rr(t),n=rr(n),e[t]=n},r:function(e,t){return or(e=(e=ar(e,"_emval_take_value")).readValueFromPointer(t))},P:function(e){return or(typeof(e=rr(e)))},xa:function(e,t){e=new Date(1e3*z[e>>2]),z[t>>2]=e.getUTCSeconds(),z[t+4>>2]=e.getUTCMinutes(),z[t+8>>2]=e.getUTCHours(),z[t+12>>2]=e.getUTCDate(),z[t+16>>2]=e.getUTCMonth(),z[t+20>>2]=e.getUTCFullYear()-1900,z[t+24>>2]=e.getUTCDay(),z[t+28>>2]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},ya:function(e,t){e=new Date(1e3*z[e>>2]),z[t>>2]=e.getSeconds(),z[t+4>>2]=e.getMinutes(),z[t+8>>2]=e.getHours(),z[t+12>>2]=e.getDate(),z[t+16>>2]=e.getMonth(),z[t+20>>2]=e.getFullYear()-1900,z[t+24>>2]=e.getDay();var n=new Date(e.getFullYear(),0,1);z[t+28>>2]=(e.getTime()-n.getTime())/864e5|0,z[t+36>>2]=-60*e.getTimezoneOffset();var r=new Date(e.getFullYear(),6,1).getTimezoneOffset();n=n.getTimezoneOffset(),z[t+32>>2]=0|(r!=n&&e.getTimezoneOffset()==Math.min(n,r))},gb:pr,hb:mr,za:function e(t,n,r){e.xe||(e.xe=!0,vr(t,n,r))},j:function(){Ae("")},N:mt,ab:function(){b||k("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},Va:function(){throw he+=1,"unwind"},Ya:function(){return B.length},D:Ee,Aa:function(e,t,n){B.copyWithin(e,t,t+n)},S:wr,kb:function(e,t,n){t/=2,gr.length=t,n>>=3;for(var r=0;r<t;r++)gr[r]=H[n+2*r]?H[n+2*r+1]:X[n+2*r+1];return(0>e?Oe[-e-1]:Zr[e]).apply(null,gr)},Xa:function(){Ae("OOM")},ma:function(e,t,n){return _r(e)?Pr(e,t,n):Ar(e,t,n)},Ba:function(){throw"unwind"},na:function(e,t){return t={alpha:!!z[t>>=2],depth:!!z[t+1],stencil:!!z[t+2],antialias:!!z[t+3],premultipliedAlpha:!!z[t+4],preserveDrawingBuffer:!!z[t+5],powerPreference:Dr[z[t+6]],failIfMajorPerformanceCaveat:!!z[t+7],ee:z[t+8],dg:z[t+9],Sd:z[t+10],Ne:z[t+11],kg:z[t+12],lg:z[t+13]},!(e=_r(e))||t.Ne?0:Nr(e,t)},Ha:Mr,Ia:xr,U:function(e){Ao(e)},L:Lr,pa:Ur,_:Wr,ib:Cr,Q:jr,ca:function(e,t,n,r){var o=Q[1+(e>>2)],i=Q[6+(e>>2)],a=Q[2+(e>>2)],c=[],u=!1;if(15===(e=Se(Q[3+(e>>2)])[1]))throw Error("complex ret marshalling nyi");if(0>e||15<e)throw Error("Unexpected rtype "+e);4!==e&&13!==e||(c.push(n),u=!0);for(var s=0;s<i;s++){var f=Q[(r>>2)+s],l=Se(Q[(a>>2)+s]);switch(l=l[1]){case 1:case 10:case 9:case 14:c.push(Q[f>>2]);break;case 2:c.push(q[f>>2]);break;case 3:c.push(X[f>>3]);break;case 5:case 6:c.push(B[f]);break;case 7:case 8:c.push(V[f>>1]);break;case 11:case 12:c.push(Y[f>>3]);break;case 4:c.push(Y[f>>3]),c.push(Y[1+(f>>3)]);break;case 13:c.push(f);break;case 15:throw Error("complex marshalling nyi");default:throw Error("Unexpected type "+l)}}var d=wo();if(i!=o){var h=d;for(s=o-1;s>=i;s--)switch(f=Q[(r>>2)+s],l=Se(Q[(a>>2)+s]),l=l[1],l){case 5:case 6:--h,B[h&=-1]=B[f];break;case 7:case 8:h-=2,V[(h&=-2)>>1]=V[f>>1];break;case 1:case 9:case 10:case 14:case 2:h-=4,Q[(h&=-4)>>2]=Q[f>>2];break;case 3:case 11:case 12:h-=8,Q[(h&=-8)>>2]=Q[f>>2],Q[1+(h>>2)]=Q[1+(f>>2)];break;case 4:h-=16,Q[(h&=-8)>>2]=Q[f>>2],Q[1+(h>>2)]=Q[1+(f>>2)],Q[2+(h>>2)]=Q[1+(f>>2)],Q[3+(h>>2)]=Q[1+(f>>2)];break;case 13:h-=4,Q[(h&=-4)>>2]=f;break;case 15:throw Error("complex arg marshalling nyi");default:throw Error("Unexpected argtype "+l)}c.push(h),yo(h)}if(t=ae.get(t).apply(null,c),yo(d),!u)switch(e){case 0:break;case 1:case 9:case 10:case 14:Q[n>>2]=t;break;case 2:q[n>>2]=t;break;case 3:X[n>>3]=t;break;case 5:case 6:B[n+0]=t;break;case 7:case 8:V[n>>1]=t;break;case 11:case 12:Y[n>>3]=t;break;case 15:throw Error("complex ret marshalling nyi");default:throw Error("Unexpected rtype "+e)}},g:function(){return N},da:function(e){var t=Date.now();return z[e>>2]=t/1e3|0,z[e+4>>2]=t%1e3*1e3|0,0},I:function(e){var t=wo();try{return pt(e)()}catch(e){if(yo(t),e!==e+0)throw e;mo(1,0)}},u:function(e,t){var n=wo();try{return pt(e)(t)}catch(e){if(yo(n),e!==e+0)throw e;mo(1,0)}},s:function(e,t,n){var r=wo();try{return pt(e)(t,n)}catch(e){if(yo(r),e!==e+0)throw e;mo(1,0)}},t:function(e,t,n,r){var o=wo();try{return pt(e)(t,n,r)}catch(e){if(yo(o),e!==e+0)throw e;mo(1,0)}},M:function(e,t,n,r,o){var i=wo();try{return pt(e)(t,n,r,o)}catch(e){if(yo(i),e!==e+0)throw e;mo(1,0)}},Ta:function(e,t,n,r,o,i){var a=wo();try{return pt(e)(t,n,r,o,i)}catch(e){if(yo(a),e!==e+0)throw e;mo(1,0)}},Oa:function(e,t,n,r,o,i,a,c,u){var s=wo();try{return pt(e)(t,n,r,o,i,a,c,u)}catch(e){if(yo(s),e!==e+0)throw e;mo(1,0)}},V:function(e,t,n,r,o,i,a){var c=wo();try{return pt(e)(t,n,r,o,i,a)}catch(e){if(yo(c),e!==e+0)throw e;mo(1,0)}},Sa:function(e,t,n,r,o,i,a,c){var u=wo();try{return pt(e)(t,n,r,o,i,a,c)}catch(e){if(yo(u),e!==e+0)throw e;mo(1,0)}},Ra:function(e,t,n,r,o,i,a,c,u,s,f,l,d){var h=wo();try{return pt(e)(t,n,r,o,i,a,c,u,s,f,l,d)}catch(e){if(yo(h),e!==e+0)throw e;mo(1,0)}},q:function(e,t){var n=wo();try{pt(e)(t)}catch(e){if(yo(n),e!==e+0)throw e;mo(1,0)}},C:function(e,t,n){var r=wo();try{pt(e)(t,n)}catch(e){if(yo(r),e!==e+0)throw e;mo(1,0)}},y:function(e,t,n,r){var o=wo();try{pt(e)(t,n,r)}catch(e){if(yo(o),e!==e+0)throw e;mo(1,0)}},F:function(e,t,n,r,o){var i=wo();try{pt(e)(t,n,r,o)}catch(e){if(yo(i),e!==e+0)throw e;mo(1,0)}},Pa:function(e,t,n,r,o,i){var a=wo();try{pt(e)(t,n,r,o,i)}catch(e){if(yo(a),e!==e+0)throw e;mo(1,0)}},ea:function(e,t,n,r,o,i,a){var c=wo();try{pt(e)(t,n,r,o,i,a)}catch(e){if(yo(c),e!==e+0)throw e;mo(1,0)}},Qa:function(e,t,n,r,o,i,a,c,u,s){var f=wo();try{pt(e)(t,n,r,o,i,a,c,u,s)}catch(e){if(yo(f),e!==e+0)throw e;mo(1,0)}},a:O||n.wasmMemory,Fa:Br,i:function(e){N=e},Ua:function(){me()},Na:function(e,t,n,r){function o(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function i(e,t){return o(e,t,"0")}function a(e,t){function n(e){return 0>e?-1:0<e?1:0}var r;return 0===(r=n(e.getFullYear()-t.getFullYear()))&&0===(r=n(e.getMonth()-t.getMonth()))&&(r=n(e.getDate()-t.getDate())),r}function c(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){e=qr(new Date(e.dc+1900,0,1),e.kd);var t=new Date(e.getFullYear()+1,0,4),n=c(new Date(e.getFullYear(),0,4));return t=c(t),0>=a(n,e)?0>=a(t,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var s=z[r+40>>2];for(var f in r={Lf:z[r>>2],Kf:z[r+4>>2],hd:z[r+8>>2],Wc:z[r+12>>2],Jc:z[r+16>>2],dc:z[r+20>>2],jd:z[r+24>>2],kd:z[r+28>>2],og:z[r+32>>2],Jf:z[r+36>>2],Mf:s?L(s):""},n=L(n),s={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(f,"g"),s[f]);var l="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(f in s={"%a":function(e){return l[e.jd].substring(0,3)},"%A":function(e){return l[e.jd]},"%b":function(e){return d[e.Jc].substring(0,3)},"%B":function(e){return d[e.Jc]},"%C":function(e){return i((e.dc+1900)/100|0,2)},"%d":function(e){return i(e.Wc,2)},"%e":function(e){return o(e.Wc,2," ")},"%g":function(e){return u(e).toString().substring(2)},"%G":function(e){return u(e)},"%H":function(e){return i(e.hd,2)},"%I":function(e){return 0==(e=e.hd)?e=12:12<e&&(e-=12),i(e,2)},"%j":function(e){return i(e.Wc+Vr(Ir(e.dc+1900)?zr:Qr,e.Jc-1),3)},"%m":function(e){return i(e.Jc+1,2)},"%M":function(e){return i(e.Kf,2)},"%n":function(){return"\n"},"%p":function(e){return 0<=e.hd&&12>e.hd?"AM":"PM"},"%S":function(e){return i(e.Lf,2)},"%t":function(){return"\t"},"%u":function(e){return e.jd||7},"%U":function(e){var t=new Date(e.dc+1900,0,1),n=0===t.getDay()?t:qr(t,7-t.getDay());return 0>a(n,e=new Date(e.dc+1900,e.Jc,e.Wc))?i(Math.ceil((31-n.getDate()+(Vr(Ir(e.getFullYear())?zr:Qr,e.getMonth()-1)-31)+e.getDate())/7),2):0===a(n,t)?"01":"00"},"%V":function(e){var t=new Date(e.dc+1901,0,4),n=c(new Date(e.dc+1900,0,4));t=c(t);var r=qr(new Date(e.dc+1900,0,1),e.kd);return 0>a(r,n)?"53":0>=a(t,r)?"01":i(Math.ceil((n.getFullYear()<e.dc+1900?e.kd+32-n.getDate():e.kd+1-n.getDate())/7),2)},"%w":function(e){return e.jd},"%W":function(e){var t=new Date(e.dc,0,1),n=1===t.getDay()?t:qr(t,0===t.getDay()?1:7-t.getDay()+1);return 0>a(n,e=new Date(e.dc+1900,e.Jc,e.Wc))?i(Math.ceil((31-n.getDate()+(Vr(Ir(e.getFullYear())?zr:Qr,e.getMonth()-1)-31)+e.getDate())/7),2):0===a(n,t)?"01":"00"},"%y":function(e){return(e.dc+1900).toString().substring(2)},"%Y":function(e){return e.dc+1900},"%z":function(e){var t=0<=(e=e.Jf);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.Mf},"%%":function(){return"%"}},n=n.replace(/%%/g,"\0\0"),s)n.includes(f)&&(n=n.replace(new RegExp(f,"g"),s[f](r)));return(f=$r(n=n.replace(/\0\0/g,"%"),!1)).length>t?0:(j.set(f,e),f.length-1)},Ja:function(e){throw new TypeError(L(e))},Da:function(e){var t=n.Error.buffer();throw n.Error.clear(),Error(L(e)+"\n"+t)},T:function(e){var t=Date.now()/1e3|0;return e&&(z[e>>2]=t),t}};!function(){function e(e,t){if(n.asm=e.exports,dt.gd.push(n.asm.sb),ae=n.asm.ob,ue.unshift(n.asm.mb),S=t,!m){var r=dt.qc.length;dt.qc.forEach((function(e){dt.de(e,(function(){--r||Pe()}))}))}}function t(t){e(t.instance,t.module)}function r(e){return(A||!h&&!b||"function"!=typeof fetch?Promise.resolve().then((function(){return Ne()})):fetch(we,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+we+"'";return e.arrayBuffer()})).catch((function(){return Ne()}))).then((function(e){return WebAssembly.instantiate(e,i)})).then((function(e){return e})).then(e,(function(e){g("failed to asynchronously prepare wasm: "+e),Ae(e)}))}var i={a:Jr};if(m||_e(),n.instantiateWasm)try{return n.instantiateWasm(i,e)}catch(e){return g("Module.instantiateWasm callback failed with error: "+e),!1}(A||"function"!=typeof WebAssembly.instantiateStreaming||Te()||"function"!=typeof fetch?r(t):fetch(we,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,i).then(t,(function(e){return g("wasm streaming compile failed: "+e),g("falling back to ArrayBuffer instantiation"),r(t)}))}))).catch(o)}(),n.___wasm_call_ctors=function(){return(n.___wasm_call_ctors=n.asm.mb).apply(null,arguments)};var Kr=n._malloc=function(){return(Kr=n._malloc=n.asm.nb).apply(null,arguments)};n._main=function(){return(n._main=n.asm.pb).apply(null,arguments)};var eo=n._free=function(){return(eo=n._free=n.asm.qb).apply(null,arguments)},to=n.___errno_location=function(){return(to=n.___errno_location=n.asm.rb).apply(null,arguments)};n._emscripten_tls_init=function(){return(n._emscripten_tls_init=n.asm.sb).apply(null,arguments)};var no=n._emscripten_builtin_memalign=function(){return(no=n._emscripten_builtin_memalign=n.asm.tb).apply(null,arguments)},ro=n.___getTypeName=function(){return(ro=n.___getTypeName=n.asm.ub).apply(null,arguments)};n.___embind_register_native_and_builtin_types=function(){return(n.___embind_register_native_and_builtin_types=n.asm.vb).apply(null,arguments)};var oo=n.___stdio_exit=function(){return(oo=n.___stdio_exit=n.asm.wb).apply(null,arguments)},io=n.___funcs_on_exit=function(){return(io=n.___funcs_on_exit=n.asm.xb).apply(null,arguments)},ao=n._pthread_self=function(){return(ao=n._pthread_self=n.asm.yb).apply(null,arguments)};n.__emscripten_thread_crashed=function(){return(n.__emscripten_thread_crashed=n.asm.zb).apply(null,arguments)};var co=n._emscripten_main_thread_process_queued_calls=function(){return(co=n._emscripten_main_thread_process_queued_calls=n.asm.Ab).apply(null,arguments)},uo=n.__emscripten_thread_init=function(){return(uo=n.__emscripten_thread_init=n.asm.Bb).apply(null,arguments)};n._emscripten_current_thread_process_queued_calls=function(){return(n._emscripten_current_thread_process_queued_calls=n.asm.Cb).apply(null,arguments)};var so,fo=n._emscripten_sync_run_in_main_thread_4=function(){return(fo=n._emscripten_sync_run_in_main_thread_4=n.asm.Db).apply(null,arguments)},lo=n._emscripten_run_in_main_runtime_thread_js=function(){return(lo=n._emscripten_run_in_main_runtime_thread_js=n.asm.Eb).apply(null,arguments)},ho=n._emscripten_dispatch_to_thread_=function(){return(ho=n._emscripten_dispatch_to_thread_=n.asm.Fb).apply(null,arguments)},bo=n.__emscripten_thread_free_data=function(){return(bo=n.__emscripten_thread_free_data=n.asm.Gb).apply(null,arguments)},po=n.__emscripten_thread_exit=function(){return(po=n.__emscripten_thread_exit=n.asm.Hb).apply(null,arguments)},mo=n._setThrew=function(){return(mo=n._setThrew=n.asm.Ib).apply(null,arguments)},vo=n._emscripten_stack_set_limits=function(){return(vo=n._emscripten_stack_set_limits=n.asm.Jb).apply(null,arguments)},wo=n.stackSave=function(){return(wo=n.stackSave=n.asm.Kb).apply(null,arguments)},yo=n.stackRestore=function(){return(yo=n.stackRestore=n.asm.Lb).apply(null,arguments)},go=n.stackAlloc=function(){return(go=n.stackAlloc=n.asm.Mb).apply(null,arguments)},ko=n.__emscripten_allow_main_runtime_queued_calls=1314072;function _o(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Po(e){function t(){if(!so&&(so=!0,n.calledRun=!0,!R)){if(pe(),m||st(se),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),No){var t=e,o=n._main,i=(t=t||[]).length+1,a=go(4*(i+1));z[a>>2]=re(l);for(var c=1;c<i;c++)z[(a>>2)+c]=re(t[c-1]);z[(a>>2)+i]=0;try{Ao(o(i,a),!0)}catch(e){De(e)}}if(!m){if(n.postRun)for("function"==typeof n.postRun&&(n.postRun=[n.postRun]);n.postRun.length;)t=n.postRun.shift(),le.unshift(t);st(le)}}}if(e=e||f,!(0<ye))if(m)r(n),pe(),postMessage({cmd:"loaded"});else{if(n.preRun)for("function"==typeof n.preRun&&(n.preRun=[n.preRun]);n.preRun.length;)ve();st(ce),0<ye||(n.setStatus?(n.setStatus("Running..."),setTimeout((function(){setTimeout((function(){n.setStatus("")}),1),t()}),1)):t())}}function Ao(e,t){if(D=e,!t&&m)throw ht(e),"unwind";be()||me(),To(e)}function To(e){D=e,be()||(dt.me(),n.onExit&&n.onExit(e),R=!0),d(e,new _o(e))}if(n.addFunction=function(e,t){if(!P){P=new WeakMap;for(var n=ae.length,r=0;r<0+n;r++){var o=pt(r);o&&P.set(o,r)}}if(P.has(e))return P.get(e);if(T.length)n=T.pop();else{try{ae.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}n=ae.length-1}try{r=n,ae.set(r,e),bt[r]=e}catch(c){if(!(c instanceof TypeError))throw c;if("function"==typeof WebAssembly.Function){o={i:"i32",j:"i64",f:"f32",d:"f64"};var i={parameters:[],results:"v"==t[0]?[]:[o[t[0]]]};for(r=1;r<t.length;++r)i.parameters.push(o[t[r]]);r=new WebAssembly.Function(i,e)}else{o=[1,0,1,96],i=t.slice(0,1),t=t.slice(1);var a={i:127,j:126,f:125,d:124};for(o.push(t.length),r=0;r<t.length;++r)o.push(a[t[r]]);"v"==i?o.push(0):o=o.concat([1,a[i]]),o[1]=o.length-2,t=new Uint8Array([0,97,115,109,1,0,0,0].concat(o,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),t=new WebAssembly.Module(t),r=new WebAssembly.Instance(t,{e:{f:e}}).exports.f}t=n,ae.set(t,r),bt[t]=r}return P.set(e,n),n},n.keepRuntimeAlive=be,n.ENV=Rr,n.FS=Rt,n.PThread=dt,n.deletionQueue=Dn,n.PThread=dt,n.wasmMemory=O,n.ExitStatus=_o,ke=function e(){so||Po(),so||(ke=e)},n.run=Po,n.preInit)for("function"==typeof n.preInit&&(n.preInit=[n.preInit]);0<n.preInit.length;)n.preInit.pop()();var No=!0;return n.noInitialRun&&(No=!1),Po(),t.ready}})();"object"==typeof exports&&"object"==typeof module?module.exports=Vips:"function"==typeof define&&define.amd?define([],(function(){return Vips})):"object"==typeof exports&&(exports.Vips=Vips);
|
vips/vips.wasm
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:30a050fc7f815d77590f7199ec299c3fcc56f09f5cfc97b316639cb95842243f
|
3 |
+
size 5100409
|
vips/vips.worker.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
"use strict";var Module={},initializedJS=!1;function threadPrintErr(){var e=Array.prototype.slice.call(arguments).join(" ");console.error(e)}function threadAlert(){var e=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:e,threadId:Module._pthread_self()})}var err=threadPrintErr;self.alert=threadAlert,Module.instantiateWasm=(e,t)=>{var r=new WebAssembly.Instance(Module.wasmModule,e);return t(r),Module.wasmModule=null,r.exports},self.onmessage=e=>{try{if("load"===e.data.cmd){if(Module.wasmModule=e.data.wasmModule,Module.wasmMemory=e.data.wasmMemory,Module.buffer=Module.wasmMemory.buffer,Module.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof e.data.urlOrBlob)importScripts(e.data.urlOrBlob);else{var t=URL.createObjectURL(e.data.urlOrBlob);importScripts(t),URL.revokeObjectURL(t)}Vips(Module).then((function(e){Module=e}))}else if("run"===e.data.cmd){Module.__performance_now_clock_drift=performance.now()-e.data.time,Module.__emscripten_thread_init(e.data.threadInfoStruct,0,0,1),Module.establishStackSpace(),Module.PThread.receiveObjectTransfer(e.data),Module.PThread.threadInit(),initializedJS||(Module.___embind_register_native_and_builtin_types(),initializedJS=!0);try{var r=Module.invokeEntryPoint(e.data.start_routine,e.data.arg);Module.keepRuntimeAlive()?Module.PThread.setExitStatus(r):Module.__emscripten_thread_exit(r)}catch(e){if("unwind"!=e){if(!(e instanceof Module.ExitStatus))throw e;Module.keepRuntimeAlive()||Module.__emscripten_thread_exit(e.status)}}}else"cancel"===e.data.cmd?Module._pthread_self()&&Module.__emscripten_thread_exit(-1):"setimmediate"===e.data.target||("processThreadQueue"===e.data.cmd?Module._pthread_self()&&Module._emscripten_current_thread_process_queued_calls():"processProxyingQueue"===e.data.cmd?Module._pthread_self()&&Module._emscripten_proxy_execute_queue(e.data.queue):(err("worker.js received unknown command "+e.data.cmd),err(e.data)))}catch(e){throw err("worker.js onmessage() captured an uncaught exception: "+e),e&&e.stack&&err(e.stack),Module.__emscripten_thread_crashed&&Module.__emscripten_thread_crashed(),e}};
|