diff --git a/Audio-Transcription/README.md b/Audio-Transcription/README.md index 44d14aa..4e5fa8c 100644 --- a/Audio-Transcription/README.md +++ b/Audio-Transcription/README.md @@ -2,6 +2,8 @@ Audio Transcription is a Chrome extension that allows users to capture any audio playing on the current tab and transcribe it using OpenAI-whisper in real time. Users will have the option to do voice activity detection as well to not send audio to server when there is no speech. +We use OpenAI-whisper model to process the audio continuously and send the transcription back to the client. We apply a few optimizations on top of OpenAI's implementation to improve performance and run it faster in a real-time manner. To this end, we used [faster-whisper](https://github.com/guillaumekln/faster-whisper) which is 4x faster than OpenAI's implementation. + ## Loading the Extension - Open the Google Chrome browser. - Type chrome://extensions in the address bar and press Enter. @@ -16,43 +18,18 @@ Audio Transcription is a Chrome extension that allows users to capture any audio This Chrome extension allows you to send audio from your browser to a server for transcribing the audio in real time. It can also incorporate voice activity detection on the client side to detect when speech is present, and it continuously receives transcriptions of the spoken content from the server. You can select from the options menu if you want to run the speech recognition. -## Running the Whisper-live server -For a detailed overview of how to run the server to leverage real time transcriptions with OpenAI-whisper, use [whisper-live](https://github.com/collabora/whisper-live) to setup your own server. - - -## Options -Several options are able to be changed in the extension: -- 'Mute tabs that are being captured' allows the extension to force any tabs currently being captured to be muted on the system's audio output, but still have its audio captured and encoded to the resulting file. -- 'Maximum capture time' changes the amount of time the extension will capture audio for before timing out, and has a limit to prevent exceeding Chrome's memory limit. -- 'Output file format' allows users to choose whether the resulting file will be encoded into .wav or .mp3 -- 'MP3 Quality' is only applicable for .mp3 encodings, and will change the bitrate of the encode. (Low: 96 kbps, Medium: 192 kbps, High: 320 kbps) -- 'Enable Voice Activity detection' allows users to run a voice activity detection model before sending audio to a server hosting the OpenAI-whisper model for transcriptions. - - ## Implementation Details ### Capturing Audio -To capture the audio in the current tab, I used the chrome `tabCapture` API to obtain a `MediaStream` object of the current tab. Next I used the `MediaStream` object to initialize a recorder that will encode the stream into a .wav file using the `Recorder.js` library. +To capture the audio in the current tab, we used the chrome `tabCapture` API to obtain a `MediaStream` object of the current tab. -### Audio Transcription -We use OpenAI-whisper model to process the audio continuously and send the transcription back to the client. We apply a few optimizations on top of OpenAI's implementation to improve performance and run it faster in a real-time manner. To this end, we used [faster-whisper](https://github.com/guillaumekln/faster-whisper) which is 4x faster than OpenAI's implementation. - -### Voice Activity Detection -For VAD, we use [silero-vad](https://github.com/snakers4/silero-vad) which is both efficient and accurate for detecting voice activity. It takes around ```1ms``` to process a single audio chunk of ```30ms```. We use the ONNX model in the browser to only send the audio to the server when there is a voice activity. - -### Tab Management -To allow audio capture on multiple tabs simultaneously, I stored the `tabId` of each tab being captured into the `sessionStorage` object. When a `stopCapture` command is issued, the extension will check whether the current tab is the same as the tab that the capture was started on, and only stop the specific instance of the capture on the current tab. - - -### Audio Playback During Capture -By default, using `tabCapture` will mute the audio on the current tab in order for the capture to take place. To allow audio to continue playing during the capture, I created an `Audio` object which has its source linked to the ongoing stream that is being captured. In the options menu, users will have the option to keep the tab muted or unmuted during the capture. +### Getting Started +- Make sure the transcription server is running properly. To know more about how to start the server, see the [documentation here](https://github.com/collabora/whisper-live). +- Just click on the Chrome Extension which should show 2 options + - **Start Capture** : Starts capturing the audio in the current tab and sends the captured audio to the server for transcription. This also creates an element to show the transcriptions recieved from the server on the current tab. + - **Stop Capture** - Stops capturing the audio. ## Limitations This extension requires an internet connection to stream audio and receive transcriptions. The accuracy of the transcriptions may vary depending on the audio quality and the performance of the server-side transcription service. The extension may consume additional system resources while running, especially when streaming audio. -## License -This extension is provided as-is, without any warranty or guarantee of its performance or suitability for any particular purpose. The developers of this extension shall not be held responsible for any damages or losses incurred while using this extension. -This extension uses LAME MP3 encoder, licensed LGPL. -Everything else is under the MIT License. - diff --git a/Audio-Transcription/background.html b/Audio-Transcription/background.html deleted file mode 100644 index cd29f49..0000000 --- a/Audio-Transcription/background.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Audio-Transcription/background.js b/Audio-Transcription/background.js index 3254ed0..25ea75c 100644 --- a/Audio-Transcription/background.js +++ b/Audio-Transcription/background.js @@ -1,368 +1,203 @@ -const extend = function() { //helper function to merge objects - let target = arguments[0], - sources = [].slice.call(arguments, 1); - for (let i = 0; i < sources.length; ++i) { - let src = sources[i]; - for (key in src) { - let val = src[key]; - target[key] = typeof val === "object" - ? extend(typeof target[key] === "object" ? target[key] : {}, val) - : val; - } - } - return target; -}; +/** + * Removes a tab with the specified tab ID in Google Chrome. + * @param {number} tabId - The ID of the tab to be removed. + * @returns {Promise} A promise that resolves when the tab is successfully removed or fails to remove. + */ +function removeChromeTab(tabId) { + return new Promise((resolve) => { + chrome.tabs.remove(tabId) + .then(resolve) + .catch(resolve); + }); +} -const WORKER_FILE = { - wav: "WavWorker.js", - mp3: "Mp3Worker.js" -}; -// default configs -const CONFIGS = { - workerDir: "/workers/", // worker scripts dir (end with /) - numChannels: 2, // number of channels - encoding: "wav", // encoding (can be changed at runtime) - - // runtime options - options: { - timeLimit: 1200, // recording time limit (sec) - encodeAfterRecord: true, // process encoding after recording - progressInterval: 1000, // encoding progress report interval (millisec) - bufferSize: 4096, // buffer size (use browser default) - - // encoding-specific options - wav: { - mimeType: "audio/wav" - }, - mp3: { - mimeType: "audio/mpeg", - bitRate: 192 // (CBR only): bit rate = [64 .. 320] - } - } -}; - -class Recorder { - - constructor(source, configs) { //creates audio context from the source and connects it to the worker - extend(this, CONFIGS, configs || {}); - this.speech_threshold = 0.4 - this.context = source.context; - if (this.context.createScriptProcessor == null) - this.context.createScriptProcessor = this.context.createJavaScriptNode; - this.input = this.context.createGain(); - source.connect(this.input); - this.buffer = []; - this.initWorker(); - } - - isRecording() { - return this.processor != null; - } - - setEncoding(encoding) { - if(!this.isRecording() && this.encoding !== encoding) { - this.encoding = encoding; - this.initWorker(); - } - } - - setOptions(options) { - if (!this.isRecording()) { - extend(this.options, options); - this.worker.postMessage({ command: "options", options: this.options}); - } - } - - async startRecording(doVad) { - if(!this.isRecording()) { - let numChannels = this.numChannels; - let buffer = this.buffer; - let worker = this.worker; - - // initialize onnx model - const session = await ort.InferenceSession.create('./silero_vad.onnx'); - var h = new Array(128); - for (let i = 0; i < h.length; i++) { - h[i] = 0; +/** + * Executes a script file in a specific tab in Google Chrome. + * @param {number} tabId - The ID of the tab where the script should be executed. + * @param {string} file - The file path or URL of the script to be executed. + * @returns {Promise} A promise that resolves when the script is successfully executed or fails to execute. + */ +function executeScriptInTab(tabId, file) { + return new Promise((resolve) => { + chrome.scripting.executeScript( + { + target: { tabId }, + files: [file], + }, () => { + resolve(); } - var c = new Array(128); - for (let i = 0; i < h.length; i++) { - c[i] = 0; - } - - const sr = new BigInt64Array(1) - sr[0] = BigInt(16000); - const srate = new ort.Tensor('int64', sr, [1]); - let speech_prob = undefined; - const vad_infer = async (feed_dict) => { - // feed inputs and run - try{ - const results = await session.run(feed_dict); + ); + }); +} - // update states - h = results.hn.data - c = results.cn.data - speech_prob = results.output.data - } catch(e) { - console.log(e) - } - } - this.processor = this.context.createScriptProcessor( - this.options.bufferSize, - this.numChannels, this.numChannels); - this.input.connect(this.processor); - this.processor.connect(this.context.destination); - this.processor.onaudioprocess = function(event) { - for (var ch = 0; ch < numChannels; ++ch) - buffer[ch] = event.inputBuffer.getChannelData(ch); - - // voice activity detection inference - const audioBuffer = new ort.Tensor('float32', buffer[0], [1, buffer[0].length]); - const hh = new ort.Tensor('float32', h, [2, 1, 64]); - const hc = new ort.Tensor('float32', c, [2, 1, 64]); - const feeds = { input: audioBuffer, sr: srate, h: hh, c: hc}; - - // feed inputs and run - if (doVad) { - vad_infer(feeds) - if (speech_prob > 0.4) { - worker.postMessage({ command: "record", buffer: buffer }); - } - else - console.log("no speech found: " + speech_prob) - } - else - worker.postMessage({ command: "record", buffer: buffer }); - }; - this.worker.postMessage({ - command: "start", - bufferSize: this.processor.bufferSize - }); - this.startTime = Date.now(); - } - } - cancelRecording() { - if(this.isRecording()) { - this.input.disconnect(); - this.processor.disconnect(); - delete this.processor; - this.worker.postMessage({ command: "cancel" }); - } - } - - finishRecording() { - if (this.isRecording()) { - this.input.disconnect(); - this.processor.disconnect(); - delete this.processor; - this.worker.postMessage({ command: "finish" }); - } - } - - cancelEncoding() { - if (this.options.encodeAfterRecord) - if (!this.isRecording()) { - this.onEncodingCanceled(this); - this.initWorker(); - } - } - - initWorker() { - if (this.worker != null) - this.worker.terminate(); - this.onEncoderLoading(this, this.encoding); - this.worker = new Worker(this.workerDir + WORKER_FILE[this.encoding]); - let _this = this; - this.worker.onmessage = function(event) { - let data = event.data; - switch (data.command) { - case "transcription": - chrome.tabs.getSelected(null, function(tab) { - chrome.tabs.sendMessage(tab.id, { message: data.text }); - }); - break; - case "loaded": - _this.onEncoderLoaded(_this, _this.encoding); - break; - case "timeout": - _this.onTimeout(_this); - break; - case "progress": - _this.onEncodingProgress(_this, data.progress); - break; - case "complete": - _this.onComplete(_this, data.blob); - } - } - this.worker.postMessage({ - command: "init", - config: { - sampleRate: this.context.sampleRate, - numChannels: this.numChannels +/** + * Opens the options page of the Chrome extension in a new pinned tab. + * @returns {Promise} A promise that resolves with the created tab object. + */ +function openExtensionOptions() { + return new Promise((resolve) => { + chrome.tabs.create( + { + pinned: true, + active: false, + url: `chrome-extension://${chrome.runtime.id}/options.html`, }, - options: this.options + (tab) => { + resolve(tab); + } + ); + }); +} + + +/** + * Retrieves the value associated with the specified key from the local storage in Google Chrome. + * @param {string} key - The key of the value to retrieve from the local storage. + * @returns {Promise} A promise that resolves with the retrieved value from the local storage. + */ +function getLocalStorageValue(key) { + return new Promise((resolve) => { + chrome.storage.local.get([key], (result) => { + resolve(result[key]); }); - } - - onEncoderLoading(recorder, encoding) {} - onEncoderLoaded(recorder, encoding) {} - onTimeout(recorder) {} - onEncodingProgress(recorder, progress) {} - onEncodingCanceled(recorder) {} - onComplete(recorder, blob) {} - + }); } -const audioCapture = (timeLimit, muteTab, format, quality, limitRemoved, doVad) => { - chrome.tabCapture.capture({audio: true}, (stream) => { // sets up stream for capture - let startTabId; //tab when the capture is started - let timeout; - let completeTabID; //tab when the capture is stopped - let audioURL = null; //resulting object when encoding is completed - chrome.tabs.query({active:true, currentWindow: true}, (tabs) => startTabId = tabs[0].id) //saves start tab - const liveStream = stream; - const audioCtx = new AudioContext({sampleRate: 16000}); - const source = audioCtx.createMediaStreamSource(stream); - let mediaRecorder = new Recorder(source); //initiates the recorder based on the current stream - mediaRecorder.setEncoding(format); //sets encoding based on options - if(limitRemoved) { //removes time limit - mediaRecorder.setOptions({timeLimit: 10800}); + +/** + * Sends a message to a specific tab in Google Chrome. + * @param {number} tabId - The ID of the tab to send the message to. + * @param {any} data - The data to be sent as the message. + * @returns {Promise} A promise that resolves with the response from the tab. + */ +function sendMessageToTab(tabId, data) { + return new Promise((resolve) => { + chrome.tabs.sendMessage(tabId, data, (response) => { + resolve(response); + }); + }); +} + + +/** + * Delays the execution for a specified duration. + * @param {number} ms - The duration to sleep in milliseconds (default: 0). + * @returns {Promise} A promise that resolves after the specified duration. + */ +function delayExecution(ms = 0) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + + +/** + * Sets a value associated with the specified key in the local storage of Google Chrome. + * @param {string} key - The key to set in the local storage. + * @param {any} value - The value to associate with the key in the local storage. + * @returns {Promise} A promise that resolves with the value that was set in the local storage. + */ +function setLocalStorageValue(key, value) { + return new Promise((resolve) => { + chrome.storage.local.set( + { + [key]: value, + }, () => { + resolve(value); + } + ); + }); +} + + +/** + * Retrieves the tab object with the specified tabId. + * @param {number} tabId - The ID of the tab to retrieve. + * @returns {Promise} - A Promise that resolves to the tab object. + */ +async function getTab(tabId) { + return new Promise((resolve) => { + chrome.tabs.get(tabId, (tab) => { + resolve(tab); + }); + }); +} + + +/** + * Starts the capture process for the specified tab. + * @param {number} tabId - The ID of the tab to start capturing. + * @returns {Promise} - A Promise that resolves when the capture process is started successfully. + */ +async function startCapture(tabId) { + const optionTabId = await getLocalStorageValue("optionTabId"); + if (optionTabId) { + await removeChromeTab(optionTabId); + } + + try { + const currentTab = await getTab(tabId); + if (currentTab.audible) { + await setLocalStorageValue("currentTabId", currentTab.id); + await executeScriptInTab(currentTab.id, "content.js"); + await delayExecution(500); + + const optionTab = await openExtensionOptions(); + + await setLocalStorageValue("optionTabId", optionTab.id); + await delayExecution(500); + + await sendMessageToTab(optionTab.id, { + type: "start_capture", + data: { currentTabId: currentTab.id }, + }); } else { - mediaRecorder.setOptions({timeLimit: timeLimit/1000}); + console.log("No Audio"); } - if(format === "mp3") { - mediaRecorder.setOptions({mp3: {bitRate: quality}}); - } - mediaRecorder.startRecording(doVad); - - function onStopCommand(command) { //keypress - if (command === "stop") { - stopCapture(); - } - } - function onStopClick(request) { //click on popup - if(request === "stopCapture") { - stopCapture(); - } else if (request === "cancelCapture") { - cancelCapture(); - } else if (request.cancelEncodeID) { - if(request.cancelEncodeID === startTabId && mediaRecorder) { - mediaRecorder.cancelEncoding(); - } - } - } - chrome.commands.onCommand.addListener(onStopCommand); - chrome.runtime.onMessage.addListener(onStopClick); - mediaRecorder.onComplete = (recorder, blob) => { - audioURL = window.URL.createObjectURL(blob); - if(completeTabID) { - chrome.tabs.sendMessage(completeTabID, {type: "encodingComplete", audioURL}); - } - mediaRecorder = null; - } - mediaRecorder.onEncodingProgress = (recorder, progress) => { - if(completeTabID) { - chrome.tabs.sendMessage(completeTabID, {type: "encodingProgress", progress: progress}); - } - } - - const stopCapture = function() { - let endTabId; - //check to make sure the current tab is the tab being captured - chrome.tabs.query({active: true, currentWindow: true}, (tabs) => { - endTabId = tabs[0].id; - if(mediaRecorder && startTabId === endTabId){ - mediaRecorder.finishRecording(); - chrome.tabs.create({url: "complete.html"}, (tab) => { - completeTabID = tab.id; - let completeCallback = () => { - chrome.tabs.sendMessage(tab.id, {type: "createTab", format: format, audioURL, startID: startTabId}); - } - setTimeout(completeCallback, 500); - }); - closeStream(endTabId); - } - }) - } - - const cancelCapture = function() { - let endTabId; - chrome.tabs.query({active: true, currentWindow: true}, (tabs) => { - endTabId = tabs[0].id; - if(mediaRecorder && startTabId === endTabId){ - mediaRecorder.cancelRecording(); - closeStream(endTabId); - } - }) - } - -//removes the audio context and closes recorder to save memory - const closeStream = function(endTabId) { - chrome.commands.onCommand.removeListener(onStopCommand); - chrome.runtime.onMessage.removeListener(onStopClick); - mediaRecorder.onTimeout = () => {}; - audioCtx.close(); - liveStream.getAudioTracks()[0].stop(); - sessionStorage.removeItem(endTabId); - chrome.runtime.sendMessage({captureStopped: endTabId}); - } - - mediaRecorder.onTimeout = stopCapture; - - if(!muteTab) { - let audio = new Audio(); - audio.srcObject = liveStream; - audio.play(); - } - }); + } catch (error) { + console.error("Error occurred while starting capture:", error); + } } +/** + * Stops the capture process and performs cleanup. + * @returns {Promise} - A Promise that resolves when the capture process is stopped successfully. + */ +async function stopCapture() { + const optionTabId = await getLocalStorageValue("optionTabId"); + const currentTabId = await getLocalStorageValue("currentTabId"); -//sends reponses to and from the popup menu -chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { - if (request.currentTab && sessionStorage.getItem(request.currentTab)) { - sendResponse(sessionStorage.getItem(request.currentTab)); - } else if (request.currentTab){ - sendResponse(false); - } else if (request === "startCapture") { - startCapture(); + if (optionTabId) { + res = await sendMessageToTab(currentTabId, { + type: "STOP", + data: { currentTabId: currentTabId }, + }); + await removeChromeTab(optionTabId); + } +} + + +/** + * Listens for messages from the runtime and performs corresponding actions. + * @param {Object} message - The message received from the runtime. + */ +chrome.runtime.onMessage.addListener((message) => { + if (message.action === "startCapture") { + startCapture(message.tabId); + } else if (message.action === "stopCapture") { + stopCapture(); } }); -const startCapture = function() { - chrome.tabs.query({active: true, currentWindow: true}, (tabs) => { - // CODE TO BLOCK CAPTURE ON YOUTUBE, DO NOT REMOVE - // if(tabs[0].url.toLowerCase().includes("youtube")) { - // chrome.tabs.create({url: "error.html"}); - // } else { - if(!sessionStorage.getItem(tabs[0].id)) { - sessionStorage.setItem(tabs[0].id, Date.now()); - chrome.storage.sync.get({ - maxTime: 1200000, - muteTab: false, - format: "mp3", - quality: 192, - limitRemoved: false, - doVad: false - }, (options) => { - let time = options.maxTime; - if(time > 1200000) { - time = 1200000 - } - audioCapture(time, options.muteTab, options.format, options.quality, options.limitRemoved, options.doVad); - }); - chrome.runtime.sendMessage({captureStarted: tabs[0].id, startTime: Date.now()}); - } - // } - }); -}; - -chrome.commands.onCommand.addListener((command) => { - if (command === "start") { - startCapture(); +/** + * Listens for if the tab is reloaded. + * @param {Object} message - The message received from the runtime. + */ +chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => { + if (changeInfo.status === 'complete') { + await executeScriptInTab(tabId, "content.js"); + await delayExecution(500); } }); diff --git a/Audio-Transcription/collabora.png b/Audio-Transcription/collabora.png deleted file mode 100644 index f656f2e..0000000 Binary files a/Audio-Transcription/collabora.png and /dev/null differ diff --git a/Audio-Transcription/complete.css b/Audio-Transcription/complete.css deleted file mode 100644 index f81dfdc..0000000 --- a/Audio-Transcription/complete.css +++ /dev/null @@ -1,71 +0,0 @@ -.header { - display: flex; - align-items: center; - padding-bottom: 15px; - padding-left: 20px; - border-bottom: 2px solid darkred; -} - -.header-title { - padding: 0 5px; -} - -.progress { - margin: 50px 20px 10px 20px; - font-size: 16px; - display: flex; -} - -.notes { - margin: 0 20px; -} - -#progressContainer { - margin-left: 5px; - width: 500px; - height: 18px; - background-color: lavenderblush; -} - -#encodeProgress { - height: 100%; - width: 0%; - background-color: darkred; -} - -#saveCapture { - display: none; -} - -.buttonContainer { - display: flex; -} - -#status { - margin-top: 30px; - margin-left: 20px; - font-size: 14px; -} - -.button { - padding: 10px; - border: 2px solid darkred; - font-size: 16px; - background-color: lavenderblush; - font-weight: bold; - margin: 10px 20px; - cursor: pointer; - border-radius: 5px; -} - -.button:hover { - color: red; - background-color: darkred; -} - -#review { - color: blue; - display: inline; - text-decoration: underline; - cursor: pointer; -} diff --git a/Audio-Transcription/complete.html b/Audio-Transcription/complete.html deleted file mode 100644 index 676b19f..0000000 --- a/Audio-Transcription/complete.html +++ /dev/null @@ -1,24 +0,0 @@ - - - Audio Transcription Options - - - - -

Audio Transcription

-
-
- -
-
-
-
-

-
-
-
Save Capture
-
Close
-
-
Thank you for using the extension! Please go
here
to leave a star!
- - diff --git a/Audio-Transcription/complete.js b/Audio-Transcription/complete.js deleted file mode 100644 index 208a7bf..0000000 --- a/Audio-Transcription/complete.js +++ /dev/null @@ -1,56 +0,0 @@ -document.addEventListener('DOMContentLoaded', () => { - const encodeProgress = document.getElementById('encodeProgress'); - const saveButton = document.getElementById('saveCapture'); - const closeButton = document.getElementById('close'); - const review = document.getElementById('review'); - const status = document.getElementById('status'); - let format; - let audioURL; - let encoding = false; - chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { - if(request.type === "createTab") { - format = request.format; - let startID = request.startID; - status.innerHTML = "Please wait..." - closeButton.onclick = () => { - chrome.runtime.sendMessage({cancelEncodeID: startID}); - chrome.tabs.getCurrent((tab) => { - chrome.tabs.remove(tab.id); - }); - } - - //if the encoding completed before the page has loaded - if(request.audioURL) { - encodeProgress.style.width = '100%'; - status.innerHTML = "File is ready!" - generateSave(request.audioURL); - } else { - encoding = true; - } - } - - //when encoding completes - if(request.type === "encodingComplete" && encoding) { - encoding = false; - status.innerHTML = "File is ready!"; - encodeProgress.style.width = '100%'; - generateSave(request.audioURL); - } - //updates encoding process bar upon messages - if(request.type === "encodingProgress" && encoding) { - encodeProgress.style.width = `${request.progress * 100}%`; - } - function generateSave(url) { //creates the save button - const currentDate = new Date(Date.now()).toDateString(); - saveButton.onclick = () => { - chrome.downloads.download({url: url, filename: `${currentDate}.${format}`, saveAs: true}); - }; - saveButton.style.display = "inline-block"; - } - }); - review.onclick = () => { - chrome.tabs.create({url: "https://github.com/collabora/whisper-live"}); - } - - -}) diff --git a/Audio-Transcription/content.js b/Audio-Transcription/content.js index 8ce32fc..e8c654f 100644 --- a/Audio-Transcription/content.js +++ b/Audio-Transcription/content.js @@ -1,3 +1,5 @@ + + var elem_container = null; var elem_text = null; @@ -111,17 +113,33 @@ function get_lines(elem, line_height) { } -chrome.runtime.onMessage.addListener(function(request, sender) { +function remove_element() { + var elem = document.getElementById('transcription') + for (var i = 0; i < 4; i++) { + document.getElementById("t" + i).remove(); + } + elem.remove() +} + +chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { + const { type, data } = request; + + if (type === "STOP") { + remove_element(); + sendResponse({data: "STOPPED"}); + return; + } + init_element(); - message = JSON.parse(request.message); + message = JSON.parse(data); var text = ''; - for (var i = 0; i < message.segments.length; i++) { - text += message.segments[i].text + ' '; + for (var i = 0; i < message.length; i++) { + text += message[i].text + ' '; } text = text.replace(/(\r\n|\n|\r)/gm, ""); - + var elem = document.getElementById('t3'); elem.innerHTML = text; @@ -132,6 +150,7 @@ chrome.runtime.onMessage.addListener(function(request, sender) { text_segments = []; text_segments = get_lines(elem, line_height); + elem.innerHTML = ''; if (text_segments.length > 2) { @@ -160,4 +179,6 @@ chrome.runtime.onMessage.addListener(function(request, sender) { var elem = document.getElementById('t' + i); elem.style.top = parent_elem.offsetHeight + parent_elem.offsetTop + 'px'; } -}); \ No newline at end of file + + sendResponse({}); +}); diff --git a/Audio-Transcription/encoders/Mp3Encoder.min.js b/Audio-Transcription/encoders/Mp3Encoder.min.js deleted file mode 100644 index 1562efc..0000000 --- a/Audio-Transcription/encoders/Mp3Encoder.min.js +++ /dev/null @@ -1,14 +0,0 @@ -((function(self){var Module=self.Mp3LameEncoderConfig;var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB;var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);if(!ret&&filename!=nodePath["resolve"](filename)){filename=path.join(__dirname,"..","src",filename);ret=nodeFS["readFileSync"](filename)}if(ret&&!binary)ret=ret.toString();return ret};Module["readBinary"]=function readBinary(filename){return Module["read"](filename,true)};Module["load"]=function load(f){globalEval(read(f))};if(!Module["thisProgram"]){if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}else{Module["thisProgram"]="unknown-program"}}Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.log(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WORKER){Module["load"]=importScripts}if(typeof Module["setWindowTitle"]==="undefined"){Module["setWindowTitle"]=(function(title){document.title=title})}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}var Runtime={setTempRet0:(function(value){tempRet0=value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}),getNativeFieldSize:(function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)}),STACK_ALIGN:16,prepVararg:(function(ptr,type){if(type==="double"||type==="i64"){if(ptr&7){assert((ptr&7)===4);ptr+=4}}else{assert((ptr&3)===0)}return ptr}),getAlignSize:(function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)}),dynCall:(function(sig,ptr,args){if(args&&args.length){if(!args.splice)args=Array.prototype.slice.call(args);args.splice(0,0,ptr);return Module["dynCall_"+sig].apply(null,args)}else{return Module["dynCall_"+sig].call(null,ptr)}}),functionPointers:[],addFunction:(function(func){for(var i=0;i=TOTAL_MEMORY){var success=enlargeMemory();if(!success){DYNAMICTOP=ret;return 0}}return ret}),alignMemory:(function(size,quantum){var ret=size=Math.ceil(size/(quantum?quantum:16))*(quantum?quantum:16);return ret}),makeBigInt:(function(low,high,unsigned){var ret=unsigned?+(low>>>0)+ +(high>>>0)*+4294967296:+(low>>>0)+ +(high|0)*+4294967296;return ret}),GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module["Runtime"]=Runtime;var __THREW__=0;var ABORT=false;var EXITSTATUS=0;var undef=0;var tempValue,tempInt,tempBigInt,tempInt2,tempBigInt2,tempPair,tempBigIntI,tempBigIntR,tempBigIntS,tempBigIntP,tempBigIntD,tempDouble,tempFloat;var tempI64,tempI64b;var tempRet0,tempRet1,tempRet2,tempRet3,tempRet4,tempRet5,tempRet6,tempRet7,tempRet8,tempRet9;function assert(condition,text){if(!condition){abort("Assertion failed: "+text)}}var globalScope=this;function getCFunc(ident){var func=Module["_"+ident];if(!func){try{func=eval("_"+ident)}catch(e){}}assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)");return func}var cwrap,ccall;((function(){var JSfuncs={"stackSave":(function(){Runtime.stackSave()}),"stackRestore":(function(){Runtime.stackRestore()}),"arrayToC":(function(arr){var ret=Runtime.stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}),"stringToC":(function(str){var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=Runtime.stackAlloc((str.length<<2)+1);writeStringToMemory(str,ret)}return ret})};var toC={"string":JSfuncs["stringToC"],"array":JSfuncs["arrayToC"]};ccall=function ccallFunc(ident,returnType,argTypes,args,opts){var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;i>0]=value;break;case"i8":HEAP8[ptr>>0]=value;break;case"i16":HEAP16[ptr>>1]=value;break;case"i32":HEAP32[ptr>>2]=value;break;case"i64":tempI64=[value>>>0,(tempDouble=value,+Math_abs(tempDouble)>=+1?tempDouble>+0?(Math_min(+Math_floor(tempDouble/+4294967296),+4294967295)|0)>>>0:~~+Math_ceil((tempDouble- +(~~tempDouble>>>0))/+4294967296)>>>0:0)],HEAP32[ptr>>2]=tempI64[0],HEAP32[ptr+4>>2]=tempI64[1];break;case"float":HEAPF32[ptr>>2]=value;break;case"double":HEAPF64[ptr>>3]=value;break;default:abort("invalid type for setValue: "+type)}}Module["setValue"]=setValue;function getValue(ptr,type,noSafe){type=type||"i8";if(type.charAt(type.length-1)==="*")type="i32";switch(type){case"i1":return HEAP8[ptr>>0];case"i8":return HEAP8[ptr>>0];case"i16":return HEAP16[ptr>>1];case"i32":return HEAP32[ptr>>2];case"i64":return HEAP32[ptr>>2];case"float":return HEAPF32[ptr>>2];case"double":return HEAPF64[ptr>>3];default:abort("invalid type for setValue: "+type)}return null}Module["getValue"]=getValue;var ALLOC_NORMAL=0;var ALLOC_STACK=1;var ALLOC_STATIC=2;var ALLOC_DYNAMIC=3;var ALLOC_NONE=4;Module["ALLOC_NORMAL"]=ALLOC_NORMAL;Module["ALLOC_STACK"]=ALLOC_STACK;Module["ALLOC_STATIC"]=ALLOC_STATIC;Module["ALLOC_DYNAMIC"]=ALLOC_DYNAMIC;Module["ALLOC_NONE"]=ALLOC_NONE;function allocate(slab,types,allocator,ptr){var zeroinit,size;if(typeof slab==="number"){zeroinit=true;size=slab}else{zeroinit=false;size=slab.length}var singleType=typeof types==="string"?types:null;var ret;if(allocator==ALLOC_NONE){ret=ptr}else{ret=[_malloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][allocator===undefined?ALLOC_STATIC:allocator](Math.max(size,singleType?1:types.length))}if(zeroinit){var ptr=ret,stop;assert((ret&3)==0);stop=ret+(size&~3);for(;ptr>2]=0}stop=ret+size;while(ptr>0]=0}return ret}if(singleType==="i8"){if(slab.subarray||slab.slice){HEAPU8.set(slab,ret)}else{HEAPU8.set(new Uint8Array(slab),ret)}return ret}var i=0,type,typeSize,previousType;while(i>0];hasUtf|=t;if(t==0&&!length)break;i++;if(length&&i==length)break}if(!length)length=i;var ret="";if(hasUtf<128){var MAX_CHUNK=1024;var curr;while(length>0){curr=String.fromCharCode.apply(String,HEAPU8.subarray(ptr,ptr+Math.min(length,MAX_CHUNK)));ret=ret?ret+curr:curr;ptr+=MAX_CHUNK;length-=MAX_CHUNK}return ret}return Module["UTF8ToString"](ptr)}Module["Pointer_stringify"]=Pointer_stringify;function AsciiToString(ptr){var str="";while(1){var ch=HEAP8[ptr++>>0];if(!ch)return str;str+=String.fromCharCode(ch)}}Module["AsciiToString"]=AsciiToString;function stringToAscii(str,outPtr){return writeAsciiToMemory(str,outPtr,false)}Module["stringToAscii"]=stringToAscii;function UTF8ArrayToString(u8Array,idx){var u0,u1,u2,u3,u4,u5;var str="";while(1){u0=u8Array[idx++];if(!u0)return str;if(!(u0&128)){str+=String.fromCharCode(u0);continue}u1=u8Array[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}u2=u8Array[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u3=u8Array[idx++]&63;if((u0&248)==240){u0=(u0&7)<<18|u1<<12|u2<<6|u3}else{u4=u8Array[idx++]&63;if((u0&252)==248){u0=(u0&3)<<24|u1<<18|u2<<12|u3<<6|u4}else{u5=u8Array[idx++]&63;u0=(u0&1)<<30|u1<<24|u2<<18|u3<<12|u4<<6|u5}}}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}Module["UTF8ArrayToString"]=UTF8ArrayToString;function UTF8ToString(ptr){return UTF8ArrayToString(HEAPU8,ptr)}Module["UTF8ToString"]=UTF8ToString;function stringToUTF8Array(str,outU8Array,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){if(outIdx>=endIdx)break;outU8Array[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;outU8Array[outIdx++]=192|u>>6;outU8Array[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;outU8Array[outIdx++]=224|u>>12;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=2097151){if(outIdx+3>=endIdx)break;outU8Array[outIdx++]=240|u>>18;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else if(u<=67108863){if(outIdx+4>=endIdx)break;outU8Array[outIdx++]=248|u>>24;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}else{if(outIdx+5>=endIdx)break;outU8Array[outIdx++]=252|u>>30;outU8Array[outIdx++]=128|u>>24&63;outU8Array[outIdx++]=128|u>>18&63;outU8Array[outIdx++]=128|u>>12&63;outU8Array[outIdx++]=128|u>>6&63;outU8Array[outIdx++]=128|u&63}}outU8Array[outIdx]=0;return outIdx-startIdx}Module["stringToUTF8Array"]=stringToUTF8Array;function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}Module["stringToUTF8"]=stringToUTF8;function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127){++len}else if(u<=2047){len+=2}else if(u<=65535){len+=3}else if(u<=2097151){len+=4}else if(u<=67108863){len+=5}else{len+=6}}return len}Module["lengthBytesUTF8"]=lengthBytesUTF8;function UTF16ToString(ptr){var i=0;var str="";while(1){var codeUnit=HEAP16[ptr+i*2>>1];if(codeUnit==0)return str;++i;str+=String.fromCharCode(codeUnit)}}Module["UTF16ToString"]=UTF16ToString;function stringToUTF16(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<2)return 0;maxBytesToWrite-=2;var startPtr=outPtr;var numCharsToWrite=maxBytesToWrite>1]=codeUnit;outPtr+=2}HEAP16[outPtr>>1]=0;return outPtr-startPtr}Module["stringToUTF16"]=stringToUTF16;function lengthBytesUTF16(str){return str.length*2}Module["lengthBytesUTF16"]=lengthBytesUTF16;function UTF32ToString(ptr){var i=0;var str="";while(1){var utf32=HEAP32[ptr+i*4>>2];if(utf32==0)return str;++i;if(utf32>=65536){var ch=utf32-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}else{str+=String.fromCharCode(utf32)}}}Module["UTF32ToString"]=UTF32ToString;function stringToUTF32(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=2147483647}if(maxBytesToWrite<4)return 0;var startPtr=outPtr;var endPtr=startPtr+maxBytesToWrite-4;for(var i=0;i=55296&&codeUnit<=57343){var trailSurrogate=str.charCodeAt(++i);codeUnit=65536+((codeUnit&1023)<<10)|trailSurrogate&1023}HEAP32[outPtr>>2]=codeUnit;outPtr+=4;if(outPtr+4>endPtr)break}HEAP32[outPtr>>2]=0;return outPtr-startPtr}Module["stringToUTF32"]=stringToUTF32;function lengthBytesUTF32(str){var len=0;for(var i=0;i=55296&&codeUnit<=57343)++i;len+=4}return len}Module["lengthBytesUTF32"]=lengthBytesUTF32;function demangle(func){var hasLibcxxabi=!!Module["___cxa_demangle"];if(hasLibcxxabi){try{var buf=_malloc(func.length);writeStringToMemory(func.substr(1),buf);var status=_malloc(4);var ret=Module["___cxa_demangle"](buf,0,0,status);if(getValue(status,"i32")===0&&ret){return Pointer_stringify(ret)}}catch(e){}finally{if(buf)_free(buf);if(status)_free(status);if(ret)_free(ret)}}var i=3;var basicTypes={"v":"void","b":"bool","c":"char","s":"short","i":"int","l":"long","f":"float","d":"double","w":"wchar_t","a":"signed char","h":"unsigned char","t":"unsigned short","j":"unsigned int","m":"unsigned long","x":"long long","y":"unsigned long long","z":"..."};var subs=[];var first=true;function dump(x){if(x)Module.print(x);Module.print(func);var pre="";for(var a=0;a"}else{ret=name}paramLoop:while(i0){var c=func[i++];if(c in basicTypes){list.push(basicTypes[c])}else{switch(c){case"P":list.push(parse(true,1,true)[0]+"*");break;case"R":list.push(parse(true,1,true)[0]+"&");break;case"L":{i++;var end=func.indexOf("E",i);var size=end-i;list.push(func.substr(i,size));i+=size+2;break};case"A":{var size=parseInt(func.substr(i));i+=size.toString().length;if(func[i]!=="_")throw"?";i++;list.push(parse(true,1,true)[0]+" ["+size+"]");break};case"E":break paramLoop;default:ret+="?"+c;break paramLoop}}}if(!allowVoid&&list.length===1&&list[0]==="void")list=[];if(rawList){if(ret){list.push(ret+"?")}return list}else{return ret+flushList()}}var parsed=func;try{if(func=="Object._main"||func=="_main"){return"main()"}if(typeof func==="number")func=Pointer_stringify(func);if(func[0]!=="_")return func;if(func[1]!=="_")return func;if(func[2]!=="Z")return func;switch(func[3]){case"n":return"operator new()";case"d":return"operator delete()"}parsed=parse()}catch(e){parsed+="?"}if(parsed.indexOf("?")>=0&&!hasLibcxxabi){Runtime.warnOnce("warning: a problem occurred in builtin C++ name demangling; build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling")}return parsed}function demangleAll(text){return text.replace(/__Z[\w\d_]+/g,(function(x){var y=demangle(x);return x===y?x:x+" ["+y+"]"}))}function jsStackTrace(){var err=new Error;if(!err.stack){try{throw new Error(0)}catch(e){err=e}if(!err.stack){return"(no stack trace available)"}}return err.stack.toString()}function stackTrace(){return demangleAll(jsStackTrace())}Module["stackTrace"]=stackTrace;var PAGE_SIZE=4096;function alignMemoryPage(x){if(x%4096>0){x+=4096-x%4096}return x}var HEAP;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var STATIC_BASE=0,STATICTOP=0,staticSealed=false;var STACK_BASE=0,STACKTOP=0,STACK_MAX=0;var DYNAMIC_BASE=0,DYNAMICTOP=0;function enlargeMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.")}var TOTAL_STACK=Module["TOTAL_STACK"]||5242880;var TOTAL_MEMORY=Module["TOTAL_MEMORY"]||16777216;var totalMemory=64*1024;while(totalMemory0){var callback=callbacks.shift();if(typeof callback=="function"){callback();continue}var func=callback.func;if(typeof func==="number"){if(callback.arg===undefined){Runtime.dynCall("v",func)}else{Runtime.dynCall("vi",func,[callback.arg])}}else{func(callback.arg===undefined?null:callback.arg)}}}var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var runtimeInitialized=false;var runtimeExited=false;function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){if(runtimeInitialized)return;runtimeInitialized=true;callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__);runtimeExited=true}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}Module["addOnPreRun"]=Module.addOnPreRun=addOnPreRun;function addOnInit(cb){__ATINIT__.unshift(cb)}Module["addOnInit"]=Module.addOnInit=addOnInit;function addOnPreMain(cb){__ATMAIN__.unshift(cb)}Module["addOnPreMain"]=Module.addOnPreMain=addOnPreMain;function addOnExit(cb){__ATEXIT__.unshift(cb)}Module["addOnExit"]=Module.addOnExit=addOnExit;function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}Module["addOnPostRun"]=Module.addOnPostRun=addOnPostRun;function intArrayFromString(stringy,dontAddNull,length){var len=length>0?length:lengthBytesUTF8(stringy)+1;var u8array=new Array(len);var numBytesWritten=stringToUTF8Array(stringy,u8array,0,u8array.length);if(dontAddNull)u8array.length=numBytesWritten;return u8array}Module["intArrayFromString"]=intArrayFromString;function intArrayToString(array){var ret=[];for(var i=0;i255){chr&=255}ret.push(String.fromCharCode(chr))}return ret.join("")}Module["intArrayToString"]=intArrayToString;function writeStringToMemory(string,buffer,dontAddNull){var array=intArrayFromString(string,dontAddNull);var i=0;while(i>0]=chr;i=i+1}}Module["writeStringToMemory"]=writeStringToMemory;function writeArrayToMemory(array,buffer){for(var i=0;i>0]=array[i]}}Module["writeArrayToMemory"]=writeArrayToMemory;function writeAsciiToMemory(str,buffer,dontAddNull){for(var i=0;i>0]=str.charCodeAt(i)}if(!dontAddNull)HEAP8[buffer>>0]=0}Module["writeAsciiToMemory"]=writeAsciiToMemory;function unSign(value,bits,ignore){if(value>=0){return value}return bits<=32?2*Math.abs(1<=half&&(bits<=32||value>half)){value=-2*half+value}return value}if(!Math["imul"]||Math["imul"](4294967295,5)!==-5)Math["imul"]=function imul(a,b){var ah=a>>>16;var al=a&65535;var bh=b>>>16;var bl=b&65535;return al*bl+(ah*bl+al*bh<<16)|0};Math.imul=Math["imul"];if(!Math["clz32"])Math["clz32"]=(function(x){x=x>>>0;for(var i=0;i<32;i++){if(x&1<<31-i)return i}return 32});Math.clz32=Math["clz32"];var Math_abs=Math.abs;var Math_cos=Math.cos;var Math_sin=Math.sin;var Math_tan=Math.tan;var Math_acos=Math.acos;var Math_asin=Math.asin;var Math_atan=Math.atan;var Math_atan2=Math.atan2;var Math_exp=Math.exp;var Math_log=Math.log;var Math_sqrt=Math.sqrt;var Math_ceil=Math.ceil;var Math_floor=Math.floor;var Math_pow=Math.pow;var Math_imul=Math.imul;var Math_fround=Math.fround;var Math_min=Math.min;var Math_clz32=Math.clz32;var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}Module["addRunDependency"]=addRunDependency;function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}Module["removeRunDependency"]=removeRunDependency;Module["preloadedImages"]={};Module["preloadedAudios"]={};var memoryInitializer=null;var ASM_CONSTS=[];STATIC_BASE=8;STATICTOP=STATIC_BASE+96992;__ATINIT__.push();memoryInitializer="/../encoders/Mp3Encoder.min.js.mem";var tempDoublePtr=Runtime.alignMemory(allocate(12,"i8",ALLOC_STATIC),8);assert(tempDoublePtr%8==0);function copyTempFloat(ptr){HEAP8[tempDoublePtr]=HEAP8[ptr];HEAP8[tempDoublePtr+1]=HEAP8[ptr+1];HEAP8[tempDoublePtr+2]=HEAP8[ptr+2];HEAP8[tempDoublePtr+3]=HEAP8[ptr+3]}function copyTempDouble(ptr){HEAP8[tempDoublePtr]=HEAP8[ptr];HEAP8[tempDoublePtr+1]=HEAP8[ptr+1];HEAP8[tempDoublePtr+2]=HEAP8[ptr+2];HEAP8[tempDoublePtr+3]=HEAP8[ptr+3];HEAP8[tempDoublePtr+4]=HEAP8[ptr+4];HEAP8[tempDoublePtr+5]=HEAP8[ptr+5];HEAP8[tempDoublePtr+6]=HEAP8[ptr+6];HEAP8[tempDoublePtr+7]=HEAP8[ptr+7]}function _InitGainAnalysis(){Module["printErr"]("missing function: InitGainAnalysis");abort(-1)}function _AnalyzeSamples(){Module["printErr"]("missing function: AnalyzeSamples");abort(-1)}Module["_i64Subtract"]=_i64Subtract;var _fabsf=Math_abs;var _floorf=Math_floor;Module["_memset"]=_memset;var _BDtoILow=true;var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};var ERRNO_MESSAGES={0:"Success",1:"Not super-user",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"I/O error",6:"No such device or address",7:"Arg list too long",8:"Exec format error",9:"Bad file number",10:"No children",11:"No more processes",12:"Not enough core",13:"Permission denied",14:"Bad address",15:"Block device required",16:"Mount device busy",17:"File exists",18:"Cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Not a typewriter",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read only file system",31:"Too many links",32:"Broken pipe",33:"Math arg out of domain of func",34:"Math result not representable",35:"File locking deadlock error",36:"File or path name too long",37:"No record locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many symbolic links",42:"No message of desired type",43:"Identifier removed",44:"Channel number out of range",45:"Level 2 not synchronized",46:"Level 3 halted",47:"Level 3 reset",48:"Link number out of range",49:"Protocol driver not attached",50:"No CSI structure available",51:"Level 2 halted",52:"Invalid exchange",53:"Invalid request descriptor",54:"Exchange full",55:"No anode",56:"Invalid request code",57:"Invalid slot",59:"Bad font file fmt",60:"Device not a stream",61:"No data (for no delay io)",62:"Timer expired",63:"Out of streams resources",64:"Machine is not on the network",65:"Package not installed",66:"The object is remote",67:"The link has been severed",68:"Advertise error",69:"Srmount error",70:"Communication error on send",71:"Protocol error",72:"Multihop attempted",73:"Cross mount point (not really error)",74:"Trying to read unreadable message",75:"Value too large for defined data type",76:"Given log. name not unique",77:"f.d. invalid for this operation",78:"Remote address changed",79:"Can access a needed shared lib",80:"Accessing a corrupted shared lib",81:".lib section in a.out corrupted",82:"Attempting to link in too many libs",83:"Attempting to exec a shared library",84:"Illegal byte sequence",86:"Streams pipe error",87:"Too many users",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Unknown protocol",94:"Socket type not supported",95:"Not supported",96:"Protocol family not supported",97:"Address family not supported by protocol family",98:"Address already in use",99:"Address not available",100:"Network interface is not configured",101:"Network is unreachable",102:"Connection reset by network",103:"Connection aborted",104:"Connection reset by peer",105:"No buffer space available",106:"Socket is already connected",107:"Socket is not connected",108:"Can't send after socket shutdown",109:"Too many references",110:"Connection timed out",111:"Connection refused",112:"Host is down",113:"Host is unreachable",114:"Socket already connected",115:"Connection already in progress",116:"Stale file handle",122:"Quota exceeded",123:"No medium (in tape drive)",125:"Operation canceled",130:"Previous owner died",131:"State not recoverable"};var ___errno_state=0;function ___setErrNo(value){HEAP32[___errno_state>>2]=value;return value}function _strerror_r(errnum,strerrbuf,buflen){if(errnum in ERRNO_MESSAGES){if(ERRNO_MESSAGES[errnum].length>buflen-1){return ___setErrNo(ERRNO_CODES.ERANGE)}else{var msg=ERRNO_MESSAGES[errnum];writeAsciiToMemory(msg,strerrbuf);return 0}}else{return ___setErrNo(ERRNO_CODES.EINVAL)}}function _strerror(errnum){if(!_strerror.buffer)_strerror.buffer=_malloc(256);_strerror_r(errnum,_strerror.buffer,256);return _strerror.buffer}function _VBR_encode_frame(){Module["printErr"]("missing function: VBR_encode_frame");abort(-1)}function _abort(){Module["abort"]()}function _init_xrpow_core_sse(){Module["printErr"]("missing function: init_xrpow_core_sse");abort(-1)}var PATH={splitPath:(function(filename){var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return splitPathRe.exec(filename).slice(1)}),normalizeArray:(function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}),normalize:(function(path){var isAbsolute=path.charAt(0)==="/",trailingSlash=path.substr(-1)==="/";path=PATH.normalizeArray(path.split("/").filter((function(p){return!!p})),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path}),dirname:(function(path){var result=PATH.splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir}),basename:(function(path){if(path==="/")return"/";var lastSlash=path.lastIndexOf("/");if(lastSlash===-1)return path;return path.substr(lastSlash+1)}),extname:(function(path){return PATH.splitPath(path)[3]}),join:(function(){var paths=Array.prototype.slice.call(arguments,0);return PATH.normalize(paths.join("/"))}),join2:(function(l,r){return PATH.normalize(l+"/"+r)}),resolve:(function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:FS.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){return""}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=PATH.normalizeArray(resolvedPath.split("/").filter((function(p){return!!p})),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."}),relative:(function(from,to){from=PATH.resolve(from).substr(1);to=PATH.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i0){result=buf.slice(0,bytesRead).toString("utf-8")}else{result=null}}else if(typeof window!="undefined"&&typeof window.prompt=="function"){result=window.prompt("Input: ");if(result!==null){result+="\n"}}else if(typeof readline=="function"){result=readline();if(result!==null){result+="\n"}}if(!result){return null}tty.input=intArrayFromString(result,true)}return tty.input.shift()}),put_char:(function(tty,val){if(val===null||val===10){Module["print"](UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}}),flush:(function(tty){if(tty.output&&tty.output.length>0){Module["print"](UTF8ArrayToString(tty.output,0));tty.output=[]}})},default_tty1_ops:{put_char:(function(tty,val){if(val===null||val===10){Module["printErr"](UTF8ArrayToString(tty.output,0));tty.output=[]}else{if(val!=0)tty.output.push(val)}}),flush:(function(tty){if(tty.output&&tty.output.length>0){Module["printErr"](UTF8ArrayToString(tty.output,0));tty.output=[]}})}};var MEMFS={ops_table:null,mount:(function(mount){return MEMFS.createNode(null,"/",16384|511,0)}),createNode:(function(parent,name,mode,dev){if(FS.isBlkdev(mode)||FS.isFIFO(mode)){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(!MEMFS.ops_table){MEMFS.ops_table={dir:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,lookup:MEMFS.node_ops.lookup,mknod:MEMFS.node_ops.mknod,rename:MEMFS.node_ops.rename,unlink:MEMFS.node_ops.unlink,rmdir:MEMFS.node_ops.rmdir,readdir:MEMFS.node_ops.readdir,symlink:MEMFS.node_ops.symlink},stream:{llseek:MEMFS.stream_ops.llseek}},file:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:{llseek:MEMFS.stream_ops.llseek,read:MEMFS.stream_ops.read,write:MEMFS.stream_ops.write,allocate:MEMFS.stream_ops.allocate,mmap:MEMFS.stream_ops.mmap,msync:MEMFS.stream_ops.msync}},link:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr,readlink:MEMFS.node_ops.readlink},stream:{}},chrdev:{node:{getattr:MEMFS.node_ops.getattr,setattr:MEMFS.node_ops.setattr},stream:FS.chrdev_stream_ops}}}var node=FS.createNode(parent,name,mode,dev);if(FS.isDir(node.mode)){node.node_ops=MEMFS.ops_table.dir.node;node.stream_ops=MEMFS.ops_table.dir.stream;node.contents={}}else if(FS.isFile(node.mode)){node.node_ops=MEMFS.ops_table.file.node;node.stream_ops=MEMFS.ops_table.file.stream;node.usedBytes=0;node.contents=null}else if(FS.isLink(node.mode)){node.node_ops=MEMFS.ops_table.link.node;node.stream_ops=MEMFS.ops_table.link.stream}else if(FS.isChrdev(node.mode)){node.node_ops=MEMFS.ops_table.chrdev.node;node.stream_ops=MEMFS.ops_table.chrdev.stream}node.timestamp=Date.now();if(parent){parent.contents[name]=node}return node}),getFileDataAsRegularArray:(function(node){if(node.contents&&node.contents.subarray){var arr=[];for(var i=0;inode.contents.length){node.contents=MEMFS.getFileDataAsRegularArray(node);node.usedBytes=node.contents.length}if(!node.contents||node.contents.subarray){var prevCapacity=node.contents?node.contents.buffer.byteLength:0;if(prevCapacity>=newCapacity)return;var CAPACITY_DOUBLING_MAX=1024*1024;newCapacity=Math.max(newCapacity,prevCapacity*(prevCapacity0)node.contents.set(oldContents.subarray(0,node.usedBytes),0);return}if(!node.contents&&newCapacity>0)node.contents=[];while(node.contents.lengthnewSize)node.contents.length=newSize;else while(node.contents.length=stream.node.usedBytes)return 0;var size=Math.min(stream.node.usedBytes-position,length);assert(size>=0);if(size>8&&contents.subarray){buffer.set(contents.subarray(position,position+size),offset)}else{for(var i=0;i0||position+lengthe2.timestamp){create.push(key);total++}}));var remove=[];Object.keys(dst.entries).forEach((function(key){var e=dst.entries[key];var e2=src.entries[key];if(!e2){remove.push(key);total++}}));if(!total){return callback(null)}var errored=false;var completed=0;var db=src.type==="remote"?src.db:dst.db;var transaction=db.transaction([IDBFS.DB_STORE_NAME],"readwrite");var store=transaction.objectStore(IDBFS.DB_STORE_NAME);function done(err){if(err){if(!done.errored){done.errored=true;return callback(err)}return}if(++completed>=total){return callback(null)}}transaction.onerror=(function(e){done(this.error);e.preventDefault()});create.sort().forEach((function(path){if(dst.type==="local"){IDBFS.loadRemoteEntry(store,path,(function(err,entry){if(err)return done(err);IDBFS.storeLocalEntry(path,entry,done)}))}else{IDBFS.loadLocalEntry(path,(function(err,entry){if(err)return done(err);IDBFS.storeRemoteEntry(store,path,entry,done)}))}}));remove.sort().reverse().forEach((function(path){if(dst.type==="local"){IDBFS.removeLocalEntry(path,done)}else{IDBFS.removeRemoteEntry(store,path,done)}}))})};var NODEFS={isWindows:false,staticInit:(function(){NODEFS.isWindows=!!process.platform.match(/^win/)}),mount:(function(mount){assert(ENVIRONMENT_IS_NODE);return NODEFS.createNode(null,"/",NODEFS.getMode(mount.opts.root),0)}),createNode:(function(parent,name,mode,dev){if(!FS.isDir(mode)&&!FS.isFile(mode)&&!FS.isLink(mode)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node=FS.createNode(parent,name,mode);node.node_ops=NODEFS.node_ops;node.stream_ops=NODEFS.stream_ops;return node}),getMode:(function(path){var stat;try{stat=fs.lstatSync(path);if(NODEFS.isWindows){stat.mode=stat.mode|(stat.mode&146)>>1}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}return stat.mode}),realPath:(function(node){var parts=[];while(node.parent!==node){parts.push(node.name);node=node.parent}parts.push(node.mount.opts.root);parts.reverse();return PATH.join.apply(null,parts)}),flagsToPermissionStringMap:{0:"r",1:"r+",2:"r+",64:"r",65:"r+",66:"r+",129:"rx+",193:"rx+",514:"w+",577:"w",578:"w+",705:"wx",706:"wx+",1024:"a",1025:"a",1026:"a+",1089:"a",1090:"a+",1153:"ax",1154:"ax+",1217:"ax",1218:"ax+",4096:"rs",4098:"rs+"},flagsToPermissionString:(function(flags){if(flags in NODEFS.flagsToPermissionStringMap){return NODEFS.flagsToPermissionStringMap[flags]}else{return flags}}),node_ops:{getattr:(function(node){var path=NODEFS.realPath(node);var stat;try{stat=fs.lstatSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}if(NODEFS.isWindows&&!stat.blksize){stat.blksize=4096}if(NODEFS.isWindows&&!stat.blocks){stat.blocks=(stat.size+stat.blksize-1)/stat.blksize|0}return{dev:stat.dev,ino:stat.ino,mode:stat.mode,nlink:stat.nlink,uid:stat.uid,gid:stat.gid,rdev:stat.rdev,size:stat.size,atime:stat.atime,mtime:stat.mtime,ctime:stat.ctime,blksize:stat.blksize,blocks:stat.blocks}}),setattr:(function(node,attr){var path=NODEFS.realPath(node);try{if(attr.mode!==undefined){fs.chmodSync(path,attr.mode);node.mode=attr.mode}if(attr.timestamp!==undefined){var date=new Date(attr.timestamp);fs.utimesSync(path,date,date)}if(attr.size!==undefined){fs.truncateSync(path,attr.size)}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),lookup:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);var mode=NODEFS.getMode(path);return NODEFS.createNode(parent,name,mode)}),mknod:(function(parent,name,mode,dev){var node=NODEFS.createNode(parent,name,mode,dev);var path=NODEFS.realPath(node);try{if(FS.isDir(node.mode)){fs.mkdirSync(path,node.mode)}else{fs.writeFileSync(path,"",{mode:node.mode})}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}return node}),rename:(function(oldNode,newDir,newName){var oldPath=NODEFS.realPath(oldNode);var newPath=PATH.join2(NODEFS.realPath(newDir),newName);try{fs.renameSync(oldPath,newPath)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),unlink:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);try{fs.unlinkSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),rmdir:(function(parent,name){var path=PATH.join2(NODEFS.realPath(parent),name);try{fs.rmdirSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),readdir:(function(node){var path=NODEFS.realPath(node);try{return fs.readdirSync(path)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),symlink:(function(parent,newName,oldPath){var newPath=PATH.join2(NODEFS.realPath(parent),newName);try{fs.symlinkSync(oldPath,newPath)}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),readlink:(function(node){var path=NODEFS.realPath(node);try{path=fs.readlinkSync(path);path=NODEJS_PATH.relative(NODEJS_PATH.resolve(node.mount.opts.root),path);return path}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}})},stream_ops:{open:(function(stream){var path=NODEFS.realPath(stream.node);try{if(FS.isFile(stream.node.mode)){stream.nfd=fs.openSync(path,NODEFS.flagsToPermissionString(stream.flags))}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),close:(function(stream){try{if(FS.isFile(stream.node.mode)&&stream.nfd){fs.closeSync(stream.nfd)}}catch(e){if(!e.code)throw e;throw new FS.ErrnoError(ERRNO_CODES[e.code])}}),read:(function(stream,buffer,offset,length,position){if(length===0)return 0;var nbuffer=new Buffer(length);var res;try{res=fs.readSync(stream.nfd,nbuffer,0,length,position)}catch(e){throw new FS.ErrnoError(ERRNO_CODES[e.code])}if(res>0){for(var i=0;i8){throw new FS.ErrnoError(ERRNO_CODES.ELOOP)}var parts=PATH.normalizeArray(path.split("/").filter((function(p){return!!p})),false);var current=FS.root;var current_path="/";for(var i=0;i40){throw new FS.ErrnoError(ERRNO_CODES.ELOOP)}}}}return{path:current_path,node:current}}),getPath:(function(node){var path;while(true){if(FS.isRoot(node)){var mount=node.mount.mountpoint;if(!path)return mount;return mount[mount.length-1]!=="/"?mount+"/"+path:mount+path}path=path?node.name+"/"+path:node.name;node=node.parent}}),hashName:(function(parentid,name){var hash=0;for(var i=0;i>>0)%FS.nameTable.length}),hashAddNode:(function(node){var hash=FS.hashName(node.parent.id,node.name);node.name_next=FS.nameTable[hash];FS.nameTable[hash]=node}),hashRemoveNode:(function(node){var hash=FS.hashName(node.parent.id,node.name);if(FS.nameTable[hash]===node){FS.nameTable[hash]=node.name_next}else{var current=FS.nameTable[hash];while(current){if(current.name_next===node){current.name_next=node.name_next;break}current=current.name_next}}}),lookupNode:(function(parent,name){var err=FS.mayLookup(parent);if(err){throw new FS.ErrnoError(err,parent)}var hash=FS.hashName(parent.id,name);for(var node=FS.nameTable[hash];node;node=node.name_next){var nodeName=node.name;if(node.parent.id===parent.id&&nodeName===name){return node}}return FS.lookup(parent,name)}),createNode:(function(parent,name,mode,rdev){if(!FS.FSNode){FS.FSNode=(function(parent,name,mode,rdev){if(!parent){parent=this}this.parent=parent;this.mount=parent.mount;this.mounted=null;this.id=FS.nextInode++;this.name=name;this.mode=mode;this.node_ops={};this.stream_ops={};this.rdev=rdev});FS.FSNode.prototype={};var readMode=292|73;var writeMode=146;Object.defineProperties(FS.FSNode.prototype,{read:{get:(function(){return(this.mode&readMode)===readMode}),set:(function(val){val?this.mode|=readMode:this.mode&=~readMode})},write:{get:(function(){return(this.mode&writeMode)===writeMode}),set:(function(val){val?this.mode|=writeMode:this.mode&=~writeMode})},isFolder:{get:(function(){return FS.isDir(this.mode)})},isDevice:{get:(function(){return FS.isChrdev(this.mode)})}})}var node=new FS.FSNode(parent,name,mode,rdev);FS.hashAddNode(node);return node}),destroyNode:(function(node){FS.hashRemoveNode(node)}),isRoot:(function(node){return node===node.parent}),isMountpoint:(function(node){return!!node.mounted}),isFile:(function(mode){return(mode&61440)===32768}),isDir:(function(mode){return(mode&61440)===16384}),isLink:(function(mode){return(mode&61440)===40960}),isChrdev:(function(mode){return(mode&61440)===8192}),isBlkdev:(function(mode){return(mode&61440)===24576}),isFIFO:(function(mode){return(mode&61440)===4096}),isSocket:(function(mode){return(mode&49152)===49152}),flagModes:{"r":0,"rs":1052672,"r+":2,"w":577,"wx":705,"xw":705,"w+":578,"wx+":706,"xw+":706,"a":1089,"ax":1217,"xa":1217,"a+":1090,"ax+":1218,"xa+":1218},modeStringToFlags:(function(str){var flags=FS.flagModes[str];if(typeof flags==="undefined"){throw new Error("Unknown file open mode: "+str)}return flags}),flagsToPermissionString:(function(flag){var accmode=flag&2097155;var perms=["r","w","rw"][accmode];if(flag&512){perms+="w"}return perms}),nodePermissions:(function(node,perms){if(FS.ignorePermissions){return 0}if(perms.indexOf("r")!==-1&&!(node.mode&292)){return ERRNO_CODES.EACCES}else if(perms.indexOf("w")!==-1&&!(node.mode&146)){return ERRNO_CODES.EACCES}else if(perms.indexOf("x")!==-1&&!(node.mode&73)){return ERRNO_CODES.EACCES}return 0}),mayLookup:(function(dir){var err=FS.nodePermissions(dir,"x");if(err)return err;if(!dir.node_ops.lookup)return ERRNO_CODES.EACCES;return 0}),mayCreate:(function(dir,name){try{var node=FS.lookupNode(dir,name);return ERRNO_CODES.EEXIST}catch(e){}return FS.nodePermissions(dir,"wx")}),mayDelete:(function(dir,name,isdir){var node;try{node=FS.lookupNode(dir,name)}catch(e){return e.errno}var err=FS.nodePermissions(dir,"wx");if(err){return err}if(isdir){if(!FS.isDir(node.mode)){return ERRNO_CODES.ENOTDIR}if(FS.isRoot(node)||FS.getPath(node)===FS.cwd()){return ERRNO_CODES.EBUSY}}else{if(FS.isDir(node.mode)){return ERRNO_CODES.EISDIR}}return 0}),mayOpen:(function(node,flags){if(!node){return ERRNO_CODES.ENOENT}if(FS.isLink(node.mode)){return ERRNO_CODES.ELOOP}else if(FS.isDir(node.mode)){if((flags&2097155)!==0||flags&512){return ERRNO_CODES.EISDIR}}return FS.nodePermissions(node,FS.flagsToPermissionString(flags))}),MAX_OPEN_FDS:4096,nextfd:(function(fd_start,fd_end){fd_start=fd_start||0;fd_end=fd_end||FS.MAX_OPEN_FDS;for(var fd=fd_start;fd<=fd_end;fd++){if(!FS.streams[fd]){return fd}}throw new FS.ErrnoError(ERRNO_CODES.EMFILE)}),getStream:(function(fd){return FS.streams[fd]}),createStream:(function(stream,fd_start,fd_end){if(!FS.FSStream){FS.FSStream=(function(){});FS.FSStream.prototype={};Object.defineProperties(FS.FSStream.prototype,{object:{get:(function(){return this.node}),set:(function(val){this.node=val})},isRead:{get:(function(){return(this.flags&2097155)!==1})},isWrite:{get:(function(){return(this.flags&2097155)!==0})},isAppend:{get:(function(){return this.flags&1024})}})}var newStream=new FS.FSStream;for(var p in stream){newStream[p]=stream[p]}stream=newStream;var fd=FS.nextfd(fd_start,fd_end);stream.fd=fd;FS.streams[fd]=stream;return stream}),closeStream:(function(fd){FS.streams[fd]=null}),getStreamFromPtr:(function(ptr){return FS.streams[ptr-1]}),getPtrForStream:(function(stream){return stream?stream.fd+1:0}),chrdev_stream_ops:{open:(function(stream){var device=FS.getDevice(stream.node.rdev);stream.stream_ops=device.stream_ops;if(stream.stream_ops.open){stream.stream_ops.open(stream)}}),llseek:(function(){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)})},major:(function(dev){return dev>>8}),minor:(function(dev){return dev&255}),makedev:(function(ma,mi){return ma<<8|mi}),registerDevice:(function(dev,ops){FS.devices[dev]={stream_ops:ops}}),getDevice:(function(dev){return FS.devices[dev]}),getMounts:(function(mount){var mounts=[];var check=[mount];while(check.length){var m=check.pop();mounts.push(m);check.push.apply(check,m.mounts)}return mounts}),syncfs:(function(populate,callback){if(typeof populate==="function"){callback=populate;populate=false}var mounts=FS.getMounts(FS.root.mount);var completed=0;function done(err){if(err){if(!done.errored){done.errored=true;return callback(err)}return}if(++completed>=mounts.length){callback(null)}}mounts.forEach((function(mount){if(!mount.type.syncfs){return done(null)}mount.type.syncfs(mount,populate,done)}))}),mount:(function(type,opts,mountpoint){var root=mountpoint==="/";var pseudo=!mountpoint;var node;if(root&&FS.root){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}else if(!root&&!pseudo){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});mountpoint=lookup.path;node=lookup.node;if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}}var mount={type:type,opts:opts,mountpoint:mountpoint,mounts:[]};var mountRoot=type.mount(mount);mountRoot.mount=mount;mount.root=mountRoot;if(root){FS.root=mountRoot}else if(node){node.mounted=mount;if(node.mount){node.mount.mounts.push(mount)}}return mountRoot}),unmount:(function(mountpoint){var lookup=FS.lookupPath(mountpoint,{follow_mount:false});if(!FS.isMountpoint(lookup.node)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node=lookup.node;var mount=node.mounted;var mounts=FS.getMounts(mount);Object.keys(FS.nameTable).forEach((function(hash){var current=FS.nameTable[hash];while(current){var next=current.name_next;if(mounts.indexOf(current.mount)!==-1){FS.destroyNode(current)}current=next}}));node.mounted=null;var idx=node.mount.mounts.indexOf(mount);assert(idx!==-1);node.mount.mounts.splice(idx,1)}),lookup:(function(parent,name){return parent.node_ops.lookup(parent,name)}),mknod:(function(path,mode,dev){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);if(!name||name==="."||name===".."){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var err=FS.mayCreate(parent,name);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.mknod){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return parent.node_ops.mknod(parent,name,mode,dev)}),create:(function(path,mode){mode=mode!==undefined?mode:438;mode&=4095;mode|=32768;return FS.mknod(path,mode,0)}),mkdir:(function(path,mode){mode=mode!==undefined?mode:511;mode&=511|512;mode|=16384;return FS.mknod(path,mode,0)}),mkdev:(function(path,mode,dev){if(typeof dev==="undefined"){dev=mode;mode=438}mode|=8192;return FS.mknod(path,mode,dev)}),symlink:(function(oldpath,newpath){if(!PATH.resolve(oldpath)){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}var lookup=FS.lookupPath(newpath,{parent:true});var parent=lookup.node;if(!parent){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}var newname=PATH.basename(newpath);var err=FS.mayCreate(parent,newname);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.symlink){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return parent.node_ops.symlink(parent,newname,oldpath)}),rename:(function(old_path,new_path){var old_dirname=PATH.dirname(old_path);var new_dirname=PATH.dirname(new_path);var old_name=PATH.basename(old_path);var new_name=PATH.basename(new_path);var lookup,old_dir,new_dir;try{lookup=FS.lookupPath(old_path,{parent:true});old_dir=lookup.node;lookup=FS.lookupPath(new_path,{parent:true});new_dir=lookup.node}catch(e){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(!old_dir||!new_dir)throw new FS.ErrnoError(ERRNO_CODES.ENOENT);if(old_dir.mount!==new_dir.mount){throw new FS.ErrnoError(ERRNO_CODES.EXDEV)}var old_node=FS.lookupNode(old_dir,old_name);var relative=PATH.relative(old_path,new_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}relative=PATH.relative(new_path,old_dirname);if(relative.charAt(0)!=="."){throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY)}var new_node;try{new_node=FS.lookupNode(new_dir,new_name)}catch(e){}if(old_node===new_node){return}var isdir=FS.isDir(old_node.mode);var err=FS.mayDelete(old_dir,old_name,isdir);if(err){throw new FS.ErrnoError(err)}err=new_node?FS.mayDelete(new_dir,new_name,isdir):FS.mayCreate(new_dir,new_name);if(err){throw new FS.ErrnoError(err)}if(!old_dir.node_ops.rename){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(old_node)||new_node&&FS.isMountpoint(new_node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}if(new_dir!==old_dir){err=FS.nodePermissions(old_dir,"w");if(err){throw new FS.ErrnoError(err)}}try{if(FS.trackingDelegate["willMovePath"]){FS.trackingDelegate["willMovePath"](old_path,new_path)}}catch(e){console.log("FS.trackingDelegate['willMovePath']('"+old_path+"', '"+new_path+"') threw an exception: "+e.message)}FS.hashRemoveNode(old_node);try{old_dir.node_ops.rename(old_node,new_dir,new_name)}catch(e){throw e}finally{FS.hashAddNode(old_node)}try{if(FS.trackingDelegate["onMovePath"])FS.trackingDelegate["onMovePath"](old_path,new_path)}catch(e){console.log("FS.trackingDelegate['onMovePath']('"+old_path+"', '"+new_path+"') threw an exception: "+e.message)}}),rmdir:(function(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var err=FS.mayDelete(parent,name,true);if(err){throw new FS.ErrnoError(err)}if(!parent.node_ops.rmdir){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}try{if(FS.trackingDelegate["willDeletePath"]){FS.trackingDelegate["willDeletePath"](path)}}catch(e){console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: "+e.message)}parent.node_ops.rmdir(parent,name);FS.destroyNode(node);try{if(FS.trackingDelegate["onDeletePath"])FS.trackingDelegate["onDeletePath"](path)}catch(e){console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: "+e.message)}}),readdir:(function(path){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;if(!node.node_ops.readdir){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}return node.node_ops.readdir(node)}),unlink:(function(path){var lookup=FS.lookupPath(path,{parent:true});var parent=lookup.node;var name=PATH.basename(path);var node=FS.lookupNode(parent,name);var err=FS.mayDelete(parent,name,false);if(err){if(err===ERRNO_CODES.EISDIR)err=ERRNO_CODES.EPERM;throw new FS.ErrnoError(err)}if(!parent.node_ops.unlink){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isMountpoint(node)){throw new FS.ErrnoError(ERRNO_CODES.EBUSY)}try{if(FS.trackingDelegate["willDeletePath"]){FS.trackingDelegate["willDeletePath"](path)}}catch(e){console.log("FS.trackingDelegate['willDeletePath']('"+path+"') threw an exception: "+e.message)}parent.node_ops.unlink(parent,name);FS.destroyNode(node);try{if(FS.trackingDelegate["onDeletePath"])FS.trackingDelegate["onDeletePath"](path)}catch(e){console.log("FS.trackingDelegate['onDeletePath']('"+path+"') threw an exception: "+e.message)}}),readlink:(function(path){var lookup=FS.lookupPath(path);var link=lookup.node;if(!link){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(!link.node_ops.readlink){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}return PATH.resolve(FS.getPath(lookup.node.parent),link.node_ops.readlink(link))}),stat:(function(path,dontFollow){var lookup=FS.lookupPath(path,{follow:!dontFollow});var node=lookup.node;if(!node){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(!node.node_ops.getattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}return node.node_ops.getattr(node)}),lstat:(function(path){return FS.stat(path,true)}),chmod:(function(path,mode,dontFollow){var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}node.node_ops.setattr(node,{mode:mode&4095|node.mode&~4095,timestamp:Date.now()})}),lchmod:(function(path,mode){FS.chmod(path,mode,true)}),fchmod:(function(fd,mode){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}FS.chmod(stream.node,mode)}),chown:(function(path,uid,gid,dontFollow){var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:!dontFollow});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}node.node_ops.setattr(node,{timestamp:Date.now()})}),lchown:(function(path,uid,gid){FS.chown(path,uid,gid,true)}),fchown:(function(fd,uid,gid){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}FS.chown(stream.node,uid,gid)}),truncate:(function(path,len){if(len<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var node;if(typeof path==="string"){var lookup=FS.lookupPath(path,{follow:true});node=lookup.node}else{node=path}if(!node.node_ops.setattr){throw new FS.ErrnoError(ERRNO_CODES.EPERM)}if(FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!FS.isFile(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var err=FS.nodePermissions(node,"w");if(err){throw new FS.ErrnoError(err)}node.node_ops.setattr(node,{size:len,timestamp:Date.now()})}),ftruncate:(function(fd,len){var stream=FS.getStream(fd);if(!stream){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}FS.truncate(stream.node,len)}),utime:(function(path,atime,mtime){var lookup=FS.lookupPath(path,{follow:true});var node=lookup.node;node.node_ops.setattr(node,{timestamp:Math.max(atime,mtime)})}),open:(function(path,flags,mode,fd_start,fd_end){if(path===""){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}flags=typeof flags==="string"?FS.modeStringToFlags(flags):flags;mode=typeof mode==="undefined"?438:mode;if(flags&64){mode=mode&4095|32768}else{mode=0}var node;if(typeof path==="object"){node=path}else{path=PATH.normalize(path);try{var lookup=FS.lookupPath(path,{follow:!(flags&131072)});node=lookup.node}catch(e){}}var created=false;if(flags&64){if(node){if(flags&128){throw new FS.ErrnoError(ERRNO_CODES.EEXIST)}}else{node=FS.mknod(path,mode,0);created=true}}if(!node){throw new FS.ErrnoError(ERRNO_CODES.ENOENT)}if(FS.isChrdev(node.mode)){flags&=~512}if(!created){var err=FS.mayOpen(node,flags);if(err){throw new FS.ErrnoError(err)}}if(flags&512){FS.truncate(node,0)}flags&=~(128|512);var stream=FS.createStream({node:node,path:FS.getPath(node),flags:flags,seekable:true,position:0,stream_ops:node.stream_ops,ungotten:[],error:false},fd_start,fd_end);if(stream.stream_ops.open){stream.stream_ops.open(stream)}if(Module["logReadFiles"]&&!(flags&1)){if(!FS.readFiles)FS.readFiles={};if(!(path in FS.readFiles)){FS.readFiles[path]=1;Module["printErr"]("read file: "+path)}}try{if(FS.trackingDelegate["onOpenFile"]){var trackingFlags=0;if((flags&2097155)!==1){trackingFlags|=FS.tracking.openFlags.READ}if((flags&2097155)!==0){trackingFlags|=FS.tracking.openFlags.WRITE}FS.trackingDelegate["onOpenFile"](path,trackingFlags)}}catch(e){console.log("FS.trackingDelegate['onOpenFile']('"+path+"', flags) threw an exception: "+e.message)}return stream}),close:(function(stream){try{if(stream.stream_ops.close){stream.stream_ops.close(stream)}}catch(e){throw e}finally{FS.closeStream(stream.fd)}}),llseek:(function(stream,offset,whence){if(!stream.seekable||!stream.stream_ops.llseek){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}stream.position=stream.stream_ops.llseek(stream,offset,whence);stream.ungotten=[];return stream.position}),read:(function(stream,buffer,offset,length,position){if(length<0||position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===1){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!stream.stream_ops.read){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}var seeking=true;if(typeof position==="undefined"){position=stream.position;seeking=false}else if(!stream.seekable){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}var bytesRead=stream.stream_ops.read(stream,buffer,offset,length,position);if(!seeking)stream.position+=bytesRead;return bytesRead}),write:(function(stream,buffer,offset,length,position,canOwn){if(length<0||position<0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(FS.isDir(stream.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.EISDIR)}if(!stream.stream_ops.write){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if(stream.flags&1024){FS.llseek(stream,0,2)}var seeking=true;if(typeof position==="undefined"){position=stream.position;seeking=false}else if(!stream.seekable){throw new FS.ErrnoError(ERRNO_CODES.ESPIPE)}var bytesWritten=stream.stream_ops.write(stream,buffer,offset,length,position,canOwn);if(!seeking)stream.position+=bytesWritten;try{if(stream.path&&FS.trackingDelegate["onWriteToFile"])FS.trackingDelegate["onWriteToFile"](stream.path)}catch(e){console.log("FS.trackingDelegate['onWriteToFile']('"+path+"') threw an exception: "+e.message)}return bytesWritten}),allocate:(function(stream,offset,length){if(offset<0||length<=0){throw new FS.ErrnoError(ERRNO_CODES.EINVAL)}if((stream.flags&2097155)===0){throw new FS.ErrnoError(ERRNO_CODES.EBADF)}if(!FS.isFile(stream.node.mode)&&!FS.isDir(node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}if(!stream.stream_ops.allocate){throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP)}stream.stream_ops.allocate(stream,offset,length)}),mmap:(function(stream,buffer,offset,length,position,prot,flags){if((stream.flags&2097155)===1){throw new FS.ErrnoError(ERRNO_CODES.EACCES)}if(!stream.stream_ops.mmap){throw new FS.ErrnoError(ERRNO_CODES.ENODEV)}return stream.stream_ops.mmap(stream,buffer,offset,length,position,prot,flags)}),msync:(function(stream,buffer,offset,length,mmapFlags){if(!stream||!stream.stream_ops.msync){return 0}return stream.stream_ops.msync(stream,buffer,offset,length,mmapFlags)}),munmap:(function(stream){return 0}),ioctl:(function(stream,cmd,arg){if(!stream.stream_ops.ioctl){throw new FS.ErrnoError(ERRNO_CODES.ENOTTY)}return stream.stream_ops.ioctl(stream,cmd,arg)}),readFile:(function(path,opts){opts=opts||{};opts.flags=opts.flags||"r";opts.encoding=opts.encoding||"binary";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var ret;var stream=FS.open(path,opts.flags);var stat=FS.stat(path);var length=stat.size;var buf=new Uint8Array(length);FS.read(stream,buf,0,length,0);if(opts.encoding==="utf8"){ret=UTF8ArrayToString(buf,0)}else if(opts.encoding==="binary"){ret=buf}FS.close(stream);return ret}),writeFile:(function(path,data,opts){opts=opts||{};opts.flags=opts.flags||"w";opts.encoding=opts.encoding||"utf8";if(opts.encoding!=="utf8"&&opts.encoding!=="binary"){throw new Error('Invalid encoding type "'+opts.encoding+'"')}var stream=FS.open(path,opts.flags,opts.mode);if(opts.encoding==="utf8"){var buf=new Uint8Array(lengthBytesUTF8(data)+1);var actualNumBytes=stringToUTF8Array(data,buf,0,buf.length);FS.write(stream,buf,0,actualNumBytes,0,opts.canOwn)}else if(opts.encoding==="binary"){FS.write(stream,data,0,data.length,0,opts.canOwn)}FS.close(stream)}),cwd:(function(){return FS.currentPath}),chdir:(function(path){var lookup=FS.lookupPath(path,{follow:true});if(!FS.isDir(lookup.node.mode)){throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR)}var err=FS.nodePermissions(lookup.node,"x");if(err){throw new FS.ErrnoError(err)}FS.currentPath=lookup.path}),createDefaultDirectories:(function(){FS.mkdir("/tmp");FS.mkdir("/home");FS.mkdir("/home/web_user")}),createDefaultDevices:(function(){FS.mkdir("/dev");FS.registerDevice(FS.makedev(1,3),{read:(function(){return 0}),write:(function(stream,buffer,offset,length,pos){return length})});FS.mkdev("/dev/null",FS.makedev(1,3));TTY.register(FS.makedev(5,0),TTY.default_tty_ops);TTY.register(FS.makedev(6,0),TTY.default_tty1_ops);FS.mkdev("/dev/tty",FS.makedev(5,0));FS.mkdev("/dev/tty1",FS.makedev(6,0));var random_device;if(typeof crypto!=="undefined"){var randomBuffer=new Uint8Array(1);random_device=(function(){crypto.getRandomValues(randomBuffer);return randomBuffer[0]})}else if(ENVIRONMENT_IS_NODE){random_device=(function(){return require("crypto").randomBytes(1)[0]})}else{random_device=(function(){return Math.random()*256|0})}FS.createDevice("/dev","random",random_device);FS.createDevice("/dev","urandom",random_device);FS.mkdir("/dev/shm");FS.mkdir("/dev/shm/tmp")}),createStandardStreams:(function(){if(Module["stdin"]){FS.createDevice("/dev","stdin",Module["stdin"])}else{FS.symlink("/dev/tty","/dev/stdin")}if(Module["stdout"]){FS.createDevice("/dev","stdout",null,Module["stdout"])}else{FS.symlink("/dev/tty","/dev/stdout")}if(Module["stderr"]){FS.createDevice("/dev","stderr",null,Module["stderr"])}else{FS.symlink("/dev/tty1","/dev/stderr")}var stdin=FS.open("/dev/stdin","r");HEAP32[_stdin>>2]=FS.getPtrForStream(stdin);assert(stdin.fd===0,"invalid handle for stdin ("+stdin.fd+")");var stdout=FS.open("/dev/stdout","w");HEAP32[_stdout>>2]=FS.getPtrForStream(stdout);assert(stdout.fd===1,"invalid handle for stdout ("+stdout.fd+")");var stderr=FS.open("/dev/stderr","w");HEAP32[_stderr>>2]=FS.getPtrForStream(stderr);assert(stderr.fd===2,"invalid handle for stderr ("+stderr.fd+")")}),ensureErrnoError:(function(){if(FS.ErrnoError)return;FS.ErrnoError=function ErrnoError(errno,node){this.node=node;this.setErrno=(function(errno){this.errno=errno;for(var key in ERRNO_CODES){if(ERRNO_CODES[key]===errno){this.code=key;break}}});this.setErrno(errno);this.message=ERRNO_MESSAGES[errno]};FS.ErrnoError.prototype=new Error;FS.ErrnoError.prototype.constructor=FS.ErrnoError;[ERRNO_CODES.ENOENT].forEach((function(code){FS.genericErrors[code]=new FS.ErrnoError(code);FS.genericErrors[code].stack=""}))}),staticInit:(function(){FS.ensureErrnoError();FS.nameTable=new Array(4096);FS.mount(MEMFS,{},"/");FS.createDefaultDirectories();FS.createDefaultDevices()}),init:(function(input,output,error){assert(!FS.init.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)");FS.init.initialized=true;FS.ensureErrnoError();Module["stdin"]=input||Module["stdin"];Module["stdout"]=output||Module["stdout"];Module["stderr"]=error||Module["stderr"];FS.createStandardStreams()}),quit:(function(){FS.init.initialized=false;for(var i=0;ithis.length-1||idx<0){return undefined}var chunkOffset=idx%this.chunkSize;var chunkNum=idx/this.chunkSize|0;return this.getter(chunkNum)[chunkOffset]};LazyUint8Array.prototype.setDataGetter=function LazyUint8Array_setDataGetter(getter){this.getter=getter};LazyUint8Array.prototype.cacheLength=function LazyUint8Array_cacheLength(){var xhr=new XMLHttpRequest;xhr.open("HEAD",url,false);xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);var datalength=Number(xhr.getResponseHeader("Content-length"));var header;var hasByteServing=(header=xhr.getResponseHeader("Accept-Ranges"))&&header==="bytes";var chunkSize=1024*1024;if(!hasByteServing)chunkSize=datalength;var doXHR=(function(from,to){if(from>to)throw new Error("invalid range ("+from+", "+to+") or no bytes requested!");if(to>datalength-1)throw new Error("only "+datalength+" bytes available! programmer error!");var xhr=new XMLHttpRequest;xhr.open("GET",url,false);if(datalength!==chunkSize)xhr.setRequestHeader("Range","bytes="+from+"-"+to);if(typeof Uint8Array!="undefined")xhr.responseType="arraybuffer";if(xhr.overrideMimeType){xhr.overrideMimeType("text/plain; charset=x-user-defined")}xhr.send(null);if(!(xhr.status>=200&&xhr.status<300||xhr.status===304))throw new Error("Couldn't load "+url+". Status: "+xhr.status);if(xhr.response!==undefined){return new Uint8Array(xhr.response||[])}else{return intArrayFromString(xhr.responseText||"",true)}});var lazyArray=this;lazyArray.setDataGetter((function(chunkNum){var start=chunkNum*chunkSize;var end=(chunkNum+1)*chunkSize-1;end=Math.min(end,datalength-1);if(typeof lazyArray.chunks[chunkNum]==="undefined"){lazyArray.chunks[chunkNum]=doXHR(start,end)}if(typeof lazyArray.chunks[chunkNum]==="undefined")throw new Error("doXHR failed!");return lazyArray.chunks[chunkNum]}));this._length=datalength;this._chunkSize=chunkSize;this.lengthKnown=true};if(typeof XMLHttpRequest!=="undefined"){if(!ENVIRONMENT_IS_WORKER)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var lazyArray=new LazyUint8Array;Object.defineProperty(lazyArray,"length",{get:(function(){if(!this.lengthKnown){this.cacheLength()}return this._length})});Object.defineProperty(lazyArray,"chunkSize",{get:(function(){if(!this.lengthKnown){this.cacheLength()}return this._chunkSize})});var properties={isDevice:false,contents:lazyArray}}else{var properties={isDevice:false,url:url}}var node=FS.createFile(parent,name,properties,canRead,canWrite);if(properties.contents){node.contents=properties.contents}else if(properties.url){node.contents=null;node.url=properties.url}Object.defineProperty(node,"usedBytes",{get:(function(){return this.contents.length})});var stream_ops={};var keys=Object.keys(node.stream_ops);keys.forEach((function(key){var fn=node.stream_ops[key];stream_ops[key]=function forceLoadLazyFile(){if(!FS.forceLoadFile(node)){throw new FS.ErrnoError(ERRNO_CODES.EIO)}return fn.apply(null,arguments)}}));stream_ops.read=function stream_ops_read(stream,buffer,offset,length,position){if(!FS.forceLoadFile(node)){throw new FS.ErrnoError(ERRNO_CODES.EIO)}var contents=stream.node.contents;if(position>=contents.length)return 0;var size=Math.min(contents.length-position,length);assert(size>=0);if(contents.slice){for(var i=0;i0){var start=Date.now();var blocker=Browser.mainLoop.queue.shift();blocker.func(blocker.arg);if(Browser.mainLoop.remainingBlockers){var remaining=Browser.mainLoop.remainingBlockers;var next=remaining%1==0?remaining-1:Math.floor(remaining);if(blocker.counted){Browser.mainLoop.remainingBlockers=next}else{next=next+.5;Browser.mainLoop.remainingBlockers=(8*remaining+next)/9}}console.log('main loop blocker "'+blocker.name+'" took '+(Date.now()-start)+" ms");Browser.mainLoop.updateStatus();setTimeout(Browser.mainLoop.runner,0);return}if(thisMainLoopId1&&Browser.mainLoop.currentFrameNumber%Browser.mainLoop.timingValue!=0){Browser.mainLoop.scheduler();return}if(Browser.mainLoop.method==="timeout"&&Module.ctx){Module.printErr("Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!");Browser.mainLoop.method=""}Browser.mainLoop.runIter((function(){if(typeof arg!=="undefined"){Runtime.dynCall("vi",func,[arg])}else{Runtime.dynCall("v",func)}}));if(thisMainLoopId0)_emscripten_set_main_loop_timing(0,1e3/fps);else _emscripten_set_main_loop_timing(1,1);Browser.mainLoop.scheduler()}if(simulateInfiniteLoop){throw"SimulateInfiniteLoop"}}var Browser={mainLoop:{scheduler:null,method:"",currentlyRunningMainloop:0,func:null,arg:0,timingMode:0,timingValue:0,currentFrameNumber:0,queue:[],pause:(function(){Browser.mainLoop.scheduler=null;Browser.mainLoop.currentlyRunningMainloop++}),resume:(function(){Browser.mainLoop.currentlyRunningMainloop++;var timingMode=Browser.mainLoop.timingMode;var timingValue=Browser.mainLoop.timingValue;var func=Browser.mainLoop.func;Browser.mainLoop.func=null;_emscripten_set_main_loop(func,0,false,Browser.mainLoop.arg,true);_emscripten_set_main_loop_timing(timingMode,timingValue);Browser.mainLoop.scheduler()}),updateStatus:(function(){if(Module["setStatus"]){var message=Module["statusMessage"]||"Please wait...";var remaining=Browser.mainLoop.remainingBlockers;var expected=Browser.mainLoop.expectedBlockers;if(remaining){if(remaining=6){var curr=leftchar>>leftbits-6&63;leftbits-=6;ret+=BASE[curr]}}if(leftbits==2){ret+=BASE[(leftchar&3)<<4];ret+=PAD+PAD}else if(leftbits==4){ret+=BASE[(leftchar&15)<<2];ret+=PAD}return ret}audio.src="data:audio/x-"+name.substr(-3)+";base64,"+encode64(byteArray);finish(audio)};audio.src=url;Browser.safeSetTimeout((function(){finish(audio)}),1e4)}else{return fail()}};Module["preloadPlugins"].push(audioPlugin);var canvas=Module["canvas"];function pointerLockChange(){Browser.pointerLock=document["pointerLockElement"]===canvas||document["mozPointerLockElement"]===canvas||document["webkitPointerLockElement"]===canvas||document["msPointerLockElement"]===canvas}if(canvas){canvas.requestPointerLock=canvas["requestPointerLock"]||canvas["mozRequestPointerLock"]||canvas["webkitRequestPointerLock"]||canvas["msRequestPointerLock"]||(function(){});canvas.exitPointerLock=document["exitPointerLock"]||document["mozExitPointerLock"]||document["webkitExitPointerLock"]||document["msExitPointerLock"]||(function(){});canvas.exitPointerLock=canvas.exitPointerLock.bind(document);document.addEventListener("pointerlockchange",pointerLockChange,false);document.addEventListener("mozpointerlockchange",pointerLockChange,false);document.addEventListener("webkitpointerlockchange",pointerLockChange,false);document.addEventListener("mspointerlockchange",pointerLockChange,false);if(Module["elementPointerLock"]){canvas.addEventListener("click",(function(ev){if(!Browser.pointerLock&&canvas.requestPointerLock){canvas.requestPointerLock();ev.preventDefault()}}),false)}}}),createContext:(function(canvas,useWebGL,setInModule,webGLContextAttributes){if(useWebGL&&Module.ctx&&canvas==Module.canvas)return Module.ctx;var ctx;var contextHandle;if(useWebGL){var contextAttributes={antialias:false,alpha:false};if(webGLContextAttributes){for(var attribute in webGLContextAttributes){contextAttributes[attribute]=webGLContextAttributes[attribute]}}contextHandle=GL.createContext(canvas,contextAttributes);if(contextHandle){ctx=GL.getContext(contextHandle).GLctx}canvas.style.backgroundColor="black"}else{ctx=canvas.getContext("2d")}if(!ctx)return null;if(setInModule){if(!useWebGL)assert(typeof GLctx==="undefined","cannot set in module if GLctx is used, but we are a non-GL context that would replace it");Module.ctx=ctx;if(useWebGL)GL.makeContextCurrent(contextHandle);Module.useWebGL=useWebGL;Browser.moduleContextCreatedCallbacks.forEach((function(callback){callback()}));Browser.init()}return ctx}),destroyContext:(function(canvas,useWebGL,setInModule){}),fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:(function(lockPointer,resizeCanvas,vrDevice){Browser.lockPointer=lockPointer;Browser.resizeCanvas=resizeCanvas;Browser.vrDevice=vrDevice;if(typeof Browser.lockPointer==="undefined")Browser.lockPointer=true;if(typeof Browser.resizeCanvas==="undefined")Browser.resizeCanvas=false;if(typeof Browser.vrDevice==="undefined")Browser.vrDevice=null;var canvas=Module["canvas"];function fullScreenChange(){Browser.isFullScreen=false;var canvasContainer=canvas.parentNode;if((document["webkitFullScreenElement"]||document["webkitFullscreenElement"]||document["mozFullScreenElement"]||document["mozFullscreenElement"]||document["fullScreenElement"]||document["fullscreenElement"]||document["msFullScreenElement"]||document["msFullscreenElement"]||document["webkitCurrentFullScreenElement"])===canvasContainer){canvas.cancelFullScreen=document["cancelFullScreen"]||document["mozCancelFullScreen"]||document["webkitCancelFullScreen"]||document["msExitFullscreen"]||document["exitFullscreen"]||(function(){});canvas.cancelFullScreen=canvas.cancelFullScreen.bind(document);if(Browser.lockPointer)canvas.requestPointerLock();Browser.isFullScreen=true;if(Browser.resizeCanvas)Browser.setFullScreenCanvasSize()}else{canvasContainer.parentNode.insertBefore(canvas,canvasContainer);canvasContainer.parentNode.removeChild(canvasContainer);if(Browser.resizeCanvas)Browser.setWindowedCanvasSize()}if(Module["onFullScreen"])Module["onFullScreen"](Browser.isFullScreen);Browser.updateCanvasDimensions(canvas)}if(!Browser.fullScreenHandlersInstalled){Browser.fullScreenHandlersInstalled=true;document.addEventListener("fullscreenchange",fullScreenChange,false);document.addEventListener("mozfullscreenchange",fullScreenChange,false);document.addEventListener("webkitfullscreenchange",fullScreenChange,false);document.addEventListener("MSFullscreenChange",fullScreenChange,false)}var canvasContainer=document.createElement("div");canvas.parentNode.insertBefore(canvasContainer,canvas);canvasContainer.appendChild(canvas);canvasContainer.requestFullScreen=canvasContainer["requestFullScreen"]||canvasContainer["mozRequestFullScreen"]||canvasContainer["msRequestFullscreen"]||(canvasContainer["webkitRequestFullScreen"]?(function(){canvasContainer["webkitRequestFullScreen"](Element["ALLOW_KEYBOARD_INPUT"])}):null);if(vrDevice){canvasContainer.requestFullScreen({vrDisplay:vrDevice})}else{canvasContainer.requestFullScreen()}}),nextRAF:0,fakeRequestAnimationFrame:(function(func){var now=Date.now();if(Browser.nextRAF===0){Browser.nextRAF=now+1e3/60}else{while(now+2>=Browser.nextRAF){Browser.nextRAF+=1e3/60}}var delay=Math.max(Browser.nextRAF-now,0);setTimeout(func,delay)}),requestAnimationFrame:function requestAnimationFrame(func){if(typeof window==="undefined"){Browser.fakeRequestAnimationFrame(func)}else{if(!window.requestAnimationFrame){window.requestAnimationFrame=window["requestAnimationFrame"]||window["mozRequestAnimationFrame"]||window["webkitRequestAnimationFrame"]||window["msRequestAnimationFrame"]||window["oRequestAnimationFrame"]||Browser.fakeRequestAnimationFrame}window.requestAnimationFrame(func)}},safeCallback:(function(func){return(function(){if(!ABORT)return func.apply(null,arguments)})}),allowAsyncCallbacks:true,queuedAsyncCallbacks:[],pauseAsyncCallbacks:(function(){Browser.allowAsyncCallbacks=false}),resumeAsyncCallbacks:(function(){Browser.allowAsyncCallbacks=true;if(Browser.queuedAsyncCallbacks.length>0){var callbacks=Browser.queuedAsyncCallbacks;Browser.queuedAsyncCallbacks=[];callbacks.forEach((function(func){func()}))}}),safeRequestAnimationFrame:(function(func){return Browser.requestAnimationFrame((function(){if(ABORT)return;if(Browser.allowAsyncCallbacks){func()}else{Browser.queuedAsyncCallbacks.push(func)}}))}),safeSetTimeout:(function(func,timeout){Module["noExitRuntime"]=true;return setTimeout((function(){if(ABORT)return;if(Browser.allowAsyncCallbacks){func()}else{Browser.queuedAsyncCallbacks.push(func)}}),timeout)}),safeSetInterval:(function(func,timeout){Module["noExitRuntime"]=true;return setInterval((function(){if(ABORT)return;if(Browser.allowAsyncCallbacks){func()}}),timeout)}),getMimetype:(function(name){return{"jpg":"image/jpeg","jpeg":"image/jpeg","png":"image/png","bmp":"image/bmp","ogg":"audio/ogg","wav":"audio/wav","mp3":"audio/mpeg"}[name.substr(name.lastIndexOf(".")+1)]}),getUserMedia:(function(func){if(!window.getUserMedia){window.getUserMedia=navigator["getUserMedia"]||navigator["mozGetUserMedia"]}window.getUserMedia(func)}),getMovementX:(function(event){return event["movementX"]||event["mozMovementX"]||event["webkitMovementX"]||0}),getMovementY:(function(event){return event["movementY"]||event["mozMovementY"]||event["webkitMovementY"]||0}),getMouseWheelDelta:(function(event){var delta=0;switch(event.type){case"DOMMouseScroll":delta=event.detail;break;case"mousewheel":delta=event.wheelDelta;break;case"wheel":delta=event["deltaY"];break;default:throw"unrecognized mouse wheel event: "+event.type}return delta}),mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,touches:{},lastTouches:{},calculateMouseEvent:(function(event){if(Browser.pointerLock){if(event.type!="mousemove"&&"mozMovementX"in event){Browser.mouseMovementX=Browser.mouseMovementY=0}else{Browser.mouseMovementX=Browser.getMovementX(event);Browser.mouseMovementY=Browser.getMovementY(event)}if(typeof SDL!="undefined"){Browser.mouseX=SDL.mouseX+Browser.mouseMovementX;Browser.mouseY=SDL.mouseY+Browser.mouseMovementY}else{Browser.mouseX+=Browser.mouseMovementX;Browser.mouseY+=Browser.mouseMovementY}}else{var rect=Module["canvas"].getBoundingClientRect();var cw=Module["canvas"].width;var ch=Module["canvas"].height;var scrollX=typeof window.scrollX!=="undefined"?window.scrollX:window.pageXOffset;var scrollY=typeof window.scrollY!=="undefined"?window.scrollY:window.pageYOffset;if(event.type==="touchstart"||event.type==="touchend"||event.type==="touchmove"){var touch=event.touch;if(touch===undefined){return}var adjustedX=touch.pageX-(scrollX+rect.left);var adjustedY=touch.pageY-(scrollY+rect.top);adjustedX=adjustedX*(cw/rect.width);adjustedY=adjustedY*(ch/rect.height);var coords={x:adjustedX,y:adjustedY};if(event.type==="touchstart"){Browser.lastTouches[touch.identifier]=coords;Browser.touches[touch.identifier]=coords}else if(event.type==="touchend"||event.type==="touchmove"){var last=Browser.touches[touch.identifier];if(!last)last=coords;Browser.lastTouches[touch.identifier]=last;Browser.touches[touch.identifier]=coords}return}var x=event.pageX-(scrollX+rect.left);var y=event.pageY-(scrollY+rect.top);x=x*(cw/rect.width);y=y*(ch/rect.height);Browser.mouseMovementX=x-Browser.mouseX;Browser.mouseMovementY=y-Browser.mouseY;Browser.mouseX=x;Browser.mouseY=y}}),xhrLoad:(function(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response)}else{onerror()}};xhr.onerror=onerror;xhr.send(null)}),asyncLoad:(function(url,onload,onerror,noRunDep){Browser.xhrLoad(url,(function(arrayBuffer){assert(arrayBuffer,'Loading data file "'+url+'" failed (no arrayBuffer).');onload(new Uint8Array(arrayBuffer));if(!noRunDep)removeRunDependency("al "+url)}),(function(event){if(onerror){onerror()}else{throw'Loading data file "'+url+'" failed.'}}));if(!noRunDep)addRunDependency("al "+url)}),resizeListeners:[],updateResizeListeners:(function(){var canvas=Module["canvas"];Browser.resizeListeners.forEach((function(listener){listener(canvas.width,canvas.height)}))}),setCanvasSize:(function(width,height,noUpdates){var canvas=Module["canvas"];Browser.updateCanvasDimensions(canvas,width,height);if(!noUpdates)Browser.updateResizeListeners()}),windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:(function(){if(typeof SDL!="undefined"){var flags=HEAPU32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2];flags=flags|8388608;HEAP32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2]=flags}Browser.updateResizeListeners()}),setWindowedCanvasSize:(function(){if(typeof SDL!="undefined"){var flags=HEAPU32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2];flags=flags&~8388608;HEAP32[SDL.screen+Runtime.QUANTUM_SIZE*0>>2]=flags}Browser.updateResizeListeners()}),updateCanvasDimensions:(function(canvas,wNative,hNative){if(wNative&&hNative){canvas.widthNative=wNative;canvas.heightNative=hNative}else{wNative=canvas.widthNative;hNative=canvas.heightNative}var w=wNative;var h=hNative;if(Module["forcedAspectRatio"]&&Module["forcedAspectRatio"]>0){if(w/h>8,sock.sport&255]))}return peer}),getPeer:(function(sock,addr,port){return sock.peers[addr+":"+port]}),addPeer:(function(sock,peer){sock.peers[peer.addr+":"+peer.port]=peer}),removePeer:(function(sock,peer){delete sock.peers[peer.addr+":"+peer.port]}),handlePeerEvents:(function(sock,peer){var first=true;var handleOpen=(function(){Module["websocket"].emit("open",sock.stream.fd);try{var queued=peer.dgram_send_queue.shift();while(queued){peer.socket.send(queued);queued=peer.dgram_send_queue.shift()}}catch(e){peer.socket.close()}});function handleMessage(data){assert(typeof data!=="string"&&data.byteLength!==undefined);data=new Uint8Array(data);var wasfirst=first;first=false;if(wasfirst&&data.length===10&&data[0]===255&&data[1]===255&&data[2]===255&&data[3]===255&&data[4]==="p".charCodeAt(0)&&data[5]==="o".charCodeAt(0)&&data[6]==="r".charCodeAt(0)&&data[7]==="t".charCodeAt(0)){var newport=data[8]<<8|data[9];SOCKFS.websocket_sock_ops.removePeer(sock,peer);peer.port=newport;SOCKFS.websocket_sock_ops.addPeer(sock,peer);return}sock.recv_queue.push({addr:peer.addr,port:peer.port,data:data});Module["websocket"].emit("message",sock.stream.fd)}if(ENVIRONMENT_IS_NODE){peer.socket.on("open",handleOpen);peer.socket.on("message",(function(data,flags){if(!flags.binary){return}handleMessage((new Uint8Array(data)).buffer)}));peer.socket.on("close",(function(){Module["websocket"].emit("close",sock.stream.fd)}));peer.socket.on("error",(function(error){sock.error=ERRNO_CODES.ECONNREFUSED;Module["websocket"].emit("error",[sock.stream.fd,sock.error,"ECONNREFUSED: Connection refused"])}))}else{peer.socket.onopen=handleOpen;peer.socket.onclose=(function(){Module["websocket"].emit("close",sock.stream.fd)});peer.socket.onmessage=function peer_socket_onmessage(event){handleMessage(event.data)};peer.socket.onerror=(function(error){sock.error=ERRNO_CODES.ECONNREFUSED;Module["websocket"].emit("error",[sock.stream.fd,sock.error,"ECONNREFUSED: Connection refused"])})}}),poll:(function(sock){if(sock.type===1&&sock.server){return sock.pending.length?64|1:0}var mask=0;var dest=sock.type===1?SOCKFS.websocket_sock_ops.getPeer(sock,sock.daddr,sock.dport):null;if(sock.recv_queue.length||!dest||dest&&dest.socket.readyState===dest.socket.CLOSING||dest&&dest.socket.readyState===dest.socket.CLOSED){mask|=64|1}if(!dest||dest&&dest.socket.readyState===dest.socket.OPEN){mask|=4}if(dest&&dest.socket.readyState===dest.socket.CLOSING||dest&&dest.socket.readyState===dest.socket.CLOSED){mask|=16}return mask}),ioctl:(function(sock,request,arg){switch(request){case 21531:var bytes=0;if(sock.recv_queue.length){bytes=sock.recv_queue[0].data.length}HEAP32[arg>>2]=bytes;return 0;default:return ERRNO_CODES.EINVAL}}),close:(function(sock){if(sock.server){try{sock.server.close()}catch(e){}sock.server=null}var peers=Object.keys(sock.peers);for(var i=0;i>2]=HEAP32[varargs+argIndex>>2],HEAP32[tempDoublePtr+4>>2]=HEAP32[varargs+(argIndex+4)>>2],+HEAPF64[tempDoublePtr>>3]);argIndex+=8}else if(type=="i64"){ret=[HEAP32[varargs+argIndex>>2],HEAP32[varargs+(argIndex+4)>>2]];argIndex+=8}else{assert((argIndex&3)===0);type="i32";ret=HEAP32[varargs+argIndex>>2];argIndex+=4}return ret}var ret=[];var curr,next,currArg;while(1){var startTextIndex=textIndex;curr=HEAP8[textIndex>>0];if(curr===0)break;next=HEAP8[textIndex+1>>0];if(curr==37){var flagAlwaysSigned=false;var flagLeftAlign=false;var flagAlternative=false;var flagZeroPad=false;var flagPadSign=false;flagsLoop:while(1){switch(next){case 43:flagAlwaysSigned=true;break;case 45:flagLeftAlign=true;break;case 35:flagAlternative=true;break;case 48:if(flagZeroPad){break flagsLoop}else{flagZeroPad=true;break};case 32:flagPadSign=true;break;default:break flagsLoop}textIndex++;next=HEAP8[textIndex+1>>0]}var width=0;if(next==42){width=getNextArg("i32");textIndex++;next=HEAP8[textIndex+1>>0]}else{while(next>=48&&next<=57){width=width*10+(next-48);textIndex++;next=HEAP8[textIndex+1>>0]}}var precisionSet=false,precision=-1;if(next==46){precision=0;precisionSet=true;textIndex++;next=HEAP8[textIndex+1>>0];if(next==42){precision=getNextArg("i32");textIndex++}else{while(1){var precisionChr=HEAP8[textIndex+1>>0];if(precisionChr<48||precisionChr>57)break;precision=precision*10+(precisionChr-48);textIndex++}}next=HEAP8[textIndex+1>>0]}if(precision<0){precision=6;precisionSet=false}var argSize;switch(String.fromCharCode(next)){case"h":var nextNext=HEAP8[textIndex+2>>0];if(nextNext==104){textIndex++;argSize=1}else{argSize=2}break;case"l":var nextNext=HEAP8[textIndex+2>>0];if(nextNext==108){textIndex++;argSize=8}else{argSize=4}break;case"L":case"q":case"j":argSize=8;break;case"z":case"t":case"I":argSize=4;break;default:argSize=null}if(argSize)textIndex++;next=HEAP8[textIndex+1>>0];switch(String.fromCharCode(next)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":{var signed=next==100||next==105;argSize=argSize||4;var currArg=getNextArg("i"+argSize*8);var origArg=currArg;var argText;if(argSize==8){currArg=Runtime.makeBigInt(currArg[0],currArg[1],next==117)}if(argSize<=4){var limit=Math.pow(256,argSize)-1;currArg=(signed?reSign:unSign)(currArg&limit,argSize*8)}var currAbsArg=Math.abs(currArg);var prefix="";if(next==100||next==105){if(argSize==8&&i64Math)argText=i64Math.stringify(origArg[0],origArg[1],null);else argText=reSign(currArg,8*argSize,1).toString(10)}else if(next==117){if(argSize==8&&i64Math)argText=i64Math.stringify(origArg[0],origArg[1],true);else argText=unSign(currArg,8*argSize,1).toString(10);currArg=Math.abs(currArg)}else if(next==111){argText=(flagAlternative?"0":"")+currAbsArg.toString(8)}else if(next==120||next==88){prefix=flagAlternative&&currArg!=0?"0x":"";if(argSize==8&&i64Math){if(origArg[1]){argText=(origArg[1]>>>0).toString(16);var lower=(origArg[0]>>>0).toString(16);while(lower.length<8)lower="0"+lower;argText+=lower}else{argText=(origArg[0]>>>0).toString(16)}}else if(currArg<0){currArg=-currArg;argText=(currAbsArg-1).toString(16);var buffer=[];for(var i=0;i=0){if(flagAlwaysSigned){prefix="+"+prefix}else if(flagPadSign){prefix=" "+prefix}}if(argText.charAt(0)=="-"){prefix="-"+prefix;argText=argText.substr(1)}while(prefix.length+argText.lengthexponent&&exponent>=-4){next=(next==103?"f":"F").charCodeAt(0);precision-=exponent+1}else{next=(next==103?"e":"E").charCodeAt(0);precision--}effectivePrecision=Math.min(precision,20)}if(next==101||next==69){argText=currArg.toExponential(effectivePrecision);if(/[eE][-+]\d$/.test(argText)){argText=argText.slice(0,-1)+"0"+argText.slice(-1)}}else if(next==102||next==70){argText=currArg.toFixed(effectivePrecision);if(currArg===0&&__reallyNegative(currArg)){argText="-"+argText}}var parts=argText.split("e");if(isGeneral&&!flagAlternative){while(parts[0].length>1&&parts[0].indexOf(".")!=-1&&(parts[0].slice(-1)=="0"||parts[0].slice(-1)==".")){parts[0]=parts[0].slice(0,-1)}}else{if(flagAlternative&&argText.indexOf(".")==-1)parts[0]+=".";while(precision>effectivePrecision++)parts[0]+="0"}argText=parts[0]+(parts.length>1?"e"+parts[1]:"");if(next==69)argText=argText.toUpperCase();if(currArg>=0){if(flagAlwaysSigned){argText="+"+argText}else if(flagPadSign){argText=" "+argText}}}while(argText.length>0])}}else{ret=ret.concat(intArrayFromString("(null)".substr(0,argLength),true))}if(flagLeftAlign){while(argLength0){ret.push(32)}if(!flagLeftAlign)ret.push(getNextArg("i8"));break};case"n":{var ptr=getNextArg("i32*");HEAP32[ptr>>2]=ret.length;break};case"%":{ret.push(curr);break};default:{for(var i=startTextIndex;i>0])}}}textIndex+=2}else{ret.push(curr);textIndex+=1}}return ret}function _fprintf(stream,format,varargs){var result=__formatString(format,varargs);var stack=Runtime.stackSave();var ret=_fwrite(allocate(result,"i8",ALLOC_STACK),1,result.length,stream);Runtime.stackRestore(stack);return ret}function _vfprintf(s,f,va_arg){return _fprintf(s,f,HEAP32[va_arg>>2])}function _emscripten_memcpy_big(dest,src,num){HEAPU8.set(HEAPU8.subarray(src,src+num),dest);return dest}Module["_memcpy"]=_memcpy;var _log=Math_log;var _cos=Math_cos;var _llvm_pow_f64=Math_pow;function _sbrk(bytes){var self=_sbrk;if(!self.called){DYNAMICTOP=alignMemoryPage(DYNAMICTOP);self.called=true;assert(Runtime.dynamicAlloc);self.alloc=Runtime.dynamicAlloc;Runtime.dynamicAlloc=(function(){abort("cannot dynamically allocate, sbrk now has control")})}var ret=DYNAMICTOP;if(bytes!=0){var success=self.alloc(bytes);if(!success)return-1>>>0}return ret}Module["_bitshift64Shl"]=_bitshift64Shl;function ___errno_location(){return ___errno_state}var _BItoD=true;function _hip_set_debugf(){Module["printErr"]("missing function: hip_set_debugf");abort(-1)}var _exp=Math_exp;function _time(ptr){var ret=Date.now()/1e3|0;if(ptr){HEAP32[ptr>>2]=ret}return ret}function _hip_decode1_unclipped(){Module["printErr"]("missing function: hip_decode1_unclipped");abort(-1)}___errno_state=Runtime.staticAlloc(4);HEAP32[___errno_state>>2]=0;FS.staticInit();__ATINIT__.unshift((function(){if(!Module["noFSInit"]&&!FS.init.initialized)FS.init()}));__ATMAIN__.push((function(){FS.ignorePermissions=false}));__ATEXIT__.push((function(){FS.quit()}));Module["FS_createFolder"]=FS.createFolder;Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createLink"]=FS.createLink;Module["FS_createDevice"]=FS.createDevice;__ATINIT__.unshift((function(){TTY.init()}));__ATEXIT__.push((function(){TTY.shutdown()}));if(ENVIRONMENT_IS_NODE){var fs=require("fs");var NODEJS_PATH=require("path");NODEFS.staticInit()}Module["requestFullScreen"]=function Module_requestFullScreen(lockPointer,resizeCanvas,vrDevice){Browser.requestFullScreen(lockPointer,resizeCanvas,vrDevice)};Module["requestAnimationFrame"]=function Module_requestAnimationFrame(func){Browser.requestAnimationFrame(func)};Module["setCanvasSize"]=function Module_setCanvasSize(width,height,noUpdates){Browser.setCanvasSize(width,height,noUpdates)};Module["pauseMainLoop"]=function Module_pauseMainLoop(){Browser.mainLoop.pause()};Module["resumeMainLoop"]=function Module_resumeMainLoop(){Browser.mainLoop.resume()};Module["getUserMedia"]=function Module_getUserMedia(){Browser.getUserMedia()};Module["createContext"]=function Module_createContext(canvas,useWebGL,setInModule,webGLContextAttributes){return Browser.createContext(canvas,useWebGL,setInModule,webGLContextAttributes)};__ATINIT__.push((function(){SOCKFS.root=FS.mount(SOCKFS,{},null)}));STACK_BASE=STACKTOP=Runtime.alignMemory(STATICTOP);staticSealed=true;STACK_MAX=STACK_BASE+TOTAL_STACK;DYNAMIC_BASE=DYNAMICTOP=Runtime.alignMemory(STACK_MAX);assert(DYNAMIC_BASE>2]|0;qa=b+140|0;y=(c[qa>>2]|0)==0;if(y)La=0;else La=c[b+85804>>2]|0;ua=b+192|0;if(+g[ua>>2]>0.0)p=+g[(c[b+85796>>2]|0)+8>>2]*+g[b+200>>2];else p=1.0;A=Ia;z=A+64|0;do{c[A>>2]=0;A=A+4|0}while((A|0)<(z|0));sa=b+180|0;A=(c[sa>>2]|0)==1;if(A)Ka=4;else Ka=c[b+72>>2]|0;ze(Fa|0,b+25660|0,976)|0;if(y)ba=0;else ba=c[b+85804>>2]|0;Ea=b+72|0;v=c[Ea>>2]|0;aa=A?4:v;ve(za|0,0,4608)|0;if((v|0)>0)if((aa|0)>2){z=0;do{A=c[e+(z<<2)>>2]|0;y=0;do{g[za+(z*2304|0)+(y<<2)>>2]=+g[A+(y+407<<2)>>2]-(+g[A+(y+418<<2)>>2]+ +g[A+(y+397<<2)>>2])*1.7303260184043527e-17-(+g[A+(y+417<<2)>>2]+ +g[A+(y+398<<2)>>2])*.017031719908118248-(+g[A+(y+416<<2)>>2]+ +g[A+(y+399<<2)>>2])*1.3495279640235235e-17+(+g[A+(y+415<<2)>>2]+ +g[A+(y+400<<2)>>2])*.04180720075964928-(+g[A+(y+414<<2)>>2]+ +g[A+(y+401<<2)>>2])*6.732779685849225e-17-(+g[A+(y+413<<2)>>2]+ +g[A+(y+402<<2)>>2])*.08763240277767181-(+g[A+(y+412<<2)>>2]+ +g[A+(y+403<<2)>>2])*3.0835000291318875e-17+(+g[A+(y+411<<2)>>2]+ +g[A+(y+404<<2)>>2])*.1863476037979126-(+g[A+(y+410<<2)>>2]+ +g[A+(y+405<<2)>>2])*1.1044240253100168e-16-(+g[A+(y+409<<2)>>2]+ +g[A+(y+406<<2)>>2])*.6276379823684692;y=y+1|0}while((y|0)!=576);ze(j+(f*976|0)+(z*488|0)+244|0,b+26636+(z*244|0)|0,244)|0;ze(j+(f*976|0)+(z*488|0)|0,b+25660+(z*244|0)|0,244)|0;ja=z+2|0;ze(k+(f*976|0)+(z*488|0)+244|0,b+26636+(ja*244|0)|0,244)|0;ze(k+(f*976|0)+(z*488|0)|0,b+25660+(ja*244|0)|0,244)|0;z=z+1|0}while((z|0)!=(v|0));}else{z=0;do{A=c[e+(z<<2)>>2]|0;y=0;do{g[za+(z*2304|0)+(y<<2)>>2]=+g[A+(y+407<<2)>>2]-(+g[A+(y+418<<2)>>2]+ +g[A+(y+397<<2)>>2])*1.7303260184043527e-17-(+g[A+(y+417<<2)>>2]+ +g[A+(y+398<<2)>>2])*.017031719908118248-(+g[A+(y+416<<2)>>2]+ +g[A+(y+399<<2)>>2])*1.3495279640235235e-17+(+g[A+(y+415<<2)>>2]+ +g[A+(y+400<<2)>>2])*.04180720075964928-(+g[A+(y+414<<2)>>2]+ +g[A+(y+401<<2)>>2])*6.732779685849225e-17-(+g[A+(y+413<<2)>>2]+ +g[A+(y+402<<2)>>2])*.08763240277767181-(+g[A+(y+412<<2)>>2]+ +g[A+(y+403<<2)>>2])*3.0835000291318875e-17+(+g[A+(y+411<<2)>>2]+ +g[A+(y+404<<2)>>2])*.1863476037979126-(+g[A+(y+410<<2)>>2]+ +g[A+(y+405<<2)>>2])*1.1044240253100168e-16-(+g[A+(y+409<<2)>>2]+ +g[A+(y+406<<2)>>2])*.6276379823684692;y=y+1|0}while((y|0)!=576);ze(j+(f*976|0)+(z*488|0)+244|0,b+26636+(z*244|0)|0,244)|0;ze(j+(f*976|0)+(z*488|0)|0,b+25660+(z*244|0)|0,244)|0;z=z+1|0}while((z|0)!=(v|0));}if((aa|0)>0){F=(ba|0)==0;E=Ja+4|0;q=wa+4|0;B=Aa+4|0;r=wa+8|0;C=Aa+8|0;s=wa+12|0;t=wa+16|0;G=wa+20|0;H=wa+24|0;I=wa+28|0;J=wa+32|0;K=wa+36|0;L=wa+40|0;M=wa+44|0;N=ca+4|0;P=ca+8|0;R=ca+12|0;S=Aa+12|0;T=Aa+16|0;U=Aa+20|0;V=Aa+24|0;W=Aa+28|0;X=Aa+32|0;Y=Aa+36|0;Z=Aa+40|0;_=Aa+44|0;$=0;do{c[ca>>2]=0;c[ca+4>>2]=0;c[ca+8>>2]=0;c[ca+12>>2]=0;z=za+(($&1)*2304|0)|0;if(($|0)==2){A=0;do{ia=za+(A<<2)|0;w=+g[ia>>2];ja=za+2304+(A<<2)|0;u=+g[ja>>2];g[ia>>2]=u+w;g[ja>>2]=w-u;A=A+1|0}while((A|0)!=576);}w=+g[b+27636+($*36|0)+24>>2];g[wa>>2]=w;g[Aa>>2]=w/+g[b+27636+($*36|0)+16>>2];x=+g[b+27636+($*36|0)+28>>2];g[q>>2]=x;g[B>>2]=x/+g[b+27636+($*36|0)+20>>2];u=+g[b+27636+($*36|0)+32>>2];g[r>>2]=u;g[C>>2]=u/w;g[ca>>2]=x+w+u;y=0;do{D=1.0;A=z;z=z+256|0;do{u=+O(+(+g[A>>2]));D=D>>0>>0);A=y+3|0;g[wa+(A<<2)>>2]=D;g[b+27636+($*36|0)+(y<<2)>>2]=D;ja=ca+(((y|0)/3|0)+1<<2)|0;g[ja>>2]=+g[ja>>2]+D;y=y+1|0;x=+g[wa+(y<<2)>>2];if(!(D>x)){D=D*10.0;if(x>D)D=x/D;else D=0.0}else D=D/x;g[Aa+(A<<2)>>2]=D}while((y|0)!=9);D=+g[t>>2];u=+g[G>>2];x=D+ +g[s>>2]+u;if(u*6.0>2]=D;D=+g[I>>2];u=+g[J>>2];x=D+ +g[H>>2]+u;if(u*6.0>2]=D;D=+g[L>>2];u=+g[M>>2];x=D+ +g[K>>2]+u;if(u*6.0>2]=D;if(!F){u=+g[Aa>>2];w=+g[B>>2];u=u>2];u=u>2];u=u>2];u=u>2];u=u>2];u=u>2];u=u>2];u=u>2];u=u>2];u=u>2];ja=ba+197112+($<<3)|0;h[ba+197144+(f<<5)+($<<3)>>3]=+h[ja>>3];h[ja>>3]=u>2]|0)+6480+($<<2)>>2];z=0;do{A=Ia+($<<4)+(((z|0)/3|0)<<2)|0;if((c[A>>2]|0)==0?+g[Aa+(z<<2)>>2]>D:0)c[A>>2]=((z|0)%3|0)+1;z=z+1|0}while((z|0)!=12);z=Ia+($<<4)|0;x=+g[ca>>2];w=+g[N>>2];u=w*1.7000000476837158;if(ww?x:w)<4.0e4:0)){A=Ia+($<<4)+4|0;if((c[z>>2]|0)<=(c[A>>2]|0))c[z>>2]=0;c[A>>2]=0}D=+g[P>>2];x=D*1.7000000476837158;if(DD?w:D)<4.0e4:0))c[Ia+($<<4)+8>>2]=0;u=+g[R>>2];if(uu?D:u)<4.0e4:0))c[Ia+($<<4)+12>>2]=0;A=c[z>>2]|0;v=c[b+27780+($<<2)>>2]|0;if((A|0)<=(v|0)){c[z>>2]=0;A=0}y=Ia+($<<4)+4|0;z=c[y>>2]|0;if((v|0)!=3?(z+A+(c[Ia+($<<4)+8>>2]|0)|0)==(0-(c[Ia+($<<4)+12>>2]|0)|0):0)A=1;else Da=47;do if((Da|0)==47){Da=0;do if(!z)z=0;else{if(!A)break;c[y>>2]=0;z=0}while(0);A=Ia+($<<4)+8|0;if(!(c[A>>2]|0)){A=0;break}if(z){c[A>>2]=0;A=0;break}A=Ia+($<<4)+12|0;if(!(c[A>>2]|0)){A=0;break}c[A>>2]=0;A=0}while(0);do if(($|0)<2)c[Ja+($<<2)>>2]=A;else{if(A)break;c[E>>2]=0;c[Ja>>2]=0}while(0);c[n+($<<2)>>2]=c[b+27620+($<<2)>>2];$=$+1|0}while(($|0)!=(aa|0));}A=c[b+184>>2]|0;if((A|0)==1?(da=Ja+4|0,(c[Ja>>2]|0)==0|(c[da>>2]|0)==0):0){c[da>>2]=0;c[Ja>>2]=0}z=c[Ea>>2]|0;do if((z|0)>0)if((A|0)==3){A=0;do{c[Ja+(A<<2)>>2]=0;A=A+1|0}while((A|0)<(z|0));}else if((A|0)==2){A=0;do{c[Ja+(A<<2)>>2]=1;A=A+1|0}while((A|0)<(z|0));}else break;while(0);ra=(Ka|0)>0;if(ra){ba=b+85796|0;aa=Aa+4|0;$=b+84908|0;ca=wa+4|0;_=b+85804|0;Z=0;do{E=Z&1;z=oa+(E<<12)|0;if(!(c[qa>>2]|0))t=0;else t=c[_>>2]|0;v=(Z|0)<2;if(!v){if((Z|0)==2){A=E+1|0;y=1023;while(1){ia=oa+(E<<12)+(y<<2)|0;w=+g[ia>>2];ja=oa+(A<<12)+(y<<2)|0;u=+g[ja>>2];g[ia>>2]=(u+w)*.7071067690849304;g[ja>>2]=(w-u)*.7071067690849304;if((y|0)>0)y=y+-1|0;else break}}}else Kb(b,z,Z,e);u=+g[z>>2];g[pa>>2]=u*u;A=511;while(1){ja=512-A|0;u=+g[oa+(E<<12)+(ja<<2)>>2];w=+g[oa+(E<<12)+(A+512<<2)>>2];g[pa+(ja<<2)>>2]=(w*w+u*u)*.5;if((A|0)>0)A=A+-1|0;else{A=11;D=0.0;break}}do{D=+g[pa+(A<<2)>>2]+D;A=A+1|0}while((A|0)!=513);g[b+27620+(Z<<2)>>2]=D;if(t){A=0;do{ja=t+90936+(Z<<13)+(A<<3)|0;h[t+123704+(f<<15)+(Z<<13)+(A<<3)>>3]=+h[ja>>3];h[ja>>3]=+g[pa+(A<<2)>>2];A=A+1|0}while((A|0)!=513);}if(v){y=b+27612+(Z<<2)|0;c[b+27804+(f<<3)+(Z<<2)>>2]=c[y>>2];A=c[ba>>2]|0;z=0;D=0.0;do{D=+g[A+724+(z<<2)>>2]*+g[pa+(z<<2)>>2]+D;z=z+1|0}while((z|0)!=512);g[y>>2]=D*8.974871343596633e-12}da=c[ta>>2]|0;n=da+2148|0;s=c[n>>2]|0;C=(s|0)>0;if(C){t=0;A=0;do{v=c[da+1716+(t<<2)>>2]|0;if((v|0)>0){x=0.0;z=0;y=A;D=0.0;while(1){u=+g[pa+(y<<2)>>2];x=u+x;D=D1?v:1)+A|0}else{x=0.0;D=0.0}g[xa+(Z<<8)+(t<<2)>>2]=x;g[Aa+(t<<2)>>2]=D;g[wa+(t<<2)>>2]=+g[da+512+(t<<2)>>2]*x;t=t+1|0}while((t|0)!=(s|0));D=+g[ca>>2];x=+g[wa>>2]}else{D=0.0;x=0.0}D=x+D;if(D>0.0){u=+g[Aa>>2];w=+g[aa>>2];A=~~(((u>2]|0)+-1+(c[da+1720>>2]|0)|0)*D));A=(A|0)>8?8:A&255}else A=0;a[za>>0]=A;t=s+-1|0;w=+g[ca>>2];D=w+x;if((t|0)>1){v=(t|0)>2;A=0;y=1;while(1){z=y+1|0;x=w;w=+g[wa+(z<<2)>>2];D=w+D;if(D>0.0){u=+g[Aa+(A<<2)>>2];Na=+g[Aa+(y<<2)>>2];u=u>2];A=~~(((u>2]|0)+-1+(c[da+1716+(y<<2)>>2]|0)+(c[da+1716+(z<<2)>>2]|0)|0)*D));A=(A|0)>8?8:A&255}else A=0;a[za+y>>0]=A;D=w+x;if((z|0)==(t|0))break;else{A=y;y=z}}z=v?t:2;A=z+-1|0}else{A=0;z=1}if(D>0.0){u=+g[Aa+(A<<2)>>2];w=+g[Aa+(z<<2)>>2];A=~~(((u>2]|0)+-1+(c[da+1716+(z<<2)>>2]|0)|0)*D));A=(A|0)>8?8:A&255}else A=0;a[za+z>>0]=A;if(C){F=da+2156|0;E=b+27796+(E<<2)|0;A=0;y=0;do{u=+g[$>>2]*+g[da+(A<<2)>>2];B=c[da+1204+(A<<3)>>2]|0;q=c[da+1204+(A<<3)+4>>2]|0;r=c[11448+((d[za+A>>0]|0)<<2)>>2]|0;z=d[za+B>>0]|0;v=c[F>>2]|0;D=+g[xa+(Z<<8)+(B<<2)>>2]*+g[v+(y<<2)>>2]*+g[11488+(z<<2)>>2];y=y+1|0;if((B|0)<(q|0)){C=y;t=B;while(1){t=t+1|0;s=d[za+t>>0]|0;z=s+z|0;x=+g[xa+(Z<<8)+(t<<2)>>2]*+g[v+(C<<2)>>2]*+g[11488+(s<<2)>>2];s=t-A|0;D=D<0.0?0.0:D;x=x<0.0?0.0:x;do if(!(D<=0.0)){if(x<=0.0)break;v=x>D;w=v?x/D:D/x;if((((s|0)>-1?s:0-s|0)|0)>(r|0))if(w<+g[2894]){D=x+D;break}else{D=v?x:D;break}else if(!(w>=+g[2882])){D=+g[11536+(~~(+Wd(w)*4.816479930623698)<<2)>>2]*(x+D);break}else{D=x+D;break}}else D=x;while(0);if((t|0)==(q|0))break;v=c[F>>2]|0;C=C+1|0}v=1-B+q|0;y=y-B+q|0}else v=1;w=+g[11488+(((z<<1|1|0)/(v<<1|0)|0)<<2)>>2]*.5;x=w*D;z=c[E>>2]|0;do if((z|0)==2){z=b+21564+(Z<<8)+(A<<2)|0;D=+g[z>>2]*2.0;if(D>0.0){D=x>2]=D;break}else{Na=x;D=+g[xa+(Z<<8)+(A<<2)>>2]*.3;D=Na>2]=D;break}}else{Na=+g[b+22588+(Z<<8)+(A<<2)>>2]*16.0;ja=b+21564+(Z<<8)+(A<<2)|0;D=+g[ja>>2]*2.0;Na=!(Na<=0.0)?Na:x;D=!(D<=0.0)?D:x;D=(z|0)==0?(D>2]=D;z=ja}while(0);c[b+22588+(Z<<8)+(A<<2)>>2]=c[z>>2];g[z>>2]=x;x=+g[Aa+(A<<2)>>2]*w*+g[da+256+(A<<2)>>2];if(D>x){g[v>>2]=x;D=x}if(u>1.0){D=D*u;g[v>>2]=D}x=+g[xa+(Z<<8)+(A<<2)>>2];if(D>x){g[v>>2]=x;D=x}if(u<1.0)g[v>>2]=D*u;A=A+1|0}while((A|0)<(c[n>>2]|0));if((A|0)<64)Da=114}else{A=0;Da=114}if((Da|0)==114){Da=0;ja=256-(A<<2)|0;ve(xa+(Z<<8)+(A<<2)|0,0,ja|0)|0;ve(Ba+(Z<<8)+(A<<2)|0,0,ja|0)|0}Z=Z+1|0}while((Z|0)!=(Ka|0));}if((c[sa>>2]|0)==1?((c[Ja+4>>2]|0)+(c[Ja>>2]|0)|0)==2:0)hc(xa,Ba,na+768|0,(c[b+85796>>2]|0)+212|0,p,+g[ua>>2],c[na+2148>>2]|0);if(ra){v=0;do{ja=xa+(v<<8)|0;t=Ba+(v<<8)|0;ic(c[ta>>2]|0,ja,t,b+26636+(v*244|0)|0,b+25660+(v*244|0)|0);ic((c[ta>>2]|0)+4320|0,ja,t,za,Aa);t=0;do{ja=c[za+(t<<2)>>2]|0;u=+g[Aa+(t<<2)>>2]*.015625;c[b+26636+(v*244|0)+88+(t*12|0)>>2]=ja;g[b+25660+(v*244|0)+88+(t*12|0)>>2]=u;c[b+26636+(v*244|0)+88+(t*12|0)+4>>2]=ja;g[b+25660+(v*244|0)+88+(t*12|0)+4>>2]=u;c[b+26636+(v*244|0)+88+(t*12|0)+8>>2]=ja;g[b+25660+(v*244|0)+88+(t*12|0)+8>>2]=u;t=t+1|0}while((t|0)!=13);v=v+1|0}while((v|0)!=(Ka|0));}oa=na+2928|0;pa=b+85796|0;X=na+4308|0;W=(c[(c[ta>>2]|0)+6500>>2]|0)!=0;V=za+4|0;U=Aa+4|0;T=za+8|0;S=Aa+8|0;R=za+12|0;C=Aa+12|0;r=za+16|0;P=Aa+16|0;N=za+20|0;G=Aa+20|0;H=za+24|0;I=Aa+24|0;J=za+28|0;K=Aa+28|0;L=za+32|0;M=Aa+32|0;ea=za+36|0;fa=Aa+36|0;ga=za+40|0;ha=Aa+40|0;ia=za+44|0;ja=Aa+44|0;ka=za+48|0;la=Aa+48|0;ma=Aa+4|0;qa=b+84908|0;Y=wa+4|0;Z=(c[Ja>>2]|0)!=(0-(c[Ja+4>>2]|0)|0);na=0;do{if(ra){ca=(na|0)==0;ba=ya+(na*516|0)|0;aa=0;do{y=aa&1;if(W|(c[Ja+(y<<2)>>2]|0)==0){if(ca&(aa|0)<2)Jb(b,Ca+(y*3072|0)|0,aa,e);if((aa|0)==2){A=y+1|0;z=255;while(1){n=Ca+(y*3072|0)+(na<<10)+(z<<2)|0;w=+g[n>>2];da=Ca+(A*3072|0)+(na<<10)+(z<<2)|0;u=+g[da>>2];g[n>>2]=(u+w)*.7071067690849304;g[da>>2]=(w-u)*.7071067690849304;if((z|0)>0)z=z+-1|0;else break}}u=+g[Ca+(y*3072|0)+(na<<10)>>2];g[ba>>2]=u*u;A=127;while(1){da=128-A|0;u=+g[Ca+(y*3072|0)+(na<<10)+(da<<2)>>2];w=+g[Ca+(y*3072|0)+(na<<10)+(A+128<<2)>>2];g[ya+(na*516|0)+(da<<2)>>2]=(w*w+u*u)*.5;if((A|0)>0)A=A+-1|0;else break}da=c[ta>>2]|0;ve(Aa|0,0,256)|0;ve(wa|0,0,256)|0;n=da+4308|0;F=c[n>>2]|0;_=(F|0)>0;if(_){t=0;A=0;do{v=c[da+3876+(t<<2)>>2]|0;if((v|0)>0){x=0.0;z=0;y=A;D=0.0;while(1){u=+g[ya+(na*516|0)+(y<<2)>>2];x=u+x;D=D>2]=x;g[Aa+(t<<2)>>2]=D;g[wa+(t<<2)>>2]=+g[da+2672+(t<<2)>>2]*x;t=t+1|0}while((t|0)!=(F|0));w=+g[Y>>2];x=+g[wa>>2]}else{w=0.0;x=0.0}D=x+w;if(D>0.0){u=+g[Aa>>2];Na=+g[ma>>2];A=~~(((u>2]|0)+-1+(c[da+3880>>2]|0)|0)*D));A=(A|0)>8?8:A&255}else A=0;a[za>>0]=A;t=F+-1|0;D=w+x;if((t|0)>1){v=(t|0)>2;A=0;y=1;while(1){z=y+1|0;x=w;w=+g[wa+(z<<2)>>2];D=w+D;if(D>0.0){u=+g[Aa+(A<<2)>>2];Na=+g[Aa+(y<<2)>>2];u=u>2];A=~~(((u>2]|0)+-1+(c[da+3876+(y<<2)>>2]|0)+(c[da+3876+(z<<2)>>2]|0)|0)*D));A=(A|0)>8?8:A&255}else A=0;a[za+y>>0]=A;D=w+x;if((z|0)==(t|0))break;else{A=y;y=z}}z=v?t:2;A=z+-1|0}else{A=0;z=1}if(D>0.0){u=+g[Aa+(A<<2)>>2];w=+g[Aa+(z<<2)>>2];A=~~(((u>2]|0)+-1+(c[da+3876+(z<<2)>>2]|0)|0)*D));A=(A|0)>8?8:A&255}else A=0;a[za+z>>0]=A;if(_){$=da+4316|0;A=0;y=0;do{q=c[da+3364+(A<<3)>>2]|0;B=c[da+3364+(A<<3)+4>>2]|0;E=c[11448+((d[za+A>>0]|0)<<2)>>2]|0;u=+g[qa>>2]*+g[da+2160+(A<<2)>>2];z=d[za+q>>0]|0;v=c[$>>2]|0;D=+g[xa+(aa<<8)+(q<<2)>>2]*+g[v+(y<<2)>>2]*+g[11488+(z<<2)>>2];y=y+1|0;if((q|0)<(B|0)){F=y;t=q;while(1){t=t+1|0;s=d[za+t>>0]|0;z=s+z|0;x=+g[xa+(aa<<8)+(t<<2)>>2]*+g[v+(F<<2)>>2]*+g[11488+(s<<2)>>2];s=t-A|0;D=D<0.0?0.0:D;x=x<0.0?0.0:x;do if(!(D<=0.0)){if(x<=0.0)break;v=x>D;w=v?x/D:D/x;if((((s|0)>-1?s:0-s|0)|0)>(E|0))if(w<+g[2894]){D=x+D;break}else{D=v?x:D;break}else if(!(w>=+g[2882])){D=+g[11536+(~~(+Wd(w)*4.816479930623698)<<2)>>2]*(x+D);break}else{D=x+D;break}}else D=x;while(0);if((t|0)==(B|0))break;v=c[$>>2]|0;F=F+1|0}v=1-q+B|0;y=y-q+B|0}else v=1;x=+g[11488+(((z<<1|1|0)/(v<<1|0)|0)<<2)>>2]*.5;D=x*D;z=Ba+(aa<<8)+(A<<2)|0;g[z>>2]=D;_=b+23612+(aa<<8)+(A<<2)|0;c[b+24636+(aa<<8)+(A<<2)>>2]=c[_>>2];g[_>>2]=D;x=+g[Aa+(A<<2)>>2]*x*+g[da+2416+(A<<2)>>2];if(D>x){g[z>>2]=x;D=x}if(u>1.0){D=D*u;g[z>>2]=D}x=+g[xa+(aa<<8)+(A<<2)>>2];if(D>x){g[z>>2]=x;D=x}if(u<1.0)g[z>>2]=D*u;A=A+1|0}while((A|0)<(c[n>>2]|0));if((A|0)<64)Da=185}else{A=0;Da=185}if((Da|0)==185){Da=0;da=256-(A<<2)|0;ve(xa+(aa<<8)+(A<<2)|0,0,da|0)|0;ve(Ba+(aa<<8)+(A<<2)|0,0,da|0)|0}}else if(ca?(va=c[(c[ta>>2]|0)+4308>>2]|0,(va|0)>0):0){A=0;do{c[b+24636+(aa<<8)+(A<<2)>>2]=c[b+23612+(aa<<8)+(A<<2)>>2];A=A+1|0}while((A|0)!=(va|0));}aa=aa+1|0}while((aa|0)!=(Ka|0));}if(!((c[sa>>2]|0)!=1|Z))hc(xa,Ba,oa,(c[pa>>2]|0)+468|0,p,+g[ua>>2],c[X>>2]|0);if(ra){A=0;do{if(W|(c[Ja+((A&1)<<2)>>2]|0)==0){ic((c[ta>>2]|0)+2160|0,xa+(A<<8)|0,Ba+(A<<8)|0,za,Aa);c[b+26636+(A*244|0)+88+(na<<2)>>2]=c[za>>2];c[b+25660+(A*244|0)+88+(na<<2)>>2]=c[Aa>>2];c[b+26636+(A*244|0)+100+(na<<2)>>2]=c[V>>2];c[b+25660+(A*244|0)+100+(na<<2)>>2]=c[U>>2];c[b+26636+(A*244|0)+112+(na<<2)>>2]=c[T>>2];c[b+25660+(A*244|0)+112+(na<<2)>>2]=c[S>>2];c[b+26636+(A*244|0)+124+(na<<2)>>2]=c[R>>2];c[b+25660+(A*244|0)+124+(na<<2)>>2]=c[C>>2];c[b+26636+(A*244|0)+136+(na<<2)>>2]=c[r>>2];c[b+25660+(A*244|0)+136+(na<<2)>>2]=c[P>>2];c[b+26636+(A*244|0)+148+(na<<2)>>2]=c[N>>2];c[b+25660+(A*244|0)+148+(na<<2)>>2]=c[G>>2];c[b+26636+(A*244|0)+160+(na<<2)>>2]=c[H>>2];c[b+25660+(A*244|0)+160+(na<<2)>>2]=c[I>>2];c[b+26636+(A*244|0)+172+(na<<2)>>2]=c[J>>2];c[b+25660+(A*244|0)+172+(na<<2)>>2]=c[K>>2];c[b+26636+(A*244|0)+184+(na<<2)>>2]=c[L>>2];c[b+25660+(A*244|0)+184+(na<<2)>>2]=c[M>>2];c[b+26636+(A*244|0)+196+(na<<2)>>2]=c[ea>>2];c[b+25660+(A*244|0)+196+(na<<2)>>2]=c[fa>>2];c[b+26636+(A*244|0)+208+(na<<2)>>2]=c[ga>>2];c[b+25660+(A*244|0)+208+(na<<2)>>2]=c[ha>>2];c[b+26636+(A*244|0)+220+(na<<2)>>2]=c[ia>>2];c[b+25660+(A*244|0)+220+(na<<2)>>2]=c[ja>>2];c[b+26636+(A*244|0)+232+(na<<2)>>2]=c[ka>>2];c[b+25660+(A*244|0)+232+(na<<2)>>2]=c[la>>2]}A=A+1|0}while((A|0)!=(Ka|0));}na=na+1|0}while((na|0)!=3);if(ra){z=0;do{r=b+27780+(z<<2)|0;A=0;do{C=b+25660+(z*244|0)+88+(A*12|0)|0;q=Fa+(z*244|0)+88+(A*12|0)+8|0;y=Fa+(z*244|0)+88+(A*12|0)+4|0;B=0;do{x=+g[b+25660+(z*244|0)+88+(A*12|0)+(B<<2)>>2]*.8;t=(B|0)>0;s=B+-1|0;u=+g[(t?Ga+(s<<2)|0:q)>>2];v=c[Ia+(z<<4)+(B<<2)>>2]|0;if((v|0)<=1?(c[Ia+(z<<4)+(B+1<<2)>>2]|0)!=1:0)w=x;else if(x>0.0)w=+Q(+(u/x),.36000001430511475)*x;else w=0.0;w=w0.0)x=+Q(+(u/w),.18000000715255737)*w;else x=0.0;else{if((B|0)==0?(c[r>>2]|0)==3:0)Da=233;else Da=230;do if((Da|0)==230){Da=0;if(!t)break a;if((c[Ia+(z<<4)+(s<<2)>>2]|0)!=3)break a;if(!B){Da=233;break}else if((B|0)==1){x=+g[q>>2];break}else if((B|0)==2){x=+g[Ga>>2];break}else{x=u;break}}while(0);if((Da|0)==233)x=+g[y>>2];if(!(w>0.0)){x=0.0;break}x=+Q(+(x/w),.18000000715255737)*w}while(0);g[Ga+(B<<2)>>2]=(x>2];B=B+1|0}while((B|0)!=3);c[C>>2]=c[Ga>>2];c[C+4>>2]=c[Ga+4>>2];c[C+8>>2]=c[Ga+8>>2];A=A+1|0}while((A|0)!=13);z=z+1|0}while((z|0)!=(Ka|0));if(ra){q=0;do{c[b+27780+(q<<2)>>2]=c[Ia+(q<<4)+8>>2];q=q+1|0}while((q|0)!=(Ka|0));}}r=c[Ea>>2]|0;if((r|0)>0){v=0;do{s=b+27796+(v<<2)|0;q=c[s>>2]|0;do if(!(c[Ja+(v<<2)>>2]|0))if(!q){c[s>>2]=1;t=1;q=2;break}else if((q|0)==3){c[s>>2]=2;t=2;q=2;break}else{t=q;q=2;break}else{t=q;q=(q|0)==2?3:0}while(0);c[o+(v<<2)>>2]=t;c[s>>2]=q;v=v+1|0}while((v|0)!=(r|0));}if(!ra){i=Ma;return 0}y=m+-8|0;s=o+4|0;C=(La|0)==0;r=0;do{if((r|0)>1){if((c[o>>2]|0)!=2?(c[s>>2]|0)!=2:0)q=0;else q=2;A=k+(f*976|0)+((r+-2|0)*488|0)|0;z=y}else{A=j+(f*976|0)+(r*488|0)|0;z=l;q=c[o+(r<<2)>>2]|0}D=+g[qa>>2];if((q|0)==2){p=309.07000732421875;t=0;do{v=11584+(t<<2)|0;u=+g[A+88+(t*12|0)>>2];do if(u>0.0){x=u*D;w=+g[A+332+(t*12|0)>>2];if(!(w>x))break;u=+g[v>>2];if(w>x*1.0e10){p=u*23.02585092994046+p;break}else{p=u*.30102999566398114*+Wd(w/x)+p;break}}while(0);u=+g[A+88+(t*12|0)+4>>2];do if(u>0.0){x=u*D;w=+g[A+332+(t*12|0)+4>>2];if(!(w>x))break;u=+g[v>>2];if(w>x*1.0e10){p=u*23.02585092994046+p;break}else{p=u*.30102999566398114*+Wd(w/x)+p;break}}while(0);u=+g[A+88+(t*12|0)+8>>2];do if(u>0.0){x=u*D;w=+g[A+332+(t*12|0)+8>>2];if(!(w>x))break;u=+g[v>>2];if(w>x*1.0e10){p=u*23.02585092994046+p;break}else{p=u*.30102999566398114*+Wd(w/x)+p;break}}while(0);t=t+1|0}while((t|0)!=12);g[z+(r<<2)>>2]=p}else{p=281.0574951171875;v=0;do{u=+g[A+(v<<2)>>2];do if(u>0.0){u=u*D;w=+g[A+244+(v<<2)>>2];if(!(w>u))break;x=+g[11632+(v<<2)>>2];if(w>u*1.0e10){p=x*23.02585092994046+p;break}else{p=x*.30102999566398114*+Wd(w/u)+p;break}}while(0);v=v+1|0}while((v|0)!=21);g[z+(r<<2)>>2]=p}if(!C)h[La+189240+(f<<5)+(r<<3)>>3]=p;r=r+1|0}while((r|0)!=(Ka|0));i=Ma;return 0}function gc(a){a=a|0;var b=0,d=0,e=0.0,f=0,h=0.0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0,E=0.0;D=i;i=i+768|0;t=D+512|0;u=D+256|0;v=D;w=c[a+288>>2]|0;y=w+16|0;x=w+64|0;C=+(c[x>>2]|0);e=-+g[w+280>>2];f=w+85800|0;if(c[f>>2]|0){z=0;i=D;return z|0}ve(v|0,0,256)|0;B=se(1,6504)|0;c[f>>2]=B;c[B+6500>>2]=c[a+144>>2];c[w+27800>>2]=0;c[w+27796>>2]=0;b=0;do{f=0;do{g[w+21564+(b<<8)+(f<<2)>>2]=100000002004087734272.0;g[w+22588+(b<<8)+(f<<2)>>2]=100000002004087734272.0;g[w+24636+(b<<8)+(f<<2)>>2]=1.0;g[w+23612+(b<<8)+(f<<2)>>2]=1.0;f=f+1|0}while((f|0)!=64);g[w+26636+(b*244|0)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+4>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+4>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+8>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+8>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+12>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+12>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+16>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+16>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+20>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+20>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+24>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+24>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+28>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+28>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+32>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+32>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+36>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+36>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+40>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+40>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+44>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+44>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+48>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+48>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+52>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+52>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+56>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+56>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+60>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+60>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+64>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+64>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+68>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+68>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+72>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+72>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+76>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+76>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+80>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+80>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+84>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+84>>2]=100000002004087734272.0;f=w+27780+(b<<2)|0;d=0;do{g[w+26636+(b*244|0)+88+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+88+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+100+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+100+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+112+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+112+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+124+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+124+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+136+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+136+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+148+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+148+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+160+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+160+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+172+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+172+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+184+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+184+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+196+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+196+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+208+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+208+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+220+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+220+(d<<2)>>2]=100000002004087734272.0;g[w+26636+(b*244|0)+232+(d<<2)>>2]=100000002004087734272.0;g[w+25660+(b*244|0)+232+(d<<2)>>2]=100000002004087734272.0;c[f>>2]=0;d=d+1|0}while((d|0)!=3);g[w+27636+(b*36|0)>>2]=10.0;g[w+27636+(b*36|0)+4>>2]=10.0;g[w+27636+(b*36|0)+8>>2]=10.0;g[w+27636+(b*36|0)+12>>2]=10.0;g[w+27636+(b*36|0)+16>>2]=10.0;g[w+27636+(b*36|0)+20>>2]=10.0;g[w+27636+(b*36|0)+24>>2]=10.0;g[w+27636+(b*36|0)+28>>2]=10.0;g[w+27636+(b*36|0)+32>>2]=10.0;b=b+1|0}while((b|0)!=4);g[w+27616>>2]=0.0;g[w+27612>>2]=0.0;jc(B,C,1024,576,22,w+21360|0);z=B+2148|0;f=c[z>>2]|0;j=C*.0009765625;if((f|0)>0){h=j;k=0;d=0;do{r=c[B+1716+(d<<2)>>2]|0;E=+Fd(+(k|0)*j);s=k;k=r+k|0;g[t+(d<<2)>>2]=(+Fd(+(k+-1|0)*j)+E)*.5;E=+Fd((+(s|0)+-.5)*h);g[u+(d<<2)>>2]=+Fd((+(k|0)+-.5)*h)-E;d=d+1|0}while((d|0)!=(f|0));f=c[z>>2]|0;if((f|0)>0){d=0;do{g[v+(d<<2)>>2]=1.0;d=d+1|0}while((d|0)<(f|0));}}q=B+1204|0;f=kc(B+2156|0,q,f,t,u,v)|0;if(f){z=f;i=D;return z|0}if((c[z>>2]|0)>0){l=B+1716|0;m=w+85796|0;h=e;n=B+256|0;o=0;f=0;do{b=l+(o<<2)|0;k=c[b>>2]|0;if((k|0)>0){d=0;j=1.e+37;do{E=+Q(10.0,+((+Ed(y,+(f|0)*C*9.765625e-07*1.0e3)+-20.0)*.1));k=c[b>>2]|0;E=+(k|0)*E;j=j>E?E:j;d=d+1|0;f=f+1|0}while((d|0)<(k|0));}else j=1.e+37;g[(c[m>>2]|0)+212+(o<<2)>>2]=j;j=(+g[t+(o<<2)>>2]*.10000000149011612+-1.0)*20.0;j=j>6.0?30.0:j;g[n+(o<<2)>>2]=+(k|0)*+Q(10.0,+((c[x>>2]|0)<44e3?2.2:((j>2]|0));}r=B+2160|0;s=w+21452|0;jc(r,C,256,192,13,s);p=B+4308|0;f=c[p>>2]|0;j=C*.00390625;if((f|0)>0){h=j;k=0;d=0;do{l=c[r+1716+(d<<2)>>2]|0;E=+Fd(+(k|0)*j);b=k;k=l+k|0;g[t+(d<<2)>>2]=(+Fd(+(k+-1|0)*j)+E)*.5;E=+Fd((+(b|0)+-.5)*h);g[u+(d<<2)>>2]=+Fd((+(k|0)+-.5)*h)-E;d=d+1|0}while((d|0)!=(f|0));f=c[p>>2]|0;if((f|0)>0){l=B+3876|0;b=w+85796|0;o=B+2416|0;m=0;f=0;while(1){h=+g[t+(m<<2)>>2];if(!(h>=13.0))j=-8.25;else j=(24.0-h)*-.75-(h+-13.0)*.40909090638160706;g[v+(m<<2)>>2]=+Q(10.0,+(j*.1));n=l+(m<<2)|0;k=c[n>>2]|0;if((k|0)>0){d=0;j=1.e+37;do{E=+Q(10.0,+((+Ed(y,+(f|0)*C*3.90625e-06*1.0e3)+-20.0)*.1));k=c[n>>2]|0;E=+(k|0)*E;j=j>E?E:j;d=d+1|0;f=f+1|0}while((d|0)<(k|0));d=f}else{d=f;j=1.e+37}g[(c[b>>2]|0)+468+(m<<2)>>2]=j;j=(h*.0833333358168602+-1.0)*7.0;if(h>12.0)j=(+Z(+(j+1.0))*3.1+1.0)*j;if(h<12.0)j=(+Z(+(1.0-j))*2.3+1.0)*j;h=j>6.0?30.0:j;g[o+(m<<2)>>2]=+(k|0)*+Q(10.0,+((c[x>>2]|0)<44e3?2.2:((h>2]|0;if((m|0)>=(f|0))break;else f=d}}}f=kc(B+4316|0,B+3364|0,f,t,u,v)|0;if(f){z=f;i=D;return z|0}g[2882]=3.6517412662506104;g[2894]=31.62277603149414;Lb(w);j=C;g[B+6496>>2]=+Y(+(-44209.633785485676/j));f=w+192|0;e=+g[f>>2];g[f>>2]=e!=e|0.0!=0.0|e==0.0?((c[w+96>>2]|0)!=0?1.0:3.5):e;f=c[z>>2]|0;if((f|0)>0){d=f+-1|0;k=0;do{b=q+(k<<3)+4|0;if((c[b>>2]|0)>(d|0))c[b>>2]=d;k=k+1|0}while((k|0)<(f|0));}e=+Q(10.0,+(+(c[w+76>>2]|0)*576.0/j*-1.2));k=w+85796|0;v=c[k>>2]|0;g[v+16>>2]=e;g[v+8>>2]=.009999999776482582;g[v+12>>2]=1.0;if((c[w+208>>2]|0)!=-1){h=+(c[x>>2]|0)*.0009765625;e=0.0;j=0.0;f=0;do{j=j+h;E=1.0/+Q(10.0,+(+Ed(y,j)*.10000000149011612));d=c[k>>2]|0;g[d+724+(f<<2)>>2]=E;e=E+e;f=f+1|0}while((f|0)!=512);e=1.0/e;f=511;while(1){y=d+724+(f<<2)|0;g[y>>2]=+g[y>>2]*e;if((f|0)>0)f=f+-1|0;else break}}b=c[p>>2]|0;h=+g[a+264>>2];e=+g[a+268>>2];h=h<0.0?4.400000095367432:h;g[B+6488>>2]=h;g[B+6484>>2]=h;g[B+6480>>2]=h;g[B+6492>>2]=e<0.0?25.0:e;d=c[a+164>>2]|0;if((d|0)<4)j=-.7400000095367432;else{j=+g[11720+(d<<2)>>2];j=((j-+g[11720+(d+1<<2)>>2])*+g[a+160>>2]+j)*.10000000149011612}if((b|0)>0){f=(b|0)>1;e=+(b|0);d=0;do{g[r+(d<<2)>>2]=+Q(10.0,+(j*(+(b-d|0)/e)));d=d+1|0}while((b|0)>(d|0));if(f){if((b|0)<64)A=50}else{b=1;A=50}}else{b=0;A=50}if((A|0)==50)do{g[r+(b<<2)>>2]=1.0;b=b+1|0}while((b|0)!=64);b=c[z>>2]|0;if((b|0)>0){d=(b|0)>1;e=+(b|0);f=0;do{g[B+(f<<2)>>2]=+Q(10.0,+(j*(+(b-f|0)/e)));f=f+1|0}while((b|0)>(f|0));if(d){if((b|0)<64)A=57}else{b=1;A=57}}else{b=0;A=57}if((A|0)==57)do{g[B+(b<<2)>>2]=1.0;b=b+1|0}while((b|0)!=64);z=B+4320|0;ze(z|0,B|0,2160)|0;jc(z,C,1024,192,13,s);z=0;i=D;return z|0}function hc(a,b,c,d,e,f,h){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;f=+f;h=h|0;var i=0.0,j=0.0,k=0.0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0;t=f*2.0;if((h|0)<=0)return;if(f>0.0)l=0;else{n=0;do{j=+g[a+512+(n<<2)>>2];k=+g[a+768+(n<<2)>>2];q=+g[b+(n<<2)>>2];r=+g[b+256+(n<<2)>>2];l=b+512+(n<<2)|0;f=+g[l>>2];m=b+768+(n<<2)|0;i=+g[m>>2];if(!(!(r<=q*1.5800000429153442)|!(q<=r*1.5800000429153442))){r=+g[c+(n<<2)>>2];q=r*k;r=r*j;q=iq?f:q;i=i>r?i:r}g[l>>2]=f>j?j:f;g[m>>2]=i>k?k:i;n=n+1|0}while((n|0)!=(h|0));return}do{r=+g[a+512+(l<<2)>>2];s=+g[a+768+(l<<2)>>2];i=+g[b+(l<<2)>>2];f=+g[b+256+(l<<2)>>2];n=b+512+(l<<2)|0;k=+g[n>>2];m=b+768+(l<<2)|0;j=+g[m>>2];if(!(f<=i*1.5800000429153442)|!(i<=f*1.5800000429153442))q=j;else{q=+g[c+(l<<2)>>2];p=q*s;q=q*r;p=jp?k:p;q=j>q?j:q}j=+g[d+(l<<2)>>2]*e;p=i>j?i:j;f=f>j?f:j;i=k>j?k:j;j=q>j?q:j;o=i+j;if(o>0.0?(u=t*(p>2]=p>r?r:p;g[m>>2]=q>s?s:q;l=l+1|0}while((l|0)!=(h|0));return}function ic(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0.0,k=0,l=0,m=0.0,n=0,o=0,p=0,q=0,r=0.0;q=c[a+2152>>2]|0;a:do if((q|0)>0){p=c[a+2148>>2]|0;o=0;j=0.0;h=0;i=0.0;while(1){k=c[a+2060+(h<<2)>>2]|0;if((o|0)<(((k|0)<(p|0)?k:p)|0)){l=(p|0)>(k|0)?k:p;k=o;do{j=+g[b+(k<<2)>>2]+j;i=+g[d+(k<<2)>>2]+i;k=k+1|0}while((k|0)!=(l|0));}else l=o;if((l|0)>=(p|0))break;r=+g[a+1112+(h<<2)>>2];m=1.0-r;k=b+(l<<2)|0;n=d+(l<<2)|0;i=+g[n>>2]*r+i;g[e+(h<<2)>>2]=+g[k>>2]*r+j;g[f+(h<<2)>>2]=i;h=h+1|0;if((h|0)<(q|0)){o=l+1|0;j=+g[k>>2]*m;i=+g[n>>2]*m}else break a}g[e+(h<<2)>>2]=j;g[f+(h<<2)>>2]=i;h=h+1|0}else h=0;while(0);if((h|0)>=(q|0))return;do{g[e+(h<<2)>>2]=0.0;g[f+(h<<2)>>2]=0.0;h=h+1|0}while((h|0)!=(q|0));return}function jc(a,b,d,e,f,h){a=a|0;b=+b;d=d|0;e=e|0;f=f|0;h=h|0;var j=0.0,k=0,l=0,m=0.0,n=0,o=0,p=0.0,q=0,r=0,s=0,t=0.0,u=0;s=i;i=i+2320|0;q=s+2052|0;r=s;j=+(e|0)*2.0;p=b/j;m=+(d|0);j=m/j;ve(r|0,0,2052)|0;m=b/m;o=(d|0)/2|0;k=0;e=0;while(1){if((e|0)>=64){d=e;break}t=+(k|0)*m;b=+Fd(t);g[q+(e<<2)>>2]=t;d=k;while(1)if((d|0)>(o|0)|!(+Fd(+(d|0)*m)-b<.34))break;else d=d+1|0;l=d-k|0;c[a+1716+(e<<2)>>2]=l;g[a+512+(e<<2)>>2]=(l|0)>0?1.0/+(l|0):0.0;l=e+1|0;if((d|0)>(k|0))do{c[r+(k<<2)>>2]=e;k=k+1|0}while((k|0)!=(d|0));else d=k;if((d|0)>(o|0)){k=o;d=l;break}else{k=d;e=l}}g[q+(d<<2)>>2]=+(k|0)*m;c[a+2152>>2]=f;l=a+2148|0;c[l>>2]=d;if((d|0)>0){e=0;d=0;while(1){k=c[a+1716+(e<<2)>>2]|0;b=+Fd(+(((k|0)/2|0)+d|0)*m);g[a+768+(e<<2)>>2]=+Q(10.0,+((1.0-+R(+(b<15.5?b*.2026833970057931:3.141592653589793)))*1.25+-2.5));e=e+1|0;if((e|0)<(c[l>>2]|0))d=k+d|0;else break}if((e|0)<64)n=13}else{e=0;n=13}if((n|0)==13)while(1){g[a+768+(e<<2)>>2]=1.0;e=e+1|0;if((e|0)==64)break;else n=13}if((f|0)<=0){i=s;return}e=0;do{d=c[h+(e<<2)>>2]|0;k=e;e=e+1|0;l=c[h+(e<<2)>>2]|0;u=~~+N(+((+(d|0)+-.5)*j+.5));n=~~+N(+((+(l|0)+-.5)*j+.5));n=c[r+(((n|0)>(o|0)?o:n)<<2)>>2]|0;c[a+1972+(k<<2)>>2]=((c[r+(((u|0)<0?0:u)<<2)>>2]|0)+n|0)/2|0;c[a+2060+(k<<2)>>2]=n;b=+g[q+(n<<2)>>2];b=(+(l|0)*p-b)/(+g[q+(n+1<<2)>>2]-b);if(!(b<0.0)){if(b>1.0)b=1.0}else b=0.0;g[a+1112+(k<<2)>>2]=b;b=+Fd(+(d|0)*p);g[a+1024+(k<<2)>>2]=+Q(10.0,+((1.0-+R(+(b<15.5?b*.2026833970057931:3.141592653589793)))*1.25+-2.5));}while((e|0)!=(f|0));i=s;return}function kc(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0;r=i;i=i+16384|0;q=r;ve(q|0,0,16384)|0;p=(d|0)>0;if(p){k=0;do{n=+g[e+(k<<2)>>2];o=+g[h+(k<<2)>>2];j=0;do{l=n-+g[e+(j<<2)>>2];l=l*(!(l>=0.0)?1.5:3.0);if(!(l>=.5)|!(l<=2.5))m=0.0;else{m=l+-.5;m=(m*m-m*2.0)*8.0}l=l+.474;l=l*7.5+15.811389-+P(+(l*l+1.0))*17.5;if(!(l<=-60.0))l=+Y(+((l+m)*.23025850929940458))*1.5130440282194817;else l=0.0;g[q+(k<<8)+(j<<2)>>2]=+g[f+(j<<2)>>2]*l*o;j=j+1|0}while((j|0)!=(d|0));k=k+1|0}while((k|0)!=(d|0));if(p){e=0;h=0;do{j=0;do{if(+g[q+(e<<8)+(j<<2)>>2]>0.0)break;j=j+1|0}while((j|0)<(d|0));c[b+(e<<3)>>2]=j;f=d;while(1){k=f+-1|0;if((f|0)<=1)break;if(+g[q+(e<<8)+(k<<2)>>2]>0.0)break;else f=k}c[b+(e<<3)+4>>2]=k;h=h+f-j|0;e=e+1|0}while((e|0)!=(d|0));h=h<<2}else h=0}else h=0;h=qe(h)|0;c[a>>2]=h;h=(h|0)==0;if(h|p^1){d=h<<31>>31;i=r;return d|0}else{f=0;h=0}do{j=c[b+(f<<3)>>2]|0;k=c[b+(f<<3)+4>>2]|0;if((j|0)<=(k|0)){ze((c[a>>2]|0)+(h<<2)|0,q+(f<<8)+(j<<2)|0,k+1-j<<2|0)|0;h=h+1+k-j|0}f=f+1|0}while((f|0)!=(d|0));h=0;i=r;return h|0}function lc(a){a=a|0;c[a+85824>>2]=(c[a+85756>>2]&4|0)==0?6:5;return}function mc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0.0;O=i;i=i+10592|0;F=O+5336|0;G=O+3032|0;I=O+2408|0;L=O+104|0;H=O+40|0;K=O+24|0;J=O+8|0;N=O;B=a+116|0;C=a+84744|0;c[C>>2]=c[B>>2];E=Cc(a,G)|0;M=a+76|0;c[G>>2]=(E|0)/(c[M>>2]|0)|0;E=a+112|0;c[C>>2]=c[E>>2];c[C>>2]=1;c[F>>2]=xb(a)|0;if((c[B>>2]|0)>=1){l=1;while(1){c[C>>2]=l;c[H+(l<<2)>>2]=Cc(a,F)|0;if((l|0)<(c[B>>2]|0))l=l+1|0;else break}}h=c[M>>2]|0;a:do if((h|0)>0){s=a+84756|0;u=a+72|0;f=a+84916|0;j=a+84908|0;k=a+84912|0;l=1;p=0;t=0;do{n=J+(t<<3)|0;m=wc(a,b,n,c[G>>2]|0,t,0)|0;if((c[s>>2]|0)==2){r=0;do{z=a+304+(t*10504|0)+(r<<2)|0;P=+g[z>>2];A=a+304+(t*10504|0)+5252+(r<<2)|0;o=+g[A>>2];g[z>>2]=(o+P)*.7071067690849304;g[A>>2]=(P-o)*.7071067690849304;r=r+1|0}while((r|0)!=576);xc(n,+g[d+(t<<2)>>2],c[G>>2]|0,m);}m=c[u>>2]|0;if((m|0)>0){q=0;do{r=a+304+(t*10504|0)+(q*5252|0)|0;o=+Y(+(3.5-+g[b+(t<<3)+(q<<2)>>2]*3.3333333333333335e-03))+1.0;if((c[a+304+(t*10504|0)+(q*5252|0)+4788>>2]|0)==2)o=+g[f>>2]-(2.56/o+-.14);else o=+g[k>>2]-(1.28/o+-.05);g[j>>2]=+Q(10.0,+(o*.1));rc(a,r);m=(zc(a,e+(t*976|0)+(q*488|0)|0,r,I+(t*312|0)+(q*156|0)|0)|0)==0;l=m?l:0;c[K+(t<<3)+(q<<2)>>2]=126;p=(c[J+(t<<3)+(q<<2)>>2]|0)+p|0;q=q+1|0;m=c[u>>2]|0}while((q|0)<(m|0));}t=t+1|0;h=c[M>>2]|0}while((t|0)<(h|0));s=m;if((h|0)>0){if((p|0)<=0){j=s;k=s;q=0;while(1){if((j|0)>0){m=0;do{j=K+(q<<3)+(m<<2)|0;f=c[J+(q<<3)+(m<<2)>>2]|0;if((c[j>>2]|0)>(f|0)){c[j>>2]=f;k=s}m=m+1|0}while((m|0)<(k|0));f=k}else{f=k;k=j}q=q+1|0;if((q|0)>=(h|0))break a;else{j=k;k=f}}}j=(s|0)>0;r=0;do{if(j){f=c[H+(c[B>>2]<<2)>>2]|0;n=(p|0)>(f|0);q=0;do{m=J+(r<<3)+(q<<2)|0;k=c[m>>2]|0;if(n){k=($(k,f)|0)/(p|0)|0;c[m>>2]=k}m=K+(r<<3)+(q<<2)|0;if((c[m>>2]|0)>(k|0))c[m>>2]=k;q=q+1|0}while((q|0)<(s|0));}r=r+1|0}while((r|0)<(h|0));}}else{u=a+72|0;l=1}while(0);v=(l|0)==0;w=a+124|0;x=a+85824|0;y=a+85096|0;z=a+85092|0;A=F+2304|0;d=0;m=0;b:while(1){if((d|0)>=(h|0)){if(!v?(c[w>>2]|0)==0:0)l=1;else l=c[E>>2]|0;c[C>>2]=l;k=c[B>>2]|0;c:do if((l|0)<(k|0))do{if((m|0)<=(c[H+(l<<2)>>2]|0))break c;l=l+1|0;c[C>>2]=l}while((l|0)<(k|0));while(0);e=(m|0)>(Cc(a,N)|0);h=c[M>>2]|0;l=(h|0)>0;if(!e)break;if(!l){d=0;m=0;continue}j=c[u>>2]|0;f=(j|0)>0;m=0;s=I;while(1){if(f){l=0;k=s;while(1){r=I+(m*312|0)+(l*156|0)|0;p=c[a+304+(m*10504|0)+(l*5252|0)+4856>>2]|0;if((p|0)>0){n=(p|0)>1;q=0;while(1){o=+(q|0);g[r>>2]=(o*o*5.991735537190083e-05+1.0)*+g[r>>2];q=q+1|0;if((q|0)==(p|0))break;else r=r+4|0}r=k+((n?p:1)<<2)|0}if((c[a+304+(m*10504|0)+(l*5252|0)+4788>>2]|0)==2?(D=c[a+304+(m*10504|0)+(l*5252|0)+4852>>2]|0,(D|0)<13):0){q=D;while(1){o=+(q|0);o=o*o*1.715976331360947e-04+1.0;b=r+4|0;g[r>>2]=o*+g[r>>2];e=r+8|0;g[b>>2]=o*+g[b>>2];g[e>>2]=+g[e>>2]*o;q=q+1|0;if((q|0)==13)break;else r=r+12|0}}P=+(c[K+(m<<3)+(l<<2)>>2]|0);e=J+(m<<3)+(l<<2)|0;o=+(c[e>>2]|0)*.9;c[e>>2]=~~(P>o?P:o);l=l+1|0;if((l|0)>=(j|0))break;else k=k+156|0}}m=m+1|0;if((m|0)<(h|0))s=s+312|0;else{d=0;m=0;continue b}}}if((c[u>>2]|0)>0){b=0;do{e=a+304+(d*10504|0)+(b*5252|0)|0;g[F>>2]=0.0;t=c[a+304+(d*10504|0)+(b*5252|0)+5208>>2]|0;g[a+304+(d*10504|0)+(b*5252|0)+4764>>2]=0.0;ve(L+(t<<2)|0,0,576-t<<2|0)|0;jb[c[x>>2]&7](e,L,t,F);if(+g[F>>2]>9.999999682655225e-21){l=(c[y>>2]|0)>>>1&1;k=a+304+(d*10504|0)+(b*5252|0)+4864|0;if((c[k>>2]|0)>0){r=0;do{c[a+84936+(r<<2)>>2]=l;r=r+1|0}while((r|0)<(c[k>>2]|0));}q=c[J+(d<<3)+(b<<2)>>2]|0;if(q){t=I+(d*312|0)+(b*156|0)|0;k=c[K+(d<<3)+(b<<2)>>2]|0;h=c[z>>2]|0;ve(A|0,0,2304)|0;f=q+-42|0;j=a+304+(d*10504|0)+(b*5252|0)+4768|0;s=k;l=q;r=0;q=(k+q|0)/2|0;while(1){c[z>>2]=(q|0)>(f|0)?0:h;if((sc(a,e,t,L,b,q)|0)>=1){p=q+32|0;n=l-p|0;q=(l+p|0)/2|0;if(!r)r=0;else{ze(e|0,F|0,5252)|0;ze(L|0,G|0,2304)|0;r=2}}else{q=c[j>>2]|0;ze(F|0,e|0,5252)|0;ze(G|0,L|0,2304)|0;q=q+-32|0;p=s;l=q;n=q-s|0;r=1;q=(q+s|0)/2|0}if((n|0)>12)s=p;else break}c[z>>2]=h;if((r|0)==2)ze(a+304+(d*10504|0)+(b*5252|0)+2304|0,A|0,2304)|0;if(c[y>>2]&1)tc(a,e,t,L);m=(c[j>>2]|0)+m+(c[a+304+(d*10504|0)+(b*5252|0)+4844>>2]|0)|0}}else ve(a+304+(d*10504|0)+(b*5252|0)+2304|0,0,2304)|0;b=b+1|0}while((b|0)<(c[u>>2]|0));h=c[M>>2]|0}d=d+1|0}if(!l){A=c[N>>2]|0;Fc(a,A);i=O;return}k=a+304|0;l=a+36|0;f=c[u>>2]|0;j=0;do{if((f|0)>0){h=0;do{f=a+304+(j*10504|0)+(h*5252|0)|0;td(a,j,h,k);if((c[l>>2]|0)==1)rd(a,f);Ec(a,f);h=h+1|0;f=c[u>>2]|0}while((h|0)<(f|0));h=c[M>>2]|0}j=j+1|0}while((j|0)<(h|0));A=c[N>>2]|0;Fc(a,A);i=O;return}function nc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0.0,G=0.0;E=i;i=i+9936|0;B=E;x=E+9932|0;s=E+9928|0;v=E+9304|0;y=E+88|0;A=E+24|0;w=E+8|0;D=E+4|0;ve(y|0,0,9216)|0;z=a+152|0;if(!(c[z>>2]|0)){f=a+116|0;d=a+84744|0;c[d>>2]=c[f>>2];Cc(a,s)|0;k=c[a+52144>>2]|0;c[d>>2]=c[a+112>>2];c[d>>2]=1;c[x>>2]=xb(a)|0;j=c[f>>2]|0;if((j|0)>=1){h=1;while(1){c[d>>2]=h;c[A+(h<<2)>>2]=Cc(a,x)|0;j=c[f>>2]|0;if((h|0)<(j|0))h=h+1|0;else break}}t=c[A+(j<<2)>>2]|0}else{c[a+84744>>2]=0;t=Cc(a,s)|0;c[A>>2]=t;k=c[a+52144>>2]|0}C=a+76|0;j=c[C>>2]|0;if((j|0)>0){o=a+84756|0;n=a+72|0;f=a+84912|0;q=a+84908|0;h=1;d=0;r=0;do{wc(a,b,w+(r<<3)|0,c[s>>2]|0,r,0)|0;if((c[o>>2]|0)==2){m=0;do{l=a+304+(r*10504|0)+(m<<2)|0;G=+g[l>>2];j=a+304+(r*10504|0)+5252+(m<<2)|0;F=+g[j>>2];g[l>>2]=(F+G)*.7071067690849304;g[j>>2]=(G-F)*.7071067690849304;m=m+1|0}while((m|0)!=576);}l=c[n>>2]|0;if((l|0)>0){p=0;do{l=a+304+(r*10504|0)+(p*5252|0)|0;g[q>>2]=+Q(10.0,+(+g[f>>2]*.1));rc(a,l);l=(zc(a,e+(r*976|0)+(p*488|0)|0,l,v+(r*312|0)+(p*156|0)|0)|0)==0;h=l?h:0;d=(c[w+(r<<3)+(p<<2)>>2]|0)+d|0;p=p+1|0;l=c[n>>2]|0}while((p|0)<(l|0));}r=r+1|0;j=c[C>>2]|0}while((r|0)<(j|0));o=l;if((j|0)>0){n=(d|0)>(t|0)&(d|0)>0;f=o;m=0;do{if((f|0)>0){l=0;do{if(n){f=w+(m<<3)+(l<<2)|0;c[f>>2]=($(c[f>>2]|0,t)|0)/(d|0)|0;f=o}l=l+1|0}while((l|0)<(f|0));}m=m+1|0}while((m|0)<(j|0));}if(!h)h=0;else u=21}else{h=1;u=21}if((u|0)==21)k=0;if((j|0)>0){n=a+72|0;m=a+85824|0;p=a+85096|0;f=c[n>>2]|0;o=0;do{if((f|0)>0){l=0;do{g[x>>2]=0.0;u=c[a+304+(o*10504|0)+(l*5252|0)+5208>>2]|0;g[a+304+(o*10504|0)+(l*5252|0)+4764>>2]=0.0;ve(y+(o*4608|0)+(l*2304|0)+(u<<2)|0,0,576-u<<2|0)|0;jb[c[m>>2]&7](a+304+(o*10504|0)+(l*5252|0)|0,y+(o*4608|0)+(l*2304|0)|0,u,x);if(+g[x>>2]>9.999999682655225e-21){j=(c[p>>2]|0)>>>1&1;f=a+304+(o*10504|0)+(l*5252|0)+4864|0;if((c[f>>2]|0)>0){d=0;do{c[a+84936+(d<<2)>>2]=j;d=d+1|0}while((d|0)<(c[f>>2]|0));}}else{ve(a+304+(o*10504|0)+(l*5252|0)+2304|0,0,2304)|0;c[w+(o<<3)+(l<<2)>>2]=0}l=l+1|0;f=c[n>>2]|0}while((l|0)<(f|0));j=c[C>>2]|0}o=o+1|0}while((o|0)<(j|0));}j=oa(a|0,y|0,v|0,w|0)|0;do if(!(c[z>>2]|0)){if((h|0)!=0?(c[a+124>>2]|0)==0:0)d=1;else d=c[a+112>>2]|0;f=c[a+116>>2]|0;a:do if((d|0)<(f|0))do{if((j|0)<=(c[A+(d<<2)>>2]|0))break a;d=d+1|0}while((d|0)<(f|0));while(0);d=(d|0)>(f|0)?f:d;if((k|0)<=0){c[a+84744>>2]=d;f=d;break}b:do if((f|0)>(d|0))do{if(((c[A+(f<<2)>>2]|0)-j|0)<=(k|0))break b;f=f+-1|0}while((f|0)>(d|0));while(0);c[a+84744>>2]=f}else{c[a+84744>>2]=0;f=0}while(0);if((j|0)>(c[A+(f<<2)>>2]|0)){Pd(a,11768,B);bb(-1);}Cc(a,D)|0;d=c[C>>2]|0;if((d|0)<=0){z=c[D>>2]|0;Fc(a,z);i=E;return}j=a+72|0;f=c[j>>2]|0;h=0;do{if((f|0)>0){d=0;do{Ec(a,a+304+(h*10504|0)+(d*5252|0)|0);d=d+1|0;f=c[j>>2]|0}while((d|0)<(f|0));d=c[C>>2]|0}h=h+1|0}while((h|0)<(d|0));z=c[D>>2]|0;Fc(a,z);i=E;return}function oc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0.0;I=i;i=i+2496|0;F=I+2484|0;D=I+2328|0;H=I+24|0;G=I+8|0;E=I;w=a+304|0;c[E>>2]=0;x=a+76|0;h=c[x>>2]|0;B=a+116|0;C=a+84744|0;c[C>>2]=c[B>>2];v=Cc(a,F)|0;c[C>>2]=1;z=xb(a)|0;k=c[a+24>>2]<<3;f=c[x>>2]|0;y=a+72|0;u=c[y>>2]|0;l=$(u,f)|0;z=(z-k|0)/(l|0)|0;h=$(h*576e3|0,c[a+108>>2]|0)|0;c[F>>2]=h;A=a+85096|0;if(c[A>>2]&1){h=~~(+(h|0)*1.09);c[F>>2]=h}r=(((h|0)/(c[a+64>>2]|0)|0)-k|0)/(l|0)|0;c[F>>2]=r;j=(11.0-+g[a+244>>2])*.012727272727272728+.93;j=j<.9?.8999999761581421:j;t=(f|0)>0;if(t){k=~~((j>1.0?1.0:j)*+(r|0));l=(r|0)/2|0;o=(r*3|0)/2|0;p=(u|0)>0;q=0;do{if(p){h=0;n=0;do{s=G+(q<<3)+(h<<2)|0;c[s>>2]=k;j=+g[b+(q<<3)+(h<<2)>>2];if(j>700.0){m=~~((j+-700.0)*.7142857142857143);m=((m|0)<(l|0)?(c[a+304+(q*10504|0)+(h*5252|0)+4788>>2]|0)==2:0)?l:m;m=((m|0)>(o|0)?o:(m|0)<0?0:m)+k|0;c[s>>2]=m}else m=k;if((m|0)>4095){c[s>>2]=4095;m=4095}n=m+n|0;h=h+1|0}while((h|0)<(u|0));if((n|0)>7680){m=0;do{s=G+(q<<3)+(m<<2)|0;c[s>>2]=((c[s>>2]|0)*7680|0)/(n|0)|0;m=m+1|0}while((m|0)<(u|0));}}q=q+1|0}while((q|0)<(f|0));}b=a+84756|0;if((c[b>>2]|0)==2)if(t){xc(G,+g[d>>2],$(r,u)|0,7680);f=c[x>>2]|0;if((f|0)>1){h=1;do{xc(G+(h<<3)|0,+g[d+(h<<2)>>2],$(c[F>>2]|0,c[y>>2]|0)|0,7680);h=h+1|0;f=c[x>>2]|0}while((h|0)<(f|0));d=17}else d=17}else d=30;else d=17;if((d|0)==17)if((f|0)>0){s=c[y>>2]|0;m=(s|0)>0;o=0;h=0;do{if(m){n=0;do{k=G+(o<<3)+(n<<2)|0;l=c[k>>2]|0;if((l|0)>4095){c[k>>2]=4095;l=4095}h=l+h|0;n=n+1|0}while((n|0)<(s|0));}o=o+1|0}while((o|0)<(f|0));if((h|0)>0&(h|0)>(v|0)){m=(s|0)>0;k=f;n=0;do{if(m){l=0;do{u=G+(n<<3)+(l<<2)|0;c[u>>2]=($(c[u>>2]|0,v)|0)/(h|0)|0;l=l+1|0}while((l|0)<(s|0));k=f}n=n+1|0}while((n|0)<(k|0));}if((f|0)>0){o=a+84912|0;f=a+84916|0;p=a+84908|0;q=a+85824|0;r=a+36|0;s=0;do{if((c[b>>2]|0)==2){l=0;do{u=a+304+(s*10504|0)+(l<<2)|0;J=+g[u>>2];v=a+304+(s*10504|0)+5252+(l<<2)|0;j=+g[v>>2];g[u>>2]=(j+J)*.7071067690849304;g[v>>2]=(J-j)*.7071067690849304;l=l+1|0}while((l|0)!=576);}if((c[y>>2]|0)>0){h=0;do{k=a+304+(s*10504|0)+(h*5252|0)|0;g[p>>2]=+Q(10.0,+(+g[((c[a+304+(s*10504|0)+(h*5252|0)+4788>>2]|0)==2?f:o)>>2]*.1));rc(a,k);g[F>>2]=0.0;v=c[a+304+(s*10504|0)+(h*5252|0)+5208>>2]|0;g[a+304+(s*10504|0)+(h*5252|0)+4764>>2]=0.0;ve(H+(v<<2)|0,0,576-v<<2|0)|0;jb[c[q>>2]&7](k,H,v,F);if(+g[F>>2]>9.999999682655225e-21){n=(c[A>>2]|0)>>>1&1;m=a+304+(s*10504|0)+(h*5252|0)+4864|0;if((c[m>>2]|0)>0){l=0;do{c[a+84936+(l<<2)>>2]=n;l=l+1|0}while((l|0)<(c[m>>2]|0));}m=G+(s<<3)+(h<<2)|0;if(!(zc(a,e+(s*976|0)+(h*488|0)|0,k,D)|0)){c[m>>2]=z;m=z}else m=c[m>>2]|0;sc(a,k,D,H,h,m)|0}else ve(a+304+(s*10504|0)+(h*5252|0)+2304|0,0,2304)|0;td(a,s,h,w);if((c[r>>2]|0)==1)rd(a,k);Ec(a,k);h=h+1|0}while((h|0)<(c[y>>2]|0));}s=s+1|0}while((s|0)<(c[x>>2]|0));}}else d=30;A=c[a+112>>2]|0;c[C>>2]=A;if((A|0)>(c[B>>2]|0)){B=c[E>>2]|0;Fc(a,B);i=I;return}while(1){if((Cc(a,E)|0)>-1){d=51;break}A=c[C>>2]|0;c[C>>2]=A+1;if((A|0)>=(c[B>>2]|0)){d=51;break}}if((d|0)==51){B=c[E>>2]|0;Fc(a,B);i=I;return}}function pc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0.0,E=0.0;C=i;i=i+2480|0;z=C+2476|0;x=C+2320|0;B=C+16|0;A=C+8|0;y=C;m=a+304|0;Cc(a,y)|0;n=a+76|0;if((c[n>>2]|0)<=0){e=c[y>>2]|0;Fc(a,e);i=C;return}q=a+84756|0;r=a+72|0;s=a+84912|0;t=a+84916|0;u=a+84908|0;v=a+85824|0;o=a+85096|0;p=a+36|0;w=0;do{f=wc(a,b,A,c[y>>2]|0,w,w)|0;if((c[q>>2]|0)==2){h=0;do{k=a+304+(w*10504|0)+(h<<2)|0;E=+g[k>>2];j=a+304+(w*10504|0)+5252+(h<<2)|0;D=+g[j>>2];g[k>>2]=(D+E)*.7071067690849304;g[j>>2]=(E-D)*.7071067690849304;h=h+1|0}while((h|0)!=576);xc(A,+g[d+(w<<2)>>2],c[y>>2]|0,f);}if((c[r>>2]|0)>0){k=0;do{f=a+304+(w*10504|0)+(k*5252|0)|0;g[u>>2]=+Q(10.0,+(+g[((c[a+304+(w*10504|0)+(k*5252|0)+4788>>2]|0)==2?t:s)>>2]*.1));rc(a,f);g[z>>2]=0.0;h=c[a+304+(w*10504|0)+(k*5252|0)+5208>>2]|0;g[a+304+(w*10504|0)+(k*5252|0)+4764>>2]=0.0;ve(B+(h<<2)|0,0,576-h<<2|0)|0;jb[c[v>>2]&7](f,B,h,z);if(+g[z>>2]>9.999999682655225e-21){h=(c[o>>2]|0)>>>1&1;j=a+304+(w*10504|0)+(k*5252|0)+4864|0;if((c[j>>2]|0)>0){l=0;do{c[a+84936+(l<<2)>>2]=h;l=l+1|0}while((l|0)<(c[j>>2]|0));}zc(a,e+(w*976|0)+(k*488|0)|0,f,x)|0;sc(a,f,x,B,k,c[A+(k<<2)>>2]|0)|0}else ve(a+304+(w*10504|0)+(k*5252|0)+2304|0,0,2304)|0;td(a,w,k,m);if((c[p>>2]|0)==1)rd(a,f);Ec(a,f);k=k+1|0}while((k|0)<(c[r>>2]|0));}w=w+1|0}while((w|0)<(c[n>>2]|0));e=c[y>>2]|0;Fc(a,e);i=C;return}function qc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0,h=0,i=0.0;g[d>>2]=0.0;if((c|0)<0)return;f=a+4764|0;e=0.0;h=0;while(1){i=+O(+(+g[a+(h<<2)>>2]));g[d>>2]=e+i;e=i;e=+P(+(+P(+e)*e));g[b+(h<<2)>>2]=e;if(e>+g[f>>2])g[f>>2]=e;if((h|0)==(c|0))break;e=+g[d>>2];h=h+1|0}return}function rc(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,j=0,k=0,l=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0;s=i;i=i+2304|0;r=s;c[b+4768>>2]=0;c[b+4772>>2]=0;c[b+4776>>2]=0;c[b+4780>>2]=210;c[b+4784>>2]=0;p=a+64|0;e=b+4796|0;d=e+52|0;do{c[e>>2]=0;e=e+4|0}while((e|0)<(d|0));j=b+4848|0;if((c[p>>2]|0)<8001){c[j>>2]=17;f=17;e=9;d=17}else{c[j>>2]=21;f=(c[a+85092>>2]|0)!=0?22:21;e=12;d=21}m=b+4852|0;c[m>>2]=e;o=b+4856|0;c[o>>2]=f;h=b+4864|0;c[h>>2]=f;n=b+4860|0;c[n>>2]=d;k=b+4868|0;c[k>>2]=11;f=0;do{e=f;f=f+1|0;c[b+4872+(e<<2)>>2]=(c[a+21360+(f<<2)>>2]|0)-(c[a+21360+(e<<2)>>2]|0);c[b+5028+(e<<2)>>2]=3}while((f|0)!=22);q=b+4788|0;if((c[q>>2]|0)==2){c[m>>2]=0;c[j>>2]=0;if(!(c[b+4792>>2]|0)){d=0;e=0}else{c[m>>2]=3;e=(c[a+76>>2]<<1)+4|0;c[j>>2]=e;d=3}if((c[p>>2]|0)<8001){f=((9-d|0)*3|0)+e|0;c[h>>2]=f}else{c[h>>2]=((((c[a+85092>>2]|0)!=0?13:12)-d|0)*3|0)+e;f=((12-d|0)*3|0)+e|0}c[n>>2]=f;c[k>>2]=f+-18;c[o>>2]=e;f=c[a+21360+(e<<2)>>2]|0;ze(r|0,b|0,2304)|0;n=c[a+21452+(d<<2)>>2]|0;f=b+(f<<2)|0;h=d;do{h=h+1|0;m=n;n=c[a+21452+(h<<2)>>2]|0;if((n|0)>(m|0)){o=n-m|0;k=f;j=m;while(1){c[k>>2]=c[r+(j*3<<2)>>2];j=j+1|0;if((j|0)==(n|0))break;else k=k+4|0}k=f+(o<<2)|0;j=m;while(1){c[k>>2]=c[r+((j*3|0)+1<<2)>>2];j=j+1|0;if((j|0)==(n|0))break;else k=k+4|0}k=f+(o<<1<<2)|0;while(1){c[k>>2]=c[r+((m*3|0)+2<<2)>>2];m=m+1|0;if((m|0)==(n|0))break;else k=k+4|0}f=f+(o*3<<2)|0}}while((h|0)!=13);while(1){n=d;d=d+1|0;n=(c[a+21452+(d<<2)>>2]|0)-(c[a+21452+(n<<2)>>2]|0)|0;p=e+2|0;c[b+4872+(p<<2)>>2]=n;o=e+1|0;c[b+4872+(o<<2)>>2]=n;c[b+4872+(e<<2)>>2]=n;c[b+5028+(e<<2)>>2]=0;c[b+5028+(o<<2)>>2]=1;c[b+5028+(p<<2)>>2]=2;if((d|0)==13)break;else e=e+3|0}}c[b+5184>>2]=0;c[b+5188>>2]=11824;p=b+5192|0;c[p>>2]=0;c[p+4>>2]=0;c[p+8>>2]=0;c[p+12>>2]=0;c[b+5208>>2]=575;ve(b+4608|0,0,156)|0;p=c[a+104>>2]|0;if((p|0)==0|(p|0)==3|(p|0)==4|(p|0)==1){i=s;return}r=c[a+85796>>2]|0;if((c[q>>2]|0)!=2){h=r+8|0;j=r+20|0;k=a+84852|0;m=5;a:while(1){d=c[a+21508+(m<<2)>>2]|0;f=c[a+21508+(m+1<<2)>>2]|0;l=+yc(+g[h>>2],+g[r+164+(m<<2)>>2],+g[j>>2],0.0);t=+g[k>>2];l=t>9.999999960041972e-13?t*l:l;if((f|0)>(d|0))do{f=f+-1|0;e=b+(f<<2)|0;if(!(+O(+(+g[e>>2]))>2]=0.0}while((f|0)>(d|0));if((m|0)>0)m=m+-1|0;else{d=32;break}}if((d|0)==32){i=s;return}}d=a+21500|0;p=a+21504|0;o=a+21536|0;n=r+8|0;f=r+20|0;e=a+84904|0;h=5;b:while(1){m=c[a+21536+(h<<2)>>2]|0;j=((c[d>>2]|0)*3|0)+(m-(c[o>>2]|0))|0;m=(c[a+21536+(h+1<<2)>>2]|0)-m|0;l=+yc(+g[n>>2],+g[r+188+(h<<2)>>2],+g[f>>2],0.0);t=+g[e>>2];l=t>9.999999960041972e-13?t*l:l;if((m|0)>0){k=m+j|0;do{k=k+-1|0;m=b+(k<<2)|0;if(!(+O(+(+g[m>>2]))>2]=0.0}while((k|0)>(j|0));}if((h|0)>0)h=h+-1|0;else{h=5;break}}c:while(1){j=c[d>>2]|0;m=c[a+21536+(h<<2)>>2]|0;j=(c[p>>2]|0)-j+(j*3|0)+(m-(c[o>>2]|0))|0;m=(c[a+21536+(h+1<<2)>>2]|0)-m|0;l=+yc(+g[n>>2],+g[r+188+(h<<2)>>2],+g[f>>2],0.0);t=+g[e>>2];l=t>9.999999960041972e-13?t*l:l;if((m|0)>0){k=m+j|0;do{k=k+-1|0;m=b+(k<<2)|0;if(!(+O(+(+g[m>>2]))>2]=0.0}while((k|0)>(j|0));}if((h|0)>0)h=h+-1|0;else{h=5;break}}d:while(1){j=c[d>>2]|0;m=c[a+21536+(h<<2)>>2]|0;j=((c[p>>2]|0)-j<<1)+(j*3|0)+(m-(c[o>>2]|0))|0;m=(c[a+21536+(h+1<<2)>>2]|0)-m|0;l=+yc(+g[n>>2],+g[r+188+(h<<2)>>2],+g[f>>2],0.0);t=+g[e>>2];l=t>9.999999960041972e-13?t*l:l;if((m|0)>0){k=m+j|0;do{k=k+-1|0;m=b+(k<<2)|0;if(!(+O(+(+g[m>>2]))>2]=0.0}while((k|0)>(j|0));}if((h|0)>0)h=h+-1|0;else{d=32;break}}if((d|0)==32){i=s;return}}function sc(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0;ra=i;i=i+8256|0;ma=ra+2992|0;qa=ra+688|0;na=ra+528|0;la=ra+504|0;pa=ra+24|0;oa=ra;s=a+84928+(f<<2)|0;j=c[s>>2]|0;p=a+84920+(f<<2)|0;q=c[p>>2]|0;r=b+4780|0;c[r>>2]=q;o=h-(c[b+4844>>2]|0)|0;f=sd(a,e,b,0)|0;if(!((j|0)==1|(f|0)==(o|0))){l=0;k=0;while(1){if((f|0)>(o|0)){n=(l|0)==2?1:k;k=(n|0)==0?j:(j|0)/2|0;j=k;l=1}else{n=(l|0)==1?1:k;k=(n|0)==0?j:(j|0)/2|0;j=k;l=2;k=0-k|0}f=(c[r>>2]|0)+k|0;k=(f|0)<0;f=k?0:f;m=(f|0)>255;c[r>>2]=m?255:f;f=sd(a,e,b,0)|0;if((j|0)==1|(f|0)==(o|0))break;else k=k|m?1:n}}a:do if((f|0)>(o|0))do{j=c[r>>2]|0;if((j|0)>=255)break a;c[r>>2]=j+1;f=sd(a,e,b,0)|0}while((f|0)>(o|0));while(0);c[s>>2]=(q-(c[r>>2]|0)|0)>3?4:2;c[p>>2]=c[r>>2];ja=b+4768|0;c[ja>>2]=f;C=a+28|0;if(!(c[C>>2]|0)){ea=100;i=ra;return ea|0}ve(pa|0,0,476)|0;Ac(b,d,na,la,pa)|0;D=la+20|0;c[D>>2]=c[ja>>2];ze(ma|0,b|0,5252)|0;ze(qa|0,e|0,2304)|0;E=a+85096|0;F=a+85092|0;G=ma+4836|0;H=ma+4860|0;I=a+40|0;J=ma+4764|0;K=ma+4844|0;L=ma+4768|0;M=ma+4780|0;N=la+12|0;Q=oa+20|0;R=b+4788|0;S=a+84|0;T=a+88|0;U=oa+16|0;V=la+16|0;W=oa+8|0;X=la+8|0;Y=a+48|0;Z=oa+12|0;_=oa+4|0;aa=la+4|0;ba=ma+4864|0;ca=a+84936|0;da=ma+4832|0;ea=ma+4788|0;fa=a+32|0;ga=ma+4848|0;ha=ma+4868|0;ia=0;B=0;s=9999999;while(1){z=(ia|0)==1?2:1;A=(ia|0)!=0;y=0;b:while(1){r=(c[E>>2]&2|0)==0?3:20;l=c[H>>2]|0;if(c[F>>2]|0){if(+g[na+(l<<2)>>2]>1.0){ka=167;break}if((c[ea>>2]|0)==2){if(+g[na+(l+1<<2)>>2]>1.0){ka=167;break}if(+g[na+(l+2<<2)>>2]>1.0){ka=167;break}}}u=(c[G>>2]|0)==0?1.2968395948410034:1.6817928552627563;k=(l|0)>0;if(k){f=0;x=0.0;do{v=+g[na+(f<<2)>>2];x=x>2]|0;j=(f|0)==3?z:f;do if((j|0)!=2)if((j|0)==1){w=x;if(x>1.0){v=+O(+(+P(+w)));x=x==-t?t:v;break}else{x=w*.95;break}}else if(x>1.0)x=1.0;else x=x*.95;while(0);if(k){j=l;l=0;m=0}else{ka=167;break}do{k=c[ma+4872+(m<<2)>>2]|0;l=k+l|0;if(!(+g[na+(m<<2)>>2]>2]&2|0)!=0?(p=a+84936+(m<<2)|0,q=(c[p>>2]|0)==0,c[p>>2]=q&1,!q):0)?(c[I>>2]|0)==2:0){f=2;break}q=ma+4608+(m<<2)|0;c[q>>2]=(c[q>>2]|0)+1;if((k|0)>0){w=+g[J>>2];f=0-k|0;while(1){q=e+(f+l<<2)|0;v=+g[q>>2]*u;g[q>>2]=v;if(v>w){g[J>>2]=v;w=v}if((f|0)<-1)f=f+1|0;else break}}f=c[I>>2]|0;if((f|0)==2){f=2;break}j=c[H>>2]|0}m=m+1|0}while((m|0)<(j|0));j=c[H>>2]|0;if((j|0)>0)k=0;else{ka=167;break}while(1){if((c[ma+4608+(k<<2)>>2]|0)==(0-(c[ma+4808+(c[ma+5028+(k<<2)>>2]<<2)>>2]|0)|0))break;k=k+1|0;if((k|0)>=(j|0))break b}if(ud(a,ma)|0){if((c[C>>2]|0)<=1){ka=167;break}ve(ca|0,0,156)|0;c:do if(!(c[G>>2]|0)){if((c[H>>2]|0)>0){l=0;m=0;do{j=c[ma+4872+(m<<2)>>2]|0;k=ma+4608+(m<<2)|0;f=c[k>>2]|0;if(c[da>>2]|0)f=(c[12112+(m<<2)>>2]|0)+f|0;l=j+l|0;do if(f&1){f=f+1|0;if((j|0)<=0)break;x=+g[J>>2];j=0-j|0;while(1){q=e+(j+l<<2)|0;w=+g[q>>2]*1.2968395948410034;g[q>>2]=w;if(w>x){g[J>>2]=w;x=w}if((j|0)<-1)j=j+1|0;else break}}while(0);c[k>>2]=f>>1;m=m+1|0}while((m|0)<(c[H>>2]|0));}c[da>>2]=0;c[G>>2]=1}else{if((c[ea>>2]|0)!=2){ka=167;break b}if((c[fa>>2]|0)<=0){ka=167;break b}f=c[ga>>2]|0;if((f|0)>0){j=0;while(1){if((c[ma+4608+(j<<2)>>2]|0)>15){ka=167;break b}j=j+1|0;if((j|0)>=(f|0)){p=3;q=-1;o=0;break}}}else{p=3;q=-1;o=0}while(1){k=o+f|0;l=c[ha>>2]|0;if((k|0)<(l|0)){n=p+f|0;m=(l|0)>(n|0);j=q-f|0;f=0;do{sa=c[ma+4608+(k<<2)>>2]|0;f=(f|0)<(sa|0)?sa:f;k=k+3|0}while((k|0)<(l|0));k=(m?l:n)+j|0;l=f;k=k+n-((k>>>0)%3|0)|0}else l=0;f=c[H>>2]|0;if((k|0)<(f|0)){j=0;do{n=c[ma+4608+(k<<2)>>2]|0;j=(j|0)<(n|0)?n:j;k=k+3|0}while((k|0)<(f|0));}else j=0;do if((l|0)<16&(j|0)<8)j=o+1|0;else{f=ma+4808+(o<<2)|0;j=c[f>>2]|0;if((j|0)>6){ka=167;break b}c[f>>2]=j+1;k=c[ga>>2]|0;l=c[a+21360+(k<<2)>>2]|0;k=k+o|0;f=c[H>>2]|0;j=o+1|0;if((k|0)<(f|0)){o=2-o|0;do{n=c[ma+4872+(k<<2)>>2]|0;f=ma+4608+(k<<2)|0;m=(c[f>>2]|0)-(4>>>(c[G>>2]|0))|0;if((m|0)>-1){c[f>>2]=m;l=(n*3|0)+l|0}else{c[f>>2]=0;v=+g[79704+((m<<(c[G>>2]|0)+1)+210<<2)>>2];f=($(n,j)|0)+l|0;if((n|0)>0){x=+g[J>>2];l=0-n|0;while(1){m=e+(l+f<<2)|0;w=+g[m>>2]*v;g[m>>2]=w;if(w>x){g[J>>2]=w;x=w}if((l|0)<-1)l=l+1|0;else break}}l=f+($(n,o)|0)|0}k=k+3|0;f=c[H>>2]|0}while((k|0)<(f|0));}v=+g[20128];k=c[ma+4872+(k<<2)>>2]|0;l=($(k,j)|0)+l|0;if((k|0)<=0)break;x=+g[J>>2];k=0-k|0;while(1){o=e+(l+k<<2)|0;w=+g[o>>2]*v;g[o>>2]=w;if(w>x){g[J>>2]=w;x=w}if((k|0)<-1)k=k+1|0;else break}}while(0);if((j|0)>=3)break;f=c[ga>>2]|0;p=p+1|0;q=q+-1|0;o=j}if((f|0)>0)j=0;else{ka=167;break b}while(1){if((c[ma+4608+(j<<2)>>2]|0)==(0-(c[ma+4808+(c[ma+5028+(j<<2)>>2]<<2)>>2]|0)|0))break c;j=j+1|0;if((j|0)>=(f|0)){ka=167;break b}}}while(0);if(ud(a,ma)|0){ka=167;break}}k=(c[G>>2]|0)==0?255:254;j=h-(c[K>>2]|0)|0;if((j|0)<1){ka=167;break}q=sd(a,e,ma,pa)|0;c[L>>2]=q;f=c[M>>2]|0;if((q|0)>(j|0)&(f|0)<=(k|0))do{c[M>>2]=f+1;q=sd(a,e,ma,pa)|0;c[L>>2]=q;f=c[M>>2]|0}while((q|0)>(j|0)&(f|0)<=(k|0));if((f|0)>(k|0)){ka=167;break}if(!(c[N>>2]|0)){q=sd(a,e,ma,pa)|0;c[L>>2]=q;f=c[M>>2]|0;if((q|0)>(s|0)&(f|0)<=(k|0))do{c[M>>2]=f+1;q=sd(a,e,ma,pa)|0;c[L>>2]=q;f=c[M>>2]|0}while((q|0)>(s|0)&(f|0)<=(k|0));if((f|0)>(k|0)){ka=167;break}}Ac(ma,d,na,oa,pa)|0;k=c[L>>2]|0;c[Q>>2]=k;d:do switch(c[((c[R>>2]|0)==2?T:S)>>2]|0){case 1:{u=+g[W>>2];ka=118;break}case 6:{v=+g[oa>>2];u=+g[la>>2];do if(!(vx){if(!(v<=w*9.999999974752427e-07)){f=0;break}}else if(!(v<=x*9.999999974752427e-07)){f=0;break}v=+g[W>>2];u=+g[X>>2];if(!(vw){if(!(v<=x*9.999999974752427e-07)){f=0;break}}else if(!(v<=w*9.999999974752427e-07)){f=0;break}f=+g[_>>2]<=+g[aa>>2]}else f=1}else f=1;while(0);f=f&1;break}case 8:{if((c[ba>>2]|0)>0){u=1.0e-37;f=0;do{v=+g[na+(f<<2)>>2];u=+Wd(v*v*.632*v+.368)*.30102999566398114+u;f=f+1|0}while((f|0)<(c[ba>>2]|0));}else u=1.0e-37;u=u<1.0e-20?9.999999682655225e-21:u;g[W>>2]=u;ka=118;break}case 7:{if((c[Z>>2]|0)<(c[N>>2]|0))f=1;else f=+g[oa>>2]<+g[la>>2];f=f&1;break}case 3:{if(+g[_>>2]<+g[aa>>2])f=+g[W>>2]<+g[X>>2];else f=0;f=f&1;break}case 5:{v=+g[oa>>2];u=+g[la>>2];do if(vw){if(!(v<=x*9.999999974752427e-07)){f=0;break}}else if(!(v<=w*9.999999974752427e-07)){f=0;break}f=+g[_>>2]<+g[aa>>2]}while(0);f=f&1;break}case 2:{f=+g[_>>2]<+g[aa>>2]&1;break}case 0:{f=c[Z>>2]|0;j=c[N>>2]|0;do if((f|0)>=(j|0))if((f|0)==(j|0)){v=+g[oa>>2];u=+g[la>>2];if(vx){if(!(u<=w*9.999999974752427e-07)){f=0;break}}else if(!(u<=x*9.999999974752427e-07)){f=0;break}f=+g[_>>2]<+g[aa>>2]}}else f=0;else f=1;while(0);f=f&1;break}case 4:{x=+g[W>>2];do if(x<=0.0){w=+g[X>>2];u=w;if(!(u>.2)){v=x;f=u>v+-.2;if(w<0.0&f?+g[_>>2]<+g[aa>>2]:0){f=1;break}if(!(!(w>0.0)|f^1)?+g[_>>2]<+g[la>>2]+ +g[aa>>2]:0)f=1;else ka=130}else f=1}else{v=x;ka=130}while(0);do if((ka|0)==130){ka=0;if(x>0.0){u=+g[X>>2];if(u>-.05&u>v+-.1?+g[oa>>2]+ +g[_>>2]<+g[la>>2]+ +g[aa>>2]:0){f=1;break}if(u>-.1&u>v+-.15)f=+g[oa>>2]*2.0+ +g[_>>2]<+g[la>>2]*2.0+ +g[aa>>2];else f=0}else f=0}while(0);f=f&1;break}default:{if((c[N>>2]|0)>0){f=c[U>>2]|0;j=c[V>>2]|0;if((f|0)!=(j|0)){f=(f|0)<=(j|0)&1;break d}f=(k|0)<(c[D>>2]|0)&1;break d}u=+g[W>>2];if(u<0.0)f=u*10.0+ +(k|0)<=+(c[D>>2]|0)+ +g[X>>2]*10.0;else f=0;f=f&1}}while(0);if((ka|0)==118){ka=0;f=u<+g[X>>2]&1}j=(c[N>>2]|0)==0;if(j){if(!f)f=0;else f=(c[Q>>2]|0)<(c[D>>2]|0);f=f&1}do if(!f)if(!(c[Y>>2]|0)){f=y+1|0;if((y|0)>=(r|0)&j){ka=167;break b}j=A&(c[I>>2]|0)==3;if((y|0)>29&j){ka=167;break b}if(!j)break;if(((c[M>>2]|0)-B|0)>15){ka=167;break b}}else f=y;else{s=c[ja>>2]|0;c[la>>2]=c[oa>>2];c[la+4>>2]=c[oa+4>>2];c[la+8>>2]=c[oa+8>>2];c[la+12>>2]=c[oa+12>>2];c[la+16>>2]=c[oa+16>>2];c[la+20>>2]=c[oa+20>>2];ze(b|0,ma|0,5252)|0;ze(qa|0,e|0,2304)|0;f=0}while(0);if(((c[G>>2]|0)+(c[M>>2]|0)|0)<255)y=f;else{ka=167;break}}if((ka|0)==167){ka=0;f=c[I>>2]|0}if(!((ia|0)==0&(f|0)==3))break;ze(ma|0,b|0,5252)|0;ze(e|0,qa|0,2304)|0;ia=1;B=c[M>>2]|0}ea=c[a+104>>2]|0;if(!((ea|0)==1|(ea|0)==4|(ea|0)==2)){if(c[E>>2]&1)tc(a,b,d,e);}else ze(e|0,qa|0,2304)|0;ea=c[N>>2]|0;i=ra;return ea|0}function tc(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,k=0,l=0.0,m=0,n=0,o=0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0;y=i;i=i+192|0;x=y+24|0;h=y;f=c[a+85096>>2]|0;if(!(f&4)){if(!((f&128|0)==0?(c[b+4788>>2]|0)!=2:0)){i=y;return}}else if(f&128){i=y;return}Ac(b,d,x,h,0)|0;h=0;do{if(!(c[b+2304+(h<<2)>>2]|0))j=0.0;else j=+O(+(+g[b+(h<<2)>>2]));g[e+(h<<2)>>2]=j;h=h+1|0}while((h|0)!=576);u=b+4864|0;v=0;w=(c[b+4788>>2]|0)==2?6:8;do{f=c[b+4872+(w<<2)>>2]|0;t=v;v=f+v|0;k=x+(w<<2)|0;a:do if(!(+g[k>>2]>=1.0)){Yd(e+(t<<2)|0,f,4,1);j=+g[e+(v+-1<<2)>>2];l=+O(+j);if(j!=j|0.0!=0.0|j==0.0){if(j==0.0)break}else if(l<=l*9.999999974752427e-07)break;s=(1.0-+g[k>>2])*+g[d+(w<<2)>>2];h=0;while(1){m=h+1|0;b:do if((m|0)<(f|0)){p=+g[e+(h+v-f<<2)>>2];r=+O(+p);k=h+t|0;q=r*9.999999974752427e-07;n=m;m=1;while(1){l=+g[e+(k+m<<2)>>2];j=+O(+l);l=+O(+(p-l));if(r>j){if(!(l<=q)){o=1;break b}}else if(!(l<=j*9.999999974752427e-07)){o=1;break b}m=m+1|0;n=m+h|0;if((n|0)>=(f|0)){o=0;break}}}else{n=m;o=0;k=t+h|0;m=1}while(0);l=+g[e+(k<<2)>>2];l=l*l*+(m|0);if(s>2];j=+O(+l);if(l!=l|0.0!=0.0|l==0.0){if(l==0.0)break}else if(j<=j*9.999999974752427e-07)break;while(1){h=v-f|0;if(+O(+(+g[b+(h<<2)>>2]))<=l)c[b+2304+(h<<2)>>2]=0;if((f|0)>1)f=f+-1|0;else break}}}while(0);w=w+1|0}while((w|0)<(c[u>>2]|0));c[b+4768>>2]=qd(a,b,0)|0;i=y;return}function uc(a,b){a=a|0;b=b|0;var c=0.0,d=0.0;d=+g[a>>2];c=+g[b>>2];return (d>c?1:(d>31)|0}function vc(a){a=a|0;var b=0,d=0.0,e=0,f=0,h=0,i=0,j=0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0;b=a+8|0;if(c[b>>2]|0)return;c[b>>2]=1;c[a+21312>>2]=0;n=a+16|0;o=a+85796|0;p=c[o>>2]|0;k=+(c[a+64>>2]|0);d=k*8.680555620230734e-04;l=a+224|0;m=a+196|0;h=0;do{b=c[a+21360+(h<<2)>>2]|0;f=h;h=h+1|0;e=c[a+21360+(h<<2)>>2]|0;f=p+24+(f<<2)|0;g[f>>2]=9999999933815812510711506.0e12;if((b|0)<(e|0))do{r=+Ed(n,+(b|0)*d);q=+g[l>>2];q=+Q(10.0,+((+g[m>>2]+r+(q>0.0?-q:-100.0))*.10000000149011612));r=+g[f>>2];g[f>>2]=r>2]|0;e=h;h=h+1|0;f=c[a+21508+(h<<2)>>2]|0;e=p+164+(e<<2)|0;g[e>>2]=9999999933815812510711506.0e12;if((b|0)<(f|0))do{r=+Ed(n,+(b|0)*d);q=+g[l>>2];q=+Q(10.0,+((+g[m>>2]+r+(q>0.0?-q:-100.0))*.10000000149011612));r=+g[e>>2];g[e>>2]=r>2]|0;b=0;do{j=a+21452+(b<<2)|0;i=b;b=b+1|0;e=a+21452+(b<<2)|0;h=c[e>>2]|0;i=p+112+(i<<2)|0;g[i>>2]=9999999933815812510711506.0e12;if((f|0)<(h|0)){do{q=+Ed(n,+(f|0)*k);d=+g[l>>2];d=+Q(10.0,+((+g[m>>2]+q+(d>0.0?-d:-100.0))*.10000000149011612));q=+g[i>>2];d=q>2]=d;f=f+1|0}while((f|0)!=(h|0));f=c[e>>2]|0}else{f=h;d=9999999933815812510711506.0e12}g[i>>2]=+(f-(c[j>>2]|0)|0)*d}while((b|0)!=13);e=a+21504|0;b=a+21500|0;j=0;do{f=c[a+21536+(j<<2)>>2]|0;i=j;j=j+1|0;h=c[a+21536+(j<<2)>>2]|0;i=p+188+(i<<2)|0;g[i>>2]=9999999933815812510711506.0e12;if((f|0)<(h|0))do{q=+Ed(n,+(f|0)*k);d=+g[l>>2];d=+Q(10.0,+((+g[m>>2]+q+(d>0.0?-d:-100.0))*.10000000149011612));q=+g[i>>2];d=q>2]=d;f=f+1|0}while((f|0)!=(h|0));else d=9999999933815812510711506.0e12;g[i>>2]=+((c[e>>2]|0)-(c[b>>2]|0)|0)*d}while((j|0)!=6);if(c[a+220>>2]|0){g[p+24>>2]=9.999999682655225e-21;g[p+28>>2]=9.999999682655225e-21;g[p+32>>2]=9.999999682655225e-21;g[p+36>>2]=9.999999682655225e-21;g[p+40>>2]=9.999999682655225e-21;g[p+44>>2]=9.999999682655225e-21;g[p+48>>2]=9.999999682655225e-21;g[p+52>>2]=9.999999682655225e-21;g[p+56>>2]=9.999999682655225e-21;g[p+60>>2]=9.999999682655225e-21;g[p+64>>2]=9.999999682655225e-21;g[p+68>>2]=9.999999682655225e-21;g[p+72>>2]=9.999999682655225e-21;g[p+76>>2]=9.999999682655225e-21;g[p+80>>2]=9.999999682655225e-21;g[p+84>>2]=9.999999682655225e-21;g[p+88>>2]=9.999999682655225e-21;g[p+92>>2]=9.999999682655225e-21;g[p+96>>2]=9.999999682655225e-21;g[p+100>>2]=9.999999682655225e-21;g[p+104>>2]=9.999999682655225e-21;g[p+108>>2]=9.999999682655225e-21;g[p+164>>2]=9.999999682655225e-21;g[p+168>>2]=9.999999682655225e-21;g[p+172>>2]=9.999999682655225e-21;g[p+176>>2]=9.999999682655225e-21;g[p+180>>2]=9.999999682655225e-21;g[p+184>>2]=9.999999682655225e-21;g[p+112>>2]=9.999999682655225e-21;g[p+116>>2]=9.999999682655225e-21;g[p+120>>2]=9.999999682655225e-21;g[p+124>>2]=9.999999682655225e-21;g[p+128>>2]=9.999999682655225e-21;g[p+132>>2]=9.999999682655225e-21;g[p+136>>2]=9.999999682655225e-21;g[p+140>>2]=9.999999682655225e-21;g[p+144>>2]=9.999999682655225e-21;g[p+148>>2]=9.999999682655225e-21;g[p+152>>2]=9.999999682655225e-21;g[p+156>>2]=9.999999682655225e-21;g[p+160>>2]=9.999999682655225e-21;g[p+188>>2]=9.999999682655225e-21;g[p+192>>2]=9.999999682655225e-21;g[p+196>>2]=9.999999682655225e-21;g[p+200>>2]=9.999999682655225e-21;g[p+204>>2]=9.999999682655225e-21;g[p+208>>2]=9.999999682655225e-21}k=+Ed(n,-1.0);d=+g[l>>2];d=+de(+Q(10.0,+((+g[m>>2]+k+(d>0.0?-d:-100.0))*.10000000149011612)))*10.0;g[(c[o>>2]|0)+20>>2]=d;g[3510]=0.0;b=1;do{g[14040+(b<<2)>>2]=+Q(+(+(b|0)),1.3333333333333333);b=b+1|0}while((b|0)!=8208);g[11718]=0.0;d=+g[3510];b=1;do{k=d;d=+g[14040+(b<<2)>>2];g[46872+(b<<2)>>2]=+(b|0)+-.5-+Q(+((d+k)*.5),.75);b=b+1|0}while((b|0)!=8208);b=0;do{g[79704+(b<<2)>>2]=+ae(+(b+-210|0)*-.1875);b=b+1|0}while((b|0)!=257);b=0;do{g[80736+(b<<2)>>2]=+ae(+(b+-326|0)*.25);b=b+1|0}while((b|0)!=374);vd(a);lc(a);j=a+232|0;d=+Q(10.0,+((+g[j>>2]+-.5)*.10000000149011612));g[a+84768>>2]=d;g[a+84772>>2]=d;g[a+84776>>2]=d;g[a+84780>>2]=d;g[a+84784>>2]=d;g[a+84788>>2]=d;g[a+84792>>2]=d;l=a+228|0;d=+Q(10.0,+((+g[l>>2]+-.25)*.10000000149011612));g[a+84796>>2]=d;g[a+84800>>2]=d;g[a+84804>>2]=d;g[a+84808>>2]=d;g[a+84812>>2]=d;g[a+84816>>2]=d;g[a+84820>>2]=d;m=a+236|0;d=+Q(10.0,+((+g[m>>2]+-.02500000037252903)*.10000000149011612));g[a+84824>>2]=d;g[a+84828>>2]=d;g[a+84832>>2]=d;g[a+84836>>2]=d;g[a+84840>>2]=d;g[a+84844>>2]=d;g[a+84848>>2]=d;n=a+240|0;g[a+84852>>2]=+Q(10.0,+((+g[n>>2]+.5)*.10000000149011612));d=+Q(10.0,+((+g[j>>2]+-2.0)*.10000000149011612));g[a+84856>>2]=d;g[a+84860>>2]=d;g[a+84864>>2]=d;d=+Q(10.0,+((+g[l>>2]+-1.0)*.10000000149011612));g[a+84868>>2]=d;g[a+84872>>2]=d;g[a+84876>>2]=d;g[a+84880>>2]=d;d=+Q(10.0,+((+g[m>>2]+-.05000000074505806)*.10000000149011612));g[a+84884>>2]=d;g[a+84888>>2]=d;g[a+84892>>2]=d;g[a+84896>>2]=d;g[a+84900>>2]=d;g[a+84904>>2]=+Q(10.0,+((+g[n>>2]+.5)*.10000000149011612));return}function wc(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+16|0;o=r+12|0;m=r+8|0;n=r;c[o>>2]=0;q=n;c[q>>2]=0;c[q+4>>2]=0;Dc(a,e,m,o,h);m=c[m>>2]|0;h=c[o>>2]|0;q=h+m|0;q=(q|0)>7680?7680:q;p=a+72|0;j=c[p>>2]|0;if((j|0)<=0){i=r;return q|0}l=(e*3|0)/4|0;a=0;k=0;do{j=(m|0)/(j|0)|0;j=(j|0)>4095?4095:j;c[d+(k<<2)>>2]=j;e=~~(+(j|0)*+g[b+(f<<3)+(k<<2)>>2]*1.4285714285714286e-03-+(j|0));e=(e|0)>(l|0)?l:e;e=(e|0)<0?0:e;if((e+j|0)>4095){e=4095-j|0;e=(e|0)<0?0:e}c[n+(k<<2)>>2]=e;a=e+a|0;k=k+1|0;j=c[p>>2]|0}while((k|0)<(j|0));if((a|0)>0&(a|0)>(h|0))if((j|0)>0){e=0;do{b=n+(e<<2)|0;c[b>>2]=($(c[b>>2]|0,h)|0)/(a|0)|0;e=e+1|0}while((e|0)<(j|0));}else{i=r;return q|0}if((j|0)>0)j=0;else{i=r;return q|0}do{e=c[n+(j<<2)>>2]|0;b=d+(j<<2)|0;c[b>>2]=(c[b>>2]|0)+e;h=h-e|0;j=j+1|0;e=c[p>>2]|0}while((j|0)<(e|0));a=e;c[o>>2]=h;e=(a|0)>0;if(e){h=0;j=0}else{i=r;return q|0}do{h=(c[d+(j<<2)>>2]|0)+h|0;j=j+1|0}while((j|0)<(a|0));if((h|0)<7681|e^1){i=r;return q|0}else j=0;do{n=d+(j<<2)|0;c[n>>2]=((c[n>>2]|0)*7680|0)/(h|0)|0;j=j+1|0}while((j|0)<(c[p>>2]|0));i=r;return q|0}function xc(a,b,d,e){a=a|0;b=+b;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;b=(.5-b)*.66;b=b<0.0?0.0:b;f=c[a>>2]|0;j=a+4|0;i=c[j>>2]|0;g=~~(+(i+f|0)*(b>.5?.25:b*.5));h=4095-f|0;g=(g|0)>(h|0)?h:g;g=(g|0)<0?0:g;do if((i|0)>124){h=i-g|0;if((h|0)<=125){f=f+-125+i|0;c[a>>2]=f;c[j>>2]=125;h=125;break}if((f|0)<(d|0)){f=g+f|0;c[a>>2]=f}c[j>>2]=h}else h=i;while(0);g=h+f|0;if((g|0)<=(e|0))return;c[a>>2]=($(f,e)|0)/(g|0)|0;c[j>>2]=($(h,e)|0)/(g|0)|0;return}function yc(a,b,c,d){a=+a;b=+b;c=+c;d=+d;a=a*a;b=+Wd(b)*3.0102999566398116-c;if(a>9.999999682655225e-21)a=+Wd(a)*.03333343265598758+1.0;else a=0.0;return +(+Q(10.0,+((c+90.30873107910156+(d<1.0?-94.82444763183594:-d)+(a<0.0?0.0:a)*b)*.10000000149011612)));}function zc(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0.0,t=0,u=0,v=0,w=0.0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0.0,G=0.0,H=0.0;E=c[b+85796>>2]|0;t=e+4856|0;if((c[t>>2]|0)>0){u=E+8|0;v=E+20|0;x=b+224|0;h=0;i=0;r=0;while(1){k=+g[u>>2];m=+g[v>>2];n=+g[x>>2];k=k*k;o=+Wd(+g[E+24+(i<<2)>>2])*3.0102999566398116-m;if(k>9.999999682655225e-21)l=+Wd(k)*.03333343265598758+1.0;else l=0.0;l=+Q(10.0,+((m+90.30873107910156+(n<1.0?-94.82444763183594:-n)+(l<0.0?0.0:l)*o)*.10000000149011612));s=+g[b+84768+(i<<2)>>2];l=s*l;q=c[e+4872+(i<<2)>>2]|0;m=l/+(q|0);if((q|0)>0){n=0.0;j=r;p=0;o=2.220446049250313e-16;while(1){k=+g[e+(j<<2)>>2];k=k*k;n=k+n;o=(kl&1)+h|0;k=n>2];if(l>9.999999960041972e-13?(w=s*(+g[d+(i<<2)>>2]*n/l),k2.220446049250313e-16?k:2.220446049250313e-16;a[e+5212+i>>0]=n>k+9.9999998245167e-15&1;j=f+4|0;g[f>>2]=k;i=i+1|0;if((i|0)<(c[t>>2]|0))f=j;else{p=j;q=i;break}}}else{p=f;h=0;q=0;r=0}i=575;while(1){if(+O(+(+g[e+(i<<2)>>2]))>9.999999960041972e-13)break;if((i|0)>1)i=i+-1|0;else{i=0;break}}j=(c[e+4788>>2]|0)==2;if(j)i=i+5-((i|0)%6|0)|0;else i=i|1;if((c[b+85092>>2]|0)==0?(y=c[b+64>>2]|0,(y|0)<44e3):0){f=(y|0)<8001;if(j)f=(c[b+21452+((f?9:12)<<2)>>2]|0)*3|0;else f=c[b+21360+((f?17:21)<<2)>>2]|0;v=f+-1|0;i=(i|0)>(v|0)?v:i}c[e+5208>>2]=i;v=e+4864|0;if((q|0)>=(c[v>>2]|0)){v=h;return v|0}z=E+8|0;A=E+20|0;B=b+224|0;C=b+92|0;D=b+85800|0;i=r;u=c[e+4852>>2]|0;while(1){n=+g[z>>2];m=+g[A>>2];l=+g[B>>2];n=n*n;k=+Wd(+g[E+112+(u<<2)>>2])*3.0102999566398116-m;if(n>9.999999682655225e-21)o=+Wd(n)*.03333343265598758+1.0;else o=0.0;w=+Q(10.0,+((m+90.30873107910156+(l<1.0?-94.82444763183594:-l)+(o<0.0?0.0:o)*k)*.10000000149011612));x=b+84856+(u<<2)|0;l=+g[x>>2];w=l*w;y=c[e+4872+(q<<2)>>2]|0;s=w/+(y|0);if((y|0)>0){n=0.0;j=i;f=0;o=2.220446049250313e-16;while(1){k=+g[e+(j<<2)>>2];k=k*k;n=k+n;o=(kw&1)+h|0;o=m>2];if(n>9.999999960041972e-13?(F=l*(+g[d+88+(u*12|0)>>2]*m/n),o2.220446049250313e-16?o:2.220446049250313e-16;a[e+5212+q>>0]=m>n+9.9999998245167e-15&1;i=p+4|0;g[p>>2]=n;n=0.0;j=r;f=0;o=2.220446049250313e-16;while(1){k=+g[e+(j<<2)>>2];k=k*k;n=k+n;o=(kw&1)+t|0;o=m>2];if(n>9.999999960041972e-13?(G=+g[x>>2]*(+g[d+88+(u*12|0)+4>>2]*m/n),o2.220446049250313e-16?o:2.220446049250313e-16;a[q+1+(e+5212)>>0]=m>n+9.9999998245167e-15&1;r=p+8|0;g[i>>2]=n;n=0.0;j=h;f=0;o=2.220446049250313e-16;while(1){k=+g[e+(j<<2)>>2];k=k*k;n=k+n;o=(kw&1)+t|0;l=n>2];if(o>9.999999960041972e-13?(H=+g[x>>2]*(+g[d+88+(u*12|0)+8>>2]*n/o),l2.220446049250313e-16?l:2.220446049250313e-16;a[q+2+(e+5212)>>0]=n>o+9.9999998245167e-15&1;g[r>>2]=o}else{j=w<0.0&1;o=w>0.0?0.0:w>2.220446049250313e-16?w:2.220446049250313e-16;k=(o<0.0?+g[d+332+(u*12|0)>>2]>9.999999960041972e-13:0)?0.0:o;k=k>2.220446049250313e-16?k:2.220446049250313e-16;a[e+5212+q>>0]=k+9.9999998245167e-15<0.0&1;g[p>>2]=k;k=(o<0.0?+g[d+332+(u*12|0)+4>>2]>9.999999960041972e-13:0)?0.0:o;k=k>2.220446049250313e-16?k:2.220446049250313e-16;a[q+1+(e+5212)>>0]=k+9.9999998245167e-15<0.0&1;g[p+4>>2]=k;o=(o<0.0?+g[d+332+(u*12|0)+8>>2]>9.999999960041972e-13:0)?0.0:o;o=o>2.220446049250313e-16?o:2.220446049250313e-16;a[q+2+(e+5212)>>0]=o+9.9999998245167e-15<0.0&1;g[p+8>>2]=o;h=j+(j+(j+h))|0}f=p+8|0;if(c[C>>2]|0){n=+g[p>>2];j=p+4|0;k=+g[j>>2];if(n>k){k=+g[(c[D>>2]|0)+6496>>2]*(n-k)+k;g[j>>2]=k;o=+g[f>>2]}if(k>o)g[f>>2]=+g[(c[D>>2]|0)+6496>>2]*(k-o)+o}p=p+12|0;q=q+3|0;if((q|0)>=(c[v>>2]|0))break;else u=u+1|0}return h|0}function Ac(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,j=0.0,k=0.0,l=0,m=0.0,n=0,o=0.0,p=0,q=0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0.0,K=0,L=0.0;I=i;i=i+16|0;H=I;x=e+16|0;c[x>>2]=0;y=a+4864|0;if((c[y>>2]|0)<=0){h=-20.0;G=0;r=0.0;j=0.0;E=e+12|0;c[E>>2]=G;E=e+4|0;g[E>>2]=j;g[e>>2]=r;E=e+8|0;g[E>>2]=h;i=I;return G|0}C=a+4780|0;D=a+4832|0;E=a+4836|0;F=(f|0)!=0;G=a+5208|0;z=a+4776|0;A=a+4772|0;B=H+4|0;w=d;s=0;k=-20.0;d=0;j=0.0;u=a+4608|0;v=0;h=0.0;while(1){n=c[C>>2]|0;if(!(c[D>>2]|0))l=0;else l=c[12112+(v<<2)>>2]|0;q=n-(l+(c[u>>2]|0)<<(c[E>>2]|0)+1)-(c[a+4808+(c[a+5028+(v<<2)>>2]<<2)>>2]<<3)|0;u=u+4|0;r=1.0/+g[b>>2];b=b+4|0;if(F?(c[f+8+(v<<2)>>2]|0)==(q|0):0){l=(c[a+4872+(v<<2)>>2]|0)+s|0;m=+g[f+164+(v<<2)>>2]*r;o=+g[f+320+(v<<2)>>2];t=27}else t=8;do if((t|0)==8){t=0;o=+g[80736+(q+116<<2)>>2];p=c[a+4872+(v<<2)>>2]|0;n=p>>1;l=c[G>>2]|0;if((p+s|0)>(l|0)){n=l-s|0;if((n|0)>-1)n=n+1>>1;else n=0}do if((s|0)>(c[z>>2]|0))if(!n){l=s;m=0.0}else{l=n;p=s;m=0.0;while(1){l=l+-1|0;J=+g[a+(p<<2)>>2];o=+g[a+(p+1<<2)>>2];m=J*J+m+o*o;if(!l)break;else p=p+2|0}l=(n<<1)+s|0}else if((s|0)>(c[A>>2]|0)){g[H>>2]=0.0;g[B>>2]=o;if(!n){l=s;m=0.0;break}else{l=n;p=s;m=0.0}while(1){l=l+-1|0;J=+O(+(+g[a+(p<<2)>>2]));J=J-+g[H+(c[a+2304+(p<<2)>>2]<<2)>>2];K=p+1|0;o=+O(+(+g[a+(K<<2)>>2]));o=o-+g[H+(c[a+2304+(K<<2)>>2]<<2)>>2];m=J*J+m+o*o;if(!l)break;else p=p+2|0}l=(n<<1)+s|0;break}else{if(!n){l=s;m=0.0;break}else{p=n;l=s;m=0.0}while(1){p=p+-1|0;L=+O(+(+g[a+(l<<2)>>2]));L=L-+g[14040+(c[a+2304+(l<<2)>>2]<<2)>>2]*o;K=l+1|0;J=+O(+(+g[a+(K<<2)>>2]));J=J-+g[14040+(c[a+2304+(K<<2)>>2]<<2)>>2]*o;m=L*L+m+J*J;if(!p)break;else l=l+2|0}l=(n<<1)+s|0;break}while(0);if(F){c[f+8+(v<<2)>>2]=q;g[f+164+(v<<2)>>2]=m}m=m*r;o=+Wd(m>9.999999682655225e-21?m:9.999999682655225e-21)*.30102999566398114;if(F){g[f+320+(v<<2)>>2]=o;n=c[C>>2]|0;t=27;break}else{g[w>>2]=m;break}}while(0);if((t|0)==27){g[w>>2]=m;c[f>>2]=n}h=o+h;if(o>0.0){t=~~(o*10.0+.5);t=(t|0)>1?t:1;t=$(t,t)|0;c[x>>2]=(c[x>>2]|0)+t;d=d+1|0;j=o+j}k=k>o?k:o;v=v+1|0;if((v|0)>=(c[y>>2]|0))break;else{w=w+4|0;s=l}}G=e+12|0;c[G>>2]=d;G=e+4|0;g[G>>2]=h;g[e>>2]=j;G=e+8|0;g[G>>2]=k;i=I;return d|0}function Bc(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,j=0,k=0.0,l=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0.0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0.0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0;ca=i;i=i+496|0;Y=ca+340|0;aa=ca+184|0;Z=ca+160|0;_=ca;L=a+76|0;d=c[L>>2]|0;if((d|0)<=0){i=ca;return}R=a+72|0;S=a+85804|0;T=a+212|0;U=a+85796|0;K=a+21360|0;V=a+216|0;W=Z+12|0;X=Z+8|0;M=Z+4|0;O=Z+16|0;e=c[R>>2]|0;J=0;do{if((e|0)>0){H=(J|0)==1;I=0;do{j=a+304+(J*10504|0)+(I*5252|0)|0;G=a+304+(J*10504|0)+(I*5252|0)+4608|0;ze(_|0,G|0,156)|0;if(H?(P=a+10808+(I*5252|0)+4848|0,Q=c[P>>2]|0,(Q|0)>0):0){e=Q;f=0;do{d=a+10808+(I*5252|0)+4608+(f<<2)|0;if((c[d>>2]|0)<0){c[d>>2]=c[a+304+(I*5252|0)+4608+(f<<2)>>2];e=c[P>>2]|0}f=f+1|0}while((f|0)<(e|0));}F=(c[a+304+(J*10504|0)+(I*5252|0)+4836>>2]|0)==0?.5:1.0;zc(a,b+(J*976|0)+(I*488|0)|0,j,Y)|0;Ac(j,Y,aa,Z,0)|0;e=c[a+304+(J*10504|0)+(I*5252|0)+4848>>2]|0;r=(c[a+304+(J*10504|0)+(I*5252|0)+4788>>2]|0)==2;if(!r?(c[a+304+(J*10504|0)+(I*5252|0)+4792>>2]|0)==0:0){e=22;ba=13}else if((e|0)>0)ba=13;else{j=0;e=0}if((ba|0)==13){ba=0;d=c[S>>2]|0;m=c[U>>2]|0;n=(c[a+304+(J*10504|0)+(I*5252|0)+4832>>2]|0)!=0;o=c[K>>2]|0;j=0;p=0;do{q=p;p=p+1|0;f=o;o=c[a+21360+(p<<2)>>2]|0;f=o-f|0;if((j|0)<(o|0)){k=0.0;do{l=+g[a+304+(J*10504|0)+(I*5252|0)+(j<<2)>>2];k=l*l+k;j=j+1|0}while((j|0)!=(o|0));j=o}else k=0.0;l=+(f|0);k=k/l;h[d+190712+(J*704|0)+(I*176|0)+(q<<3)>>3]=k*999999986991104.0;h[d+201208+(J*352|0)+(I*176|0)+(q<<3)>>3]=+g[Y+(q<<2)>>2]*999999986991104.0*+g[aa+(q<<2)>>2]/l;l=+g[b+(J*976|0)+(I*488|0)+244+(q<<2)>>2];if(l>0.0)k=(c[T>>2]|0)==0?k/l:0.0;else k=0.0;l=+g[b+(J*976|0)+(I*488|0)+(q<<2)>>2]*k;k=+g[m+24+(q<<2)>>2];h[d+189304+(J*704|0)+(I*176|0)+(q<<3)>>3]=(l>k?l:k)*999999986991104.0;f=d+199160+(J*352|0)+(I*176|0)+(q<<3)|0;h[f>>3]=0.0;if(n&(q|0)>10){k=-(F*+(c[12112+(q<<2)>>2]|0));h[f>>3]=k}else k=0.0;if((q|0)<21)h[f>>3]=k-+(c[a+304+(J*10504|0)+(I*5252|0)+4608+(q<<2)>>2]|0)*F}while((p|0)!=(e|0));}if(r?(N=c[a+304+(J*10504|0)+(I*5252|0)+4852>>2]|0,(N|0)<13):0){y=c[S>>2]|0;z=(c[T>>2]|0)==0;A=c[U>>2]|0;B=a+304+(J*10504|0)+(I*5252|0)+4808|0;C=a+304+(J*10504|0)+(I*5252|0)+4812|0;D=a+304+(J*10504|0)+(I*5252|0)+4816|0;E=c[a+21452+(N<<2)>>2]|0;x=N;while(1){v=x;x=x+1|0;n=E;E=c[a+21452+(x<<2)>>2]|0;m=E-n|0;t=+(m|0);s=v*3|0;u=+g[A+112+(v<<2)>>2];w=(v|0)<12;if((E|0)<=(n|0)){h[y+194616+(J*1248|0)+(I*312|0)+(s<<3)>>3]=9.999999747378752e-06;h[y+201912+(J*624|0)+(I*312|0)+(s<<3)>>3]=+g[Y+(e<<2)>>2]*999999986991104.0*+g[aa+(e<<2)>>2]/t;l=+g[b+(J*976|0)+(I*488|0)+332+(v*12|0)>>2];if(z?(c[V>>2]|0)==0:0)l=l>0.0?9.999999682655225e-21/l:0.0;else l=0.0;l=+g[b+(J*976|0)+(I*488|0)+88+(v*12|0)>>2]*l;h[y+192120+(J*1248|0)+(I*312|0)+(s<<3)>>3]=(l>u?l:u)*999999986991104.0;l=+(c[B>>2]|0)*-2.0;f=y+199864+(J*624|0)+(I*312|0)+(s<<3)|0;h[f>>3]=l;if(w)h[f>>3]=l-+(c[a+304+(J*10504|0)+(I*5252|0)+4608+(e<<2)>>2]|0)*F;q=e+1|0;f=s+1|0;h[y+194616+(J*1248|0)+(I*312|0)+(f<<3)>>3]=9.999999747378752e-06;h[y+201912+(J*624|0)+(I*312|0)+(f<<3)>>3]=+g[Y+(q<<2)>>2]*999999986991104.0*+g[aa+(q<<2)>>2]/t;l=+g[b+(J*976|0)+(I*488|0)+332+(v*12|0)+4>>2];if(z?(c[V>>2]|0)==0:0)l=l>0.0?9.999999682655225e-21/l:0.0;else l=0.0;l=+g[b+(J*976|0)+(I*488|0)+88+(v*12|0)+4>>2]*l;h[y+192120+(J*1248|0)+(I*312|0)+(f<<3)>>3]=(l>u?l:u)*999999986991104.0;l=+(c[C>>2]|0)*-2.0;f=y+199864+(J*624|0)+(I*312|0)+(f<<3)|0;h[f>>3]=l;if(w)h[f>>3]=l-+(c[a+304+(J*10504|0)+(I*5252|0)+4608+(q<<2)>>2]|0)*F;q=e+2|0;f=s+2|0;h[y+194616+(J*1248|0)+(I*312|0)+(f<<3)>>3]=9.999999747378752e-06;h[y+201912+(J*624|0)+(I*312|0)+(f<<3)>>3]=+g[Y+(q<<2)>>2]*999999986991104.0*+g[aa+(q<<2)>>2]/t;l=+g[b+(J*976|0)+(I*488|0)+332+(v*12|0)+8>>2];if(z?(c[V>>2]|0)==0:0)l=l>0.0?9.999999682655225e-21/l:0.0;else l=0.0;l=+g[b+(J*976|0)+(I*488|0)+88+(v*12|0)+8>>2]*l;h[y+192120+(J*1248|0)+(I*312|0)+(f<<3)>>3]=(l>u?l:u)*999999986991104.0;l=+(c[D>>2]|0)*-2.0;f=y+199864+(J*624|0)+(I*312|0)+(f<<3)|0;h[f>>3]=l;if(w)h[f>>3]=l-+(c[a+304+(J*10504|0)+(I*5252|0)+4608+(q<<2)>>2]|0)*F}else{o=E*3|0;f=0;r=j;d=e;while(1){l=0.0;q=r;p=n;while(1){k=+g[a+304+(J*10504|0)+(I*5252|0)+(q<<2)>>2];l=k*k+l;p=p+1|0;if((p|0)==(E|0))break;else q=q+1|0}r=r+m|0;l=l/t;l=l>1.0e-20?l:9.999999682655225e-21;q=f+s|0;h[y+194616+(J*1248|0)+(I*312|0)+(q<<3)>>3]=l*999999986991104.0;h[y+201912+(J*624|0)+(I*312|0)+(q<<3)>>3]=+g[Y+(d<<2)>>2]*999999986991104.0*+g[aa+(d<<2)>>2]/t;k=+g[b+(J*976|0)+(I*488|0)+332+(v*12|0)+(f<<2)>>2];if(z?(c[V>>2]|0)==0:0)l=k>0.0?l/k:0.0;else l=0.0;l=+g[b+(J*976|0)+(I*488|0)+88+(v*12|0)+(f<<2)>>2]*l;h[y+192120+(J*1248|0)+(I*312|0)+(q<<3)>>3]=(l>u?l:u)*999999986991104.0;l=+(c[a+304+(J*10504|0)+(I*5252|0)+4808+(f<<2)>>2]|0)*-2.0;q=y+199864+(J*624|0)+(I*312|0)+(q<<3)|0;h[q>>3]=l;if(w)h[q>>3]=l-+(c[a+304+(J*10504|0)+(I*5252|0)+4608+(d<<2)>>2]|0)*F;f=f+1|0;if((f|0)==3)break;else d=d+1|0}j=j+o+($(n,-3)|0)|0}if((x|0)==13)break;else e=e+3|0}}e=c[S>>2]|0;c[e+201112+(J<<3)+(I<<2)>>2]=c[a+304+(J*10504|0)+(I*5252|0)+4780>>2];q=a+304+(J*10504|0)+(I*5252|0)+4844|0;c[e+203400+(J<<3)+(I<<2)>>2]=(c[q>>2]|0)+(c[a+304+(J*10504|0)+(I*5252|0)+4768>>2]|0);c[e+203416+(J<<3)+(I<<2)>>2]=c[q>>2];c[e+203160+(J<<3)+(I<<2)>>2]=c[W>>2];h[e+203208+(J<<4)+(I<<3)>>3]=+g[X>>2]*10.0;h[e+203240+(J<<4)+(I<<3)>>3]=+g[Z>>2]*10.0;h[e+203176+(J<<4)+(I<<3)>>3]=+g[M>>2]*10.0;c[e+203272+(J<<3)+(I<<2)>>2]=c[O>>2];ze(G|0,_|0,156)|0;I=I+1|0;e=c[R>>2]|0}while((I|0)<(e|0));d=c[L>>2]|0}J=J+1|0}while((J|0)<(d|0));i=ca;return}function Cc(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;e=xb(a)|0;f=c[a+76>>2]|0;h=(e-(c[a+24>>2]<<3)|0)/(f|0)|0;i=(f<<11)+-8|0;g=c[a+148>>2]|0;e=g-e|0;d=a+52144|0;e=(e|0)>(i|0)?i:e;c[d>>2]=e;if(!((e|0)>=0?(c[a+144>>2]|0)==0:0)){c[d>>2]=0;e=0}d=$(f,h)|0;f=c[a+52140>>2]|0;e=((f|0)<(e|0)?f:e)+d|0;e=(e|0)>(g|0)?g:e;c[a+21320>>2]=0;d=c[a+85804>>2]|0;if(!d){c[b>>2]=h;return e|0}c[d+203484>>2]=(h|0)/2|0;c[d+203488>>2]=f;c[b>>2]=h;return e|0}function Dc(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;k=c[a+52144>>2]|0;j=(c[a+52140>>2]|0)+((f|0)==0?0:b)|0;f=a+85096|0;h=c[f>>2]|0;i=h&1;if(!i)g=k;else g=~~(+(k|0)*.9);g=g*9|0;if((j*10|0)<=(g|0)){c[f>>2]=h&127;if(!(c[a+144>>2]|i)){g=0;f=~~(+(b|0)*.9);}else{g=0;f=b}}else{i=j-((g|0)/10|0)|0;c[f>>2]=h|128;g=i;f=i+b|0}h=(k*6|0)/10|0;g=((j|0)<(h|0)?j:h)-g|0;c[d>>2]=f;c[e>>2]=(g|0)<0?0:g;return}function Ec(a,b){a=a|0;b=b|0;a=a+52140|0;c[a>>2]=(c[a>>2]|0)-((c[b+4844>>2]|0)+(c[b+4768>>2]|0));return}function Fc(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;f=$(c[a+76>>2]|0,b)|0;b=a+52140|0;f=(c[b>>2]|0)+f|0;d=(f|0)%8|0;g=f-d-(c[a+52144>>2]|0)|0;d=((g|0)>0?g:0)+d|0;g=a+21312|0;i=c[g>>2]|0;h=i<<3;h=(((h|0)<(d|0)?h:d)|0)/8|0;e=h<<3;c[a+21320>>2]=e;d=d-e|0;c[g>>2]=i-h;c[a+21324>>2]=d;c[b>>2]=f-e-d;return}function Gc(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){a=-1;return a|0}c[a+12>>2]=b;a=0;return a|0}function Hc(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){a=-1;return a|0}if((b|0)>2|(b|0)==0){a=-1;return a|0}c[a+8>>2]=b;a=0;return a|0}function Ic(a,b){a=a|0;b=+b;if(!(Tb(a)|0)){a=-1;return a|0}g[a+20>>2]=b;a=0;return a|0}function Jc(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+20>>2];return +b}function Kc(a,b){a=a|0;b=b|0;if(b>>>0>4|(Tb(a)|0)==0){a=-1;return a|0}c[a+48>>2]=b;a=0;return a|0}function Lc(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){b=-1;return b|0}c[a+96>>2]=b;if((b|0)<=320){b=0;return b|0}c[a+128>>2]=1;b=0;return b|0}function Mc(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){a=-1;return a|0}c[a+132>>2]=b;a=0;return a|0}function Nc(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){a=-1;return a|0}c[a+136>>2]=b;a=0;return a|0}function Oc(a){a=a|0;if(!(Tb(a)|0)){a=0;return a|0}a=c[a+132>>2]|0;return a|0}function Pc(a){a=a|0;if(!(Tb(a)|0)){a=0;return a|0}a=c[a+136>>2]|0;return a|0}function Qc(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){b=-1;return b|0}c[a+140>>2]=b;b=0;return b|0}function Rc(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){b=-1;return b|0}c[a+148>>2]=b;b=0;return b|0}function Sc(a){a=a|0;if(!(Tb(a)|0)){a=0;return a|0}a=c[a+148>>2]|0;return a|0}function Tc(a,b){a=a|0;b=b|0;if(b>>>0>4|(Tb(a)|0)==0){b=-1;return b|0}c[a+156>>2]=b;b=0;return b|0}function Uc(a){a=a|0;if(!(Tb(a)|0)){a=0;return a|0}a=c[a+156>>2]|0;return a|0}function Vc(a,b){a=a|0;b=b|0;var d=0,e=0;if(!(Tb(a)|0)){b=-1;return b|0}e=(b|0)<0?0:b;d=(e|0)>9;c[a+164>>2]=d?9:e;g[a+160>>2]=0.0;b=d?-1:b>>31;return b|0}function Wc(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){b=-1;return b|0}c[a+168>>2]=b;b=0;return b|0}function Xc(a){a=a|0;if(!(Tb(a)|0)){a=0;return a|0}a=c[a+168>>2]|0;return a|0}function Yc(a,b){a=a|0;b=+b;if(!(Tb(a)|0)){a=-1;return a|0}g[a+200>>2]=b;a=0;return a|0}function Zc(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+200>>2];return +b}function _c(a,b){a=a|0;b=+b;if(!(Tb(a)|0)){a=-1;return a|0}g[a+204>>2]=b;a=0;return a|0}function $c(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+204>>2];return +b}function ad(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){b=-1;return b|0}c[a+220>>2]=b;b=0;return b|0}function bd(a,b){a=a|0;b=+b;if(!(Tb(a)|0)){a=-1;return a|0}g[a+224>>2]=b;a=0;return a|0}function cd(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+224>>2];return +b}function dd(a,b){a=a|0;b=+b;if(!(Tb(a)|0)){a=-1;return a|0}g[a+228>>2]=b;a=0;return a|0}function ed(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+228>>2];return +b}function fd(a,b){a=a|0;b=+b;if(!(Tb(a)|0)){a=-1;return a|0}g[a+236>>2]=b;a=0;return a|0}function gd(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+236>>2];return +b}function hd(a,b){a=a|0;b=+b;if(!(b<=1.0)|(!(b>=0.0)|(Tb(a)|0)==0)){a=-1;return a|0}g[a+248>>2]=b;a=0;return a|0}function id(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+248>>2];return +b}function jd(a,b){a=a|0;b=b|0;if(!(Tb(a)|0)){a=-1;return a|0}c[a+84>>2]=(b|0)!=0?2:1;a=0;return a|0}function kd(a,b){a=a|0;b=+b;if(!(Tb(a)|0)){a=-1;return a|0}g[a+264>>2]=b;a=0;return a|0}function ld(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+264>>2];return +b}function md(a,b){a=a|0;b=+b;if(!(Tb(a)|0)){a=-1;return a|0}g[a+268>>2]=b;a=0;return a|0}function nd(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+268>>2];return +b}function od(a,b){a=a|0;b=+b;if(!(Tb(a)|0))return;g[a+252>>2]=b;return}function pd(a){a=a|0;var b=0.0;if(!(Tb(a)|0)){b=0.0;return +b}b=+g[a+252>>2];return +b}function qd(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;t=i;i=i+16|0;s=t;c[s>>2]=0;q=e+2304|0;h=(c[e+5208>>2]|0)+2&-2;h=(h|0)>576?576:h;r=(f|0)!=0;if(r)c[f+4>>2]=0;while(1){if((h|0)<=1){p=4;break}g=h+-2|0;if(!(c[e+2304+(g<<2)>>2]|c[e+2304+(h+-1<<2)>>2]))h=g;else{p=6;break}}if((p|0)==4){c[e+4776>>2]=h;p=9}else if((p|0)==6){c[e+4776>>2]=h;if((h|0)>3){n=0;g=0;while(1){o=h+-4|0;j=c[e+2304+(o<<2)>>2]|0;k=c[e+2304+(h+-3<<2)>>2]|0;l=c[e+2304+(h+-2<<2)>>2]|0;m=c[e+2304+(h+-1<<2)>>2]|0;if((k|j|l|m)>>>0>1){m=n;j=g;break}m=(((j<<1)+k<<1)+l<<1)+m|0;h=(d[82240+m>>0]|0)+n|0;g=(d[82256+m>>0]|0)+g|0;if((o|0)>3){n=h;h=o}else{m=h;j=g;h=o;break}}c[s>>2]=m;g=e+4840|0;c[g>>2]=0;if((m|0)>(j|0)){c[s>>2]=j;c[g>>2]=1;g=j}else g=m}else p=9}if((p|0)==9){c[s>>2]=0;c[e+4840>>2]=0;g=0}c[e+5184>>2]=g;m=e+4772|0;c[m>>2]=h;if(!h){q=c[s>>2]|0;i=t;return q|0}l=e+4788|0;g=c[l>>2]|0;if(!g){g=a[h+-2+(b+85100)>>0]|0;c[e+4824>>2]=g;j=a[h+-1+(b+85100)>>0]|0;c[e+4828>>2]=j;j=c[b+21360+(g+2+j<<2)>>2]|0;g=c[b+21360+(g+1<<2)>>2]|0;if((j|0)<(h|0))c[e+4804>>2]=fb[c[b+85816>>2]&3](e+2304+(j<<2)|0,e+2304+(h<<2)|0,s)|0}else if((g|0)==2){g=(c[b+21464>>2]|0)*3|0;g=(g|0)>(h|0)?h:g;j=h}else{c[e+4824>>2]=7;c[e+4828>>2]=13;g=c[b+21392>>2]|0;g=(g|0)>(h|0)?h:g;j=h}g=(g|0)<(h|0)?g:h;h=(j|0)<(h|0)?j:h;if((g|0)>0)c[e+4796>>2]=fb[c[b+85816>>2]&3](q,e+2304+(g<<2)|0,s)|0;if((g|0)<(h|0))c[e+4800>>2]=fb[c[b+85816>>2]&3](e+2304+(g<<2)|0,e+2304+(h<<2)|0,s)|0;if((c[b+36>>2]|0)==2){q=e+4768|0;c[q>>2]=c[s>>2];rd(b,e);c[s>>2]=c[q>>2]}if(!r){q=c[s>>2]|0;i=t;return q|0}if(c[l>>2]|0){q=c[s>>2]|0;i=t;return q|0}h=c[m>>2]|0;g=0;while(1)if((c[b+21360+(g<<2)>>2]|0)<(h|0))g=g+1|0;else break;c[f+4>>2]=g;q=c[s>>2]|0;i=t;return q|0}function rd(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;C=i;i=i+5632|0;w=C+5624|0;r=C+5620|0;B=C+368|0;x=C+276|0;y=C+184|0;z=C+92|0;A=C;v=b+2304|0;f=c[b+4788>>2]|0;do if((f|0)==2)if((c[a+76>>2]|0)==1){i=C;return}else{ze(B|0,b|0,5252)|0;f=b;u=5;break}else{ze(B|0,b|0,5252)|0;if(!f){q=c[b+4772>>2]|0;c[x>>2]=1e5;c[x+4>>2]=1e5;c[x+8>>2]=1e5;c[x+12>>2]=1e5;c[x+16>>2]=1e5;c[x+20>>2]=1e5;c[x+24>>2]=1e5;c[x+28>>2]=1e5;c[x+32>>2]=1e5;c[x+36>>2]=1e5;c[x+40>>2]=1e5;c[x+44>>2]=1e5;c[x+48>>2]=1e5;c[x+52>>2]=1e5;c[x+56>>2]=1e5;c[x+60>>2]=1e5;c[x+64>>2]=1e5;c[x+68>>2]=1e5;c[x+72>>2]=1e5;c[x+76>>2]=1e5;c[x+80>>2]=1e5;c[x+84>>2]=1e5;c[x+88>>2]=1e5;t=a+85816|0;p=0;do{m=p;p=p+1|0;f=c[a+21360+(p<<2)>>2]|0;if((f|0)>=(q|0))break;c[r>>2]=0;g=b+2304+(f<<2)|0;f=fb[c[t>>2]&3](v,g,r)|0;l=0;do{e=l+m|0;h=c[a+21360+(e+2<<2)>>2]|0;if((h|0)>=(q|0))break;c[w>>2]=c[r>>2];k=fb[c[t>>2]&3](g,b+2304+(h<<2)|0,w)|0;j=x+(e<<2)|0;h=c[w>>2]|0;if((c[j>>2]|0)>(h|0)){c[j>>2]=h;c[y+(e<<2)>>2]=m;c[z+(e<<2)>>2]=f;c[A+(e<<2)>>2]=k}l=l+1|0}while((l|0)<8);}while((p|0)<16);s=B+4772|0;p=c[s>>2]|0;e=B+5184|0;f=b+4768|0;g=b+2304+(p<<2)|0;h=b+4824|0;j=b+4828|0;k=b+4796|0;l=b+4800|0;m=b+4804|0;o=2;do{q=c[a+21360+(o<<2)>>2]|0;if((q|0)>=(p|0))break;n=o+-2|0;r=(c[e>>2]|0)+(c[x+(n<<2)>>2]|0)|0;c[w>>2]=r;if((c[f>>2]|0)<=(r|0))break;r=fb[c[t>>2]&3](b+2304+(q<<2)|0,g,w)|0;q=c[w>>2]|0;if((c[f>>2]|0)>(q|0)){ze(b|0,B|0,5252)|0;c[f>>2]=q;q=c[y+(n<<2)>>2]|0;c[h>>2]=q;c[j>>2]=n-q;c[k>>2]=c[z+(n<<2)>>2];c[l>>2]=c[A+(n<<2)>>2];c[m>>2]=r}o=o+1|0}while((o|0)<23);t=b}else{f=b;u=5}}while(0);if((u|0)==5){s=B+4772|0;t=f}f=c[s>>2]|0;if(!f){i=C;return}if((c[b+2304+(f+-1<<2)>>2]|c[b+2304+(f+-2<<2)>>2])>>>0>1){i=C;return}j=c[b+4776>>2]|0;g=j+2|0;if((g|0)>576){i=C;return}ze(B|0,t|0,5252)|0;c[B+4776>>2]=g;h=c[s>>2]|0;if((g|0)>(h|0)){k=j+-2|0;k=j+~((h|0)>(k|0)?k:h)+2&-4;e=0;f=0;do{u=g;g=g+-4|0;u=(((c[b+2304+(g<<2)>>2]<<1)+(c[b+2304+(u+-3<<2)>>2]|0)<<1)+(c[b+2304+(u+-2<<2)>>2]|0)<<1)+(c[b+2304+(u+-1<<2)>>2]|0)|0;e=(d[82240+u>>0]|0)+e|0;f=(d[82256+u>>0]|0)+f|0}while((g|0)>(h|0));g=j+-2-k|0}else{e=0;f=0}c[s>>2]=g;s=(e|0)>(f|0);e=s?f:e;c[B+4840>>2]=s&1;s=B+5184|0;c[s>>2]=e;if(!(c[B+4788>>2]|0)){l=b+4768|0;h=a+85816|0;f=b+2304+(g<<2)|0;e=b+4824|0;m=b+4828|0;n=b+4796|0;o=b+4800|0;p=b+4804|0;r=2;do{k=c[a+21360+(r<<2)>>2]|0;if((k|0)>=(g|0))break;q=r+-2|0;v=(c[s>>2]|0)+(c[x+(q<<2)>>2]|0)|0;c[w>>2]=v;if((c[l>>2]|0)<=(v|0))break;k=fb[c[h>>2]&3](b+2304+(k<<2)|0,f,w)|0;j=c[w>>2]|0;if((c[l>>2]|0)>(j|0)){ze(t|0,B|0,5252)|0;c[l>>2]=j;v=c[y+(q<<2)>>2]|0;c[e>>2]=v;c[m>>2]=q-v;c[n>>2]=c[z+(q<<2)>>2];c[o>>2]=c[A+(q<<2)>>2];c[p>>2]=k}r=r+1|0}while((r|0)<23);i=C;return}else{f=B+4768|0;c[f>>2]=e;e=c[a+21392>>2]|0;e=(e|0)>(g|0)?g:e;if((e|0)>0)c[B+4796>>2]=fb[c[a+85816>>2]&3](v,b+2304+(e<<2)|0,f)|0;if((g|0)>(e|0))c[B+4800>>2]=fb[c[a+85816>>2]&3](b+2304+(e<<2)|0,b+2304+(g<<2)|0,f)|0;if((c[b+4768>>2]|0)<=(c[f>>2]|0)){i=C;return}ze(t|0,B|0,5252)|0;i=C;return}}function sd(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0.0,E=0.0,F=0,G=0.0,H=0,I=0;F=d+4780|0;i=c[F>>2]|0;E=+g[79704+(i<<2)>>2];if(+g[d+4764>>2]>8206.0/E){B=1e5;return B|0}m=d+2304|0;A=(e|0)!=0;if(A)w=(i|0)==(c[e>>2]|0);else w=0;u=d+4788|0;t=(c[u>>2]|0)==2?38:21;v=d+4832|0;C=d+4836|0;D=.5945999622344971/E;x=d+5208|0;y=t+1|0;z=e+4|0;s=b;l=m;h=b;k=0;j=0;q=m;r=0;o=0;while(1){if(!w?(c[u>>2]|0)!=0:0){m=-1;B=15}else{if(!(c[v>>2]|0))m=0;else m=c[12112+(o<<2)>>2]|0;m=(c[F>>2]|0)-(m+(c[d+4608+(o<<2)>>2]|0)<<(c[C>>2]|0)+1)-(c[d+4808+(c[d+5028+(o<<2)>>2]<<2)>>2]<<3)|0;if(w?(c[e+8+(o<<2)>>2]|0)==(m|0):0){if(k)wd(k,E,h,l);if(!j){k=0;j=0;i=o}else{m=0;do{i=m|1;k=!(D>+g[h+(i<<2)>>2])&1;c[l+(m<<2)>>2]=!(D>+g[h+(m<<2)>>2])&1;c[l+(i<<2)>>2]=k;m=m+2|0}while(m>>>0>>0);k=0;j=0;i=o}}else B=15}if((B|0)==15){B=0;i=c[d+4872+(o<<2)>>2]|0;n=c[x>>2]|0;if((i+r|0)>(n|0)){i=n-r+1|0;ve(d+2304+(n<<2)|0,0,576-n<<2|0)|0;i=(i|0)<0?0:i;p=y}else p=o;n=(k|0)==0;o=(j|0)==0;I=(k|j|0)==0;l=I?q:l;h=I?s:h;if((A?(I=c[z>>2]|0,!((I|0)<1|(p|0)<(I|0))):0)?(I=c[e+8+(p<<2)>>2]|0,!((I|0)<1|(m|0)<(I|0))):0){if(!n){wd(k,E,h,l);l=q;h=s}k=0;j=i+j|0}else{if(!o){m=0;do{n=m|1;o=!(D>+g[h+(n<<2)>>2])&1;c[l+(m<<2)>>2]=!(D>+g[h+(m<<2)>>2])&1;c[l+(n<<2)>>2]=o;m=m+2|0}while(m>>>0>>0);l=q;h=s}k=i+k|0;j=0}if((i|0)<1){i=k;B=27;break}else i=p}if((i|0)>(t|0)){m=s;o=q;n=r}else{n=c[d+4872+(i<<2)>>2]|0;m=s+(n<<2)|0;o=q+(n<<2)|0;n=n+r|0}if((i|0)<(t|0)){s=m;q=o;r=n;o=i+1|0}else{B=34;break}}if((B|0)==27){if(j){k=0;do{B=k|1;A=!(D>+g[h+(B<<2)>>2])&1;c[l+(k<<2)>>2]=!(D>+g[h+(k<<2)>>2])&1;c[l+(B<<2)>>2]=A;k=k+2|0}while(k>>>0>>0);}if(i)wd(i,E,h,l);}else if((B|0)==34){if(k)wd(k,E,h,l);if(j){i=0;do{B=i|1;A=!(D>+g[h+(B<<2)>>2])&1;c[l+(i<<2)>>2]=!(D>+g[h+(i<<2)>>2])&1;c[l+(B<<2)>>2]=A;i=i+2|0}while(i>>>0>>0);}}if((c[a+85096>>2]&2|0)!=0?(G=.634521682242439/+g[79704+((c[C>>2]|0)+(c[F>>2]|0)<<2)>>2],H=d+4860|0,f=c[H>>2]|0,(f|0)>0):0){j=0;k=0;do{B=c[d+4872+(k<<2)>>2]|0;h=j;j=B+j|0;if((B|0)>0?(c[a+84936+(k<<2)>>2]|0)!=0:0){do{f=d+2304+(h<<2)|0;if(!(+g[b+(h<<2)>>2]>=G))i=0;else i=c[f>>2]|0;c[f>>2]=i;h=h+1|0}while((h|0)<(j|0));f=c[H>>2]|0}k=k+1|0}while((k|0)<(f|0));}B=qd(a,d,e)|0;return B|0}function td(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;R=e+(b*10504|0)+(d*5252|0)|0;S=e+(b*10504|0)+(d*5252|0)+4860|0;m=c[S>>2]|0;if((m|0)>0){k=0;f=0;j=0;do{h=c[e+(b*10504|0)+(d*5252|0)+4872+(j<<2)>>2]|0;l=k;k=h+k|0;a:do if((h|0)>0)do{if(c[e+(b*10504|0)+(d*5252|0)+2304+(l<<2)>>2]|0)break a;l=l+1|0}while((l|0)<(k|0));while(0);if((l|0)==(k|0)){c[e+(b*10504|0)+(d*5252|0)+4608+(j<<2)>>2]=-2;m=c[S>>2]|0;f=-2}j=j+1|0}while((j|0)<(m|0));}else f=0;i=e+(b*10504|0)+(d*5252|0)+4836|0;h=e+(b*10504|0)+(d*5252|0)+4832|0;if(((c[i>>2]|0)==0?(c[h>>2]|0)==0:0)?(g=(m|0)>0,g):0){l=0;k=0;do{j=c[e+(b*10504|0)+(d*5252|0)+4608+(k<<2)>>2]|0;l=((j|0)>0?j:0)|l;k=k+1|0}while((k|0)<(m|0));if((l|0)!=0&(l&1|0)==0){if(g){j=0;do{l=e+(b*10504|0)+(d*5252|0)+4608+(j<<2)|0;k=c[l>>2]|0;if((k|0)>0){c[l>>2]=k>>1;m=c[S>>2]|0}j=j+1|0}while((j|0)<(m|0));}c[i>>2]=1;f=1}}if(((((((((((((c[h>>2]|0)==0?(c[e+(b*10504|0)+(d*5252|0)+4788>>2]|0)!=2:0)?(c[a+76>>2]|0)==2:0)?(L=e+(b*10504|0)+(d*5252|0)+4652|0,M=c[L>>2]|0,N=c[3039]|0,(M|0)==-2|(M|0)>=(N|0)):0)?(O=e+(b*10504|0)+(d*5252|0)+4656|0,P=c[O>>2]|0,Q=c[3040]|0,(P|0)==-2|(P|0)>=(Q|0)):0)?(p=e+(b*10504|0)+(d*5252|0)+4660|0,n=c[p>>2]|0,o=c[3041]|0,(n|0)==-2|(n|0)>=(o|0)):0)?(s=e+(b*10504|0)+(d*5252|0)+4664|0,q=c[s>>2]|0,r=c[3042]|0,(q|0)==-2|(q|0)>=(r|0)):0)?(v=e+(b*10504|0)+(d*5252|0)+4668|0,t=c[v>>2]|0,u=c[3043]|0,(t|0)==-2|(t|0)>=(u|0)):0)?(y=e+(b*10504|0)+(d*5252|0)+4672|0,w=c[y>>2]|0,x=c[3044]|0,(w|0)==-2|(w|0)>=(x|0)):0)?(B=e+(b*10504|0)+(d*5252|0)+4676|0,z=c[B>>2]|0,A=c[3045]|0,(z|0)==-2|(z|0)>=(A|0)):0)?(E=e+(b*10504|0)+(d*5252|0)+4680|0,C=c[E>>2]|0,D=c[3046]|0,(C|0)==-2|(C|0)>=(D|0)):0)?(H=e+(b*10504|0)+(d*5252|0)+4684|0,F=c[H>>2]|0,G=c[3047]|0,(F|0)==-2|(F|0)>=(G|0)):0)?(K=e+(b*10504|0)+(d*5252|0)+4688|0,I=c[K>>2]|0,J=c[3048]|0,(I|0)==-2|(I|0)>=(J|0)):0){if((M|0)>0)c[L>>2]=M-N;if((P|0)>0)c[O>>2]=P-Q;if((n|0)>0)c[p>>2]=n-o;if((q|0)>0)c[s>>2]=q-r;if((t|0)>0)c[v>>2]=t-u;if((w|0)>0)c[y>>2]=w-x;if((z|0)>0)c[B>>2]=z-A;if((C|0)>0)c[E>>2]=C-D;if((F|0)>0)c[H>>2]=F-G;if((I|0)>0)c[K>>2]=I-J;c[h>>2]=1;f=1}A=e+21008+((d<<2)+4<<2)|0;c[A>>2]=0;c[A+4>>2]=0;c[A+8>>2]=0;c[A+12>>2]=0;if((((b|0)==1?(c[a+76>>2]|0)==2:0)?(c[e+(d*5252|0)+4788>>2]|0)!=2:0)?(c[e+10504+(d*5252|0)+4788>>2]|0)!=2:0){j=c[21034]|0;k=e+10504+(d*5252|0)+4608|0;m=c[21035]|0;i=(m|0)>(j|0);b:do if(i){h=j;do{A=c[e+10504+(d*5252|0)+4608+(h<<2)>>2]|0;if((A|0)>-1?(c[e+(d*5252|0)+4608+(h<<2)>>2]|0)!=(A|0):0)break b;h=h+1|0}while((h|0)<(m|0));}else h=j;while(0);if((h|0)==(m|0)){if(i)ve(e+10504+(d*5252|0)+4608+(j<<2)|0,-1,m-j<<2|0)|0;c[e+21024+(d<<4)>>2]=1}l=c[21036]|0;j=(l|0)>(m|0);c:do if(j){h=m;do{A=c[e+10504+(d*5252|0)+4608+(h<<2)>>2]|0;if((A|0)>-1?(c[e+(d*5252|0)+4608+(h<<2)>>2]|0)!=(A|0):0)break c;h=h+1|0}while((h|0)<(l|0));}else h=m;while(0);if((h|0)==(l|0)){if(j)ve(e+10504+(d*5252|0)+4608+(m<<2)|0,-1,l-m<<2|0)|0;c[e+21024+(d<<4)+4>>2]=1}m=c[21037]|0;j=(m|0)>(l|0);d:do if(j){h=l;do{A=c[e+10504+(d*5252|0)+4608+(h<<2)>>2]|0;if((A|0)>-1?(c[e+(d*5252|0)+4608+(h<<2)>>2]|0)!=(A|0):0)break d;h=h+1|0}while((h|0)<(m|0));}else h=l;while(0);if((h|0)==(m|0)){if(j)ve(e+10504+(d*5252|0)+4608+(l<<2)|0,-1,m-l<<2|0)|0;c[e+21024+(d<<4)+8>>2]=1}j=c[21038]|0;i=(j|0)>(m|0);e:do if(i){h=m;do{A=c[e+10504+(d*5252|0)+4608+(h<<2)>>2]|0;if((A|0)>-1?(c[e+(d*5252|0)+4608+(h<<2)>>2]|0)!=(A|0):0)break e;h=h+1|0}while((h|0)<(j|0));}else h=m;while(0);if((h|0)==(j|0)){if(i)ve(e+10504+(d*5252|0)+4608+(m<<2)|0,-1,j-m<<2|0)|0;c[e+21024+(d<<4)+12>>2]=1}h=c[k>>2]|0;f=(h|0)==-1;g=f&1^1;h=f?0:(h|0)>0?h:0;f=c[e+10504+(d*5252|0)+4612>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4616>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4620>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4624>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4628>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4632>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4636>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4640>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4644>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}f=c[e+10504+(d*5252|0)+4648>>2]|0;if((f|0)!=-1){g=g+1|0;h=(h|0)<(f|0)?f:h}j=c[e+10504+(d*5252|0)+4652>>2]|0;i=(j|0)==-1;f=i&1^1;j=i?0:(j|0)>0?j:0;i=c[e+10504+(d*5252|0)+4656>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}i=c[e+10504+(d*5252|0)+4660>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}i=c[e+10504+(d*5252|0)+4664>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}i=c[e+10504+(d*5252|0)+4668>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}i=c[e+10504+(d*5252|0)+4672>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}i=c[e+10504+(d*5252|0)+4676>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}i=c[e+10504+(d*5252|0)+4680>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}i=c[e+10504+(d*5252|0)+4684>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}i=c[e+10504+(d*5252|0)+4688>>2]|0;if((i|0)!=-1){f=f+1|0;j=(j|0)<(i|0)?i:j}k=e+10504+(d*5252|0)+4844|0;l=e+10504+(d*5252|0)+4784|0;m=0;do{do if((h|0)<(c[88776+(m<<2)>>2]|0)){if((j|0)>=(c[88840+(m<<2)>>2]|0))break;i=$(c[88648+(m<<2)>>2]|0,g)|0;i=($(c[88712+(m<<2)>>2]|0,f)|0)+i|0;if((c[k>>2]|0)<=(i|0))break;c[k>>2]=i;c[l>>2]=m}while(0);m=m+1|0}while((m|0)!=16);f=0}g=c[S>>2]|0;if((g|0)>0){i=0;do{h=e+(b*10504|0)+(d*5252|0)+4608+(i<<2)|0;if((c[h>>2]|0)==-2){c[h>>2]=0;g=c[S>>2]|0}i=i+1|0}while((i|0)<(g|0));}if(!f)return;ud(a,R)|0;return}function ud(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0;K=i;i=i+16|0;J=K;if((c[a+76>>2]|0)==2){if((c[b+4788>>2]|0)!=2){a=b+4832|0;if(((((((((((c[a>>2]|0)==0?(d=b+4652|0,e=c[d>>2]|0,f=c[3039]|0,(e|0)>=(f|0)):0)?(g=b+4656|0,h=c[g>>2]|0,j=c[3040]|0,(h|0)>=(j|0)):0)?(m=b+4660|0,l=c[m>>2]|0,k=c[3041]|0,(l|0)>=(k|0)):0)?(p=b+4664|0,o=c[p>>2]|0,n=c[3042]|0,(o|0)>=(n|0)):0)?(s=b+4668|0,r=c[s>>2]|0,q=c[3043]|0,(r|0)>=(q|0)):0)?(v=b+4672|0,u=c[v>>2]|0,t=c[3044]|0,(u|0)>=(t|0)):0)?(y=b+4676|0,x=c[y>>2]|0,w=c[3045]|0,(x|0)>=(w|0)):0)?(B=b+4680|0,A=c[B>>2]|0,z=c[3046]|0,(A|0)>=(z|0)):0)?(E=b+4684|0,D=c[E>>2]|0,C=c[3047]|0,(D|0)>=(C|0)):0)?(H=b+4688|0,G=c[H>>2]|0,F=c[3048]|0,(G|0)>=(F|0)):0){c[a>>2]=1;c[d>>2]=e-f;c[g>>2]=h-j;c[m>>2]=l-k;c[p>>2]=o-n;c[s>>2]=r-q;c[v>>2]=u-t;c[y>>2]=x-w;c[B>>2]=A-z;c[E>>2]=D-C;c[H>>2]=G-F;a=89032}else a=89032}else a=(c[b+4792>>2]|0)!=0?88904:88968;f=c[b+4868>>2]|0;if((f|0)>0){d=0;e=0;do{y=c[b+4608+(e<<2)>>2]|0;d=(d|0)<(y|0)?y:d;e=e+1|0}while((e|0)!=(f|0));m=d;e=(f|0)>1?f:1}else{m=0;e=0}f=c[b+4860>>2]|0;if((e|0)<(f|0)){d=0;do{y=c[b+4608+(e<<2)>>2]|0;d=(d|0)<(y|0)?y:d;e=e+1|0}while((e|0)!=(f|0));h=d}else h=0;g=b+4844|0;c[g>>2]=1e5;f=b+4784|0;d=1e5;e=0;do{if(((m|0)<(c[88776+(e<<2)>>2]|0)?(h|0)<(c[88840+(e<<2)>>2]|0):0)?(I=c[a+(e<<2)>>2]|0,(d|0)>(I|0)):0){c[g>>2]=I;c[f>>2]=e;d=I}e=e+1|0}while((e|0)!=16);y=(d|0)==1e5&1;i=K;return y|0}I=(c[b+4832>>2]|0)==0;c[J>>2]=0;c[J+4>>2]=0;c[J+8>>2]=0;c[J+12>>2]=0;H=I?0:2;if((c[b+4788>>2]|0)!=2){g=c[11824+(H*48|0)>>2]|0;if((g|0)>0){d=0;f=0;do{e=c[b+4608+(f<<2)>>2]|0;if((e|0)>(d|0)){c[J>>2]=e;d=e}f=f+1|0}while((f|0)!=(g|0));}else{d=0;g=0}l=c[11824+(H*48|0)+4>>2]|0;if((l|0)>0){f=J+4|0;h=0;j=0;k=g;while(1){e=c[b+4608+(k<<2)>>2]|0;if((e|0)>(h|0))c[f>>2]=e;else e=h;j=j+1|0;if((j|0)==(l|0))break;else{h=e;k=k+1|0}}g=l+g|0}else e=0;m=c[11824+(H*48|0)+8>>2]|0;if((m|0)>0){k=J+8|0;f=0;j=0;l=g;while(1){h=c[b+4608+(l<<2)>>2]|0;if((h|0)>(f|0)){c[k>>2]=h;f=h}j=j+1|0;if((j|0)==(m|0))break;else l=l+1|0}g=m+g|0}else f=0;m=c[11824+(H*48|0)+12>>2]|0;if((m|0)>0){k=J+12|0;j=0;l=0;while(1){h=c[b+4608+(g<<2)>>2]|0;if((h|0)>(j|0))c[k>>2]=h;else h=j;l=l+1|0;if((l|0)==(m|0)){m=0;break}else{j=h;g=g+1|0}}}else{h=0;m=0}}else{a=0;d=0;do{y=c[11824+(H*48|0)+16+(a<<2)>>2]|0;l=(y|0)/3|0;if((y|0)>2){j=J+(a<<2)|0;f=(l|0)>1;h=c[j>>2]|0;e=0;n=d;while(1){m=n*3|0;k=c[b+4608+(m<<2)>>2]|0;if((k|0)>(h|0)){c[j>>2]=k;h=k}k=c[b+4608+(m+1<<2)>>2]|0;if((k|0)>(h|0)){c[j>>2]=k;h=k}g=c[b+4608+(m+2<<2)>>2]|0;if((g|0)>(h|0)){c[j>>2]=g;h=g}e=e+1|0;if((e|0)>=(l|0))break;else n=n+1|0}d=(f?l:1)+d|0}a=a+1|0}while((a|0)!=4);d=c[J>>2]|0;e=c[J+4>>2]|0;f=c[J+8>>2]|0;h=c[J+12>>2]|0;m=1}l=((e|0)>(c[89096+(H<<4)+4>>2]|0)&1)+((d|0)>(c[89096+(H<<4)>>2]|0)&1)+((f|0)>(c[89096+(H<<4)+8>>2]|0)&1)+((h|0)>(c[89096+(H<<4)+12>>2]|0)&1)|0;if(!l){j=11824+(H*48|0)+(m<<4)|0;c[b+5188>>2]=j;k=c[89192+(d<<2)>>2]|0;c[b+5192>>2]=k;e=c[89192+(e<<2)>>2]|0;c[b+5196>>2]=e;g=c[89192+(f<<2)>>2]|0;c[b+5200>>2]=g;h=c[89192+(h<<2)>>2]|0;c[b+5204>>2]=h;if(I)f=(g<<2)+((k*5|0)+e<<4)+h|0;else f=(k*3|0)+500+e|0;c[b+4784>>2]=f;y=$(c[j>>2]|0,k)|0;y=($(c[11824+(H*48|0)+(m<<4)+4>>2]|0,e)|0)+y|0;y=y+($(c[11824+(H*48|0)+(m<<4)+8>>2]|0,g)|0)|0;c[b+4844>>2]=y+($(c[11824+(H*48|0)+(m<<4)+12>>2]|0,h)|0);}y=l;i=K;return y|0}function vd(b){b=b|0;var d=0,e=0,f=0,g=0;c[b+85816>>2]=2;g=2;do{d=0;do d=d+1|0;while((c[b+21360+(d<<2)>>2]|0)<(g|0));f=c[89256+(d<<3)>>2]|0;e=f;while(1)if((c[b+21360+(e+1<<2)>>2]|0)>(g|0))e=e+-1|0;else break;e=(e|0)<0?f:e;a[g+-2+(b+85100)>>0]=e;f=c[89256+(d<<3)+4>>2]|0;e=e<<24>>24;d=f;while(1)if((c[b+21360+(d+2+e<<2)>>2]|0)>(g|0))d=d+-1|0;else break;a[g+-1+(b+85100)>>0]=(d|0)<0?f:d;g=g+2|0}while((g|0)<577);return}function wd(a,b,d,e){a=a|0;b=+b;d=d|0;e=e|0;var f=0,h=0,i=0,j=0,l=0.0,m=0.0,n=0.0,o=0.0;j=a&2;f=a>>>2;if(!f)a=e;else{i=f<<2;a=e+(i<<2)|0;h=d;while(1){f=f+-1|0;o=+g[h>>2]*b+8388608.0;n=+g[h+4>>2]*b+8388608.0;m=+g[h+8>>2]*b+8388608.0;l=+g[h+12>>2]*b+8388608.0;o=+g[46872+((g[k>>2]=o,c[k>>2]|0)+-1258291200<<2)>>2]+o;n=+g[46872+((g[k>>2]=n,c[k>>2]|0)+-1258291200<<2)>>2]+n;m=+g[46872+((g[k>>2]=m,c[k>>2]|0)+-1258291200<<2)>>2]+m;l=+g[46872+((g[k>>2]=l,c[k>>2]|0)+-1258291200<<2)>>2]+l;c[e>>2]=(g[k>>2]=o,c[k>>2]|0)+-1258291200;c[e+4>>2]=(g[k>>2]=n,c[k>>2]|0)+-1258291200;c[e+8>>2]=(g[k>>2]=m,c[k>>2]|0)+-1258291200;c[e+12>>2]=(g[k>>2]=l,c[k>>2]|0)+-1258291200;if(!f)break;else{h=h+16|0;e=e+16|0}}d=d+(i<<2)|0}if(!j)return;l=+g[d>>2]*b+8388608.0;b=+g[d+4>>2]*b+8388608.0;l=+g[46872+((g[k>>2]=l,c[k>>2]|0)+-1258291200<<2)>>2]+l;b=+g[46872+((g[k>>2]=b,c[k>>2]|0)+-1258291200<<2)>>2]+b;c[a>>2]=(g[k>>2]=l,c[k>>2]|0)+-1258291200;c[a+4>>2]=(g[k>>2]=b,c[k>>2]|0)+-1258291200;return}function xd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;g=a;f=0;e=0;do{i=c[g>>2]|0;h=c[g+4>>2]|0;g=g+8|0;f=(f|0)<(i|0)?i:f;e=(e|0)<(h|0)?h:e}while(g>>>0>>0);e=(f|0)<(e|0)?e:f;if(e>>>0<16){e=gb[c[89440+(e<<2)>>2]&7](a,b,e,d)|0;return e|0}if(e>>>0>8206){c[d>>2]=1e5;e=-1;return e|0}f=e+-15|0;if((c[20665]|0)>>>0>>0)if((c[20669]|0)>>>0>>0)if((c[20673]|0)>>>0>>0)if((c[20677]|0)>>>0>>0)if((c[20681]|0)>>>0>>0)if((c[20685]|0)>>>0>>0)if((c[20689]|0)>>>0>>0)if((c[20693]|0)>>>0>>0){i=24;h=32}else{g=31;j=9}else{g=30;j=9}else{g=29;j=9}else{g=28;j=9}else{g=27;j=9}else{g=26;j=9}else{g=25;j=9}else{g=24;j=9}a:do if((j|0)==9){e=g+-8|0;while(1){if((c[82272+(e<<4)+4>>2]|0)>>>0>=f>>>0){i=e;h=g;break a}e=e+1|0;if((e|0)>=24){i=e;h=g;break}}}while(0);g=(c[82272+(i<<4)>>2]<<16)+(c[82272+(h<<4)>>2]|0)|0;f=a;e=0;do{a=c[f>>2]|0;l=c[f+4>>2]|0;f=f+8|0;k=a>>>0>14;j=l>>>0>14;e=(k?g:0)+e+(c[82816+((j?15:l)+(k?240:a<<4)<<2)>>2]|0)+(j?g:0)|0}while(f>>>0>>0);a=e&65535;b=e>>>16;k=b>>>0>a>>>0;c[d>>2]=(c[d>>2]|0)+(k?a:b);k=k?h:i;return k|0}function yd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return 0}function zd(a,b,e,f){a=a|0;b=b|0;e=e|0;f=f|0;var g=0;g=c[20575]|0;e=0;do{e=(d[g+((c[a>>2]<<1)+(c[a+4>>2]|0))>>0]|0)+e|0;a=a+8|0}while(a>>>0>>0);c[f>>2]=(c[f>>2]|0)+e;return 1}function Ad(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;g=d+-1|0;h=c[89504+(g<<2)>>2]|0;f=c[82272+(h<<4)>>2]|0;g=(g|0)==1?83840:83880;d=0;do{d=(c[g+(($(c[a>>2]|0,f)|0)+(c[a+4>>2]|0)<<2)>>2]|0)+d|0;a=a+8|0}while(a>>>0>>0);f=d&65535;a=d>>>16;d=a>>>0>f>>>0;c[e>>2]=(c[e>>2]|0)+(d?f:a);return (d&1)+h|0}function Bd(a,b,e,f){a=a|0;b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;n=c[89504+(e+-1<<2)>>2]|0;j=c[82272+(n<<4)>>2]|0;k=c[82272+(n<<4)+12>>2]|0;o=n+1|0;l=c[82272+(o<<4)+12>>2]|0;m=n+2|0;i=c[82272+(m<<4)+12>>2]|0;h=a;a=0;g=0;e=0;do{p=($(c[h>>2]|0,j)|0)+(c[h+4>>2]|0)|0;h=h+8|0;a=(d[k+p>>0]|0)+a|0;g=(d[l+p>>0]|0)+g|0;e=(d[i+p>>0]|0)+e|0}while(h>>>0>>0);b=a>>>0>g>>>0;k=b?g:a;l=k>>>0>e>>>0;c[f>>2]=(c[f>>2]|0)+(l?e:k);return (l?m:b?o:n)|0}function Cd(a){a=a|0;var b=0,d=0,e=0,f=0;b=a+85704|0;d=c[b>>2]|0;if(d){re(d);c[b>>2]=0}d=a+85708|0;b=c[d>>2]|0;if(b){re(b);c[d>>2]=0}d=a+85712|0;b=c[d>>2]|0;if(b){re(b);c[d>>2]=0}b=a+85716|0;d=c[b>>2]|0;if(d){re(d);c[b>>2]=0}d=a+85728|0;b=c[d>>2]|0;if(b){re(b);c[d>>2]=0;c[a+85732>>2]=0;c[a+85740>>2]=0}b=a+85744|0;d=c[b>>2]|0;if(!d)return;do{f=c[d+24>>2]|0;e=d;d=c[d>>2]|0;re(c[e+12>>2]|0);re(f);re(e);}while((d|0)!=0);c[b>>2]=0;c[a+85748>>2]=0;return}function Dd(a){a=a|0;var b=0,d=0,e=0;e=0;do{d=a+37192+(e<<2)|0;b=c[d>>2]|0;if(b){re(b);c[d>>2]=0}e=e+1|0}while((e|0)!=641);d=a+37184|0;b=c[d>>2]|0;if(b){re(b);c[d>>2]=0}d=a+37188|0;b=c[d>>2]|0;if(b){re(b);c[d>>2]=0}b=a+284|0;d=c[b>>2]|0;if(d){re(d);c[b>>2]=0}d=a+85780|0;b=c[d>>2]|0;if(b){re(b);c[d>>2]=0;c[a+85776>>2]=0}b=c[a+85796>>2]|0;if(b)re(b);b=c[a+85676>>2]|0;if(b)re(b);b=c[a+52152>>2]|0;if(b)re(b);b=c[a+52156>>2]|0;if(b)re(b);Cd(a);d=a+85808|0;b=c[d>>2]|0;if(b){Ha(b|0)|0;c[d>>2]=0}e=a+85800|0;b=c[e>>2]|0;if(!b){re(a);return}d=c[b+2156>>2]|0;if(d){re(d);b=c[e>>2]|0}d=c[b+4316>>2]|0;if(d){re(d);b=c[e>>2]|0}re(b);re(a);return}function Ed(a,b){a=a|0;b=+b;var d=0.0,e=0.0;switch(c[a+192>>2]|0){case 3:{b=b<-.3?3.4100000858306885:b*1.0000000474974513e-03;b=b<.10000000149011612?.10000000149011612:b;b=b>24.0?24.0:b;e=b+-3.4;d=b+-8.7;b=+Q(+b,-.8)*3.64-+Y(+(e*e*-.6))*6.8+ +Y(+(d*d*-.15))*6.0+ +Q(+b,4.0)*6.399999999999999e-04+6.0;return +b}case 1:{b=b<-.3?3.4100000858306885:b*1.0000000474974513e-03;b=b<.10000000149011612?.10000000149011612:b;b=b>24.0?24.0:b;e=b+-3.4;d=b+-8.7;b=+Q(+b,-.8)*3.64-+Y(+(e*e*-.6))*6.8+ +Y(+(d*d*-.15))*6.0+ +Q(+b,4.0)*.00056;return +b}case 4:{b=b<-.3?3.4100000858306885:b*1.0000000474974513e-03;b=b<.10000000149011612?.10000000149011612:b;b=b>24.0?24.0:b;e=b+-3.4;d=b+-8.7;b=+Q(+b,-.8)*3.64-+Y(+(e*e*-.6))*6.8+ +Y(+(d*d*-.15))*6.0+ +Q(+b,4.0)*(+g[a+188>>2]*4.0e-05+.0006);return +b}case 0:{b=b<-.3?3.4100000858306885:b*1.0000000474974513e-03;b=b<.10000000149011612?.10000000149011612:b;b=b>24.0?24.0:b;e=b+-3.4;d=b+-8.7;b=+Q(+b,-.8)*3.64-+Y(+(e*e*-.6))*6.8+ +Y(+(d*d*-.15))*6.0+ +Q(+b,4.0)*9.599999999999999e-04;return +b}case 5:{b=b<-.3?3.4100000858306885:b*1.0000000474974513e-03;b=b<3.4100000858306885?3.4100000858306885:b;b=b>16.100000381469727?16.100000381469727:b;e=b+-3.4;d=b+-8.7;b=+Q(+b,-.8)*3.64-+Y(+(e*e*-.6))*6.8+ +Y(+(d*d*-.15))*6.0+ +Q(+b,4.0)*(+g[a+188>>2]*4.0e-05+.0006);return +b}case 2:{b=b<-.3?3.4100000858306885:b*1.0000000474974513e-03;b=b<.10000000149011612?.10000000149011612:b;b=b>24.0?24.0:b;e=b+-3.4;d=b+-8.7;b=+Q(+b,-.8)*3.64-+Y(+(e*e*-.6))*6.8+ +Y(+(d*d*-.15))*6.0+ +Q(+b,4.0)*.0006;return +b}default:{b=b<-.3?3.4100000858306885:b*1.0000000474974513e-03;b=b<.10000000149011612?.10000000149011612:b;b=b>24.0?24.0:b;e=b+-3.4;d=b+-8.7;b=+Q(+b,-.8)*3.64-+Y(+(e*e*-.6))*6.8+ +Y(+(d*d*-.15))*6.0+ +Q(+b,4.0)*.0006;return +b}}return 0.0}function Fd(a){a=+a;a=a<0.0?0.0:a*.001;return +(+W(+(a*a*.017777777777777778))*3.5+ +W(+(a*.76))*13.0);}function Gd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=(d|0)<16e3?2:b;d=c[83944+(e<<6)+4>>2]|0;f=2;do{b=c[83944+(e<<6)+(f<<2)>>2]|0;if((b|0)>0){h=b-a|0;g=d-a|0;d=(((h|0)>0?h:0-h|0)|0)<(((g|0)>0?g:0-g|0)|0)?b:d}f=f+1|0}while((f|0)!=15);return d|0}function Hd(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;f=a&65535;d=0;while(1){if((d|0)>=16){e=16;d=320;a=16;b=320;break}a=d+1|0;b=c[89568+(a<<2)>>2]|0;if((((f|0)>(b|0)?f:b)|0)==(f|0))d=a;else{g=4;break}}if((g|0)==4){e=d;d=c[89568+(d<<2)>>2]|0}return ((b-f|0)>(f-d|0)?e:a)|0}function Id(a){a=a|0;if((a|0)>=8001)if((a|0)>=11026)if((a|0)>=12001)if((a|0)>=16001)if((a|0)>=22051)if((a|0)>=24001)if((a|0)<32001)a=32e3;else a=(a|0)<44101?44100:48e3;else a=24e3;else a=22050;else a=16e3;else a=12e3;else a=11025;else a=8e3;return a|0}function Jd(a,b,d){a=a|0;b=b|0;d=d|0;d=(d|0)<16e3?2:b;b=c[83944+(d<<6)>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=0;return d|0}b=c[83944+(d<<6)+4>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=1;return d|0}b=c[83944+(d<<6)+8>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=2;return d|0}b=c[83944+(d<<6)+12>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=3;return d|0}b=c[83944+(d<<6)+16>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=4;return d|0}b=c[83944+(d<<6)+20>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=5;return d|0}b=c[83944+(d<<6)+24>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=6;return d|0}b=c[83944+(d<<6)+28>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=7;return d|0}b=c[83944+(d<<6)+32>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=8;return d|0}b=c[83944+(d<<6)+36>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=9;return d|0}b=c[83944+(d<<6)+40>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=10;return d|0}b=c[83944+(d<<6)+44>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=11;return d|0}b=c[83944+(d<<6)+48>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=12;return d|0}b=c[83944+(d<<6)+52>>2]|0;if((b|0)>0&(b|0)==(a|0)){d=13;return d|0}else{d=c[83944+(d<<6)+56>>2]|0;return ((d|0)>0&(d|0)==(a|0)?14:-1)|0}return 0}function Kd(a,b){a=a|0;b=b|0;do if((a|0)==22050){c[b>>2]=0;a=0}else if((a|0)==8e3){c[b>>2]=0;a=2}else if((a|0)==16e3){c[b>>2]=0;a=2}else if((a|0)==48e3){c[b>>2]=1;a=1}else if((a|0)==12e3){c[b>>2]=0;a=1}else if((a|0)==44100){c[b>>2]=1;a=0}else if((a|0)==24e3){c[b>>2]=0;a=1}else if((a|0)==32e3){c[b>>2]=1;a=2}else if((a|0)==11025){c[b>>2]=0;a=0}else{c[b>>2]=0;a=-1}while(0);return a|0}function Ld(a){a=a|0;var b=0.0;b=+(c[a+48>>2]|0);a=c[a+44>>2]|0;if((a|0)<(~~(b*.9994999766349792)|0)){a=1;a=a&1;return a|0}a=(~~(b*1.000499963760376)|0)<(a|0);a=a&1;return a|0}function Md(a,b,d,e,f,i){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;i=i|0;var j=0,k=0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0,B=0,C=0,D=0,E=0,F=0.0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,P=0,Q=0,T=0,U=0,V=0;T=c[a+84036>>2]|0;l=c[a+76>>2]|0;P=l*576|0;U=c[a+72>>2]|0;Q=a+64|0;j=c[Q>>2]|0;o=+(j|0);I=a+60|0;k=c[I>>2]|0;if((k|0)>=(~~(o*.9994999766349792)|0)?(~~(o*1.000499963760376)|0)>=(k|0):0){j=(P|0)<(e|0)?P:e;k=j<<2;l=0;do{ze((c[b+(l<<2)>>2]|0)+(T<<2)|0,c[d+(l<<2)>>2]|0,k|0)|0;l=l+1|0}while((l|0)<(U|0));c[i>>2]=j;c[f>>2]=j;return}J=a+12|0;K=a+37184|0;L=a+37188|0;M=a+37168|0;H=(l|0)>0;l=0;while(1){C=c[b+(l<<2)>>2]|0;G=c[d+(l<<2)>>2]|0;F=+(k|0)/+(j|0);if(!k)k=j;else{n=j;while(1){m=(n|0)%(k|0)|0;if(!m)break;else{n=k;k=m}}}k=(j|0)/(k|0)|0;j=(k|0)>320?320:k;D=+O(+(F-+N(+(F+.5))))<.0001;o=1.0/F;m=o>1.0;D=D?32:31;E=D+1|0;if(!(c[J>>2]|0)){c[K>>2]=se(E,4)|0;c[L>>2]=se(E,4)|0;u=j<<1;if((j|0)<0){c[M>>2]=0;c[M+4>>2]=0;c[M+8>>2]=0;c[M+12>>2]=0;n=0}else{n=0;while(1){c[a+37192+(n<<2)>>2]=se(E,4)|0;if((n|0)<(u|0))n=n+1|0;else break}c[M>>2]=0;c[M+4>>2]=0;c[M+8>>2]=0;c[M+12>>2]=0;z=+(j|0)*2.0;x=m?3.1415927410125732:o*3.141592653589793;v=+(D|0);w=x*.3183098861837907;x=x*v;y=+(D|0)*3.141592653589793;r=(k|0)<320?-2-(k<<1^-2)|0:640;k=0;while(1){t=+(k-j|0)/z;m=c[a+37192+(k<<2)>>2]|0;s=0;p=0.0;while(1){o=(+(s|0)-t)/v;o=o<0.0?0.0:o;o=o>1.0?1.0:o;q=o+-.5;if(+O(+q)<1.0e-09)o=w;else o=(.42-+R(+(o*2.0*3.141592653589793))*.5+ +R(+(o*4.0*3.141592653589793))*.08)*+S(+(x*q))/(y*q);g[m+(s<<2)>>2]=o;p=o+p;if((s|0)<(D|0))s=s+1|0;else break}n=0;while(1){s=m+(n<<2)|0;g[s>>2]=+g[s>>2]/p;if((n|0)<(D|0))n=n+1|0;else break}if((k|0)<(u|0))k=k+1|0;else break}n=(r|0)>0?r|1:1}c[J>>2]=1}else n=0;B=c[a+37184+(l<<2)>>2]|0;A=a+37168+(l<<3)|0;a:do if(H){u=D>>>1;m=D-u|0;v=+(D&1|0)*.5;t=+(j|0);q=t*2.0;o=+h[A>>3];j=0;do{p=+(j|0)*F-o;n=~~+N(+p);if((n+m|0)>=(e|0))break a;s=n-u|0;k=c[a+37192+(~~+N(+(q*(p-v-+(n|0))+t+.5))<<2)>>2]|0;r=0;p=0.0;while(1){V=r+s|0;p=+g[k+(r<<2)>>2]*+g[((V|0)<0?B+(V+E<<2)|0:G+(V<<2)|0)>>2]+p;if((r|0)<(D|0))r=r+1|0;else break}g[C+(j+T<<2)>>2]=p;j=j+1|0}while((j|0)<(P|0));}else{m=D-(D>>>1)|0;o=+h[A>>3];j=0}while(0);k=n+m|0;k=(k|0)>(e|0)?e:k;c[f>>2]=k;h[A>>3]=o-+(j|0)*F+ +(k|0);if((D|0)>=(k|0)){m=E-k|0;if((m|0)>0){n=0;do{c[B+(n<<2)>>2]=c[B+(n+k<<2)>>2];n=n+1|0}while((n|0)!=(m|0));}else m=0;if((D|0)>=(m|0)){n=E-m|0;k=0;while(1){c[B+(m<<2)>>2]=c[G+(k<<2)>>2];k=k+1|0;if((k|0)==(n|0))break;else m=m+1|0}}}else{k=k+~D|0;m=0;do{c[B+(m<<2)>>2]=c[G+(k+m<<2)>>2];m=m+1|0}while((m|0)<(E|0));}l=l+1|0;if((l|0)>=(U|0))break;k=c[I>>2]|0;j=c[Q>>2]|0}c[i>>2]=j;return}function Nd(a,b){a=a|0;b=b|0;var d=0;d=c[n>>2]|0;ra(d|0,a|0,b|0)|0;ua(d|0)|0;return}function Od(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=i;i=i+16|0;e=f;if(!a){i=f;return}a=a+85828|0;if(!(c[a>>2]|0)){i=f;return}c[e>>2]=d;hb[c[a>>2]&3](b,e);i=f;return}function Pd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;f=i;i=i+16|0;e=f;if(!a){i=f;return}a=a+85836|0;if(!(c[a>>2]|0)){i=f;return}c[e>>2]=d;hb[c[a>>2]&3](b,e);i=f;return}function Qd(){return 0}function Rd(){return 0}function Sd(){return 0}function Td(){return 0}function Ud(){return}function Vd(){var a=0;if(!(c[22410]|0))a=0;else{c[22410]=1;return}do{g[89648+(a<<2)>>2]=+Z(+(+(a|0)*.001953125+1.0))*1.4426950408889634;a=a+1|0}while((a|0)!=513);c[22410]=1;return}function Wd(a){a=+a;var b=0,d=0;d=(g[k>>2]=a,c[k>>2]|0);a=+(d&16383|0)*.00006103515625;b=d>>>14&511;return +(+g[89648+(b<<2)>>2]*(1.0-a)+ +((d>>>23&255)+-127|0)+ +g[89648+(b+1<<2)>>2]*a);}function Xd(){return 91704}function Yd(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;B=i;i=i+688|0;x=B+424|0;w=B+192|0;z=B;f=$(d,b)|0;if(!f){i=B;return}j=f-d|0;c[z+4>>2]=d;c[z>>2]=d;g=d;b=d;h=2;while(1){g=g+d+b|0;c[z+(h<<2)>>2]=g;if(g>>>0>>0){y=b;b=g;h=h+1|0;g=y}else break}y=0-d|0;t=a+j|0;if((j|0)>0){r=(d|0)==0;s=t;f=1;g=0;b=1;do{do if((f&3|0)!=3){q=b+-1|0;if((c[z+(q<<2)>>2]|0)>>>0<(s-a|0)>>>0){c[w>>2]=a;a:do if((b|0)>1){j=b;h=a;o=a;k=1;while(1){p=h+y|0;l=j+-2|0;h=h+(0-((c[z+(l<<2)>>2]|0)+d))|0;if((ib[e&1](o,h)|0)>-1?(ib[e&1](o,p)|0)>-1:0){n=k;break}n=k+1|0;m=w+(k<<2)|0;if((ib[e&1](h,p)|0)>-1){c[m>>2]=h;j=j+-1|0}else{c[m>>2]=p;h=p;j=l}if((j|0)<=1)break;o=c[w>>2]|0;k=n}if((n|0)>=2?(v=w+(n<<2)|0,c[v>>2]=x,!r):0){k=d;j=x;while(1){h=k>>>0>256?256:k;l=c[w>>2]|0;ze(j|0,l|0,h|0)|0;m=0;do{p=m;m=m+1|0;o=l;l=c[w+(m<<2)>>2]|0;ze(o|0,l|0,h|0)|0;c[w+(p<<2)>>2]=o+h}while((m|0)!=(n|0));if((k|0)==(h|0))break a;k=k-h|0;j=c[v>>2]|0}}}while(0);}else Zd(a,d,e,f,g,b,0,z);if((b|0)==1){j=f<<1;g=f>>>31|g<<1;b=0;break}else{p=q>>>0>31;o=p?0:f;b=p?b+-33|0:q;j=o<>>(32-b|0)|(p?f:g)<>2]=a;b:do if((b|0)>1){j=b;h=a;n=a;l=1;while(1){o=h+y|0;p=j+-2|0;h=h+(0-((c[z+(p<<2)>>2]|0)+d))|0;if((ib[e&1](n,h)|0)>-1?(ib[e&1](n,o)|0)>-1:0){m=l;break}m=l+1|0;k=w+(l<<2)|0;if((ib[e&1](h,o)|0)>-1){c[k>>2]=h;j=j+-1|0}else{c[k>>2]=o;h=o;j=p}if((j|0)<=1)break;n=c[w>>2]|0;l=m}if((m|0)>=2?(u=w+(m<<2)|0,c[u>>2]=x,!r):0){k=d;j=x;while(1){l=k>>>0>256?256:k;h=c[w>>2]|0;ze(j|0,h|0,l|0)|0;j=h;h=0;do{q=h;h=h+1|0;p=j;j=c[w+(h<<2)>>2]|0;ze(p|0,j|0,l|0)|0;c[w+(q<<2)>>2]=p+l}while((h|0)!=(m|0));if((k|0)==(l|0))break b;k=k-l|0;j=c[u>>2]|0}}}while(0);j=f>>>2|g<<30;g=g>>>2;b=b+2|0}while(0);f=j|1;a=a+d|0}while(a>>>0>>0);}else{g=0;f=1;b=1}Zd(a,d,e,f,g,b,0,z);if((g|0)==0&((f|0)==1&(b|0)==1)){i=B;return}else{h=f;p=a;o=b}while(1){if((o|0)>=2){v=h>>>30;x=o+-2|0;u=(h<<1&2147483646|v<<31)^3;w=(v|g<<2)>>>1;Zd(p+(0-((c[z+(x<<2)>>2]|0)+d))|0,d,e,u,w,o+-1|0,1,z);v=w<<1|v&1;u=u<<1|1;w=p+y|0;Zd(w,d,e,u,v,x,1,z);h=u;g=v;p=w;o=x;continue}b=h+-1|0;do if(b){if(!(b&1)){f=b;b=0;do{b=b+1|0;f=f>>>1}while((f&1|0)==0);if(!b)A=51}else A=51;if((A|0)==51){A=0;if(!g){b=64;A=56;break}if(!(g&1)){f=g;b=0}else{f=0;a=h;b=0;break}while(1){a=b+1|0;f=f>>>1;if(f&1){f=a;break}else b=a}if(!f){f=0;a=h;b=0;break}else b=b+33|0}if(b>>>0>31)A=56;else{f=b;a=h}}else{b=32;A=56}while(0);if((A|0)==56){A=0;f=b+-32|0;a=g;g=0}h=g<<32-f|a>>>f;g=g>>>f;o=b+o|0;if((g|0)==0&((h|0)==1&(o|0)==1))break;else p=p+y|0}i=B;return} -function kb(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+15&-16;return b|0}function lb(){return i|0}function mb(a){a=a|0;i=a}function nb(a,b){a=a|0;b=b|0;i=a;j=b}function ob(a,b){a=a|0;b=b|0;if(!o){o=a;p=b}}function pb(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0]}function qb(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0];a[k+4>>0]=a[b+4>>0];a[k+5>>0]=a[b+5>>0];a[k+6>>0]=a[b+6>>0];a[k+7>>0]=a[b+7>>0]}function rb(a){a=a|0;D=a}function sb(){return D|0}function tb(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;e=c[83944+(c[a+16>>2]<<6)+(c[a+84744>>2]<<2)>>2]|0;f=a+85784|0;c[f>>2]=(c[f>>2]|0)+1;f=a+85760|0;e=(c[f>>2]|0)+e|0;c[f>>2]=e;f=a+85764|0;b=(c[f>>2]|0)+1|0;c[f>>2]=b;h=a+85768|0;if((b|0)<(c[h>>2]|0))return;i=a+85772|0;d=c[i>>2]|0;g=a+85776|0;b=c[g>>2]|0;if((d|0)<(b|0)){c[(c[a+85780>>2]|0)+(d<<2)>>2]=e;d=(c[i>>2]|0)+1|0;c[i>>2]=d;c[f>>2]=0;b=c[g>>2]|0}if((d|0)!=(b|0))return;if((b|0)>1){b=c[a+85780>>2]|0;d=1;do{c[b+(((d|0)/2|0)<<2)>>2]=c[b+(d<<2)>>2];d=d+2|0}while((d|0)<(c[g>>2]|0));b=c[i>>2]|0}c[h>>2]=c[h>>2]<<1;c[i>>2]=(b|0)/2|0;return}function ub(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0;h=i;i=i+2896|0;e=h;g=h+8|0;f=c[b+288>>2]|0;b=c[f+16>>2]|0;if((b|0)==1)d=128;else d=(c[f+64>>2]|0)<16e3?32:64;if(!(c[f+104>>2]|0))d=c[f+120>>2]|0;j=$((b*72e3|0)+72e3|0,d)|0;j=(j|0)/(c[f+64>>2]|0)|0;d=(c[f+24>>2]|0)+156|0;b=f+85792|0;c[b>>2]=j;if((j|0)>2880|(j|0)<(d|0)){c[f+156>>2]=0;b=0;i=h;return b|0}c[f+85784>>2]=0;c[f+85788>>2]=0;c[f+85760>>2]=0;c[f+85764>>2]=0;c[f+85768>>2]=1;c[f+85772>>2]=0;d=f+85780|0;do if(!(c[d>>2]|0)){j=qe(1600)|0;c[d>>2]=j;d=f+85776|0;if(j){c[d>>2]=400;break}c[d>>2]=0;Pd(f,8,e);c[f+156>>2]=0;b=-1;i=h;return b|0}while(0);ve(g|0,0,2880)|0;wb(f,g);b=c[b>>2]|0;if(b){d=0;do{Bb(f,a[g+d>>0]|0,1);d=d+1|0}while((d|0)!=(b|0));}b=0;i=h;return b|0}function vb(a,e,f){a=a|0;e=e|0;f=f|0;var g=0,h=0;if((f|0)<=0)return;g=b[a>>1]|0;h=0;do{g=((g&65535)>>>8^c[48+(((g^(d[e+h>>0]|0))&255)<<2)>>2])&65535;b[a>>1]=g;h=h+1|0}while((h|0)!=(f|0));return}function wb(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0;a[e>>0]=-1;j=e+1|0;i=(d[j>>0]|0)<<3|7;a[j>>0]=i;h=b+64|0;i=i<<1|(c[h>>2]|0)>15999;a[j>>0]=i;f=b+16|0;i=(i<<1&62|c[f>>2]&1)<<2|1;a[j>>0]=i;i=i<<1|(c[b+160>>2]|0)==0;a[j>>0]=i;k=e+2|0;g=(d[k>>0]|0)<<4|c[b+84744>>2]&15;a[k>>0]=g;g=g<<2&124|c[b+20>>2]&3;a[k>>0]=g<<1;a[k>>0]=g<<2|c[b+172>>2]&1;g=e+3|0;l=(d[g>>0]|0)<<2|c[b+180>>2]&3;a[g>>0]=l;l=l<<2|c[b+84756>>2]&3;a[g>>0]=l;l=l<<1|c[b+164>>2]&1;a[g>>0]=l;l=l<<1|c[b+168>>2]&1;a[g>>0]=l;a[g>>0]=l<<2|c[b+176>>2]&3;a[e>>0]=-1;g=c[f>>2]|0;if((g|0)==1)e=128;else e=(c[h>>2]|0)<16e3?32:64;if(!(c[b+104>>2]|0))e=c[b+120>>2]|0;if(!(c[b+152>>2]|0)){e=(Jd(e,g,c[h>>2]|0)|0)<<4&255;g=c[f>>2]|0}else e=0;f=i<<24>>24&-15;if((g|0)==1){a[j>>0]=f|10;f=(d[k>>0]|0)&13|e<<24>>24;f=f&255;a[k>>0]=f;return}else{a[j>>0]=f|2;f=(d[k>>0]|0)&13|e&255;f=f&255;a[k>>0]=f;return}}function xb(a){a=a|0;var b=0,d=0,e=0;b=a+16|0;e=c[a+84744>>2]|0;if(!e){d=c[b>>2]|0;b=a+120|0}else{b=c[b>>2]|0;d=b;b=83944+(b<<6)+(e<<2)|0}return (($((d*72e3|0)+72e3|0,c[b>>2]|0)|0)/(c[a+64>>2]|0)|0)+(c[a+84752>>2]|0)<<3|0}function yb(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[a+104>>2]|0;if((d|0)>320){e=c[a>>2]|0;if((b|0)==1){d=(($((e*72e3|0)+72e3|0,d)|0)/(c[a+48>>2]|0)|0)<<3;return d|0}else{d=(e*7680|0)+7680|0;return d|0}}d=c[a>>2]|0;if((b|0)==1){e=c[a+48>>2]|0;d=(($((d*72e3|0)+72e3|0,c[((e|0)<16e3?83944+(d<<6)+32|0:83944+(d<<6)+56|0)>>2]|0)|0)/(e|0)|0)<<3;return d|0}else if((b|0)==2){d=(d*7680|0)+7680|0;return d|0}else{d=11520;return d|0}return 0}function zb(b,e){b=b|0;e=e|0;var f=0,g=0,h=0;h=d[e+2>>0]|0;f=(h&128|0)!=0?262140:196598;f=(((f^h<<10)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<11)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<12)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<13)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<14)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<15)&65536|0)==0?f:f^32773)<<1;g=d[e+3>>0]|0;f=(((f^h<<16)&65536|0)==0?f:f^32773)<<1;f=(((f^g<<9)&65536|0)==0?f:f^32773)<<1;f=(((f^g<<10)&65536|0)==0?f:f^32773)<<1;f=(((f^g<<11)&65536|0)==0?f:f^32773)<<1;f=(((f^g<<12)&65536|0)==0?f:f^32773)<<1;f=(((f^g<<13)&65536|0)==0?f:f^32773)<<1;f=(((f^g<<14)&65536|0)==0?f:f^32773)<<1;f=(((f^g<<15)&65536|0)==0?f:f^32773)<<1;f=((f^g<<16)&65536|0)==0?f:f^32773;g=c[b+24>>2]|0;if((g|0)>6)b=6;else{b=f;g=b>>>8;g=g&255;f=e+4|0;a[f>>0]=g;b=b&255;f=e+5|0;a[f>>0]=b;return}do{h=d[e+b>>0]|0;f=f<<1;f=(((h<<9^f)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<10)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<11)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<12)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<13)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<14)&65536|0)==0?f:f^32773)<<1;f=(((f^h<<15)&65536|0)==0?f:f^32773)<<1;f=((f^h<<16)&65536|0)==0?f:f^32773;b=b+1|0}while((b|0)<(g|0));g=f>>>8;g=g&255;b=e+4|0;a[b>>0]=g;b=f&255;f=e+5|0;a[f>>0]=b;return}function Ab(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;g=i;i=i+16|0;d=c[a+52132>>2]|0;b=c[a+52128>>2]|0;b=(b|0)==0?255:b+-1|0;e=(c[a+39840+(b*48|0)>>2]|0)-(c[a+292>>2]|0)|0;if((e|0)>-1){f=b+(1-d)|0;e=e-($(((b|0)<(d|0)?f+256|0:f)<<3,c[a+24>>2]|0)|0)|0}d=a+16|0;f=c[a+84744>>2]|0;if(!f){b=c[d>>2]|0;d=a+120|0}else{d=c[d>>2]|0;b=d;d=83944+(d<<6)+(f<<2)|0}b=((($((b*72e3|0)+72e3|0,c[d>>2]|0)|0)/(c[a+64>>2]|0)|0)+(c[a+84752>>2]|0)<<3)+e|0;if((b|0)<0){Pd(a,1072,g);i=g;return}else{Fb(a,b);c[a+52140>>2]=0;c[a+21312>>2]=0;i=g;return}}function Bb(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;if(!f)return;h=e&255;i=b+300|0;j=b+296|0;k=b+284|0;l=b+292|0;do{g=8;do{e=c[i>>2]|0;if(!e){c[i>>2]=8;e=(c[j>>2]|0)+1|0;c[j>>2]=e;a[(c[k>>2]|0)+e>>0]=0;e=c[i>>2]|0}m=(g|0)<(e|0)?g:e;g=g-m|0;n=e-m|0;c[i>>2]=n;e=(c[k>>2]|0)+(c[j>>2]|0)|0;a[e>>0]=h>>>g<>0]|0);c[l>>2]=(c[l>>2]|0)+m}while((g|0)>0);e=0;do{m=b+39840+(e*48|0)|0;c[m>>2]=(c[m>>2]|0)+8;e=e+1|0}while((e|0)!=256);f=f+-1|0}while((f|0)!=0);return}function Cb(b){b=b|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0;W=i;i=i+96|0;U=W+88|0;T=W+80|0;S=W+72|0;R=W+64|0;V=W+24|0;Q=W+16|0;P=W+8|0;B=W;J=b+16|0;I=b+84744|0;f=c[I>>2]|0;if(!f){e=c[J>>2]|0;f=b+120|0}else{A=c[J>>2]|0;e=A;f=83944+(A<<6)+(f<<2)|0}L=b+84752|0;K=b+64|0;M=(($((e*72e3|0)+72e3|0,c[f>>2]|0)|0)/(c[K>>2]|0)|0)+(c[L>>2]|0)<<3;N=b+21320|0;Fb(b,c[N>>2]|0);H=b+52128|0;f=c[H>>2]|0;c[b+39840+(f*48|0)+4>>2]=0;O=b+24|0;ve(b+39840+(f*48|0)+8|0,0,c[O>>2]|0)|0;f=c[H>>2]|0;g=c[b+39840+(f*48|0)+4>>2]|0;if((c[K>>2]|0)<16e3){e=12;do{z=8-(g&7)|0;A=(e|0)<(z|0)?e:z;e=e-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=4094>>>e<>0]|0);g=A+g|0;f=c[H>>2]|0}while((e|0)>0);c[b+39840+(f*48|0)+4>>2]=g}else{e=12;do{z=8-(g&7)|0;A=(e|0)<(z|0)?e:z;e=e-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=4095>>>e<>0]|0);g=A+g|0;f=c[H>>2]|0}while((e|0)>0);c[b+39840+(f*48|0)+4>>2]=g}C=b+16|0;h=c[C>>2]|0;e=1;do{z=8-(g&7)|0;A=(e|0)<(z|0)?e:z;e=e-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>e<>0]|0);g=A+g|0;f=c[H>>2]|0}while((e|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=2;do{z=8-(g&7)|0;A=(e|0)<(z|0)?e:z;e=e-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=1>>>e<>0]|0);g=A+g|0;f=c[H>>2]|0}while((e|0)>0);c[b+39840+(f*48|0)+4>>2]=g;D=b+160|0;e=(c[D>>2]|0)==0&1;h=1;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[I>>2]|0;h=4;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+20>>2]|0;h=2;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[L>>2]|0;h=1;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+172>>2]|0;h=1;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+180>>2]|0;h=2;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+84756>>2]|0;h=2;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+164>>2]|0;h=1;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+168>>2]|0;h=1;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+176>>2]|0;h=2;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);h=b+39840+(f*48|0)+4|0;c[h>>2]=g;if(c[D>>2]|0){e=16;do{A=8-(g&7)|0;A=(e|0)<(A|0)?e:A;e=e-A|0;g=A+g|0}while((e|0)>0);c[h>>2]=g}G=b+21312|0;j=c[G>>2]|0;do if((c[C>>2]|0)!=1){h=8;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);h=b+39840+(f*48|0)+4|0;c[h>>2]=g;j=c[b+21316>>2]|0;E=b+72|0;e=c[E>>2]|0;if((e|0)<=0){c[h>>2]=g;break}do{z=8-(g&7)|0;A=(e|0)<(z|0)?e:z;e=e-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>e<>0]|0);g=A+g|0;f=c[H>>2]|0}while((e|0)>0);A=c[E>>2]|0;c[b+39840+(f*48|0)+4>>2]=g;if((A|0)>0){F=0;while(1){h=(c[b+304+(F*5252|0)+4844>>2]|0)+(c[b+304+(F*5252|0)+4768>>2]|0)|0;j=12;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=(c[b+304+(F*5252|0)+4772>>2]|0)/2|0;j=9;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4780>>2]|0;j=8;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4784>>2]|0;j=9;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);j=b+39840+(f*48|0)+4|0;c[j>>2]=g;h=b+304+(F*5252|0)+4788|0;if(!(c[h>>2]|0)){h=1;do{A=8-(g&7)|0;A=(h|0)<(A|0)?h:A;h=h-A|0;g=A+g|0}while((h|0)>0);c[j>>2]=g;e=b+304+(F*5252|0)+4796|0;h=c[e>>2]|0;if((h|0)==14){c[e>>2]=16;f=c[H>>2]|0;h=16;g=c[b+39840+(f*48|0)+4>>2]|0}j=5;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=b+304+(F*5252|0)+4800|0;e=c[h>>2]|0;if((e|0)==14){c[h>>2]=16;f=c[H>>2]|0;e=16;g=c[b+39840+(f*48|0)+4>>2]|0}j=5;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=b+304+(F*5252|0)+4804|0;e=c[h>>2]|0;if((e|0)==14){c[h>>2]=16;f=c[H>>2]|0;e=16;g=c[b+39840+(f*48|0)+4>>2]|0}j=5;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4824>>2]|0;j=4;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4828>>2]|0;j=3;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g}else{j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=1>>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[h>>2]|0;j=2;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4792>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=b+304+(F*5252|0)+4796|0;e=c[h>>2]|0;if((e|0)==14){c[h>>2]=16;f=c[H>>2]|0;g=c[b+39840+(f*48|0)+4>>2]|0;e=16}j=5;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=b+304+(F*5252|0)+4800|0;e=c[h>>2]|0;if((e|0)==14){c[h>>2]=16;f=c[H>>2]|0;g=c[b+39840+(f*48|0)+4>>2]|0;e=16}j=5;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4808>>2]|0;j=3;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4812>>2]|0;j=3;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4816>>2]|0;j=3;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g}h=c[b+304+(F*5252|0)+4836>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*5252|0)+4840>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=F+1|0;if((h|0)<(c[E>>2]|0))F=h;else break}}}else{h=9;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;E=b+72|0;j=c[b+21316>>2]|0;if((c[E>>2]|0)==2){h=3;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g}else{h=5;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g}e=c[E>>2]|0;if((e|0)>0){h=0;do{e=c[b+21328+(h<<4)>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+21328+(h<<4)+4>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+21328+(h<<4)+8>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;e=c[b+21328+(h<<4)+12>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=e>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=h+1|0;e=c[E>>2]|0}while((h|0)<(e|0));g=e;F=0}else{g=e;F=0}do{if((g|0)>0){g=c[b+39840+(f*48|0)+4>>2]|0;e=0;while(1){h=(c[b+304+(F*10504|0)+(e*5252|0)+4844>>2]|0)+(c[b+304+(F*10504|0)+(e*5252|0)+4768>>2]|0)|0;j=12;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=(c[b+304+(F*10504|0)+(e*5252|0)+4772>>2]|0)/2|0;j=9;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4780>>2]|0;j=8;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4784>>2]|0;j=4;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);j=b+39840+(f*48|0)+4|0;c[j>>2]=g;h=b+304+(F*10504|0)+(e*5252|0)+4788|0;if(!(c[h>>2]|0)){h=1;do{A=8-(g&7)|0;A=(h|0)<(A|0)?h:A;h=h-A|0;g=A+g|0}while((h|0)>0);c[j>>2]=g;h=b+304+(F*10504|0)+(e*5252|0)+4796|0;j=c[h>>2]|0;if((j|0)==14){c[h>>2]=16;f=c[H>>2]|0;g=c[b+39840+(f*48|0)+4>>2]|0;j=16}h=5;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=b+304+(F*10504|0)+(e*5252|0)+4800|0;j=c[h>>2]|0;if((j|0)==14){c[h>>2]=16;f=c[H>>2]|0;g=c[b+39840+(f*48|0)+4>>2]|0;j=16}h=5;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=b+304+(F*10504|0)+(e*5252|0)+4804|0;j=c[h>>2]|0;if((j|0)==14){c[h>>2]=16;f=c[H>>2]|0;g=c[b+39840+(f*48|0)+4>>2]|0;j=16}h=5;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4824>>2]|0;j=4;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4828>>2]|0;j=3;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g}else{j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=1>>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[h>>2]|0;j=2;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4792>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=b+304+(F*10504|0)+(e*5252|0)+4796|0;j=c[h>>2]|0;if((j|0)==14){c[h>>2]=16;f=c[H>>2]|0;g=c[b+39840+(f*48|0)+4>>2]|0;j=16}h=5;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=b+304+(F*10504|0)+(e*5252|0)+4800|0;j=c[h>>2]|0;if((j|0)==14){c[h>>2]=16;f=c[H>>2]|0;g=c[b+39840+(f*48|0)+4>>2]|0;j=16}h=5;do{z=8-(g&7)|0;A=(h|0)<(z|0)?h:z;h=h-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=j>>h<>0]|0);g=A+g|0;f=c[H>>2]|0}while((h|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4808>>2]|0;j=3;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4812>>2]|0;j=3;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4816>>2]|0;j=3;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g}h=c[b+304+(F*10504|0)+(e*5252|0)+4832>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4836>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);c[b+39840+(f*48|0)+4>>2]=g;h=c[b+304+(F*10504|0)+(e*5252|0)+4840>>2]|0;j=1;do{z=8-(g&7)|0;A=(j|0)<(z|0)?j:z;j=j-A|0;f=(g>>3)+(b+39840+(f*48|0)+8)|0;a[f>>0]=h>>j<>0]|0);g=A+g|0;f=c[H>>2]|0}while((j|0)>0);h=g;c[b+39840+(f*48|0)+4>>2]=h;e=e+1|0;g=c[E>>2]|0;if((e|0)<(g|0))g=h;else break}}F=F+1|0}while((F|0)!=2);}while(0);if(c[D>>2]|0){zb(b,b+39840+(f*48|0)+8|0);f=c[H>>2]|0}F=f+1&255;c[H>>2]=F;c[b+39840+(F*48|0)>>2]=(c[b+39840+(f*48|0)>>2]|0)+M;F=b+52132|0;if((c[H>>2]|0)==(c[F>>2]|0))Pd(b,1112,B);E=c[O>>2]<<3;D=b+72|0;do if((c[C>>2]|0)==1){s=b+300|0;p=b+296|0;k=b+292|0;n=b+284|0;o=b+21464|0;h=c[D>>2]|0;w=0;g=0;do{if((h|0)>0){u=0;do{v=b+304+(w*10504|0)+(u*5252|0)|0;t=c[b+304+(w*10504|0)+(u*5252|0)+4784>>2]|0;q=c[88648+(t<<2)>>2]|0;t=c[88712+(t<<2)>>2]|0;r=b+304+(w*10504|0)+(u*5252|0)+4868|0;f=c[r>>2]|0;a:do if((f|0)>0){if((q|0)>0){j=f;h=0;f=0}else{h=0;j=0;while(1){h=((c[b+304+(w*10504|0)+(u*5252|0)+4608+(j<<2)>>2]|0)==-1?0:q)+h|0;j=j+1|0;if((j|0)==(f|0))break a}}do{m=c[b+304+(w*10504|0)+(u*5252|0)+4608+(f<<2)>>2]|0;if((m|0)!=-1){l=q;do{j=c[s>>2]|0;if(!j){c[s>>2]=8;j=(c[p>>2]|0)+1|0;c[p>>2]=j;e=c[F>>2]|0;if((c[b+39840+(e*48|0)>>2]|0)==(c[k>>2]|0)){ze((c[n>>2]|0)+j|0,b+39840+(e*48|0)+8|0,c[O>>2]|0)|0;A=c[O>>2]|0;j=(c[p>>2]|0)+A|0;c[p>>2]=j;c[k>>2]=(c[k>>2]|0)+(A<<3);c[F>>2]=(c[F>>2]|0)+1&255}a[(c[n>>2]|0)+j>>0]=0;j=c[s>>2]|0}A=(l|0)<(j|0)?l:j;l=l-A|0;y=j-A|0;c[s>>2]=y;z=(c[n>>2]|0)+(c[p>>2]|0)|0;a[z>>0]=m>>l<>0]|0);c[k>>2]=(c[k>>2]|0)+A}while((l|0)>0);j=c[r>>2]|0;h=h+q|0}f=f+1|0}while((f|0)<(j|0));}else{h=0;f=0}while(0);r=b+304+(w*10504|0)+(u*5252|0)+4860|0;j=c[r>>2]|0;if((f|0)<(j|0)){q=(t|0)>0;do{m=c[b+304+(w*10504|0)+(u*5252|0)+4608+(f<<2)>>2]|0;if((m|0)!=-1){if(q){l=t;do{j=c[s>>2]|0;if(!j){c[s>>2]=8;j=(c[p>>2]|0)+1|0;c[p>>2]=j;e=c[F>>2]|0;if((c[b+39840+(e*48|0)>>2]|0)==(c[k>>2]|0)){ze((c[n>>2]|0)+j|0,b+39840+(e*48|0)+8|0,c[O>>2]|0)|0;A=c[O>>2]|0;j=(c[p>>2]|0)+A|0;c[p>>2]=j;c[k>>2]=(c[k>>2]|0)+(A<<3);c[F>>2]=(c[F>>2]|0)+1&255}a[(c[n>>2]|0)+j>>0]=0;j=c[s>>2]|0}A=(l|0)<(j|0)?l:j;l=l-A|0;y=j-A|0;c[s>>2]=y;z=(c[n>>2]|0)+(c[p>>2]|0)|0;a[z>>0]=m>>l<>0]|0);c[k>>2]=(c[k>>2]|0)+A}while((l|0)>0);j=c[r>>2]|0}h=h+t|0}f=f+1|0}while((f|0)<(j|0));}if((c[b+304+(w*10504|0)+(u*5252|0)+4788>>2]|0)==2){z=(c[o>>2]|0)*3|0;A=b+304+(w*10504|0)+(u*5252|0)+4772|0;j=c[A>>2]|0;z=(z|0)>(j|0)?j:z;j=Gb(b,c[b+304+(w*10504|0)+(u*5252|0)+4796>>2]|0,0,z,v)|0;j=(Gb(b,c[b+304+(w*10504|0)+(u*5252|0)+4800>>2]|0,z,c[A>>2]|0,v)|0)+j|0}else{j=c[b+304+(w*10504|0)+(u*5252|0)+4772>>2]|0;A=c[b+304+(w*10504|0)+(u*5252|0)+4824>>2]|0;y=c[b+21360+(A+1<<2)>>2]|0;A=c[b+21360+(A+2+(c[b+304+(w*10504|0)+(u*5252|0)+4828>>2]|0)<<2)>>2]|0;y=(y|0)>(j|0)?j:y;A=(A|0)>(j|0)?j:A;z=Gb(b,c[b+304+(w*10504|0)+(u*5252|0)+4796>>2]|0,0,y,v)|0;z=(Gb(b,c[b+304+(w*10504|0)+(u*5252|0)+4800>>2]|0,y,A,v)|0)+z|0;j=z+(Gb(b,c[b+304+(w*10504|0)+(u*5252|0)+4804>>2]|0,A,j,v)|0)|0}g=h+g+j+(Hb(b,v)|0)|0;u=u+1|0;h=c[D>>2]|0}while((u|0)<(h|0));}w=w+1|0}while((w|0)!=2);}else{if((c[D>>2]|0)<=0){k=b+292|0;g=0;break}y=b+300|0;z=b+296|0;k=b+292|0;A=b+284|0;B=b+21464|0;C=0;g=0;do{x=b+304+(C*5252|0)|0;w=b+304+(C*5252|0)+5188|0;if((c[b+304+(C*5252|0)+4788>>2]|0)==2){j=0;h=0;v=0;do{u=c[(c[w>>2]|0)+(v<<2)>>2]|0;f=(u|0)/3|0;n=c[b+304+(C*5252|0)+5192+(v<<2)>>2]|0;if((u|0)>2){o=(n|0)>0;u=(f|0)>1?f:1;s=0;t=h;while(1){e=t*3|0;r=c[b+304+(C*5252|0)+4608+(e<<2)>>2]|0;r=(r|0)>0?r:0;if(o){q=n;do{m=c[y>>2]|0;if(!m){c[y>>2]=8;m=(c[z>>2]|0)+1|0;c[z>>2]=m;l=c[F>>2]|0;if((c[b+39840+(l*48|0)>>2]|0)==(c[k>>2]|0)){ze((c[A>>2]|0)+m|0,b+39840+(l*48|0)+8|0,c[O>>2]|0)|0;p=c[O>>2]|0;m=(c[z>>2]|0)+p|0;c[z>>2]=m;c[k>>2]=(c[k>>2]|0)+(p<<3);c[F>>2]=(c[F>>2]|0)+1&255}a[(c[A>>2]|0)+m>>0]=0;m=c[y>>2]|0}l=(q|0)<(m|0)?q:m;q=q-l|0;m=m-l|0;c[y>>2]=m;p=(c[A>>2]|0)+(c[z>>2]|0)|0;a[p>>0]=r>>q<>0]|0);l=(c[k>>2]|0)+l|0;c[k>>2]=l}while((q|0)>0);q=c[b+304+(C*5252|0)+4608+(e+1<<2)>>2]|0;q=(q|0)>0?q:0;r=n;do{m=c[y>>2]|0;if(!m){c[y>>2]=8;m=(c[z>>2]|0)+1|0;c[z>>2]=m;p=c[F>>2]|0;if((c[b+39840+(p*48|0)>>2]|0)==(l|0)){ze((c[A>>2]|0)+m|0,b+39840+(p*48|0)+8|0,c[O>>2]|0)|0;p=c[O>>2]|0;m=(c[z>>2]|0)+p|0;c[z>>2]=m;c[k>>2]=(c[k>>2]|0)+(p<<3);c[F>>2]=(c[F>>2]|0)+1&255}a[(c[A>>2]|0)+m>>0]=0;m=c[y>>2]|0}l=(r|0)<(m|0)?r:m;r=r-l|0;m=m-l|0;c[y>>2]=m;p=(c[A>>2]|0)+(c[z>>2]|0)|0;a[p>>0]=q>>r<>0]|0);l=(c[k>>2]|0)+l|0;c[k>>2]=l}while((r|0)>0);q=c[b+304+(C*5252|0)+4608+(e+2<<2)>>2]|0;q=(q|0)>0?q:0;r=n;p=l;do{l=c[y>>2]|0;if(!l){c[y>>2]=8;l=(c[z>>2]|0)+1|0;c[z>>2]=l;m=c[F>>2]|0;if((c[b+39840+(m*48|0)>>2]|0)==(p|0)){ze((c[A>>2]|0)+l|0,b+39840+(m*48|0)+8|0,c[O>>2]|0)|0;p=c[O>>2]|0;l=(c[z>>2]|0)+p|0;c[z>>2]=l;c[k>>2]=(c[k>>2]|0)+(p<<3);c[F>>2]=(c[F>>2]|0)+1&255}a[(c[A>>2]|0)+l>>0]=0;l=c[y>>2]|0}p=(r|0)<(l|0)?r:l;r=r-p|0;l=l-p|0;c[y>>2]=l;e=(c[A>>2]|0)+(c[z>>2]|0)|0;a[e>>0]=q>>r<>0]|0);p=(c[k>>2]|0)+p|0;c[k>>2]=p}while((r|0)>0);}s=s+1|0;if((s|0)>=(f|0))break;else t=t+1|0}j=($(n*3|0,u)|0)+j|0;h=u+h|0}v=v+1|0}while((v|0)!=4);v=(c[B>>2]|0)*3|0;w=b+304+(C*5252|0)+4772|0;h=c[w>>2]|0;v=(v|0)>(h|0)?h:v;h=Gb(b,c[b+304+(C*5252|0)+4796>>2]|0,0,v,x)|0;h=(Gb(b,c[b+304+(C*5252|0)+4800>>2]|0,v,c[w>>2]|0,x)|0)+h|0}else{j=0;h=0;r=0;do{q=c[(c[w>>2]|0)+(r<<2)>>2]|0;n=c[b+304+(C*5252|0)+5192+(r<<2)>>2]|0;if((q|0)>0){if((n|0)>0){o=0;p=h;while(1){l=c[b+304+(C*5252|0)+4608+(p<<2)>>2]|0;l=(l|0)>0?l:0;m=n;do{f=c[y>>2]|0;if(!f){c[y>>2]=8;f=(c[z>>2]|0)+1|0;c[z>>2]=f;e=c[F>>2]|0;if((c[b+39840+(e*48|0)>>2]|0)==(c[k>>2]|0)){ze((c[A>>2]|0)+f|0,b+39840+(e*48|0)+8|0,c[O>>2]|0)|0;v=c[O>>2]|0;f=(c[z>>2]|0)+v|0;c[z>>2]=f;c[k>>2]=(c[k>>2]|0)+(v<<3);c[F>>2]=(c[F>>2]|0)+1&255}a[(c[A>>2]|0)+f>>0]=0;f=c[y>>2]|0}v=(m|0)<(f|0)?m:f;m=m-v|0;t=f-v|0;c[y>>2]=t;u=(c[A>>2]|0)+(c[z>>2]|0)|0;a[u>>0]=l>>m<>0]|0);c[k>>2]=(c[k>>2]|0)+v}while((m|0)>0);o=o+1|0;if((o|0)==(q|0))break;else p=p+1|0}}j=($(n,q)|0)+j|0;h=q+h|0}r=r+1|0}while((r|0)!=4);h=c[b+304+(C*5252|0)+4772>>2]|0;w=c[b+304+(C*5252|0)+4824>>2]|0;u=c[b+21360+(w+1<<2)>>2]|0;w=c[b+21360+(w+2+(c[b+304+(C*5252|0)+4828>>2]|0)<<2)>>2]|0;u=(u|0)>(h|0)?h:u;w=(w|0)>(h|0)?h:w;v=Gb(b,c[b+304+(C*5252|0)+4796>>2]|0,0,u,x)|0;v=(Gb(b,c[b+304+(C*5252|0)+4800>>2]|0,u,w,x)|0)+v|0;h=v+(Gb(b,c[b+304+(C*5252|0)+4804>>2]|0,w,h,x)|0)|0}g=j+g+h+(Hb(b,x)|0)|0;C=C+1|0}while((C|0)<(c[D>>2]|0));}while(0);h=b+21324|0;Fb(b,c[h>>2]|0);j=g+E+(c[h>>2]|0)|0;c[G>>2]=(c[G>>2]|0)+((M-j|0)/8|0);e=c[F>>2]|0;g=c[H>>2]|0;g=(g|0)==0?255:g+-1|0;f=(c[b+39840+(g*48|0)>>2]|0)-(c[k>>2]|0)|0;if((f|0)>-1){A=g+(1-e)|0;e=f-($(((g|0)<(e|0)?A+256|0:A)<<3,c[O>>2]|0)|0)|0}else e=f;g=c[I>>2]|0;if(!g){f=c[J>>2]|0;g=b+120|0}else{A=c[J>>2]|0;f=A;g=83944+(A<<6)+(g<<2)|0}e=((($((f*72e3|0)+72e3|0,c[g>>2]|0)|0)/(c[K>>2]|0)|0)+(c[L>>2]|0)<<3)+e|0;if((e|0)<0)Pd(b,1072,P);g=b+52140|0;if((e|0)!=(c[g>>2]|0)){Pd(b,1168,Q);e=c[g>>2]|0}f=c[G>>2]<<3;if((f|0)!=(e|0)){z=c[h>>2]|0;y=c[N>>2]|0;A=c[O>>2]<<3;c[V>>2]=f;c[V+4>>2]=e;c[V+8>>2]=z;c[V+12>>2]=y;c[V+16>>2]=A;c[V+20>>2]=j-z-A;c[V+24>>2]=j;c[V+28>>2]=(j|0)%8|0;c[V+32>>2]=M;Pd(b,1224,V);Pd(b,1504,R);Pd(b,1560,S);Pd(b,1640,T);Pd(b,1680,U);c[g>>2]=c[G>>2]<<3}e=c[k>>2]|0;if((e|0)>1e9)f=0;else{i=W;return 0}do{A=b+39840+(f*48|0)|0;c[A>>2]=(c[A>>2]|0)-e;f=f+1|0}while((f|0)!=256);c[k>>2]=0;i=W;return 0}function Db(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0.0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;r=i;i=i+9216|0;p=r;f=a+296|0;h=c[f>>2]|0;q=h+1|0;if((h|0)<0){o=0;i=r;return o|0}if(!((d|0)==0|(h|0)<(d|0))){o=-1;i=r;return o|0}ze(b|0,c[a+284>>2]|0,q|0)|0;c[f>>2]=-1;c[a+300>>2]=0;if(!e){o=q;i=r;return o|0}vb(a+85752|0,b,q);o=a+85788|0;c[o>>2]=(c[o>>2]|0)+q;if(!(c[a+136>>2]|0)){o=q;i=r;return o|0}h=a+85808|0;f=p+4608|0;l=a+132|0;m=a+128|0;n=a+85676|0;o=a+72|0;e=a+85684|0;d=q;while(1){d=Ua(c[h>>2]|0,b|0,d|0,p|0,f|0)|0;d=(d|0)==-1?0:d;if((d|0)>0){if(c[l>>2]|0){j=+g[e>>2];a=0;do{k=+g[p+(a<<2)>>2];if(!(k>j)){k=-k;if(j>2]=k;j=k}}else{g[e>>2]=k;j=k}a=a+1|0}while((a|0)!=(d|0));if((c[o>>2]|0)>1){a=0;do{k=+g[p+4608+(a<<2)>>2];if(!(k>j)){k=-k;if(j>2]=k;j=k}}else{g[e>>2]=k;j=k}a=a+1|0}while((a|0)!=(d|0));}}if((c[m>>2]|0)!=0?(Qa(c[n>>2]|0,p|0,f|0,d|0,c[o>>2]|0)|0)==0:0){f=24;break}}if(!d){f=23;break}else d=0}if((f|0)==23){o=q;i=r;return o|0}else if((f|0)==24){o=-6;i=r;return o|0}return 0}function Eb(a){a=a|0;c[a+52132>>2]=0;c[a+52128>>2]=0;c[a+39840>>2]=0;c[a+284>>2]=qe(147456)|0;c[a+288>>2]=147456;c[a+296>>2]=-1;c[a+300>>2]=0;c[a+292>>2]=0;return}function Fb(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;if((e|0)>7){k=b+300|0;l=b+296|0;m=b+52132|0;n=b+292|0;o=b+284|0;r=b+24|0;h=8;do{f=c[k>>2]|0;if(!f){c[k>>2]=8;f=(c[l>>2]|0)+1|0;c[l>>2]=f;g=c[m>>2]|0;if((c[b+39840+(g*48|0)>>2]|0)==(c[n>>2]|0)){ze((c[o>>2]|0)+f|0,b+39840+(g*48|0)+8|0,c[r>>2]|0)|0;j=c[r>>2]|0;f=(c[l>>2]|0)+j|0;c[l>>2]=f;c[n>>2]=(c[n>>2]|0)+(j<<3);c[m>>2]=(c[m>>2]|0)+1&255}a[(c[o>>2]|0)+f>>0]=0;f=c[k>>2]|0}j=(h|0)<(f|0)?h:f;h=h-j|0;i=f-j|0;c[k>>2]=i;f=(c[o>>2]|0)+(c[l>>2]|0)|0;a[f>>0]=76>>>h<>0];f=(c[n>>2]|0)+j|0;c[n>>2]=f}while((h|0)>0);g=f;f=e+-8|0;if((f|0)>7){j=8;while(1){f=c[k>>2]|0;if(!f){c[k>>2]=8;f=(c[l>>2]|0)+1|0;c[l>>2]=f;h=c[m>>2]|0;if((c[b+39840+(h*48|0)>>2]|0)==(g|0)){ze((c[o>>2]|0)+f|0,b+39840+(h*48|0)+8|0,c[r>>2]|0)|0;i=c[r>>2]|0;f=(c[l>>2]|0)+i|0;c[l>>2]=f;c[n>>2]=(c[n>>2]|0)+(i<<3);c[m>>2]=(c[m>>2]|0)+1&255}a[(c[o>>2]|0)+f>>0]=0;f=c[k>>2]|0}i=(j|0)<(f|0)?j:f;j=j-i|0;h=f-i|0;c[k>>2]=h;f=(c[o>>2]|0)+(c[l>>2]|0)|0;a[f>>0]=65>>>j<>0];f=(c[n>>2]|0)+i|0;c[n>>2]=f;if((j|0)<=0){g=f;break}else g=f}f=e+-16|0;if((f|0)>7){j=8;while(1){f=c[k>>2]|0;if(!f){c[k>>2]=8;f=(c[l>>2]|0)+1|0;c[l>>2]=f;h=c[m>>2]|0;if((c[b+39840+(h*48|0)>>2]|0)==(g|0)){ze((c[o>>2]|0)+f|0,b+39840+(h*48|0)+8|0,c[r>>2]|0)|0;i=c[r>>2]|0;f=(c[l>>2]|0)+i|0;c[l>>2]=f;c[n>>2]=(c[n>>2]|0)+(i<<3);c[m>>2]=(c[m>>2]|0)+1&255}a[(c[o>>2]|0)+f>>0]=0;f=c[k>>2]|0}i=(j|0)<(f|0)?j:f;j=j-i|0;h=f-i|0;c[k>>2]=h;f=(c[o>>2]|0)+(c[l>>2]|0)|0;a[f>>0]=77>>>j<>0];f=(c[n>>2]|0)+i|0;c[n>>2]=f;if((j|0)<=0){g=f;break}else g=f}f=e+-24|0;if((f|0)>7){i=8;do{f=c[k>>2]|0;if(!f){c[k>>2]=8;f=(c[l>>2]|0)+1|0;c[l>>2]=f;h=c[m>>2]|0;if((c[b+39840+(h*48|0)>>2]|0)==(g|0)){ze((c[o>>2]|0)+f|0,b+39840+(h*48|0)+8|0,c[r>>2]|0)|0;j=c[r>>2]|0;f=(c[l>>2]|0)+j|0;c[l>>2]=f;c[n>>2]=(c[n>>2]|0)+(j<<3);c[m>>2]=(c[m>>2]|0)+1&255}a[(c[o>>2]|0)+f>>0]=0;f=c[k>>2]|0}g=(i|0)<(f|0)?i:f;i=i-g|0;h=f-g|0;c[k>>2]=h;j=(c[o>>2]|0)+(c[l>>2]|0)|0;a[j>>0]=69>>>i<>0];g=(c[n>>2]|0)+g|0;c[n>>2]=g}while((i|0)>0);f=e+-32|0;if((f|0)>31){q=Xd()|0;if((we(q|0)|0)>0){e=0;do{j=a[q+e>>0]|0;i=8;do{h=c[k>>2]|0;if(!h){c[k>>2]=8;h=(c[l>>2]|0)+1|0;c[l>>2]=h;g=c[m>>2]|0;if((c[b+39840+(g*48|0)>>2]|0)==(c[n>>2]|0)){ze((c[o>>2]|0)+h|0,b+39840+(g*48|0)+8|0,c[r>>2]|0)|0;g=c[r>>2]|0;h=(c[l>>2]|0)+g|0;c[l>>2]=h;c[n>>2]=(c[n>>2]|0)+(g<<3);c[m>>2]=(c[m>>2]|0)+1&255}a[(c[o>>2]|0)+h>>0]=0;h=c[k>>2]|0}g=(i|0)<(h|0)?i:h;i=i-g|0;p=h-g|0;c[k>>2]=p;h=(c[o>>2]|0)+(c[l>>2]|0)|0;a[h>>0]=j>>i<>0];c[n>>2]=(c[n>>2]|0)+g}while((i|0)>0);f=f+-8|0;e=e+1|0}while((f|0)>7&(e|0)<(we(q|0)|0));p=2}}else p=2}else p=2}else p=2}else p=2}else{f=e;p=2}if((p|0)==2)if((f|0)<=0)return;k=b+52136|0;l=b+300|0;m=b+296|0;n=b+52132|0;o=b+292|0;p=b+284|0;q=b+24|0;e=b+144|0;j=c[k>>2]|0;while(1){i=1;do{h=c[l>>2]|0;if(!h){c[l>>2]=8;h=(c[m>>2]|0)+1|0;c[m>>2]=h;g=c[n>>2]|0;if((c[b+39840+(g*48|0)>>2]|0)==(c[o>>2]|0)){ze((c[p>>2]|0)+h|0,b+39840+(g*48|0)+8|0,c[q>>2]|0)|0;g=c[q>>2]|0;h=(c[m>>2]|0)+g|0;c[m>>2]=h;c[o>>2]=(c[o>>2]|0)+(g<<3);c[n>>2]=(c[n>>2]|0)+1&255}a[(c[p>>2]|0)+h>>0]=0;h=c[l>>2]|0}g=(i|0)<(h|0)?i:h;i=i-g|0;r=h-g|0;c[l>>2]=r;h=(c[p>>2]|0)+(c[m>>2]|0)|0;a[h>>0]=j>>i<>0];c[o>>2]=(c[o>>2]|0)+g}while((i|0)>0);j=(c[e>>2]|0)==0^c[k>>2];c[k>>2]=j;if((f|0)<=1)break;else f=f+-1|0}return}function Gb(b,f,h,i,j){b=b|0;f=f|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;z=c[82272+(f<<4)>>2]|0;if(!((f|0)!=0&(h|0)<(i|0))){i=0;return i|0}A=f>>>0>15;B=z&65535;C=c[82272+(f<<4)+12>>2]|0;y=c[82272+(f<<4)+8>>2]|0;s=b+300|0;t=b+296|0;u=b+52132|0;v=b+292|0;w=b+284|0;x=b+24|0;f=0;do{l=c[j+2304+(h<<2)>>2]|0;q=h+1|0;o=c[j+2304+(q<<2)>>2]|0;if(!l){p=0;k=0}else{p=-1;k=+g[j+(h<<2)>>2]<0.0&1}if(A){if(l>>>0>14){k=k|(l<<1)+131042&131070;l=15;n=B}else n=0;if(o>>>0>14){k=k<>16;q=+g[j+(q<<2)>>2]<0.0|k<<1;k=m}o=($(k,l)|0)+o|0;p=p<<16>>16;m=(n&65535)-p|0;p=(d[C+o>>0]|0)+p|0;o=e[y+(o<<1)>>1]|0;if((p|0)>0){n=p;do{l=c[s>>2]|0;if(!l){c[s>>2]=8;l=(c[t>>2]|0)+1|0;c[t>>2]=l;k=c[u>>2]|0;if((c[b+39840+(k*48|0)>>2]|0)==(c[v>>2]|0)){ze((c[w>>2]|0)+l|0,b+39840+(k*48|0)+8|0,c[x>>2]|0)|0;k=c[x>>2]|0;l=(c[t>>2]|0)+k|0;c[t>>2]=l;c[v>>2]=(c[v>>2]|0)+(k<<3);c[u>>2]=(c[u>>2]|0)+1&255}a[(c[w>>2]|0)+l>>0]=0;l=c[s>>2]|0}k=(n|0)<(l|0)?n:l;n=n-k|0;r=l-k|0;c[s>>2]=r;l=(c[w>>2]|0)+(c[t>>2]|0)|0;a[l>>0]=o>>>n<>0]|0);c[v>>2]=(c[v>>2]|0)+k}while((n|0)>0);}n=m&65535;if(n){m=n;do{k=c[s>>2]|0;if(!k){c[s>>2]=8;k=(c[t>>2]|0)+1|0;c[t>>2]=k;l=c[u>>2]|0;if((c[b+39840+(l*48|0)>>2]|0)==(c[v>>2]|0)){ze((c[w>>2]|0)+k|0,b+39840+(l*48|0)+8|0,c[x>>2]|0)|0;l=c[x>>2]|0;k=(c[t>>2]|0)+l|0;c[t>>2]=k;c[v>>2]=(c[v>>2]|0)+(l<<3);c[u>>2]=(c[u>>2]|0)+1&255}a[(c[w>>2]|0)+k>>0]=0;k=c[s>>2]|0}l=(m|0)<(k|0)?m:k;m=m-l|0;o=k-l|0;c[s>>2]=o;k=(c[w>>2]|0)+(c[t>>2]|0)|0;a[k>>0]=q>>m<>0]|0);c[v>>2]=(c[v>>2]|0)+l}while((m|0)>0);}f=n+f+p|0;h=h+2|0}while((h|0)<(i|0));return f|0}function Hb(b,f){b=b|0;f=f|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;h=(c[f+4840>>2]|0)+32|0;j=c[f+4772>>2]|0;i=(c[f+4776>>2]|0)-j|0;if((i|0)<=3){p=0;return p|0}w=c[82272+(h<<4)+8>>2]|0;p=c[82272+(h<<4)+12>>2]|0;q=b+300|0;r=b+296|0;s=b+52132|0;t=b+292|0;u=b+284|0;v=b+24|0;h=0;n=(i|0)/4|0;o=f+2304+(j<<2)|0;m=f+(j<<2)|0;while(1){if(c[o>>2]|0)if(+g[m>>2]<0.0){i=1;f=8}else{i=0;f=8}else{i=0;f=0}if(c[o+4>>2]|0){f=f|4;i=i<<1;if(+g[m+4>>2]<0.0)i=i|1}if(c[o+8>>2]|0){f=f+2|0;i=i<<1;if(+g[m+8>>2]<0.0)i=i|1}if(c[o+12>>2]|0){f=f+1|0;i=i<<1;if(+g[m+12>>2]<0.0)i=i|1}o=o+16|0;m=m+16|0;l=(e[w+(f<<1)>>1]|0)+i|0;k=p+f|0;j=a[k>>0]|0;if(!(j<<24>>24))i=0;else{i=j&255;do{f=c[q>>2]|0;if(!f){c[q>>2]=8;f=(c[r>>2]|0)+1|0;c[r>>2]=f;j=c[s>>2]|0;if((c[b+39840+(j*48|0)>>2]|0)==(c[t>>2]|0)){ze((c[u>>2]|0)+f|0,b+39840+(j*48|0)+8|0,c[v>>2]|0)|0;j=c[v>>2]|0;f=(c[r>>2]|0)+j|0;c[r>>2]=f;c[t>>2]=(c[t>>2]|0)+(j<<3);c[s>>2]=(c[s>>2]|0)+1&255}a[(c[u>>2]|0)+f>>0]=0;f=c[q>>2]|0}j=(i|0)<(f|0)?i:f;i=i-j|0;x=f-j|0;c[q>>2]=x;f=(c[u>>2]|0)+(c[r>>2]|0)|0;a[f>>0]=l>>i<>0]|0);c[t>>2]=(c[t>>2]|0)+j}while((i|0)>0);i=a[k>>0]|0}h=(i&255)+h|0;if((n|0)<=1)break;else n=n+-1|0}return h|0}function Ib(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0;_=i;i=i+20112|0;L=_+12056|0;M=_+4e3|0;S=_+2048|0;T=_+96|0;Z=_+88|0;Q=_+56|0;X=_+8|0;U=_+40|0;V=_+24|0;P=_;O=_+16|0;p=X;c[p>>2]=1056964608;c[p+4>>2]=1056964608;c[U>>2]=0;c[U+4>>2]=0;c[U+8>>2]=0;c[U+12>>2]=0;c[V>>2]=0;c[V+4>>2]=0;c[V+8>>2]=0;c[V+12>>2]=0;c[Z>>2]=b;c[Z+4>>2]=d;p=a+4|0;if(!(c[p>>2]|0)){K=a+76|0;o=c[K>>2]|0;j=o*576|0;c[p>>2]=1;ve(L|0,0,8056)|0;ve(M|0,0,8056)|0;n=j+862|0;if((n|0)>0){m=a+72|0;l=0;p=0;do{if((l|0)<(j|0)){g[L+(l<<2)>>2]=0.0;if((c[m>>2]|0)==2)g[M+(l<<2)>>2]=0.0}else{c[L+(l<<2)>>2]=c[b+(p<<2)>>2];if((c[m>>2]|0)==2)c[M+(l<<2)>>2]=c[d+(p<<2)>>2];p=p+1|0}l=l+1|0}while((l|0)!=(n|0));}if((o|0)>0){m=a+72|0;p=c[m>>2]|0;n=0;do{if((p|0)>0){o=0;do{c[a+304+(n*10504|0)+(o*5252|0)+4788>>2]=2;o=o+1|0;p=c[m>>2]|0}while((o|0)<(p|0));o=c[K>>2]|0}n=n+1|0}while((n|0)<(o|0));}ac(a,L,M);}p=a+84752|0;c[p>>2]=0;o=a+39836|0;n=(c[o>>2]|0)-(c[a+39832>>2]|0)|0;c[o>>2]=n;if((n|0)<0){c[o>>2]=(c[a+64>>2]|0)+n;c[p>>2]=1}K=P;c[K>>2]=0;c[K+4>>2]=0;K=a+76|0;p=c[K>>2]|0;a:do if((p|0)>0){m=a+72|0;l=a+180|0;j=0;while(1){p=c[m>>2]|0;if((p|0)>0){o=(j*576|0)+304|0;n=0;do{c[P+(n<<2)>>2]=(c[Z+(n<<2)>>2]|0)+(o<<2);n=n+1|0}while((n|0)<(p|0));}if(fc(a,P,j,S,T,U+(j<<3)|0,V+(j<<3)|0,Q+(j<<4)|0,O)|0){j=-4;break}if((c[l>>2]|0)==1?(J=+g[Q+(j<<4)+12>>2],I=J+ +g[Q+(j<<4)+8>>2],N=X+(j<<2)|0,g[N>>2]=I,I>0.0):0)g[N>>2]=J/I;p=c[m>>2]|0;if((p|0)>0){o=0;do{c[a+304+(j*10504|0)+(o*5252|0)+4788>>2]=c[O+(o<<2)>>2];c[a+304+(j*10504|0)+(o*5252|0)+4792>>2]=0;o=o+1|0}while((o|0)<(p|0));}j=j+1|0;p=c[K>>2]|0;if((j|0)>=(p|0))break a}i=_;return j|0}while(0);n=c[a+85796>>2]|0;do if(!(c[n>>2]|0))g[n+8>>2]=1.0;else{r=+g[a+27804>>2];u=+g[a+27812>>2];if((c[a+72>>2]|0)==2){t=+g[a+27808>>2];s=+g[a+27816>>2]}else{t=r;s=u}A=u+s;r=r+t;r=+g[n+4>>2]*.5*((p|0)==2?(r>A?r:A):r);if(r>.03125){o=n+8|0;r=+g[o>>2];if(!(r>=1.0)){p=n+12|0;s=+g[p>>2];if(r>2]=s}else{g[o>>2]=1.0;p=n+12|0}g[p>>2]=1.0;break}s=r*31.98+.000625;p=n+8|0;r=+g[p>>2];do if(!(r>=s)){t=+g[n+12>>2];if(t>=s){g[p>>2]=s;break}if(r>2]=t}else{A=r*(s*.075+.925);g[p>>2]=A;if(A>2]=s}while(0);g[n+12>>2]=s}while(0);ac(a,c[Z>>2]|0,d);O=a+84756|0;c[O>>2]=0;do if(!(c[a+80>>2]|0))if((c[a+180>>2]|0)==1){n=c[K>>2]|0;if((n|0)>0?(R=c[a+72>>2]|0,(R|0)>0):0){o=0;r=0.0;s=0.0;do{p=0;do{s=+g[V+(o<<3)+(p<<2)>>2]+s;r=+g[U+(o<<3)+(p<<2)>>2]+r;p=p+1|0}while((p|0)<(R|0));o=o+1|0}while((o|0)<(n|0));if(!(s<=r)){p=0;break}}R=n+-1|0;if((c[a+5092>>2]|0)==(c[a+10344>>2]|0)?(c[a+304+(R*10504|0)+4788>>2]|0)==(c[a+304+(R*10504|0)+10040>>2]|0):0){c[O>>2]=2;p=1}else p=0}else p=0;else{c[O>>2]=2;p=1}while(0);P=p?T:S;l=p?V:U;Q=a+140|0;if(((c[Q>>2]|0)!=0?(W=a+85804|0,(c[W>>2]|0)!=0):0)?(q=c[K>>2]|0,(q|0)>0):0){n=a+72|0;p=c[n>>2]|0;o=0;do{if((p|0)>0){r=+g[X+(o<<2)>>2];q=0;do{V=c[W>>2]|0;h[V+90904+(o<<3)>>3]=0.0;h[V+90920+(o<<3)>>3]=r;c[V+203288+(o<<3)+(q<<2)>>2]=c[a+304+(o*10504|0)+(q*5252|0)+4788>>2];h[V+189240+(o<<5)+(q<<3)>>3]=+g[l+(o<<3)+(q<<2)>>2];ze(V+54040+(o*9216|0)+(q*4608|0)|0,a+304+(o*10504|0)+(q*5252|0)|0,2304)|0;if((c[O>>2]|0)==2){V=q+2|0;U=c[W>>2]|0;h[U+197144+(o<<5)+(q<<3)>>3]=+h[U+197144+(o<<5)+(V<<3)>>3];ze(U+123704+(o<<15)+(q<<13)|0,U+123704+(o<<15)+(V<<13)|0,8192)|0}q=q+1|0;p=c[n>>2]|0}while((q|0)<(p|0));q=c[K>>2]|0}o=o+1|0}while((o|0)<(q|0));}W=c[a+104>>2]|0;if((W|0)==3|(W|0)==0){j=a+39760|0;ca=c[j>>2]|0;c[a+39756>>2]=ca;o=a+39764|0;ba=c[o>>2]|0;c[j>>2]=ba;j=a+39768|0;L=c[j>>2]|0;c[o>>2]=L;o=a+39772|0;q=c[o>>2]|0;c[j>>2]=q;j=a+39776|0;m=c[j>>2]|0;c[o>>2]=m;o=a+39780|0;N=c[o>>2]|0;c[j>>2]=N;j=a+39784|0;S=c[j>>2]|0;c[o>>2]=S;o=a+39788|0;U=c[o>>2]|0;c[j>>2]=U;j=a+39792|0;W=c[j>>2]|0;c[o>>2]=W;o=a+39796|0;da=c[o>>2]|0;c[j>>2]=da;j=a+39800|0;b=c[j>>2]|0;c[o>>2]=b;o=a+39804|0;V=c[o>>2]|0;c[j>>2]=V;j=a+39808|0;T=c[j>>2]|0;c[o>>2]=T;o=a+39812|0;R=c[o>>2]|0;c[j>>2]=R;j=a+39816|0;d=c[j>>2]|0;c[o>>2]=d;o=a+39820|0;M=c[o>>2]|0;c[j>>2]=M;j=a+39824|0;p=c[j>>2]|0;c[o>>2]=p;o=a+39828|0;aa=c[o>>2]|0;c[j>>2]=aa;j=c[K>>2]|0;n=(j|0)>0;t=(c[k>>2]=da,+g[k>>2]);s=(c[k>>2]=ca,+g[k>>2]);r=(c[k>>2]=ba,+g[k>>2]);v=(c[k>>2]=aa,+g[k>>2]);w=(c[k>>2]=L,+g[k>>2]);x=(c[k>>2]=p,+g[k>>2]);y=(c[k>>2]=q,+g[k>>2]);z=(c[k>>2]=M,+g[k>>2]);A=(c[k>>2]=m,+g[k>>2]);B=(c[k>>2]=d,+g[k>>2]);C=(c[k>>2]=N,+g[k>>2]);D=(c[k>>2]=R,+g[k>>2]);E=(c[k>>2]=S,+g[k>>2]);F=(c[k>>2]=T,+g[k>>2]);G=(c[k>>2]=U,+g[k>>2]);H=(c[k>>2]=V,+g[k>>2]);I=(c[k>>2]=W,+g[k>>2]);J=(c[k>>2]=b,+g[k>>2]);b=c[a+72>>2]|0;if(n&(b|0)>0){u=0.0;p=0;do{q=0;do{u=+g[l+(p<<3)+(q<<2)>>2]+u;q=q+1|0}while((q|0)<(b|0));p=p+1|0}while((p|0)<(j|0));}else u=0.0;g[o>>2]=u;r=+($(j*3350|0,b)|0)/((J+I)*.9354900121688843+((H+G)*.7568249702453613+((F+E)*.5045499801635742+((D+C)*.23387250304222107+((B+A)*3.8980449615198e-17+((z+y)*-.1559150069952011+((x+w)*-.21623599529266357+((v+r)*-.18920649588108063+((u+s)*-.10394349694252014+t)))))))));if(n&(b|0)>0){p=0;do{q=0;do{W=l+(p<<3)+(q<<2)|0;g[W>>2]=+g[W>>2]*r;q=q+1|0}while((q|0)<(b|0));p=p+1|0}while((p|0)<(j|0));}}jb[c[a+85812>>2]&7](a,l,X,P);Cb(a)|0;j=Db(a,e,f,1)|0;if(c[a+156>>2]|0)tb(a);if((c[Q>>2]|0)!=0?(Y=c[a+85804>>2]|0,(Y|0)!=0):0){n=(c[K>>2]|0)*576|0;o=c[a+72>>2]|0;if((o|0)>0){p=0;do{m=0;do{h[Y+24+(p*12800|0)+(m<<3)>>3]=+h[Y+24+(p*12800|0)+(m+n<<3)>>3];m=m+1|0}while((m|0)!=272);m=c[Z+(p<<2)>>2]|0;l=272;do{h[Y+24+(p*12800|0)+(l<<3)>>3]=+g[m+(l+-272<<2)>>2];l=l+1|0}while((l|0)!=1600);p=p+1|0}while((p|0)<(o|0));}g[a+84908>>2]=1.0;Bc(a,P);}n=a+84748|0;c[n>>2]=(c[n>>2]|0)+1;n=a+84744|0;q=a+84040+((c[n>>2]|0)*20|0)+16|0;c[q>>2]=(c[q>>2]|0)+1;q=a+84356|0;c[q>>2]=(c[q>>2]|0)+1;q=a+72|0;if((c[q>>2]|0)==2){W=a+84040+((c[n>>2]|0)*20|0)+(c[O>>2]<<2)|0;c[W>>2]=(c[W>>2]|0)+1;W=a+84340+(c[O>>2]<<2)|0;c[W>>2]=(c[W>>2]|0)+1}l=c[K>>2]|0;if((l|0)<=0){W=j;i=_;return W|0}o=a+84740|0;m=c[q>>2]|0;p=0;do{if((m|0)>0){l=0;do{m=(c[a+304+(p*10504|0)+(l*5252|0)+4792>>2]|0)==0?c[a+304+(p*10504|0)+(l*5252|0)+4788>>2]|0:4;W=a+84360+((c[n>>2]|0)*24|0)+(m<<2)|0;c[W>>2]=(c[W>>2]|0)+1;W=a+84360+((c[n>>2]|0)*24|0)+20|0;c[W>>2]=(c[W>>2]|0)+1;m=a+84720+(m<<2)|0;c[m>>2]=(c[m>>2]|0)+1;c[o>>2]=(c[o>>2]|0)+1;l=l+1|0;m=c[q>>2]|0}while((l|0)<(m|0));l=c[K>>2]|0}p=p+1|0}while((p|0)<(l|0));i=_;return j|0}function Jb(a,b,e,f){a=a|0;b=b|0;e=e|0;f=f|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0;l=f+(e<<2)|0;e=a+85820|0;h=0;i=b;while(1){k=h;h=h+1|0;f=($(h,12582912)|0)>>16;a=c[l>>2]|0;j=31;k=b+(k<<10)+512|0;while(1){s=d[1720+(j<<2)>>0]|0;t=s+f|0;r=+g[a+(t<<2)>>2]*+g[1848+(s<<2)>>2];o=+g[a+(t+128<<2)>>2]*+g[1848+(127-s<<2)>>2];p=r-o;r=o+r;o=+g[a+(t+64<<2)>>2]*+g[1848+(s+64<<2)>>2];n=+g[a+(t+192<<2)>>2]*+g[1848+(63-s<<2)>>2];q=o-n;o=n+o;m=k;k=k+-16|0;g[k>>2]=o+r;g[m+-8>>2]=r-o;g[m+-12>>2]=q+p;g[m+-4>>2]=p-q;q=+g[a+(t+1<<2)>>2]*+g[1848+(s+1<<2)>>2];p=+g[a+(t+129<<2)>>2]*+g[1848+(126-s<<2)>>2];o=q-p;q=p+q;p=+g[a+(t+65<<2)>>2]*+g[1848+(s+65<<2)>>2];r=+g[a+(t+193<<2)>>2]*+g[1848+(62-s<<2)>>2];n=p-r;p=r+p;g[m+496>>2]=p+q;g[m+504>>2]=q-p;g[m+500>>2]=n+o;g[m+508>>2]=o-n;if((j|0)<=0)break;else j=j+-1|0}hb[c[e>>2]&3](i,128);if((h|0)==3)break;else i=i+1024|0}return}function Kb(a,b,e,f){a=a|0;b=b|0;e=e|0;f=f|0;var h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0;f=c[f+(e<<2)>>2]|0;e=b+2048|0;h=127;while(1){o=d[1720+h>>0]|0;n=+g[f+(o<<2)>>2]*+g[2360+(o<<2)>>2];i=o|512;k=+g[f+(i<<2)>>2]*+g[2360+(i<<2)>>2];l=n-k;n=k+n;i=o|256;k=+g[f+(i<<2)>>2]*+g[2360+(i<<2)>>2];i=o|768;j=+g[f+(i<<2)>>2]*+g[2360+(i<<2)>>2];m=k-j;k=j+k;i=e;e=e+-16|0;g[e>>2]=k+n;g[i+-8>>2]=n-k;g[i+-12>>2]=m+l;g[i+-4>>2]=l-m;p=o+1|0;m=+g[f+(p<<2)>>2]*+g[2360+(p<<2)>>2];p=o+513|0;l=+g[f+(p<<2)>>2]*+g[2360+(p<<2)>>2];k=m-l;m=l+m;p=o+257|0;l=+g[f+(p<<2)>>2]*+g[2360+(p<<2)>>2];o=o+769|0;n=+g[f+(o<<2)>>2]*+g[2360+(o<<2)>>2];j=l-n;l=n+l;g[i+2032>>2]=l+m;g[i+2040>>2]=m-l;g[i+2036>>2]=j+k;g[i+2044>>2]=k-j;if((h|0)<=0)break;else h=h+-1|0}hb[c[a+85820>>2]&3](b,512);return}function Lb(a){a=a|0;var b=0,d=0.0;b=0;do{d=+(b|0)+.5;g[2360+(b<<2)>>2]=.42-+R(+(d*.006135923151542565))*.5+ +R(+(d*.01227184630308513))*.08;b=b+1|0}while((b|0)!=1024);b=0;do{g[1848+(b<<2)>>2]=(1.0-+R(+((+(b|0)+.5)*.02454369260617026)))*.5;b=b+1|0}while((b|0)!=128);c[a+85820>>2]=1;return}function Mb(a,b){a=a|0;b=b|0;var c=0,d=0.0,e=0.0,f=0.0,h=0,i=0.0,j=0,k=0.0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0,v=0,w=0.0,x=0.0,y=0,z=0.0,A=0,B=0.0,C=0,D=0.0,E=0.0,F=0,G=0.0;l=b<<1;m=a+(l<<2)|0;q=4;s=6456;while(1){n=q>>1;o=q<<1;p=q*3|0;r=q;q=q<<2;b=a;c=a+(n<<2)|0;while(1){d=+g[b>>2];j=b+(r<<2)|0;i=+g[j>>2];f=d-i;d=i+d;t=b+(o<<2)|0;i=+g[t>>2];h=b+(p<<2)|0;k=+g[h>>2];e=i-k;i=k+i;g[t>>2]=d-i;g[b>>2]=i+d;g[h>>2]=f-e;g[j>>2]=e+f;f=+g[c>>2];j=c+(r<<2)|0;e=+g[j>>2];d=f-e;f=e+f;h=c+(p<<2)|0;e=+g[h>>2]*1.4142135623730951;t=c+(o<<2)|0;i=+g[t>>2]*1.4142135623730951;g[t>>2]=f-i;g[c>>2]=i+f;g[h>>2]=d-e;g[j>>2]=e+d;b=b+(q<<2)|0;if(b>>>0>=m>>>0)break;else c=c+(q<<2)|0}h=s+4|0;if((r|0)>2){i=+g[s>>2];j=1;k=+g[h>>2];while(1){e=k*2.0;f=1.0-e*k;e=e*i;c=a+(j<<2)|0;b=a+(r-j<<2)|0;while(1){t=c+(r<<2)|0;B=+g[t>>2];A=b+(r<<2)|0;D=+g[A>>2];w=B*e-D*f;B=D*e+B*f;D=+g[c>>2];d=D-B;D=B+D;B=+g[b>>2];u=B-w;w=B+w;v=c+(p<<2)|0;B=+g[v>>2];C=b+(p<<2)|0;G=+g[C>>2];z=B*e-G*f;B=G*e+B*f;F=c+(o<<2)|0;G=+g[F>>2];x=G-B;G=B+G;y=b+(o<<2)|0;B=+g[y>>2];E=B-z;z=B+z;B=G*k-E*i;E=G*i+E*k;g[F>>2]=D-E;g[c>>2]=E+D;g[C>>2]=u-B;g[A>>2]=B+u;u=z*i-x*k;x=z*k+x*i;g[y>>2]=w-x;g[b>>2]=x+w;g[v>>2]=d-u;g[t>>2]=u+d;c=c+(q<<2)|0;if(c>>>0>=m>>>0)break;else b=b+(q<<2)|0}d=+g[s>>2];e=+g[h>>2];f=e*i+d*k;j=j+1|0;if((j|0)>=(n|0))break;else{i=d*i-e*k;k=f}}}if((q|0)>=(l|0))break;else s=s+8|0}return}function Nb(d,e,f){d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0.0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;y=i;i=i+1040|0;g=y;q=y+8|0;if(!d){d=0;i=y;return d|0}h=d+288|0;v=c[h>>2]|0;if(!v){d=0;i=y;return d|0}s=v+85696|0;j=c[s>>2]|0;if(j&4){d=0;i=y;return d|0}m=c[v+85704>>2]|0;if(!m)k=0;else k=we(m|0)|0;m=c[v+85708>>2]|0;if(!m)p=0;else p=we(m|0)|0;n=c[v+85712>>2]|0;if(!n)n=0;else n=we(n|0)|0;o=c[v+85716>>2]|0;if(!o)o=0;else o=we(o|0)|0;if(!(k>>>0>30|p>>>0>30|n>>>0>30|o>>>0>30)?(j&10|0)==0&(o>>>0<29|(c[v+85720>>2]|0)==0):0){d=0;i=y;return d|0}k=c[d+4>>2]|0;if((k|0)!=-1){l=+(k>>>0)*1.0e3/+(c[v+60>>2]|0);if(!(l>4294967295.0))if(l<0.0)k=0;else k=~~l>>>0;else k=-1;c[g>>2]=k;je(q,6496,g)|0;k=c[h>>2]|0;if(k){p=k+85696|0;o=c[p>>2]|0;Rb(d,1414284622,6488,0,q)|0;c[p>>2]=o}}t=v+85728|0;do if((c[t>>2]|0)!=0?(r=c[v+85732>>2]|0,(r|0)!=0):0){k=c[v+85740>>2]|0;if((k|0)==2)k=6504;else if((k|0)==3)k=6520;else if((k|0)==1)k=6536;else{u=0;k=10;break}u=k;k=(we(k|0)|0)+24+r|0}else{u=0;k=10}while(0);d=v+85744|0;j=c[d>>2]|0;if(j)do{h=c[j+4>>2]|0;do if((h|0)==1431520594|(h|0)==1129270605){h=c[j+16>>2]|0;h=(c[j+20>>2]|0)==1?(h<<1)+16|0:h+15|0;m=c[j+28>>2]|0;if((c[j+32>>2]|0)==1){h=h+(m<<1)|0;break}else{h=h+m|0;break}}else{q=h&-16777216;if(!((q|0)==0|(q|0)==1459617792)){n=c[j+16>>2]|0;m=(n|0)!=0;h=c[j+28>>2]|0;if((c[j+32>>2]|0)==1){h=(m?(n<<1)+13|0:11)+(h<<1)|0;break}else{h=(m?n+12|0:11)+h|0;break}}h=c[j+16>>2]|0;do if(h)if((c[j+20>>2]|0)==1){h=(h<<1)+13|0;break}else{h=h+12|0;break}else h=10;while(0);m=c[j+28>>2]|0;if(m)if((c[j+32>>2]|0)==1){h=h+-1+m|0;break}else{h=m+h|0;break}}while(0);k=h+k|0;j=c[j>>2]|0}while((j|0)!=0);if(!(c[s>>2]&32))s=k;else s=(c[v+85736>>2]|0)+k|0;if(s>>>0>f>>>0){d=s;i=y;return d|0}if(!e){d=0;i=y;return d|0}a[e>>0]=73;a[e+1>>0]=68;a[e+2>>0]=51;a[e+3>>0]=3;a[e+4>>0]=0;a[e+5>>0]=0;k=s+-10|0;a[e+6>>0]=k>>>21&127;a[e+7>>0]=k>>>14&127;a[e+8>>0]=k>>>7&127;g=e+10|0;a[e+9>>0]=k&127;k=c[d>>2]|0;if(k){f=g;while(1){d=c[k+4>>2]|0;do if((d|0)==1431520594|(d|0)==1129270605){p=k+20|0;j=k+16|0;n=c[j>>2]|0;h=k+32|0;q=k+28|0;n=(c[q>>2]<<((c[h>>2]|0)==1&1))+((c[p>>2]|0)==1?(n<<1)+16|0:n+15|0)|0;if(n>>>0>10){a[f+3>>0]=d;a[f+2>>0]=d>>>8;a[f+1>>0]=d>>>16;a[f>>0]=d>>>24;r=n+-10|0;a[f+7>>0]=r;a[f+6>>0]=r>>>8;a[f+5>>0]=r>>>16;a[f+4>>0]=r>>>24;a[f+8>>0]=0;a[f+9>>0]=0;r=k+24|0;a[f+10>>0]=(c[h>>2]|0)==1&1;a[f+11>>0]=a[k+8>>0]|0;a[f+12>>0]=a[k+9>>0]|0;m=f+14|0;a[f+13>>0]=a[k+10>>0]|0;o=k+12|0;if((c[p>>2]|0)==1){p=c[o>>2]|0;o=c[j>>2]|0;if(!o){o=15;n=16}else{g=b[p>>1]|0;n=g<<16>>16==-2;j=o<<1;o=o+-1|0;d=(g&65535)>>>8;a[m>>0]=n?d:g;a[f+15>>0]=n?-2:d&255;if(o)do{p=p+2|0;d=m;m=m+2|0;z=b[p>>1]|0;o=o+-1|0;g=(z&65535)>>>8;a[m>>0]=n?g:z;a[d+3>>0]=n?z:g}while((o|0)!=0);m=f+(j+14)|0;o=j+15|0;n=j+16|0}a[m>>0]=0;a[f+o>>0]=0}else{p=c[j>>2]|0;if(!p)n=15;else{o=c[o>>2]|0;n=p;while(1){n=n+-1|0;a[m>>0]=a[o>>0]|0;if(!n)break;else{o=o+1|0;m=m+1|0}}m=f+(p+14)|0;n=p+15|0}a[m>>0]=0}g=f+n|0;if((c[h>>2]|0)==1){o=c[r>>2]|0;m=c[q>>2]|0;if(!m)break;q=b[o>>1]|0;p=q<<16>>16==-2;j=m<<1;m=m+-1|0;d=(q&65535)>>>8;a[g>>0]=p?d:q;a[f+(n+1)>>0]=p?-2:d&255;if(m)do{o=o+2|0;d=g;g=g+2|0;h=b[o>>1]|0;m=m+-1|0;q=(h&65535)>>>8;a[g>>0]=p?q:h;a[d+3>>0]=p?h:q}while((m|0)!=0);g=f+(j+n)|0;break}else{o=c[q>>2]|0;if(!o)break;j=c[r>>2]|0;m=o;while(1){m=m+-1|0;a[g>>0]=a[j>>0]|0;if(!m)break;else{j=j+1|0;g=g+1|0}}g=f+(o+n)|0;break}}else g=f}else{q=d&-16777216;if(!((q|0)==0|(q|0)==1459617792)){r=k+32|0;p=k+16|0;o=c[p>>2]|0;n=(o|0)!=0;h=k+28|0;m=c[h>>2]|0;if((c[r>>2]|0)==1)n=(n?(o<<1)+13|0:11)+(m<<1)|0;else n=(n?o+12|0:11)+m|0;if(n>>>0<=10){g=f;break}a[f+3>>0]=d;a[f+2>>0]=d>>>8;a[f+1>>0]=d>>>16;a[f>>0]=d>>>24;d=n+-10|0;a[f+7>>0]=d;a[f+6>>0]=d>>>8;a[f+5>>0]=d>>>16;a[f+4>>0]=d>>>24;a[f+8>>0]=0;a[f+9>>0]=0;d=k+24|0;g=f+11|0;a[f+10>>0]=(c[r>>2]|0)==1&1;p=c[p>>2]|0;do if(p){n=k+12|0;if((c[k+20>>2]|0)==1){o=c[n>>2]|0;j=b[o>>1]|0;n=j<<16>>16==-2;m=p<<1;p=p+-1|0;q=(j&65535)>>>8;a[g>>0]=n?q:j;a[f+12>>0]=n?-2:q&255;if(p)do{o=o+2|0;q=g;g=g+2|0;z=b[o>>1]|0;p=p+-1|0;j=(z&65535)>>>8;a[g>>0]=n?j:z;a[q+3>>0]=n?z:j}while((p|0)!=0);a[f+(m+11)>>0]=0;a[f+(m+12)>>0]=0;g=f+(m+13)|0;break}else{o=c[n>>2]|0;n=p;while(1){n=n+-1|0;a[g>>0]=a[o>>0]|0;if(!n)break;else{o=o+1|0;g=g+1|0}}a[f+(p+11)>>0]=0;g=f+(p+12)|0;break}}while(0);if((c[r>>2]|0)==1){o=c[d>>2]|0;m=c[h>>2]|0;if(!m)break;q=b[o>>1]|0;p=q<<16>>16==-2;h=m<<1;n=m+-1|0;d=(q&65535)>>>8;a[g>>0]=p?d:q;a[g+1>>0]=p?-2:d&255;if(n){j=g;m=o;do{m=m+2|0;d=j;j=j+2|0;o=b[m>>1]|0;n=n+-1|0;q=(o&65535)>>>8;a[j>>0]=p?q:o;a[d+3>>0]=p?o:q}while((n|0)!=0);}g=g+h|0;break}else{n=c[h>>2]|0;if(!n)break;j=c[d>>2]|0;h=g;m=n;while(1){m=m+-1|0;a[h>>0]=a[j>>0]|0;if(!m)break;else{j=j+1|0;h=h+1|0}}g=g+n|0;break}}p=k+16|0;j=c[p>>2]|0;do if(j)if((c[k+20>>2]|0)==1){m=(j<<1)+13|0;break}else{m=j+12|0;break}else m=10;while(0);r=k+28|0;j=c[r>>2]|0;do if(j)if((c[k+32>>2]|0)==1){m=m+-1+j|0;break}else{m=j+m|0;break}while(0);if(m>>>0<=10){g=f;break}a[f+3>>0]=d;a[f+2>>0]=d>>>8;a[f+1>>0]=d>>>16;a[f>>0]=d>>>24;g=m+-10|0;a[f+7>>0]=g;a[f+6>>0]=g>>>8;a[f+5>>0]=g>>>16;a[f+4>>0]=g>>>24;a[f+8>>0]=0;g=f+10|0;a[f+9>>0]=0;do if(c[p>>2]|0){d=k+20|0;h=f+11|0;a[g>>0]=(c[d>>2]|0)==1&1;m=k+12|0;if((c[d>>2]|0)==1){o=c[m>>2]|0;n=c[p>>2]|0;if(!n){j=12;m=13}else{q=b[o>>1]|0;p=q<<16>>16==-2;m=n<<1;n=n+-1|0;d=(q&65535)>>>8;a[h>>0]=p?d:q;a[f+12>>0]=p?-2:d&255;if(n)do{o=o+2|0;d=h;h=h+2|0;j=b[o>>1]|0;n=n+-1|0;q=(j&65535)>>>8;a[h>>0]=p?q:j;a[d+3>>0]=p?j:q}while((n|0)!=0);h=f+(m+11)|0;j=m+12|0;m=m+13|0}a[h>>0]=0;a[f+j>>0]=0;g=f+m|0;break}else{o=c[p>>2]|0;if(!o)j=12;else{n=c[m>>2]|0;m=o;while(1){m=m+-1|0;a[h>>0]=a[n>>0]|0;if(!m)break;else{n=n+1|0;h=h+1|0}}h=f+(o+11)|0;j=o+12|0}a[h>>0]=0;g=f+j|0;break}}while(0);j=k+24|0;if((c[k+32>>2]|0)!=1){n=c[r>>2]|0;if(!n)break;j=c[j>>2]|0;h=g;m=n;while(1){m=m+-1|0;a[h>>0]=a[j>>0]|0;if(!m)break;else{j=j+1|0;h=h+1|0}}g=g+n|0;break}n=c[j>>2]|0;m=c[r>>2]|0;if(!m)break;j=b[n>>1]|0;if(j<<16>>16==-257|j<<16>>16==-2){m=m+-1|0;if(!m)break;else n=n+2|0}p=j<<16>>16==-2;h=g;o=m;while(1){o=o+-1|0;j=b[n>>1]|0;if(p){j=j&65535;j=(j<<8|j>>>8)&65535}a[h>>0]=(j+-32&65535)>223?32:j&255;if(!o)break;else{n=n+2|0;h=h+1|0}}g=g+m|0}while(0);k=c[k>>2]|0;if(!k)break;else f=g}}if((u|0)!=0?(w=c[t>>2]|0,x=c[v+85732>>2]|0,(w|0)!=0&(x|0)!=0):0){a[g+3>>0]=67;a[g+2>>0]=73;a[g+1>>0]=80;a[g>>0]=65;k=x+4+(we(u|0)|0)|0;a[g+7>>0]=k;a[g+6>>0]=k>>>8;a[g+5>>0]=k>>>16;a[g+4>>0]=k>>>24;a[g+8>>0]=0;a[g+9>>0]=0;k=g+11|0;a[g+10>>0]=0;j=a[u>>0]|0;if(j<<24>>24){g=u;h=k;while(1){g=g+1|0;k=h+1|0;a[h>>0]=j;j=a[g>>0]|0;if(!(j<<24>>24))break;else h=k}}a[k>>0]=0;a[k+1>>0]=0;a[k+2>>0]=0;g=w;h=x;j=k+3|0;while(1){h=h+-1|0;a[j>>0]=a[g>>0]|0;if(!h)break;else{g=g+1|0;j=j+1|0}}g=k+(x+3)|0}ve(g|0,0,s+e-g|0)|0;d=s;i=y;return d|0}function Ob(b){b=b|0;var d=0,e=0,f=0,g=0;f=c[b+288>>2]|0;if((c[f+85696>>2]&5|0)!=1){b=0;return b|0}d=Nb(b,0,0)|0;g=se(d,1)|0;if(!g){b=-1;return b|0}e=Nb(b,g,d)|0;if(e>>>0>d>>>0){re(g);b=-1;return b|0}if(e){b=0;do{Bb(f,a[g+b>>0]|0,1);b=b+1|0}while((b|0)!=(e|0));}re(g);b=e;return b|0}function Pb(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;s=i;i=i+16|0;m=s;n=s+4|0;if(!b){m=0;i=s;return m|0}if(e>>>0<128){m=128;i=s;return m|0}r=c[b+288>>2]|0;if((d|0)==0|(r|0)==0){m=0;i=s;return m|0}b=c[r+85696>>2]|0;if((b&9|0)!=1){m=0;i=s;return m|0}a[d>>0]=84;a[d+1>>0]=65;a[d+2>>0]=71;p=b<<1&32;f=d+3|0;h=c[r+85704>>2]|0;b=30;a:while(1){e=(h|0)==0;g=f;while(1){b=b+-1|0;if(!e?(j=a[h>>0]|0,j<<24>>24!=0):0){e=j;break}f=g+1|0;a[g>>0]=p;if(!b)break a;else g=f}f=g+1|0;a[g>>0]=e;if(!b)break;else h=h+1|0}h=c[r+85708>>2]|0;b=30;b:while(1){g=(h|0)==0;while(1){b=b+-1|0;if(!g?(k=a[h>>0]|0,k<<24>>24!=0):0){d=f;e=k;break}e=f+1|0;a[f>>0]=p;if(!b){f=e;break b}else f=e}f=d+1|0;a[d>>0]=e;if(!b)break;else h=h+1|0}g=c[r+85712>>2]|0;b=30;c:while(1){d=(g|0)==0;while(1){b=b+-1|0;if(!d?(l=a[g>>0]|0,l<<24>>24!=0):0){d=f;e=l;break}e=f+1|0;a[f>>0]=p;if(!b){f=e;break c}else f=e}f=d+1|0;a[d>>0]=e;if(!b)break;else g=g+1|0}g=r+85700|0;c[m>>2]=c[g>>2];je(n,6552,m)|0;g=(c[g>>2]|0)!=0?n:0;e=4;d:while(1){d=(g|0)==0;while(1){e=e+-1|0;if(!d?(o=a[g>>0]|0,o<<24>>24!=0):0){d=f;b=o;break}b=f+1|0;a[f>>0]=p;if(!e){f=b;break d}else f=b}f=d+1|0;a[d>>0]=b;if(!e)break;else g=g+1|0}h=r+85720|0;g=c[r+85716>>2]|0;e=(c[h>>2]|0)!=0?28:30;e:while(1){b=(g|0)==0;d=f;while(1){e=e+-1|0;if(!b?(q=a[g>>0]|0,q<<24>>24!=0):0){b=q;break}f=d+1|0;a[d>>0]=p;if(!e)break e;else d=f}f=d+1|0;a[d>>0]=b;if(!e)break;else g=g+1|0}if(c[h>>2]|0){a[f>>0]=0;a[d+2>>0]=c[h>>2];f=d+3|0}a[f>>0]=c[r+85724>>2];m=128;i=s;return m|0}function Qb(b){b=b|0;var d=0,e=0,f=0,g=0;g=i;i=i+128|0;f=g;e=c[b+288>>2]|0;b=Pb(b,f,128)|0;if((b+-1|0)>>>0>127){b=0;i=g;return b|0}else d=0;do{Bb(e,a[f+d>>0]|0,1);d=d+1|0}while((d|0)!=(b|0));i=g;return b|0}function Rb(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(!b){n=-255;return n|0}o=c[b+288>>2]|0;if(!o){n=-255;return n|0}k=o+85744|0;b=c[k>>2]|0;a:do if(!b)b=0;else while(1){if((c[b+4>>2]|0)==(d|0))break a;b=c[b>>2]|0;if(!b){b=0;break}}while(0);b:do if((d|0)==1347570006|(d|0)==1196575044|(d|0)==1162756946|(d|0)==1279872587|(d|0)==1095061059|(d|0)==1346588244|(d|0)==1195724610|(d|0)==1095780675|(d|0)==1398361172|(d|0)==1129270605|(d|0)==1465407576|(d|0)==1415075928)if(!b)m=25;else{if(!f)c:while(1){if((Sb(b+8|0,e)|0)!=0?(c[b+16>>2]|0)==0:0){j=b;break b}b=c[b>>2]|0;if(!b){m=25;break b}while(1){if((c[b+4>>2]|0)==(d|0))continue c;b=c[b>>2]|0;if(!b){m=25;break b}}}d:while(1){e:do if(Sb(b+8|0,e)|0){j=c[b+16>>2]|0;i=(j|0)==0;if((c[b+20>>2]|0)==1)if(i){j=b;break b}else break;if(i){j=b;break b}i=c[b+12>>2]|0;h=0;while(1){if((a[i+h>>0]|0)!=(a[f+h>>0]|0))break e;h=h+1|0;if(h>>>0>=j>>>0){m=24;break b}}}while(0);b=c[((b|0)==0?k:b)>>2]|0;if(!b){m=25;break b}while(1){if((c[b+4>>2]|0)==(d|0))continue d;b=c[b>>2]|0;if(!b){m=25;break b}}}}else m=24;while(0);if((m|0)==24)if(!b)m=25;else j=b;if((m|0)==25){b=se(1,36)|0;if(!b){n=-254;return n|0}i=o+85748|0;h=c[i>>2]|0;if((h|0)!=0?(c[k>>2]|0)!=0:0)c[h>>2]=b;else c[k>>2]=b;c[i>>2]=b;j=b}c[j+4>>2]=d;b=j+8|0;do if((e|0)!=0?(l=a[e>>0]|0,l<<24>>24!=0):0){a[b>>0]=l;if(a[e>>0]|0){a[j+9>>0]=a[e+1>>0]|0;if(!(a[e>>0]|0))i=2;else{a[j+10>>0]=a[e+2>>0]|0;break}}else i=1;ve(j+8+i|0,32,i^3|0)|0}else m=33;while(0);if((m|0)==33){a[b>>0]=88;a[j+9>>0]=88;a[j+10>>0]=88}b=j+12|0;re(c[b>>2]|0);c[b>>2]=0;if(f){h=0;while(1){i=h+1|0;if(!(a[f+h>>0]|0))break;else h=i}if((h|0)!=0?(n=se(i,1)|0,c[b>>2]=n,(n|0)!=0):0){ze(n|0,f|0,h|0)|0;a[n+h>>0]=0}else h=0}else h=0;c[j+16>>2]=h;c[j+20>>2]=0;b=j+24|0;re(c[b>>2]|0);c[b>>2]=0;if(g){h=0;while(1){i=h+1|0;if(!(a[g+h>>0]|0))break;else h=i}if((h|0)!=0?(p=se(i,1)|0,c[b>>2]=p,(p|0)!=0):0){ze(p|0,g|0,h|0)|0;a[p+h>>0]=0}else h=0}else h=0;c[j+28>>2]=h;c[j+32>>2]=0;n=o+85696|0;c[n>>2]=c[n>>2]|3;n=0;return n|0}function Sb(b,c){b=b|0;c=c|0;var d=0,e=0,f=0;if((c|0)!=0?(d=a[c>>0]|0,d<<24>>24!=0):0){e=a[c+1>>0]|0;c=a[c+2>>0]|0}else{d=88;e=88;c=88}f=$d(a[b>>0]|0)|0;d=$d(d<<24>>24)|0;if((((d&255)<<24>>24<32?32:d)^((f&255)<<24>>24<32?32:f))&255)return 0;d=$d(a[b+1>>0]|0)|0;e=$d(e<<24>>24)|0;if(!((((e&255)<<24>>24<32?32:e)^((d&255)<<24>>24<32?32:d))&255)){d=$d(a[b+2>>0]|0)|0;c=$d(c<<24>>24)|0;return ((((c&255)<<24>>24<32?32:c)^((d&255)<<24>>24<32?32:d))&255|0)==0|0}else return 0;return 0}function Tb(a){a=a|0;if(!a){a=0;return a|0}a=(c[a>>2]|0)==-487877&1;return a|0}function Ub(a){a=a|0;var b=0,d=0,e=0.0,f=0.0,h=0.0,j=0,l=0,m=0.0,n=0,o=0,p=0,q=0.0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;J=i;i=i+16|0;y=J;G=a+288|0;H=c[G>>2]|0;I=H+16|0;c[H>>2]=0;c[H+124>>2]=c[a+180>>2];F=c[a+32>>2]|0;c[H+140>>2]=F;if(F)c[a+36>>2]=0;if(c[H+85804>>2]|0)c[a+36>>2]=0;u=a+272|0;c[H+85828>>2]=c[u>>2];v=a+276|0;c[H+85832>>2]=c[v>>2];w=a+280|0;c[H+85836>>2]=c[w>>2];if(!(c[a+296>>2]|0)){F=H+85756|0;n=c[F>>2]&-3;c[F>>2]=n}else{n=Rd()|0;F=H+85756|0;n=c[F>>2]&-3|n<<1&2;c[F>>2]=n}if(!(c[a+292>>2]|0)){n=n&-2;c[H+85756>>2]=n}else{n=Qd()|0;F=H+85756|0;n=c[F>>2]&-2|n&1;c[F>>2]=n}if(!(c[a+300>>2]|0))c[H+85756>>2]=n&-13;else{E=Sd()|0;F=H+85756|0;c[F>>2]=c[F>>2]&-5|E<<2&4;E=Td()|0;c[F>>2]=c[F>>2]&-9|E<<3&8}C=H+85796|0;if((c[C>>2]|0)==0?(F=se(1,2772)|0,c[C>>2]=F,(F|0)==0):0){G=-2;i=J;return G|0}t=H+85676|0;if((c[t>>2]|0)==0?(F=se(1,134792)|0,c[t>>2]=F,(F|0)==0):0){Dd(H);c[G>>2]=0;G=-2;i=J;return G|0}A=H+160|0;c[A>>2]=c[a+120>>2];c[H+164>>2]=c[a+104>>2];c[H+168>>2]=c[a+108>>2];c[H+172>>2]=c[a+112>>2];c[H+176>>2]=c[a+116>>2];E=c[a+8>>2]|0;F=H+68|0;c[F>>2]=E;x=a+48|0;if((E|0)!=1){E=(c[x>>2]|0)==3;n=E?1:2;l=H+72|0;c[l>>2]=n;if(E)D=23;else{j=c[a+52>>2]|0;E=l}}else{c[x>>2]=3;l=H+72|0;c[l>>2]=1;n=1;D=23}if((D|0)==23){c[a+52>>2]=0;j=0;E=l}c[H+80>>2]=j;B=a+156|0;l=c[B>>2]|0;if((l|0)==4|(l|0)==1)D=29;else if(!l){l=c[a+168>>2]|0;if((l|0)!=128?(o=a+96|0,(c[o>>2]|0)==0):0)c[o>>2]=l;d=H+152|0;c[d>>2]=c[a+56>>2];b=a+96|0;do if(!(c[b>>2]|0)){l=a+100|0;m=+g[l>>2];h=+O(+m);if(m!=m|0.0!=0.0|m==0.0){if(!(m==0.0))break}else if(!(h<=h*9.999999974752427e-07))break;g[l>>2]=11.024999618530273}while(0);l=a+100|0;m=+g[l>>2];if(m>0.0){j=a+16|0;o=c[j>>2]|0;if(!o){o=Id(~~(+(c[a+12>>2]|0)*.97))|0;c[j>>2]=o;n=c[E>>2]|0;m=+g[l>>2]}c[b>>2]=~~(+($(o<<4,n)|0)/(m*1.0e3));c[H+20>>2]=Kd(o,I)|0;if(!(c[d>>2]|0))c[b>>2]=Gd(c[b>>2]|0,c[I>>2]|0,c[j>>2]|0)|0}}else{c[a+56>>2]=0;D=29}if((D|0)==29){d=H+152|0;c[d>>2]=c[a+56>>2]}s=a+16|0;n=c[s>>2]|0;a:do if(!n){z=c[B>>2]|0;if((z|0)==4|(z|0)==1){b=a+164|0;p=a+160|0;f=+(c[b>>2]|0)+ +g[p>>2];l=c[a+12>>2]|0;o=2;while(1){j=c[6560+(o*24|0)>>2]|0;if((l|0)==(j|0)?(e=+g[6560+(o*24|0)+4>>2],f>2]*(f/e);z=~~h;c[b>>2]=z;g[p>>2]=h-+(z|0);}if(((l|0)>=(j|0)?(q=+g[6560+(o*24|0)+4>>2],q<=f):0)?(r=+g[6560+(o*24|0)+8>>2],f=9)break a}e=+g[6560+(o*24|0)+12>>2];e=(+g[6560+(o*24|0)+16>>2]-e)*(f-h)/(m-h)+e;n=~~e;c[b>>2]=n;g[p>>2]=e-+(n|0);c[s>>2]=j;n=a+184|0;if(!(c[n>>2]|0)){c[n>>2]=-1;n=j}else n=j}else n=0}else{if((n|0)<16e3){z=a+168|0;b=c[z>>2]|0;b=(b|0)>8?b:8;c[z>>2]=(b|0)<64?b:64;break}l=a+168|0;j=c[l>>2]|0;if((n|0)<32e3){z=(j|0)>8?j:8;c[l>>2]=(z|0)<160?z:160;break}else{z=(j|0)>32?j:32;c[l>>2]=(z|0)<320?z:320;break}}while(0);p=a+184|0;l=c[p>>2]|0;if(!l){switch(c[B>>2]|0){case 0:{m=+(c[6776+((Hd(c[a+96>>2]&65535)|0)<<3)+4>>2]|0);break}case 3:{m=+(c[6776+((Hd(c[a+168>>2]&65535)|0)<<3)+4>>2]|0);break}case 2:{n=c[a+164>>2]|0;if(n>>>0<10){m=+(c[6912+(n<<2)>>2]|0);m=(+(c[6912+(n+1<<2)>>2]|0)-m)*+g[a+160>>2]+m}else m=19500.0;break}case 1:case 4:{n=c[a+164>>2]|0;if(n>>>0<10){m=+(c[6960+(n<<2)>>2]|0);m=(+(c[6960+(n+1<<2)>>2]|0)-m)*+g[a+160>>2]+m}else m=21500.0;break}default:{n=c[a+164>>2]|0;if(n>>>0<10){m=+(c[7008+(n<<2)>>2]|0);m=(+(c[7008+(n+1<<2)>>2]|0)-m)*+g[a+160>>2]+m}else m=19500.0}}if((c[x>>2]|0)==3?(z=c[B>>2]|0,(z|0)==3|(z|0)==0):0)m=m*1.5;l=~~m;c[p>>2]=l;n=c[s>>2]|0}if(!n){j=c[a+12>>2]|0;if((l<<1|0)>(j|0)){l=(j|0)/2|0;c[p>>2]=l}do if((j|0)<=47999)if((j|0)<=44099)if((j|0)<=31999)if((j|0)<=23999)if((j|0)<=22049)if((j|0)>15999)n=16e3;else{if((j|0)>11999){n=12e3;break}if((j|0)>11024){n=11025;break}n=(j|0)>7999?8e3:44100}else n=22050;else n=24e3;else n=32e3;else n=44100;else n=48e3;while(0);do if((l|0)!=-1){n=(l|0)<3971?8e3:(l|0)<4511?11025:(l|0)<5421?12e3:(l|0)<7231?16e3:(l|0)<9971?22050:(l|0)<11221?24e3:(l|0)<15251?32e3:(l|0)<15961?44100:n;if((n|0)>(j|0))if((j|0)<=44100)if((j|0)<=32e3)if((j|0)>24e3)n=32e3;else{if((j|0)>22050){n=24e3;break}if((j|0)>16e3){n=22050;break}if((j|0)>12e3){n=16e3;break}if((j|0)>11025){n=12e3;break}n=(j|0)>8e3?11025:8e3}else n=44100;else n=48e3}while(0);c[s>>2]=n;o=n}else o=n;n=c[B>>2]|0;do if((n|0)==4|(n|0)==1){z=(l|0)>24e3?24e3:l;b=(o|0)/2|0;c[p>>2]=(b|0)<(z|0)?b:z;if((n|0)==3)D=98}else{z=(l|0)>20500?20500:l;b=(o|0)/2|0;c[p>>2]=(b|0)<(z|0)?b:z;if((n|0)==3){D=98;break}else if(n)break;e=+($(o<<4,c[E>>2]|0)|0);g[a+100>>2]=e/(+(c[a+96>>2]|0)*1.0e3);}while(0);if((D|0)==98){e=+($(o<<4,c[E>>2]|0)|0);g[a+100>>2]=e/(+(c[a+168>>2]|0)*1.0e3);}z=a+36|0;n=a+60|0;if(c[z>>2]|0){l=c[n>>2]|0;n=c[a+64>>2]|0;c[H+128>>2]=l;j=H+136|0;c[j>>2]=n;if(!n)n=0;else c[H+132>>2]=1;do if(l){if(Ea(c[t>>2]|0,o|0)|0){n=c[j>>2]|0;break}Dd(H);c[G>>2]=0;G=-6;i=J;return G|0}while(0);if((n|0)!=0?(c[a+40>>2]|0)==0:0){n=H+85808|0;l=c[n>>2]|0;if(l)Ha(l|0)|0;b=cb()|0;c[n>>2]=b;Ma(b|0,c[w>>2]|0);sa(c[n>>2]|0,c[v>>2]|0);ab(c[n>>2]|0,c[u>>2]|0);}}else{c[n>>2]=0;c[a+64>>2]=0;c[H+132>>2]=0;c[H+128>>2]=0;c[H+136>>2]=0}c[H+144>>2]=c[a+128>>2];p=c[p>>2]|0;c[H+52>>2]=p;o=c[a+188>>2]|0;c[H+56>>2]=o;c[H+60>>2]=c[a+12>>2];j=c[s>>2]|0;w=H+64|0;c[w>>2]=j;t=H+76|0;c[t>>2]=(j|0)<24001?1:2;c[H+84760>>2]=576;n=c[B>>2]|0;if((n|0)==4|(n|0)==2|(n|0)==1)c[a+100>>2]=c[7056+(c[a+164>>2]<<2)>>2];else if((n|0)==3){e=+($(j<<4,c[E>>2]|0)|0);g[a+100>>2]=e/(+(c[a+168>>2]|0)*1.0e3);}else{e=+($(j<<4,c[E>>2]|0)|0);g[a+100>>2]=e/(+(c[a+96>>2]|0)*1.0e3);}n=c[x>>2]|0;if((n|0)==4){c[x>>2]=1;n=1}x=H+180|0;c[x>>2]=n;if((o|0)>0){h=+(o|0)*2.0;l=H+256|0;g[l>>2]=h;n=c[a+196>>2]|0;if((n|0)>-1)m=+(o+n|0)*2.0;else m=h;e=+(j|0);g[l>>2]=h/e;h=m/e;g[H+260>>2]=h}else{g[H+256>>2]=0.0;g[H+260>>2]=0.0;h=0.0}s=H+248|0;g[s>>2]=0.0;b=H+252|0;g[b>>2]=0.0;if((p|0)>0?(p|0)<((j|0)/2|0|0):0){f=+(p|0)*2.0;g[b>>2]=f;n=c[a+192>>2]|0;if((n|0)>-1){m=+(p-n|0)*2.0;g[s>>2]=m;if(m<0.0){g[s>>2]=0.0;m=0.0}}else{g[s>>2]=f;m=f}q=+(j|0);e=m/q;g[s>>2]=e;m=f/q;g[b>>2]=m;if(e>0.0){o=0;l=32;n=999;do{f=+(o|0)*.03225806451612903;l=(l|0)<(o|0)|!(f>=m)?l:o;n=f>2]=(+(((n|0)==999?l:n)|0)+-.75)*.03225806451612903;g[b>>2]=+(l|0)*.03225806451612903}}p=H+260|0;j=H+256|0;if(h>0.0&h<.021774193548387097){g[j>>2]=0.0;g[p>>2]=0.0;Od(H,7096,y);h=+g[p>>2]}do if(h>0.0){m=+g[j>>2];o=0;n=-1;l=-1;do{e=+(o|0)*.03225806451612903;n=(n|0)>(o|0)|!(e<=m)?n:o;l=m(o|0)?l:o):l;o=o+1|0}while((o|0)!=32);m=+(n|0);g[j>>2]=m*.03225806451612903;if((l|0)==-1){h=(m+.75)*.03225806451612903;g[p>>2]=h;n=0;break}else{h=(+(l|0)+.75)*.03225806451612903;g[p>>2]=h;n=0;break}}else n=0;while(0);while(1){e=+(n|0)*.032258063554763794;m=+g[j>>2];do if(h>m){m=(h-e)/(h-m+1.0e-20);if(m>1.0){f=0.0;break}if(m<=0.0){f=1.0;break}f=+R(+(m*1.5707963267948966));}else f=1.0;while(0);m=+g[b>>2];h=+g[s>>2];do if(m>h){m=(e-h)/(m-h+1.0e-20);if(m>1.0){m=0.0;break}if(m<=0.0){m=1.0;break}m=+R(+(m*1.5707963267948966));}else m=1.0;while(0);g[H+37040+(n<<2)>>2]=m*f;n=n+1|0;if((n|0)==32)break;h=+g[p>>2]}y=Kd(c[w>>2]|0,I)|0;n=H+20|0;c[n>>2]=y;if((y|0)<0){Dd(H);c[G>>2]=0;G=-1;i=J;return G|0}do if(!(c[B>>2]|0)){if(c[d>>2]|0){c[H+84744>>2]=0;break}v=a+96|0;y=Gd(c[v>>2]|0,c[I>>2]|0,c[w>>2]|0)|0;c[v>>2]=y;y=Jd(y,c[I>>2]|0,c[w>>2]|0)|0;c[H+84744>>2]=y;if((y|0)>=1)break;Dd(H);c[G>>2]=0;G=-1;i=J;return G|0}else c[H+84744>>2]=1;while(0);Eb(H);l=((c[I>>2]|0)*3|0)+(c[n>>2]|0)+((c[w>>2]|0)<16e3?6:0)|0;c[H+21360>>2]=c[12200+(l*204|0)>>2];c[H+21364>>2]=c[12200+(l*204|0)+4>>2];c[H+21368>>2]=c[12200+(l*204|0)+8>>2];c[H+21372>>2]=c[12200+(l*204|0)+12>>2];c[H+21376>>2]=c[12200+(l*204|0)+16>>2];c[H+21380>>2]=c[12200+(l*204|0)+20>>2];c[H+21384>>2]=c[12200+(l*204|0)+24>>2];c[H+21388>>2]=c[12200+(l*204|0)+28>>2];c[H+21392>>2]=c[12200+(l*204|0)+32>>2];c[H+21396>>2]=c[12200+(l*204|0)+36>>2];c[H+21400>>2]=c[12200+(l*204|0)+40>>2];c[H+21404>>2]=c[12200+(l*204|0)+44>>2];c[H+21408>>2]=c[12200+(l*204|0)+48>>2];c[H+21412>>2]=c[12200+(l*204|0)+52>>2];c[H+21416>>2]=c[12200+(l*204|0)+56>>2];c[H+21420>>2]=c[12200+(l*204|0)+60>>2];c[H+21424>>2]=c[12200+(l*204|0)+64>>2];c[H+21428>>2]=c[12200+(l*204|0)+68>>2];c[H+21432>>2]=c[12200+(l*204|0)+72>>2];c[H+21436>>2]=c[12200+(l*204|0)+76>>2];c[H+21440>>2]=c[12200+(l*204|0)+80>>2];n=c[12200+(l*204|0)+84>>2]|0;c[H+21444>>2]=n;j=c[12200+(l*204|0)+88>>2]|0;c[H+21448>>2]=j;j=(j-n|0)/6|0;c[H+21508>>2]=n;c[H+21512>>2]=j+n;c[H+21516>>2]=(j<<1)+n;c[H+21520>>2]=(j*3|0)+n;c[H+21524>>2]=(j<<2)+n;c[H+21528>>2]=(j*5|0)+n;c[H+21532>>2]=576;c[H+21452>>2]=c[12200+(l*204|0)+92>>2];c[H+21456>>2]=c[12200+(l*204|0)+96>>2];c[H+21460>>2]=c[12200+(l*204|0)+100>>2];c[H+21464>>2]=c[12200+(l*204|0)+104>>2];c[H+21468>>2]=c[12200+(l*204|0)+108>>2];c[H+21472>>2]=c[12200+(l*204|0)+112>>2];c[H+21476>>2]=c[12200+(l*204|0)+116>>2];c[H+21480>>2]=c[12200+(l*204|0)+120>>2];c[H+21484>>2]=c[12200+(l*204|0)+124>>2];c[H+21488>>2]=c[12200+(l*204|0)+128>>2];c[H+21492>>2]=c[12200+(l*204|0)+132>>2];c[H+21496>>2]=c[12200+(l*204|0)+136>>2];n=c[12200+(l*204|0)+140>>2]|0;c[H+21500>>2]=n;l=c[12200+(l*204|0)+144>>2]|0;c[H+21504>>2]=l;l=(l-n|0)/6|0;c[H+21536>>2]=n;c[H+21540>>2]=l+n;c[H+21544>>2]=(l<<1)+n;c[H+21548>>2]=(l*3|0)+n;c[H+21552>>2]=(l<<2)+n;c[H+21556>>2]=(l*5|0)+n;c[H+21560>>2]=192;n=c[t>>2]|0;l=c[E>>2]|0;j=(l|0)==1;j=(n|0)==2?(j?21:36):j?13:21;d=H+24|0;c[d>>2]=j;if(c[A>>2]|0)c[d>>2]=j|2;c[H>>2]=-487877;g[H+39756>>2]=+($(n*700|0,l)|0);g[H+39760>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39764>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39768>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39772>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39776>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39780>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39784>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39788>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39792>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39796>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39800>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39804>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39808>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39812>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39816>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39820>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39824>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);g[H+39828>>2]=+($((c[t>>2]|0)*700|0,c[E>>2]|0)|0);t=a+220|0;if((c[t>>2]|0)==-1)c[t>>2]=4;l=c[B>>2]|0;do if((l|0)==4|(l|0)==1){n=a+124|0;if((c[n>>2]|0)<0)c[n>>2]=2;n=a+244|0;if((c[n>>2]|0)<0)c[n>>2]=0;cc(a,($(c[a+164>>2]|0,-10)|0)+500|0,0)|0;n=a+44|0;l=c[n>>2]|0;do if((l|0)<0){c[n>>2]=3;D=169}else{if((l|0)<5){D=169;break}if((l|0)<=7)break;c[n>>2]=7}while(0);if((D|0)==169)c[n>>2]=0;if(!(c[a+140>>2]|0))l=(c[w>>2]|0)>44e3&1;else l=0;c[H+85092>>2]=l;c[H+85812>>2]=1}else if((l|0)!=2){c[H+85092>>2]=0;n=a+44|0;if((c[n>>2]|0)<0)c[n>>2]=3;j=(l|0)==0;if(j)Wc(a,c[a+96>>2]|0)|0;cc(a,c[a+168>>2]|0,0)|0;c[B>>2]=l;n=H+85812|0;if(j){c[n>>2]=3;break}else{c[n>>2]=4;break}}else{cc(a,($(c[a+164>>2]|0,-10)|0)+500|0,0)|0;if(!(c[a+140>>2]|0))l=(c[w>>2]|0)>44e3&1;else l=0;c[H+85092>>2]=l;n=a+44|0;l=c[n>>2]|0;do if((l|0)>6)c[n>>2]=6;else{if((l|0)>=0)break;c[n>>2]=3}while(0);c[H+85812>>2]=2}while(0);n=c[a+200>>2]|0;l=H+84912|0;c[l>>2]=n;j=c[a+204>>2]|0;d=H+84916|0;c[d>>2]=j;if(c[a+256>>2]|0){f=(c[k>>2]=j,+g[k>>2]);e=+g[a+260>>2];g[l>>2]=(c[k>>2]=n,+g[k>>2])+e;g[d>>2]=f+e}if(!(c[B>>2]|0)){n=0;l=c[a+168>>2]|0}else{d=H+112|0;c[d>>2]=1;b=H+116|0;n=c[w>>2]|0;c[b>>2]=(n|0)<16e3?8:14;o=a+172|0;l=c[o>>2]|0;do if(!l)n=1;else{n=Gd(l,c[I>>2]|0,n)|0;c[o>>2]=n;n=Jd(n,c[I>>2]|0,c[w>>2]|0)|0;c[d>>2]=n;if((n|0)<0)b=-1;else break;i=J;return b|0}while(0);j=a+176|0;l=c[j>>2]|0;do if(l){l=Gd(l,c[I>>2]|0,c[w>>2]|0)|0;c[j>>2]=l;l=Jd(l,c[I>>2]|0,c[w>>2]|0)|0;c[b>>2]=l;if((l|0)<0){G=-1;i=J;return G|0}else{n=c[d>>2]|0;break}}else l=c[b>>2]|0;while(0);y=c[I>>2]|0;A=c[83944+(y<<6)+(n<<2)>>2]|0;c[o>>2]=A;y=c[83944+(y<<6)+(l<<2)>>2]|0;c[j>>2]=y;n=a+168|0;l=c[n>>2]|0;l=(y|0)<(l|0)?y:l;l=(A|0)>(l|0)?A:l;c[n>>2]=l;n=c[B>>2]|0}c[H+100>>2]=c[a+152>>2];c[H+156>>2]=c[z>>2];s=H+104|0;c[s>>2]=n;c[H+85096>>2]=c[a+80>>2];c[H+28>>2]=c[a+84>>2];c[H+32>>2]=c[a+88>>2];c[H+36>>2]=c[a+92>>2];o=H+120|0;c[o>>2]=c[a+96>>2];c[H+108>>2]=l;c[H+244>>2]=c[a+100>>2];p=c[G>>2]|0;n=a+44|0;switch(c[n>>2]|0){case 5:{n=p+28|0;if(!(c[n>>2]|0))c[n>>2]=1;c[p+40>>2]=0;c[p+44>>2]=0;n=p+32|0;if((c[n>>2]|0)==-1)c[n>>2]=1;c[p+36>>2]=0;c[p+48>>2]=0;break}case 8:{c[n>>2]=7;D=203;break}case 7:{D=203;break}case 6:{n=p+28|0;if(!(c[n>>2]|0))c[n>>2]=1;c[p+40>>2]=0;c[p+44>>2]=0;n=p+32|0;if((c[n>>2]|0)==-1)c[n>>2]=1;c[p+36>>2]=0;c[p+48>>2]=0;break}case 2:{n=p+28|0;if(!(c[n>>2]|0))c[n>>2]=1;n=p+85096|0;if(!(c[n>>2]|0))c[n>>2]=2;c[p+40>>2]=1;c[p+44>>2]=1;n=p+32|0;if((c[n>>2]|0)==-1)c[n>>2]=1;c[p+36>>2]=1;c[p+48>>2]=0;break}case 4:{n=p+28|0;if(!(c[n>>2]|0))c[n>>2]=1;c[p+40>>2]=0;c[p+44>>2]=0;n=p+32|0;if((c[n>>2]|0)==-1)c[n>>2]=1;c[p+36>>2]=1;c[p+48>>2]=0;break}case 3:{n=p+28|0;if(!(c[n>>2]|0))c[n>>2]=1;c[p+40>>2]=1;c[p+44>>2]=1;n=p+32|0;if((c[n>>2]|0)==-1)c[n>>2]=1;c[p+36>>2]=1;c[p+48>>2]=0;break}case 0:{n=p+28|0;if(!(c[n>>2]|0))c[n>>2]=1;n=p+85096|0;if(!(c[n>>2]|0))c[n>>2]=2;c[p+40>>2]=2;c[p+44>>2]=1;n=p+32|0;if((c[n>>2]|0)==-1)c[n>>2]=1;c[p+36>>2]=1;c[p+48>>2]=1;break}case 1:{n=p+28|0;if(!(c[n>>2]|0))c[n>>2]=1;n=p+85096|0;if(!(c[n>>2]|0))c[n>>2]=2;c[p+40>>2]=2;c[p+44>>2]=1;n=p+32|0;if((c[n>>2]|0)==-1)c[n>>2]=1;c[p+36>>2]=1;c[p+48>>2]=0;break}default:{c[p+28>>2]=0;B=p+36|0;c[B>>2]=0;c[B+4>>2]=0;c[B+8>>2]=0;c[B+12>>2]=0}}do if((D|0)==203){c[p+28>>2]=0;A=p+36|0;c[A>>2]=0;c[A+4>>2]=0;c[A+8>>2]=0;c[A+12>>2]=0;B=c[B>>2]|0;if(!((B|0)==4|(B|0)==1))break;c[p+48>>2]=-1}while(0);d=c[a+232>>2]|0;l=c[C>>2]|0;c[l>>2]=(d|0)<0?3:d;g[l+4>>2]=+Q(10.0,+(+g[a+236>>2]*-.1));l=a+240|0;d=c[l>>2]|0;if((d|0)==-1){c[l>>2]=0;D=248}else if(!d)D=248;do if((D|0)==248){if((c[x>>2]|0)>>>0>=2){d=0;break}c[l>>2]=1;d=1}while(0);c[H+184>>2]=d;if((Oc(a)|0)<0)Mc(a,1)|0;if((Pc(a)|0)<0)Nc(a,0)|0;if(+pd(a)<0.0)od(a,0.0);Rc(a,Sc(a)|0|1)|0;d=c[t>>2]|0;if((d|0)<0){c[t>>2]=4;d=4}b=a+224|0;e=+g[b>>2];j=(g[k>>2]=e,c[k>>2]|0);if(e<0.0){g[b>>2]=4.0;j=1082130432}b=a+248|0;e=+g[b>>2];l=(g[k>>2]=e,c[k>>2]|0);if(e<0.0){g[b>>2]=0.0;l=0}n=a+244|0;b=c[n>>2]|0;if((b|0)<0){c[n>>2]=1;b=1}c[H+188>>2]=l;c[H+192>>2]=c[a+252>>2];m=+g[a+228>>2];g[H+196>>2]=-m;g[H+200>>2]=+Q(10.0,+(m*-.10000000149011612));c[H+204>>2]=j;c[H+208>>2]=d;c[H+212>>2]=c[a+208>>2];c[H+216>>2]=c[a+212>>2];c[H+220>>2]=c[a+216>>2];c[H+84>>2]=c[a+132>>2];c[H+88>>2]=c[a+136>>2];c[H+92>>2]=b;B=c[a+148>>2]|0;c[H+96>>2]=B&2;m=+(B>>>2&63|0);g[H+232>>2]=(!(m>=32.0)?m:m+-64.0)*.25;m=+(B>>>8&63|0);g[H+228>>2]=(!(m>=32.0)?m:m+-64.0)*.25;m=+(B>>>14&63|0);m=!(m>=32.0)?m:m+-64.0;g[H+236>>2]=m*.25;e=+(B>>>20&63|0);g[H+240>>2]=((!(e>=32.0)?e:e+-64.0)+m)*.25;m=+g[a+20>>2];e=+g[a+24>>2]*m;m=+g[a+28>>2]*m;do if((c[F>>2]|0)==2){if((c[E>>2]|0)!=1){f=e;h=m;e=0.0;break}f=e*.5;h=0.0;e=m*.5}else{f=e;h=m;e=0.0}while(0);g[H+264>>2]=f;g[H+268>>2]=e;g[H+272>>2]=0.0;g[H+276>>2]=h;b=H+39832|0;c[b>>2]=0;d=H+39836|0;c[d>>2]=0;if(!(c[s>>2]|0)){F=$(((c[I>>2]|0)*72e3|0)+72e3|0,c[o>>2]|0)|0;F=(F|0)%(c[w>>2]|0)|0;c[b>>2]=F;c[d>>2]=F}do if((c[a>>2]|0)==-487877){b=c[G>>2]|0;if(!b)break;c[b+84748>>2]=0;if(c[a+68>>2]|0)Ob(a)|0;g[b+85684>>2]=0.0;ve(b+84040|0,0,704)|0;if(!(c[b+156>>2]|0))break;ub(a)|0}while(0);vc(H);gc(a)|0;c[H+148>>2]=yb(I,c[a+124>>2]|0)|0;G=0;i=J;return G|0}function Vb(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return Zb(a,b,c,d,e,f,3,1,32767.0)|0}function Wb(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0;s=i;i=i+4608|0;p=s;if(!a){o=-3;i=s;return o|0}if((c[a>>2]|0)!=-487877){o=-3;i=s;return o|0}r=c[a+288>>2]|0;if(!r){o=-3;i=s;return o|0}if((c[r>>2]|0)!=-487877){o=-3;i=s;return o|0}q=r+84032|0;g=c[q>>2]|0;if((g|0)<1){o=0;i=s;return o|0}f=(c[r+76>>2]|0)*576|0;o=f+752|0;g=g+-1152|0;ve(p|0,0,4608)|0;if(!(Ld(r+16|0)|0))n=1.0;else{t=+(c[r+60>>2]|0)/+(c[r+64>>2]|0);n=t;g=~~(16.0/t+ +(g|0));}m=f-((g|0)%(f|0)|0)|0;m=((m|0)<576?f:0)+m|0;c[r+84764>>2]=m;g=(m+g|0)/(f|0)|0;if((g|0)>0){j=r+84748|0;k=r+84036|0;l=(d|0)==0;m=p+2304|0;h=c[j>>2]|0;f=g;e=0;do{g=~~(+(o-(c[k>>2]|0)|0)*n);g=(g|0)>1152?1152:g;g=Zb(a,p,m,(g|0)<1?1:g,b,l?0:d-e|0,0,1,1.0)|0;b=b+g|0;e=g+e|0;u=h;h=c[j>>2]|0;f=f-((u|0)!=(h|0)&1)|0}while((f|0)>0&(g|0)>-1);c[q>>2]=0;if((g|0)<0){o=g;i=s;return o|0}}else{c[q>>2]=0;e=0}f=(d|0)==0;Ab(r);g=Db(r,b,f?0:d-e|0,1)|0;_b(r);if((g|0)<0){o=g;i=s;return o|0}e=g+e|0;if(!(c[a+68>>2]|0)){o=e;i=s;return o|0}Qb(a)|0;o=Db(r,b+g|0,f?0:d-e|0,0)|0;o=((o|0)<0?0:e)+o|0;i=s;return o|0}function Xb(a){a=a|0;var b=0,d=0,e=0;if(!a){b=0;return b|0}if((c[a>>2]|0)!=-487877){b=0;return b|0}b=a+288|0;d=c[b>>2]|0;c[a>>2]=0;if(!d)b=-3;else{e=(c[d>>2]|0)==-487877?0:-3;c[d>>2]=0;Dd(d);c[b>>2]=0;b=e}if(!(c[a+284>>2]|0))return b|0;re(a);return b|0}function Yb(){var a=0,b=0;Vd();a=se(1,304)|0;if(!a){a=0;return a|0}ve(a|0,0,304)|0;c[a>>2]=-487877;b=se(1,85840)|0;c[a+288>>2]=b;if(!b){re(a);a=0;return a|0}else{c[a+124>>2]=2;c[a+48>>2]=4;c[a+108>>2]=1;c[a+12>>2]=44100;c[a+8>>2]=2;c[a+4>>2]=-1;c[a+36>>2]=1;c[a+44>>2]=-1;c[a+240>>2]=-1;c[a+88>>2]=-1;c[a+184>>2]=0;c[a+188>>2]=0;c[a+192>>2]=-1;c[a+196>>2]=-1;c[a+156>>2]=0;c[a+164>>2]=4;g[a+224>>2]=-1.0;c[a+168>>2]=128;c[a+172>>2]=0;c[a+176>>2]=0;c[a+180>>2]=0;c[b+112>>2]=1;c[b+116>>2]=13;c[a+132>>2]=-1;c[a+136>>2]=-1;g[a+252>>2]=-1.0;c[b+84920>>2]=180;c[b+84924>>2]=180;c[b+84928>>2]=4;c[b+84932>>2]=4;g[b+84908>>2]=1.0;g[a+264>>2]=-1.0;g[a+268>>2]=-1.0;g[a+20>>2]=1.0;g[a+24>>2]=1.0;g[a+28>>2]=1.0;c[a+232>>2]=-1;c[a+220>>2]=-1;g[a+236>>2]=0.0;c[a+244>>2]=-1;g[a+248>>2]=-1.0;c[b+84032>>2]=1728;c[b+84764>>2]=0;c[b+84036>>2]=528;c[a+60>>2]=0;c[a+64>>2]=0;c[b+136>>2]=0;c[b+128>>2]=0;c[b+132>>2]=0;c[b+85688>>2]=0;c[b+85692>>2]=0;g[b+85680>>2]=-1.0;c[a+292>>2]=1;c[a+296>>2]=1;c[a+300>>2]=1;c[a+152>>2]=0;c[a+68>>2]=1;c[a+276>>2]=2;c[a+280>>2]=2;c[a+272>>2]=2;c[a+284>>2]=1;return a|0}return 0}function Zb(a,b,d,e,f,g,h,j,k){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;k=+k;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;G=i;i=i+32|0;o=G;C=G+24|0;B=G+16|0;D=G+8|0;E=G+4|0;if(!a){y=-3;i=G;return y|0}if((c[a>>2]|0)!=-487877){y=-3;i=G;return y|0}F=c[a+288>>2]|0;if(!F){y=-3;i=G;return y|0}if((c[F>>2]|0)!=-487877){y=-3;i=G;return y|0}if(!e){y=0;i=G;return y|0}q=F+52152|0;a=c[q>>2]|0;do if(a)if((c[F+52148>>2]|0)<(e|0)){re(a);n=10;break}else{l=F+52156|0;m=a;p=l;l=c[l>>2]|0;n=13;break}else n=10;while(0);if((n|0)==10){a=F+52156|0;l=c[a>>2]|0;if(l)re(l);m=se(e,4)|0;c[q>>2]=m;l=se(e,4)|0;c[a>>2]=l;c[F+52148>>2]=e;if(m){p=a;n=13}}do if((n|0)==13){if(!l){re(m);a=p;l=c[p>>2]|0;break}a=(b|0)==0;do if((c[F+68>>2]|0)>1)if(a|(d|0)==0){y=0;i=G;return y|0}else{$b(F,b,d,e,h,j,k);break}else if(a){y=0;i=G;return y|0}else{$b(F,b,b,e,h,j,k);break}while(0);a=F+76|0;j=c[a>>2]|0;A=j*576|0;a:do if((c[F>>2]|0)==-487877){l=Db(F,f,g,0)|0;if((l|0)>=0){b=f+l|0;n=c[q>>2]|0;m=c[p>>2]|0;r=((c[a>>2]|0)*576|0)+752|0;c[C>>2]=F+52160;s=C+4|0;c[s>>2]=F+68096;t=B+4|0;u=F+128|0;v=F+72|0;w=F+84036|0;x=F+84032|0;y=F+136|0;z=F+85676|0;o=$(j,-576)|0;if(!g){f=b;a=n;b:while(1){while(1){if((e|0)<=0)break a;c[D>>2]=0;c[E>>2]=0;c[B>>2]=a;c[t>>2]=m;Md(F,C,B,e,D,E);if(((c[u>>2]|0)!=0?(c[y>>2]|0)==0:0)?(g=c[w>>2]|0,(Qa(c[z>>2]|0,(c[C>>2]|0)+(g<<2)|0,(c[s>>2]|0)+(g<<2)|0,c[E>>2]|0,c[v>>2]|0)|0)==0):0){l=-6;break a}b=c[D>>2]|0;e=e-b|0;p=a+(b<<2)|0;m=(c[v>>2]|0)==2?m+(b<<2)|0:m;b=c[E>>2]|0;n=(c[w>>2]|0)+b|0;c[w>>2]=n;a=c[x>>2]|0;if((a|0)<1){c[x>>2]=1728;a=1728}c[x>>2]=a+b;if((n|0)<(r|0))a=p;else{q=m;a=p;break}}m=Ib(F,c[C>>2]|0,c[s>>2]|0,f,0)|0;if((m|0)<0){l=m;break a}f=f+m|0;l=m+l|0;m=c[w>>2]|0;g=m-A|0;c[w>>2]=g;c[x>>2]=(c[x>>2]|0)-A;p=c[v>>2]|0;if(!((g|0)>0&(p|0)>0)){m=q;continue}h=o+m|0;m=0;while(1){j=c[C+(m<<2)>>2]|0;d=0;do{c[j+(d<<2)>>2]=c[j+(d+A<<2)>>2];d=d+1|0}while((d|0)!=(h|0));m=m+1|0;if((m|0)==(p|0)){m=q;continue b}}}}else{f=b;c:while(1){do{if((e|0)<=0)break a;c[D>>2]=0;c[E>>2]=0;c[B>>2]=n;c[t>>2]=m;Md(F,C,B,e,D,E);if(((c[u>>2]|0)!=0?(c[y>>2]|0)==0:0)?(q=c[w>>2]|0,(Qa(c[z>>2]|0,(c[C>>2]|0)+(q<<2)|0,(c[s>>2]|0)+(q<<2)|0,c[E>>2]|0,c[v>>2]|0)|0)==0):0){l=-6;break a}b=c[D>>2]|0;e=e-b|0;n=n+(b<<2)|0;m=(c[v>>2]|0)==2?m+(b<<2)|0:m;b=c[E>>2]|0;j=(c[w>>2]|0)+b|0;c[w>>2]=j;a=c[x>>2]|0;if((a|0)<1){c[x>>2]=1728;a=1728}c[x>>2]=a+b}while((j|0)<(r|0));a=Ib(F,c[C>>2]|0,c[s>>2]|0,f,g-l|0)|0;if((a|0)<0){l=a;break a}f=f+a|0;l=a+l|0;a=c[w>>2]|0;q=a-A|0;c[w>>2]=q;c[x>>2]=(c[x>>2]|0)-A;b=c[v>>2]|0;if(!((q|0)>0&(b|0)>0))continue;p=o+a|0;a=0;while(1){h=c[C+(a<<2)>>2]|0;d=0;do{c[h+(d<<2)>>2]=c[h+(d+A<<2)>>2];d=d+1|0}while((d|0)!=(p|0));a=a+1|0;if((a|0)==(b|0))continue c}}}}}else l=-3;while(0);y=l;i=G;return y|0}while(0);if(l)re(l);c[q>>2]=0;c[a>>2]=0;c[F+52148>>2]=0;Pd(F,7168,o);y=-2;i=G;return y|0}function _b(a){a=a|0;var b=0.0,d=0,e=0.0,f=0.0,h=0;h=a+85680|0;do if(c[a+128>>2]|0){b=+ya(c[a+85676>>2]|0);f=b;e=+O(+b);b=+O(+(b+24601.0));if(e>24601.0)if(!(b<=e*9.999999974752427e-07))d=5;else d=6;else if(!(b<=.024600999937888446))d=5;else d=6;if((d|0)==5){c[a+85688>>2]=~~+N(+(f*10.0+.5));break}else if((d|0)==6){c[a+85688>>2]=0;break}}while(0);if(!(c[a+132>>2]|0))return;b=+g[a+85684>>2];d=~~+_(+(+de(b*3.051850947599719e-05)*200.0));c[a+85692>>2]=d;if((d|0)>0){g[h>>2]=+N(+(3276700.0/b))*.01;return}else{g[h>>2]=-1.0;return}}function $b(a,d,e,f,i,j,k){a=a|0;d=d|0;e=e|0;f=f|0;i=i|0;j=j|0;k=+k;var l=0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0;l=c[a+52152>>2]|0;n=c[a+52156>>2]|0;o=+g[a+264>>2]*k;p=+g[a+268>>2]*k;m=+g[a+272>>2]*k;k=+g[a+276>>2]*k;switch(i|0){case 0:{if((f|0)<=0)return;a=0;while(1){q=+(b[d>>1]|0);r=+(b[e>>1]|0);g[l+(a<<2)>>2]=r*p+q*o;g[n+(a<<2)>>2]=r*k+q*m;a=a+1|0;if((a|0)==(f|0))break;else{d=d+(j<<1)|0;e=e+(j<<1)|0}}return}case 2:{if((f|0)<=0)return;a=0;while(1){q=+(c[d>>2]|0);r=+(c[e>>2]|0);g[l+(a<<2)>>2]=r*p+q*o;g[n+(a<<2)>>2]=r*k+q*m;a=a+1|0;if((a|0)==(f|0))break;else{d=d+(j<<2)|0;e=e+(j<<2)|0}}return}case 3:{if((f|0)<=0)return;a=0;while(1){q=+g[d>>2];r=+g[e>>2];g[l+(a<<2)>>2]=r*p+q*o;g[n+(a<<2)>>2]=r*k+q*m;a=a+1|0;if((a|0)==(f|0))break;else{d=d+(j<<2)|0;e=e+(j<<2)|0}}return}case 4:{if((f|0)<=0)return;a=0;while(1){q=+h[d>>3];r=+h[e>>3];g[l+(a<<2)>>2]=r*p+q*o;g[n+(a<<2)>>2]=r*k+q*m;a=a+1|0;if((a|0)==(f|0))break;else{d=d+(j<<3)|0;e=e+(j<<3)|0}}return}case 1:{if((f|0)<=0)return;a=0;while(1){q=+(c[d>>2]|0);r=+(c[e>>2]|0);g[l+(a<<2)>>2]=r*p+q*o;g[n+(a<<2)>>2]=r*k+q*m;a=a+1|0;if((a|0)==(f|0))break;else{d=d+(j<<2)|0;e=e+(j<<2)|0}}return}default:return}}function ac(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0.0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0;N=i;i=i+80|0;M=N;s=a+72|0;if((c[s>>2]|0)<=0){i=N;return}E=a+76|0;F=M+68|0;G=M+36|0;H=M+60|0;I=M+44|0;J=M+56|0;K=M+48|0;t=M+32|0;u=M+4|0;v=M+28|0;w=M+8|0;x=M+24|0;y=M+12|0;z=M+20|0;A=M+16|0;B=M+64|0;C=M+40|0;D=M+52|0;L=0;while(1){if((c[E>>2]|0)>0){r=0;q=b+1144|0;while(1){p=1-r|0;b=0;e=a+27824+(L*4608|0)+(p*2304|0)|0;f=q;while(1){bc(f,e);bc(f+128|0,e+128|0);j=e+132|0;g[j>>2]=-+g[j>>2];j=e+140|0;g[j>>2]=-+g[j>>2];j=e+148|0;g[j>>2]=-+g[j>>2];j=e+156|0;g[j>>2]=-+g[j>>2];j=e+164|0;g[j>>2]=-+g[j>>2];j=e+172|0;g[j>>2]=-+g[j>>2];j=e+180|0;g[j>>2]=-+g[j>>2];j=e+188|0;g[j>>2]=-+g[j>>2];j=e+196|0;g[j>>2]=-+g[j>>2];j=e+204|0;g[j>>2]=-+g[j>>2];j=e+212|0;g[j>>2]=-+g[j>>2];j=e+220|0;g[j>>2]=-+g[j>>2];j=e+228|0;g[j>>2]=-+g[j>>2];j=e+236|0;g[j>>2]=-+g[j>>2];j=e+244|0;g[j>>2]=-+g[j>>2];j=e+252|0;g[j>>2]=-+g[j>>2];b=b+1|0;if((b|0)==9)break;else{e=e+256|0;f=f+256|0}}l=a+304+(r*10504|0)+(L*5252|0)+4788|0;m=a+304+(r*10504|0)+(L*5252|0)+4792|0;n=0;o=a+304+(r*10504|0)+(L*5252|0)|0;while(1){j=c[7208+(n<<2)>>2]|0;k=(n|0)<2&(c[m>>2]|0)!=0?0:c[l>>2]|0;f=a+37040+(n<<2)|0;h=+g[f>>2];do if(!(h<1.0e-12)){if(h<1.0){b=a+27824+(L*4608|0)+(p*2304|0)+(j<<2)|0;g[b>>2]=+g[b>>2]*h;b=a+27824+(L*4608|0)+(p*2304|0)+(j+32<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+64<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+96<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+128<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+160<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+192<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+224<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+256<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+288<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+320<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+352<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+384<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+416<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+448<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+480<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+512<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2];b=a+27824+(L*4608|0)+(p*2304|0)+(j+544<<2)|0;g[b>>2]=+g[b>>2]*+g[f>>2]}if((k|0)==2){f=j+288|0;e=j+480|0;b=-3;do{S=b+3|0;h=+g[7624+(S<<2)>>2];T=b<<5;P=f+T|0;Q=(8-b<<5)+j|0;O=b*3|0;g[o+(O+9<<2)>>2]=+g[a+27824+(L*4608|0)+(r*2304|0)+(P<<2)>>2]*h-+g[a+27824+(L*4608|0)+(r*2304|0)+(Q<<2)>>2];R=a+27824+(L*4608|0)+(r*2304|0)+((14-b<<5)+j<<2)|0;T=a+27824+(L*4608|0)+(r*2304|0)+(e+T<<2)|0;g[o+(O+18<<2)>>2]=+g[R>>2]*h+ +g[T>>2];g[o+(O+10<<2)>>2]=+g[T>>2]*h-+g[R>>2];R=a+27824+(L*4608|0)+(p*2304|0)+((2-b<<5)+j<<2)|0;S=a+27824+(L*4608|0)+(p*2304|0)+((S<<5)+j<<2)|0;g[o+(O+19<<2)>>2]=+g[R>>2]*h+ +g[S>>2];g[o+(O+11<<2)>>2]=+g[S>>2]*h-+g[R>>2];g[o+(O+20<<2)>>2]=+g[a+27824+(L*4608|0)+(p*2304|0)+(Q<<2)>>2]*h+ +g[a+27824+(L*4608|0)+(p*2304|0)+(P<<2)>>2];b=b+1|0}while((b|0)!=0);f=o;e=0;while(1){O=f+24|0;h=+g[O>>2];Q=f+60|0;Z=+g[Q>>2];_=h*.13165250420570374-Z;V=+g[f>>2];j=f+36|0;Y=+g[j>>2];X=V*.7673270106315613-Y;h=Z*.13165250420570374+h;V=Y*.7673270106315613+V;Y=V+h;P=f+12|0;Z=+g[P>>2];b=f+48|0;$=+g[b>>2];W=X+_;U=(Z*.4142135679721832-$)*2.069978111953089e-11;g[f>>2]=U+W*1.90752519173728e-11;Z=($*.4142135679721832+Z)*2.069978111953089e-11;g[Q>>2]=Z+-Y*1.90752519173728e-11;X=(_-X)*1.6519652744032674e-11;Y=Z+Y*9.537625958686404e-12;g[P>>2]=X-Y;g[O>>2]=Y+X;U=W*9.537625958686404e-12-U;h=(V-h)*1.6519652744032674e-11;g[j>>2]=U+h;g[b>>2]=U-h;e=e+1|0;if((e|0)==3)break;else f=f+4|0}}else{f=-9;do{e=f+9|0;P=(e<<5)+j|0;O=(8-f<<5)+j|0;Y=+g[a+27824+(L*4608|0)+(p*2304|0)+(O<<2)>>2]*+g[7336+(k*144|0)+(f+36<<2)>>2]+ +g[a+27824+(L*4608|0)+(p*2304|0)+(P<<2)>>2]*+g[7336+(k*144|0)+(f+27<<2)>>2];b=f+18|0;h=+g[a+27824+(L*4608|0)+(r*2304|0)+(P<<2)>>2]*+g[7336+(k*144|0)+(e<<2)>>2]-+g[a+27824+(L*4608|0)+(r*2304|0)+(O<<2)>>2]*+g[7336+(k*144|0)+(b<<2)>>2];U=+g[7624+(f+12<<2)>>2];g[M+(e<<2)>>2]=Y-h*U;g[M+(b<<2)>>2]=U*Y+h;f=f+1|0}while((f|0)!=0);X=+g[F>>2]-+g[G>>2];$=+g[H>>2]-+g[I>>2];_=+g[J>>2]-+g[K>>2];Y=+g[t>>2]+ +g[M>>2];V=+g[v>>2]+ +g[u>>2];Z=+g[x>>2]+ +g[w>>2];U=+g[z>>2]+ +g[y>>2];W=Z+Y-U;g[o+68>>2]=+g[A>>2]-V+W;W=W*.5+(V-+g[A>>2]);h=(X-$-_)*.8660253882408142;g[o+20>>2]=W+h;g[o+24>>2]=h-W;W=(+g[B>>2]-+g[C>>2])*.8660253882408142;V=+g[A>>2]+V*.5;h=$*.6427876353263855+X*.9848077297210693+_*.3420201539993286+W;aa=Z*.7660444378852844+Y*.1736481785774231+U*.9396926164627075+V;g[o+4>>2]=h+aa;g[o+8>>2]=h-aa;aa=X*.6427876353263855-$*.3420201539993286+_*.9848077297210693-W;h=Y*.7660444378852844-Z*.9396926164627075-U*.1736481785774231+V;g[o+36>>2]=aa+h;g[o+40>>2]=aa-h;W=$*.9848077297210693+X*.3420201539993286-_*.6427876353263855-W;V=Y*.9396926164627075-Z*.1736481785774231+U*.7660444378852844-V;g[o+52>>2]=V+W;g[o+56>>2]=W-V;V=+g[t>>2]-+g[M>>2];W=+g[x>>2]-+g[w>>2];U=+g[z>>2]-+g[y>>2];Z=+g[G>>2]+ +g[F>>2];Y=+g[C>>2]+ +g[B>>2];_=+g[I>>2]+ +g[H>>2];X=+g[K>>2]+ +g[J>>2];$=_+Z+X;g[o>>2]=+g[D>>2]+Y+$;$=-Y-+g[D>>2]+$*.5;h=(V-W+U)*.8660253882408142;g[o+44>>2]=$+h;g[o+48>>2]=$-h;h=(+g[v>>2]-+g[u>>2])*.8660253882408142;Y=+g[D>>2]-Y*.5;$=Z*.9396926164627075-_*.1736481785774231-X*.7660444378852844-Y;aa=W*.9848077297210693+V*.3420201539993286+U*.6427876353263855+h;g[o+12>>2]=$+aa;g[o+16>>2]=$-aa;aa=Z*.7660444378852844-_*.9396926164627075+X*.1736481785774231+Y;$=V*.6427876353263855-W*.3420201539993286-U*.9848077297210693+h;g[o+28>>2]=aa+$;g[o+32>>2]=aa-$;Y=_*.7660444378852844+Z*.1736481785774231-X*.9396926164627075+Y;h=W*.6427876353263855+V*.9848077297210693-U*.3420201539993286-h;g[o+60>>2]=Y+h;g[o+64>>2]=Y-h;break}}else{f=o;e=f+72|0;do{c[f>>2]=0;f=f+4|0}while((f|0)<(e|0));}while(0);if((n|0)!=0&(k|0)!=2){f=7;while(1){b=o+(f<<2)|0;U=+g[b>>2];h=+g[7624+(f+20<<2)>>2];e=o+(~f<<2)|0;Y=+g[e>>2];V=+g[7624+(f+28<<2)>>2];g[e>>2]=V*Y+h*U;g[b>>2]=V*U-Y*h;if((f|0)>0)f=f+-1|0;else break}}n=n+1|0;if((n|0)==32)break;else o=o+72|0}r=r+1|0;b=c[E>>2]|0;if((r|0)>=(b|0))break;else q=q+2304|0}if((b|0)==1)ze(a+27824+(L*4608|0)|0,a+27824+(L*4608|0)+2304|0,2304)|0}L=L+1|0;if((L|0)>=(c[s>>2]|0))break;else b=d}i=N;return}function bc(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ba=0.0;c=a;d=-15;e=7952;f=a+-248|0;while(1){x=+g[e+-40>>2];y=+g[e+-36>>2];w=+g[e+-32>>2];v=+g[e+-28>>2];u=+g[e+-24>>2];t=+g[e+-20>>2];s=+g[e+-16>>2];r=+g[e+-12>>2];q=+g[e+-8>>2];p=+g[e+-4>>2];o=+g[e>>2];n=+g[e+4>>2];m=+g[e+8>>2];l=+g[e+12>>2];k=+g[e+16>>2];i=+g[e+20>>2];j=+g[c+640>>2]*y+ +g[c+896>>2]*x+ +g[c+384>>2]*w+ +g[c+128>>2]*v+ +g[c+-128>>2]*u+ +g[c+-384>>2]*t+ +g[c+-640>>2]*s+ +g[c+-896>>2]*r-+g[f+1024>>2]*q-+g[f+768>>2]*p-+g[f+512>>2]*o-+g[f+256>>2]*n-+g[f>>2]*m-+g[f+-256>>2]*l-+g[f+-512>>2]*k-+g[f+-768>>2]*i;i=(+g[f+-640>>2]*y+ +g[f+-896>>2]*x+ +g[f+-384>>2]*w+ +g[f+-128>>2]*v+ +g[f+128>>2]*u+ +g[f+384>>2]*t+ +g[f+640>>2]*s+ +g[f+896>>2]*r+ +g[c+-1024>>2]*q+ +g[c+-768>>2]*p+ +g[c+-512>>2]*o+ +g[c+-256>>2]*n+ +g[c>>2]*m+ +g[c+256>>2]*l+ +g[c+512>>2]*k+ +g[c+768>>2]*i)*+g[e+24>>2];h=d<<1;g[b+(h+30<<2)>>2]=j+i;g[b+(h+31<<2)>>2]=(j-i)*+g[e+28>>2];d=d+1|0;if(!d)break;else{c=c+-4|0;e=e+72|0;f=f+4|0}}p=(+g[a+-252>>2]-+g[a+4>>2])*5302.158203125+ +g[a+-124>>2]*10612.802734375+(+g[a+132>>2]+ +g[a+-380>>2])*929.7763061523438+(+g[a+-508>>2]-+g[a+260>>2])*728.8010864257812+(+g[a+388>>2]+ +g[a+-636>>2])*288.09765625+(+g[a+-764>>2]-+g[a+516>>2])*64.91738891601562+(+g[a+644>>2]+ +g[a+-892>>2])*30.125003814697266+(+g[a+-1020>>2]-+g[a+772>>2])*4.101456642150879;w=+g[a+-444>>2]*1945.5516357421875+ +g[a+-188>>2]*12804.7978515625+ +g[a+-700>>2]*313.42449951171875+ +g[a+-956>>2]*20.801593780517578-+g[a+68>>2]*1995.1556396484375-+g[a+324>>2]*9.000839233398438-+g[a+580>>2]*-29.202180862426758-+g[a+836>>2];n=w-p;p=w+p;R=b+56|0;w=+g[R>>2];T=b+60|0;j=+g[T>>2]-w;t=p+w;X=b+124|0;v=j+n;V=b+120|0;j=n-j;w=p-w;a=b+112|0;p=+g[a>>2];n=+g[b>>2];g[b>>2]=n+p;g[a>>2]=(p-n)*1.9615705013275146;d=b+116|0;n=+g[d>>2];W=b+4|0;p=+g[W>>2];g[W>>2]=p+n;g[d>>2]=(n-p)*1.9615705013275146;F=b+104|0;p=+g[F>>2];c=b+8|0;n=+g[c>>2];g[c>>2]=n+p;g[F>>2]=(p-n)*1.8477590084075928;H=b+108|0;n=+g[H>>2];e=b+12|0;p=+g[e>>2];g[e>>2]=p+n;g[H>>2]=(n-p)*1.8477590084075928;M=b+96|0;p=+g[M>>2];I=b+16|0;n=+g[I>>2];g[I>>2]=n+p;g[M>>2]=(p-n)*1.662939190864563;K=b+100|0;n=+g[K>>2];G=b+20|0;p=+g[G>>2];g[G>>2]=p+n;g[K>>2]=(n-p)*1.662939190864563;N=b+88|0;p=+g[N>>2];J=b+24|0;n=+g[J>>2];x=n+p;P=b+92|0;ba=+g[P>>2];L=b+28|0;l=+g[L>>2];q=l+ba;s=q-x;n=(p-n)*1.4142135623730951-s;q=(ba-l)*1.4142135623730951-q-n;g[J>>2]=t-x;g[X>>2]=t+x;g[L>>2]=v-s;g[V>>2]=v+s;g[N>>2]=j-n;g[T>>2]=j+n;g[P>>2]=w-q;g[R>>2]=w+q;E=b+80|0;q=+g[E>>2];Q=b+32|0;w=+g[Q>>2];n=w+q;w=(q-w)*1.111140489578247;C=b+84|0;q=+g[C>>2];O=b+36|0;j=+g[O>>2];s=j+q;j=(q-j)*1.111140489578247;f=b+72|0;q=+g[f>>2];B=b+40|0;v=+g[B>>2];x=v+q;v=(q-v)*.7653668522834778;z=b+76|0;q=+g[z>>2];D=b+44|0;t=+g[D>>2];l=t+q;t=(q-t)*.7653668522834778;U=b+64|0;q=+g[U>>2];A=b+48|0;ba=+g[A>>2];p=ba+q;ba=(q-ba)*.39018064737319946;S=b+68|0;q=+g[S>>2];h=b+52|0;u=+g[h>>2];o=u+q;u=(q-u)*.39018064737319946;q=+g[M>>2];g[E>>2]=q+w;g[M>>2]=(q-w)*.7653668522834778;w=+g[K>>2];g[C>>2]=w+j;g[K>>2]=(w-j)*.7653668522834778;j=+g[I>>2];g[I>>2]=n+j;g[Q>>2]=(j-n)*.7653668522834778;n=+g[G>>2];g[G>>2]=s+n;g[O>>2]=(n-s)*.7653668522834778;s=+g[b>>2];g[b>>2]=p+s;g[A>>2]=(s-p)*1.8477590084075928;p=+g[W>>2];g[W>>2]=o+p;g[h>>2]=(p-o)*1.8477590084075928;o=+g[a>>2];g[U>>2]=o+ba;g[a>>2]=(ba-o)*1.8477590084075928;o=+g[d>>2];g[S>>2]=o+u;g[d>>2]=(o-u)*1.8477590084075928;u=+g[c>>2];o=x+u;ba=+g[e>>2];p=l+ba;s=+g[F>>2];n=s+v;j=+g[H>>2];w=j+t;q=w-p;p=p-o;m=+g[X>>2];g[c>>2]=m-o;g[X>>2]=m+o;l=(ba-l)*1.4142135623730951-q;ba=n-p;o=+g[V>>2];g[e>>2]=o-p;g[V>>2]=o+p;q=q-ba;p=+g[T>>2];g[f>>2]=p-ba;g[T>>2]=p+ba;x=(u-x)*1.4142135623730951-q;u=+g[R>>2];g[z>>2]=u-q;g[R>>2]=u+q;q=l-x;u=+g[P>>2];g[B>>2]=u-x;g[P>>2]=u+x;n=(s-v)*1.4142135623730951-n-q;v=+g[N>>2];g[D>>2]=v-q;g[N>>2]=v+q;l=(j-t)*1.4142135623730951-w-l-n;w=+g[L>>2];g[F>>2]=w-n;g[L>>2]=w+n;n=+g[J>>2];g[H>>2]=n-l;g[J>>2]=n+l;l=+g[b>>2];n=+g[I>>2];w=n+l;g[b>>2]=w;g[I>>2]=(l-n)*1.4142135623730951;n=+g[W>>2];l=+g[G>>2];t=l+n;j=+g[U>>2];q=+g[E>>2];v=q+j;s=+g[S>>2];x=+g[C>>2];u=x+s;ba=+g[Q>>2];p=+g[A>>2];o=p+ba;m=+g[O>>2];k=+g[h>>2];r=k+m;Z=+g[K>>2];Y=+g[d>>2];y=Y+Z;$=+g[M>>2];aa=+g[a>>2];_=$-aa;i=_-v;q=(j-q)*1.4142135623730951-i;j=y-u;x=(s-x)*1.4142135623730951-j;u=u-t;s=r-u;j=j-s;l=(n-l)*1.4142135623730951-j;n=x-l;r=(m-k)*-1.4142135623730951-r-n;w=t-w;v=v-w;u=u-v;t=o-u;s=s-t;i=i-s;j=j-i;k=+g[I>>2]-j;l=l-k;m=q-l;n=n-m;o=(ba-p)*-1.4142135623730951-o-n;p=r-o;q=(aa+$)*-1.4142135623730951-_-q-p;r=(Z-Y)*-1.4142135623730951-y-x-r-q;x=+g[b>>2];y=+g[X>>2];g[b>>2]=y+x;g[X>>2]=y-x;x=+g[V>>2];g[W>>2]=x+w;g[V>>2]=x-w;w=+g[T>>2];g[U>>2]=w+v;g[T>>2]=w-v;v=+g[R>>2];g[S>>2]=v+u;g[R>>2]=v-u;u=+g[P>>2];g[Q>>2]=u+t;g[P>>2]=u-t;t=+g[N>>2];g[O>>2]=t+s;g[N>>2]=t-s;s=+g[L>>2];g[M>>2]=s+i;g[L>>2]=s-i;i=+g[J>>2];g[K>>2]=i+j;g[J>>2]=i-j;j=+g[H>>2];g[I>>2]=j+k;g[H>>2]=j-k;k=+g[F>>2];g[G>>2]=k+l;g[F>>2]=k-l;l=+g[D>>2];g[E>>2]=l+m;g[D>>2]=l-m;m=+g[B>>2];g[C>>2]=m+n;g[B>>2]=m-n;n=+g[z>>2];g[A>>2]=n+o;g[z>>2]=n-o;o=+g[f>>2];g[h>>2]=o+p;g[f>>2]=o-p;p=+g[e>>2];g[a>>2]=p+q;g[e>>2]=p-q;q=+g[c>>2];g[d>>2]=q+r;g[c>>2]=q-r;return}function cc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;a:do switch(b|0){case 1e3:{Tc(a,4)|0;c[a+152>>2]=470;e=14;break}case 1004:case 1001:{Tc(a,4)|0;c[a+152>>2]=480;e=15;break}case 1005:case 1002:{Tc(a,4)|0;c[a+152>>2]=500;e=17;break}case 1003:{c[a+152>>2]=320;dc(a,320,d)|0;Tc(a,0)|0;e=320;return e|0}case 1007:case 1006:{Tc(a,4)|0;c[a+152>>2]=460;e=13;break}default:{e=a+152|0;c[e>>2]=b;switch(b|0){case 460:{e=13;break a}case 490:{ec(a,1,d);e=490;return e|0}case 430:{ec(a,7,d);e=430;return e|0}case 500:{e=17;break a}case 410:{ec(a,9,d);e=410;return e|0}case 480:{e=15;break a}case 440:{ec(a,6,d);e=440;return e|0}case 470:{e=14;break a}case 420:{ec(a,8,d);e=420;return e|0}case 450:{ec(a,5,d);e=450;return e|0}default:if((b+-8|0)>>>0<313){e=dc(a,b,d)|0;return e|0}else{c[e>>2]=0;e=b;return e|0}}}}while(0);if((e|0)==13){ec(a,4,d);e=460;return e|0}else if((e|0)==14){ec(a,3,d);e=470;return e|0}else if((e|0)==15){ec(a,2,d);e=480;return e|0}else if((e|0)==17){ec(a,0,d);e=500;return e|0}return 0}function dc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0.0;e=Hd(b&65535)|0;Tc(a,3)|0;Wc(a,b)|0;f=Xc(a)|0;Wc(a,(f|0)<320?f:320)|0;f=Xc(a)|0;Wc(a,(f|0)>8?f:8)|0;Lc(a,Xc(a)|0)|0;if((e+-12|0)>>>0<5)Rc(a,Sc(a)|0|2)|0;if(e>>>0<13)jd(a,1)|0;d=(d|0)!=0;if(!d){if((Oc(a)|0)==-1)Mc(a,c[10560+(e*52|0)+4>>2]|0)|0;if((Pc(a)|0)==-1)Nc(a,c[10560+(e*52|0)+8>>2]|0)|0;h=+pd(a)+1.0;if(h!=h|0.0!=0.0|h==0.0)od(a,+g[10560+(e*52|0)+16>>2]);h=+ld(a)+1.0;if(h!=h|0.0!=0.0|h==0.0)kd(a,+g[10560+(e*52|0)+20>>2])|0;h=+nd(a)+1.0;if(h!=h|0.0!=0.0|h==0.0)md(a,+g[10560+(e*52|0)+24>>2])|0}else{Mc(a,c[10560+(e*52|0)+4>>2]|0)|0;Nc(a,c[10560+(e*52|0)+8>>2]|0)|0;od(a,+g[10560+(e*52|0)+16>>2]);kd(a,+g[10560+(e*52|0)+20>>2])|0;md(a,+g[10560+(e*52|0)+24>>2])|0}h=+Jc(a);Ic(a,+g[10560+(e*52|0)+28>>2]*h)|0;if(d){h=+g[10560+(e*52|0)+32>>2];Yc(a,h)|0;_c(a,h*1.1)|0;dd(a,+g[10560+(e*52|0)+36>>2])|0;bd(a,+g[10560+(e*52|0)+40>>2])|0;hd(a,+g[10560+(e*52|0)+44>>2])|0;d=10560+(e*52|0)|0;d=c[d>>2]|0;h=+(d|0);h=h*.015625;d=a+288|0;d=c[d>>2]|0;d=d+280|0;g[d>>2]=h;return b|0}h=+Zc(a);if(h!=h|0.0!=0.0|h==0.0)Yc(a,+g[10560+(e*52|0)+32>>2])|0;h=+$c(a);if(h!=h|0.0!=0.0|h==0.0)_c(a,+g[10560+(e*52|0)+32>>2]*1.1)|0;h=+ed(a);if(h!=h|0.0!=0.0|h==0.0)dd(a,+g[10560+(e*52|0)+36>>2])|0;h=+cd(a)+1.0;if(h!=h|0.0!=0.0|h==0.0)bd(a,+g[10560+(e*52|0)+40>>2])|0;h=+id(a)+1.0;if(!(h!=h|0.0!=0.0|h==0.0)){d=10560+(e*52|0)|0;d=c[d>>2]|0;h=+(d|0);h=h*.015625;d=a+288|0;d=c[d>>2]|0;d=d+280|0;g[d>>2]=h;return b|0}hd(a,+g[10560+(e*52|0)+44>>2])|0;d=10560+(e*52|0)|0;d=c[d>>2]|0;h=+(d|0);h=h*.015625;d=a+288|0;d=c[d>>2]|0;d=d+280|0;g[d>>2]=h;return b|0}function ec(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0.0,j=0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0.0,v=0.0,w=0,x=0.0,y=0.0,z=0,A=0.0;t=Uc(a)|0;if((t|0)==1|(t|0)==4)e=9808;else e=9056;f=a+160|0;k=+g[f>>2];m=c[e+(b*68|0)+4>>2]|0;t=c[e+(b*68|0)+8>>2]|0;h=c[e+(b*68|0)+12>>2]|0;n=+g[e+(b*68|0)+16>>2];o=+g[e+(b*68|0)+20>>2];p=+g[e+(b*68|0)+24>>2];q=+g[e+(b*68|0)+28>>2];r=+g[e+(b*68|0)+32>>2];s=+g[e+(b*68|0)+36>>2];u=+g[e+(b*68|0)+40>>2];v=+g[e+(b*68|0)+44>>2];l=c[e+(b*68|0)+48>>2]|0;w=c[e+(b*68|0)+52>>2]|0;x=+g[e+(b*68|0)+56>>2];y=+g[e+(b*68|0)+60>>2];i=+g[e+(b*68|0)+64>>2];z=b+1|0;n=(+g[e+(z*68|0)+16>>2]-n)*k+n;o=(+g[e+(z*68|0)+20>>2]-o)*k+o;p=(+g[e+(z*68|0)+24>>2]-p)*k+p;q=(+g[e+(z*68|0)+28>>2]-q)*k+q;r=(+g[e+(z*68|0)+32>>2]-r)*k+r;s=(+g[e+(z*68|0)+36>>2]-s)*k+s;u=(+g[e+(z*68|0)+40>>2]-u)*k+u;v=(+g[e+(z*68|0)+44>>2]-v)*k+v;w=~~(+((c[e+(z*68|0)+52>>2]|0)-w|0)*k+ +(w|0));x=(+g[e+(z*68|0)+56>>2]-x)*k+x;y=(+g[e+(z*68|0)+60>>2]-y)*k+y;i=(+g[e+(z*68|0)+64>>2]-i)*k+i;Vc(a,c[e+(b*68|0)>>2]|0)|0;e=(d|0)!=0;if(!e){if((Oc(a)|0)==-1)Mc(a,m)|0;if((Pc(a)|0)==-1)Nc(a,t)|0}else{Mc(a,m)|0;Nc(a,t)|0}if(h)Qc(a,h)|0;if(!e){A=+ld(a)+1.0;if(A!=A|0.0!=0.0|A==0.0)kd(a,n)|0;n=+nd(a)+1.0;if(n!=n|0.0!=0.0|n==0.0)md(a,o)|0;o=+Zc(a);if(o!=o|0.0!=0.0|o==0.0)Yc(a,p)|0;p=+$c(a);if(p!=p|0.0!=0.0|p==0.0)_c(a,q)|0}else{kd(a,n)|0;md(a,o)|0;Yc(a,p)|0;_c(a,q)|0}if(!((Uc(a)|0)!=1?(Uc(a)|0)!=4:0))ad(a,5)|0;if(!e){q=+ed(a);if(q!=q|0.0!=0.0|q==0.0)dd(a,r)|0;r=+cd(a)+1.0;if(r!=r|0.0!=0.0|r==0.0)bd(a,s)|0;s=+gd(a);if(s!=s|0.0!=0.0|s==0.0)fd(a,u)|0}else{dd(a,r)|0;bd(a,s)|0;fd(a,u)|0}do if(v>0.0){if(e){hd(a,v)|0;break}u=+id(a)+1.0;if(u!=u|0.0!=0.0|u==0.0)hd(a,v)|0}while(0);if((l|0)>0)Rc(a,Sc(a)|0|2)|0;if((w|0)>0?(j=Sc(a)|0,(j&66060288|0)==0):0)Rc(a,j|w<<20)|0;if(e){od(a,x);b=a+288|0;b=c[b>>2]|0;t=b+280|0;g[t>>2]=y;b=b+224|0;g[b>>2]=i;return}u=+pd(a)+1.0;if(u!=u|0.0!=0.0|u==0.0)od(a,x);c[a+164>>2]=b;g[f>>2]=k;b=a+288|0;b=c[b>>2]|0;t=b+280|0;g[t>>2]=y;b=b+224|0;g[b>>2]=i;return} -function Zd(a,b,d,e,f,g,h,j){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;v=i;i=i+720|0;u=v+456|0;t=v+228|0;q=v;c[q>>2]=a;r=0-b|0;a:do if((f|0)!=0|(e|0)!=1?(m=a+(0-(c[j+(g<<2)>>2]|0))|0,(ib[d&1](m,a)|0)>=1):0){n=m;k=f;m=1;l=e;while(1){if((h|0)==0&(g|0)>1){f=c[j+(g+-2<<2)>>2]|0;if((ib[d&1](a+r|0,n)|0)>-1){n=a;f=m;break a}if((ib[d&1](a+(0-(f+b))|0,n)|0)>-1){n=a;f=m;break a}}f=m+1|0;c[q+(m<<2)>>2]=n;a=l+-1|0;do if(a){if(!(a&1)){m=a;a=0;do{a=a+1|0;m=m>>>1}while((m&1|0)==0);if(!a)o=10}else o=10;if((o|0)==10){o=0;if(!k){a=64;o=15;break}if(!(k&1)){a=k;m=0}else{h=0;m=l;e=k;a=0;break}while(1){e=m+1|0;a=a>>>1;if(a&1){a=e;break}else m=e}if(!a){h=0;m=l;e=k;a=0;break}else a=m+33|0}if(a>>>0>31)o=15;else{h=a;m=l;e=k}}else{a=32;o=15}while(0);if((o|0)==15){o=0;h=a+-32|0;m=k;e=0}l=e<<32-h|m>>>h;k=e>>>h;g=a+g|0;if(!((k|0)!=0|(l|0)!=1))break a;m=n+(0-(c[j+(g<<2)>>2]|0))|0;if((ib[d&1](m,c[q>>2]|0)|0)<1){a=n;h=0;o=18;break}else{a=n;h=0;n=m;m=f}}}else{f=1;o=18}while(0);if((o|0)==18)if(!h)n=a;else{i=v;return}b:do if((f|0)>=2?(p=q+(f<<2)|0,c[p>>2]=u,(b|0)!=0):0){l=b;h=u;while(1){k=l>>>0>256?256:l;a=c[q>>2]|0;ze(h|0,a|0,k|0)|0;e=0;do{m=e;e=e+1|0;h=a;a=c[q+(e<<2)>>2]|0;ze(h|0,a|0,k|0)|0;c[q+(m<<2)>>2]=h+k}while((e|0)!=(f|0));if((l|0)==(k|0))break b;l=l-k|0;h=c[p>>2]|0}}while(0);c[t>>2]=n;c:do if((g|0)>1){k=n;f=n;a=1;while(1){l=k+r|0;m=g+-2|0;e=k+(0-((c[j+(m<<2)>>2]|0)+b))|0;if((ib[d&1](f,e)|0)>-1?(ib[d&1](f,l)|0)>-1:0){h=a;break}h=a+1|0;k=t+(a<<2)|0;if((ib[d&1](e,l)|0)>-1){c[k>>2]=e;l=e;g=g+-1|0}else{c[k>>2]=l;g=m}if((g|0)<=1)break;k=l;f=c[t>>2]|0;a=h}if((h|0)>=2?(s=t+(h<<2)|0,c[s>>2]=u,(b|0)!=0):0){k=u;while(1){g=b>>>0>256?256:b;l=c[t>>2]|0;ze(k|0,l|0,g|0)|0;k=l;l=0;do{n=l;l=l+1|0;m=k;k=c[t+(l<<2)>>2]|0;ze(m|0,k|0,g|0)|0;c[t+(n<<2)>>2]=m+g}while((l|0)!=(h|0));if((b|0)==(g|0))break c;b=b-g|0;k=c[s>>2]|0}}}while(0);i=v;return}function _d(a){a=a|0;return (a+-65|0)>>>0<26|0}function $d(a){a=a|0;var b=0;b=(_d(a)|0)==0;return (b?a:a|32)|0}function ae(a){a=+a;var b=0,d=0,e=0,f=0,j=0.0,l=0.0;f=i;i=i+16|0;e=f;h[k>>3]=a;b=c[k+4>>2]|0;d=b&2147483647;do if(d>>>0>1083174911){if(((b|0)>-1|(b|0)==-1&(c[k>>2]|0)>>>0>4294967295)&d>>>0>1083179007){a=a*8988465674311579538646525.0e283;i=f;return +a}if(d>>>0>2146435071){a=-1.0/a;i=f;return +a}if((b|0)<0)if(!(a<=-1075.0)){if(!(a+-4503599627370496.0+4503599627370496.0!=a))break;g[e>>2]=-1.401298464324817e-45/a;break}else{g[e>>2]=-1.401298464324817e-45/a;a=0.0;i=f;return +a}}else if(d>>>0<1016070144){a=a+1.0;i=f;return +a}while(0);l=a+26388279066624.0;h[k>>3]=l;b=(c[k>>2]|0)+128|0;d=b<<1&510;j=+h[91712+(d<<3)>>3];a=a-(l+-26388279066624.0)-+h[91712+((d|1)<<3)>>3];a=+ee(j+j*a*(a*(a*(a*(a*1.3333559164630223e-03+.009618129842126066)+.0555041086648214)+.2402265069591)+.6931471805599453),(b&-256|0)/256|0);i=f;return +a}function be(a,b){a=+a;b=b|0;var d=0,e=0,f=0;h[k>>3]=a;d=c[k>>2]|0;e=c[k+4>>2]|0;f=ye(d|0,e|0,52)|0;f=f&2047;if((f|0)==2047)return +a;else if(!f){if(a!=0.0){a=+be(a*18446744073709551616.0,b);d=(c[b>>2]|0)+-64|0}else d=0;c[b>>2]=d;return +a}else{c[b>>2]=f+-1022;c[k>>2]=d;c[k+4>>2]=e&-2146435073|1071644672;a=+h[k>>3];return +a}return 0.0}function ce(a,b){a=+a;b=b|0;return +(+be(a,b));}function de(a){a=+a;var b=0,d=0,e=0,f=0.0,g=0.0,i=0.0,j=0.0,l=0.0;h[k>>3]=a;d=c[k>>2]|0;b=c[k+4>>2]|0;e=(b|0)<0;do if(!(e|b>>>0<1048576)){if(b>>>0>2146435071)return +a;if((d|0)==0&0==0&(b|0)==1072693248){a=0.0;return +a}else{e=d;d=-1023}}else{if((d|0)==0&(b&2147483647|0)==0){a=-1.0/(a*a);return +a}if(!e){h[k>>3]=a*18014398509481984.0;b=c[k+4>>2]|0;e=c[k>>2]|0;d=-1077;break}a=(a-a)/0.0;return +a}while(0);b=b+614242|0;c[k>>2]=e;c[k+4>>2]=(b&1048575)+1072079006;l=+h[k>>3]+-1.0;a=l*(l*.5);i=l/(l+2.0);j=i*i;g=j*j;h[k>>3]=l-a;e=c[k+4>>2]|0;c[k>>2]=0;c[k+4>>2]=e;f=+h[k>>3];a=i*(a+(g*(g*(g*.15313837699209373+.22222198432149784)+.3999999999940942)+j*(g*(g*(g*.14798198605116586+.1818357216161805)+.2857142874366239)+.6666666666666735)))+(l-f-a);l=f*.4342944818781689;g=+(d+(b>>>20)|0);j=g*.30102999566361177;i=j+l;a=i+(l+(j-i)+(a*.4342944818781689+(g*3.694239077158931e-13+(f+a)*2.5082946711645275e-11)));return +a}function ee(a,b){a=+a;b=b|0;var d=0;if((b|0)>1023){a=a*8988465674311579538646525.0e283;d=b+-1023|0;if((d|0)>1023){d=b+-2046|0;d=(d|0)>1023?1023:d;a=a*8988465674311579538646525.0e283}}else if((b|0)<-1022){a=a*2.2250738585072014e-308;d=b+1022|0;if((d|0)<-1022){d=b+2044|0;d=(d|0)<-1022?-1022:d;a=a*2.2250738585072014e-308}}else d=b;b=Ae(d+1023|0,0,52)|0;d=D;c[k>>2]=b;c[k+4>>2]=d;return +(a*+h[k>>3]);}function fe(a,b){a=a|0;b=b|0;if(!a)a=0;else a=ge(a,b,0)|0;return a|0}function ge(b,d,e){b=b|0;d=d|0;e=e|0;if(!b){b=1;return b|0}if(d>>>0<128){a[b>>0]=d;b=1;return b|0}if(d>>>0<2048){a[b>>0]=d>>>6|192;a[b+1>>0]=d&63|128;b=2;return b|0}if(d>>>0<55296|(d&-8192|0)==57344){a[b>>0]=d>>>12|224;a[b+1>>0]=d>>>6&63|128;a[b+2>>0]=d&63|128;b=3;return b|0}if((d+-65536|0)>>>0<1048576){a[b>>0]=d>>>18|240;a[b+1>>0]=d>>>12&63|128;a[b+2>>0]=d>>>6&63|128;a[b+3>>0]=d&63|128;b=4;return b|0}else{c[(Ra()|0)>>2]=84;b=-1;return b|0}return 0}function he(b){b=b|0;var d=0,e=0;d=b+74|0;e=a[d>>0]|0;a[d>>0]=e+255|e;d=c[b>>2]|0;if(!(d&8)){c[b+8>>2]=0;c[b+4>>2]=0;d=c[b+44>>2]|0;c[b+28>>2]=d;c[b+20>>2]=d;c[b+16>>2]=d+(c[b+48>>2]|0);d=0;return d|0}else{c[b>>2]=d|32;d=-1;return d|0}return 0}function ie(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=e+16|0;g=c[f>>2]|0;do if(!g)if(!(he(e)|0)){g=c[f>>2]|0;break}else{f=0;return f|0}while(0);i=e+20|0;f=c[i>>2]|0;if((g-f|0)>>>0>>0){f=fb[c[e+36>>2]&3](e,b,d)|0;return f|0}a:do if((a[e+75>>0]|0)>-1){g=d;while(1){if(!g){h=d;g=0;break a}h=g+-1|0;if((a[b+h>>0]|0)==10)break;else g=h}if((fb[c[e+36>>2]&3](e,b,g)|0)>>>0>>0){f=g;return f|0}else{h=d-g|0;b=b+g|0;f=c[i>>2]|0;break}}else{h=d;g=0}while(0);ze(f|0,b|0,h|0)|0;c[i>>2]=(c[i>>2]|0)+h;f=g+h|0;return f|0}function je(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=i;i=i+16|0;f=e;c[f>>2]=d;b=me(a,b,f)|0;i=e;return b|0}function ke(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=i;i=i+224|0;l=p+120|0;o=p+80|0;n=p;m=p+136|0;e=o;f=e+40|0;do{c[e>>2]=0;e=e+4|0}while((e|0)<(f|0));c[l>>2]=c[d>>2];if((oe(0,b,l,n,o)|0)<0){m=-1;i=p;return m|0}e=a+48|0;if(!(c[e>>2]|0)){g=a+44|0;h=c[g>>2]|0;c[g>>2]=m;j=a+28|0;c[j>>2]=m;k=a+20|0;c[k>>2]=m;c[e>>2]=80;f=a+16|0;c[f>>2]=m+80;d=oe(a,b,l,n,o)|0;if(h){fb[c[a+36>>2]&3](a,0,0)|0;d=(c[k>>2]|0)==0?-1:d;c[g>>2]=h;c[e>>2]=0;c[f>>2]=0;c[j>>2]=0;c[k>>2]=0}}else d=oe(a,b,l,n,o)|0;m=d;i=p;return m|0}function le(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0;m=i;i=i+128|0;g=m+112|0;l=m;h=l;j=95808;k=h+112|0;do{c[h>>2]=c[j>>2];h=h+4|0;j=j+4|0}while((h|0)<(k|0));if((d+-1|0)>>>0>2147483646)if(!d)d=1;else{c[(Ra()|0)>>2]=75;d=-1;i=m;return d|0}else g=b;h=-2-g|0;h=d>>>0>h>>>0?h:d;c[l+48>>2]=h;b=l+20|0;c[b>>2]=g;c[l+44>>2]=g;d=g+h|0;g=l+16|0;c[g>>2]=d;c[l+28>>2]=d;d=ke(l,e,f)|0;if(!h){i=m;return d|0}b=c[b>>2]|0;a[b+(((b|0)==(c[g>>2]|0))<<31>>31)>>0]=0;i=m;return d|0}function me(a,b,c){a=a|0;b=b|0;c=c|0;return le(a,2147483647,b,c)|0}function ne(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;h=d&255;f=(e|0)!=0;a:do if(f&(b&3|0)!=0){g=d&255;while(1){if((a[b>>0]|0)==g<<24>>24){i=6;break a}b=b+1|0;e=e+-1|0;f=(e|0)!=0;if(!(f&(b&3|0)!=0)){i=5;break}}}else i=5;while(0);if((i|0)==5)if(f)i=6;else e=0;b:do if((i|0)==6){g=d&255;if((a[b>>0]|0)!=g<<24>>24){f=$(h,16843009)|0;c:do if(e>>>0>3)while(1){d=c[b>>2]^f;if((d&-2139062144^-2139062144)&d+-16843009)break;b=b+4|0;e=e+-4|0;if(e>>>0<=3){i=11;break c}}else i=11;while(0);if((i|0)==11)if(!e){e=0;break}while(1){if((a[b>>0]|0)==g<<24>>24)break b;b=b+1|0;e=e+-1|0;if(!e){e=0;break}}}}while(0);return ((e|0)!=0?b:0)|0}function oe(e,f,g,j,l){e=e|0;f=f|0;g=g|0;j=j|0;l=l|0;var m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0,z=0.0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Sa=0,Ta=0,Ua=0,Va=0,Wa=0,Xa=0,Za=0,_a=0,$a=0,ab=0,bb=0,cb=0,db=0,eb=0,fb=0,gb=0;gb=i;i=i+864|0;Oa=gb+16|0;Sa=gb+8|0;Pa=gb+836|0;ma=Pa;La=gb+824|0;Za=gb+568|0;Ha=gb+528|0;db=gb;Va=gb+520|0;na=(e|0)!=0;Aa=Ha+40|0;Ea=Aa;Ha=Ha+39|0;Ia=db+4|0;Ja=db;Ka=La+12|0;La=La+11|0;Ma=Ka;oa=Ma-ma|0;pa=-2-ma|0;va=Ma+2|0;wa=Oa+288|0;xa=Pa+9|0;ya=xa;za=Pa+8|0;I=0;G=0;t=0;q=0;v=0;a:while(1){do if((t|0)>-1)if((q|0)>(2147483647-t|0)){c[(Ra()|0)>>2]=75;ba=-1;break}else{ba=q+t|0;break}else ba=t;while(0);q=a[f>>0]|0;if(!(q<<24>>24)){Qa=ba;Ua=v;P=344;break}else p=f;while(1){if(q<<24>>24==37){Ca=p;eb=p;P=9;break}else if(!(q<<24>>24)){ha=p;fa=p;break}H=p+1|0;q=a[H>>0]|0;p=H}b:do if((P|0)==9)while(1){P=0;if((a[Ca+1>>0]|0)!=37){ha=Ca;fa=eb;break b}p=eb+1|0;q=Ca+2|0;if((a[q>>0]|0)==37){Ca=q;eb=p}else{ha=q;fa=p;break}}while(0);q=fa-f|0;if(na)ie(f,q,e)|0;if((fa|0)!=(f|0)){f=ha;t=ba;continue}t=ha+1|0;r=a[t>>0]|0;p=(r<<24>>24)+-48|0;if(p>>>0<10){F=(a[ha+2>>0]|0)==36;t=F?ha+3|0:t;r=a[t>>0]|0;H=F?p:-1;v=F?1:v}else H=-1;p=r<<24>>24;c:do if((p&-32|0)==32){u=0;do{if(!(1<>24)+-32|u;t=t+1|0;r=a[t>>0]|0;p=r<<24>>24}while((p&-32|0)==32);}else u=0;while(0);do if(r<<24>>24==42){p=t+1|0;r=(a[p>>0]|0)+-48|0;if(r>>>0<10?(a[t+2>>0]|0)==36:0){c[l+(r<<2)>>2]=10;v=1;r=t+3|0;t=c[j+((a[p>>0]|0)+-48<<3)>>2]|0}else{if(v){fb=-1;P=363;break a}if(!na){r=p;v=0;O=0;break}v=(c[g>>2]|0)+(4-1)&~(4-1);t=c[v>>2]|0;c[g>>2]=v+4;v=0;r=p}if((t|0)<0){u=u|8192;O=0-t|0}else O=t}else{p=(r<<24>>24)+-48|0;if(p>>>0<10){r=t;t=0;do{t=(t*10|0)+p|0;r=r+1|0;p=(a[r>>0]|0)+-48|0}while(p>>>0<10);if((t|0)<0){fb=-1;P=363;break a}else O=t}else{r=t;O=0}}while(0);d:do if((a[r>>0]|0)==46){t=r+1|0;p=a[t>>0]|0;if(p<<24>>24!=42){p=(p<<24>>24)+-48|0;if(p>>>0<10){r=t;t=0}else{r=t;A=0;break}while(1){t=(t*10|0)+p|0;r=r+1|0;p=(a[r>>0]|0)+-48|0;if(p>>>0>=10){A=t;break d}}}p=r+2|0;t=(a[p>>0]|0)+-48|0;if(t>>>0<10?(a[r+3>>0]|0)==36:0){c[l+(t<<2)>>2]=10;r=r+4|0;A=c[j+((a[p>>0]|0)+-48<<3)>>2]|0;break}if(v){fb=-1;P=363;break a}if(na){r=(c[g>>2]|0)+(4-1)&~(4-1);A=c[r>>2]|0;c[g>>2]=r+4;r=p}else{r=p;A=0}}else A=-1;while(0);y=0;while(1){t=(a[r>>0]|0)+-65|0;if(t>>>0>57){fb=-1;P=363;break a}w=r+1|0;t=a[95920+(y*58|0)+t>>0]|0;p=t&255;if((p+-1|0)>>>0<8){r=w;y=p}else{x=t;break}}if(!(x<<24>>24)){fb=-1;P=363;break}t=(H|0)>-1;e:do if(x<<24>>24==19)if(t){fb=-1;P=363;break a}else{qa=I;ra=G;P=62}else{if(t){c[l+(H<<2)>>2]=p;ra=j+(H<<3)|0;qa=c[ra+4>>2]|0;ra=c[ra>>2]|0;P=62;break}if(!na){fb=0;P=363;break a}if((x&255)>20){Ba=G;Da=I}else do switch(p|0){case 10:{Ba=(c[g>>2]|0)+(4-1)&~(4-1);Da=c[Ba>>2]|0;c[g>>2]=Ba+4;Ba=Da;Da=((Da|0)<0)<<31>>31;break e}case 11:{Da=(c[g>>2]|0)+(4-1)&~(4-1);Ba=c[Da>>2]|0;c[g>>2]=Da+4;Da=0;break e}case 9:{Da=(c[g>>2]|0)+(4-1)&~(4-1);Ba=c[Da>>2]|0;c[g>>2]=Da+4;Da=I;break e}case 17:{Ba=(c[g>>2]|0)+(8-1)&~(8-1);s=+h[Ba>>3];c[g>>2]=Ba+8;h[k>>3]=s;Ba=c[k>>2]|0;Da=c[k+4>>2]|0;break e}case 18:{Ba=(c[g>>2]|0)+(8-1)&~(8-1);s=+h[Ba>>3];c[g>>2]=Ba+8;h[k>>3]=s;Ba=c[k>>2]|0;Da=c[k+4>>2]|0;break e}case 16:{Da=(c[g>>2]|0)+(4-1)&~(4-1);Ba=c[Da>>2]|0;c[g>>2]=Da+4;Ba=Ba&255;Da=0;break e}case 15:{Ba=(c[g>>2]|0)+(4-1)&~(4-1);Da=c[Ba>>2]|0;c[g>>2]=Ba+4;Ba=Da<<24>>24;Da=(((Da&255)<<24>>24|0)<0)<<31>>31;break e}case 12:{I=(c[g>>2]|0)+(8-1)&~(8-1);Da=I;Ba=c[Da>>2]|0;Da=c[Da+4>>2]|0;c[g>>2]=I+8;break e}case 13:{Ba=(c[g>>2]|0)+(4-1)&~(4-1);Da=c[Ba>>2]|0;c[g>>2]=Ba+4;Ba=Da<<16>>16;Da=(((Da&65535)<<16>>16|0)<0)<<31>>31;break e}case 14:{Da=(c[g>>2]|0)+(4-1)&~(4-1);Ba=c[Da>>2]|0;c[g>>2]=Da+4;Ba=Ba&65535;Da=0;break e}default:{Ba=G;Da=I;break e}}while(0);}while(0);if((P|0)==62){P=0;if(na){Ba=ra;Da=qa}else{I=qa;G=ra;f=w;t=ba;continue}}J=a[r>>0]|0;J=(y|0)!=0&(J&15|0)==3?J&-33:J;x=u&-65537;N=(u&8192|0)==0?u:x;f:do switch(J|0){case 111:{p=(Ba|0)==0&(Da|0)==0;if(p)o=Aa;else{o=Aa;f=Ba;q=Da;do{o=o+-1|0;a[o>>0]=f&7|48;f=ye(f|0,q|0,3)|0;q=D}while(!((f|0)==0&(q|0)==0));}T=(N&8|0)==0|p;U=Ba;V=Da;Q=N;R=A;S=T&1^1;T=T?96400:96405;P=89;break}case 117:{Fa=Da;Ga=Ba;_a=0;$a=96400;P=84;break}case 99:{a[Ha>>0]=Ba;ia=Da;ja=Ba;ka=Ha;n=x;ca=1;da=0;ea=96400;ga=Aa;break}case 109:{Na=Ya(c[(Ra()|0)>>2]|0)|0;P=94;break}case 115:{Na=(Ba|0)!=0?Ba:96416;P=94;break}case 105:case 100:{if((Da|0)<0){Ga=ue(0,0,Ba|0,Da|0)|0;Fa=D;_a=1;$a=96400;P=84;break f}if(!(N&2048)){$a=N&1;Fa=Da;Ga=Ba;_a=$a;$a=($a|0)==0?96400:96402;P=84}else{Fa=Da;Ga=Ba;_a=1;$a=96401;P=84}break}case 67:{c[db>>2]=Ba;c[Ia>>2]=0;sa=db;ta=Ja;Xa=-1;P=97;break}case 83:{f=Ba;if(!A){_=Ba;aa=f;Z=0;P=102}else{sa=f;ta=Ba;Xa=A;P=97}break}case 112:{Ta=N|8;Wa=A>>>0>8?A:8;cb=120;P=73;break}case 88:case 120:{Ta=N;Wa=A;cb=J;P=73;break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{c[k>>2]=Ba;c[k+4>>2]=Da;s=+h[k>>3];c[Sa>>2]=0;if((Da|0)>=0)if(!(N&2048)){L=N&1;K=L;L=(L|0)==0?96425:96430}else{K=1;L=96427}else{s=-s;K=1;L=96424}h[k>>3]=s;I=c[k+4>>2]&2146435072;do if(I>>>0<2146435072|(I|0)==2146435072&0<0){z=+ce(s,Sa)*2.0;t=z!=0.0;if(t)c[Sa>>2]=(c[Sa>>2]|0)+-1;I=J|32;if((I|0)==97){B=J&32;E=(B|0)==0?L:L+9|0;F=K|2;t=12-A|0;do if(!(A>>>0>11|(t|0)==0)){s=8.0;do{t=t+-1|0;s=s*16.0}while((t|0)!=0);if((a[E>>0]|0)==45){s=-(s+(-z-s));break}else{s=z+s-s;break}}else s=z;while(0);t=c[Sa>>2]|0;t=(t|0)<0?0-t|0:t;if((t|0)<0){r=Ka;p=t;u=((t|0)<0)<<31>>31;while(1){t=Ie(p|0,u|0,10,0)|0;r=r+-1|0;a[r>>0]=t|48;t=He(p|0,u|0,10,0)|0;if(u>>>0>9|(u|0)==9&p>>>0>4294967295){p=t;u=D}else break}}else r=Ka;if(t)while(1){r=r+-1|0;a[r>>0]=(t>>>0)%10|0|48;if(t>>>0<10)break;else t=(t>>>0)/10|0}if((r|0)==(Ka|0)){a[La>>0]=48;r=La}a[r+-1>>0]=(c[Sa>>2]>>31&2)+43;C=r+-2|0;a[C>>0]=J+15;if(!(N&8))if((A|0)<1){r=Pa;do{I=~~s;t=r+1|0;a[r>>0]=d[96384+I>>0]|B;s=(s-+(I|0))*16.0;if((t-ma|0)!=1|s==0.0)r=t;else{a[t>>0]=46;r=r+2|0}}while(s!=0.0);}else{r=Pa;do{I=~~s;t=r+1|0;a[r>>0]=d[96384+I>>0]|B;s=(s-+(I|0))*16.0;if((t-ma|0)==1){a[t>>0]=46;r=r+2|0}else r=t}while(s!=0.0);}else{r=Pa;do{I=~~s;t=r+1|0;a[r>>0]=d[96384+I>>0]|B;s=(s-+(I|0))*16.0;if((t-ma|0)==1){a[t>>0]=46;r=r+2|0}else r=t}while(s!=0.0);}y=(A|0)!=0&(pa+r|0)<(A|0)?va+A-C|0:oa-C+r|0;u=y+F|0;x=N&73728;p=(O|0)>(u|0);if((x|0)==0&p){t=O-u|0;ve(Za|0,32,(t>>>0>256?256:t)|0)|0;if(t>>>0>255){f=t;do{ie(Za,256,e)|0;f=f+-256|0}while(f>>>0>255);t=t&255}ie(Za,t,e)|0}ie(E,F,e)|0;if((x|0)==65536&p){f=O-u|0;ve(Za|0,48,(f>>>0>256?256:f)|0)|0;if(f>>>0>255){q=f;do{ie(Za,256,e)|0;q=q+-256|0}while(q>>>0>255);f=f&255}ie(Za,f,e)|0}r=r-ma|0;ie(Pa,r,e)|0;t=Ma-C|0;r=y-t-r|0;if((r|0)>0){ve(Za|0,48,(r>>>0>256?256:r)|0)|0;if(r>>>0>255){f=r;do{ie(Za,256,e)|0;f=f+-256|0}while(f>>>0>255);r=r&255}ie(Za,r,e)|0}ie(C,t,e)|0;if((x|0)==8192&p){f=O-u|0;ve(Za|0,32,(f>>>0>256?256:f)|0)|0;if(f>>>0>255){r=f;do{ie(Za,256,e)|0;r=r+-256|0}while(r>>>0>255);f=f&255}ie(Za,f,e)|0}q=p?O:u;break}r=(A|0)<0?6:A;if(t){t=(c[Sa>>2]|0)+-28|0;c[Sa>>2]=t;s=z*268435456.0}else{s=z;t=c[Sa>>2]|0}M=(t|0)<0?Oa:wa;G=M;u=M;do{H=~~s>>>0;c[u>>2]=H;u=u+4|0;s=(s-+(H>>>0))*1.0e9}while(s!=0.0);t=c[Sa>>2]|0;if((t|0)>0){f=t;t=M;do{y=(f|0)>29?29:f;p=u+-4|0;do if(p>>>0>=t>>>0){f=0;do{H=Ae(c[p>>2]|0,0,y|0)|0;H=xe(H|0,D|0,f|0,0)|0;f=D;F=Ie(H|0,f|0,1e9,0)|0;c[p>>2]=F;f=He(H|0,f|0,1e9,0)|0;p=p+-4|0}while(p>>>0>=t>>>0);if(!f)break;t=t+-4|0;c[t>>2]=f}while(0);while(1){if(u>>>0<=t>>>0)break;f=u+-4|0;if(!(c[f>>2]|0))u=f;else break}f=(c[Sa>>2]|0)-y|0;c[Sa>>2]=f}while((f|0)>0);}else{f=t;t=M}g:do if((f|0)<0){C=((r+25|0)/9|0)+1|0;if((I|0)!=102)while(1){f=0-f|0;f=(f|0)>9?9:f;do if(t>>>0>>0){y=(1<>>f;x=0;q=t;do{H=c[q>>2]|0;c[q>>2]=(H>>>f)+x;x=$(H&y,p)|0;q=q+4|0}while(q>>>0>>0);t=(c[t>>2]|0)==0?t+4|0:t;if(!x)break;c[u>>2]=x;u=u+4|0}else t=(c[t>>2]|0)==0?t+4|0:t;while(0);u=(u-t>>2|0)>(C|0)?t+(C<<2)|0:u;f=(c[Sa>>2]|0)+f|0;c[Sa>>2]=f;if((f|0)>=0)break g}A=M+(C<<2)|0;do{f=0-f|0;f=(f|0)>9?9:f;do if(t>>>0>>0){y=(1<>>f;x=0;q=t;do{H=c[q>>2]|0;c[q>>2]=(H>>>f)+x;x=$(H&y,p)|0;q=q+4|0}while(q>>>0>>0);t=(c[t>>2]|0)==0?t+4|0:t;if(!x)break;c[u>>2]=x;u=u+4|0}else t=(c[t>>2]|0)==0?t+4|0:t;while(0);u=(u-G>>2|0)>(C|0)?A:u;f=(c[Sa>>2]|0)+f|0;c[Sa>>2]=f}while((f|0)<0);}while(0);do if(t>>>0>>0){f=(G-t>>2)*9|0;p=c[t>>2]|0;if(p>>>0<10){B=f;break}else x=10;do{x=x*10|0;f=f+1|0}while(p>>>0>=x>>>0);B=f}else B=0;while(0);F=(I|0)==103;E=(r|0)!=0;p=r-((I|0)!=102?B:0)+((E&F)<<31>>31)|0;if((p|0)<(((u-G>>2)*9|0)+-9|0)){x=p+9216|0;A=(x|0)/9|0;f=M+(A+-1023<<2)|0;x=((x|0)%9|0)+1|0;if((x|0)<9){y=10;do{y=y*10|0;x=x+1|0}while((x|0)!=9);}else y=10;p=c[f>>2]|0;q=(p>>>0)%(y>>>0)|0;if((q|0)==0?(M+(A+-1022<<2)|0)==(u|0):0){Y=t;X=f;W=B}else P=221;do if((P|0)==221){P=0;z=(((p>>>0)/(y>>>0)|0)&1|0)==0?9007199254740992.0:9007199254740994.0;x=(y|0)/2|0;do if(q>>>0>>0)s=.5;else{if((q|0)==(x|0)?(M+(A+-1022<<2)|0)==(u|0):0){s=1.0;break}s=1.5}while(0);do if(K){if((a[L>>0]|0)!=45)break;z=-z;s=-s}while(0);x=p-q|0;c[f>>2]=x;if(!(z+s!=z)){Y=t;X=f;W=B;break}I=x+y|0;c[f>>2]=I;if(I>>>0>999999999)while(1){q=f+-4|0;c[f>>2]=0;if(q>>>0>>0){t=t+-4|0;c[t>>2]=0}I=(c[q>>2]|0)+1|0;c[q>>2]=I;if(I>>>0>999999999)f=q;else{f=q;break}}q=(G-t>>2)*9|0;x=c[t>>2]|0;if(x>>>0<10){Y=t;X=f;W=q;break}else p=10;do{p=p*10|0;q=q+1|0}while(x>>>0>=p>>>0);Y=t;X=f;W=q}while(0);I=X+4|0;t=Y;B=W;u=u>>>0>I>>>0?I:u}A=0-B|0;while(1){if(u>>>0<=t>>>0){H=0;break}x=u+-4|0;if(!(c[x>>2]|0))u=x;else{H=1;break}}do if(F){r=(E&1^1)+r|0;if((r|0)>(B|0)&(B|0)>-5){q=J+-1|0;r=r+-1-B|0}else{q=J+-2|0;r=r+-1|0}x=N&8;if(x){F=x;break}do if(H){y=c[u+-4>>2]|0;if(!y){x=9;break}if(!((y>>>0)%10|0)){p=10;x=0}else{x=0;break}do{p=p*10|0;x=x+1|0}while(((y>>>0)%(p>>>0)|0|0)==0);}else x=9;while(0);p=((u-G>>2)*9|0)+-9|0;if((q|32|0)==102){F=p-x|0;F=(F|0)<0?0:F;r=(r|0)<(F|0)?r:F;F=0;break}else{F=p+B-x|0;F=(F|0)<0?0:F;r=(r|0)<(F|0)?r:F;F=0;break}}else{q=J;F=N&8}while(0);G=r|F;C=(G|0)!=0&1;E=(q|32|0)==102;if(E){x=(B|0)>0?B:0;B=0}else{y=(B|0)<0?A:B;if((y|0)<0){x=Ka;f=y;p=((y|0)<0)<<31>>31;while(1){y=Ie(f|0,p|0,10,0)|0;x=x+-1|0;a[x>>0]=y|48;y=He(f|0,p|0,10,0)|0;if(p>>>0>9|(p|0)==9&f>>>0>4294967295){f=y;p=D}else break}}else x=Ka;if(y)while(1){x=x+-1|0;a[x>>0]=(y>>>0)%10|0|48;if(y>>>0<10)break;else y=(y>>>0)/10|0}if((Ma-x|0)<2)do{x=x+-1|0;a[x>>0]=48}while((Ma-x|0)<2);a[x+-1>>0]=(B>>31&2)+43;B=x+-2|0;a[B>>0]=q;x=Ma-B|0}I=K+1+r+C+x|0;C=N&73728;A=(O|0)>(I|0);if((C|0)==0&A){x=O-I|0;ve(Za|0,32,(x>>>0>256?256:x)|0)|0;if(x>>>0>255){y=x;do{ie(Za,256,e)|0;y=y+-256|0}while(y>>>0>255);x=x&255}ie(Za,x,e)|0}ie(L,K,e)|0;if((C|0)==65536&A){f=O-I|0;ve(Za|0,48,(f>>>0>256?256:f)|0)|0;if(f>>>0>255){p=f;do{ie(Za,256,e)|0;p=p+-256|0}while(p>>>0>255);f=f&255}ie(Za,f,e)|0}if(E){y=t>>>0>M>>>0?M:t;f=y;do{q=c[f>>2]|0;if(!q)t=xa;else{t=xa;while(1){t=t+-1|0;a[t>>0]=(q>>>0)%10|0|48;if(q>>>0<10)break;else q=(q>>>0)/10|0}}do if((f|0)==(y|0)){if((t|0)!=(xa|0))break;a[za>>0]=48;t=za}else{if(t>>>0<=Pa>>>0)break;do{t=t+-1|0;a[t>>0]=48}while(t>>>0>Pa>>>0);}while(0);ie(t,ya-t|0,e)|0;f=f+4|0}while(f>>>0<=M>>>0);if(G)ie(96480,1,e)|0;if((r|0)>0&f>>>0>>0){p=f;do{t=c[p>>2]|0;if(t){f=xa;while(1){f=f+-1|0;a[f>>0]=(t>>>0)%10|0|48;if(t>>>0<10)break;else t=(t>>>0)/10|0}if(f>>>0>Pa>>>0){ab=f;P=289}else la=f}else{ab=xa;P=289}if((P|0)==289)while(1){P=0;f=ab+-1|0;a[f>>0]=48;if(f>>>0>Pa>>>0)ab=f;else{la=f;break}}H=(r|0)>9;ie(la,H?9:r,e)|0;p=p+4|0;r=r+-9|0}while(H&p>>>0>>0);}if((r|0)>0){ve(Za|0,48,(r>>>0>256?256:r)|0)|0;if(r>>>0>255){f=r;do{ie(Za,256,e)|0;f=f+-256|0}while(f>>>0>255);r=r&255}ie(Za,r,e)|0}}else{p=H?u:t+4|0;do if((r|0)>-1){x=(F|0)==0;y=t;do{u=c[y>>2]|0;if(u){f=xa;q=u;while(1){u=f+-1|0;a[u>>0]=(q>>>0)%10|0|48;if(q>>>0<10)break;else{f=u;q=(q>>>0)/10|0}}if((u|0)!=(xa|0)){ua=f;bb=u}else P=303}else P=303;if((P|0)==303){P=0;a[za>>0]=48;ua=xa;bb=za}do if((y|0)==(t|0)){ie(bb,1,e)|0;if(x&(r|0)<1){u=ua;break}ie(96480,1,e)|0;u=ua}else{if(bb>>>0>Pa>>>0)u=bb;else{u=bb;break}do{u=u+-1|0;a[u>>0]=48}while(u>>>0>Pa>>>0);}while(0);H=ya-u|0;ie(u,(r|0)>(H|0)?H:r,e)|0;r=r-H|0;y=y+4|0}while(y>>>0

>>0&(r|0)>-1);if((r|0)<=0)break;ve(Za|0,48,(r>>>0>256?256:r)|0)|0;if(r>>>0>255){f=r;do{ie(Za,256,e)|0;f=f+-256|0}while(f>>>0>255);r=r&255}ie(Za,r,e)|0}while(0);ie(B,Ma-B|0,e)|0}if((C|0)==8192&A){f=O-I|0;ve(Za|0,32,(f>>>0>256?256:f)|0)|0;if(f>>>0>255){r=f;do{ie(Za,256,e)|0;r=r+-256|0}while(r>>>0>255);f=f&255}ie(Za,f,e)|0}q=A?O:I}else{q=(J&32|0)!=0;u=s!=s|0.0!=0.0;t=u?0:K;q=u?(q?96464:96472):q?96448:96456;u=t+3|0;p=(O|0)>(u|0);if((N&8192|0)==0&p){r=O-u|0;ve(Za|0,32,(r>>>0>256?256:r)|0)|0;if(r>>>0>255){f=r;do{ie(Za,256,e)|0;f=f+-256|0}while(f>>>0>255);r=r&255}ie(Za,r,e)|0}ie(L,t,e)|0;ie(q,3,e)|0;if((N&73728|0)==8192&p){f=O-u|0;ve(Za|0,32,(f>>>0>256?256:f)|0)|0;if(f>>>0>255){r=f;do{ie(Za,256,e)|0;r=r+-256|0}while(r>>>0>255);f=f&255}ie(Za,f,e)|0}q=p?O:u}while(0);I=Da;G=Ba;f=w;t=ba;continue a}case 110:switch(y|0){case 0:{c[Ba>>2]=ba;I=Da;G=Ba;f=w;t=ba;continue a}case 1:{c[Ba>>2]=ba;I=Da;G=Ba;f=w;t=ba;continue a}case 2:{I=Ba;c[I>>2]=ba;c[I+4>>2]=((ba|0)<0)<<31>>31;I=Da;G=Ba;f=w;t=ba;continue a}case 3:{b[Ba>>1]=ba;I=Da;G=Ba;f=w;t=ba;continue a}case 4:{a[Ba>>0]=ba;I=Da;G=Ba;f=w;t=ba;continue a}case 6:{c[Ba>>2]=ba;I=Da;G=Ba;f=w;t=ba;continue a}case 7:{I=Ba;c[I>>2]=ba;c[I+4>>2]=((ba|0)<0)<<31>>31;I=Da;G=Ba;f=w;t=ba;continue a}default:{I=Da;G=Ba;f=w;t=ba;continue a}}default:{ia=Da;ja=Ba;ka=f;n=N;ca=A;da=0;ea=96400;ga=Aa}}while(0);if((P|0)==73){o=cb&32;if(!((Ba|0)==0&(Da|0)==0)){p=Aa;q=Ba;f=Da;do{p=p+-1|0;a[p>>0]=d[96384+(q&15)>>0]|o;q=ye(q|0,f|0,4)|0;f=D}while(!((q|0)==0&(f|0)==0));if(!(Ta&8)){U=Ba;V=Da;o=p;Q=Ta;R=Wa;S=0;T=96400;P=89}else{U=Ba;V=Da;o=p;Q=Ta;R=Wa;S=2;T=96400+(cb>>4)|0;P=89}}else{U=Ba;V=Da;o=Aa;Q=Ta;R=Wa;S=0;T=96400;P=89}}else if((P|0)==84){if(Fa>>>0>0|(Fa|0)==0&Ga>>>0>4294967295){o=Aa;f=Ga;q=Fa;while(1){p=Ie(f|0,q|0,10,0)|0;o=o+-1|0;a[o>>0]=p|48;p=He(f|0,q|0,10,0)|0;if(q>>>0>9|(q|0)==9&f>>>0>4294967295){f=p;q=D}else break}}else{o=Aa;p=Ga}if(!p){U=Ga;V=Fa;Q=N;R=A;S=_a;T=$a;P=89}else while(1){o=o+-1|0;a[o>>0]=(p>>>0)%10|0|48;if(p>>>0<10){U=Ga;V=Fa;Q=N;R=A;S=_a;T=$a;P=89;break}else p=(p>>>0)/10|0}}else if((P|0)==94){P=0;ga=ne(Na,0,A)|0;I=(ga|0)==0;ia=Da;ja=Ba;ka=Na;n=x;ca=I?A:ga-Na|0;da=0;ea=96400;ga=I?Na+A|0:ga}else if((P|0)==97){q=0;f=0;r=sa;while(1){p=c[r>>2]|0;if(!p)break;f=fe(Va,p)|0;if((f|0)<0|f>>>0>(Xa-q|0)>>>0)break;q=f+q|0;if(Xa>>>0>q>>>0)r=r+4|0;else break}if((f|0)<0){fb=-1;P=363;break}else{_=ta;aa=sa;Z=q;P=102}}if((P|0)==89){P=0;n=(R|0)>-1?Q&-65537:Q;p=(U|0)!=0|(V|0)!=0;if(p|(R|0)!=0){ca=(p&1^1)+(Ea-o)|0;ia=V;ja=U;ka=o;ca=(R|0)>(ca|0)?R:ca;da=S;ea=T;ga=Aa}else{ia=V;ja=U;ka=Aa;ca=0;da=S;ea=T;ga=Aa}}else if((P|0)==102){P=0;t=N&73728;y=(O|0)>(Z|0);if((t|0)==0&y){f=O-Z|0;ve(Za|0,32,(f>>>0>256?256:f)|0)|0;if(f>>>0>255){r=f;do{ie(Za,256,e)|0;r=r+-256|0}while(r>>>0>255);f=f&255}ie(Za,f,e)|0}h:do if(Z){f=0;q=aa;while(1){r=c[q>>2]|0;if(!r)break h;r=fe(Va,r)|0;f=r+f|0;if((f|0)>(Z|0))break h;ie(Va,r,e)|0;if(f>>>0>=Z>>>0)break;else q=q+4|0}}while(0);if((t|0)==8192&y){f=O-Z|0;ve(Za|0,32,(f>>>0>256?256:f)|0)|0;if(f>>>0>255){q=f;do{ie(Za,256,e)|0;q=q+-256|0}while(q>>>0>255);f=f&255}ie(Za,f,e)|0}I=Da;G=_;f=w;t=ba;q=y?O:Z;continue}q=ga-ka|0;u=(ca|0)<(q|0)?q:ca;t=da+u|0;y=(O|0)<(t|0)?t:O;x=n&73728;p=(y|0)>(t|0);if((x|0)==0&p){r=y-t|0;ve(Za|0,32,(r>>>0>256?256:r)|0)|0;if(r>>>0>255){f=r;do{ie(Za,256,e)|0;f=f+-256|0}while(f>>>0>255);r=r&255}ie(Za,r,e)|0}ie(ea,da,e)|0;if((x|0)==65536&p){r=y-t|0;ve(Za|0,48,(r>>>0>256?256:r)|0)|0;if(r>>>0>255){f=r;do{ie(Za,256,e)|0;f=f+-256|0}while(f>>>0>255);r=r&255}ie(Za,r,e)|0}if((u|0)>(q|0)){r=u-q|0;ve(Za|0,48,(r>>>0>256?256:r)|0)|0;if(r>>>0>255){f=r;do{ie(Za,256,e)|0;f=f+-256|0}while(f>>>0>255);r=r&255}ie(Za,r,e)|0}ie(ka,q,e)|0;if((x|0)==8192&p){f=y-t|0;ve(Za|0,32,(f>>>0>256?256:f)|0)|0;if(f>>>0>255){q=f;do{ie(Za,256,e)|0;q=q+-256|0}while(q>>>0>255);f=f&255}ie(Za,f,e)|0}I=ia;G=ja;f=w;t=ba;q=y}if((P|0)==344){if(e){cb=Qa;i=gb;return cb|0}if(!Ua){cb=0;i=gb;return cb|0}else p=1;while(1){n=c[l+(p<<2)>>2]|0;if(!n){m=p;break}o=j+(p<<3)|0;i:do if(n>>>0<=20)do switch(n|0){case 9:{bb=(c[g>>2]|0)+(4-1)&~(4-1);cb=c[bb>>2]|0;c[g>>2]=bb+4;c[o>>2]=cb;break i}case 10:{cb=(c[g>>2]|0)+(4-1)&~(4-1);bb=c[cb>>2]|0;c[g>>2]=cb+4;cb=o;c[cb>>2]=bb;c[cb+4>>2]=((bb|0)<0)<<31>>31;break i}case 11:{cb=(c[g>>2]|0)+(4-1)&~(4-1);bb=c[cb>>2]|0;c[g>>2]=cb+4;cb=o;c[cb>>2]=bb;c[cb+4>>2]=0;break i}case 12:{cb=(c[g>>2]|0)+(8-1)&~(8-1);bb=cb;ab=c[bb>>2]|0;bb=c[bb+4>>2]|0;c[g>>2]=cb+8;cb=o;c[cb>>2]=ab;c[cb+4>>2]=bb;break i}case 13:{cb=(c[g>>2]|0)+(4-1)&~(4-1);bb=c[cb>>2]|0;c[g>>2]=cb+4;bb=(bb&65535)<<16>>16;cb=o;c[cb>>2]=bb;c[cb+4>>2]=((bb|0)<0)<<31>>31;break i}case 14:{cb=(c[g>>2]|0)+(4-1)&~(4-1);bb=c[cb>>2]|0;c[g>>2]=cb+4;cb=o;c[cb>>2]=bb&65535;c[cb+4>>2]=0;break i}case 15:{cb=(c[g>>2]|0)+(4-1)&~(4-1);bb=c[cb>>2]|0;c[g>>2]=cb+4;bb=(bb&255)<<24>>24;cb=o;c[cb>>2]=bb;c[cb+4>>2]=((bb|0)<0)<<31>>31;break i}case 16:{cb=(c[g>>2]|0)+(4-1)&~(4-1);bb=c[cb>>2]|0;c[g>>2]=cb+4;cb=o;c[cb>>2]=bb&255;c[cb+4>>2]=0;break i}case 17:{cb=(c[g>>2]|0)+(8-1)&~(8-1);s=+h[cb>>3];c[g>>2]=cb+8;h[o>>3]=s;break i}case 18:{cb=(c[g>>2]|0)+(8-1)&~(8-1);s=+h[cb>>3];c[g>>2]=cb+8;h[o>>3]=s;break i}default:break i}while(0);while(0);p=p+1|0;if((p|0)>=10){fb=1;P=363;break}}if((P|0)==363){i=gb;return fb|0}if((m|0)>=10){cb=1;i=gb;return cb|0}while(1){if(c[l+(m<<2)>>2]|0){fb=-1;P=363;break}m=m+1|0;if((m|0)>=10){fb=1;P=363;break}}if((P|0)==363){i=gb;return fb|0}}else if((P|0)==363){i=gb;return fb|0}return 0}function pe(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=a+20|0;f=c[e>>2]|0;a=(c[a+16>>2]|0)-f|0;a=a>>>0>d>>>0?d:a;ze(f|0,b|0,a|0)|0;c[e>>2]=(c[e>>2]|0)+a;return d|0}function qe(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0;do if(a>>>0<245){q=a>>>0<11?16:a+11&-8;a=q>>>3;l=c[24122]|0;j=l>>>a;if(j&3){e=(j&1^1)+a|0;f=e<<1;b=96528+(f<<2)|0;f=96528+(f+2<<2)|0;g=c[f>>2]|0;h=g+8|0;i=c[h>>2]|0;do if((b|0)!=(i|0)){if(i>>>0<(c[24126]|0)>>>0)pa();d=i+12|0;if((c[d>>2]|0)==(g|0)){c[d>>2]=b;c[f>>2]=i;break}else pa();}else c[24122]=l&~(1<>2]=w|3;w=g+(w|4)|0;c[w>>2]=c[w>>2]|1;w=h;return w|0}b=c[24124]|0;if(q>>>0>b>>>0){if(j){f=2<>>12&16;f=f>>>a;e=f>>>5&8;f=f>>>e;d=f>>>2&4;f=f>>>d;g=f>>>1&2;f=f>>>g;h=f>>>1&1;h=(e|a|d|g|h)+(f>>>h)|0;f=h<<1;g=96528+(f<<2)|0;f=96528+(f+2<<2)|0;d=c[f>>2]|0;a=d+8|0;e=c[a>>2]|0;do if((g|0)!=(e|0)){if(e>>>0<(c[24126]|0)>>>0)pa();i=e+12|0;if((c[i>>2]|0)==(d|0)){c[i>>2]=g;c[f>>2]=e;k=c[24124]|0;break}else pa();}else{c[24122]=l&~(1<>2]=q|3;j=d+q|0;c[d+(q|4)>>2]=b|1;c[d+w>>2]=b;if(k){e=c[24127]|0;g=k>>>3;i=g<<1;f=96528+(i<<2)|0;h=c[24122]|0;g=1<>2]|0;if(i>>>0<(c[24126]|0)>>>0)pa();else{m=h;n=i}}else{c[24122]=h|g;m=96528+(i+2<<2)|0;n=f}c[m>>2]=e;c[n+12>>2]=e;c[e+8>>2]=n;c[e+12>>2]=f}c[24124]=b;c[24127]=j;w=a;return w|0}a=c[24123]|0;if(a){h=(a&0-a)+-1|0;v=h>>>12&16;h=h>>>v;u=h>>>5&8;h=h>>>u;w=h>>>2&4;h=h>>>w;i=h>>>1&2;h=h>>>i;g=h>>>1&1;g=c[96792+((u|v|w|i|g)+(h>>>g)<<2)>>2]|0;h=(c[g+4>>2]&-8)-q|0;i=g;while(1){d=c[i+16>>2]|0;if(!d){d=c[i+20>>2]|0;if(!d){l=h;k=g;break}}i=(c[d+4>>2]&-8)-q|0;w=i>>>0>>0;h=w?i:h;i=d;g=w?d:g}a=c[24126]|0;if(k>>>0>>0)pa();b=k+q|0;if(k>>>0>=b>>>0)pa();j=c[k+24>>2]|0;g=c[k+12>>2]|0;do if((g|0)==(k|0)){h=k+20|0;i=c[h>>2]|0;if(!i){h=k+16|0;i=c[h>>2]|0;if(!i){e=0;break}}while(1){g=i+20|0;f=c[g>>2]|0;if(f){i=f;h=g;continue}g=i+16|0;f=c[g>>2]|0;if(!f)break;else{i=f;h=g}}if(h>>>0>>0)pa();else{c[h>>2]=0;e=i;break}}else{f=c[k+8>>2]|0;if(f>>>0>>0)pa();i=f+12|0;if((c[i>>2]|0)!=(k|0))pa();h=g+8|0;if((c[h>>2]|0)==(k|0)){c[i>>2]=g;c[h>>2]=f;e=g;break}else pa();}while(0);do if(j){i=c[k+28>>2]|0;h=96792+(i<<2)|0;if((k|0)==(c[h>>2]|0)){c[h>>2]=e;if(!e){c[24123]=c[24123]&~(1<>>0<(c[24126]|0)>>>0)pa();i=j+16|0;if((c[i>>2]|0)==(k|0))c[i>>2]=e;else c[j+20>>2]=e;if(!e)break}h=c[24126]|0;if(e>>>0>>0)pa();c[e+24>>2]=j;i=c[k+16>>2]|0;do if(i)if(i>>>0>>0)pa();else{c[e+16>>2]=i;c[i+24>>2]=e;break}while(0);i=c[k+20>>2]|0;if(i)if(i>>>0<(c[24126]|0)>>>0)pa();else{c[e+20>>2]=i;c[i+24>>2]=e;break}}while(0);if(l>>>0<16){w=l+q|0;c[k+4>>2]=w|3;w=k+(w+4)|0;c[w>>2]=c[w>>2]|1}else{c[k+4>>2]=q|3;c[k+(q|4)>>2]=l|1;c[k+(l+q)>>2]=l;d=c[24124]|0;if(d){e=c[24127]|0;g=d>>>3;i=g<<1;f=96528+(i<<2)|0;h=c[24122]|0;g=1<>2]|0;if(h>>>0<(c[24126]|0)>>>0)pa();else{p=i;o=h}}else{c[24122]=h|g;p=96528+(i+2<<2)|0;o=f}c[p>>2]=e;c[o+12>>2]=e;c[e+8>>2]=o;c[e+12>>2]=f}c[24124]=l;c[24127]=b}w=k+8|0;return w|0}else z=q}else z=q}else if(a>>>0<=4294967231){a=a+11|0;p=a&-8;k=c[24123]|0;if(k){j=0-p|0;a=a>>>8;if(a)if(p>>>0>16777215)l=31;else{q=(a+1048320|0)>>>16&8;w=a<>>16&4;w=w<>>16&2;l=14-(o|q|l)+(w<>>15)|0;l=p>>>(l+7|0)&1|l<<1}else l=0;a=c[96792+(l<<2)>>2]|0;a:do if(!a){h=0;a=0;w=86}else{e=j;h=0;d=p<<((l|0)==31?0:25-(l>>>1)|0);b=a;a=0;while(1){g=c[b+4>>2]&-8;j=g-p|0;if(j>>>0>>0)if((g|0)==(p|0)){g=b;a=b;w=90;break a}else a=b;else j=e;w=c[b+20>>2]|0;b=c[b+16+(d>>>31<<2)>>2]|0;h=(w|0)==0|(w|0)==(b|0)?h:w;if(!b){w=86;break}else{e=j;d=d<<1}}}while(0);if((w|0)==86){if((h|0)==0&(a|0)==0){a=2<>>12&16;a=a>>>n;m=a>>>5&8;a=a>>>m;o=a>>>2&4;a=a>>>o;q=a>>>1&2;a=a>>>q;h=a>>>1&1;h=c[96792+((m|n|o|q|h)+(a>>>h)<<2)>>2]|0;a=0}if(!h){n=j;q=a}else{g=h;w=90}}if((w|0)==90)while(1){w=0;q=(c[g+4>>2]&-8)-p|0;h=q>>>0>>0;j=h?q:j;a=h?g:a;h=c[g+16>>2]|0;if(h){g=h;w=90;continue}g=c[g+20>>2]|0;if(!g){n=j;q=a;break}else w=90}if((q|0)!=0?n>>>0<((c[24124]|0)-p|0)>>>0:0){a=c[24126]|0;if(q>>>0>>0)pa();m=q+p|0;if(q>>>0>=m>>>0)pa();j=c[q+24>>2]|0;g=c[q+12>>2]|0;do if((g|0)==(q|0)){h=q+20|0;i=c[h>>2]|0;if(!i){h=q+16|0;i=c[h>>2]|0;if(!i){s=0;break}}while(1){g=i+20|0;f=c[g>>2]|0;if(f){i=f;h=g;continue}g=i+16|0;f=c[g>>2]|0;if(!f)break;else{i=f;h=g}}if(h>>>0>>0)pa();else{c[h>>2]=0;s=i;break}}else{f=c[q+8>>2]|0;if(f>>>0>>0)pa();i=f+12|0;if((c[i>>2]|0)!=(q|0))pa();h=g+8|0;if((c[h>>2]|0)==(q|0)){c[i>>2]=g;c[h>>2]=f;s=g;break}else pa();}while(0);do if(j){i=c[q+28>>2]|0;h=96792+(i<<2)|0;if((q|0)==(c[h>>2]|0)){c[h>>2]=s;if(!s){c[24123]=c[24123]&~(1<>>0<(c[24126]|0)>>>0)pa();i=j+16|0;if((c[i>>2]|0)==(q|0))c[i>>2]=s;else c[j+20>>2]=s;if(!s)break}h=c[24126]|0;if(s>>>0>>0)pa();c[s+24>>2]=j;i=c[q+16>>2]|0;do if(i)if(i>>>0>>0)pa();else{c[s+16>>2]=i;c[i+24>>2]=s;break}while(0);i=c[q+20>>2]|0;if(i)if(i>>>0<(c[24126]|0)>>>0)pa();else{c[s+20>>2]=i;c[i+24>>2]=s;break}}while(0);b:do if(n>>>0>=16){c[q+4>>2]=p|3;c[q+(p|4)>>2]=n|1;c[q+(n+p)>>2]=n;i=n>>>3;if(n>>>0<256){h=i<<1;f=96528+(h<<2)|0;g=c[24122]|0;i=1<>2]|0;if(h>>>0<(c[24126]|0)>>>0)pa();else{t=i;u=h}}else{c[24122]=g|i;t=96528+(h+2<<2)|0;u=f}c[t>>2]=m;c[u+12>>2]=m;c[q+(p+8)>>2]=u;c[q+(p+12)>>2]=f;break}d=n>>>8;if(d)if(n>>>0>16777215)f=31;else{v=(d+1048320|0)>>>16&8;w=d<>>16&4;w=w<>>16&2;f=14-(u|v|f)+(w<>>15)|0;f=n>>>(f+7|0)&1|f<<1}else f=0;i=96792+(f<<2)|0;c[q+(p+28)>>2]=f;c[q+(p+20)>>2]=0;c[q+(p+16)>>2]=0;h=c[24123]|0;g=1<>2]=m;c[q+(p+24)>>2]=i;c[q+(p+12)>>2]=m;c[q+(p+8)>>2]=m;break}d=c[i>>2]|0;c:do if((c[d+4>>2]&-8|0)!=(n|0)){h=n<<((f|0)==31?0:25-(f>>>1)|0);while(1){b=d+16+(h>>>31<<2)|0;i=c[b>>2]|0;if(!i)break;if((c[i+4>>2]&-8|0)==(n|0)){z=i;break c}else{h=h<<1;d=i}}if(b>>>0<(c[24126]|0)>>>0)pa();else{c[b>>2]=m;c[q+(p+24)>>2]=d;c[q+(p+12)>>2]=m;c[q+(p+8)>>2]=m;break b}}else z=d;while(0);d=z+8|0;b=c[d>>2]|0;w=c[24126]|0;if(b>>>0>=w>>>0&z>>>0>=w>>>0){c[b+12>>2]=m;c[d>>2]=m;c[q+(p+8)>>2]=b;c[q+(p+12)>>2]=z;c[q+(p+24)>>2]=0;break}else pa();}else{w=n+p|0;c[q+4>>2]=w|3;w=q+(w+4)|0;c[w>>2]=c[w>>2]|1}while(0);w=q+8|0;return w|0}else z=p}else z=p}else z=-1;while(0);a=c[24124]|0;if(a>>>0>=z>>>0){b=a-z|0;d=c[24127]|0;if(b>>>0>15){c[24127]=d+z;c[24124]=b;c[d+(z+4)>>2]=b|1;c[d+a>>2]=b;c[d+4>>2]=z|3}else{c[24124]=0;c[24127]=0;c[d+4>>2]=a|3;w=d+(a+4)|0;c[w>>2]=c[w>>2]|1}w=d+8|0;return w|0}a=c[24125]|0;if(a>>>0>z>>>0){v=a-z|0;c[24125]=v;w=c[24128]|0;c[24128]=w+z;c[w+(z+4)>>2]=v|1;c[w+4>>2]=z|3;w=w+8|0;return w|0}do if(!(c[24240]|0)){a=Ia(30)|0;if(!(a+-1&a)){c[24242]=a;c[24241]=a;c[24243]=-1;c[24244]=-1;c[24245]=0;c[24233]=0;c[24240]=(Wa(0)|0)&-16^1431655768;break}else pa();}while(0);l=z+48|0;d=c[24242]|0;b=z+47|0;e=d+b|0;d=0-d|0;m=e&d;if(m>>>0<=z>>>0){w=0;return w|0}a=c[24232]|0;if((a|0)!=0?(t=c[24230]|0,u=t+m|0,u>>>0<=t>>>0|u>>>0>a>>>0):0){w=0;return w|0}d:do if(!(c[24233]&4)){a=c[24128]|0;e:do if(a){h=96936;while(1){j=c[h>>2]|0;if(j>>>0<=a>>>0?(r=h+4|0,(j+(c[r>>2]|0)|0)>>>0>a>>>0):0){g=h;a=r;break}h=c[h+8>>2]|0;if(!h){w=174;break e}}j=e-(c[24125]|0)&d;if(j>>>0<2147483647){h=Ba(j|0)|0;u=(h|0)==((c[g>>2]|0)+(c[a>>2]|0)|0);a=u?j:0;if(u){if((h|0)!=(-1|0)){x=h;w=194;break d}}else w=184}else a=0}else w=174;while(0);do if((w|0)==174){g=Ba(0)|0;if((g|0)!=(-1|0)){a=g;j=c[24241]|0;h=j+-1|0;if(!(h&a))j=m;else j=m-a+(h+a&0-j)|0;a=c[24230]|0;h=a+j|0;if(j>>>0>z>>>0&j>>>0<2147483647){u=c[24232]|0;if((u|0)!=0?h>>>0<=a>>>0|h>>>0>u>>>0:0){a=0;break}h=Ba(j|0)|0;w=(h|0)==(g|0);a=w?j:0;if(w){x=g;w=194;break d}else w=184}else a=0}else a=0}while(0);f:do if((w|0)==184){g=0-j|0;do if(l>>>0>j>>>0&(j>>>0<2147483647&(h|0)!=(-1|0))?(v=c[24242]|0,v=b-j+v&0-v,v>>>0<2147483647):0)if((Ba(v|0)|0)==(-1|0)){Ba(g|0)|0;break f}else{j=v+j|0;break}while(0);if((h|0)!=(-1|0)){x=h;a=j;w=194;break d}}while(0);c[24233]=c[24233]|4;w=191}else{a=0;w=191}while(0);if((((w|0)==191?m>>>0<2147483647:0)?(x=Ba(m|0)|0,y=Ba(0)|0,x>>>0>>0&((x|0)!=(-1|0)&(y|0)!=(-1|0))):0)?(A=y-x|0,B=A>>>0>(z+40|0)>>>0,B):0){a=B?A:a;w=194}if((w|0)==194){j=(c[24230]|0)+a|0;c[24230]=j;if(j>>>0>(c[24231]|0)>>>0)c[24231]=j;n=c[24128]|0;g:do if(n){e=96936;do{j=c[e>>2]|0;h=e+4|0;g=c[h>>2]|0;if((x|0)==(j+g|0)){C=j;D=h;E=g;F=e;w=204;break}e=c[e+8>>2]|0}while((e|0)!=0);if(((w|0)==204?(c[F+12>>2]&8|0)==0:0)?n>>>0>>0&n>>>0>=C>>>0:0){c[D>>2]=E+a;w=(c[24125]|0)+a|0;v=n+8|0;v=(v&7|0)==0?0:0-v&7;u=w-v|0;c[24128]=n+v;c[24125]=u;c[n+(v+4)>>2]=u|1;c[n+(w+4)>>2]=40;c[24129]=c[24244];break}j=c[24126]|0;if(x>>>0>>0){c[24126]=x;j=x}h=x+a|0;e=96936;while(1){if((c[e>>2]|0)==(h|0)){g=e;h=e;w=212;break}e=c[e+8>>2]|0;if(!e){g=96936;break}}if((w|0)==212)if(!(c[h+12>>2]&8)){c[g>>2]=x;p=h+4|0;c[p>>2]=(c[p>>2]|0)+a;p=x+8|0;p=(p&7|0)==0?0:0-p&7;k=x+(a+8)|0;k=(k&7|0)==0?0:0-k&7;i=x+(k+a)|0;o=p+z|0;q=x+o|0;m=i-(x+p)-z|0;c[x+(p+4)>>2]=z|3;h:do if((i|0)!=(n|0)){if((i|0)==(c[24127]|0)){w=(c[24124]|0)+m|0;c[24124]=w;c[24127]=q;c[x+(o+4)>>2]=w|1;c[x+(w+o)>>2]=w;break}l=a+4|0;h=c[x+(l+k)>>2]|0;if((h&3|0)==1){b=h&-8;e=h>>>3;i:do if(h>>>0>=256){d=c[x+((k|24)+a)>>2]|0;g=c[x+(a+12+k)>>2]|0;do if((g|0)==(i|0)){f=k|16;g=x+(l+f)|0;h=c[g>>2]|0;if(!h){g=x+(f+a)|0;h=c[g>>2]|0;if(!h){K=0;break}}while(1){f=h+20|0;e=c[f>>2]|0;if(e){h=e;g=f;continue}f=h+16|0;e=c[f>>2]|0;if(!e)break;else{h=e;g=f}}if(g>>>0>>0)pa();else{c[g>>2]=0;K=h;break}}else{f=c[x+((k|8)+a)>>2]|0;if(f>>>0>>0)pa();j=f+12|0;if((c[j>>2]|0)!=(i|0))pa();h=g+8|0;if((c[h>>2]|0)==(i|0)){c[j>>2]=g;c[h>>2]=f;K=g;break}else pa();}while(0);if(!d)break;j=c[x+(a+28+k)>>2]|0;h=96792+(j<<2)|0;do if((i|0)!=(c[h>>2]|0)){if(d>>>0<(c[24126]|0)>>>0)pa();j=d+16|0;if((c[j>>2]|0)==(i|0))c[j>>2]=K;else c[d+20>>2]=K;if(!K)break i}else{c[h>>2]=K;if(K)break;c[24123]=c[24123]&~(1<>>0>>0)pa();c[K+24>>2]=d;j=k|16;i=c[x+(j+a)>>2]|0;do if(i)if(i>>>0>>0)pa();else{c[K+16>>2]=i;c[i+24>>2]=K;break}while(0);i=c[x+(l+j)>>2]|0;if(!i)break;if(i>>>0<(c[24126]|0)>>>0)pa();else{c[K+20>>2]=i;c[i+24>>2]=K;break}}else{g=c[x+((k|8)+a)>>2]|0;f=c[x+(a+12+k)>>2]|0;h=96528+(e<<1<<2)|0;do if((g|0)!=(h|0)){if(g>>>0>>0)pa();if((c[g+12>>2]|0)==(i|0))break;pa();}while(0);if((f|0)==(g|0)){c[24122]=c[24122]&~(1<>>0>>0)pa();j=f+8|0;if((c[j>>2]|0)==(i|0)){G=j;break}pa();}while(0);c[g+12>>2]=f;c[G>>2]=g}while(0);i=x+((b|k)+a)|0;j=b+m|0}else j=m;i=i+4|0;c[i>>2]=c[i>>2]&-2;c[x+(o+4)>>2]=j|1;c[x+(j+o)>>2]=j;i=j>>>3;if(j>>>0<256){h=i<<1;f=96528+(h<<2)|0;g=c[24122]|0;i=1<>2]|0;if(h>>>0>=(c[24126]|0)>>>0){L=i;M=h;break}pa();}while(0);c[L>>2]=q;c[M+12>>2]=q;c[x+(o+8)>>2]=M;c[x+(o+12)>>2]=f;break}d=j>>>8;do if(!d)f=0;else{if(j>>>0>16777215){f=31;break}v=(d+1048320|0)>>>16&8;w=d<>>16&4;w=w<>>16&2;f=14-(u|v|f)+(w<>>15)|0;f=j>>>(f+7|0)&1|f<<1}while(0);i=96792+(f<<2)|0;c[x+(o+28)>>2]=f;c[x+(o+20)>>2]=0;c[x+(o+16)>>2]=0;h=c[24123]|0;g=1<>2]=q;c[x+(o+24)>>2]=i;c[x+(o+12)>>2]=q;c[x+(o+8)>>2]=q;break}d=c[i>>2]|0;j:do if((c[d+4>>2]&-8|0)!=(j|0)){h=j<<((f|0)==31?0:25-(f>>>1)|0);while(1){b=d+16+(h>>>31<<2)|0;i=c[b>>2]|0;if(!i)break;if((c[i+4>>2]&-8|0)==(j|0)){N=i;break j}else{h=h<<1;d=i}}if(b>>>0<(c[24126]|0)>>>0)pa();else{c[b>>2]=q;c[x+(o+24)>>2]=d;c[x+(o+12)>>2]=q;c[x+(o+8)>>2]=q;break h}}else N=d;while(0);d=N+8|0;b=c[d>>2]|0;w=c[24126]|0;if(b>>>0>=w>>>0&N>>>0>=w>>>0){c[b+12>>2]=q;c[d>>2]=q;c[x+(o+8)>>2]=b;c[x+(o+12)>>2]=N;c[x+(o+24)>>2]=0;break}else pa();}else{w=(c[24125]|0)+m|0;c[24125]=w;c[24128]=q;c[x+(o+4)>>2]=w|1}while(0);w=x+(p|8)|0;return w|0}else g=96936;while(1){h=c[g>>2]|0;if(h>>>0<=n>>>0?(i=c[g+4>>2]|0,f=h+i|0,f>>>0>n>>>0):0)break;g=c[g+8>>2]|0}j=h+(i+-39)|0;h=h+(i+-47+((j&7|0)==0?0:0-j&7))|0;j=n+16|0;h=h>>>0>>0?n:h;i=h+8|0;g=x+8|0;g=(g&7|0)==0?0:0-g&7;w=a+-40-g|0;c[24128]=x+g;c[24125]=w;c[x+(g+4)>>2]=w|1;c[x+(a+-36)>>2]=40;c[24129]=c[24244];g=h+4|0;c[g>>2]=27;c[i>>2]=c[24234];c[i+4>>2]=c[24235];c[i+8>>2]=c[24236];c[i+12>>2]=c[24237];c[24234]=x;c[24235]=a;c[24237]=0;c[24236]=i;i=h+28|0;c[i>>2]=7;if((h+32|0)>>>0>>0)do{w=i;i=i+4|0;c[i>>2]=7}while((w+8|0)>>>0>>0);if((h|0)!=(n|0)){f=h-n|0;c[g>>2]=c[g>>2]&-2;c[n+4>>2]=f|1;c[h>>2]=f;i=f>>>3;if(f>>>0<256){h=i<<1;f=96528+(h<<2)|0;g=c[24122]|0;i=1<>2]|0;if(b>>>0<(c[24126]|0)>>>0)pa();else{H=d;I=b}}else{c[24122]=g|i;H=96528+(h+2<<2)|0;I=f}c[H>>2]=n;c[I+12>>2]=n;c[n+8>>2]=I;c[n+12>>2]=f;break}d=f>>>8;if(d)if(f>>>0>16777215)h=31;else{v=(d+1048320|0)>>>16&8;w=d<>>16&4;w=w<>>16&2;h=14-(u|v|h)+(w<>>15)|0;h=f>>>(h+7|0)&1|h<<1}else h=0;i=96792+(h<<2)|0;c[n+28>>2]=h;c[n+20>>2]=0;c[j>>2]=0;d=c[24123]|0;b=1<>2]=n;c[n+24>>2]=i;c[n+12>>2]=n;c[n+8>>2]=n;break}d=c[i>>2]|0;k:do if((c[d+4>>2]&-8|0)!=(f|0)){i=f<<((h|0)==31?0:25-(h>>>1)|0);while(1){b=d+16+(i>>>31<<2)|0;e=c[b>>2]|0;if(!e)break;if((c[e+4>>2]&-8|0)==(f|0)){J=e;break k}else{i=i<<1;d=e}}if(b>>>0<(c[24126]|0)>>>0)pa();else{c[b>>2]=n;c[n+24>>2]=d;c[n+12>>2]=n;c[n+8>>2]=n;break g}}else J=d;while(0);d=J+8|0;b=c[d>>2]|0;w=c[24126]|0;if(b>>>0>=w>>>0&J>>>0>=w>>>0){c[b+12>>2]=n;c[d>>2]=n;c[n+8>>2]=b;c[n+12>>2]=J;c[n+24>>2]=0;break}else pa();}}else{w=c[24126]|0;if((w|0)==0|x>>>0>>0)c[24126]=x;c[24234]=x;c[24235]=a;c[24237]=0;c[24131]=c[24240];c[24130]=-1;d=0;do{w=d<<1;v=96528+(w<<2)|0;c[96528+(w+3<<2)>>2]=v;c[96528+(w+2<<2)>>2]=v;d=d+1|0}while((d|0)!=32);w=x+8|0;w=(w&7|0)==0?0:0-w&7;v=a+-40-w|0;c[24128]=x+w;c[24125]=v;c[x+(w+4)>>2]=v|1;c[x+(a+-36)>>2]=40;c[24129]=c[24244]}while(0);b=c[24125]|0;if(b>>>0>z>>>0){v=b-z|0;c[24125]=v;w=c[24128]|0;c[24128]=w+z;c[w+(z+4)>>2]=v|1;c[w+4>>2]=z|3;w=w+8|0;return w|0}}c[(Ra()|0)>>2]=12;w=0;return w|0}function re(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;if(!a)return;g=a+-8|0;h=c[24126]|0;if(g>>>0>>0)pa();f=c[a+-4>>2]|0;e=f&3;if((e|0)==1)pa();o=f&-8;q=a+(o+-8)|0;do if(!(f&1)){g=c[g>>2]|0;if(!e)return;i=-8-g|0;l=a+i|0;m=g+o|0;if(l>>>0>>0)pa();if((l|0)==(c[24127]|0)){g=a+(o+-4)|0;f=c[g>>2]|0;if((f&3|0)!=3){u=l;k=m;break}c[24124]=m;c[g>>2]=f&-2;c[a+(i+4)>>2]=m|1;c[q>>2]=m;return}d=g>>>3;if(g>>>0<256){e=c[a+(i+8)>>2]|0;f=c[a+(i+12)>>2]|0;g=96528+(d<<1<<2)|0;if((e|0)!=(g|0)){if(e>>>0>>0)pa();if((c[e+12>>2]|0)!=(l|0))pa();}if((f|0)==(e|0)){c[24122]=c[24122]&~(1<>>0>>0)pa();g=f+8|0;if((c[g>>2]|0)==(l|0))b=g;else pa();}else b=f+8|0;c[e+12>>2]=f;c[b>>2]=e;u=l;k=m;break}b=c[a+(i+24)>>2]|0;e=c[a+(i+12)>>2]|0;do if((e|0)==(l|0)){f=a+(i+20)|0;g=c[f>>2]|0;if(!g){f=a+(i+16)|0;g=c[f>>2]|0;if(!g){j=0;break}}while(1){e=g+20|0;d=c[e>>2]|0;if(d){g=d;f=e;continue}e=g+16|0;d=c[e>>2]|0;if(!d)break;else{g=d;f=e}}if(f>>>0>>0)pa();else{c[f>>2]=0;j=g;break}}else{d=c[a+(i+8)>>2]|0;if(d>>>0>>0)pa();g=d+12|0;if((c[g>>2]|0)!=(l|0))pa();f=e+8|0;if((c[f>>2]|0)==(l|0)){c[g>>2]=e;c[f>>2]=d;j=e;break}else pa();}while(0);if(b){g=c[a+(i+28)>>2]|0;f=96792+(g<<2)|0;if((l|0)==(c[f>>2]|0)){c[f>>2]=j;if(!j){c[24123]=c[24123]&~(1<>>0<(c[24126]|0)>>>0)pa();g=b+16|0;if((c[g>>2]|0)==(l|0))c[g>>2]=j;else c[b+20>>2]=j;if(!j){u=l;k=m;break}}f=c[24126]|0;if(j>>>0>>0)pa();c[j+24>>2]=b;g=c[a+(i+16)>>2]|0;do if(g)if(g>>>0>>0)pa();else{c[j+16>>2]=g;c[g+24>>2]=j;break}while(0);g=c[a+(i+20)>>2]|0;if(g)if(g>>>0<(c[24126]|0)>>>0)pa();else{c[j+20>>2]=g;c[g+24>>2]=j;u=l;k=m;break}else{u=l;k=m}}else{u=l;k=m}}else{u=g;k=o}while(0);if(u>>>0>=q>>>0)pa();g=a+(o+-4)|0;f=c[g>>2]|0;if(!(f&1))pa();if(!(f&2)){if((q|0)==(c[24128]|0)){l=(c[24125]|0)+k|0;c[24125]=l;c[24128]=u;c[u+4>>2]=l|1;if((u|0)!=(c[24127]|0))return;c[24127]=0;c[24124]=0;return}if((q|0)==(c[24127]|0)){l=(c[24124]|0)+k|0;c[24124]=l;c[24127]=u;c[u+4>>2]=l|1;c[u+l>>2]=l;return}h=(f&-8)+k|0;b=f>>>3;do if(f>>>0>=256){b=c[a+(o+16)>>2]|0;g=c[a+(o|4)>>2]|0;do if((g|0)==(q|0)){f=a+(o+12)|0;g=c[f>>2]|0;if(!g){f=a+(o+8)|0;g=c[f>>2]|0;if(!g){p=0;break}}while(1){e=g+20|0;d=c[e>>2]|0;if(d){g=d;f=e;continue}e=g+16|0;d=c[e>>2]|0;if(!d)break;else{g=d;f=e}}if(f>>>0<(c[24126]|0)>>>0)pa();else{c[f>>2]=0;p=g;break}}else{f=c[a+o>>2]|0;if(f>>>0<(c[24126]|0)>>>0)pa();e=f+12|0;if((c[e>>2]|0)!=(q|0))pa();d=g+8|0;if((c[d>>2]|0)==(q|0)){c[e>>2]=g;c[d>>2]=f;p=g;break}else pa();}while(0);if(b){g=c[a+(o+20)>>2]|0;f=96792+(g<<2)|0;if((q|0)==(c[f>>2]|0)){c[f>>2]=p;if(!p){c[24123]=c[24123]&~(1<>>0<(c[24126]|0)>>>0)pa();g=b+16|0;if((c[g>>2]|0)==(q|0))c[g>>2]=p;else c[b+20>>2]=p;if(!p)break}g=c[24126]|0;if(p>>>0>>0)pa();c[p+24>>2]=b;f=c[a+(o+8)>>2]|0;do if(f)if(f>>>0>>0)pa();else{c[p+16>>2]=f;c[f+24>>2]=p;break}while(0);d=c[a+(o+12)>>2]|0;if(d)if(d>>>0<(c[24126]|0)>>>0)pa();else{c[p+20>>2]=d;c[d+24>>2]=p;break}}}else{d=c[a+o>>2]|0;e=c[a+(o|4)>>2]|0;g=96528+(b<<1<<2)|0;if((d|0)!=(g|0)){if(d>>>0<(c[24126]|0)>>>0)pa();if((c[d+12>>2]|0)!=(q|0))pa();}if((e|0)==(d|0)){c[24122]=c[24122]&~(1<>>0<(c[24126]|0)>>>0)pa();f=e+8|0;if((c[f>>2]|0)==(q|0))n=f;else pa();}else n=e+8|0;c[d+12>>2]=e;c[n>>2]=d}while(0);c[u+4>>2]=h|1;c[u+h>>2]=h;if((u|0)==(c[24127]|0)){c[24124]=h;return}else g=h}else{c[g>>2]=f&-2;c[u+4>>2]=k|1;c[u+k>>2]=k;g=k}f=g>>>3;if(g>>>0<256){e=f<<1;g=96528+(e<<2)|0;b=c[24122]|0;d=1<>2]|0;if(b>>>0<(c[24126]|0)>>>0)pa();else{r=d;s=b}}else{c[24122]=b|d;r=96528+(e+2<<2)|0;s=g}c[r>>2]=u;c[s+12>>2]=u;c[u+8>>2]=s;c[u+12>>2]=g;return}b=g>>>8;if(b)if(g>>>0>16777215)f=31;else{k=(b+1048320|0)>>>16&8;l=b<>>16&4;l=l<>>16&2;f=14-(j|k|f)+(l<>>15)|0;f=g>>>(f+7|0)&1|f<<1}else f=0;d=96792+(f<<2)|0;c[u+28>>2]=f;c[u+20>>2]=0;c[u+16>>2]=0;b=c[24123]|0;e=1<>2]|0;b:do if((c[d+4>>2]&-8|0)!=(g|0)){f=g<<((f|0)==31?0:25-(f>>>1)|0);while(1){b=d+16+(f>>>31<<2)|0;e=c[b>>2]|0;if(!e)break;if((c[e+4>>2]&-8|0)==(g|0)){t=e;break b}else{f=f<<1;d=e}}if(b>>>0<(c[24126]|0)>>>0)pa();else{c[b>>2]=u;c[u+24>>2]=d;c[u+12>>2]=u;c[u+8>>2]=u;break a}}else t=d;while(0);b=t+8|0;d=c[b>>2]|0;l=c[24126]|0;if(d>>>0>=l>>>0&t>>>0>=l>>>0){c[d+12>>2]=u;c[b>>2]=u;c[u+8>>2]=d;c[u+12>>2]=t;c[u+24>>2]=0;break}else pa();}else{c[24123]=b|e;c[d>>2]=u;c[u+24>>2]=d;c[u+12>>2]=u;c[u+8>>2]=u}while(0);l=(c[24130]|0)+-1|0;c[24130]=l;if(!l)b=96944;else return;while(1){b=c[b>>2]|0;if(!b)break;else b=b+8|0}c[24130]=-1;return}function se(a,b){a=a|0;b=b|0;var d=0;if(a){d=$(b,a)|0;if((b|a)>>>0>65535)d=((d>>>0)/(a>>>0)|0|0)==(b|0)?d:-1}else d=0;b=qe(d)|0;if(!b)return b|0;if(!(c[b+-4>>2]&3))return b|0;ve(b|0,0,d|0)|0;return b|0}function te(){}function ue(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;b=b-d-(c>>>0>a>>>0|0)>>>0;return (D=b,a-c>>>0|0)|0}function ve(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=b+e|0;if((e|0)>=20){d=d&255;h=b&3;i=d|d<<8|d<<16|d<<24;g=f&~3;if(h){h=b+4-h|0;while((b|0)<(h|0)){a[b>>0]=d;b=b+1|0}}while((b|0)<(g|0)){c[b>>2]=i;b=b+4|0}}while((b|0)<(f|0)){a[b>>0]=d;b=b+1|0}return b-e|0}function we(b){b=b|0;var c=0;c=b;while(a[c>>0]|0)c=c+1|0;return c-b|0}function xe(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;c=a+c>>>0;return (D=b+d+(c>>>0>>0|0)>>>0,c|0)|0}function ye(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b>>>c;return a>>>c|(b&(1<>>c-32|0}function ze(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if((e|0)>=4096)return Fa(b|0,d|0,e|0)|0;f=b|0;if((b&3)==(d&3)){while(b&3){if(!e)return f|0;a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}while((e|0)>=4){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0;e=e-4|0}}while((e|0)>0){a[b>>0]=a[d>>0]|0;b=b+1|0;d=d+1|0;e=e-1|0}return f|0}function Ae(a,b,c){a=a|0;b=b|0;c=c|0;if((c|0)<32){D=b<>>32-c;return a<>c;return a>>>c|(b&(1<>c-32|0}function Ce(b){b=b|0;var c=0;c=a[m+(b&255)>>0]|0;if((c|0)<8)return c|0;c=a[m+(b>>8&255)>>0]|0;if((c|0)<8)return c+8|0;c=a[m+(b>>16&255)>>0]|0;if((c|0)<8)return c+16|0;return (a[m+(b>>>24)>>0]|0)+24|0}function De(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0;f=a&65535;d=b&65535;c=$(d,f)|0;e=a>>>16;d=(c>>>16)+($(d,e)|0)|0;b=b>>>16;a=$(b,f)|0;return (D=(d>>>16)+($(b,e)|0)+(((d&65535)+a|0)>>>16)|0,d+a<<16|c&65535|0)|0}function Ee(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;j=b>>31|((b|0)<0?-1:0)<<1;i=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;f=d>>31|((d|0)<0?-1:0)<<1;e=((d|0)<0?-1:0)>>31|((d|0)<0?-1:0)<<1;h=ue(j^a,i^b,j,i)|0;g=D;b=f^j;a=e^i;return ue((Je(h,g,ue(f^c,e^d,f,e)|0,D,0)|0)^b,D^a,b,a)|0}function Fe(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0;f=i;i=i+8|0;j=f|0;h=b>>31|((b|0)<0?-1:0)<<1;g=((b|0)<0?-1:0)>>31|((b|0)<0?-1:0)<<1;l=e>>31|((e|0)<0?-1:0)<<1;k=((e|0)<0?-1:0)>>31|((e|0)<0?-1:0)<<1;b=ue(h^a,g^b,h,g)|0;a=D;Je(b,a,ue(l^d,k^e,l,k)|0,D,j)|0;a=ue(c[j>>2]^h,c[j+4>>2]^g,h,g)|0;b=D;i=f;return (D=b,a)|0}function Ge(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=a;f=c;a=De(e,f)|0;c=D;return (D=($(b,f)|0)+($(d,e)|0)+c|c&0,a|0|0)|0}function He(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return Je(a,b,c,d,0)|0}function Ie(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;g=i;i=i+8|0;f=g|0;Je(a,b,d,e,f)|0;i=g;return (D=c[f+4>>2]|0,c[f>>2]|0)|0}function Je(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;n=a;l=b;m=l;k=d;o=e;i=o;if(!m){g=(f|0)!=0;if(!i){if(g){c[f>>2]=(n>>>0)%(k>>>0);c[f+4>>2]=0}l=0;m=(n>>>0)/(k>>>0)>>>0;return (D=l,m)|0}else{if(!g){l=0;m=0;return (D=l,m)|0}c[f>>2]=a|0;c[f+4>>2]=b&0;l=0;m=0;return (D=l,m)|0}}j=(i|0)==0;do if(k){if(!j){h=(ba(i|0)|0)-(ba(m|0)|0)|0;if(h>>>0<=31){g=h+1|0;l=31-h|0;k=h-31>>31;i=g;j=n>>>(g>>>0)&k|m<>>(g>>>0)&k;g=0;h=n<>2]=a|0;c[f+4>>2]=l|b&0;l=0;m=0;return (D=l,m)|0}j=k-1|0;if(j&k){h=(ba(k|0)|0)+33-(ba(m|0)|0)|0;p=64-h|0;l=32-h|0;a=l>>31;b=h-32|0;k=b>>31;i=h;j=l-1>>31&m>>>(b>>>0)|(m<>>(h>>>0))&k;k=k&m>>>(h>>>0);g=n<>>(b>>>0))&a|n<>31;break}if(f){c[f>>2]=j&n;c[f+4>>2]=0}if((k|0)==1){l=l|b&0;m=a|0|0;return (D=l,m)|0}else{a=Ce(k|0)|0;l=m>>>(a>>>0)|0;m=m<<32-a|n>>>(a>>>0)|0;return (D=l,m)|0}}else{if(j){if(f){c[f>>2]=(m>>>0)%(k>>>0);c[f+4>>2]=0}l=0;m=(m>>>0)/(k>>>0)>>>0;return (D=l,m)|0}if(!n){if(f){c[f>>2]=0;c[f+4>>2]=(m>>>0)%(i>>>0);}l=0;m=(m>>>0)/(i>>>0)>>>0;return (D=l,m)|0}j=i-1|0;if(!(j&i)){if(f){c[f>>2]=a|0;c[f+4>>2]=j&m|b&0}l=0;m=m>>>((Ce(i|0)|0)>>>0);return (D=l,m)|0}h=(ba(i|0)|0)-(ba(m|0)|0)|0;if(h>>>0<=30){k=h+1|0;h=31-h|0;i=k;j=m<>>(k>>>0);k=m>>>(k>>>0);g=0;h=n<>2]=a|0;c[f+4>>2]=l|b&0;l=0;m=0;return (D=l,m)|0}while(0);if(!i){l=h;i=0;h=0}else{m=d|0|0;l=o|e&0;b=xe(m|0,l|0,-1,-1)|0;a=D;d=h;h=0;do{p=d;d=g>>>31|d<<1;g=h|g<<1;p=j<<1|p>>>31|0;o=j>>>31|k<<1|0;ue(b,a,p,o)|0;n=D;e=n>>31|((n|0)<0?-1:0)<<1;h=e&1;j=ue(p,o,e&m,(((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1)&l)|0;k=D;i=i-1|0}while((i|0)!=0);l=d;i=0}d=0;if(f){c[f>>2]=j;c[f+4>>2]=k}l=(g|0)>>>31|(l|d)<<1|(d<<1|g>>>31)&0|i;m=(g<<1|0>>>31)&-2|h;return (D=l,m)|0}function Ke(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return fb[a&3](b|0,c|0,d|0)|0}function Le(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return gb[a&7](b|0,c|0,d|0,e|0)|0}function Me(a,b,c){a=a|0;b=b|0;c=c|0;hb[a&3](b|0,c|0);}function Ne(a,b,c){a=a|0;b=b|0;c=c|0;return ib[a&1](b|0,c|0)|0}function Oe(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;jb[a&7](b|0,c|0,d|0,e|0);}function Pe(a,b,c){a=a|0;b=b|0;c=c|0;ca(0);return 0}function Qe(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(1);return 0}function Re(a,b){a=a|0;b=b|0;ca(2);}function Se(a,b){a=a|0;b=b|0;ca(3);return 0}function Te(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ca(4);}function Ue(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;Ta(a|0,b|0,c|0,d|0);} - -// EMSCRIPTEN_END_FUNCS -var fb=[Pe,pe,xd,Pe];var gb=[Qe,yd,zd,Ad,Bd,Qe,Qe,Qe];var hb=[Re,Mb,Nd,Re];var ib=[Se,uc];var jb=[Te,nc,mc,pc,oc,Ue,qc,Te];return{_i64Subtract:ue,_lame_set_brate:Lc,_lame_encode_buffer_ieee_float:Vb,_lame_close:Xb,_lame_set_in_samplerate:Gc,_i64Add:xe,_lame_set_num_channels:Hc,_strlen:we,_memset:ve,_malloc:qe,_memcpy:ze,_lame_init:Yb,_bitshift64Lshr:ye,_free:re,_lame_init_params:Ub,_lame_encode_flush:Wb,_bitshift64Shl:Ae,_lame_set_mode:Kc,runPostSets:te,stackAlloc:kb,stackSave:lb,stackRestore:mb,establishStackSpace:nb,setThrew:ob,setTempRet0:rb,getTempRet0:sb,dynCall_iiii:Ke,dynCall_iiiii:Le,dynCall_vii:Me,dynCall_iii:Ne,dynCall_viiii:Oe}}) - - -// EMSCRIPTEN_END_ASM -(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _lame_set_brate=Module["_lame_set_brate"]=asm["_lame_set_brate"];var _lame_encode_buffer_ieee_float=Module["_lame_encode_buffer_ieee_float"]=asm["_lame_encode_buffer_ieee_float"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var _lame_close=Module["_lame_close"]=asm["_lame_close"];var _lame_set_in_samplerate=Module["_lame_set_in_samplerate"]=asm["_lame_set_in_samplerate"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _lame_set_num_channels=Module["_lame_set_num_channels"]=asm["_lame_set_num_channels"];var _strlen=Module["_strlen"]=asm["_strlen"];var _memset=Module["_memset"]=asm["_memset"];var _malloc=Module["_malloc"]=asm["_malloc"];var _lame_set_mode=Module["_lame_set_mode"]=asm["_lame_set_mode"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _lame_init=Module["_lame_init"]=asm["_lame_init"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _free=Module["_free"]=asm["_free"];var _lame_init_params=Module["_lame_init_params"]=asm["_lame_init_params"];var _lame_encode_flush=Module["_lame_encode_flush"]=asm["_lame_encode_flush"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];var dynCall_iiiii=Module["dynCall_iiiii"]=asm["dynCall_iiiii"];var dynCall_vii=Module["dynCall_vii"]=asm["dynCall_vii"];var dynCall_iii=Module["dynCall_iii"]=asm["dynCall_iii"];var dynCall_viiii=Module["dynCall_viiii"]=asm["dynCall_viiii"];Runtime.stackAlloc=asm["stackAlloc"];Runtime.stackSave=asm["stackSave"];Runtime.stackRestore=asm["stackRestore"];Runtime.establishStackSpace=asm["establishStackSpace"];Runtime.setTempRet0=asm["setTempRet0"];Runtime.getTempRet0=asm["getTempRet0"];var i64Math=(function(){var goog={math:{}};goog.math.Long=(function(low,high){this.low_=low|0;this.high_=high|0});goog.math.Long.IntCache_={};goog.math.Long.fromInt=(function(value){if(-128<=value&&value<128){var cachedObj=goog.math.Long.IntCache_[value];if(cachedObj){return cachedObj}}var obj=new goog.math.Long(value|0,value<0?-1:0);if(-128<=value&&value<128){goog.math.Long.IntCache_[value]=obj}return obj});goog.math.Long.fromNumber=(function(value){if(isNaN(value)||!isFinite(value)){return goog.math.Long.ZERO}else if(value<=-goog.math.Long.TWO_PWR_63_DBL_){return goog.math.Long.MIN_VALUE}else if(value+1>=goog.math.Long.TWO_PWR_63_DBL_){return goog.math.Long.MAX_VALUE}else if(value<0){return goog.math.Long.fromNumber(-value).negate()}else{return new goog.math.Long(value%goog.math.Long.TWO_PWR_32_DBL_|0,value/goog.math.Long.TWO_PWR_32_DBL_|0)}});goog.math.Long.fromBits=(function(lowBits,highBits){return new goog.math.Long(lowBits,highBits)});goog.math.Long.fromString=(function(str,opt_radix){if(str.length==0){throw Error("number format error: empty string")}var radix=opt_radix||10;if(radix<2||36=0){throw Error('number format error: interior "-" character: '+str)}var radixToPower=goog.math.Long.fromNumber(Math.pow(radix,8));var result=goog.math.Long.ZERO;for(var i=0;i=0?this.low_:goog.math.Long.TWO_PWR_32_DBL_+this.low_});goog.math.Long.prototype.getNumBitsAbs=(function(){if(this.isNegative()){if(this.equals(goog.math.Long.MIN_VALUE)){return 64}else{return this.negate().getNumBitsAbs()}}else{var val=this.high_!=0?this.high_:this.low_;for(var bit=31;bit>0;bit--){if((val&1<0});goog.math.Long.prototype.greaterThanOrEqual=(function(other){return this.compare(other)>=0});goog.math.Long.prototype.compare=(function(other){if(this.equals(other)){return 0}var thisNeg=this.isNegative();var otherNeg=other.isNegative();if(thisNeg&&!otherNeg){return-1}if(!thisNeg&&otherNeg){return 1}if(this.subtract(other).isNegative()){return-1}else{return 1}});goog.math.Long.prototype.negate=(function(){if(this.equals(goog.math.Long.MIN_VALUE)){return goog.math.Long.MIN_VALUE}else{return this.not().add(goog.math.Long.ONE)}});goog.math.Long.prototype.add=(function(other){var a48=this.high_>>>16;var a32=this.high_&65535;var a16=this.low_>>>16;var a00=this.low_&65535;var b48=other.high_>>>16;var b32=other.high_&65535;var b16=other.low_>>>16;var b00=other.low_&65535;var c48=0,c32=0,c16=0,c00=0;c00+=a00+b00;c16+=c00>>>16;c00&=65535;c16+=a16+b16;c32+=c16>>>16;c16&=65535;c32+=a32+b32;c48+=c32>>>16;c32&=65535;c48+=a48+b48;c48&=65535;return goog.math.Long.fromBits(c16<<16|c00,c48<<16|c32)});goog.math.Long.prototype.subtract=(function(other){return this.add(other.negate())});goog.math.Long.prototype.multiply=(function(other){if(this.isZero()){return goog.math.Long.ZERO}else if(other.isZero()){return goog.math.Long.ZERO}if(this.equals(goog.math.Long.MIN_VALUE)){return other.isOdd()?goog.math.Long.MIN_VALUE:goog.math.Long.ZERO}else if(other.equals(goog.math.Long.MIN_VALUE)){return this.isOdd()?goog.math.Long.MIN_VALUE:goog.math.Long.ZERO}if(this.isNegative()){if(other.isNegative()){return this.negate().multiply(other.negate())}else{return this.negate().multiply(other).negate()}}else if(other.isNegative()){return this.multiply(other.negate()).negate()}if(this.lessThan(goog.math.Long.TWO_PWR_24_)&&other.lessThan(goog.math.Long.TWO_PWR_24_)){return goog.math.Long.fromNumber(this.toNumber()*other.toNumber())}var a48=this.high_>>>16;var a32=this.high_&65535;var a16=this.low_>>>16;var a00=this.low_&65535;var b48=other.high_>>>16;var b32=other.high_&65535;var b16=other.low_>>>16;var b00=other.low_&65535;var c48=0,c32=0,c16=0,c00=0;c00+=a00*b00;c16+=c00>>>16;c00&=65535;c16+=a16*b00;c32+=c16>>>16;c16&=65535;c16+=a00*b16;c32+=c16>>>16;c16&=65535;c32+=a32*b00;c48+=c32>>>16;c32&=65535;c32+=a16*b16;c48+=c32>>>16;c32&=65535;c32+=a00*b32;c48+=c32>>>16;c32&=65535;c48+=a48*b00+a32*b16+a16*b32+a00*b48;c48&=65535;return goog.math.Long.fromBits(c16<<16|c00,c48<<16|c32)});goog.math.Long.prototype.div=(function(other){if(other.isZero()){throw Error("division by zero")}else if(this.isZero()){return goog.math.Long.ZERO}if(this.equals(goog.math.Long.MIN_VALUE)){if(other.equals(goog.math.Long.ONE)||other.equals(goog.math.Long.NEG_ONE)){return goog.math.Long.MIN_VALUE}else if(other.equals(goog.math.Long.MIN_VALUE)){return goog.math.Long.ONE}else{var halfThis=this.shiftRight(1);var approx=halfThis.div(other).shiftLeft(1);if(approx.equals(goog.math.Long.ZERO)){return other.isNegative()?goog.math.Long.ONE:goog.math.Long.NEG_ONE}else{var rem=this.subtract(other.multiply(approx));var result=approx.add(rem.div(other));return result}}}else if(other.equals(goog.math.Long.MIN_VALUE)){return goog.math.Long.ZERO}if(this.isNegative()){if(other.isNegative()){return this.negate().div(other.negate())}else{return this.negate().div(other).negate()}}else if(other.isNegative()){return this.div(other.negate()).negate()}var res=goog.math.Long.ZERO;var rem=this;while(rem.greaterThanOrEqual(other)){var approx=Math.max(1,Math.floor(rem.toNumber()/other.toNumber()));var log2=Math.ceil(Math.log(approx)/Math.LN2);var delta=log2<=48?1:Math.pow(2,log2-48);var approxRes=goog.math.Long.fromNumber(approx);var approxRem=approxRes.multiply(other);while(approxRem.isNegative()||approxRem.greaterThan(rem)){approx-=delta;approxRes=goog.math.Long.fromNumber(approx);approxRem=approxRes.multiply(other)}if(approxRes.isZero()){approxRes=goog.math.Long.ONE}res=res.add(approxRes);rem=rem.subtract(approxRem)}return res});goog.math.Long.prototype.modulo=(function(other){return this.subtract(this.div(other).multiply(other))});goog.math.Long.prototype.not=(function(){return goog.math.Long.fromBits(~this.low_,~this.high_)});goog.math.Long.prototype.and=(function(other){return goog.math.Long.fromBits(this.low_&other.low_,this.high_&other.high_)});goog.math.Long.prototype.or=(function(other){return goog.math.Long.fromBits(this.low_|other.low_,this.high_|other.high_)});goog.math.Long.prototype.xor=(function(other){return goog.math.Long.fromBits(this.low_^other.low_,this.high_^other.high_)});goog.math.Long.prototype.shiftLeft=(function(numBits){numBits&=63;if(numBits==0){return this}else{var low=this.low_;if(numBits<32){var high=this.high_;return goog.math.Long.fromBits(low<>>32-numBits)}else{return goog.math.Long.fromBits(0,low<>>numBits|high<<32-numBits,high>>numBits)}else{return goog.math.Long.fromBits(high>>numBits-32,high>=0?0:-1)}}});goog.math.Long.prototype.shiftRightUnsigned=(function(numBits){numBits&=63;if(numBits==0){return this}else{var high=this.high_;if(numBits<32){var low=this.low_;return goog.math.Long.fromBits(low>>>numBits|high<<32-numBits,high>>>numBits)}else if(numBits==32){return goog.math.Long.fromBits(high,0)}else{return goog.math.Long.fromBits(high>>>numBits-32,0)}}});var navigator={appName:"Modern Browser"};var dbits;var canary=0xdeadbeefcafe;var j_lm=(canary&16777215)==15715070;function BigInteger(a,b,c){if(a!=null)if("number"==typeof a)this.fromNumber(a,b,c);else if(b==null&&"string"!=typeof a)this.fromString(a,256);else this.fromString(a,b)}function nbi(){return new BigInteger(null)}function am1(i,x,w,j,c,n){while(--n>=0){var v=x*this[i++]+w[j]+c;c=Math.floor(v/67108864);w[j++]=v&67108863}return c}function am2(i,x,w,j,c,n){var xl=x&32767,xh=x>>15;while(--n>=0){var l=this[i]&32767;var h=this[i++]>>15;var m=xh*l+h*xl;l=xl*l+((m&32767)<<15)+w[j]+(c&1073741823);c=(l>>>30)+(m>>>15)+xh*h+(c>>>30);w[j++]=l&1073741823}return c}function am3(i,x,w,j,c,n){var xl=x&16383,xh=x>>14;while(--n>=0){var l=this[i]&16383;var h=this[i++]>>14;var m=xh*l+h*xl;l=xl*l+((m&16383)<<14)+w[j]+c;c=(l>>28)+(m>>14)+xh*h;w[j++]=l&268435455}return c}if(j_lm&&navigator.appName=="Microsoft Internet Explorer"){BigInteger.prototype.am=am2;dbits=30}else if(j_lm&&navigator.appName!="Netscape"){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=(1<=0;--i)r[i]=this[i];r.t=this.t;r.s=this.s}function bnpFromInt(x){this.t=1;this.s=x<0?-1:0;if(x>0)this[0]=x;else if(x<-1)this[0]=x+DV;else this.t=0}function nbv(i){var r=nbi();r.fromInt(i);return r}function bnpFromString(s,b){var k;if(b==16)k=4;else if(b==8)k=3;else if(b==256)k=8;else if(b==2)k=1;else if(b==32)k=5;else if(b==4)k=2;else{this.fromRadix(s,b);return}this.t=0;this.s=0;var i=s.length,mi=false,sh=0;while(--i>=0){var x=k==8?s[i]&255:intAt(s,i);if(x<0){if(s.charAt(i)=="-")mi=true;continue}mi=false;if(sh==0)this[this.t++]=x;else if(sh+k>this.DB){this[this.t-1]|=(x&(1<>this.DB-sh}else this[this.t-1]|=x<=this.DB)sh-=this.DB}if(k==8&&(s[0]&128)!=0){this.s=-1;if(sh>0)this[this.t-1]|=(1<0&&this[this.t-1]==c)--this.t}function bnToString(b){if(this.s<0)return"-"+this.negate().toString(b);var k;if(b==16)k=4;else if(b==8)k=3;else if(b==2)k=1;else if(b==32)k=5;else if(b==4)k=2;else return this.toRadix(b);var km=(1<0){if(p>p)>0){m=true;r=int2char(d)}while(i>=0){if(p>(p+=this.DB-k)}else{d=this[i]>>(p-=k)&km;if(p<=0){p+=this.DB;--i}}if(d>0)m=true;if(m)r+=int2char(d)}}return m?r:"0"}function bnNegate(){var r=nbi();BigInteger.ZERO.subTo(this,r);return r}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(a){var r=this.s-a.s;if(r!=0)return r;var i=this.t;r=i-a.t;if(r!=0)return this.s<0?-r:r;while(--i>=0)if((r=this[i]-a[i])!=0)return r;return 0}function nbits(x){var r=1,t;if((t=x>>>16)!=0){x=t;r+=16}if((t=x>>8)!=0){x=t;r+=8}if((t=x>>4)!=0){x=t;r+=4}if((t=x>>2)!=0){x=t;r+=2}if((t=x>>1)!=0){x=t;r+=1}return r}function bnBitLength(){if(this.t<=0)return 0;return this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i)r[i+n]=this[i];for(i=n-1;i>=0;--i)r[i]=0;r.t=this.t+n;r.s=this.s}function bnpDRShiftTo(n,r){for(var i=n;i=0;--i){r[i+ds+1]=this[i]>>cbs|c;c=(this[i]&bm)<=0;--i)r[i]=0;r[ds]=c;r.t=this.t+ds+1;r.s=this.s;r.clamp()}function bnpRShiftTo(n,r){r.s=this.s;var ds=Math.floor(n/this.DB);if(ds>=this.t){r.t=0;return}var bs=n%this.DB;var cbs=this.DB-bs;var bm=(1<>bs;for(var i=ds+1;i>bs}if(bs>0)r[this.t-ds-1]|=(this.s&bm)<>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c-=a.s}r.s=c<0?-1:0;if(c<-1)r[i++]=this.DV+c;else if(c>0)r[i++]=c;r.t=i;r.clamp()}function bnpMultiplyTo(a,r){var x=this.abs(),y=a.abs();var i=x.t;r.t=i+y.t;while(--i>=0)r[i]=0;for(i=0;i=0)r[i]=0;for(i=0;i=x.DV){r[i+x.t]-=x.DV;r[i+x.t+1]=1}}if(r.t>0)r[r.t-1]+=x.am(i,x[i],r,2*i,0,1);r.s=0;r.clamp()}function bnpDivRemTo(m,q,r){var pm=m.abs();if(pm.t<=0)return;var pt=this.abs();if(pt.t0){pm.lShiftTo(nsh,y);pt.lShiftTo(nsh,r)}else{pm.copyTo(y);pt.copyTo(r)}var ys=y.t;var y0=y[ys-1];if(y0==0)return;var yt=y0*(1<1?y[ys-2]>>this.F2:0);var d1=this.FV/yt,d2=(1<=0){r[r.t++]=1;r.subTo(t,r)}BigInteger.ONE.dlShiftTo(ys,t);t.subTo(y,y);while(y.t=0){var qd=r[--i]==y0?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);if((r[i]+=y.am(0,qd,r,j,0,ys))0)r.rShiftTo(nsh,r);if(ts<0)BigInteger.ZERO.subTo(r,r)}function bnMod(a){var r=nbi();this.abs().divRemTo(a,null,r);if(this.s<0&&r.compareTo(BigInteger.ZERO)>0)a.subTo(r,r);return r}function Classic(m){this.m=m}function cConvert(x){if(x.s<0||x.compareTo(this.m)>=0)return x.mod(this.m);else return x}function cRevert(x){return x}function cReduce(x){x.divRemTo(this.m,null,x)}function cMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}function cSqrTo(x,r){x.squareTo(r);this.reduce(r)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1)return 0;var x=this[0];if((x&1)==0)return 0;var y=x&3;y=y*(2-(x&15)*y)&15;y=y*(2-(x&255)*y)&255;y=y*(2-((x&65535)*y&65535))&65535;y=y*(2-x*y%this.DV)%this.DV;return y>0?this.DV-y:-y}function Montgomery(m){this.m=m;this.mp=m.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<0)this.m.subTo(r,r);return r}function montRevert(x){var r=nbi();x.copyTo(r);this.reduce(r);return r}function montReduce(x){while(x.t<=this.mt2)x[x.t++]=0;for(var i=0;i>15)*this.mpl&this.um)<<15)&x.DM;j=i+this.m.t;x[j]+=this.m.am(0,u0,x,i,0,this.m.t);while(x[j]>=x.DV){x[j]-=x.DV;x[++j]++}}x.clamp();x.drShiftTo(this.m.t,x);if(x.compareTo(this.m)>=0)x.subTo(this.m,x)}function montSqrTo(x,r){x.squareTo(r);this.reduce(r)}function montMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return(this.t>0?this[0]&1:this.s)==0}function bnpExp(e,z){if(e>4294967295||e<1)return BigInteger.ONE;var r=nbi(),r2=nbi(),g=z.convert(this),i=nbits(e)-1;g.copyTo(r);while(--i>=0){z.sqrTo(r,r2);if((e&1<0)z.mulTo(r2,g,r);else{var t=r;r=r2;r2=t}}return z.revert(r)}function bnModPowInt(e,m){var z;if(e<256||m.isEven())z=new Classic(m);else z=new Montgomery(m);return this.exp(e,z)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function bnpFromRadix(s,b){this.fromInt(0);if(b==null)b=10;var cs=this.chunkSize(b);var d=Math.pow(b,cs),mi=false,j=0,w=0;for(var i=0;i=cs){this.dMultiply(d);this.dAddOffset(w,0);j=0;w=0}}if(j>0){this.dMultiply(Math.pow(b,j));this.dAddOffset(w,0)}if(mi)BigInteger.ZERO.subTo(this,this)}function bnpChunkSize(r){return Math.floor(Math.LN2*this.DB/Math.log(r))}function bnSigNum(){if(this.s<0)return-1;else if(this.t<=0||this.t==1&&this[0]<=0)return 0;else return 1}function bnpDMultiply(n){this[this.t]=this.am(0,n-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(n,w){if(n==0)return;while(this.t<=w)this[this.t++]=0;this[w]+=n;while(this[w]>=this.DV){this[w]-=this.DV;if(++w>=this.t)this[this.t++]=0;++this[w]}}function bnpToRadix(b){if(b==null)b=10;if(this.signum()==0||b<2||b>36)return"0";var cs=this.chunkSize(b);var a=Math.pow(b,cs);var d=nbv(a),y=nbi(),z=nbi(),r="";this.divRemTo(d,y,z);while(y.signum()>0){r=(a+z.intValue()).toString(b).substr(1)+r;y.divRemTo(d,y,z)}return z.intValue().toString(b)+r}function bnIntValue(){if(this.s<0){if(this.t==1)return this[0]-this.DV;else if(this.t==0)return-1}else if(this.t==1)return this[0];else if(this.t==0)return 0;return(this[1]&(1<<32-this.DB)-1)<>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c+=a.s}r.s=c<0?-1:0;if(c>0)r[i++]=c;else if(c<-1)r[i++]=this.DV+c;r.t=i;r.clamp()}BigInteger.prototype.fromRadix=bnpFromRadix;BigInteger.prototype.chunkSize=bnpChunkSize;BigInteger.prototype.signum=bnSigNum;BigInteger.prototype.dMultiply=bnpDMultiply;BigInteger.prototype.dAddOffset=bnpDAddOffset;BigInteger.prototype.toRadix=bnpToRadix;BigInteger.prototype.intValue=bnIntValue;BigInteger.prototype.addTo=bnpAddTo;var Wrapper={abs:(function(l,h){var x=new goog.math.Long(l,h);var ret;if(x.isNegative()){ret=x.negate()}else{ret=x}HEAP32[tempDoublePtr>>2]=ret.low_;HEAP32[tempDoublePtr+4>>2]=ret.high_}),ensureTemps:(function(){if(Wrapper.ensuredTemps)return;Wrapper.ensuredTemps=true;Wrapper.two32=new BigInteger;Wrapper.two32.fromString("4294967296",10);Wrapper.two64=new BigInteger;Wrapper.two64.fromString("18446744073709551616",10);Wrapper.temp1=new BigInteger;Wrapper.temp2=new BigInteger}),lh2bignum:(function(l,h){var a=new BigInteger;a.fromString(h.toString(),10);var b=new BigInteger;a.multiplyTo(Wrapper.two32,b);var c=new BigInteger;c.fromString(l.toString(),10);var d=new BigInteger;c.addTo(b,d);return d}),stringify:(function(l,h,unsigned){var ret=(new goog.math.Long(l,h)).toString();if(unsigned&&ret[0]=="-"){Wrapper.ensureTemps();var bignum=new BigInteger;bignum.fromString(ret,10);ret=new BigInteger;Wrapper.two64.addTo(bignum,ret);ret=ret.toString(10)}return ret}),fromString:(function(str,base,min,max,unsigned){Wrapper.ensureTemps();var bignum=new BigInteger;bignum.fromString(str,base);var bigmin=new BigInteger;bigmin.fromString(min,10);var bigmax=new BigInteger;bigmax.fromString(max,10);if(unsigned&&bignum.compareTo(BigInteger.ZERO)<0){var temp=new BigInteger;bignum.addTo(Wrapper.two64,temp);bignum=temp}var error=false;if(bignum.compareTo(bigmin)<0){bignum=bigmin;error=true}else if(bignum.compareTo(bigmax)>0){bignum=bigmax;error=true}var ret=goog.math.Long.fromString(bignum.toString());HEAP32[tempDoublePtr>>2]=ret.low_;HEAP32[tempDoublePtr+4>>2]=ret.high_;if(error)throw"range error"})};return Wrapper})();if(memoryInitializer){if(typeof Module["locateFile"]==="function"){memoryInitializer=Module["locateFile"](memoryInitializer)}else if(Module["memoryInitializerPrefixURL"]){memoryInitializer=Module["memoryInitializerPrefixURL"]+memoryInitializer}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,STATIC_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,STATIC_BASE);removeRunDependency("memory initializer")});var request=Module["memoryInitializerRequest"];if(request){if(request.response){setTimeout((function(){applyMemoryInitializer(request.response)}),0)}else{request.addEventListener("load",(function(){if(request.status!==200&&request.status!==0){console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status)}if(!request.response||typeof request.response!=="object"||!request.response.byteLength){console.warn("a problem seems to have happened with Module.memoryInitializerRequest response (expected ArrayBuffer): "+request.response)}applyMemoryInitializer(request.response)}))}}else{Browser.asyncLoad(memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}}}function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var preloadStartTime=null;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=Module.callMain=function callMain(args){assert(runDependencies==0,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");assert(__ATPRERUN__.length==0,"cannot call main when preRun functions remain to be called");args=args||[];ensureInitRuntime();var argc=args.length+1;function pad(){for(var i=0;i<4-1;i++){argv.push(0)}}var argv=[allocate(intArrayFromString(Module["thisProgram"]),"i8",ALLOC_NORMAL)];pad();for(var i=0;i0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(ENVIRONMENT_IS_WEB&&preloadStartTime!==null){Module.printErr("pre-main prep time: "+(Date.now()-preloadStartTime)+" ms")}if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout((function(){setTimeout((function(){Module["setStatus"]("")}),1);doRun()}),1)}else{doRun()}}Module["run"]=Module.run=run;function exit(status,implicit){if(implicit&&Module["noExitRuntime"]){return}if(Module["noExitRuntime"]){}else{ABORT=true;EXITSTATUS=status;STACKTOP=initialStackTop;exitRuntime();if(Module["onExit"])Module["onExit"](status)}if(ENVIRONMENT_IS_NODE){process["stdout"]["once"]("drain",(function(){process["exit"](status)}));console.log(" ");setTimeout((function(){process["exit"](status)}),500)}else if(ENVIRONMENT_IS_SHELL&&typeof quit==="function"){quit(status)}throw new ExitStatus(status)}Module["exit"]=Module.exit=exit;var abortDecorators=[];function abort(what){if(what!==undefined){Module.print(what);Module.printErr(what);what=JSON.stringify(what)}else{what=""}ABORT=true;EXITSTATUS=1;var extra="\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";var output="abort("+what+") at "+stackTrace()+extra;if(abortDecorators){abortDecorators.forEach((function(decorator){output=decorator(output,what)}))}throw output}Module["abort"]=Module.abort=abort;if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()()}}var shouldRunNow=true;if(Module["noInitialRun"]){shouldRunNow=false}run();var NUM_CH=2,HEAPU8=Module.HEAPU8,malloc=Module._malloc,free=Module._free,lame_init=Module._lame_init,lame_set_mode=Module._lame_set_mode,lame_set_num_channels=Module._lame_set_num_channels,lame_set_in_samplerate=Module._lame_set_in_samplerate,lame_set_brate=Module._lame_set_brate,lame_init_params=Module._lame_init_params,lame_encode_buffer_ieee_float=Module._lame_encode_buffer_ieee_float,lame_encode_flush=Module._lame_encode_flush,lame_close=Module._lame_close;var Encoder=(function(sampleRate,bitRate){this.gfp=lame_init();lame_set_mode(this.gfp,1);lame_set_num_channels(this.gfp,NUM_CH);lame_set_in_samplerate(this.gfp,sampleRate);lame_set_brate(this.gfp,bitRate);lame_init_params(this.gfp);this.allocBuffers(8192);this.mp3Buffers=[]});Encoder.prototype.encode=(function(buffers){var length=buffers[0].length;if(length>this.srcLen){this.freeBuffers();this.allocBuffers(length)}for(var ch=0;ch - - Audio Transcription Options - - - -

-
-

Sorry, capture on YouTube is disabled!

-

Chrome Web Store does not allow extensions to capture audio from YouTube due to copyright reasons.

-

Sorry for the inconvenience, please use the extension on other websites.

-
- - diff --git a/Audio-Transcription/icon.png b/Audio-Transcription/icon.png deleted file mode 100644 index 3dcf0e0..0000000 Binary files a/Audio-Transcription/icon.png and /dev/null differ diff --git a/Audio-Transcription/icon128.png b/Audio-Transcription/icon128.png new file mode 100644 index 0000000..3234deb Binary files /dev/null and b/Audio-Transcription/icon128.png differ diff --git a/Audio-Transcription/manifest.json b/Audio-Transcription/manifest.json index 021fa0c..da09ae0 100644 --- a/Audio-Transcription/manifest.json +++ b/Audio-Transcription/manifest.json @@ -1,53 +1,27 @@ -{ - "manifest_version": 2, + { + "manifest_version": 3, - "name": "Audio Transcription", - "description": "This extension captures the audio on the current tab and saves the output file on your computer when the capture is complete", - "version": "1.1.1", - "icons": { - "128":"collabora.png" + "name": "Audio Transcription", + "version": "1.0.0", + "description": "This extension captures the audio on the current tab, sends it to a server for transcription and shows the transcription in Real-time.", + "content_security_policy": { + "extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';" }, - - "browser_action": { - "default_icon": "collabora.png", - "default_popup": "popup.html", - "default_title": "Open Audio Transcription interface" - }, - "options_page": "options.html", - "background": { - "page" : "background.html", - "persistent": true - }, - "content_security_policy": "script-src 'self' https://cdn.jsdelivr.net 'wasm-eval'; object-src 'self'", - "permissions": [ - "tabCapture", - "downloads", - "storage", - "activeTab", - "tabs", - "*://*/*" - ], - "externally_connectable": { - "matches": [""] - }, - "content_scripts": [{ - "js": ["content.js"], - "matches": [""] - }], - "commands": { - "start": { - "suggested_key": { - "default": "Ctrl+Shift+S", - "mac": "Command+Shift+U" - }, - "description": "Start Capture" + "options_page": "options.html", + "background": { + "service_worker": "background.js" }, - "stop": { - "suggested_key": { - "default": "Ctrl+Shift+X", - "mac": "MacCtrl+Shift+X" - }, - "description": "Stop Capture" + "permissions": [ + "storage", + "activeTab", + "tabCapture", + "scripting" + ], + "icons": { + "128":"icon128.png" + }, + "action": { + "default_popup": "popup.html", + "default_icon": "icon128.png" } - } } diff --git a/Audio-Transcription/options.html b/Audio-Transcription/options.html index 34c0590..51ab923 100644 --- a/Audio-Transcription/options.html +++ b/Audio-Transcription/options.html @@ -1,33 +1,17 @@ - - + + + + + Audio Transcription Options + + + + + + + - - - -

Audio Transcription

-
-

Options

-
    -
  • -
  • min(s)
  • -
  • -
  • - - -
  • -
  • - - -
  • -
  • -
-
-
Save Settings
-
- - + + + \ No newline at end of file diff --git a/Audio-Transcription/options.js b/Audio-Transcription/options.js index 2f97f90..9827c59 100644 --- a/Audio-Transcription/options.js +++ b/Audio-Transcription/options.js @@ -1,100 +1,183 @@ -document.addEventListener('DOMContentLoaded', () => { - const mute = document.getElementById('mute'); - const maxTime = document.getElementById('maxTime'); - const save = document.getElementById('save'); - const status = document.getElementById('status'); - const mp3Select = document.getElementById('mp3'); - const wavSelect = document.getElementById('wav'); - const quality = document.getElementById("quality"); - const qualityLi = document.getElementById("qualityLi"); - const limitRemoved = document.getElementById("removeLimit"); - const doVad = document.getElementById("doVad"); - let currentFormat; - //initial settings - chrome.storage.sync.get({ - muteTab: false, - maxTime: 1200000, - format: "mp3", - quality: 192, - limitRemoved: false, - asr: false, - doVad: false - }, (options) => { - mute.checked = options.muteTab; - limitRemoved.checked = options.limitRemoved; - maxTime.disabled = options.limitRemoved; - maxTime.value = options.maxTime/60000; - currentFormat = options.format; - doVad.checked = options.doVad; - if (options.format === "mp3") { - mp3Select.checked = true; - qualityLi.style.display = "block"; - } else { - wavSelect.checked = true; - } - if (options.quality === "96") { - quality.selectedIndex = 0; - } else if(options.quality === "192") { - quality.selectedIndex = 1; - } else { - quality.selectedIndex = 2; - } +/** + * Captures audio from the active tab in Google Chrome. + * @returns {Promise} A promise that resolves with the captured audio stream. + */ +function captureTabAudio() { + return new Promise((resolve) => { + chrome.tabCapture.capture( + { + audio: true, + video: false, + }, + (stream) => { + resolve(stream); + } + ); }); +} - mute.onchange = () => { - status.innerHTML = ""; - } - doVad.onchange = () => { - status.innerHTML = ""; - } - - maxTime.onchange = () => { - status.innerHTML = ""; - if(maxTime.value > 20) { - maxTime.value = 20; - } else if (maxTime.value < 1) { - maxTime.value = 1; - } else if (isNaN(maxTime.value)) { - maxTime.value = 20; - } - } - - mp3Select.onclick = () => { - currentFormat = "mp3"; - qualityLi.style.display = "block"; - status.innerHTML = ""; - } - - wavSelect.onclick = () => { - currentFormat = "wav"; - qualityLi.style.display = "none"; - status.innerHTML = ""; - } - - quality.onchange = (e) => { - status.innerHTML = ""; - } - - limitRemoved.onchange = () => { - if(limitRemoved.checked) { - maxTime.disabled = true; - status.innerHTML = "WARNING: Recordings that are too long may not save properly!" - } else { - maxTime.disabled = false; - status.innerHTML = ""; - } - } - - save.onclick = () => { - chrome.storage.sync.set({ - muteTab: mute.checked, - maxTime: maxTime.value*60000, - format: currentFormat, - quality: quality.value, - limitRemoved: limitRemoved.checked, - doVad: doVad.checked +/** + * Sends a message to a specific tab in Google Chrome. + * @param {number} tabId - The ID of the tab to send the message to. + * @param {any} data - The data to be sent as the message. + * @returns {Promise} A promise that resolves with the response from the tab. + */ +function sendMessageToTab(tabId, data) { + return new Promise((resolve) => { + chrome.tabs.sendMessage(tabId, data, (response) => { + resolve(response); }); - status.innerHTML = "Settings saved!" + }); +} + + +/** + * Resamples the audio data to a target sample rate of 16kHz. + * @param {Array|ArrayBuffer|TypedArray} audioData - The input audio data. + * @param {number} [origSampleRate=44100] - The original sample rate of the audio data. + * @returns {Float32Array} The resampled audio data at 16kHz. + */ +function resampleTo16kHZ(audioData, origSampleRate = 44100) { + // Convert the audio data to a Float32Array + const data = new Float32Array(audioData); + + // Calculate the desired length of the resampled data + const targetLength = Math.round(data.length * (16000 / origSampleRate)); + + // Create a new Float32Array for the resampled data + const resampledData = new Float32Array(targetLength); + + // Calculate the spring factor and initialize the first and last values + const springFactor = (data.length - 1) / (targetLength - 1); + resampledData[0] = data[0]; + resampledData[targetLength - 1] = data[data.length - 1]; + + // Resample the audio data + for (let i = 1; i < targetLength - 1; i++) { + const index = i * springFactor; + const leftIndex = Math.floor(index).toFixed(); + const rightIndex = Math.ceil(index).toFixed(); + const fraction = index - leftIndex; + resampledData[i] = data[leftIndex] + (data[rightIndex] - data[leftIndex]) * fraction; } + + // Return the resampled data + return resampledData; +} + + +/** + * Starts recording audio from the captured tab. + * @param {Object} option - The options object containing the currentTabId. + */ +async function startRecord(option) { + const stream = await captureTabAudio(); + var doVad = true; + if (stream) { + // call when the stream inactive + stream.oninactive = () => { + window.close(); + }; + + // create onnx model + // initialize onnx model + const session = await ort.InferenceSession.create('./silero_vad.onnx'); + var h = new Array(128); + for (let i = 0; i < h.length; i++) { + h[i] = 0; + } + var c = new Array(128); + for (let i = 0; i < h.length; i++) { + c[i] = 0; + } + + const sr = new BigInt64Array(1) + sr[0] = BigInt(16000); + const srate = new ort.Tensor('int64', sr, [1]); + let speech_prob = undefined; + const vad_infer = async (feed_dict) => { + // feed inputs and run + try{ + const results = await session.run(feed_dict); + + // update states + h = results.hn.data + c = results.cn.data + speech_prob = results.output.data + } catch(e) { + console.log(e) + } + } + + const socket = new WebSocket("ws://localhost:9090/"); + socket.onopen = function(e) { + socket.send("handshake"); + }; + + socket.onmessage = async (event) => { + // console.log(event.data); + res = await sendMessageToTab(option.currentTabId, { + type: "transcript", + data: event.data, + }); + }; + + const audioDataCache = []; + const context = new AudioContext(); + const mediaStream = context.createMediaStreamSource(stream); + const recorder = context.createScriptProcessor(4096, 1, 1); + + recorder.onaudioprocess = async (event) => { + if (!context) return; + + const inputData = event.inputBuffer.getChannelData(0); + const audioData16kHz = resampleTo16kHZ(inputData, context.sampleRate); + + audioDataCache.push(inputData); + + // voice activity detection inference + const audioBuffer = new ort.Tensor('float32', audioData16kHz, [1, audioData16kHz.length]); + const hh = new ort.Tensor('float32', h, [2, 1, 64]); + const hc = new ort.Tensor('float32', c, [2, 1, 64]); + const feeds = { input: audioBuffer, sr: srate, h: hh, c: hc}; + + // feed inputs and run + if (doVad) { + vad_infer(feeds) + if (speech_prob > 0.4) { + socket.send(audioData16kHz); + } + else + console.log("no speech found: " + speech_prob) + } + }; + + // Prevent page mute + mediaStream.connect(recorder); + recorder.connect(context.destination); + mediaStream.connect(context.destination); + } else { + window.close(); + } +} + +/** + * Listener for incoming messages from the extension's background script. + * @param {Object} request - The message request object. + * @param {Object} sender - The sender object containing information about the message sender. + * @param {Function} sendResponse - The function to send a response back to the message sender. + */ +chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => { + const { type, data } = request; + + switch (type) { + case "start_capture": + await startRecord(data); + break; + default: + break; + } + + sendResponse({}); }); diff --git a/Audio-Transcription/ort-wasm-simd-threaded.wasm b/Audio-Transcription/ort-wasm-simd-threaded.wasm new file mode 100644 index 0000000..ce834a2 Binary files /dev/null and b/Audio-Transcription/ort-wasm-simd-threaded.wasm differ diff --git a/Audio-Transcription/ort.min.js b/Audio-Transcription/ort.min.js new file mode 100644 index 0000000..73c0c78 --- /dev/null +++ b/Audio-Transcription/ort.min.js @@ -0,0 +1,6 @@ +/*! +* ONNX Runtime Web v1.15.0 +* Copyright (c) Microsoft Corporation. All rights reserved. +* Licensed under the MIT License. +*/ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ort=t():e.ort=t()}(self,(()=>(()=>{var __webpack_modules__={8453:(e,t,n)=>{"use strict";n.r(t),n.d(t,{InferenceSession:()=>f,Tensor:()=>p,env:()=>a,registerBackend:()=>i});const r={},o=[],i=(e,t,n)=>{if(!t||"function"!=typeof t.init||"function"!=typeof t.createSessionHandler)throw new TypeError("not a valid backend");{const i=r[e];if(void 0===i)r[e]={backend:t,priority:n};else{if(i.priority>n)return;if(i.priority===n&&i.backend!==t)throw new Error(`cannot register backend "${e}" using priority ${n}`)}if(n>=0){const t=o.indexOf(e);-1!==t&&o.splice(t,1);for(let t=0;t{if(!l){l=!0;const e="undefined"!=typeof BigInt64Array&&"function"==typeof BigInt64Array.from,t="undefined"!=typeof BigUint64Array&&"function"==typeof BigUint64Array.from;e&&(s.set("int64",BigInt64Array),u.set(BigInt64Array,"int64")),t&&(s.set("uint64",BigUint64Array),u.set(BigUint64Array,"uint64"))}})(),"string"==typeof e)if(r=e,i=n,"string"===e){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");o=t}else{const n=s.get(e);if(void 0===n)throw new TypeError(`Unsupported tensor type: ${e}.`);if(Array.isArray(t))o=n.from(t);else{if(!(t instanceof n))throw new TypeError(`A ${r} tensor's data must be type of ${n}`);o=t}}else if(i=t,Array.isArray(e)){if(0===e.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");const t=typeof e[0];if("string"===t)r="string",o=e;else{if("boolean"!==t)throw new TypeError(`Invalid element type of data array: ${t}.`);r="bool",o=Uint8Array.from(e)}}else{const t=u.get(e.constructor);if(void 0===t)throw new TypeError(`Unsupported type for tensor data: ${e.constructor}.`);r=t,o=e}if(void 0===i)i=[o.length];else if(!Array.isArray(i))throw new TypeError("A tensor's dims must be a number array");const a=(e=>{let t=1;for(let n=0;n{const o=document.createElement("canvas"),i=o.getContext("2d");if(!e||!i)return r();const a=new Image;a.crossOrigin="Anonymous",a.src=e,a.onload=()=>{o.width=a.width,o.height=a.height,i.drawImage(a,0,0,o.width,o.height);const e=i.getImageData(0,0,o.width,o.height);if(void 0!==t){if(void 0!==t.height&&t.height!==o.height)throw new Error("Image input config height doesn't match height");if(s.height=o.height,void 0!==t.width&&t.width!==o.width)throw new Error("Image input config width doesn't match width");s.width=o.width}else s.height=o.height,s.width=o.width;n(c.bufferToTensor(e.data,s))}}));throw new Error("Input data provided is not supported - aborted tensor creation")}{const n="RGBA";let r,o;if(void 0!==t&&void 0!==t.resizedWidth&&void 0!==t.resizedHeight?(r=t.resizedHeight,o=t.resizedWidth):(r=e.height,o=e.width),void 0!==t){if(s=t,void 0!==t.bitmapFormat&&t.bitmapFormat!==n)throw new Error("Image input config format must be RGBA for ImageData");s.bitmapFormat="RGBA"}else s.bitmapFormat="RGBA";if(s.height=r,s.width=o,void 0!==t){const t=document.createElement("canvas");t.width=o,t.height=r;const n=t.getContext("2d");if(null==n)throw new Error("Can not access image data");n.putImageData(e,0,0),a=n.getImageData(0,0,o,r).data}else a=e.data}}if(void 0!==a)return c.bufferToTensor(a,s);throw new Error("Input data provided is not supported - aborted tensor creation")}toDataURL(e){const t=document.createElement("canvas");t.width=this.dims[3],t.height=this.dims[2];const n=t.getContext("2d");if(null!=n){let r,o;void 0!==e?.tensorLayout&&"NHWC"===e.tensorLayout?(r=this.dims[2],o=this.dims[3]):(r=this.dims[3],o=this.dims[2]);const i=void 0!==e?.format?e.format:"RGB",a=e?.norm;let s,u;void 0===a||void 0===a.mean?s=[255,255,255,255]:"number"==typeof a.mean?s=[a.mean,a.mean,a.mean,a.mean]:(s=[a.mean[0],a.mean[1],a.mean[2],0],void 0!==a.mean[3]&&(s[3]=a.mean[3])),void 0===a||void 0===a.bias?u=[0,0,0,0]:"number"==typeof a.bias?u=[a.bias,a.bias,a.bias,a.bias]:(u=[a.bias[0],a.bias[1],a.bias[2],0],void 0!==a.bias[3]&&(u[3]=a.bias[3]));const l=o*r;let c=0,p=l,d=2*l,f=-1;"RGBA"===i?(c=0,p=l,d=2*l,f=3*l):"RGB"===i?(c=0,p=l,d=2*l):"RBG"===i&&(c=0,d=l,p=2*l);for(let e=0;e=r.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${r.byteLength}).`);if(u=e.byteLength-o,"number"==typeof n){if(u=n,!Number.isSafeInteger(u))throw new RangeError("'byteLength' must be an integer.");if(u<=0||o+u>r.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${r.byteLength-o}].`);if("object"==typeof i&&null!==i)s=i;else if(void 0!==i)throw new TypeError("'options' must be an object.")}else if(void 0!==n)throw new TypeError("'byteLength' must be a number.")}else if(void 0!==t)throw new TypeError("'options' must be an object.");a=new Uint8Array(r,o,u)}}const u=(s.executionProviders||[]).map((e=>"string"==typeof e?e:e.name)),l=await(async e=>{const t=0===e.length?o:e,n=[];for(const e of t){const t=r[e];if(t){if(t.initialized)return t.backend;if(t.aborted)continue;const r=!!t.initPromise;try{return r||(t.initPromise=t.backend.init()),await t.initPromise,t.initialized=!0,t.backend}catch(o){r||n.push({name:e,err:o}),t.aborted=!0}finally{delete t.initPromise}}}throw new Error(`no available backend found. ERR: ${n.map((e=>`[${e.name}] ${e.err}`)).join(", ")}`)})(u),c=await l.createSessionHandler(a,s);return new d(c)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}}const f=d},5716:(e,t,n)=>{"use strict";t.R=void 0;const r=n(6027),o=n(1723);t.R=new class{async init(){}async createSessionHandler(e,t){const n=new r.Session(t);return await n.loadModel(e),new o.OnnxjsSessionHandler(n)}}},2818:(e,t,n)=>{"use strict";t.c8=t.rX=void 0;const r=n(8453),o=n(5381),i=n(9544),a=n(6640);t.rX=()=>{if(("number"!=typeof r.env.wasm.initTimeout||r.env.wasm.initTimeout<0)&&(r.env.wasm.initTimeout=0),"boolean"!=typeof r.env.wasm.simd&&(r.env.wasm.simd=!0),"boolean"!=typeof r.env.wasm.proxy&&(r.env.wasm.proxy=!1),"number"!=typeof r.env.wasm.numThreads||!Number.isInteger(r.env.wasm.numThreads)||r.env.wasm.numThreads<=0){const e="undefined"==typeof navigator?(0,o.cpus)().length:navigator.hardwareConcurrency;r.env.wasm.numThreads=Math.min(4,Math.ceil((e||1)/2))}},t.c8=new class{async init(){(0,t.rX)(),await(0,i.initWasm)()}async createSessionHandler(e,t){const n=new a.OnnxruntimeWebAssemblySessionHandler;return await n.loadModel(e,t),Promise.resolve(n)}}},1057:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(8453),t);const i=n(8453);{const e=n(5716).R;(0,i.registerBackend)("webgl",e,-10)}{const e=n(2818).c8;(0,i.registerBackend)("cpu",e,10),(0,i.registerBackend)("wasm",e,10),(0,i.registerBackend)("xnnpack",e,9)}},4910:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createAttributeWithCacheKey=void 0;class n{constructor(e){Object.assign(this,e)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map((e=>`${this[e]}`)).join(";")),this._cacheKey}}t.createAttributeWithCacheKey=e=>new n(e)},6874:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Attribute=void 0;const r=n(1446),o=n(1287),i=n(9240),a=n(7273);var s=o.onnxruntime.experimental.fbs;class u{constructor(e){if(this._attributes=new Map,null!=e){for(const t of e)t instanceof r.onnx.AttributeProto?this._attributes.set(t.name,[u.getValue(t),u.getType(t)]):t instanceof s.Attribute&&this._attributes.set(t.name(),[u.getValue(t),u.getType(t)]);if(this._attributes.sizei.Tensor.fromProto(e)));if(e instanceof s.Attribute)return n.map((e=>i.Tensor.fromOrtTensor(e)))}if(t===r.onnx.AttributeProto.AttributeType.STRING&&e instanceof r.onnx.AttributeProto){const e=n;return(0,a.decodeUtf8String)(e)}return t===r.onnx.AttributeProto.AttributeType.STRINGS&&e instanceof r.onnx.AttributeProto?n.map(a.decodeUtf8String):n}static getValueNoCheck(e){return e instanceof r.onnx.AttributeProto?this.getValueNoCheckFromOnnxFormat(e):this.getValueNoCheckFromOrtFormat(e)}static getValueNoCheckFromOnnxFormat(e){switch(e.type){case r.onnx.AttributeProto.AttributeType.FLOAT:return e.f;case r.onnx.AttributeProto.AttributeType.INT:return e.i;case r.onnx.AttributeProto.AttributeType.STRING:return e.s;case r.onnx.AttributeProto.AttributeType.TENSOR:return e.t;case r.onnx.AttributeProto.AttributeType.GRAPH:return e.g;case r.onnx.AttributeProto.AttributeType.FLOATS:return e.floats;case r.onnx.AttributeProto.AttributeType.INTS:return e.ints;case r.onnx.AttributeProto.AttributeType.STRINGS:return e.strings;case r.onnx.AttributeProto.AttributeType.TENSORS:return e.tensors;case r.onnx.AttributeProto.AttributeType.GRAPHS:return e.graphs;default:throw new Error(`unsupported attribute type: ${r.onnx.AttributeProto.AttributeType[e.type]}`)}}static getValueNoCheckFromOrtFormat(e){switch(e.type()){case s.AttributeType.FLOAT:return e.f();case s.AttributeType.INT:return e.i();case s.AttributeType.STRING:return e.s();case s.AttributeType.TENSOR:return e.t();case s.AttributeType.GRAPH:return e.g();case s.AttributeType.FLOATS:return e.floatsArray();case s.AttributeType.INTS:{const t=[];for(let n=0;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resolveBackend=t.backend=void 0;const r=n(4418),o=new Map;async function i(e){const n=t.backend;if(void 0!==n[e]&&function(e){const t=e;return"initialize"in t&&"function"==typeof t.initialize&&"createSessionHandler"in t&&"function"==typeof t.createSessionHandler&&"dispose"in t&&"function"==typeof t.dispose}(n[e])){const t=n[e];let r=t.initialize();if("object"==typeof r&&"then"in r&&(r=await r),r)return o.set(e,t),t}}t.backend={webgl:new r.WebGLBackend},t.resolveBackend=async function e(t){if(!t)return e(["webgl"]);{const e="string"==typeof t?[t]:t;for(const t of e){const e=o.get(t);if(e)return e;const n=await i(t);if(n)return n}}throw new Error("no available backend to use")}},4418:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLBackend=void 0;const r=n(8453),o=n(1315),i=n(2171),a=n(3389);t.WebGLBackend=class{get contextId(){return r.env.webgl.contextId}set contextId(e){r.env.webgl.contextId=e}get matmulMaxBatchSize(){return r.env.webgl.matmulMaxBatchSize}set matmulMaxBatchSize(e){r.env.webgl.matmulMaxBatchSize=e}get textureCacheMode(){return r.env.webgl.textureCacheMode}set textureCacheMode(e){r.env.webgl.textureCacheMode=e}get pack(){return r.env.webgl.pack}set pack(e){r.env.webgl.pack=e}get async(){return r.env.webgl.async}set async(e){r.env.webgl.async=e}initialize(){try{return this.glContext=(0,a.createWebGLContext)(this.contextId),"number"!=typeof this.matmulMaxBatchSize&&(this.matmulMaxBatchSize=16),"string"!=typeof this.textureCacheMode&&(this.textureCacheMode="full"),"boolean"!=typeof this.pack&&(this.pack=!1),"boolean"!=typeof this.async&&(this.async=!1),o.Logger.setWithEnv(r.env),o.Logger.verbose("WebGLBackend",`Created WebGLContext: ${typeof this.glContext} with matmulMaxBatchSize: ${this.matmulMaxBatchSize}; textureCacheMode: ${this.textureCacheMode}; pack: ${this.pack}; async: ${this.async}.`),!0}catch(e){return o.Logger.warning("WebGLBackend",`Unable to initialize WebGLBackend. ${e}`),!1}}createSessionHandler(e){return new i.WebGLSessionHandler(this,e)}dispose(){this.glContext.dispose()}}},6859:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CoordsGlslLib=void 0;const r=n(7273),o=n(1997),i=n(6757),a=n(7618),s=n(432);class u extends o.GlslLib{constructor(e){super(e)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.offsetToCoords()),this.coordsToOffset()),this.toVec()),this.valueFrom()),this.getCommonUtilFuncs()),this.getInputsSamplingSnippets()),this.getOutputSamplingSnippet())}getCustomTypes(){return{}}offsetToCoords(){return{offsetToCoords:new o.GlslLibRoutine("\n vec2 offsetToCoords(int offset, int width, int height) {\n int t = offset / width;\n int s = offset - t*width;\n vec2 coords = (vec2(s,t) + vec2(0.5,0.5)) / vec2(width, height);\n return coords;\n }\n ")}}coordsToOffset(){return{coordsToOffset:new o.GlslLibRoutine("\n int coordsToOffset(vec2 coords, int width, int height) {\n float s = coords.s * float(width);\n float t = coords.t * float(height);\n int offset = int(t) * width + int(s);\n return offset;\n }\n ")}}getOutputSamplingSnippet(){const e=this.context.outputTextureLayout;return e.isPacked?this.getPackedOutputSamplingSnippet(e):this.getUnpackedOutputSamplingSnippet(e)}getPackedOutputSamplingSnippet(e){const t=e.unpackedShape,n=[e.width,e.height],r={},a="getOutputCoords";switch(t.length){case 0:r[a]=this.getOutputScalarCoords();break;case 1:r[a]=this.getOutputPacked1DCoords(t,n);break;case 2:r[a]=this.getOutputPacked2DCoords(t,n);break;case 3:r[a]=this.getOutputPacked3DCoords(t,n);break;default:r[a]=this.getOutputPackedNDCoords(t,n)}const s=`\n void setOutput(vec4 val) {\n ${(0,i.getGlsl)(this.context.glContext.version).output} = val;\n }\n `;return r.floatTextureSetRGBA=new o.GlslLibRoutine(s),r}getUnpackedOutputSamplingSnippet(e){const t=e.unpackedShape,n=[e.width,e.height],r={},a="getOutputCoords";switch(t.length){case 0:r[a]=this.getOutputScalarCoords();break;case 1:r[a]=this.getOutputUnpacked1DCoords(t,n);break;case 2:r[a]=this.getOutputUnpacked2DCoords(t,n);break;case 3:r[a]=this.getOutputUnpacked3DCoords(t,n);break;case 4:r[a]=this.getOutputUnpacked4DCoords(t,n);break;case 5:r[a]=this.getOutputUnpacked5DCoords(t,n);break;case 6:r[a]=this.getOutputUnpacked6DCoords(t,n);break;default:throw new Error(`Unsupported output dimensionality: ${t.length}`)}const s=`\n void setOutput(float val) {\n ${(0,i.getGlsl)(this.context.glContext.version).output} = vec4(val, 0, 0, 0);\n }\n `;return r.floatTextureSetR=new o.GlslLibRoutine(s),r}getOutputScalarCoords(){return new o.GlslLibRoutine("\n int getOutputCoords() {\n return 0;\n }\n ")}getOutputPacked1DCoords(e,t){const n=t;let r="";return 1===n[0]?(r=`\n int getOutputCoords() {\n return 2 * int(TexCoords.y * ${n[1]}.0);\n }\n `,new o.GlslLibRoutine(r)):1===n[1]?(r=`\n int getOutputCoords() {\n return 2 * int(TexCoords.x * ${n[0]}.0);\n }\n `,new o.GlslLibRoutine(r)):(r=`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(TexCoords.xy *\n vec2(${n[0]}, ${n[1]}));\n return 2 * (resTexRC.y * ${n[0]} + resTexRC.x);\n }\n `,new o.GlslLibRoutine(r))}getOutputPacked2DCoords(e,t){let n="";if(r.ArrayUtil.arraysEqual(e,t))return n=`\n ivec2 getOutputCoords() {\n return 2 * ivec2(TexCoords.xy * vec2(${t[0]}, ${t[1]}));\n }\n `,new o.GlslLibRoutine(n);const i=t,a=Math.ceil(e[1]/2);return n=`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(TexCoords.xy *\n vec2(${i[0]}, ${i[1]}));\n\n int index = resTexRC.y * ${i[0]} + resTexRC.x;\n\n // reverse r and c order for packed texture\n int r = imod(index, ${a}) * 2;\n int c = 2 * (index / ${a});\n\n return ivec2(r, c);\n }\n `,new o.GlslLibRoutine(n)}getOutputPacked3DCoords(e,t){const n=[t[0],t[1]],r=Math.ceil(e[2]/2),i=r*Math.ceil(e[1]/2),a=`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(TexCoords.xy *\n vec2(${n[0]}, ${n[1]}));\n int index = resTexRC.y * ${n[0]} + resTexRC.x;\n\n int b = index / ${i};\n index -= b * ${i};\n\n // reverse r and c order for packed texture\n int r = imod(index, ${r}) * 2;\n int c = 2 * (index / ${r});\n\n return ivec3(b, r, c);\n }\n `;return new o.GlslLibRoutine(a)}getOutputPackedNDCoords(e,t){const n=[t[0],t[1]],r=Math.ceil(e[e.length-1]/2),i=r*Math.ceil(e[e.length-2]/2);let a=i,s="",u="b, r, c";for(let t=2;t=0;--t)i[t]=i[t+1]*e[t+1];const a=["r","c","d"],s=i.map(((e,t)=>`int ${a[t]} = index / ${e}; ${t===i.length-1?`int ${a[t+1]} = index - ${a[t]} * ${e}`:`index -= ${a[t]} * ${e}`};`)).join("");return n=`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(TexCoords.xy *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.y * ${t[0]} + resTexRC.x;\n ${s}\n return ivec3(r, c, d);\n }\n `,new o.GlslLibRoutine(n)}getOutputUnpacked4DCoords(e,t){let n="";const r=e.length;let i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=e[r-1];for(let t=r-3;t>=0;--t)i[t]=i[t+1]*e[t+1];const a=["r","c","d","d2"],s=i.map(((e,t)=>`int ${a[t]} = index / ${e}; ${t===i.length-1?`int ${a[t+1]} = index - ${a[t]} * ${e}`:`index -= ${a[t]} * ${e}`};`)).join("");return n=`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(TexCoords.xy *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.y * ${t[0]} + resTexRC.x;\n ${s}\n return ivec4(r, c, d, d2);\n }\n `,new o.GlslLibRoutine(n)}getOutputUnpacked5DCoords(e,t){let n="";const r=e.length;let i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=e[r-1];for(let t=r-3;t>=0;--t)i[t]=i[t+1]*e[t+1];const a=["r","c","d","d2","d3"],s=i.map(((e,t)=>`int ${a[t]} = index / ${e}; ${t===i.length-1?`int ${a[t+1]} = index - ${a[t]} * ${e}`:`index -= ${a[t]} * ${e}`};`)).join("");return n=`\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(TexCoords.xy *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.y * ${t[0]} + resTexRC.x;\n ${s}\n return ivec5(r, c, d, d2, d3);\n }\n `,new o.GlslLibRoutine(n)}getOutputUnpacked6DCoords(e,t){let n="";const r=e.length;let i=null;r<2&&(i=[]),i=new Array(r-1),i[r-2]=e[r-1];for(let t=r-3;t>=0;--t)i[t]=i[t+1]*e[t+1];const a=["r","c","d","d2","d3","d4"],s=i.map(((e,t)=>`int ${a[t]} = index / ${e}; ${t===i.length-1?`int ${a[t+1]} = index - ${a[t]} * ${e}`:`index -= ${a[t]} * ${e}`};`)).join("");return n=`\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(TexCoords.xy *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.y * ${t[0]} + resTexRC.x;\n ${s}\n return ivec6(r, c, d, d2, d3, d4);\n }\n `,new o.GlslLibRoutine(n)}getCommonUtilFuncs(){const e={};let t="uvFromFlat";e[t]=new o.GlslLibRoutine("\n vec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texC = index / texNumR;\n int texR = index - texC * texNumR;\n // TODO: swap texR, texC order in following function so row is corresponding to u and column is corresponding to\n // v.\n return (vec2(texR, texC) + halfCR) / vec2(texNumR, texNumC);\n }\n "),t="packedUVfrom1D",e[t]=new o.GlslLibRoutine("\n vec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n }\n "),t="packedUVfrom2D",e[t]=new o.GlslLibRoutine("\n vec2 packedUVfrom2D(int texNumR, int texNumC, int texelsInLogicalRow, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n }\n "),t="packedUVfrom3D",e[t]=new o.GlslLibRoutine("\n vec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n }\n "),t="sampleTexture";const n=(0,i.getGlsl)(this.context.glContext.version);return e[t]=new o.GlslLibRoutine(`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${n.texture2D}(textureSampler, uv).r;\n }`),e}getInputsSamplingSnippets(){const e={},t=this.context.outputTextureLayout;return this.context.programInfo.inputNames.forEach(((n,r)=>{const o=this.context.inputTextureLayouts[r],i=(0,s.generateShaderFuncNameFromInputSamplerName)(n);o.isPacked?e[i]=this.getPackedSamplerFromInput(i,n,o):e[i]=this.getUnpackedSamplerFromInput(i,n,o);const a=(0,s.generateShaderFuncNameFromInputSamplerNameAtOutCoords)(n);o.unpackedShape.length<=t.unpackedShape.length&&(o.isPacked?e[a]=this.getPackedSamplerAtOutputCoords(a,o,t,n):e[a]=this.getUnpackedSamplerAtOutputCoords(a,o,t,n))})),e}getPackedSamplerAtOutputCoords(e,t,n,i){const a=t.unpackedShape,u=n.unpackedShape,l=i,c=(0,s.generateShaderFuncNameFromInputSamplerName)(l),p=a.length,d=u.length,f=r.BroadcastUtil.getBroadcastDims(a,u),h=(0,s.getCoordsDataType)(d),g=d-p;let m;const b=(0,s.getGlChannels)();m=0===p?"":d<2&&f.length>=1?"coords = 0;":f.map((e=>`coords.${b[e+g]} = 0;`)).join("\n");let y="";y=d<2&&p>0?"coords":a.map(((e,t)=>`coords.${b[t+g]}`)).join(", ");let w="return outputValue;";const _=1===r.ShapeUtil.size(a),v=1===r.ShapeUtil.size(u);if(1!==p||_||v){if(_&&!v)w=1===d?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(f.length){const e=p-2,t=p-1;f.indexOf(e)>-1&&f.indexOf(t)>-1?w="return vec4(outputValue.x);":f.indexOf(e)>-1?w="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":f.indexOf(t)>-1&&(w="return vec4(outputValue.xx, outputValue.zz);")}}else w="\n return vec4(outputValue.xy, outputValue.xy);\n ";const x=`\n vec4 ${e}() {\n ${h} coords = getOutputCoords();\n \n int lastDim = coords.${b[d-1]};\n coords.${b[d-1]} = coords.${b[d-2]};\n coords.${b[d-2]} = lastDim;\n \n ${m}\n vec4 outputValue = ${c}(${y});\n ${w}\n }\n `;return new o.GlslLibRoutine(x,["coordinates.getOutputCoords"])}getUnpackedSamplerAtOutputCoords(e,t,n,i){const a=[n.width,n.height],u=[t.width,t.height],l=t.unpackedShape.length,c=n.unpackedShape.length,p=t.unpackedShape,d=n.unpackedShape,f=(0,s.generateShaderFuncNameFromInputSamplerName)(i);if(l===c&&r.ArrayUtil.arraysEqual(u,a)){const t=`\n float ${e}() {\n return sampleTexture(${i}, TexCoords);\n }\n `;return new o.GlslLibRoutine(t,["coordinates.sampleTexture"])}const h=(0,s.getCoordsDataType)(c),g=r.BroadcastUtil.getBroadcastDims(p,d),m=c-l;let b;const y=(0,s.getGlChannels)();b=0===l?"":c<2&&g.length>=1?"coords = 0;":g.map((e=>`coords.${y[e+m]} = 0;`)).join("\n");let w="";w=c<2&&l>0?"coords":t.unpackedShape.map(((e,t)=>`coords.${y[t+m]}`)).join(", ");const _=`\n float ${e}() {\n ${h} coords = getOutputCoords();\n ${b}\n return ${f}(${w});\n }\n `;return new o.GlslLibRoutine(_,["coordinates.getOutputCoords"])}getPackedSamplerFromInput(e,t,n){switch(n.unpackedShape.length){case 0:return this.getPackedSamplerScalar(e,t);case 1:return this.getPackedSampler1D(e,t,n);case 2:return this.getPackedSampler2D(e,t,n);case 3:return this.getPackedSampler3D(e,t,n);default:return this.getPackedSamplerND(e,t,n)}}getUnpackedSamplerFromInput(e,t,n){const r=n.unpackedShape;switch(r.length){case 0:return this.getUnpackedSamplerScalar(e,t,n);case 1:return this.getUnpackedSampler1D(e,t,n);case 2:return this.getUnpackedSampler2D(e,t,n);case 3:return this.getUnpackedSampler3D(e,t,n);case 4:return this.getUnpackedSampler4D(e,t,n);case 5:return this.getUnpackedSampler5D(e,t,n);case 6:return this.getUnpackedSampler6D(e,t,n);default:throw new Error(`Unsupported dimension ${r.length}-D`)}}getPackedSamplerScalar(e,t){const n=`\n vec4 ${e}() {\n return ${(0,i.getGlsl)(this.context.glContext.version).texture2D}(${t}, halfCR);\n }\n `;return new o.GlslLibRoutine(n)}getPackedSampler1D(e,t,n){const r=[n.width,n.height],a=[r[1],r[0]],s=(0,i.getGlsl)(this.context.glContext.version),u=`vec4 ${e}(int index) {\n vec2 uv = packedUVfrom1D(\n ${a[0]}, ${a[1]}, index);\n return ${s.texture2D}(${t}, uv);\n }`;return new o.GlslLibRoutine(u,["coordinates.packedUVfrom1D"])}getPackedSampler2D(e,t,n){const a=n.unpackedShape,s=[n.width,n.height],u=(0,i.getGlsl)(this.context.glContext.version),l=s[0],c=s[1];if(null!=s&&r.ArrayUtil.arraysEqual(a,s)){const n=`vec4 ${e}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${c}.0, ${l}.0);\n return ${u.texture2D}(${t}, uv);\n }`;return new o.GlslLibRoutine(n)}const p=s,d=Math.ceil(a[1]/2),f=`vec4 ${e}(int row, int col) {\n vec2 uv = packedUVfrom2D(${p[1]}, ${p[0]}, ${d}, row, col);\n return ${u.texture2D}(${t}, uv);\n }`;return new o.GlslLibRoutine(f,["coordinates.packedUVfrom2D"])}getPackedSampler3D(e,t,n){const r=n.unpackedShape,a=[n.width,n.height],u=[a[0],a[1]],l=(0,i.getGlsl)(this.context.glContext.version);if(1===r[0]){const i=r.slice(1),a=[1,2],u=(0,s.squeezeInputShape)(r,i),l=["b","row","col"],c=JSON.parse(JSON.stringify(n));c.unpackedShape=u;const p=this.getPackedSamplerFromInput(e,t,c),d=`${p.routineBody}\n vec4 ${e}(int b, int row, int col) {\n return ${e}(${(0,s.getSqueezedParams)(l,a)});\n } `;return new o.GlslLibRoutine(d,p.dependencies)}const c=u[0],p=u[1],d=Math.ceil(r[2]/2),f=`vec4 ${e}(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ${p}, ${c}, ${d*Math.ceil(r[1]/2)}, ${d}, b, row, col);\n return ${l.texture2D}(${t}, uv);}`;return new o.GlslLibRoutine(f,["coordinates.packedUVfrom3D"])}getPackedSamplerND(e,t,n){const r=n.unpackedShape,a=r.length,s=[n.width,n.height],u=(0,i.getGlsl)(this.context.glContext.version),l=[s[0],s[1]],c=l[1],p=l[0],d=Math.ceil(r[a-1]/2);let f=d*Math.ceil(r[a-2]/2),h="int b, int row, int col",g=`b * ${f} + (row / 2) * ${d} + (col / 2)`;for(let e=2;e{const r=this.context.inputTextureLayouts[n],i=(r.unpackedShape.length>0?r.unpackedShape:r.shape).length;let a=`_${t}`;e[a]=new o.GlslLibRoutine(this.getValueFromSingle(t,i,r.width,r.height,!1),[`shapeUtils.indicesToOffset${a}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"]),a+="_T",e[a]=new o.GlslLibRoutine(this.getValueFromSingle(t,i,r.width,r.height,!0),[`shapeUtils.indicesToOffset${a}`,"coordinates.offsetToCoords","fragcolor.getColorAsFloat"])})),e}getValueFromSingle(e,t,n,r,o){let a=`_${e}`;return o&&(a+="_T"),`\n float ${a}(int m[${t}]) {\n int offset = indicesToOffset${a}(m);\n vec2 coords = offsetToCoords(offset, ${n}, ${r});\n float value = getColorAsFloat(${(0,i.getGlsl)(this.context.glContext.version).texture2D}(${e}, coords));\n return value;\n }\n `}getPackedValueFrom(e,t,n,r,o){let a=`_${e}_Pack`;return o&&(a+="_T"),`\n vec4 ${a}(int m[${t}]) {\n int offset = indicesToOffset_${e}(m);\n vec2 coords = offsetToCoords(offset, ${n}, ${r});\n return ${(0,i.getGlsl)(this.context.glContext.version).texture2D}(${e}, coords);\n }\n `}}t.CoordsGlslLib=u},1997:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.TopologicalSortGlslRoutines=t.GlslLibRoutineNode=t.GlslLibRoutine=t.GlslLib=t.GlslContext=t.FunctionType=void 0,(n=t.FunctionType||(t.FunctionType={}))[n.ValueBased=0]="ValueBased",n[n.Positional=1]="Positional",t.GlslContext=class{constructor(e,t,n,r){this.glContext=e,this.programInfo=t,this.inputTextureLayouts=n,this.outputTextureLayout=r}},t.GlslLib=class{constructor(e){this.context=e}},t.GlslLibRoutine=class{constructor(e,t){this.routineBody=e,this.dependencies=t}},t.GlslLibRoutineNode=class{constructor(e,t,n){this.name=e,this.dependencies=n||[],t&&(this.routineBody=t)}addDependency(e){e&&this.dependencies.push(e)}},t.TopologicalSortGlslRoutines=class{static returnOrderedNodes(e){if(!e||0===e.length)return[];if(1===e.length)return e;const t=new Set,n=new Set,r=new Array;return this.createOrderedNodes(e,t,n,r),r}static createOrderedNodes(e,t,n,r){for(let o=0;o0)for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EncodingGlslLib=void 0;const r=n(1997);class o extends r.GlslLib{constructor(e){super(e)}getFunctions(){return Object.assign(Object.assign({},this.encodeFloat32()),this.decodeFloat32())}getCustomTypes(){return{}}encodeFloat32(){return{encode:new r.GlslLibRoutine("highp vec4 encode(highp float f) {\n return vec4(f, 0.0, 0.0, 0.0);\n }\n ")}}decodeFloat32(){return{decode:new r.GlslLibRoutine("highp float decode(highp vec4 rgba) {\n return rgba.r;\n }\n ")}}encodeUint8(){const e=o.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{encode:new r.GlslLibRoutine(`\n highp vec4 encode(highp float f) {\n highp float F = abs(f);\n highp float Sign = step(0.0,-f);\n highp float Exponent = floor(log2(F));\n highp float Mantissa = (exp2(- Exponent) * F);\n Exponent = floor(log2(F) + 127.0) + floor(log2(Mantissa));\n highp vec4 rgba;\n rgba[0] = 128.0 * Sign + floor(Exponent*exp2(-1.0));\n rgba[1] = 128.0 * mod(Exponent,2.0) + mod(floor(Mantissa*128.0),128.0);\n rgba[2] = floor(mod(floor(Mantissa*exp2(23.0 -8.0)),exp2(8.0)));\n rgba[3] = floor(exp2(23.0)*mod(Mantissa,exp2(-15.0)));\n ${e}\n rgba = rgba / 255.0; // values need to be normalized to [0,1]\n return rgba;\n }\n `)}}decodeUint8(){const e=o.isLittleEndian()?"rgba.rgba=rgba.abgr;":"";return{decode:new r.GlslLibRoutine(`\n highp float decode(highp vec4 rgba) {\n rgba = rgba * 255.0; // values need to be de-normalized from [0,1] to [0,255]\n ${e}\n highp float Sign = 1.0 - step(128.0,rgba[0])*2.0;\n highp float Exponent = 2.0 * mod(rgba[0],128.0) + step(128.0,rgba[1]) - 127.0;\n highp float Mantissa = mod(rgba[1],128.0)*65536.0 + rgba[2]*256.0 +rgba[3] + float(0x800000);\n highp float Result = Sign * exp2(Exponent) * (Mantissa * exp2(-23.0 ));\n return Result;\n }\n `)}}static isLittleEndian(){const e=new ArrayBuffer(4),t=new Uint32Array(e),n=new Uint8Array(e);if(t[0]=3735928559,239===n[0])return!0;if(222===n[0])return!1;throw new Error("unknown endianness")}}t.EncodingGlslLib=o},2691:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FragColorGlslLib=void 0;const r=n(1997),o=n(6757);class i extends r.GlslLib{constructor(e){super(e)}getFunctions(){return Object.assign(Object.assign({},this.setFragColor()),this.getColorAsFloat())}getCustomTypes(){return{}}setFragColor(){const e=(0,o.getGlsl)(this.context.glContext.version);return{setFragColor:new r.GlslLibRoutine(`\n void setFragColor(float value) {\n ${e.output} = encode(value);\n }\n `,["encoding.encode"])}}getColorAsFloat(){return{getColorAsFloat:new r.GlslLibRoutine("\n float getColorAsFloat(vec4 color) {\n return decode(color);\n }\n ",["encoding.decode"])}}}t.FragColorGlslLib=i},3878:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.replaceInlines=void 0;const n=/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm;t.replaceInlines=function(e){const t={};let r;for(;null!==(r=n.exec(e));){const e=r[3].split(",").map((e=>{const t=e.trim().split(" ");return t&&2===t.length?{type:t[0],name:t[1]}:null})).filter((e=>null!==e));t[r[2]]={params:e,body:r[4]}}for(const n in t){const o="(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;".replace("__FUNC__",n),i=new RegExp(o,"gm");for(;null!==(r=i.exec(e));){const o=r[1],i=r[2],a=r[3].split(","),s=o?`${o} ${i};`:"";let u=t[n].body,l="";t[n].params.forEach(((e,t)=>{e&&(l+=`${e.type} ${e.name} = ${a[t]};\n`)})),u=`${l}\n ${u}`,u=u.replace("return",`${i} = `);const c=`\n ${s}\n {\n ${u}\n }\n `;e=e.replace(r[0],c)}}return e.replace(n,"")}},8897:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GlslPreprocessor=void 0;const r=n(1997),o=n(3878),i=n(1248),a=n(6757);t.GlslPreprocessor=class{constructor(e,t,n,o){this.libs={},this.glslLibRoutineDependencyGraph={},this.context=new r.GlslContext(e,t,n,o),Object.keys(i.glslRegistry).forEach((e=>{const t=new i.glslRegistry[e](this.context);this.libs[e]=t}));const a=this.glslLibRoutineDependencyGraph;for(const e in this.libs){const t=this.libs[e].getFunctions();for(const n in t){const o=e+"."+n;let i;a[o]?(i=a[o],i.routineBody=t[n].routineBody):(i=new r.GlslLibRoutineNode(o,t[n].routineBody),a[o]=i);const s=t[n].dependencies;if(s)for(let e=0;e{const r=n.split(".")[1];-1!==e.indexOf(r)&&t.push(this.glslLibRoutineDependencyGraph[n])})),r.TopologicalSortGlslRoutines.returnOrderedNodes(t)}getUniforms(e,t){const n=[];if(e)for(const t of e)n.push(`uniform sampler2D ${t};`);if(t)for(const e of t)n.push(`uniform ${e.type} ${e.name}${e.arrayLength?`[${e.arrayLength}]`:""};`);return n.join("\n")}}},1248:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.glslRegistry=void 0;const r=n(6859),o=n(1371),i=n(2691),a=n(9183),s=n(9314);t.glslRegistry={encoding:o.EncodingGlslLib,fragcolor:i.FragColorGlslLib,vec:s.VecGlslLib,shapeUtils:a.ShapeUtilsGlslLib,coordinates:r.CoordsGlslLib}},9183:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ShapeUtilsGlslLib=void 0;const r=n(1997);class o extends r.GlslLib{constructor(e){super(e)}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.bcastIndex()),this.bcastMatmulIndex()),this.offsetToIndices()),this.indicesToOffset()),this.incrementIndices())}getCustomTypes(){return{}}bcastIndex(){const e=this.context.outputTextureLayout.shape.length,t={};return this.context.programInfo.inputNames.forEach(((n,o)=>{const i=this.context.inputTextureLayouts[o].unpackedShape;if(i.length<=e){const o=i.length,a=e-o,s=`bcastIndices_${n}`;let u="";for(let e=0;e{const i=this.context.inputTextureLayouts[o].shape;if(!(i.length<2||i.length>e)){const o=i.length,a=e-o,s=`bcastMatmulIndices_${n}`;let u="";for(let e=0;e{const i=this.context.inputTextureLayouts[n].shape,a=this.context.inputTextureLayouts[n].strides,s=i.length;let u=`indicesToOffset_${t}`;e[u]=new r.GlslLibRoutine(o.indexToOffsetSingle(u,s,a)),u=`indicesToOffset_${t}_T`,e[u]=new r.GlslLibRoutine(o.indexToOffsetSingle(u,s,a.slice().reverse()))})),e}static indexToOffsetSingle(e,t,n){let r="";for(let e=t-1;e>=0;--e)r+=`\n offset += indices[${e}] * ${n[e]};\n `;return`\n int ${e}(int indices[${t}]) {\n int offset = 0;\n ${r}\n return offset;\n }\n `}offsetToIndices(){const e={};return this.context.programInfo.inputNames.forEach(((t,n)=>{const i=this.context.inputTextureLayouts[n].shape,a=this.context.inputTextureLayouts[n].strides,s=i.length;let u=`offsetToIndices_${t}`;e[u]=new r.GlslLibRoutine(o.offsetToIndicesSingle(u,s,a)),u=`offsetToIndices_${t}_T`,e[u]=new r.GlslLibRoutine(o.offsetToIndicesSingle(u,s,a.slice().reverse()))})),e}static offsetToIndicesSingle(e,t,n){const r=[];for(let e=0;e{const o=this.context.inputTextureLayouts[n].shape,i=o.length,a=`incrementIndices_${t}`;let s="";for(let e=0;e= 0; --i) {\n if(i > axis) continue;\n indices[i] += 1;\n if(indices[i] < shape[i]) {\n break;\n }\n indices[i] = 0;\n }\n }\n `;e[a]=new r.GlslLibRoutine(u)})),e}}t.ShapeUtilsGlslLib=o},6757:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getDefaultFragShaderMain=t.getFragShaderPreamble=t.getVertexShaderSource=t.getGlsl=void 0;const n={version:"",attribute:"attribute",varyingVertex:"varying",varyingFrag:"varying",texture2D:"texture2D",output:"gl_FragColor",outputDeclaration:""},r={version:"#version 300 es",attribute:"in",varyingVertex:"out",varyingFrag:"in",texture2D:"texture",output:"outputColor",outputDeclaration:"out vec4 outputColor;"};function o(e){return 1===e?n:r}t.getGlsl=o,t.getVertexShaderSource=function(e){const t=o(e);return`${t.version}\n precision highp float;\n ${t.attribute} vec3 position;\n ${t.attribute} vec2 textureCoord;\n\n ${t.varyingVertex} vec2 TexCoords;\n\n void main()\n {\n gl_Position = vec4(position, 1.0);\n TexCoords = textureCoord;\n }`},t.getFragShaderPreamble=function(e){const t=o(e);return`${t.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${t.varyingFrag} vec2 TexCoords;\n ${t.outputDeclaration}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n // Custom vector types to handle higher dimenalities.\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n `},t.getDefaultFragShaderMain=function(e,t){return`\n void main() {\n int indices[${t}];\n toVec(TexCoords, indices);\n vec4 result = vec4(process(indices));\n ${o(e).output} = result;\n }\n `}},9314:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.VecGlslLib=void 0;const r=n(1997);class o extends r.GlslLib{constructor(e){super(e)}getCustomTypes(){return{}}getFunctions(){return Object.assign(Object.assign(Object.assign(Object.assign({},this.binaryVecFunctions()),this.copyVec()),this.setVecItem()),this.getVecItem())}binaryVecFunctions(){const e=this.context.outputTextureLayout.shape.length,t={add:"+=",sub:"-=",mul:"*=",div:"/="},n={};for(const o in t){const i=`${o}Vec`;let a="";for(let n=0;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLInferenceHandler=void 0;const r=n(1315),o=n(9240),i=n(7273),a=n(9),s=n(7379),u=n(2488),l=n(540),c=n(3314),p=n(5639);t.WebGLInferenceHandler=class{constructor(e){this.session=e,this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map}calculateTextureWidthAndHeight(e,t){return(0,c.calculateTextureWidthAndHeight)(this.session.layoutStrategy,e,t)}executeProgram(e,t){if(t.length{const n=t.map((e=>`${e.unpackedShape.join(",")};${e.width}x${e.height}`)).join("_");let r=e.name;return e.cacheHint&&(r+="["+e.cacheHint+"]"),r+=":"+n,r})(e,n);let o=this.session.programManager.getArtifact(r);const i=o?o.programInfo:"function"==typeof e.get?e.get():e,a=(0,c.createTextureLayoutFromTextureType)(this.session.layoutStrategy,i.output.dims,i.output.textureType),s=this.createTextureData(a,i.output.type);return o||(o=this.session.programManager.build(i,n,s),this.session.programManager.setArtifact(r,o)),this.runProgram(o,n,s),s}run(e,t){return this.executeProgram(e,t).tensor}runProgram(e,t,n){for(let n=0;nthis.readTexture(a)),(async e=>this.readTextureAsync(a)),void 0,i),texture:n});return this.setTextureData(a.tensor.dataId,a,e.isPacked),a}getTextureData(e,t=!1){return this.session.isInitializer(e)?this.session.getTextureData(e,t):t?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,t,n=!1){this.session.isInitializer(e)?this.session.setTextureData(e,t,n):(n?this.packedTextureDataCache:this.unpackedTextureDataCache).set(e,t)}isTextureLayoutCached(e,t=!1){return!!this.getTextureData(e.dataId,t)}dispose(){this.session.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach((e=>this.session.textureManager.releaseTexture(e))),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach((e=>this.session.textureManager.releaseTexture(e))),this.unpackedTextureDataCache=new Map}readTexture(e){return e.isPacked?this.readTexture(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTexture(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,u.encodeAsUint8)(this,e))}async readTextureAsync(e){return e.isPacked?this.readTextureAsync(this.unpack(e)):this.session.backend.glContext.isFloat32DownloadSupported?this.session.textureManager.readTextureAsync(e,e.tensor.type,e.channels):this.session.textureManager.readUint8TextureAsFloat((0,u.encodeAsUint8)(this,e))}pack(e){return this.executeProgram((0,a.createPackProgramInfoLoader)(this,e.tensor),[e.tensor])}unpack(e){return this.executeProgram((0,l.createUnpackProgramInfoLoader)(this,e.tensor),[e.tensor])}}},4110:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.WEBGL_OP_RESOLVE_RULES=void 0;const a=n(8817),s=i(n(5194)),u=n(4752),l=n(6668),c=n(9754),p=n(5042),d=n(6742),f=n(4125),h=n(6149),g=n(5378),m=n(6981),b=n(7413),y=n(7006),w=n(8276),_=n(5565),v=n(2834),x=n(1010),T=n(8126),S=n(2801),O=n(565),A=n(2444),E=n(815),I=n(564),$=n(5416),P=n(1240),D=n(5944),k=n(5707),C=i(n(9087)),R=n(7862),M=n(3980);t.WEBGL_OP_RESOLVE_RULES=[["Abs","","6+",C.abs],["Acos","","7+",C.acos],["Add","","7+",s.add],["And","","7+",s.and],["Asin","","7+",C.asin],["Atan","","7+",C.atan],["AveragePool","","7+",v.averagePool,v.parseAveragePoolAttributes],["BatchNormalization","","7+",a.batchNormalization,a.parseBatchNormalizationAttributes],["Cast","","6+",u.cast,u.parseCastAttributes],["Ceil","","6+",C.ceil],["Clip","","6-10",C.clip,C.parseClipAttributes],["Clip","","11+",C.clipV11],["Concat","","4+",l.concat,l.parseConcatAttributes],["Conv","","1+",c.conv,c.parseConvAttributes],["ConvTranspose","","1+",p.convTranspose,p.parseConvTransposeAttributes],["Cos","","7+",C.cos],["Div","","7+",s.div],["Dropout","","7+",C.identity],["DepthToSpace","","1+",d.depthToSpace,d.parseDepthToSpaceAttributes],["Equal","","7+",s.equal],["Elu","","6+",C.elu,C.parseEluAttributes],["Exp","","6+",C.exp],["Flatten","","1+",f.flatten,f.parseFlattenAttributes],["Floor","","6+",C.floor],["FusedConv","com.microsoft","1+",c.conv,c.parseConvAttributes],["Gather","","1+",h.gather,h.parseGatherAttributes],["Gemm","","7-10",g.gemm,g.parseGemmAttributesV7],["Gemm","","11+",g.gemm,g.parseGemmAttributesV11],["GlobalAveragePool","","1+",v.globalAveragePool,v.parseGlobalAveragePoolAttributes],["GlobalMaxPool","","1+",v.globalMaxPool],["Greater","","7+",s.greater],["Identity","","1+",C.identity],["ImageScaler","","1+",m.imageScaler,m.parseImageScalerAttributes],["InstanceNormalization","","6+",b.instanceNormalization,b.parseInstanceNormalizationAttributes],["LeakyRelu","","6+",C.leakyRelu,C.parseLeakyReluAttributes],["Less","","7+",s.less],["LRN","","1+",y.lrn,y.parseLrnAttributes],["Log","","6+",C.log],["MatMul","","1+",w.matMul,w.parseMatMulAttributes],["MaxPool","","1+",v.maxPool,v.parseMaxPoolAttributes],["Mul","","7+",s.mul],["Neg","","6+",C.neg],["Not","","1+",C.not],["Or","","7+",s.or],["Pad","","2-10",_.padV2,_.parsePadAttributesV2],["Pad","","11+",_.padV11,_.parsePadAttributesV11],["Pow","","7+",s.pow],["PRelu","","7+",s.pRelu],["ReduceLogSum","","1+",x.reduceLogSum,x.parseReduceAttributes],["ReduceMax","","1+",x.reduceMax,x.parseReduceAttributes],["ReduceMean","","1+",x.reduceMean,x.parseReduceAttributes],["ReduceMin","","1+",x.reduceMin,x.parseReduceAttributes],["ReduceProd","","1+",x.reduceProd,x.parseReduceAttributes],["ReduceSum","","1-12",x.reduceSum,x.parseReduceAttributes],["ReduceSumSquare","","1+",x.reduceLogSumSquare,x.parseReduceAttributes],["Relu","","6+",C.relu],["Reshape","","5+",T.reshape],["Resize","","10",S.resize,S.parseResizeAttributesV10],["Resize","","11+",S.resize,S.parseResizeAttributesV11],["Shape","","1+",O.shape],["Sigmoid","","6+",C.sigmoid],["Sin","","7+",C.sin],["Slice","","10+",A.sliceV10],["Slice","","1-9",A.slice,A.parseSliceAttributes],["Softmax","","1-12",E.softmax,E.parseSoftmaxAttributes],["Softmax","","13+",E.softmaxV13,E.parseSoftmaxAttributesV13],["Split","","2-12",I.split,I.parseSplitAttributes],["Sqrt","","6+",C.sqrt],["Squeeze","","1-12",$.squeeze,$.parseSqueezeAttributes],["Squeeze","","13+",$.squeezeV13],["Sub","","7+",s.sub],["Sum","","6+",P.sum],["Tan","","7+",C.tan],["Tanh","","6+",C.tanh],["Tile","","6+",D.tile],["Transpose","","1+",k.transpose,k.parseTransposeAttributes],["Upsample","","7-8",M.upsample,M.parseUpsampleAttributesV7],["Upsample","","9",M.upsample,M.parseUpsampleAttributesV9],["Unsqueeze","","1-12",R.unsqueeze,R.parseUnsqueezeAttributes],["Unsqueeze","","13+",R.unsqueezeV13],["Xor","","7+",s.xor]]},8817:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseBatchNormalizationAttributes=t.batchNormalization=void 0;const r=n(4910),o=n(6757),i=n(5639),a={name:"BatchNormalization",inputNames:["A","Scale","B","Mean","Variance"],inputTypes:[i.TextureType.unpacked,i.TextureType.unpacked,i.TextureType.unpacked,i.TextureType.unpacked,i.TextureType.unpacked]};t.batchNormalization=(e,t,n)=>(u(t),[e.run(Object.assign(Object.assign({},a),{cacheHint:n.cacheKey,get:()=>s(e,t,n)}),t)]),t.parseBatchNormalizationAttributes=e=>{const t=e.attributes.getFloat("epsilon",1e-5),n=e.attributes.getFloat("momentum",.9),o=e.attributes.getInt("spatial",1);return(0,r.createAttributeWithCacheKey)({epsilon:t,momentum:n,spatial:o})};const s=(e,t,n)=>{const r=(0,o.getGlsl)(e.session.backend.glContext.version),s=t[0].dims.length,[u,l]=e.calculateTextureWidthAndHeight(t[1].dims,i.TextureType.unpacked),c=`\n float process(int[${s}] indices) {\n vec2 position = offsetToCoords(indices[1], ${u}, ${l});\n float scale = getColorAsFloat(${r.texture2D}(Scale, position));\n float mean = getColorAsFloat(${r.texture2D}(Mean, position));\n float variance = getColorAsFloat(${r.texture2D}(Variance, position));\n float b = getColorAsFloat(${r.texture2D}(B, position));\n\n return scale * ( (_A(indices) - mean) / sqrt(variance + float(${n.epsilon})) ) + b;\n }`;return Object.assign(Object.assign({},a),{output:{dims:t[0].dims,type:t[0].type,textureType:i.TextureType.unpacked},shaderSource:c})},u=e=>{if(!e||5!==e.length)throw new Error("BatchNormalization requires 5 inputs.");const t=e[0],n=e[1],r=e[2],o=e[3],i=e[4];if(t.dims.length<3||1!==n.dims.length||1!==r.dims.length||1!==o.dims.length||1!==i.dims.length)throw new Error("invalid input shape.");if(n.dims[0]!==t.dims[1]||r.dims[0]!==t.dims[1]||o.dims[0]!==t.dims[1]||i.dims[0]!==t.dims[1])throw new Error("invalid input shape.");if("float32"!==t.type&&"float64"!==t.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==r.type&&"float64"!==r.type||"float32"!==o.type&&"float64"!==o.type||"float32"!==i.type&&"float64"!==i.type)throw new Error("invalid input tensor types.")}},5194:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.xor=t.sub=t.pRelu=t.pow=t.or=t.mul=t.less=t.greater=t.equal=t.div=t.and=t.add=t.glslPRelu=t.glslPow=t.glslXor=t.glslOr=t.glslAnd=t.glslLess=t.glslGreater=t.glslEqual=t.glslSub=t.glslMul=t.glslDiv=t.glslAdd=void 0;const r=n(7273),o=n(1997),i=n(6757),a=n(5639);function s(){const e="add_";return{body:`\n float ${e}(float a, float b) {\n return a + b;\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n return v1 + v2;\n }\n `,name:e,type:o.FunctionType.ValueBased}}function u(){const e="div_";return{body:`\n float ${e}(float a, float b) {\n return a / b;\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n return v1 / v2;\n }\n `,name:e,type:o.FunctionType.ValueBased}}function l(){const e="mul_";return{body:`\n float ${e}(float a, float b) {\n return a * b;\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n return v1 * v2;\n }\n `,name:e,type:o.FunctionType.ValueBased}}function c(){const e="sub_";return{body:`\n float ${e}(float a, float b) {\n return a - b;\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n return v1 - v2;\n }\n `,name:e,type:o.FunctionType.ValueBased}}function p(){const e="equal_";return{body:`\n float ${e}(float a, float b) {\n return float(a == b);\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n return vec4(equal(v1, v2));\n }\n `,name:e,type:o.FunctionType.ValueBased}}function d(){const e="greater_";return{body:`\n float ${e}(float a, float b) {\n return float(a > b);\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n return vec4( v1.r > v2.r ,\n v1.g > v2.g,\n v1.b > v2.b,\n v1.a > v2.a );\n }\n `,name:e,type:o.FunctionType.ValueBased}}function f(){const e="less_";return{body:`\n float ${e}(float a, float b) {\n return float(a < b);\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n return vec4( v1.r < v2.r ,\n v1.g < v2.g,\n v1.b < v2.b,\n v1.a < v2.a );\n }\n `,name:e,type:o.FunctionType.ValueBased}}function h(){const e="and_";return{body:`\n float ${e}(float a, float b) {\n return float( bool(a) && bool(b) );\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n bvec4 b1 = bvec4(v1);\n bvec4 b2 = bvec4(v2);\n return vec4( b1.r && b2.r ,\n b1.g && b2.g,\n b1.b && b2.b,\n b1.a && b2.a );\n }\n `,name:e,type:o.FunctionType.ValueBased}}function g(){const e="or_";return{body:`\n float ${e}(float a, float b) {\n return float( bool(a) || bool(b) );\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n bvec4 b1 = bvec4(v1);\n bvec4 b2 = bvec4(v2);\n return vec4( b1.r || b2.r ,\n b1.g || b2.g,\n b1.b || b2.b,\n b1.a || b2.a );\n }\n `,name:e,type:o.FunctionType.ValueBased}}function m(){const e="xor_";return{body:`\n float ${e}(float a, float b) {\n return float( bool(a) ^^ bool(b) );\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n bvec4 b1 = bvec4(v1);\n bvec4 b2 = bvec4(v2);\n return vec4( b1.r ^^ b2.r ,\n b1.g ^^ b2.g,\n b1.b ^^ b2.b,\n b1.a ^^ b2.a );\n }\n `,name:e,type:o.FunctionType.ValueBased}}function b(){return function(e){const t=`${e}_`;return{body:`\n float ${t}(float a, float b) {\n return ${e}(a, b);\n }\n vec4 ${t}(vec4 v1, vec4 v2) {\n return ${e}(v1, v2);\n }\n `,name:t,type:o.FunctionType.ValueBased}}("pow")}function y(){const e="prelu_";return{body:`\n float ${e}(float a, float b) {\n return a < 0.0 ? a * b: a;\n }\n vec4 ${e}(vec4 v1, vec4 v2) {\n return vec4(\n v1.r < 0.0 ? v1.r * v2.r: v1.r,\n v1.g < 0.0 ? v1.g * v2.g: v1.g,\n v1.b < 0.0 ? v1.b * v2.b: v1.b,\n v1.a < 0.0 ? v1.a * v2.a: v1.a\n );\n }\n `,name:e,type:o.FunctionType.ValueBased}}t.glslAdd=s,t.glslDiv=u,t.glslMul=l,t.glslSub=c,t.glslEqual=p,t.glslGreater=d,t.glslLess=f,t.glslAnd=h,t.glslOr=g,t.glslXor=m,t.glslPow=b,t.glslPRelu=y;const w=(e,t,n,r=t[0].type,o)=>{const i=e.session.pack?a.TextureType.packed:a.TextureType.unpacked;return{name:n.name,inputNames:["A","B"],inputTypes:[i,i],cacheHint:o,get:()=>_(e,t,n,r)}},_=(e,t,n,o=t[0].type)=>{const s=e.session.pack?a.TextureType.packed:a.TextureType.unpacked,u=!r.ShapeUtil.areEqual(t[0].dims,t[1].dims);let l=t[0].dims;const c=e.session.pack;if(u){const a=r.BroadcastUtil.calcShape(t[0].dims,t[1].dims,!1);if(!a)throw new Error("Can't perform binary op on the given tensors");l=a;const u=l.length,p=0!==t[0].dims.length?t[0].dims.length:1,d=0!==t[1].dims.length?t[1].dims.length:1,f=0!==t[0].dims.length?"bcastIndices_A(indices, aindices);":"aindices[0] = 0;",h=0!==t[1].dims.length?"bcastIndices_B(indices, bindices);":"bindices[0] = 0;",g=(0,i.getGlsl)(e.session.backend.glContext.version),m=c?`\n ${n.body}\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n vec4 result = ${n.name}(a, b);\n ${g.output} = result;\n }`:`\n ${n.body}\n float process(int indices[${u}]) {\n int aindices[${p}];\n int bindices[${d}];\n ${f}\n ${h}\n return ${n.name}(_A(aindices), _B(bindices));\n }`;return{name:n.name,inputNames:["A","B"],inputTypes:[s,s],output:{dims:l,type:o,textureType:s},shaderSource:m,hasMain:c}}const p=(0,i.getGlsl)(e.session.backend.glContext.version),d=`\n ${n.body}\n void main() {\n vec4 v1 = ${p.texture2D}(A, TexCoords);\n vec4 v2 = ${p.texture2D}(B, TexCoords);\n vec4 result = ${n.name}(v1, v2);\n ${p.output} = result;\n }\n `;return{name:n.name,inputNames:["A","B"],inputTypes:[s,s],output:{dims:t[0].dims,type:o,textureType:s},shaderSource:d,hasMain:!0}};t.add=(e,t)=>[e.run(w(e,t,s()),t)],t.and=(e,t)=>[e.run(w(e,t,h(),"bool"),t)],t.div=(e,t)=>[e.run(w(e,t,u()),t)],t.equal=(e,t)=>[e.run(w(e,t,p(),"bool"),t)],t.greater=(e,t)=>[e.run(w(e,t,d(),"bool"),t)],t.less=(e,t)=>[e.run(w(e,t,f(),"bool"),t)],t.mul=(e,t)=>[e.run(w(e,t,l()),t)],t.or=(e,t)=>[e.run(w(e,t,g(),"bool"),t)],t.pow=(e,t)=>[e.run(w(e,t,b()),t)],t.pRelu=(e,t)=>[e.run(w(e,t,y()),t)],t.sub=(e,t)=>[e.run(w(e,t,c()),t)],t.xor=(e,t)=>[e.run(w(e,t,m(),"bool"),t)]},4752:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseCastAttributes=t.cast=void 0;const r=n(7273);t.cast=(e,t,n)=>(o(t),[e.cast(t[0],n)]),t.parseCastAttributes=e=>r.ProtoUtil.tensorDataTypeFromProto(e.attributes.getInt("to"));const o=e=>{if(!e||1!==e.length)throw new Error("Cast requires 1 input.");if("string"===e[0].type)throw new Error("Invalid input type.")}},4595:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedConcatProgramInfoLoader=void 0;const r=n(6757),o=n(5639),i=n(432),a=n(5614);t.createPackedConcatProgramInfoLoader=(e,t,n)=>{const u=(l=t.length,c=n.cacheKey,{name:"Concat (packed)",inputNames:Array.from({length:l},((e,t)=>`X${t}`)),inputTypes:Array(l).fill(o.TextureType.packed),cacheHint:c});var l,c;return Object.assign(Object.assign({},u),{get:()=>((e,t,n,u)=>{const l=n[0].dims.slice();if(u>=l.length||u<-1*l.length)throw new Error("axis specified for concat doesn't match input dimensionality");u<0&&(u=l.length+u);const c=l.slice(0);for(let e=1;ee.dims)),m=(0,i.getGlChannels)(p),b=new Array(g.length-1);b[0]=g[0][u];for(let e=1;e= ${b[e-1]}) {\n return getChannel(\n getX${e}(${s(m,y,t)}),\n vec2(${s(w,y,t)}));\n }`}const x=b.length,T=b[b.length-1];v+=`\n return getChannel(\n getX${x}(${s(m,y,T)}),\n vec2(${s(w,y,T)}));`;const S=(0,r.getGlsl)(e.session.backend.glContext.version),O=`\n ${h}\n float getValue(${m.map((e=>"int "+e))}) {\n ${v}\n }\n\n void main() {\n ${f} coords = getOutputCoords();\n int lastDim = coords.${m[p-1]};\n coords.${m[p-1]} = coords.${m[p-2]};\n coords.${m[p-2]} = lastDim;\n\n vec4 result = vec4(getValue(${d}), 0., 0., 0.);\n\n ${d[p-1]} = ${d[p-1]} + 1;\n if (${d[p-1]} < ${c[p-1]}) {\n result.g = getValue(${d});\n }\n\n ${d[p-2]} = ${d[p-2]} + 1;\n if (${d[p-2]} < ${c[p-2]}) {\n result.a = getValue(${d});\n }\n\n ${d[p-1]} = ${d[p-1]} - 1;\n if (${d[p-2]} < ${c[p-2]} &&\n ${d[p-1]} < ${c[p-1]}) {\n result.b = getValue(${d});\n }\n ${S.output} = result;\n }\n `;return Object.assign(Object.assign({},t),{output:{dims:c,type:n[0].type,textureType:o.TextureType.packed},shaderSource:O,hasMain:!0})})(e,u,t,n.axis)})};const s=(e,t,n)=>{const r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}},6668:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseConcatAttributes=t.concat=void 0;const r=n(4910),o=n(5639),i=n(4595);t.concat=(e,t,n)=>(p(t),e.session.pack&&t[0].dims.length>1?[e.run((0,i.createPackedConcatProgramInfoLoader)(e,t,n),t)]:[e.run(a(e,t,n),t)]);const a=(e,t,n)=>{const r=(i=t.length,a=n.cacheKey,{name:"Concat",inputNames:Array.from({length:i},((e,t)=>`X${t}`)),inputTypes:Array(i).fill(o.TextureType.unpacked),cacheHint:a});var i,a;return Object.assign(Object.assign({},r),{get:()=>((e,t,n,r)=>{const i=n[0].dims.slice();if(r>=i.length||r<-1*i.length)throw new Error("axis specified for concat doesn't match input dimensionality");r<0&&(r=i.length+r);const a=i.slice(0);for(let e=1;e`int getTextureWhereDataResides(int index) {\n ${e.map(((e,t)=>`if(index<${e}) {return ${t};}\n`)).join("")}\n }`,u=e=>s(e),l=(e,t)=>{const n=[`float fetchDataFromCorrectTexture(int textureIndex, int indices[${t}]) {`];for(let t=0;t{const t=["int getSizeInConcatAxisValueFromIndex(int index) {"];for(let n=0;n(0,r.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis")});const p=e=>{if(!e||e.length<1)throw new Error("too few inputs");const t=e[0].type,n=e[0].dims.length;if("string"===t)throw new Error("string tensor is not supported yet");for(const r of e){if(r.type!==t)throw new Error("input tensors should be one type");if(r.dims.length!==n)throw new Error("input tensors should have the same shape")}}},7825:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createUnpackedGroupedConvProgramInfoLoader=void 0;const r=n(1315),o=n(6757),i=n(5639),a=n(9754),s=n(2150);t.createUnpackedGroupedConvProgramInfoLoader=(e,t,n)=>{const u=(l=t.length>2,c=n.cacheKey,{name:"GroupedConv",inputNames:l?["X","W","Bias"]:["X","W"],inputTypes:l?[i.TextureType.unpacked,i.TextureType.unpacked,i.TextureType.unpacked]:[i.TextureType.unpacked,i.TextureType.unpacked],cacheHint:c});var l,c;return Object.assign(Object.assign({},u),{get:()=>((e,t,n,u)=>{const l=t.length>2?"value += getBias(output_channel);":"",c=t[0].dims.slice(),p=t[1].dims.slice(),d=p[0]/u.group;r.Logger.verbose("GroupedConv",`autpPad:${u.autoPad}, dilations:${u.dilations}, group:${u.group}, kernelShape:${u.kernelShape}, pads:${u.pads}, strides:${u.strides}`);const f=(0,a.calculateOutputShape)(c,p,u.dilations,u.pads,u.strides),h=(0,o.getGlsl)(e.session.backend.glContext.version),{activationFunction:g,applyActivation:m}=(0,s.getActivationSnippet)(u),b=`\n const ivec2 strides = ivec2(${u.strides[0]}, ${u.strides[1]});\n const ivec2 pads = ivec2(${u.pads[0]}, ${u.pads[1]});\n ${g}\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int output_channel = coords.y;\n ivec2 xRCCorner = coords.zw * strides - pads;\n int group_id = output_channel / ${d};\n\n float value = 0.0;\n for (int wInChannel = 0; wInChannel < ${p[1]}; wInChannel++) {\n int input_channel = group_id * ${p[1]} + wInChannel;\n for (int wHeight = 0; wHeight < ${p[2]}; wHeight++) {\n int xHeight = xRCCorner.x + wHeight * ${u.dilations[0]};\n\n if (xHeight < 0 || xHeight >= ${c[2]}) {\n continue;\n }\n\n for (int wWidth = 0; wWidth < ${p[3]}; wWidth++) {\n int xWidth = xRCCorner.y + wWidth * ${u.dilations[1]};\n if (xWidth < 0 || xWidth >= ${c[3]}) {\n continue;\n }\n\n float xVal = getX(batch, input_channel, xWidth, xHeight);\n float wVal = getW(output_channel, wInChannel, wWidth, wHeight);\n value += xVal*wVal;\n }\n }\n }\n ${l}\n ${m}\n ${h.output} = vec4(value, .0, .0, .0);\n }\n`;return Object.assign(Object.assign({},n),{output:{dims:f,type:t[0].type,textureType:i.TextureType.unpacked},shaderSource:b,hasMain:!0})})(e,t,u,n)})}},7708:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.conv2DPacked=t.conv2DPackedPointwise=void 0;const r=n(9754),o=n(5950),i=n(5632);t.conv2DPackedPointwise=(e,t,n)=>{const o=t[0].dims,a=t[1].dims,s=(0,r.calculateOutputShape)(o,a,n.dilations,n.pads,n.strides),u=e.reshapePacked(t[0],[o[1],o[2]*o[3]]),l=e.reshapePacked(t[1],[a[0],a[1]]),c=t.length>2?[l,u,t[2]]:[l,u],p=e.run((0,i.createPackedMatmulProgramInfoLoader)(e,c,n),c);return e.reshapePacked(p,s)},t.conv2DPacked=(e,t,n)=>{const a=t[0].dims,s=t[1].dims,u=(0,r.calculateOutputShape)(a,s,n.dilations,n.pads,n.strides),l=e.run((0,o.createPackedIm2ColProgramInfoLoader)(e,t[0],t[1],u,n),[t[0]]),c=e.reshapePacked(t[1],[s[0],s[1]*s[2]*s[3]]),p=3===t.length?[c,l,t[2]]:[c,l],d=e.run((0,i.createPackedMatmulProgramInfoLoader)(e,p,n),p);return e.reshapePacked(d,u)}},5042:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseConvTransposeAttributes=t.convTranspose=void 0;const r=n(4910),o=n(6757),i=n(5639),a=n(2150),s=(e,t,n,r,o,i)=>(e-1)*t+n+(r-1)*o+1-i,u=(e,t,n,r,o)=>{const i=Math.floor(e/2);"SAME_UPPER"===t?(n[r]=i,n[o]=e-i):"SAME_LOWER"===t&&(n[r]=e-i,n[o]=i)};t.convTranspose=(e,t,n)=>(d(t,n),l(e,t,n));const l=(e,t,n)=>{const r=p(n,t);return[c(e,t,r)]},c=(e,t,n)=>e.run(((e,t,n)=>{const r=(s=t.length>2,u=n.cacheKey,{name:"ConvTranspose",inputNames:s?["X","W","B"]:["X","W"],inputTypes:s?[i.TextureType.unpacked,i.TextureType.unpacked,i.TextureType.unpacked]:[i.TextureType.unpacked,i.TextureType.unpacked],cacheHint:u});var s,u;return Object.assign(Object.assign({},r),{get:()=>((e,t,n,r)=>{const s=t.length>2?"getB(output_channel)":"0.0",u=t[0].dims,l=t[1].dims,c=l[1],p=l[0]/r.group,d=[t[0].dims[0],t[1].dims[1]*r.group,...r.outputShape],f=(0,o.getGlsl)(e.session.backend.glContext.version),{activationFunction:h,applyActivation:g}=(0,a.getActivationSnippet)(r),m=`\n const ivec2 strides = ivec2(${r.strides[0]}, ${r.strides[1]});\n const ivec2 pads = ivec2(${r.pads[0]}, ${r.pads[1]});\n ${h}\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int output_channel = coords.y;\n\n ivec2 loc = coords.zw + pads;\n\n int group_id = output_channel / ${c};\n int wOutChannel = output_channel - group_id * ${c};\n\n float value = ${s};\n for (int inChannelOffset = 0; inChannelOffset < ${p}; inChannelOffset++) {\n int input_channel = group_id * ${p} + inChannelOffset;\n for (int wWOff = 0; wWOff < ${l[2]}; wWOff++) {\n for (int wHOff = 0; wHOff < ${l[3]}; wHOff++) {\n ivec2 wOff = ivec2(wWOff * ${r.dilations[0]}, wHOff * ${r.dilations[1]});\n ivec2 wLoc = loc - wOff;\n ivec2 wLocIn = wLoc / strides;\n if (\n wLocIn * strides == wLoc &&\n wLocIn.x >= 0 && wLocIn.x < ${u[2]} &&\n wLocIn.y >= 0 && wLocIn.y < ${u[3]}\n ) {\n float xVal = getX(batch, input_channel, wLocIn.y, wLocIn.x);\n float wVal = getW(input_channel, wOutChannel, wHOff, wWOff);\n value += xVal * wVal;\n }\n }\n }\n }\n ${g}\n ${f.output} = vec4(value, .0, .0, .0);\n }\n`;return Object.assign(Object.assign({},n),{output:{dims:d,type:t[0].type,textureType:i.TextureType.unpacked},shaderSource:m,hasMain:!0})})(e,t,r,n)})})(e,t,n),t),p=(e,t)=>{const n=e.kernelShape.slice();if(0===e.kernelShape.length)for(let e=2;e{const c=e.length-2,p=0===l.length;for(let d=0;d{const t=e.attributes,n=(0,a.parseInternalActivationAttributes)(t),o=t.getString("auto_pad","NOTSET"),i=t.getInts("dilations",[1,1]),s=t.getInt("group",1),u=t.getInts("kernel_shape",[]),l=t.getInts("output_padding",[0,0]),c=t.getInts("output_shape",[]),p=t.getInts("pads",[0,0,0,0]),d=t.getInts("strides",[1,1]);return(0,r.createAttributeWithCacheKey)(Object.assign({autoPad:o,dilations:i,group:s,kernelShape:u,outputPadding:l,outputShape:c,pads:p,strides:d},n))};const d=(e,t)=>{if(!e||2!==e.length&&3!==e.length)throw new Error("Conv requires 2 or 3 inputs");if(4!==e[0].dims.length||4!==e[1].dims.length)throw new Error("currently only support 2-dimensional conv");if(e[0].dims[1]!==e[1].dims[0])throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");const n=e[1].dims[1]*t.group;if(3===e.length&&(1!==e[2].dims.length||e[2].dims[0]!==n))throw new Error("invalid bias");const r=e[0].dims.length-2;if(t.dilations.length!==r)throw new Error(`dilations should be ${r}D`);if(t.strides.length!==r)throw new Error(`strides should be ${r}D`);if(t.pads.length!==2*r)throw new Error(`pads should be ${2*r}D`);if(t.outputPadding.length!==r)throw new Error(`output_padding should be ${r}D`);if(0!==t.kernelShape.length&&t.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(0!==t.outputShape.length&&t.outputShape.length!==e[0].dims.length-2)throw new Error("invalid output shape");if("float32"!==e[0].type||"float32"!==e[1].type)throw new Error("ConvTranspose input(X,W) should be float tensor");if(3===e.length&&"float32"!==e[2].type)throw new Error("ConvTranspose input(bias) should be float tensor")}},9754:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseConvAttributes=t.conv=t.calculateOutputShape=void 0;const r=n(4910),o=n(7273),i=n(7825),a=n(7708),s=n(3281),u=n(2150),l=n(1625),c=n(8276);t.calculateOutputShape=(e,t,n,r,o)=>{const i=e[0],a=e.slice(2),s=a.length,u=t[0],l=t.slice(2).map(((e,t)=>e+(e-1)*(n[t]-1))),c=a.map(((e,t)=>e+r[t]+r[t+s])).map(((e,t)=>Math.floor((e-l[t]+o[t])/o[t])));return[i,u].concat(...c)},t.conv=(e,t,n)=>(g(t,n),p(e,t,n));const p=(e,t,n)=>{const r=h(n,t),o=e.session.pack,s=1===r.kernelShape[0]&&1===r.kernelShape[1];return r.group>1?[e.run((0,i.createUnpackedGroupedConvProgramInfoLoader)(e,t,r),t)]:s&&o?[d(e,t,r)]:o&&4===t[0].dims.length&&1===t[0].dims[0]&&!s?[(0,a.conv2DPacked)(e,t,r)]:[f(e,t,r)]},d=(e,n,r)=>{const o=n[0].dims,i=n[1].dims,a=(0,t.calculateOutputShape)(o,i,r.dilations,r.pads,r.strides),s=e.reshapeUnpacked(n[0],[o[1],o[2]*o[3]]),u=e.reshapeUnpacked(n[1],[i[0],i[1]]),l=n.length>2?[u,s,n[2]]:[u,s],p=e.run((0,c.createMatmulProgramInfoLoader)(l,r),l);return e.reshapeUnpacked(p,a)},f=(e,n,r)=>{const o=n[0].dims,i=n[1].dims,a=(0,t.calculateOutputShape)(o,i,r.dilations,r.pads,r.strides),u=e.run((0,l.createIm2ColProgramInfoLoader)(e,n[0],n[1],a,r),[n[0]]),c=3===n.length?[u,n[1],n[2]]:[u,n[1]];return e.run((0,s.createDotProductProgramInfoLoader)(e,n,a,r),c)},h=(e,t)=>{const n=e.kernelShape.slice();if(0===e.kernelShape.length)for(let e=2;e{const t=e.attributes,n=(0,u.parseInternalActivationAttributes)(t),o=t.getString("auto_pad","NOTSET"),i=t.getInts("dilations",[1,1]),a=t.getInt("group",1),s=t.getInts("kernel_shape",[]),l=t.getInts("pads",[0,0,0,0]),c=t.getInts("strides",[1,1]);return(0,r.createAttributeWithCacheKey)(Object.assign({autoPad:o,dilations:i,group:a,kernelShape:s,pads:l,strides:c},n))};const g=(e,t)=>{if(!e||2!==e.length&&3!==e.length)throw new Error("Conv requires 2 or 3 inputs");if(4!==e[0].dims.length||4!==e[1].dims.length)throw new Error("currently only support 2-dimensional conv");if(e[0].dims[1]!==e[1].dims[1]*t.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(3===e.length&&(1!==e[2].dims.length||e[1].dims[0]!==e[2].dims[0]))throw new Error("invalid bias");const n=e[0].dims.length-2;if(t.dilations.length!==n)throw new Error(`dilations should be ${n}D`);if(t.strides.length!==n)throw new Error(`strides should be ${n}D`);if(t.pads.length!==2*n)throw new Error(`pads should be ${2*n}D`);if(0!==t.kernelShape.length&&t.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if("float32"!==e[0].type||"float32"!==e[1].type)throw new Error("Conv input(X,W) should be float tensor");if(3===e.length&&"float32"!==e[2].type)throw new Error("Conv input(bias) should be float tensor")}},6742:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseDepthToSpaceAttributes=t.depthToSpace=void 0;const r=n(5707);t.depthToSpace=(e,t,n)=>{o(t);const i=n.blocksize,a=i*i,s="DCR"===n.mode?[0,3,4,1,5,2]:[0,1,4,2,5,3],u="DCR"===n.mode?[t[0].dims[0],i,i,t[0].dims[1]/a,t[0].dims[2],t[0].dims[3]]:[t[0].dims[0],t[0].dims[1]/a,i,i,t[0].dims[2],t[0].dims[3]],l=e.reshapeUnpacked(t[0],u),c={perm:s,cacheKey:`${s}`},[p]=(0,r.transpose)(e,[l],c),d=[t[0].dims[0],t[0].dims[1]/a,t[0].dims[2]*i,t[0].dims[3]*i];return[e.reshapeUnpacked(p,d)]},t.parseDepthToSpaceAttributes=e=>{const t=e.attributes.getInt("blocksize");if(t<1)throw new Error(`blocksize must be >= 1, but got : ${t} for DepthToSpace`);const n=e.attributes.getString("mode","DCR");if("DCR"!==n&&"CRD"!==n)throw new Error(`unrecognized mode: ${n} for DepthToSpace`);return{mode:n,blocksize:t}};const o=e=>{if(1!==e.length)throw new Error(`DepthToSpace expect 1 inputs, but got ${e.length}`);if("string"===e[0].type||4!==e[0].dims.length)throw new TypeError("DepthToSpace input should be a 4-D numeric tensor")}},3281:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createDotProductProgramInfoLoader=void 0;const r=n(7273),o=n(6757),i=n(5639),a=n(2150),s=n(1625);t.createDotProductProgramInfoLoader=(e,t,n,u)=>{const l=((e,t)=>({name:"ConvDotProduct",inputNames:e?["Im2Col","K","B"]:["Im2Col","K"],inputTypes:e?[i.TextureType.unpacked,i.TextureType.packedLastDimension,i.TextureType.unpacked]:[i.TextureType.unpacked,i.TextureType.packedLastDimension],cacheKey:t.activationCacheKey}))(t.length>2,u);return Object.assign(Object.assign({},l),{get:()=>((e,t,n,u,l)=>{const c=n[0].dims,p=n[1].dims,d=[p[0],Math.ceil(c[1]*p[2]*p[3]/4)],f=(0,s.calculateIm2ColDims)(c,p,u),[h,g]=e.calculateTextureWidthAndHeight(d,i.TextureType.packedLastDimension),m=r.ShapeUtil.computeStrides(f),[b,y]=e.calculateTextureWidthAndHeight(f,i.TextureType.packedLastDimension),w=u.length,_=n.length<3?"0.0":"_B(b)",v=Math.ceil(c[1]*p[2]*p[3]/4),{activationFunction:x,applyActivation:T}=(0,a.getActivationSnippet)(l),S=(0,o.getGlsl)(e.session.backend.glContext.version),O=`\n${x}\nfloat process(int indices[${w}]) {\n int b[1];\n b[0] = indices[1];\n int im2col[4];\n im2col[0] = indices[0];\n im2col[1] = indices[2];\n im2col[2] = indices[3];\n int im2colOffset = im2col[0] * ${m[0]} + im2col[1] * ${m[1]} + im2col[2] * ${m[2]};\n int kernelOffset = indices[1] * ${d[1]};\n float value = ${_};\n for (int i = 0; i < ${v}; ++i) {\n vec2 im2colCoords = offsetToCoords(im2colOffset, ${b}, ${y});\n vec2 kernelCoords = offsetToCoords(kernelOffset, ${h}, ${g});\n value += dot(${S.texture2D}(Im2Col, im2colCoords), ${S.texture2D}(K, kernelCoords));\n ++im2colOffset;\n ++kernelOffset;\n }\n ${T}\n return value;\n}`;return Object.assign(Object.assign({},t),{output:{dims:u,type:n[0].type,textureType:i.TextureType.unpacked},shaderSource:O})})(e,l,t,n,u)})}},4125:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseFlattenAttributes=t.flatten=void 0;const r=n(7273);t.flatten=(e,t,n)=>{o(t,n);const i=r.ShapeUtil.flattenShape(t[0].dims,n);return[e.reshapeUnpacked(t[0],i)]},t.parseFlattenAttributes=e=>e.attributes.getInt("axis",1);const o=(e,t)=>{if(!e||1!==e.length)throw new Error("Flatten requires 1 input.");const n=e[0].dims.length;if(0===n)throw new Error("scalar tensor is not supported.");if(t<-n||t>n)throw new Error("Invalid axis");if("string"===e[0].type)throw new Error("string tensor is not supported.")}},2150:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseInternalActivationAttributes=t.getActivationSnippet=void 0;const r=n(7273),o=n(9087);t.getActivationSnippet=function(e){let t;switch(e.activation){case"Relu":t=(0,o.glslRelu)();break;case"Sigmoid":t=(0,o.glslSigmoid)();break;case"Clip":t=(0,o.glslClip)(e.clipMin,e.clipMax);break;default:return{activationFunction:"",applyActivation:""}}const n=t.name;return{activationFunction:t.body,applyActivation:`value = ${n}_(value);`}},t.parseInternalActivationAttributes=e=>{const t=e.getString("activation","");if("Clip"===t){const[n,o]=e.getFloats("activation_params",[r.MIN_CLIP,r.MAX_CLIP]);return{activation:t,clipMax:o,clipMin:n,activationCacheKey:`${t}:${n},${o}`}}return{activation:t,activationCacheKey:t}}},6149:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseGatherAttributes=t.gather=void 0;const r=n(4910),o=n(6145),i=n(7273),a=n(5639);t.gather=(e,t,n)=>(l(t,n.axis),[e.run(u(e,t,n),t)]),t.parseGatherAttributes=e=>(0,r.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis",0)});const s={name:"Gather",inputNames:["A","B"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked]},u=(e,t,n)=>{const r=Object.assign(Object.assign({},s),{cacheHint:n.cacheKey});return Object.assign(Object.assign({},r),{get:()=>((e,t,n,r)=>{const o=n[0].dims.slice(),s=n[1].dims.slice(),u=new Array(o.length+s.length-1);r=i.ShapeUtil.normalizeAxis(r,o.length);const l=[];for(let e=0;e{if(!e||2!==e.length)throw new Error("Gather requires 2 inputs.");const n=e[0].dims.length;if(n<1)throw new Error("Invalid input shape.");if(t<-n||t>n-1)throw new Error("Invalid axis.");if(-1===o.NUMBER_TYPES.indexOf(e[0].type))throw new Error("Invaid input type.");if("int32"!==e[1].type&&"int16"!==e[1].type)throw new Error("Invaid input type.")}},5378:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseGemmAttributesV11=t.parseGemmAttributesV7=t.gemm=void 0;const r=n(4910),o=n(7273),i=n(5639);t.gemm=(e,t,n)=>(l(t,n),[e.run(s(t,n),t)]);const a=(e,t)=>{const n=0!==e.attributes.getInt("transA",0),o=0!==e.attributes.getInt("transB",0),i=e.attributes.getFloat("alpha",1),a=e.attributes.getFloat("beta",1);return(0,r.createAttributeWithCacheKey)({transA:n,transB:o,alpha:i,beta:a,isOptionalC:t})};t.parseGemmAttributesV7=e=>a(e,!1),t.parseGemmAttributesV11=e=>a(e,!0);const s=(e,t)=>{const n={name:"Gemm",inputNames:3===e.length?["A","B","C"]:["A","B"],inputTypes:3===e.length?[i.TextureType.unpacked,i.TextureType.unpacked,i.TextureType.unpacked]:[i.TextureType.unpacked,i.TextureType.unpacked],key:t.cacheKey};return Object.assign(Object.assign({},n),{get:()=>u(n,e,t)})},u=(e,t,n)=>{const r=t[0].dims.slice(),a=t[1].dims.slice(),[s,u]=o.GemmUtil.getShapeOfGemmResult(r,n.transA,a,n.transB,3===t.length?t[2].dims:void 0),l=[s,u];if(!l)throw new Error("Can't use gemm on the given tensors");let c=r[r.length-1],p="";n.transA&&(c=r[0]),n.transA&&n.transB?p="value += _A_T(a) * _B_T(b);":n.transA&&!n.transB?p="value += _A_T(a) * _B(b);":!n.transA&&n.transB?p="value += _A(a) * _B_T(b);":n.transA||n.transB||(p="value += _A(a) * _B(b);");const d=l.length,f=`\n float process(int indices[${d}]) {\n int a[${d}];\n int b[${d}];\n ${3===t.length?`int c[${t[2].dims.length}];`:""}\n\n copyVec(indices, a);\n copyVec(indices, b);\n ${3===t.length?"bcastIndices_C(indices, c);":""}\n\n float value = 0.0;\n for (int k=0; k<${c}; ++k) {\n a[${d-1}] = k;\n b[${d-2}] = k;\n ${p}\n }\n\n value = value * alpha;\n ${3===t.length?"value += beta * _C(c);":""}\n return value;\n }`;return Object.assign(Object.assign({},e),{output:{dims:l,type:t[0].type,textureType:i.TextureType.unpacked},variables:[{name:"alpha",type:"float",data:n.alpha},{name:"beta",type:"float",data:n.beta}],shaderSource:f})},l=(e,t)=>{if(!e)throw new Error("Input is missing");if(t.isOptionalC&&(e.length<2||e.length>3))throw new Error("Invaid input shape.");if(!t.isOptionalC&&3!==e.length)throw new Error("Gemm requires 3 inputs");if(3===e.length&&1!==e[2].dims.length&&2!==e[2].dims.length)throw new Error("Invalid input shape of C");if("float32"!==e[0].type&&"float64"!==e[0].type||"float32"!==e[1].type&&"float64"!==e[1].type||3===e.length&&"float32"!==e[2].type&&"float64"!==e[2].type)throw new Error("Invalid input type.");if(e[0].type!==e[1].type||3===e.length&&e[0].type!==e[2].type)throw new Error("Input types are mismatched")}},5950:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedIm2ColProgramInfoLoader=void 0;const r=n(6757),o=n(5639),i=n(5614);t.createPackedIm2ColProgramInfoLoader=(e,t,n,a,s)=>{const u=(l=s.cacheKey,{name:"Im2Col (packed)",inputNames:["A"],inputTypes:[o.TextureType.packed],cacheHint:l});var l;return Object.assign(Object.assign({},u),{get:()=>((e,t,n,a,s,u)=>{const l=n.dims,c=a.dims,p=s.length,d=[c[1]*c[2]*c[3],s[2]*s[3]],f=c[2]*c[3],h=(0,i.unpackFromChannel)(),g=(0,r.getGlsl)(e.session.backend.glContext.version);let m="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)m+=`\n blockIndex = rc.x + ${t};\n pos = rc.y + ${e};\n\n if(blockIndex < ${d[1]} && pos < ${d[0]}) {\n offsetY = int(blockIndex / (${s[p-1]})) * ${u.strides[0]} -\n ${u.pads[0]};\n d0 = offsetY + ${u.dilations[0]} * (imod(pos, ${f}) / ${c[2]});\n\n if(d0 < ${l[2]} && d0 >= 0) {\n offsetX = imod(blockIndex, ${s[p-1]}) * ${u.strides[1]} -\n ${u.pads[1]};\n d1 = offsetX + ${u.dilations[1]} * imod(imod(pos, ${f}), ${c[2]});\n\n if(d1 < ${l[3]} && d1 >= 0) {\n\n ch = int(float(pos)/ ${f}.);\n innerDims = vec2(d0, d1);\n result[${2*e+t}] = getChannel(\n getA(0, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n\n `;const b=`\n ${h}\n\n void main() {\n ivec2 rc = getOutputCoords();\n vec4 result = vec4(0.0);\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n ${m}\n ${g.output} = result;\n }\n `;return Object.assign(Object.assign({},t),{output:{dims:d,type:n.type,textureType:o.TextureType.packed},shaderSource:b,hasMain:!0})})(e,u,t,n,a,s)})}},1625:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calculateIm2ColDims=t.createIm2ColProgramInfoLoader=void 0;const r=n(5639);t.createIm2ColProgramInfoLoader=(e,n,o,i,a)=>{const s=(u=a.cacheKey,{name:"Im2Col",inputNames:["X"],inputTypes:[r.TextureType.unpacked],cacheHint:u});var u;return Object.assign(Object.assign({},s),{get:()=>((e,n,o,i,a,s)=>{const u=o.dims,l=i.dims,c=a.length,p=(0,t.calculateIm2ColDims)(u,l,a,4),d=`\n const int XC = ${u[1]};\n const int XH = ${u[2]};\n const int XW = ${u[3]};\n const int KH = ${s.kernelShape[0]};\n const int KW = ${s.kernelShape[1]};\n const int dilationH = ${s.dilations[0]};\n const int dilationW = ${s.dilations[1]};\n const int strideH = ${s.strides[0]};\n const int strideW = ${s.strides[1]};\n const int padH = ${s.pads[0]};\n const int padW = ${s.pads[1]};\n const int KHKW = KH*KW;\n const int XCKHKW = XC * KHKW;\n const int outputChannels = 4;\n vec4 process(int indices[${c}]) {\n int b = indices[0]; // batch size\n int oh = indices[1] * strideH - padH; //output height\n int ow = indices[2] * strideW - padW; //output width\n int p = indices[3] * outputChannels; //patch\n vec4 value = vec4(0.0);\n for(int i=0; i < outputChannels; ++i) {\n if(p < XCKHKW) {\n int patchC = p / KHKW;\n int patchH = (p - patchC*KHKW) / KW;\n int patchW = (p - patchC*KHKW) - patchH * KW;\n int xh2 = oh + patchH * dilationH;\n int xw2 = ow + patchW * dilationW;\n int x[${u.length}];\n x[0] = b;\n x[1] = patchC;\n x[2] = xh2;\n x[3] = xw2;\n if(xh2 >= 0 &&\n xh2 < XH &&\n xw2 >= 0 &&\n xw2 < XW) {\n value[i] = _X(x);\n }\n }\n ++p;\n }\n return value;\n }\n `;return Object.assign(Object.assign({},n),{output:{dims:p,type:o.type,textureType:r.TextureType.packedLastDimension},shaderSource:d})})(0,s,n,o,i,a)})},t.calculateIm2ColDims=(e,t,n,r=4)=>[n[0],n[2],n[3],Math.ceil(e[1]*t[2]*t[3]/r)]},6981:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseImageScalerAttributes=t.imageScaler=void 0;const r=n(4910),o=n(5639);t.imageScaler=(e,t,n)=>(u(t),[e.run(a(e,t,n),t)]),t.parseImageScalerAttributes=e=>{const t=e.attributes.getFloat("scale"),n=e.attributes.getFloats("bias");return(0,r.createAttributeWithCacheKey)({scale:t,bias:n})};const i={name:"ImageScaler",inputNames:["X"],inputTypes:[o.TextureType.unpacked]},a=(e,t,n)=>{const r=Object.assign(Object.assign({},i),{cacheHint:n.cacheKey});return Object.assign(Object.assign({},r),{get:()=>((e,t,n,r)=>{const i=n[0].dims.slice(),a=i.length,u=`\n ${s(r.bias.length)}\n float process(int indices[${a}]) {\n return _X(indices) * scale + getBias(bias, indices[1]);\n }`;return Object.assign(Object.assign({},t),{output:{dims:i,type:n[0].type,textureType:o.TextureType.unpacked},variables:[{name:"bias",type:"float",arrayLength:r.bias.length,data:r.bias},{name:"scale",type:"float",data:r.scale}],shaderSource:u})})(0,r,t,n)})},s=e=>{const t=[`float getBias(float bias[${e}], int channel) {`];for(let n=0;n{if(!e||1!==e.length)throw new Error("ImageScaler requires 1 input.");if(4!==e[0].dims.length)throw new Error("Invalid input shape.");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type.")}},7413:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseInstanceNormalizationAttributes=t.instanceNormalization=void 0;const r=n(6757),o=n(5639);t.instanceNormalization=(e,t,n)=>{l(t);const r=e.run(a(t[0]),t);return[e.run(u(e,t[0],n,r.dims),[t[0],r,t[1],t[2]])]},t.parseInstanceNormalizationAttributes=e=>e.attributes.getFloat("epsilon",1e-5);const i={name:"InstanceNormalization_MeanAndVariance",inputNames:["X"],inputTypes:[o.TextureType.unpacked]},a=e=>Object.assign(Object.assign({},i),{get:()=>((e,t)=>{const n=t.dims.slice(),r=n[1],i=n[2]*n[3],a=[n[0],r],s=`\n vec4 process(int[2] indices) {\n vec4 v = vec4(0.0);\n int a[4];\n a[0] = indices[0];\n a[1] = indices[1];\n float temp = 0.0;\n for(int a2=0; a2<${n[2]}; a2++) {\n a[2] = a2;\n for(int a3=0; a3<${n[3]}; a3++) {\n a[3] = a3;\n float x = _X(a);\n temp += x;\n }\n }\n float mean = temp / float(${i});\n temp = 0.0;\n for(int a2=0; a2<${n[2]}; a2++) {\n a[2] = a2;\n for(int a3=0; a3<${n[3]}; a3++) {\n a[3] = a3;\n float x = _X(a);\n temp += (x - mean) * (x - mean);\n }\n }\n v.r = mean;\n v.g = temp / float(${i});\n\n return v;\n }`;return Object.assign(Object.assign({},e),{output:{dims:a,type:t.type,textureType:o.TextureType.packedLastDimension},shaderSource:s})})(i,e)}),s={name:"InstanceNormalization_ComputeOutput",inputNames:["X","MeanAndVariance","Scale","B"],inputTypes:[o.TextureType.unpacked,o.TextureType.packedLastDimension,o.TextureType.unpacked,o.TextureType.unpacked]},u=(e,t,n,i)=>{const a=Object.assign(Object.assign({},s),{cacheHint:`${n}`});return Object.assign(Object.assign({},a),{get:()=>((e,t,n,i,a)=>{const s=(0,r.getGlsl)(e.session.backend.glContext.version),[u,l]=e.calculateTextureWidthAndHeight(a,o.TextureType.packedLastDimension),[c,p]=[u/4,l],d=`\n vec4 get_MeanAndVariance(int[2] mv) {\n int offset = indicesToOffset_MeanAndVariance(mv);\n vec2 coords = offsetToCoords(offset, ${c}, ${p});\n return ${s.texture2D}(MeanAndVariance, coords);\n }\n\n float process(int[4] indices) {\n int mv[2];\n mv[0] = indices[0];\n mv[1] = indices[1];\n vec4 mean_and_variance = get_MeanAndVariance(mv);\n float mean = mean_and_variance.r;\n float variance = mean_and_variance.g;\n\n int sb[1];\n sb[0] = indices[1];\n float scale = _Scale(sb);\n float b = _B(sb);\n\n return scale * (_X(indices) - mean) / sqrt(variance + epsilon) + b;\n }`;return Object.assign(Object.assign({},t),{output:{dims:n.dims,type:n.type,textureType:o.TextureType.unpacked},variables:[{name:"epsilon",type:"float",data:i}],shaderSource:d})})(e,a,t,n,i)})},l=e=>{if(!e||3!==e.length)throw new Error("InstanceNormalization requires 3 inputs.");const t=e[0],n=e[1],r=e[2];if(t.dims.length<3||1!==n.dims.length||1!==r.dims.length)throw new Error("Invalid input shape.");if(n.dims[0]!==t.dims[1]||r.dims[0]!==t.dims[1])throw new Error("Input shapes are mismatched.");if("float32"!==t.type&&"float64"!==t.type||"float32"!==n.type&&"float64"!==n.type||"float32"!==r.type&&"float64"!==r.type)throw new Error("Invalid input type.");if(4!==e[0].dims.length)throw new Error("Only support 4-D input shape.")}},7006:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createLrnProgramInfoLoader=t.parseLrnAttributes=t.lrn=void 0;const r=n(4910),o=n(5639);t.lrn=(e,t,n)=>(s(t),[e.run(a(t,n),t)]),t.parseLrnAttributes=e=>{const t=e.attributes.getFloat("alpha",1e-4),n=e.attributes.getFloat("beta",.75),o=e.attributes.getFloat("bias",1),i=e.attributes.getInt("size");return(0,r.createAttributeWithCacheKey)({alpha:t,beta:n,bias:o,size:i})};const i={name:"LRN",inputNames:["X"],inputTypes:[o.TextureType.unpacked]};function a(e,t){return Object.assign(Object.assign({},i),{cacheHint:t.cacheKey,get:()=>function(e,t){const n=e[0].dims[1],r=e[0].dims.length,a=-Math.floor((t.size-1)/2),s=Math.ceil((t.size-1)/2),u=`float(${t.alpha}) / float(${t.size})`,l=`\n float process(int indices[${r}]) {\n int c = indices[1];\n float x = _X(indices);\n float square_sum = 0.0;\n\n for (int i = ${a}; i <= ${s}; i++) {\n int idx = c + i;\n if (c >= 0 && c < ${n}) {\n indices[1] = idx;\n float j = _X(indices);\n square_sum += j * j;\n }\n }\n return x / pow(float(${t.bias}) + ${u} * square_sum, float(${t.beta}));\n }`;return Object.assign(Object.assign({},i),{cacheHint:t.cacheKey,output:{dims:e[0].dims,type:e[0].type,textureType:o.TextureType.unpacked},shaderSource:l})}(e,t)})}t.createLrnProgramInfoLoader=a;const s=e=>{if(!e||1!==e.length)throw new Error("LRN requires 1 input.");if(4!==e[0].dims.length)throw new Error('currently only support LRN for input with "NCHW" format');if("float32"!==e[0].type)throw new Error("input should be float type")}},5632:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createPackedMatmulProgramInfoLoader=void 0;const r=n(7273),o=n(6757),i=n(5639),a=n(432),s=n(2150),u=n(8276);t.createPackedMatmulProgramInfoLoader=(e,t,n)=>{const l=(c=t.length>2,p=n.activationCacheKey,{name:"MatMul (packed)",inputNames:c?["A","B","Bias"]:["A","B"],inputTypes:c?[i.TextureType.packed,i.TextureType.packed,i.TextureType.packed]:[i.TextureType.packed,i.TextureType.packed],cacheHint:p});var c,p;return Object.assign(Object.assign({},l),{get:()=>((e,t,n,l)=>{const c=n.length>2,p=c?"value += getBiasForMatmul();":"",d=n[0].dims,f=n[1].dims,h=r.BroadcastUtil.calcShape(d,f,!0),g=!r.ShapeUtil.areEqual(n[0].dims,n[1].dims);if(!h)throw new Error("Can't use matmul on the given tensors");const m=d[d.length-1],b=Math.ceil(m/2),y=d.length,w=f.length,_=(0,o.getGlsl)(e.session.backend.glContext.version),v=(0,a.getCoordsDataType)(h.length),x=h.length,T=(0,a.getGlChannels)(),{activationFunction:S,applyActivation:O}=(0,s.getActivationSnippet)(l),A=c?`${(0,u.getBiasForMatmul)(v,T,n[2].dims,h,!0)}`:"",E=g?`${function(e,t,n,o){let i=[],a=[];const s=n[0].dims,u=n[1].dims,l=s.length,c=u.length,p=o.length,d=p-l,f=p-c;i=s.map(((e,n)=>`coords.${t[n+d]}`)),i[l-1]="i*2",i.join(", "),a=u.map(((e,n)=>`coords.${t[n+f]}`)),a[c-2]="i*2",a.join(", ");const h=r.BroadcastUtil.getBroadcastDims(s,o),g=r.BroadcastUtil.getBroadcastDims(u,o),m=h.map((e=>`coords.${t[e+d]} = 0;`)).join("\n"),b=g.map((e=>`coords.${t[e+f]} = 0;`)).join("\n"),y=`int lastDim = coords.${t[p-1]};\n coords.${t[p-1]} = coords.${t[p-2]};\n coords.${t[p-2]} = lastDim;`;return`\nvec4 getAAtOutCoordsMatmul(int i) {\n ${e} coords = getOutputCoords();\n ${y}\n ${m}\n vec4 outputValue = getA(${i});\n return outputValue;\n}\n\nvec4 getBAtOutCoordsMatmul(int i) {\n ${e} coords = getOutputCoords();\n ${y}\n ${b}\n vec4 outputValue = getB(${a});\n return outputValue;\n}`}(v,T,n,h)}`:"",I=g?"getAAtOutCoordsMatmul(i)":`getA(${function(e,t){let n="";for(let r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBiasForMatmul=t.createMatmulProgramInfoLoader=t.parseMatMulAttributes=t.matMul=void 0;const r=n(7273),o=n(5639),i=n(432),a=n(2150),s=n(5632);t.matMul=(e,t,n)=>(c(t),e.session.pack?[e.run((0,s.createPackedMatmulProgramInfoLoader)(e,t,n),t)]:[e.run(l(t,n),t)]),t.parseMatMulAttributes=e=>(0,a.parseInternalActivationAttributes)(e.attributes);const u=(e,t)=>({name:"MatMul",inputNames:e?["A","B","Bias"]:["A","B"],inputTypes:e?[o.TextureType.unpacked,o.TextureType.unpacked,o.TextureType.unpacked]:[o.TextureType.unpacked,o.TextureType.unpacked],cacheHint:t});function l(e,t){const n=u(e.length>2,t.activationCacheKey);return Object.assign(Object.assign({},n),{get:()=>function(e,t,n){const s=t[0].dims,u=t[1].dims,l=r.BroadcastUtil.calcShape(s,u,!0);if(!l)throw new Error("Can't use matmul on the given tensors");const c=(0,i.getCoordsDataType)(l.length),d=(0,i.getGlChannels)(),{activationFunction:f,applyActivation:h}=(0,a.getActivationSnippet)(n),g=t.length>2,m=g?"value += getBiasForMatmul();":"",b=g?`${p(c,d,t[2].dims,l,!1)}`:"",y=l.length,w=s.length,_=u.length,v=`\n ${f}\n ${b}\n float process(int indices[${y}]) {\n int a[${w}];\n int b[${_}];\n bcastMatmulIndices_A(indices, a);\n bcastMatmulIndices_B(indices, b);\n\n float value;\n for (int k=0; k<${s[s.length-1]}; ++k) {\n a[${w-1}] = k;\n b[${_-2}] = k;\n value += _A(a) * _B(b);\n }\n ${m}\n ${h}\n return value;\n }`;return Object.assign(Object.assign({},e),{output:{dims:l,type:t[0].type,textureType:o.TextureType.unpacked},shaderSource:v})}(n,e,t)})}t.createMatmulProgramInfoLoader=l;const c=e=>{if(!e||2!==e.length)throw new Error("MatMul requires 2 inputs.");if(e[0].dims[e[0].dims.length-1]!==e[1].dims[e[1].dims.length-2])throw new Error("shared dimension does not match.");if("float32"!==e[0].type&&"float64"!==e[0].type||"float32"!==e[1].type&&"float64"!==e[1].type)throw new Error("inputs should be float type");if(e[0].type!==e[1].type)throw new Error("inputs types should match")};function p(e,t,n,o,i){let a="";const s=n.length,u=o.length,l=u-s;a=u<2&&s>0?"coords":n.map(((e,n)=>`coords.${t[n+l]}`)).join(", ");const c=r.BroadcastUtil.getBroadcastDims(n,o).map((e=>`coords.${t[e+l]} = 0;`)).join("\n");let p="vec4(outputValue.xx, outputValue.yy)";return 1===r.ShapeUtil.size(n)&&(p="vec4(outputValue.x)"),i?`\nvec4 getBiasForMatmul() {\n ${e} coords = getOutputCoords();\n ${c}\n vec4 outputValue = getBias(${a});\n return ${p};\n}`:`\nfloat getBiasForMatmul() {\n ${e} coords = getOutputCoords();\n ${c}\n return getBias(coords.x);\n}`}t.getBiasForMatmul=p},9:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createPackProgramInfoLoader=void 0;const r=n(6757),o=n(5639),i=n(432),a=n(5614),s={name:"pack",inputNames:["A"],inputTypes:[o.TextureType.unpackedReversed]};t.createPackProgramInfoLoader=(e,t)=>Object.assign(Object.assign({},s),{get:()=>((e,t)=>{const n=(0,r.getGlsl)(e.session.backend.glContext.version),u=t.dims,l=u.length,c=t.dims.length,p=(0,i.getCoordsDataType)(c),d=(0,a.getChannels)("rc",c),f=(h=c,g=d,m=u[u.length-2],b=u[u.length-1],0===h||1===h?"":`\n int r = ${g[h-2]};\n int c = ${g[h-1]};\n int rp1 = ${g[h-2]} + 1;\n int cp1 = ${g[h-1]} + 1;\n bool rEdge = rp1 >= ${b};\n bool cEdge = cp1 >= ${m};\n `);var h,g,m,b;let y;y=0===l?[1,1]:1===l?[u[0],1]:[u[c-1],u[c-2]];const w=function(e,t,n){if(0===e)return"false";if(1===e)return`rc > ${t[0]}`;let r="";for(let o=e-2;o= ${t[o-e+2]}`,o= ${e[0]} ? 0. : getA(rc + 1),\n 0, 0`;let r="";if(n>2)for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.unpackFromChannel=t.getChannels=t.getVecChannels=void 0;const r=n(432);function o(e,t){return(0,r.getGlChannels)(t).map((t=>`${e}.${t}`))}t.getVecChannels=o,t.getChannels=function(e,t){return 1===t?[e]:o(e,t)},t.unpackFromChannel=function(){return"\n float getChannel(vec4 frag, int dim) {\n int modCoord = imod(dim, 2);\n return modCoord == 0 ? frag.r : frag.g;\n }\n\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n "}},5565:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parsePadAttributesV11=t.padV11=t.parsePadAttributesV2=t.padV2=void 0;const r=n(4910),o=n(7273),i=n(6757),a=n(5639),s={name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};t.padV2=(e,t,n)=>(c(t),[e.run(Object.assign(Object.assign({},s),{cacheHint:n.cacheKey,get:()=>l(e,t[0],n)}),t)]),t.parsePadAttributesV2=e=>{const t=e.attributes.getString("mode","constant"),n=e.attributes.getFloat("value",0),o=e.attributes.getInts("pads");return(0,r.createAttributeWithCacheKey)({mode:t,value:n,pads:o})},t.padV11=(e,n,r)=>{p(n);const o=u(e,n,r);return(0,t.padV2)(e,[n[0]],o)},t.parsePadAttributesV11=e=>e.attributes.getString("mode","constant");const u=(e,t,n)=>{if(!e.session.isInitializer(t[1].dataId)||t.length>=3&&!e.session.isInitializer(t[2].dataId))throw new Error("dynamic pad attributes are not allowed");const o=Array.from(t[1].integerData),i=t.length>=3?t[2].floatData[0]:0;return(0,r.createAttributeWithCacheKey)({mode:n,pads:o,value:i})},l=(e,t,n)=>{const r=o.ShapeUtil.padShape(t.dims.slice(),n.pads),i=r.length,s=`\n ${d(e,t,n)}\n float process(int[${i}] indices) {\n return padA(indices);\n }`;return{name:"Pad",inputNames:["A"],inputTypes:[a.TextureType.unpacked],output:{dims:r,type:t.type,textureType:a.TextureType.unpacked},shaderSource:s}},c=e=>{if(!e||1!==e.length)throw new Error("Pad requires 1 input");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type.")},p=e=>{if(!e||2!==e.length&&3!==e.length)throw new Error("Pad requires 2 or 3 inputs");if("int32"!==e[1].type)throw new Error("Invalid input type.");if(e.length>=3&&"string"===e[2].type)throw new Error("Invalid input type.")},d=(e,t,n)=>{const r=(0,i.getGlsl)(e.session.backend.glContext.version),[s,u]=e.calculateTextureWidthAndHeight(t.dims,a.TextureType.unpacked),l=o.ShapeUtil.computeStrides(t.dims);switch(n.mode){case"constant":return f(r,t.dims,l,s,u,n.pads,n.value);case"reflect":return h(r,t.dims,l,s,u,n.pads);case"edge":return g(r,t.dims,l,s,u,n.pads);default:throw new Error("Invalid mode")}},f=(e,t,n,r,o,i,a)=>{const s=t.length;let u="";for(let e=s-1;e>=0;--e)u+=`\n k = m[${e}] - ${i[e]};\n if (k < 0) return constant;\n if (k >= ${t[e]}) return constant;\n offset += k * ${n[e]};\n `;return`\n float padA(int m[${s}]) {\n const float constant = float(${a});\n int offset = 0;\n int k = 0;\n ${u}\n vec2 coords = offsetToCoords(offset, ${r}, ${o});\n float value = getColorAsFloat(${e.texture2D}(A, coords));\n return value;\n }\n `},h=(e,t,n,r,o,i)=>{const a=t.length;let s="";for(let e=a-1;e>=0;--e)s+=`\n k = m[${e}] - ${i[e]};\n if (k < 0) { k = -k; }\n {\n const int _2n_1 = ${2*(t[e]-1)};\n k = int( mod( float(k), float(_2n_1) ) ) ;\n if(k >= ${t[e]}) { k = _2n_1 - k; }\n }\n offset += k * ${n[e]};\n `;return`\n float padA(int m[${a}]) {\n int offset = 0;\n int k = 0;\n ${s}\n vec2 coords = offsetToCoords(offset, ${r}, ${o});\n float value = getColorAsFloat(${e.texture2D}(A, coords));\n return value;\n }\n `},g=(e,t,n,r,o,i)=>{const a=t.length;let s="";for(let e=a-1;e>=0;--e)s+=`\n k = m[${e}] - ${i[e]};\n if (k < 0) k = 0;\n if (k >= ${t[e]}) k = ${t[e]-1};\n offset += k * ${n[e]};\n `;return`\n float padA(int m[${a}]) {\n int offset = 0;\n int k = 0;\n ${s}\n vec2 coords = offsetToCoords(offset, ${r}, ${o});\n float value = getColorAsFloat(${e.texture2D}(A, coords));\n return value;\n }\n `}},2834:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.globalMaxPool=t.parseMaxPoolAttributes=t.maxPool=t.parseGlobalAveragePoolAttributes=t.globalAveragePool=t.parseAveragePoolAttributes=t.averagePool=void 0;const r=n(4910),o=n(7273),i=n(5639);t.averagePool=(e,t,n)=>{p(t);const r={name:"AveragePool",inputNames:["X"],inputTypes:[i.TextureType.unpacked],cacheHint:n.cacheKey};return[e.run(Object.assign(Object.assign({},r),{get:()=>a(t,r,!1,n)}),t)]},t.parseAveragePoolAttributes=e=>{const t=e.attributes.getString("auto_pad","NOTSET"),n=e.attributes.getInt("ceil_mode",0),o=0!==e.attributes.getInt("count_include_pad",0),i=e.attributes.getInts("kernel_shape"),a=e.attributes.getInts("strides",[]),s=e.attributes.getInts("pads",[]);if(0!==n)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,r.createAttributeWithCacheKey)({autoPad:t,ceilMode:n,countIncludePad:o,kernelShape:i,strides:a,pads:s})};const a=(e,t,n,r)=>{const[a,s]=u(e,r,n),l=o.ShapeUtil.size(a.kernelShape);let c="";a.countIncludePad?c+=`value /= float(${l});`:c+=`value /= float(${l} - pad);`;const p=`\n ${d(e[0].dims,a,"value += _X(x);",c,"0.0")}\n `;return Object.assign(Object.assign({},t),{output:{dims:s,type:e[0].type,textureType:i.TextureType.unpacked},shaderSource:p})};t.globalAveragePool=(e,t,n)=>{p(t);const r={name:"GlobalAveragePool",inputNames:["X"],inputTypes:[i.TextureType.unpacked],cacheHint:`${n.countIncludePad}`};return[e.run(Object.assign(Object.assign({},r),{get:()=>a(t,r,!0,n)}),t)]},t.parseGlobalAveragePoolAttributes=e=>{const t=0!==e.attributes.getInt("count_include_pad",0);return(0,r.createAttributeWithCacheKey)({autoPad:"",ceilMode:0,countIncludePad:t,kernelShape:[],strides:[],pads:[]})},t.maxPool=(e,t,n)=>{p(t);const r={name:"MaxPool",inputNames:["X"],inputTypes:[i.TextureType.unpacked],cacheHint:n.cacheKey};return[e.run(Object.assign(Object.assign({},r),{get:()=>s(t,r,!1,n)}),t)]},t.parseMaxPoolAttributes=e=>{const t=e.attributes.getString("auto_pad","NOTSET"),n=e.attributes.getInt("ceil_mode",0),o=e.attributes.getInts("kernel_shape"),i=e.attributes.getInts("strides",[]),a=e.attributes.getInts("pads",[]),s=e.attributes.getInt("storage_order",0),u=e.attributes.getInts("dilations",[]);if(0!==s)throw new Error("column major storage order is not yet supported for MaxPool");if(0!==n)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,r.createAttributeWithCacheKey)({autoPad:t,ceilMode:n,countIncludePad:!1,kernelShape:o,strides:i,pads:a,storageOrder:s,dilations:u})};const s=(e,t,n,r)=>{const[o,a]=u(e,r,n),s=`\n ${d(e[0].dims,o,"\n value = max(_X(x), value);\n ","","-1e5")}\n `;return Object.assign(Object.assign({},t),{output:{dims:a,type:e[0].type,textureType:i.TextureType.unpacked},shaderSource:s})},u=(e,t,n)=>{const r=e[0].dims.slice(),i=Object.hasOwnProperty.call(t,"dilations"),a=t.kernelShape.slice(),s=t.strides.slice(),u=i?t.dilations.slice():[],l=t.pads.slice();o.PoolConvUtil.adjustPoolAttributes(n,r,a,s,u,l);const c=o.PoolConvUtil.computePoolOutputShape(n,r,s,u,a,l,t.autoPad),p=Object.assign({},t);return i?Object.assign(p,{kernelShape:a,strides:s,pads:l,dilations:u,cacheKey:t.cacheKey}):Object.assign(p,{kernelShape:a,strides:s,pads:l,cacheKey:t.cacheKey}),[p,c]},l={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""},c={name:"GlobalMaxPool",inputNames:["X"],inputTypes:[i.TextureType.unpacked]};t.globalMaxPool=(e,t)=>(p(t),[e.run(Object.assign(Object.assign({},c),{get:()=>s(t,c,!0,l)}),t)]);const p=e=>{if(!e||1!==e.length)throw new Error("Pool ops requires 1 input.");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type.")},d=(e,t,n,r,i)=>{const a=e.length;if(t.kernelShape.length<=2){const o=t.kernelShape[t.kernelShape.length-1],s=t.strides[t.strides.length-1],u=t.pads[t.pads.length/2-1],l=t.pads[t.pads.length-1],c=e[a-1];let p="",d="",f="";if(p=u+l!==0?`\n for (int i = 0; i < ${o}; i++) {\n x[${a} - 1] = indices[${a} - 1] * ${s} - ${u} + i;\n if (x[${a} - 1] < 0 || x[${a} - 1] >= ${c}) {\n pad++;\n continue;\n }\n ${n}\n }`:`\n for (int i = 0; i < ${o}; i++) {\n x[${a} - 1] = indices[${a} - 1] * ${s} - ${u} + i;\n ${n}\n }`,2===t.kernelShape.length){const n=t.kernelShape[t.kernelShape.length-2],r=t.strides[t.strides.length-2],i=t.pads[t.pads.length/2-2],s=t.pads[t.pads.length-2],u=e[a-2];d=i+s!==0?`\n for (int j = 0; j < ${n}; j++) {\n x[${a} - 2] = indices[${a} - 2] * ${r} - ${i} + j;\n if (x[${a} - 2] < 0 || x[${a} - 2] >= ${u}) {\n pad+= ${o};\n continue;\n }\n `:`\n for (int j = 0; j < ${n}; j++) {\n x[${a} - 2] = indices[${a} - 2] * ${r} - ${i} + j;\n `,f="\n }\n "}return`\n float process(int indices[${a}]) {\n int x[${a}];\n copyVec(indices, x);\n\n float value = ${i};\n int pad = 0;\n ${d}\n ${p}\n ${f}\n ${r}\n return value;\n }\n `}{const s=o.ShapeUtil.size(t.kernelShape),u=o.ShapeUtil.computeStrides(t.kernelShape),l=u.length,c=t.pads.length,p=h(l),d=f(e,"inputDims"),g=f(t.pads,"pads"),m=f(u,"kernelStrides"),b=f(t.strides,"strides");let y="";return y=t.pads.reduce(((e,t)=>e+t))?`\n if (x[j] >= inputDims[j] || x[j] < 0) {\n pad++;\n isPad = true;\n break;\n }\n }\n if (!isPad) {\n ${n}\n }`:`\n }\n ${n}\n `,`\n ${p}\n float process(int indices[${a}]) {\n int x[${a}];\n copyVec(indices, x);\n int offset[${l}];\n int pads[${c}];\n int inputDims[${a}];\n int kernelStrides[${l}];\n int strides[${l}];\n ${g}\n ${d}\n ${b}\n ${m}\n\n float value = ${i};\n int pad = 0;\n bool isPad = false;\n for (int i = 0; i < ${s}; i++) {\n offsetToIndices(i, kernelStrides, offset);\n isPad = false;\n for (int j = ${a} - ${l}; j < ${a}; j++) {\n x[j] = indices[j] * strides[j - ${a} + ${l}]\n + offset[j - ${a} + ${l}] - pads[j - 2];\n ${y}\n }\n ${r}\n\n return value;\n }\n `}},f=(e,t)=>{let n="";for(let r=0;r`\n void offsetToIndices(int offset, int[${e}] strides, out int[${e}] indices) {\n if (${e} == 0) {\n return;\n }\n for (int i = 0; i < ${e} - 1; ++i) {\n indices[i] = offset / strides[i];\n offset -= indices[i] * strides[i];\n }\n indices[${e} - 1] = offset;\n }`},1010:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reduceLogSumSquare=t.reduceLogSum=t.reduceProd=t.reduceMin=t.reduceMax=t.reduceMean=t.reduceSum=t.parseReduceAttributes=void 0;const r=n(4910),o=n(6145),i=n(7273),a=n(5639),s=(e,t,n,r,o)=>{l(t);const i={name:r,inputNames:["A"],inputTypes:[a.TextureType.unpacked]};return[e.run(Object.assign(Object.assign({},i),{cacheHint:n.cacheKey,get:()=>u(e,t,n,r,o,i)}),t)]};t.parseReduceAttributes=e=>{const t=e.attributes.getInts("axes",[]),n=1===e.attributes.getInt("keepdims",1);return(0,r.createAttributeWithCacheKey)({axes:t,keepDims:n})};const u=(e,t,n,r,o,s)=>{const u=[],l=t[0].dims.length||1,c=[],p=i.ShapeUtil.normalizeAxes(n.axes,t[0].dims.length),d=o(t,p);let f=d[1];for(let e=0;e=0||0===p.length?(n.keepDims&&u.push(1),f=`\n for(int j${e} = 0; j${e} < ${t[0].dims[e]}; j${e}++) {\n inputIdx[${e}] = j${e};\n ${f}\n }`):(c.push(`inputIdx[${e}] = outputIdx[${u.length}];`),u.push(t[0].dims[e]));const h=`\n float process(int outputIdx[${u.length||1}]) {\n float value; // final result\n int inputIdx[${l}]; // addressing input data\n ${c.join("\n")}\n ${d[0]} // init ops for reduce max/min\n ${f}\n ${d[2]} // final computation for reduce mean\n return value;\n }`;return Object.assign(Object.assign({},s),{output:{dims:u,type:t[0].type,textureType:a.TextureType.unpacked},shaderSource:h})},l=e=>{if(!e||1!==e.length)throw new Error("Reduce op requires 1 input.");if(-1===o.NUMBER_TYPES.indexOf(e[0].type))throw new Error("Invalid input type.")};t.reduceSum=(e,t,n)=>s(e,t,n,"ReduceSum",(()=>["value = 0.0;","value += _A(inputIdx);",""])),t.reduceMean=(e,t,n)=>s(e,t,n,"ReduceMean",((e,t)=>{let n=1;for(let r=0;r=0||0===t.length)&&(n*=e[0].dims[r]);return["value = 0.0;","value += _A(inputIdx);",`value /= ${n}.;`]})),t.reduceMax=(e,t,n)=>s(e,t,n,"ReduceMax",((e,t)=>{const n=[];for(let r=0;r=0||0===t.length)&&n.push(`inputIdx[${r}] = 0;`);return[`${n.join("\n")}\nvalue = _A(inputIdx);`,"value = max(value, _A(inputIdx));",""]})),t.reduceMin=(e,t,n)=>s(e,t,n,"ReduceMin",((e,t)=>{const n=[];for(let r=0;r=0||0===t.length)&&n.push(`inputIdx[${r}] = 0;`);return[`${n.join("\n")}\nvalue = _A(inputIdx);`,"value = min(value, _A(inputIdx));",""]})),t.reduceProd=(e,t,n)=>s(e,t,n,"ReduceProd",(()=>["value = 1.0;","value *= _A(inputIdx);",""])),t.reduceLogSum=(e,t,n)=>s(e,t,n,"ReduceLogSum",(()=>["value = 0.0;","value += _A(inputIdx);","value = log(value);"])),t.reduceLogSumSquare=(e,t,n)=>s(e,t,n,"ReduceLogSumSquare",(()=>["float t; value = 0.0;","t = _A(inputIdx); value += t * t;",""]))},7379:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isReshapeCheap=t.processDims3D=t.createPackedReshape3DProgramInfoLoader=void 0;const r=n(7273),o=n(6757),i=n(5639),a=n(5614);t.createPackedReshape3DProgramInfoLoader=(e,t,n)=>{const s=(e=>({name:"Reshape (packed)",inputTypes:[i.TextureType.packed],inputNames:["A"],cacheHint:`${e}`}))(n);return Object.assign(Object.assign({},s),{get:()=>((e,t,n,s)=>{const u=t.dims,l=s;let c="";for(let e=0;e<4;e++){let t="";switch(e){case 0:t="outputCoords = rc;";break;case 1:t="outputCoords = ivec3(rc.x, rc.y+1, rc.z);";break;case 2:t="outputCoords = ivec3(rc.x, rc.y, rc.z+1);";break;case 3:t="outputCoords = ivec3(rc.x, rc.y+1, rc.z+1);";break;default:throw new Error}c+=`\n ${t}\n ${e>0?"if(outputCoords.y < rows && outputCoords.z < cols){":""}\n int flattenedIndex = getFlattenedIndex(outputCoords);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flattenedIndex);\n vec2 innerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] = getChannel(getA(inputRC.x, inputRC.y, inputRC.z), innerDims);\n\n ${e>0?"}":""}\n `}const p=(0,o.getGlsl)(e.session.backend.glContext.version),d=`\n ${function(e){const t=r.ShapeUtil.computeStrides(e),n=["b","r","c"],o="index";return`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${t.map(((e,r)=>`int ${n[r]} = ${o} / ${e}; ${r===t.length-1?`int ${n[r+1]} = ${o} - ${n[r]} * ${e}`:`index -= ${n[r]} * ${e}`};`)).join("")}\n return ivec3(b, r, c);\n }\n `}(u)}\n ${function(e){const t=r.ShapeUtil.computeStrides(e);return`\n int getFlattenedIndex(ivec3 coords) {\n // reverse y, z order\n return coords.x * ${t[0]} + coords.z * ${t[1]} + coords.y;\n }\n`}(l)}\n ${(0,a.unpackFromChannel)()}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.0);\n\n ivec3 outputCoords;\n int rows = ${l[2]};\n int cols = ${l[1]};\n\n ${c}\n ${p.output} = result;\n }\n `;return Object.assign(Object.assign({},n),{output:{dims:l,type:t.type,textureType:i.TextureType.packed},shaderSource:d,hasMain:!0})})(e,t,s,n)})},t.processDims3D=function(e){if(0===e.length)return[1,1,1];let t=1;for(let n=0;n1?e[e.length-2]:1,e[e.length-1]]},t.isReshapeCheap=function(e,t){let n=!1;return n=0===e.length||0===t.length||(e.length<2||t.length<2?e[e.length-1]===t[t.length-1]:e[e.length-1]===t[t.length-1]&&e[e.length-2]===t[t.length-2]),n}},8126:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=void 0;const r=n(7273);t.reshape=(e,t)=>{const n=r.ShapeUtil.calculateReshapedDims(t[0].dims,t[1].integerData);return e.session.pack?[e.reshapePacked(t[0],n)]:[e.reshapeUnpacked(t[0],n)]}},2801:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseResizeAttributesV11=t.parseResizeAttributesV10=t.resize=void 0;const r=n(6757),o=n(5639),i=n(432),a=n(5614),s=n(3980),u={name:"Resize",inputNames:["A"],inputTypes:[o.TextureType.packed]};t.resize=(e,t,n)=>((0,s.validateInputs)(t,n),[e.run(Object.assign(Object.assign({},u),{cacheHint:n.cacheKey,get:()=>l(e,t,n)}),t)]),t.parseResizeAttributesV10=e=>(0,s.parseUpsampleAttributes)(e,10),t.parseResizeAttributesV11=e=>(0,s.parseUpsampleAttributes)(e,11);const l=(e,t,n)=>{const s=(0,r.getGlsl)(e.session.backend.glContext.version),[l,p]=c(t,n);if(l.every((e=>1===e))&&"tf_crop_and_resize"!==n.coordinateTransformMode)return Object.assign(Object.assign({},u),{output:{dims:p,type:t[0].type,textureType:o.TextureType.packed},hasMain:!0,shaderSource:`void main() {\n vec4 v = ${s.texture2D}(X, TexCoords);\n ${s.output} = v;\n }`});const d=p.length;if(d<2)throw new Error(`output dimension should be at least 2, but got ${d}`);const f=p[d-2],h=p[d-1],g=t[0].dims;if(d!==g.length)throw new Error(`output dimension should match input ${g.length}, but got ${d}`);const m=g[d-2],b=g[d-1],y=l[d-2],w=l[d-1];let _="";if("linear"!==n.mode)throw new Error(`resize (packed) does not support mode: '${n.mode}'`);switch(n.coordinateTransformMode){case"asymmetric":_="\n vec4 getSourceFracIndex(ivec4 coords) {\n return vec4(coords) / scaleWHWH;\n }\n ";break;case"half_pixel":_="\n vec4 getSourceFracIndex(ivec4 coords) {\n return (vec4(coords) + 0.5) / scaleWHWH - 0.5;\n }\n ";break;case"pytorch_half_pixel":_=`\n vec4 getSourceFracIndex(ivec4 coords) {\n vec4 fcoords = vec4(coords);\n return vec4(\n ${h}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0,\n ${f}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0,\n ${h}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0,\n ${f}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0\n );\n }\n `;break;case"align_corners":_=`\n vec4 getSourceFracIndex(ivec4 coords) {\n vec4 resized = vec4(${h}.0 - 1.0, ${f}.0 - 1.0, ${h}.0 - 1.0,\n ${f}.0 - 1.0);\n vec4 original = vec4(${b}.0 - 1.0, ${m}.0 - 1.0, ${b}.0 - 1.0,\n ${m}.0 - 1.0);\n vec4 new_scale = original / resized;\n return vec4(coords) * new_scale;\n }\n `;break;default:throw new Error(`resize (packed) does not support coordinateTransformMode: '${n.coordinateTransformMode}'`)}const v=(0,i.getCoordsDataType)(d),x=`\n const vec2 inputWH = vec2(${m}.0, ${b}.0);\n const vec4 scaleWHWH = vec4(float(${y}), float(${w}), float(${y}), float(${w}));\n ${(0,a.unpackFromChannel)()}\n ${_}\n float getAValue(int x10, int r, int c, int d) {\n return getChannel(getA(x10, r, c, d), vec2(c, d));\n }\n void main() {\n ${v} rc = getOutputCoords();\n\n int batch = rc[0];\n int depth = rc[1];\n\n // retrieve the 4 coordinates that is used in the 4 packed output values.\n ivec4 coords = ivec4(rc.wz, rc.w + 1, rc.z + 1);\n\n // calculate the source index in fraction\n vec4 sourceFrac = getSourceFracIndex(coords);\n\n // get the lower and upper bound of the 4 values that will be packed into one texel.\n ivec4 x00 = ivec4(max(sourceFrac.xy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xy)));\n ivec4 x01 = ivec4(max(sourceFrac.xw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.xw)));\n ivec4 x10 = ivec4(max(sourceFrac.zy, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zy)));\n ivec4 x11 = ivec4(max(sourceFrac.zw, vec2(0.0)), min(inputWH - 1.0, ceil(sourceFrac.zw)));\n\n bool hasNextRow = rc.w < ${f-1};\n bool hasNextCol = rc.z < ${h-1};\n\n // pack x00, x01, x10, x11's top-left corner into one vec4 structure\n vec4 topLeft = vec4(\n getAValue(batch, depth, x00.x, x00.y),\n hasNextCol ? getAValue(batch, depth, x01.x, x01.y) : 0.0,\n hasNextRow ? getAValue(batch, depth, x10.x, x10.y) : 0.0,\n (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.y) : 0.0);\n\n // pack x00, x01, x10, x11's top-right corner into one vec4 structure\n vec4 topRight = vec4(\n getAValue(batch, depth, x00.x, x00.w),\n hasNextCol ? getAValue(batch, depth, x01.x, x01.w) : 0.0,\n hasNextRow ? getAValue(batch, depth, x10.x, x10.w) : 0.0,\n (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.x, x11.w) : 0.0);\n\n // pack x00, x01, x10, x11's bottom-left corner into one vec4 structure\n vec4 bottomLeft = vec4(\n getAValue(batch, depth, x00.z, x00.y),\n hasNextCol ? getAValue(batch, depth, x01.z, x01.y) : 0.0,\n hasNextRow ? getAValue(batch, depth, x10.z, x10.y) : 0.0,\n (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.y) : 0.0);\n\n // pack x00, x01, x10, x11's bottom-right corner into one vec4 structure\n vec4 bottomRight = vec4(\n getAValue(batch, depth, x00.z, x00.w),\n hasNextCol ? getAValue(batch, depth, x01.z, x01.w) : 0.0,\n hasNextRow ? getAValue(batch, depth, x10.z, x10.w) : 0.0,\n (hasNextRow && hasNextCol) ? getAValue(batch, depth, x11.z, x11.w) : 0.0);\n\n // calculate the interpolation fraction on u and v direction\n vec4 frac = vec4(sourceFrac) - floor(sourceFrac);\n vec4 clampFrac = clamp(frac, vec4(0.0), vec4(1.0));\n\n vec4 top = mix(topLeft, topRight, clampFrac.ywyw);\n vec4 bottom = mix(bottomLeft, bottomRight, clampFrac.ywyw);\n vec4 newValue = mix(top, bottom, clampFrac.xxzz);\n\n ${s.output} = vec4(newValue);\n }\n `;return Object.assign(Object.assign({},u),{output:{dims:p,type:t[0].type,textureType:o.TextureType.packed},hasMain:!0,shaderSource:x})},c=(e,t)=>{const n=e[0].dims;let r,o=t.scales;if(0===o.length){const i=e[t.scalesInputIdx];if(i&&0!==i.size){if(e[t.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");o=p(i,t.mode,t.isResize)}else{const i=e[t.sizesInputIdx];if(!i||0===i.size)throw new Error("Either scales or sizes MUST be provided as input.");r=Array.from(i.integerData),o=d(r,n,t.mode,t.isResize)}}else if(e[t.sizesInputIdx])throw new Error("Only one of scales or sizes must be provided as input.");const i=r||n.map(((e,t)=>Math.floor(e*o[t])));return[o,i]},p=(e,t,n)=>{const r=Array.from(e.floatData);return(0,s.scalesValidation)(r,t,n),r},d=(e,t,n,r)=>{const o=t.length,i=new Array(o);for(let n=0,r=o;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shape=void 0;const r=n(9240);t.shape=(e,t)=>(o(t),[new r.Tensor([t[0].dims.length],"int32",void 0,void 0,new Int32Array(t[0].dims))]);const o=e=>{if(!e||1!==e.length)throw new Error("Shape requires 1 input.")}},2444:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sliceV10=t.parseSliceAttributes=t.slice=void 0;const r=n(4910),o=n(6145),i=n(7273),a=n(5639),s={name:"Slice",inputNames:["A"],inputTypes:[a.TextureType.unpacked]};t.slice=(e,t,n)=>(l(t),[e.run(Object.assign(Object.assign({},s),{cacheHint:n.cacheKey,get:()=>u(e,t[0],n)}),t)]),t.parseSliceAttributes=e=>{const t=e.attributes.getInts("starts"),n=e.attributes.getInts("ends"),o=e.attributes.getInts("axes",[]);return(0,r.createAttributeWithCacheKey)({starts:t,ends:n,axes:o})};const u=(e,t,n)=>{const r=0===n.axes.length?t.dims.slice(0).map(((e,t)=>t)):n.axes,o=i.ShapeUtil.normalizeAxes(r,t.dims.length),u=n.starts.map(((e,n)=>e>t.dims[o[n]]-1?t.dims[o[n]]:i.ShapeUtil.normalizeAxis(e,t.dims[o[n]]))),l=n.ends.map(((e,n)=>e>t.dims[o[n]]-1?t.dims[o[n]]:i.ShapeUtil.normalizeAxis(e,t.dims[o[n]]))),c=t.dims.slice(),p=[];for(let e=0;e0&&p.push(`outputIdx[${o[e]}] += ${u[e]};`);const d=`\n float process(int outputIdx[${c.length}]) {\n ${p.join("\n ")}\n return _A(outputIdx);\n }`;return Object.assign(Object.assign({},s),{output:{dims:c,type:t.type,textureType:a.TextureType.unpacked},shaderSource:d})},l=e=>{if(!e||1!==e.length)throw new Error("Slice requires 1 input.");if(-1===o.NUMBER_TYPES.indexOf(e[0].type))throw new Error("Invalid input type.")};t.sliceV10=(e,t)=>{p(t);const n=c(e,t);return[e.run(Object.assign(Object.assign({},s),{cacheHint:n.cacheKey,get:()=>u(e,t[0],n)}),[t[0]])]};const c=(e,t)=>{if(!e.session.isInitializer(t[1].dataId)||!e.session.isInitializer(t[2].dataId)||t.length>=4&&!e.session.isInitializer(t[3].dataId)||t.length>=5&&!e.session.isInitializer(t[4].dataId))throw new Error("dynamic slice attributes are not allowed");if(t.length>=5&&t[4].integerData.some((e=>1!==e)))throw new Error("currently non-1 steps is not supported for Slice");const n=Array.from(t[1].integerData),r=Array.from(t[2].integerData),o=t.length>=4?Array.from(t[3].integerData):[];return{starts:n,ends:r,axes:o,cacheKey:`${o};${n};${r}`}},p=e=>{if(!e||e.length<3||e.length>5)throw new Error("Invalid input number.");if("int32"!==e[1].type||1!==e[1].dims.length)throw new Error("Invalid input type.");if("int32"!==e[2].type||1!==e[2].dims.length)throw new Error("Invalid input type.");if(e.length>=4&&("int32"!==e[3].type||1!==e[3].dims.length))throw new Error("Invalid input type.");if(e.length>=5&&("int32"!==e[4].type||1!==e[4].dims.length))throw new Error("Invalid input type.")}},815:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.softmaxV13=t.parseSoftmaxAttributesV13=t.parseSoftmaxAttributes=t.softmax=void 0;const r=n(4910),o=n(7273),i=n(6757),a=n(5639),s=n(5707),u={name:"SoftmaxComputeMax",inputNames:["A"],inputTypes:[a.TextureType.unpacked]},l={name:"SoftmaxComputeScale",inputNames:["A","Max"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked]},c={name:"SoftMax",inputNames:["A","Max","Norm"],inputTypes:[a.TextureType.unpacked,a.TextureType.unpacked,a.TextureType.unpacked]};t.softmax=(e,t,n)=>{g(t);const r=t[0].dims.slice(),i=o.ShapeUtil.normalizeAxis(n.axis,r.length),a=o.ShapeUtil.sizeToDimension(r,i),s=o.ShapeUtil.sizeFromDimension(r,i);return p(e,t,n,a,s)},t.parseSoftmaxAttributes=e=>(0,r.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis",1)}),t.parseSoftmaxAttributesV13=e=>(0,r.createAttributeWithCacheKey)({axis:e.attributes.getInt("axis",-1)}),t.softmaxV13=(e,t,n)=>{g(t);const i=t[0].dims.slice(),a=o.ShapeUtil.normalizeAxis(n.axis,i.length),u=i.length,l=a!==u-1,c=[];let d,f=[],h=[];l&&(f=Array.from({length:u}).map(((e,t)=>t)),f[a]=u-1,f[u-1]=a,f.map((e=>c.push(i[e]))),d=(0,r.createAttributeWithCacheKey)({perm:f}),h=(0,s.transpose)(e,t,d));const m=l?o.ShapeUtil.sizeToDimension(c,u-1):o.ShapeUtil.sizeToDimension(i,u-1),b=l?o.ShapeUtil.sizeFromDimension(c,u-1):o.ShapeUtil.sizeFromDimension(i,u-1),y=p(e,l?h:t,n,m,b);return l?(0,s.transpose)(e,y,d):y};const p=(e,t,n,r,o)=>{const i=d(e,t[0],r,o,[r]),a=e.run(Object.assign(Object.assign({},u),{cacheHint:n.cacheKey,get:()=>i}),t),s=f(e,t[0],r,o,i.output.dims,[r]),p=e.run(Object.assign(Object.assign({},l),{cacheHint:n.cacheKey,get:()=>s}),[t[0],a]),g=h(e,t[0],r,o,i.output.dims,s.output.dims);return[e.run(Object.assign(Object.assign({},c),{cacheHint:n.cacheKey,get:()=>g}),[t[0],a,p])]},d=(e,t,n,r,o)=>{const[s,l]=e.calculateTextureWidthAndHeight(t.dims,a.TextureType.unpacked),c=o.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==o.length)throw new Error("Dimensionality of the output should be 1");if(o[0]!==n)throw new Error("Shape of the output should be equal to logical row count");const p=(0,i.getGlsl)(e.session.backend.glContext.version),d=`\n float process(int[${c}] indices) {\n int logical_row_start_offset = indices[0] * ${r};\n\n float max = getColorAsFloat(${p.texture2D}(A, offsetToCoords(logical_row_start_offset, ${s},\n ${l} )));\n for(int i=1; i<${r}; ++i)\n {\n float current = getColorAsFloat(${p.texture2D}(A, offsetToCoords(logical_row_start_offset + i,\n ${s}, ${l})));\n if(current > max)\n max = current;\n }\n\n return max;\n }`;return Object.assign(Object.assign({},u),{output:{dims:o,type:t.type,textureType:a.TextureType.unpacked},shaderSource:d})},f=(e,t,n,r,o,s)=>{const[u,c]=e.calculateTextureWidthAndHeight(t.dims,a.TextureType.unpacked),p=s.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==s.length)throw new Error("Dimensionality of the output should be 1");if(s[0]!==n)throw new Error("Shape of the output should be equal to logical row count");if(1!==o.length)throw new Error("Dimensionality of the intermediate results should be 1");if(o[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");const d=`\n float process(int[${p}] indices) {\n int logical_row_start_offset = indices[0] * ${r};\n\n float norm_factor = 0.0;\n float max = _Max(indices);\n for(int i=0; i<${r}; ++i)\n {\n norm_factor += exp(getColorAsFloat(${(0,i.getGlsl)(e.session.backend.glContext.version).texture2D}(A, offsetToCoords(logical_row_start_offset + i,\n ${u}, ${c}))) - max);\n }\n\n return norm_factor;\n }`;return Object.assign(Object.assign({},l),{output:{dims:s,type:t.type,textureType:a.TextureType.unpacked},shaderSource:d})},h=(e,t,n,r,o,i)=>{const[s,u]=e.calculateTextureWidthAndHeight(t.dims,a.TextureType.unpacked),l=t.dims.length;if(n<1||r<1)throw new Error("Logical row count N and feature count D must be greater than or equal to 1");if(1!==o.length||1!==i.length)throw new Error("Dimensionality of the intermediate results should be 1");if(o[0]!==n||i[0]!==n)throw new Error("Shape of the intermediate results should be equal to logical row count");const p=`\n float process(int[${l}] indices) {\n\n // get offset of current logical tensor index from the 2-D texture coordinates (TexCoords)\n int offset = coordsToOffset(TexCoords, ${s}, ${u});\n\n //determine the logical row for this index\n int logical_row_index[1];\n logical_row_index[0] = offset / ${r};\n\n float norm_factor = _Norm(logical_row_index);\n\n // avoid possible division by 0\n // if norm_facor is 0, all elements are zero\n // if so, return 0\n if(norm_factor == 0.0)\n return 0.0;\n\n return exp(_A(indices) - _Max(logical_row_index)) / norm_factor;\n }`;return Object.assign(Object.assign({},c),{output:{dims:t.dims,type:t.type,textureType:a.TextureType.unpacked},shaderSource:p})},g=e=>{if(!e||1!==e.length)throw new Error("Softmax requires 1 input.");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("Invalid input type")}},564:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseSplitAttributes=t.split=void 0;const r=n(4910),o=n(7273),i=n(5639),a={name:"Split",inputNames:["A"],inputTypes:[i.TextureType.unpacked]};t.split=(e,t,n)=>{l(t);const r=o.ShapeUtil.normalizeAxis(n.axis,t[0].dims.length),i=s(e,t,r,n),c=[];for(let o=0;ou(e,t[0],n,r,o)}),t));return c},t.parseSplitAttributes=e=>{const t=e.attributes.getInt("axis",0),n=e.attributes.getInts("split",[]),o=e.outputs.length;return(0,r.createAttributeWithCacheKey)({axis:t,split:n,numOutputs:o})};const s=(e,t,n,r)=>{const[,i]=o.SplitUtil.splitShape(t[0].dims,n,r.split,r.numOutputs);return i.length},u=(e,t,n,r,s)=>{const[u,l]=o.SplitUtil.splitShape(t.dims,r,n.split,n.numOutputs),c=l[s],p=u[s],d=`\n float process(int indices[${p.length}]) {\n indices[${r}] += ${c};\n return _A(indices);\n }\n `;return Object.assign(Object.assign({},a),{cacheHint:`${n.cacheKey}:${s}`,output:{dims:p,type:t.type,textureType:i.TextureType.unpacked},shaderSource:d})},l=e=>{if(!e||1!==e.length)throw new Error("Split requires one input.");if("int8"!==e[0].type&&"uint8"!==e[0].type&&"int16"!==e[0].type&&"uint16"!==e[0].type&&"int32"!==e[0].type&&"uint32"!==e[0].type&&"float32"!==e[0].type&&"float64"!==e[0].type&&"bool"!==e[0].type)throw new Error("Invalid input type.")}},5416:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseSqueezeAttributes=t.squeezeV13=t.squeeze=void 0;const r=n(7273);t.squeeze=(e,t,n)=>{o(t);const i=r.ShapeUtil.squeezeShape(t[0].dims,n);return[e.reshapeUnpacked(t[0],i)]},t.squeezeV13=(e,n)=>(i(n),(0,t.squeeze)(e,[n[0]],Array.from(n[1].integerData))),t.parseSqueezeAttributes=e=>e.attributes.getInts("axes");const o=e=>{if(!e||1!==e.length)throw new Error("Squeeze requires 1 input.");if("string"===e[0].type)throw new Error("invalid input tensor types.")},i=e=>{if(!e||2!==e.length)throw new Error("Squeeze requires 2 inputs.");if("int32"!==e[1].type)throw new Error("Invalid input type.")}},1240:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sum=void 0;const r=n(6757),o=n(5639);t.sum=(e,t)=>{a(t);const n={name:"Sum",inputNames:t.map(((e,t)=>`X${t}`)),inputTypes:new Array(t.length).fill(o.TextureType.unpacked)};return[e.run(Object.assign(Object.assign({},n),{get:()=>i(e,t,n)}),t)]};const i=(e,t,n)=>{const i=(0,r.getGlsl)(e.session.backend.glContext.version),a=t[0].dims.slice(),s=`\n void main() {\n vec4 result = ${t.map(((e,t)=>`${i.texture2D}(X${t},TexCoords)`)).join(" + ")};\n ${i.output} = result;\n }\n `;return Object.assign(Object.assign({},n),{output:{dims:a,type:t[0].type,textureType:o.TextureType.unpacked},hasMain:!0,shaderSource:s})},a=e=>{if(!e||0===e.length)throw new Error("Sum requires inputs.");const t=e[0].dims.length;for(let n=1;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tile=void 0;const r=n(6145),o=n(5639);t.tile=(e,t)=>{a(t);const n={name:"Tile",inputNames:["A"],inputTypes:[o.TextureType.unpacked]};return[e.run(Object.assign(Object.assign({},n),{get:()=>i(e,t,n)}),t)]};const i=(e,t,n)=>{const r=t[0].dims.slice(),i=new Array(r.length),a=[];for(let e=0;e{if(!e||2!==e.length)throw new Error("Tile requires 2 input.");if(1!==e[1].dims.length)throw new Error("The second input shape must 1 dimension.");if(e[1].dims[0]!==e[0].dims.length)throw new Error("Invalid input shape.");if(-1===r.NUMBER_TYPES.indexOf(e[0].type))throw new Error("Invalid input type.");if("int32"!==e[1].type&&"int16"!==e[1].type)throw new Error("Invalid repeat type.")}},5707:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseTransposeAttributes=t.transpose=void 0;const r=n(4910),o=n(7273),i=n(5639),a={name:"Transpose",inputNames:["A"],inputTypes:[i.TextureType.unpacked]};t.transpose=(e,t,n)=>(p(t),[e.run(Object.assign(Object.assign({},a),{cacheHint:n.cacheKey,get:()=>s(e,t[0],n.perm)}),t)]),t.parseTransposeAttributes=e=>(0,r.createAttributeWithCacheKey)({perm:e.attributes.getInts("perm",[])});const s=(e,t,n)=>{const r=t.dims;n=u(r,n);const o=l(r,n),s=r.length,p=`\n ${c("perm",n,s)}\n float process(int indices[${s}]) {\n int a[${s}];\n perm(a, indices);\n return _A(a);\n }`;return Object.assign(Object.assign({},a),{output:{dims:o,type:t.type,textureType:i.TextureType.unpacked},shaderSource:p})},u=(e,t)=>(t&&t.length!==e.length&&(t=[...e.keys()].reverse()),t),l=(e,t)=>(t=u(e,t),o.ShapeUtil.sortBasedOnPerm(e,t)),c=(e,t,n)=>{const r=[];r.push(`void ${e}(out int a[${n}], int src[${n}]) {`);for(let e=0;e{if(!e||1!==e.length)throw new Error("Transpose requires 1 input.");if("float32"!==e[0].type&&"float64"!==e[0].type)throw new Error("input should be float tensor")}},2488:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.encodeAsUint8=void 0;const r=n(6757),o=n(5639);t.encodeAsUint8=(e,t)=>{const n=t.shape,i=(0,r.getGlsl)(e.session.backend.glContext.version),a=`\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n bool isNaN(float val) {\n return (val < 1.0 || 0.0 < val || val == 0.0) ? false : true;\n }\n\n highp vec4 encodeAsUint8(highp float v) {\n if (isNaN(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n\n void main() {\n float value = ${i.texture2D}(X,TexCoords).r;\n ${i.output} = encodeAsUint8(value);\n }`,s={name:"Uint8Encode",inputTypes:[o.TextureType.unpacked],inputNames:["X"],output:{dims:n,type:t.tensor.type,textureType:o.TextureType.downloadUint8AsFloat},shaderSource:a,hasMain:!0};return e.executeProgram(s,[t.tensor])}},9087:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tanh=t.tan=t.sqrt=t.sin=t.sigmoid=t.relu=t.not=t.neg=t.log=t.parseLeakyReluAttributes=t.leakyRelu=t.identity=t.floor=t.exp=t.parseEluAttributes=t.elu=t.cos=t.ceil=t.clipV11=t.parseClipAttributes=t.clip=t.atan=t.asin=t.acos=t.abs=t.glslTanh=t.glslTan=t.glslSqrt=t.glslSigmoid=t.glslRelu=t.glslSin=t.glslNot=t.glslNeg=t.glslLog=t.glslLeakyRelu=t.glslIdentity=t.glslClip=t.glslFloor=t.glslExp=t.glslElu=t.glslCos=t.glslCeil=t.glslAtan=t.glslAsin=t.glslAcos=t.glslAbs=void 0;const r=n(4910),o=n(7273),i=n(1997),a=n(6757),s=n(5639);function u(){return $("abs")}function l(){return $("acos")}function c(){return $("asin")}function p(){return $("atan")}function d(){return $("ceil")}function f(){return $("cos")}function h(e){const t="elu";return{body:`\n const float alpha = float(${e});\n\n float ${t}_(float a) {\n return a >= 0.0 ? a: (exp(a) - 1.0) * alpha;\n }\n vec4 ${t}_(vec4 v) {\n return vec4(${t}_(v.x), ${t}_(v.y), ${t}_(v.z), ${t}_(v.w));\n }\n `,name:t,type:i.FunctionType.ValueBased}}function g(){return $("exp")}function m(){return $("floor")}function b(e,t){const n="clip";return{body:`\n const float min = float(${e});\n const float max = float(${t});\n\n float ${n}_(float a) {\n return clamp(a, min, max);\n }\n vec4 ${n}_(vec4 v) {\n return clamp(v, min, max);\n }\n `,name:n,type:i.FunctionType.ValueBased}}function y(){const e="indentity";return{body:`\n float ${e}_(float a) {\n return a;\n }\n vec4 ${e}_(vec4 v) {\n return v;\n }\n `,name:e,type:i.FunctionType.ValueBased}}function w(e){const t="leakyRelu";return{body:`\n const float alpha = float(${e});\n\n float ${t}_(float a) {\n return a < 0.0 ? a * alpha : a;\n }\n vec4 ${t}_(vec4 v) {\n return vec4(${t}_(v.x), ${t}_(v.y), ${t}_(v.z), ${t}_(v.w));\n }\n `,name:t,type:i.FunctionType.ValueBased}}function _(){return $("log")}function v(){const e="neg";return{body:`\n float ${e}_(float a) {\n return -a;\n }\n vec4 ${e}_(vec4 v) {\n return -v;\n }\n `,name:e,type:i.FunctionType.ValueBased}}function x(){const e="not";return{body:`\n float ${e}_(float a) {\n return float( ! bool(a) );\n }\n bool ${e}_(bool a) {\n return !a;\n }\n vec4 ${e}_(vec4 v) {\n return vec4(!bool(v.x), !bool(v.y), !bool(v.z), !bool(v.w));\n }\n bvec4 ${e}_(bvec4 v) {\n return bvec4(!v.x, !v.y, !v.z, !v.w);\n }\n `,name:e,type:i.FunctionType.ValueBased}}function T(){return $("sin")}function S(){const e="relu";return{body:`\n float ${e}_(float a) {\n return max( a, 0.0 );\n }\n vec4 ${e}_(vec4 v) {\n return max( v, 0.0 );\n }\n `,name:e,type:i.FunctionType.ValueBased}}function O(){const e="sigmoid";return{body:`\n float ${e}_(float a) {\n return 1.0 / (1.0 + exp(-a));\n }\n vec4 ${e}_(vec4 v) {\n return 1.0 / (1.0 + exp(-v));\n }\n `,name:e,type:i.FunctionType.ValueBased}}function A(){return $("sqrt")}function E(){return $("tan")}function I(){const e="tanh";return{body:`\n float ${e}_(float a) {\n a = clamp(a, -10., 10.);\n a = exp(2.*a);\n return (a - 1.) / (a + 1.);\n }\n vec4 ${e}_(vec4 v) {\n v = clamp(v, -10., 10.);\n v = exp(2.*v);\n return (v - 1.) / (v + 1.);\n }\n `,name:e,type:i.FunctionType.ValueBased}}function $(e){return{body:`\n float ${e}_(float a) {\n return ${e}(a);\n }\n vec4 ${e}_(vec4 v) {\n return ${e}(v);\n }\n `,name:e,type:i.FunctionType.ValueBased}}t.glslAbs=u,t.glslAcos=l,t.glslAsin=c,t.glslAtan=p,t.glslCeil=d,t.glslCos=f,t.glslElu=h,t.glslExp=g,t.glslFloor=m,t.glslClip=b,t.glslIdentity=y,t.glslLeakyRelu=w,t.glslLog=_,t.glslNeg=v,t.glslNot=x,t.glslSin=T,t.glslRelu=S,t.glslSigmoid=O,t.glslSqrt=A,t.glslTan=E,t.glslTanh=I;const P=(e,t,n,r)=>{const o=e.session.pack?s.TextureType.packed:s.TextureType.unpacked,i={name:n.name,inputTypes:[o],inputNames:["A"],cacheHint:r};return Object.assign(Object.assign({},i),{get:()=>((e,t,n,r)=>{const o=e.session.pack?s.TextureType.packed:s.TextureType.unpacked,i=(0,a.getGlsl)(e.session.backend.glContext.version);return Object.assign(Object.assign({},t),{output:{dims:n.dims,type:n.type,textureType:o},shaderSource:`\n ${r.body}\n void main() {\n vec4 v = ${i.texture2D}(A, TexCoords);\n v = ${r.name}_(v);\n ${i.output} = v;\n }\n `,hasMain:!0})})(e,i,t,n)})};t.abs=(e,t)=>[e.run(P(e,t[0],u()),t)],t.acos=(e,t)=>[e.run(P(e,t[0],l()),t)],t.asin=(e,t)=>[e.run(P(e,t[0],c()),t)],t.atan=(e,t)=>[e.run(P(e,t[0],p()),t)],t.clip=(e,t,n)=>[e.run(P(e,t[0],b(n.min,n.max),n.cacheKey),t)],t.parseClipAttributes=e=>(0,r.createAttributeWithCacheKey)({min:e.attributes.getFloat("min",o.MIN_CLIP),max:e.attributes.getFloat("max",o.MAX_CLIP)}),t.clipV11=(e,n)=>{const r=D(e,n);return(0,t.clip)(e,[n[0]],r)};const D=(e,t)=>{if(t.length>=3&&(!e.session.isInitializer(t[1].dataId)||!e.session.isInitializer(t[2].dataId)))throw new Error("dynamic clip attributes are not allowed");const n=t.length>=3?t[1].numberData[0]:o.MIN_CLIP,i=t.length>=3?t[2].numberData[0]:o.MAX_CLIP;return(0,r.createAttributeWithCacheKey)({min:n,max:i})};t.ceil=(e,t)=>[e.run(P(e,t[0],d()),t)],t.cos=(e,t)=>[e.run(P(e,t[0],f()),t)],t.elu=(e,t,n)=>[e.run(P(e,t[0],h(n.alpha),n.cacheKey),t)],t.parseEluAttributes=e=>(0,r.createAttributeWithCacheKey)({alpha:e.attributes.getFloat("alpha",1)}),t.exp=(e,t)=>[e.run(P(e,t[0],g()),t)],t.floor=(e,t)=>[e.run(P(e,t[0],m()),t)],t.identity=(e,t)=>[e.run(P(e,t[0],y()),t)],t.leakyRelu=(e,t,n)=>[e.run(P(e,t[0],w(n.alpha),n.cacheKey),t)],t.parseLeakyReluAttributes=e=>(0,r.createAttributeWithCacheKey)({alpha:e.attributes.getFloat("alpha",.01)}),t.log=(e,t)=>[e.run(P(e,t[0],_()),t)],t.neg=(e,t)=>[e.run(P(e,t[0],v()),t)],t.not=(e,t)=>[e.run(P(e,t[0],x()),t)],t.relu=(e,t)=>[e.run(P(e,t[0],S()),t)],t.sigmoid=(e,t)=>[e.run(P(e,t[0],O()),t)],t.sin=(e,t)=>[e.run(P(e,t[0],T()),t)],t.sqrt=(e,t)=>[e.run(P(e,t[0],A()),t)],t.tan=(e,t)=>[e.run(P(e,t[0],E()),t)],t.tanh=(e,t)=>[e.run(P(e,t[0],I()),t)]},540:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createUnpackProgramInfoLoader=t.createUnpackProgramInfo=void 0;const r=n(6757),o=n(5639),i=n(432),a=n(5614),s={name:"unpack",inputNames:["A"],inputTypes:[o.TextureType.packed]};t.createUnpackProgramInfo=(e,t)=>{const n=t.dims.length,u=(0,a.getChannels)("rc",n),l=u.slice(-2),c=(0,i.getCoordsDataType)(n),p=(0,a.unpackFromChannel)(),d=0===t.dims.length?"":function(e,t){if(1===e)return"rc";let n="";for(let r=0;rObject.assign(Object.assign({},s),{get:()=>(0,t.createUnpackProgramInfo)(e,n)})},7862:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseUnsqueezeAttributes=t.unsqueezeV13=t.unsqueeze=void 0;const r=n(7273);t.unsqueeze=(e,t,n)=>{o(t);const i=r.ShapeUtil.unsqueezeShape(t[0].dims,n);return[e.reshapeUnpacked(t[0],i)]},t.unsqueezeV13=(e,n)=>(i(n),(0,t.unsqueeze)(e,[n[0]],Array.from(n[1].integerData))),t.parseUnsqueezeAttributes=e=>e.attributes.getInts("axes");const o=e=>{if(!e||1!==e.length)throw new Error("Unsqueeze requires 1 input.");if("string"===e[0].type)throw new Error("invalid input tensor types.")},i=e=>{if(!e||2!==e.length)throw new Error("Unsqueeze requires 2 inputs.");if("int32"!==e[1].type)throw new Error("Invalid input type.")}},3980:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.scalesValidation=t.validateInputs=t.parseUpsampleAttributes=t.parseUpsampleAttributesV9=t.parseUpsampleAttributesV7=t.upsample=void 0;const r=n(4910),o=n(6757),i=n(5639),a={name:"Upsample",inputNames:["X"],inputTypes:[i.TextureType.unpacked]};t.upsample=(e,n,r)=>((0,t.validateInputs)(n,r),[e.run(Object.assign(Object.assign({},a),{cacheHint:r.cacheKey,get:()=>s(e,n,r)}),n)]),t.parseUpsampleAttributesV7=e=>(0,t.parseUpsampleAttributes)(e,7),t.parseUpsampleAttributesV9=e=>(0,t.parseUpsampleAttributes)(e,9),t.parseUpsampleAttributes=(e,n)=>{const o=n>=10,i=e.attributes.getString("mode","nearest");if("nearest"!==i&&"linear"!==i&&(n<11||"cubic"!==i))throw new Error(`unrecognized mode: ${i}`);let a=[];n<9&&(a=e.attributes.getFloats("scales"),(0,t.scalesValidation)(a,i,o));const s=e.attributes.getFloat("extrapolation_value",0),u=n>10?e.attributes.getString("coordinate_transformation_mode","half_pixel"):"asymmetric";if(-1===["asymmetric","pytorch_half_pixel","tf_half_pixel_for_nn","align_corners","tf_crop_and_resize","half_pixel"].indexOf(u))throw new Error(`coordinate_transform_mode '${u}' is not supported`);const l="tf_crop_and_resize"===u,c=l,p="nearest"===i&&n>=11?e.attributes.getString("nearest_mode","round_prefer_floor"):"";if(-1===["round_prefer_floor","round_prefer_ceil","floor","ceil",""].indexOf(p))throw new Error(`nearest_mode '${p}' is not supported`);const d=e.attributes.getFloat("cubic_coeff_a",-.75),f=0!==e.attributes.getInt("exclude_outside",0);if(f&&"cubic"!==i)throw new Error("exclude_outside can be set to 1 only when mode is CUBIC.");const h=n<11||"nearest"===i&&"asymmetric"===u&&"floor"===p;let g=0,m=0,b=0;return n>10?e.inputs.length>2?(g=1,m=2,b=3):(m=1,b=2):9===n&&(m=1),(0,r.createAttributeWithCacheKey)({opset:n,isResize:o,mode:i,scales:a,extrapolationValue:s,coordinateTransformMode:u,useExtrapolation:c,needRoiInput:l,nearestMode:p,cubicCoefficientA:d,excludeOutside:f,useNearest2xOptimization:h,roiInputIdx:g,scalesInputIdx:m,sizesInputIdx:b})};const s=(e,t,n)=>{const r=(0,o.getGlsl)(e.session.backend.glContext.version),[s,u]=e.calculateTextureWidthAndHeight(t[0].dims,i.TextureType.unpacked),l=t[0].dims.map(((e,t)=>Math.floor(e*n.scales[t]))),[c,p]=e.calculateTextureWidthAndHeight(l,i.TextureType.unpacked),d=l.length,f=new Array(d),h=new Array(d);let g=`\n int output_pitches[${d}];\n int input_pitches[${d}];\n `;for(let e=d-1;e>=0;e--)f[e]=e===d-1?1:f[e+1]*l[e+1],h[e]=e===d-1?1:h[e+1]*t[0].dims[e+1],g+=`\n output_pitches[${e}] = ${f[e]};\n input_pitches[${e}] = ${h[e]};\n `;const m=`\n float getInputFloat(int index) {\n vec2 coords = offsetToCoords(index, ${s}, ${u});\n float value = getColorAsFloat(${r.texture2D}(X, coords));\n return value;\n }\n `,b="nearest"===n.mode?`\n ${m}\n float process(int indices[${d}]) {\n int input_index = 0;\n int output_index = coordsToOffset(TexCoords, ${c}, ${p});\n\n ${g}\n\n int d, m;\n for (int dim = 0; dim < ${d}; ++dim) {\n d = output_index / output_pitches[dim];\n m = output_index - d * output_pitches[dim];\n output_index = m;\n\n if (scales[dim] != 1 && d > 0) {\n int d2 = d / scales[dim];\n m = d - d2 * scales[dim];\n d = d2;\n }\n input_index += input_pitches[dim] * d;\n }\n\n return getInputFloat(input_index);\n }`:4===d?`\n ${m}\n float process(int indices[4]) {\n int input_index = 0;\n int output_index = coordsToOffset(TexCoords, ${c}, ${p});\n\n ${g}\n\n int m;\n int index_of_dim0, index_of_dim1, index_of_dim2, index_of_dim3;\n index_of_dim0 = output_index / output_pitches[0];\n m = output_index - index_of_dim0 * output_pitches[0];\n index_of_dim1 = m / output_pitches[1];\n m = m - index_of_dim1 * output_pitches[1];\n index_of_dim2 = m / output_pitches[2];\n m = m - index_of_dim2 * output_pitches[2];\n index_of_dim3 = m;\n\n int index_of_input_dim2, index_of_input_dim3, x_offset, y_offset;\n index_of_input_dim2 = index_of_dim2 / scales[2];\n y_offset = index_of_dim2 - index_of_input_dim2 * scales[2];\n index_of_input_dim3 = index_of_dim3 / scales[3];\n x_offset = index_of_dim3 - index_of_input_dim3 * scales[3];\n\n input_index = index_of_dim0 * input_pitches[0] +\n index_of_dim1 * input_pitches[1] +\n index_of_input_dim2 * input_pitches[2] +\n index_of_input_dim3;\n\n float x00 = getInputFloat(input_index);\n float x10, x01, x11;\n\n bool end_of_dim2 = false;\n if (index_of_input_dim2 == (${t[0].dims[2]} - 1)) {\n // It's the end in dimension 2\n x01 = x00;\n end_of_dim2 = true;\n } else {\n x01 = getInputFloat(input_index + input_pitches[2]);\n }\n\n if (index_of_input_dim3 == (input_pitches[2] - 1)) {\n // It's the end in dimension 3\n x10 = x00;\n x11 = x01;\n }\n else {\n x10 = getInputFloat(input_index + 1);\n x11 = end_of_dim2 ? x10 : getInputFloat(input_index + input_pitches[2] + 1);\n }\n\n float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[2]);\n float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[2]);\n return y0 + float(x_offset) * (y1 - y0) / float(scales[3]);\n }`:`\n ${m}\n float process(int indices[2]) {\n int input_index = 0;\n int output_index = coordsToOffset(TexCoords, ${c}, ${p});\n\n ${g}\n\n int m;\n int index_of_dim0, index_of_dim1;\n index_of_dim0 = output_index / output_pitches[0];\n m = output_index - index_of_dim0 * output_pitches[0];\n index_of_dim1 = m;\n\n int index_of_input_dim0, index_of_input_dim1, x_offset, y_offset;\n index_of_input_dim0 = index_of_dim0 / scales[0];\n y_offset = index_of_dim0 - index_of_input_dim0 * scales[0];\n index_of_input_dim1 = index_of_dim1 / scales[1];\n x_offset = index_of_dim1 - index_of_input_dim1 * scales[1];\n\n input_index = index_of_input_dim0 * input_pitches[0] + index_of_input_dim1;\n\n float x00 = getInputFloat(input_index);\n float x10, x01, x11;\n\n bool end_of_dim0 = false;\n if (index_of_input_dim0 == (${t[0].dims[0]} - 1)) {\n // It's the end in dimension 0\n x01 = x00;\n end_of_dim0 = true;\n } else {\n x01 = getInputFloat(input_index + input_pitches[0]);\n }\n\n if (index_of_input_dim1 == (input_pitches[0] - 1)) {\n // It's the end in dimension 1\n x10 = x00;\n x11 = x01;\n }\n else {\n x10 = getInputFloat(input_index + 1);\n x11 = end_of_dim0 ? x10 : getInputFloat(input_index + input_pitches[0] + 1);\n }\n\n float y0 = x00 + float(y_offset) * (x01 - x00) / float(scales[0]);\n float y1 = x10 + float(y_offset) * (x11 - x10) / float(scales[0]);\n return y0 + float(x_offset) * (y1 - y0) / float(scales[1]);\n }`;return Object.assign(Object.assign({},a),{output:{dims:l,type:t[0].type,textureType:i.TextureType.unpacked},shaderSource:b,variables:[{name:"scales",type:"int",arrayLength:n.scales.length,data:n.scales.map((e=>Math.ceil(e)))}]})};t.validateInputs=(e,t)=>{if(!e||t.opset<9&&1!==e.length||t.opset>=9&&t.opset<11&&2!==e.length||t.opset>=11&&e.length<2)throw new Error("invalid inputs.");if(t.scales.length>0&&e[0].dims.length!==t.scales.length)throw new Error("Invalid input shape.");if("string"===e[0].type)throw new Error("Invalid input tensor types.")},t.scalesValidation=(e,t,n)=>{if(n){for(const t of e)if(t<=0)throw new Error("Scale value should be greater than 0.")}else for(const t of e)if(t<1)throw new Error("Scale value should be greater than or equal to 1.");if(!("linear"!==t&&"cubic"!==t||2===e.length||4===e.length&&1===e[0]&&1===e[1]))throw new Error(`'Linear' mode and 'Cubic' mode only support 2-D inputs ('Bilinear', 'Bicubic') or 4-D inputs with the corresponding outermost 2 scale values being 1 in the ${n?"Resize":"Upsample"} opeartor.`)}},2757:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgramManager=void 0;const r=n(8453),o=n(1315),i=n(8897),a=n(6757);t.ProgramManager=class{constructor(e,t,n){this.profiler=e,this.glContext=t,this.textureLayoutStrategy=n,this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,t){this.repo.set(e,t)}run(e,t,n){var r;this.profiler.event("op",`ProgramManager.run ${null!==(r=e.programInfo.name)&&void 0!==r?r:"unknown kernel"}`,(()=>{var r;const i=this.glContext.gl,a=e.program;i.useProgram(a);try{this.bindOutput(n),this.attributesBound||this.bindAttributes(e.attribLocations),this.bindUniforms(e.uniformLocations,null!==(r=e.programInfo.variables)&&void 0!==r?r:[],t)}catch(t){throw o.Logger.error("ProgramManager",e.programInfo.shaderSource),t}this.profiler.event("backend","GlContext.draw()",(()=>{this.glContext.draw()}))}),this.glContext)}dispose(){this.vertexShader&&this.glContext.deleteShader(this.vertexShader),this.repo.forEach((e=>this.glContext.deleteProgram(e.program)))}build(e,t,n){return this.profiler.event("backend","ProgramManager.build",(()=>{const r=new i.GlslPreprocessor(this.glContext,e,t,n),o=r.preprocess(),a=this.compile(o);return{programInfo:e,program:a,uniformLocations:this.getUniformLocations(a,r.context.programInfo.inputNames,r.context.programInfo.variables),attribLocations:this.getAttribLocations(a)}}))}compile(e){if(!this.vertexShader){o.Logger.verbose("ProrgramManager","Compiling and caching Vertex shader for the first time");const e=(0,a.getVertexShaderSource)(this.glContext.version);this.vertexShader=this.glContext.compileShader(e,this.glContext.gl.VERTEX_SHADER)}r.env.debug&&o.Logger.verbose("ProrgramManager",`FragShader:\n${e}\n`);const t=this.glContext.compileShader(e,this.glContext.gl.FRAGMENT_SHADER),n=this.glContext.createProgram(this.vertexShader,t);return this.glContext.deleteShader(t),n}bindOutput(e){const t=e.width,n=e.height;o.Logger.verbose("ProrgramManager",`Binding output texture to Framebuffer: w/h=${t}/${n}, shape=${e.shape}, type=${e.tensor.type}`),this.glContext.attachFramebuffer(e.texture,t,n)}bindAttributes(e){const t=e.position,n=e.textureCoord;this.glContext.setVertexAttributes(t,n),this.attributesBound=!0}bindUniforms(e,t,n){var r;const o=this.glContext.gl;let i=0;for(const{name:a,type:s,location:u,arrayLength:l}of e){const e=null===(r=t.find((e=>e.name===a)))||void 0===r?void 0:r.data;if("sampler2D"!==s&&!e)throw new Error(`variable '${a}' does not have data defined in program info`);switch(s){case"sampler2D":this.bindTexture(n[i],u,i),i++;break;case"float":l?o.uniform1fv(u,e):o.uniform1f(u,e);break;case"int":l?o.uniform1iv(u,e):o.uniform1i(u,e);break;default:throw new Error(`Uniform not implemented: ${s}`)}}}bindTexture(e,t,n){this.glContext.bindTextureToUniform(e.texture,n,t)}getAttribLocations(e){return{position:this.getAttribLocation(e,"position"),textureCoord:this.getAttribLocation(e,"textureCoord")}}getUniformLocations(e,t,n){const r=[];if(t)for(const n of t)r.push({name:n,type:"sampler2D",location:this.getUniformLocation(e,n)});if(n)for(const t of n)r.push(Object.assign(Object.assign({},t),{location:this.getUniformLocation(e,t.name)}));return r}getUniformLocation(e,t){const n=this.glContext.gl.getUniformLocation(e,t);if(null===n)throw new Error(`Uniform ${t} not found.`);return n}getAttribLocation(e,t){return this.glContext.gl.getAttribLocation(e,t)}}},2171:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLSessionHandler=void 0;const r=n(1315),o=n(5881),i=n(7860),a=n(4110),s=n(2757),u=n(7618),l=n(5243);t.WebGLSessionHandler=class{constructor(e,t){this.backend=e,this.context=t,this.layoutStrategy=new u.PreferLogicalStrategy(e.glContext.maxTextureSize),this.programManager=new s.ProgramManager(this.context.profiler,e.glContext,this.layoutStrategy),this.textureManager=new l.TextureManager(e.glContext,this.layoutStrategy,this.context.profiler,{reuseTextures:"full"===e.textureCacheMode}),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache=new Map,this.pack=e.pack,this.pack2unpackMap=new Map,this.unpack2packMap=new Map}createInferenceHandler(){return new i.WebGLInferenceHandler(this)}onGraphInitialized(e){const t=e.getValues().filter((e=>-1===e.from&&e.tensor)).map((e=>e.tensor.dataId));this.initializers=new Set(t)}isInitializer(e){return!!this.initializers&&this.initializers.has(e)}addInitializer(e){this.initializers.add(e)}getTextureData(e,t){return t?this.packedTextureDataCache.get(e):this.unpackedTextureDataCache.get(e)}setTextureData(e,t,n=!1){r.Logger.verbose("WebGLSessionHandler","Storing Texture data in cache"),n?this.packedTextureDataCache.set(e,t):this.unpackedTextureDataCache.set(e,t)}dispose(){this.programManager.dispose(),this.textureManager.clearActiveTextures(),this.packedTextureDataCache.forEach((e=>this.textureManager.releaseTexture(e,!0))),this.packedTextureDataCache=new Map,this.unpackedTextureDataCache.forEach((e=>this.textureManager.releaseTexture(e,!0))),this.unpackedTextureDataCache=new Map}resolve(e,t,n){const r=(0,o.resolveOperator)(e,t,a.WEBGL_OP_RESOLVE_RULES);return{impl:r.opImpl,context:r.opInit?r.opInit(e,n):e}}}},9622:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Uint8DataEncoder=t.RGBAFloatDataEncoder=t.RedFloat32DataEncoder=void 0;const r=n(1315);t.RedFloat32DataEncoder=class{constructor(e,t=1){if(1===t)this.internalFormat=e.R32F,this.format=e.RED,this.textureType=e.FLOAT,this.channelSize=t;else{if(4!==t)throw new Error(`Invalid number of channels: ${t}`);this.internalFormat=e.RGBA32F,this.format=e.RGBA,this.textureType=e.FLOAT,this.channelSize=t}}encode(e,t){let n,o;return e.constructor!==Float32Array&&(r.Logger.warning("Encoder","data was not of type Float32; creating new Float32Array"),o=new Float32Array(e)),t*this.channelSize>e.length?(r.Logger.warning("Encoder","Source data too small. Allocating larger array"),o=e,n=this.allocate(t*this.channelSize),o.forEach(((e,t)=>n[t]=e))):(o=e,n=o),n}allocate(e){return new Float32Array(4*e)}decode(e,t){return 1===this.channelSize?e.filter(((e,t)=>t%4==0)).subarray(0,t):e.subarray(0,t)}},t.RGBAFloatDataEncoder=class{constructor(e,t=1,n){if(1!==t&&4!==t)throw new Error(`Invalid number of channels: ${t}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.channelSize=t,this.textureType=n||e.FLOAT}encode(e,t){let n=e;return 1===this.channelSize&&(r.Logger.verbose("Encoder","Exploding into a larger array"),n=this.allocate(t),e.forEach(((e,t)=>n[4*t]=e))),n}allocate(e){return new Float32Array(4*e)}decode(e,t){return 1===this.channelSize?e.filter(((e,t)=>t%4==0)).subarray(0,t):e.subarray(0,t)}},t.Uint8DataEncoder=class{constructor(e,t=1){if(this.channelSize=4,1===t)this.internalFormat=e.ALPHA,this.format=e.ALPHA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=t;else{if(4!==t)throw new Error(`Invalid number of channels: ${t}`);this.internalFormat=e.RGBA,this.format=e.RGBA,this.textureType=e.UNSIGNED_BYTE,this.channelSize=t}}encode(e,t){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}allocate(e){return new Uint8Array(e*this.channelSize)}decode(e,t){if(e instanceof Uint8Array)return e.subarray(0,t);throw new Error(`Invalid array type: ${e.constructor}`)}}},7618:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBatchDim=t.sizeToSquarishShape=t.getRowsCols=t.sizeFromShape=t.isInt=t.parseAxisParam=t.squeezeShape=t.PreferLogicalStrategy=t.AlwaysKeepOriginalSizeStrategy=void 0;const r=n(1315),o=n(7273);function i(e,t){const n=[],r=[],o=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||o?null:a(t,e).sort();let s=0;for(let t=0;tt)&&1===e[t]&&(n.push(e[t]),r.push(t)),i[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function a(e,t){const n=t.length;return e=null==e?t.map(((e,t)=>t)):[].concat(e),(0,o.assert)(e.every((e=>e>=-n&&e`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),(0,o.assert)(e.every(s),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function s(e){return e%1==0}function u(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n=e.length?1:e.slice(t.breakAxis).reduce(((e,t)=>e*t)),i=t.breakAxis<=0?1:e.slice(0,t.breakAxis).reduce(((e,t)=>e*t));if(!(o>n||i>n))return[o,i];r.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${t.breakAxis}`)}const o=e.reduce(((e,t)=>e*t));let i=Math.floor(Math.sqrt(o));for(;i=n||o%i!=0)throw new Error(`The given dimensions are outside this GPU's boundaries: ${e}`);return[i,o/i]}},t.PreferLogicalStrategy=class{constructor(e){this.maxTextureSize=e}computeTextureWH(e,t){const n=this.computeTexture(e,t);return t&&t.isPacked&&(n[0]/=2,n[1]/=2),t&&t.reverseWH?[n[1],n[0]]:n}computeTexture(e,t){const n=t&&t.isPacked;if(0===e.length)return n?[2,2]:[1,1];let o=this.maxTextureSize;if(t&&void 0!==t.breakAxis){const n=t.breakAxis>=e.length?1:e.slice(t.breakAxis).reduce(((e,t)=>e*t)),i=t.breakAxis<=0?1:e.slice(0,t.breakAxis).reduce(((e,t)=>e*t));if(!(n>o||i>o))return[n,i];r.Logger.verbose("TextureLayout",`Given width/height preferences were unattainable: shape:${e}, breakAxis:${t.breakAxis}`)}let a=e.slice(0);if(n&&(o*=2,a=a.map(((e,t)=>t>=a.length-2?a[t]%2==0?a[t]:a[t]+1:a[t])),1===a.length&&(a=[2,a[0]])),2!==a.length){const e=i(a);a=e.newShape}const s=u(a);return a.length<=1&&s<=o?[1,s]:2===a.length&&a[0]<=o&&a[1]<=o?a:3===a.length&&a[0]*a[1]<=o&&a[2]<=o?[a[0]*a[1],a[2]]:3===a.length&&a[0]<=o&&a[1]*a[2]<=o?[a[0],a[1]*a[2]]:4===a.length&&a[0]*a[1]*a[2]<=o&&a[3]<=o?[a[0]*a[1]*a[2],a[3]]:4===a.length&&a[0]<=o&&a[1]*a[2]*a[3]<=o?[a[0],a[1]*a[2]*a[3]]:n?l(s/4).map((e=>2*e)):l(s)}},t.squeezeShape=i,t.parseAxisParam=a,t.isInt=s,t.sizeFromShape=u,t.getRowsCols=function(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]},t.sizeToSquarishShape=l,t.getBatchDim=function(e,t=2){return u(e.slice(0,e.length-t))}},3314:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createTextureLayoutFromShape=t.calculateTextureWidthAndHeight=t.createTextureLayoutFromTextureType=void 0;const r=n(7273),o=n(5639);t.createTextureLayoutFromTextureType=(e,n,r)=>{const i=r===o.TextureType.unpacked||r===o.TextureType.unpackedReversed?1:4,a=r===o.TextureType.packed,s=r===o.TextureType.unpackedReversed||r===o.TextureType.packed,u=r===o.TextureType.packedLastDimension?n.length-1:void 0,l=r===o.TextureType.packedLastDimension?n.map(((e,t)=>t===n.length-1?4*e:e)):void 0;return(0,t.createTextureLayoutFromShape)(e,n,i,l,{isPacked:a,reverseWH:s,breakAxis:u})},t.calculateTextureWidthAndHeight=(e,n,r)=>{const o=(0,t.createTextureLayoutFromTextureType)(e,n,r);return[o.width,o.height]},t.createTextureLayoutFromShape=(e,t,n=1,o,i)=>{const a=!(!i||!i.isPacked),[s,u]=e.computeTextureWH(a&&o||t,i),l=t.length;let c=t.slice(0);if(0===l&&(c=[1]),1===n)o=t;else if(a){if(4!==n)throw new Error("a packed texture must be 4-channel");o=t,l>0&&(c[l-1]=Math.ceil(c[l-1]/2)),l>1&&(c[l-2]=Math.ceil(c[l-2]/2))}else if(!o)throw new Error("Unpacked shape is needed when using channels > 1");return{width:s,height:u,channels:n,isPacked:a,shape:c,strides:r.ShapeUtil.computeStrides(c),unpackedShape:o,reversedWH:i&&i.reverseWH}}},5243:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TextureManager=void 0;const r=n(1315);t.TextureManager=class{constructor(e,t,n,r){this.glContext=e,this.layoutStrategy=t,this.profiler=n,this.config=r,this.pendingRead=new Map,r.reuseTextures&&(this.inUseTextures=new Map,this.idleTextures=new Map,this.textureLookup=new Map)}createTextureFromLayout(e,t,n,o){const i=this.toEncoderType(e),a=this.glContext.getEncoder(i,t.channels||1,o);if(t.isPacked&&1===o)throw new Error("not implemented");const s=t.width,u=t.height;let l,c;if(this.config.reuseTextures){l=`${s}x${u}_${a.format}_${a.internalFormat}_${a.textureType}`,c=this.inUseTextures.get(l),c||(c=[],this.inUseTextures.set(l,c));const t=this.idleTextures.get(l);if(t&&t.length>0){const r=t.pop();return c.push(r),1===o&&this.glContext.updateTexture(r,s,u,a,this.toTextureData(e,n)),r}}r.Logger.verbose("TextureManager",`Creating new texture of size ${t.width}x${t.height}`);const p=this.glContext.allocateTexture(s,u,a,this.toTextureData(e,n));return this.config.reuseTextures&&(c.push(p),this.textureLookup.set(p,l)),p}readTexture(e,t,n){return n||(n=1),this.profiler.event("backend","TextureManager.readTexture",(()=>{const r=e.shape.reduce(((e,t)=>e*t))*n,o=this.glContext.readTexture(e.texture,e.width,e.height,r,this.toEncoderType(t),n);return this.toTensorData(t,o)}))}async readTextureAsync(e,t,n){const r=e.tensor.dataId;if(n||(n=1),this.pendingRead.has(r)){const e=this.pendingRead.get(r);return new Promise((t=>null==e?void 0:e.push(t)))}return this.profiler.event("backend","TextureManager.readTextureAsync",(async()=>{this.pendingRead.set(r,[]);const o=e.shape.reduce(((e,t)=>e*t))*n;await this.glContext.createAndWaitForFence();const i=this.glContext.readTexture(e.texture,e.width,e.height,o,this.toEncoderType(t),n),a=this.toTensorData(t,i),s=this.pendingRead.get(r);return this.pendingRead.delete(r),null==s||s.forEach((e=>e(a))),a}))}readUint8TextureAsFloat(e){return this.profiler.event("backend","TextureManager.readUint8TextureAsFloat",(()=>{const t=e.shape.reduce(((e,t)=>e*t)),n=this.glContext.readTexture(e.texture,e.width,e.height,4*t,"byte",4);return new Float32Array(n.buffer,n.byteOffset,t)}))}releaseTexture(e,t){let n;if(this.config.reuseTextures&&(n=this.textureLookup.get(e.texture),n)){t&&this.textureLookup.delete(n);const r=this.inUseTextures.get(n);if(r){const t=r.indexOf(e.texture);if(-1!==t){r.splice(t,1);let o=this.idleTextures.get(n);o||(o=[],this.idleTextures.set(n,o)),o.push(e.texture)}}}n&&!t||(r.Logger.verbose("TextureManager",`Deleting texture of size ${e.width}x${e.height}`),this.glContext.deleteTexture(e.texture))}toTensorData(e,t){switch(e){case"int16":return t instanceof Int16Array?t:Int16Array.from(t);case"int32":return t instanceof Int32Array?t:Int32Array.from(t);case"int8":return t instanceof Int8Array?t:Int8Array.from(t);case"uint16":return t instanceof Uint16Array?t:Uint16Array.from(t);case"uint32":return t instanceof Uint32Array?t:Uint32Array.from(t);case"uint8":case"bool":return t instanceof Uint8Array?t:Uint8Array.from(t);case"float32":return t instanceof Float32Array?t:Float32Array.from(t);case"float64":return t instanceof Float64Array?t:Float64Array.from(t);default:throw new Error(`TensorData type ${e} is not supported`)}}toTextureData(e,t){if(t)return t instanceof Float32Array?t:new Float32Array(t)}toEncoderType(e){return"float"}clearActiveTextures(){this.glContext.clearActiveTextures()}}},5639:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.TextureType=void 0,(n=t.TextureType||(t.TextureType={}))[n.unpacked=0]="unpacked",n[n.unpackedReversed=1]="unpackedReversed",n[n.packed=2]="packed",n[n.downloadUint8AsFloat=3]="downloadUint8AsFloat",n[n.packedLastDimension=4]="packedLastDimension"},432:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getGlChannels=t.getCoordsDataType=t.getSqueezedParams=t.squeezeInputShape=t.generateShaderFuncNameFromInputSamplerNameAtOutCoords=t.generateShaderFuncNameFromInputSamplerName=t.repeatedTry=t.getPackedShape=void 0;const r=n(7273);t.getPackedShape=function(e){const t=e.length;return e.slice(0,t-1).concat(e[t-1]/4)},t.repeatedTry=async function(e,t=(e=>0),n){return new Promise(((r,o)=>{let i=0;const a=()=>{if(e())return void r();i++;const s=t(i);null!=n&&i>=n?o():setTimeout(a,s)};a()}))},t.generateShaderFuncNameFromInputSamplerName=function(e){return(0,r.assert)(void 0!==e&&0!==e.length,(()=>"empty string found for sampler name")),"get"+e.charAt(0).toUpperCase()+e.slice(1)},t.generateShaderFuncNameFromInputSamplerNameAtOutCoords=function(e){return(0,r.assert)(void 0!==e&&0!==e.length,(()=>"empty string found for sampler name")),"get"+e.charAt(0).toUpperCase()+e.slice(1)+"AtOutCoords"},t.squeezeInputShape=function(e,t){let n=JSON.parse(JSON.stringify(e));return n=t,n},t.getSqueezedParams=function(e,t){return t.map((t=>e[t])).join(", ")},t.getCoordsDataType=function(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)},t.getGlChannels=function(e=6){return["x","y","z","w","u","v"].slice(0,e)}},3389:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createNewWebGLContext=t.createWebGLContext=void 0;const r=n(1315),o=n(3524),i={};function a(e){const t=function(){if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas)throw new TypeError("failed to create canvas: OffscreenCanvas is not supported");return new OffscreenCanvas(1,1)}const e=document.createElement("canvas");return e.width=1,e.height=1,e}();let n;const i={alpha:!1,depth:!1,antialias:!1,stencil:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1,failIfMajorPerformanceCaveat:!1};if((!e||"webgl2"===e)&&(n=t.getContext("webgl2",i),n))try{return new o.WebGLContext(n,2)}catch(e){r.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl2'. Error: ${e}`)}if((!e||"webgl"===e)&&(n=t.getContext("webgl",i)||t.getContext("experimental-webgl",i),n))try{return new o.WebGLContext(n,1)}catch(e){r.Logger.warning("GlContextFactory",`failed to create WebGLContext using contextId 'webgl' or 'experimental-webgl'. Error: ${e}`)}throw new Error("WebGL is not supported")}t.createWebGLContext=function e(t){let n;t&&"webgl2"!==t||!("webgl2"in i)?t&&"webgl"!==t||!("webgl"in i)||(n=i.webgl):n=i.webgl2,n=n||a(t),t=t||1===n.version?"webgl":"webgl2";const r=n.gl;return i[t]=n,r.isContextLost()?(delete i[t],e(t)):(r.disable(r.DEPTH_TEST),r.disable(r.STENCIL_TEST),r.disable(r.BLEND),r.disable(r.DITHER),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SAMPLE_COVERAGE),r.enable(r.SCISSOR_TEST),r.enable(r.CULL_FACE),r.cullFace(r.BACK),n)},t.createNewWebGLContext=a},3524:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLContext=t.linearSearchLastTrue=void 0;const a=n(8453),s=i(n(9622)),u=n(432);function l(e){let t=0;for(;tthis.isTimerResultAvailable(e))),this.getTimerResult(e)}async createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t;const n=e,r=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),t=null===r?()=>!0:()=>{const e=n.clientWaitSync(r,0,0);return e===n.ALREADY_SIGNALED||e===n.CONDITION_SATISFIED},{query:r,isFencePassed:t}}async pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=l(this.itemsToPoll.map((e=>e.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}async addItemToPoll(e,t){this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1||await(0,u.repeatedTry)((()=>(this.pollItems(),0===this.itemsToPoll.length)))}}},6496:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ExecutionPlan=void 0;const r=n(1315);class o{constructor(e,t){this.op=e,this.node=t}}t.ExecutionPlan=class{constructor(e,t,n){this.graph=e,this.profiler=n,this.initialize(t)}initialize(e){this.profiler.event("session","ExecutionPlan.initialize",(()=>{const t=this.graph.getNodes();if(t.length!==e.length)throw new Error("The size of nodes and OPs do not match.");this._ops=e.map(((e,n)=>new o(e,t[n]))),this.reset(),this._starter=[],this._ops.forEach(((e,t)=>{let n=!0;for(const t of e.node.inputs)if(!this._values[t]&&-1===this.graph.getInputIndices().indexOf(t)){n=!1;break}n&&this._starter.push(t)}))}))}reset(){this._values=this.graph.getValues().map((e=>e.tensor))}async execute(e,t){return this.profiler.event("session","ExecutionPlan.execute",(async()=>{this.reset();const n=e.createInferenceHandler(),o=this.graph.getInputIndices();if(t.length!==o.length)throw new Error(`number of input tensors don't match the number of inputs to the model: actual: ${t.length} expected: ${o.length}`);t.forEach(((e,t)=>{const n=o[t];this._values[n]=e}));const i=this._starter.slice(0),a=this.graph.getValues(),s=this.graph.getNodes();let u=0;for(;uthis._values[e]));if(-1!==o.indexOf(void 0))throw new Error(`unresolved input detected: op: ${t.node}`);const l=o;r.Logger.verbose("ExecPlan",`Runing op:${t.node.name} (${l.map(((e,n)=>`'${t.node.inputs[n]}': ${e.type}[${e.dims.join(",")}]`)).join(", ")})`);const c=await this.profiler.event("node",t.node.name,(async()=>t.op.impl(n,l,t.op.context)));if(c.length!==t.node.outputs.length)throw new Error("the size of output does not match model definition.");c.forEach(((e,n)=>{const r=t.node.outputs[n];if(this._values[r])throw new Error(`output [${r}] already has value: op:${t.node.name}`);this._values[r]=e}));const p=new Set;c.forEach(((e,n)=>{const r=t.node.outputs[n];for(const e of a[r].to){const t=s[e];let n=!0;for(const e of t.inputs)if(!this._values[e]){n=!1;break}n&&p.add(e)}})),i.push(...p)}const l=[];for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Graph=void 0;const r=n(1446),o=n(6874),i=n(1287),a=n(9240),s=n(7273);var u=i.onnxruntime.experimental.fbs;t.Graph={from:(e,t)=>new p(e,t)};class l{constructor(e){this._from=void 0,this._to=[],this.tensor=void 0,this.type=void 0,e&&(this.type=s.ProtoUtil.tensorValueTypeFromProto(e.type.tensorType))}get from(){return this._from}get to(){return this._to}}class c{constructor(e,t){e instanceof r.onnx.NodeProto?(this.name=e.name,this.opType=e.opType,this.attributes=new o.Attribute(e.attribute)):e instanceof u.Node&&(this.name=null!=t?t:e.name(),this.opType=e.opType(),this.attributes=new o.Attribute(s.ProtoUtil.tensorAttributesFromORTFormat(e))),this.inputs=[],this.outputs=[],this.executeNode=!0}}class p{constructor(e,t){if(!e)throw new TypeError("graph is empty");this.buildGraph(e),this.transformGraph(t),this.checkIsAcyclic()}getInputIndices(){return this._allInputIndices}getInputNames(){return this._allInputNames}getOutputIndices(){return this._allOutputIndices}getOutputNames(){return this._allOutputNames}getValues(){return this._allData}getNodes(){return this._nodes}buildGraph(e){if(e instanceof r.onnx.GraphProto)this.buildGraphFromOnnxFormat(e);else{if(!(e instanceof u.Graph))throw new TypeError("Graph type is not supported.");this.buildGraphFromOrtFormat(e)}}buildGraphFromOnnxFormat(e){const t=new Map;this._allData=[],this._allInputIndices=[],this._allInputNames=[],this._allOutputIndices=[],this._allOutputNames=[],this._nodes=[];const n=new Map;if(!e.input)throw new Error("missing information in graph: input");const r=[];for(const n of e.input){if(t.has(n.name))throw new Error(`duplicated input name: ${n.name}`);const e=this._allData.push(new l(n))-1;t.set(n.name,e),r.push(n.name)}if(!e.initializer)throw new Error("missing information in graph: initializer");for(const n of e.initializer){let e=t.get(n.name);if(void 0===e){const r=new l;r.type={shape:{dims:s.ProtoUtil.tensorDimsFromProto(n.dims)},tensorType:s.ProtoUtil.tensorDataTypeFromProto(n.dataType)},e=this._allData.push(r)-1,t.set(n.name,e)}this._allData[e]._from=-1,this._allData[e].tensor=a.Tensor.fromProto(n)}for(let e=0;e{this._allData[t]._to.forEach((t=>{e.add(t)}))}));const t=Array.from(e),n=new Array(this._nodes.length).fill("white");for(;t.length>0;){const e=t.pop();"gray"===n[e]?n[e]="black":(t.push(e),n[e]="gray",this._nodes[e].outputs.forEach((r=>{const o=this._allData[r];if(void 0!==o.tensor)throw new Error("node outputs should not be initialized");if(o._from!==e)throw new Error("from property of the Value object doesn't match index of Node being processed");o._to.forEach((e=>{if("gray"===n[e])throw new Error("model graph is cyclic");"white"===n[e]&&t.push(e)}))})))}}transformGraph(e){this.removeAllIdentityNodes(),this.removeAllDropoutNodes(),this.fuseConvActivationNodes(),e&&e.transformGraph(this),this.finalizeGraph()}finalizeGraph(){let e=0;const t=new Array(this._nodes.length,0);let n=0;for(let e=0;e{this._allData[e]._from=-2}));this._nodes.splice(n,this._nodes.length-n);for(let e=0;e=0))throw new Error("Trying to update a removed node");n._to[e]=t[n._to[e]]}}e=0;for(let t=0;t0){let n=-1;void 0!==this._allData[t].from&&-1!==this._allData[t].from?(n=this._nodes[this._allData[t].from].outputs.indexOf(t+e),-1!==n&&(this._nodes[this._allData[t].from].outputs[n]=t)):(n=this._allInputIndices.indexOf(t+e),-1!==n&&(this._allInputIndices[n]=t)),this._allData[t].to.forEach((r=>{n=this._nodes[r].inputs.indexOf(t+e),-1!==n&&(this._nodes[r].inputs[n]=t)})),0===this._allData[t].to.length&&(n=this._allOutputIndices.indexOf(t+e),-1!==n&&(this._allOutputIndices[n]=t))}}else e++,this._allData.splice(t,1),t--}deleteNode(e){const t=this._nodes[e];if(t.outputs.length>1)for(let e=1;e0)throw new Error("Node deletion with more than one output connected to other nodes is not supported. ");t.executeNode=!1;const n=t.inputs[0],r=t.outputs[0],o=this._allData[r].to;for(let n=0;n0)for(const e of o){const t=this._nodes[e].inputs.indexOf(r);if(-1===t)throw new Error("The Node object doesn't have the output Value in it's 'inputs' property ");this._nodes[e].inputs[t]=n,this._allData[n].to.push(e)}}removeAllDropoutNodes(){let e=0;for(const t of this._nodes){if("Dropout"===t.opType){if(1!==t.inputs.length)throw new Error("Dropout nodes should only contain one input. ");if(1!==t.outputs.length&&2!==t.outputs.length)throw new Error("Dropout nodes should contain either 1 or 2 output(s)");if(2===t.outputs.length&&0!==this._allData[t.outputs[1]]._to.length)throw new Error("Dropout nodes's second output should not be referenced by other nodes");this.deleteNode(e)}e++}}removeAllIdentityNodes(){let e=0;for(const t of this._nodes)"Identity"===t.opType&&this.deleteNode(e),e++}isActivation(e){switch(e.opType){case"Relu":case"Sigmoid":case"Clip":return!0;default:return!1}}fuseConvActivationNodes(){for(const e of this._nodes)if("Conv"===e.opType){const t=this._allData[e.outputs[0]]._to;if(1===t.length&&this.isActivation(this._nodes[t[0]])){const n=this._nodes[t[0]];if("Clip"===n.opType)if(1===n.inputs.length)try{e.attributes.set("activation_params","floats",[n.attributes.getFloat("min"),n.attributes.getFloat("max")])}catch(t){e.attributes.set("activation_params","floats",[s.MIN_CLIP,s.MAX_CLIP])}else{if(!(n.inputs.length>=3&&void 0!==this._allData[n.inputs[1]].tensor&&void 0!==this._allData[n.inputs[2]].tensor))continue;e.attributes.set("activation_params","floats",[this._allData[n.inputs[1]].tensor.floatData[0],this._allData[n.inputs[2]].tensor.floatData[0]])}e.attributes.set("activation","string",n.opType),this.deleteNode(t[0])}}}}},1315:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.now=t.Profiler=t.Logger=void 0;const n={verbose:1e3,info:2e3,warning:4e3,error:5e3,fatal:6e3},r={none:new class{log(e,t,n){}},console:new class{log(e,t,n){console.log(`${this.color(e)} ${n?""+n+" ":""}${t}`)}color(e){switch(e){case"verbose":return"v";case"info":return"i";case"warning":return"w";case"error":return"e";case"fatal":return"f";default:throw new Error(`unsupported severity: ${e}`)}}}},o={provider:"console",minimalSeverity:"warning",logDateTime:!0,logSourceLocation:!1};let i={"":o};function a(e,t,n,r){if(void 0===t)return o=e,{verbose:a.verbose.bind(null,o),info:a.info.bind(null,o),warning:a.warning.bind(null,o),error:a.error.bind(null,o),fatal:a.fatal.bind(null,o)};if(void 0===n)s(e,t);else if("number"==typeof n&&void 0===r)s(e,t);else if("string"==typeof n&&void 0===r)s(e,n,0,t);else{if("string"!=typeof n||"number"!=typeof r)throw new TypeError("input is valid");s(e,n,0,t)}var o}function s(e,t,o,a){const s=i[a||""]||i[""];n[e]{a.then((async t=>{o&&await o.end(),e(t)}),(async e=>{o&&await o.end(),t(e)}))}));if(!i&&o){const e=o.end();if(e&&"function"==typeof e.then)return new Promise(((t,n)=>{e.then((()=>{t(a)}),(e=>{n(e)}))}))}return a}begin(e,n,r){if(!this._started)throw new Error("profiler is not started yet");if(void 0===r){const r=(0,t.now)();return this.flush(r),new u(e,n,r,(e=>this.endSync(e)))}{const t=r.beginTimer();return new u(e,n,0,(async e=>this.end(e)),t,r)}}async end(e){const t=await e.checkTimer();this._timingEvents.length=this._flushBatchSize||e-this._flushTime>=this._flushIntervalInMilliseconds){for(const e=this._flushPointer;this._flushPointerperformance.now():Date.now},1745:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Model=void 0;const r=n(5686),o=n(1446),i=n(4662),a=n(1287),s=n(7273);var u=a.onnxruntime.experimental.fbs;t.Model=class{constructor(){}load(e,t,n){if(!n)try{return void this.loadFromOnnxFormat(e,t)}catch(e){if(void 0!==n)throw e}this.loadFromOrtFormat(e,t)}loadFromOnnxFormat(e,t){const n=o.onnx.ModelProto.decode(e);if(s.LongUtil.longToNumber(n.irVersion)<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=n.opsetImport.map((e=>({domain:e.domain,version:s.LongUtil.longToNumber(e.version)}))),this._graph=i.Graph.from(n.graph,t)}loadFromOrtFormat(e,t){const n=new r.flatbuffers.ByteBuffer(e),o=u.InferenceSession.getRootAsInferenceSession(n).model();if(s.LongUtil.longToNumber(o.irVersion())<3)throw new Error("only support ONNX model with IR_VERSION>=3");this._opsets=[];for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FLOAT_TYPES=t.INT_TYPES=t.NUMBER_TYPES=void 0,t.NUMBER_TYPES=["float32","float64","int32","int16","int8","uint16","uint32","uint8"],t.INT_TYPES=["int32","int16","int8","uint16","uint32","uint8"],t.FLOAT_TYPES=["float32","float64"]},5881:(e,t)=>{"use strict";function n(e,t){if(t.endsWith("+")){const n=Number.parseInt(t.substring(0,t.length-1),10);return!isNaN(n)&&n<=e}if(2===t.split("-").length){const n=t.split("-"),r=Number.parseInt(n[0],10),o=Number.parseInt(n[1],10);return!isNaN(r)&&!isNaN(o)&&r<=e&&e<=o}return Number.parseInt(t,10)===e}Object.defineProperty(t,"__esModule",{value:!0}),t.resolveOperator=void 0,t.resolveOperator=function(e,t,r){for(const o of r){const r=o[0],i=o[1],a=o[2],s=o[3],u=o[4];if(e.opType===r)for(const e of t)if((e.domain===i||"ai.onnx"===e.domain&&""===i)&&n(e.version,a))return{opImpl:s,opInit:u}}throw new TypeError(`cannot resolve operator '${e.opType}' with opsets: ${t.map((e=>`${e.domain||"ai.onnx"} v${e.version}`)).join(", ")}`)}},1287:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.onnxruntime=void 0;const r=n(5686);var o,i;o=t.onnxruntime||(t.onnxruntime={}),function(e){let t;!function(e){e[e.UNDEFINED=0]="UNDEFINED",e[e.FLOAT=1]="FLOAT",e[e.INT=2]="INT",e[e.STRING=3]="STRING",e[e.TENSOR=4]="TENSOR",e[e.GRAPH=5]="GRAPH",e[e.FLOATS=6]="FLOATS",e[e.INTS=7]="INTS",e[e.STRINGS=8]="STRINGS",e[e.TENSORS=9]="TENSORS",e[e.GRAPHS=10]="GRAPHS",e[e.SPARSE_TENSOR=11]="SPARSE_TENSOR",e[e.SPARSE_TENSORS=12]="SPARSE_TENSORS"}(t=e.AttributeType||(e.AttributeType={}))}((i=o.experimental||(o.experimental={})).fbs||(i.fbs={})),function(e){!function(e){!function(e){let t;!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.VALUE=1]="VALUE",e[e.PARAM=2]="PARAM"}(t=e.DimensionValueType||(e.DimensionValueType={}))}(e.fbs||(e.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(e){!function(e){let t;!function(e){e[e.UNDEFINED=0]="UNDEFINED",e[e.FLOAT=1]="FLOAT",e[e.UINT8=2]="UINT8",e[e.INT8=3]="INT8",e[e.UINT16=4]="UINT16",e[e.INT16=5]="INT16",e[e.INT32=6]="INT32",e[e.INT64=7]="INT64",e[e.STRING=8]="STRING",e[e.BOOL=9]="BOOL",e[e.FLOAT16=10]="FLOAT16",e[e.DOUBLE=11]="DOUBLE",e[e.UINT32=12]="UINT32",e[e.UINT64=13]="UINT64",e[e.COMPLEX64=14]="COMPLEX64",e[e.COMPLEX128=15]="COMPLEX128",e[e.BFLOAT16=16]="BFLOAT16"}(t=e.TensorDataType||(e.TensorDataType={}))}(e.fbs||(e.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(e){!function(e){let t;!function(e){e[e.Primitive=0]="Primitive",e[e.Fused=1]="Fused"}(t=e.NodeType||(e.NodeType={}))}(e.fbs||(e.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(e){!function(e){let t;!function(e){e[e.NONE=0]="NONE",e[e.tensor_type=1]="tensor_type",e[e.sequence_type=2]="sequence_type",e[e.map_type=3]="map_type"}(t=e.TypeInfoValue||(e.TypeInfoValue={}))}(e.fbs||(e.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsShape(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsShape(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}dim(t,n){let r=this.bb.__offset(this.bb_pos,4);return r?(n||new e.experimental.fbs.Dimension).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}dimLength(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__vector_len(this.bb_pos+e):0}static startShape(e){e.startObject(1)}static addDim(e,t){e.addFieldOffset(0,t,0)}static createDimVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startDimVector(e,t){e.startVector(4,t,4)}static endShape(e){return e.endObject()}static createShape(e,t){return n.startShape(e),n.addDim(e,t),n.endShape(e)}}t.Shape=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDimension(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDimension(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}value(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new e.experimental.fbs.DimensionValue).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}denotation(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}static startDimension(e){e.startObject(2)}static addValue(e,t){e.addFieldOffset(0,t,0)}static addDenotation(e,t){e.addFieldOffset(1,t,0)}static endDimension(e){return e.endObject()}static createDimension(e,t,r){return n.startDimension(e),n.addValue(e,t),n.addDenotation(e,r),n.endDimension(e)}}t.Dimension=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDimensionValue(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDimensionValue(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}dimType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):e.experimental.fbs.DimensionValueType.UNKNOWN}dimValue(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}dimParam(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,e):null}static startDimensionValue(e){e.startObject(3)}static addDimType(t,n){t.addFieldInt8(0,n,e.experimental.fbs.DimensionValueType.UNKNOWN)}static addDimValue(e,t){e.addFieldInt64(1,t,e.createLong(0,0))}static addDimParam(e,t){e.addFieldOffset(2,t,0)}static endDimensionValue(e){return e.endObject()}static createDimensionValue(e,t,r,o){return n.startDimensionValue(e),n.addDimType(e,t),n.addDimValue(e,r),n.addDimParam(e,o),n.endDimensionValue(e)}}t.DimensionValue=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTensorTypeAndShape(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTensorTypeAndShape(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}elemType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):e.experimental.fbs.TensorDataType.UNDEFINED}shape(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.Shape).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startTensorTypeAndShape(e){e.startObject(2)}static addElemType(t,n){t.addFieldInt32(0,n,e.experimental.fbs.TensorDataType.UNDEFINED)}static addShape(e,t){e.addFieldOffset(1,t,0)}static endTensorTypeAndShape(e){return e.endObject()}static createTensorTypeAndShape(e,t,r){return n.startTensorTypeAndShape(e),n.addElemType(e,t),n.addShape(e,r),n.endTensorTypeAndShape(e)}}t.TensorTypeAndShape=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMapType(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMapType(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}keyType(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):e.experimental.fbs.TensorDataType.UNDEFINED}valueType(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startMapType(e){e.startObject(2)}static addKeyType(t,n){t.addFieldInt32(0,n,e.experimental.fbs.TensorDataType.UNDEFINED)}static addValueType(e,t){e.addFieldOffset(1,t,0)}static endMapType(e){return e.endObject()}static createMapType(e,t,r){return n.startMapType(e),n.addKeyType(e,t),n.addValueType(e,r),n.endMapType(e)}}t.MapType=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSequenceType(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSequenceType(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}elemType(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startSequenceType(e){e.startObject(1)}static addElemType(e,t){e.addFieldOffset(0,t,0)}static endSequenceType(e){return e.endObject()}static createSequenceType(e,t){return n.startSequenceType(e),n.addElemType(e,t),n.endSequenceType(e)}}t.SequenceType=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(e){(e.fbs||(e.fbs={})).EdgeEnd=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}nodeIndex(){return this.bb.readUint32(this.bb_pos)}srcArgIndex(){return this.bb.readInt32(this.bb_pos+4)}dstArgIndex(){return this.bb.readInt32(this.bb_pos+8)}static createEdgeEnd(e,t,n,r){return e.prep(4,12),e.writeInt32(r),e.writeInt32(n),e.writeInt32(t),e.offset()}}}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsNodeEdge(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsNodeEdge(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}nodeIndex(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb_pos+e):0}inputEdges(t,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+12*t,this.bb):null}inputEdgesLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}outputEdges(t,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new e.experimental.fbs.EdgeEnd).__init(this.bb.__vector(this.bb_pos+r)+12*t,this.bb):null}outputEdgesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}static startNodeEdge(e){e.startObject(3)}static addNodeIndex(e,t){e.addFieldInt32(0,t,0)}static addInputEdges(e,t){e.addFieldOffset(1,t,0)}static startInputEdgesVector(e,t){e.startVector(12,t,4)}static addOutputEdges(e,t){e.addFieldOffset(2,t,0)}static startOutputEdgesVector(e,t){e.startVector(12,t,4)}static endNodeEdge(e){return e.endObject()}static createNodeEdge(e,t,r,o){return n.startNodeEdge(e),n.addNodeIndex(e,t),n.addInputEdges(e,r),n.addOutputEdges(e,o),n.endNodeEdge(e)}}t.NodeEdge=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsNode(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsNode(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}docString(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}domain(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,e):null}sinceVersion(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt32(this.bb_pos+e):0}index(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readUint32(this.bb_pos+e):0}opType(e){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__string(this.bb_pos+t,e):null}type(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):e.experimental.fbs.NodeType.Primitive}executionProviderType(e){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__string(this.bb_pos+t,e):null}inputs(e,t){let n=this.bb.__offset(this.bb_pos,20);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}inputsLength(){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__vector_len(this.bb_pos+e):0}outputs(e,t){let n=this.bb.__offset(this.bb_pos,22);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}outputsLength(){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.__vector_len(this.bb_pos+e):0}attributes(t,n){let r=this.bb.__offset(this.bb_pos,24);return r?(n||new e.experimental.fbs.Attribute).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}attributesLength(){let e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__vector_len(this.bb_pos+e):0}inputArgCounts(e){let t=this.bb.__offset(this.bb_pos,26);return t?this.bb.readInt32(this.bb.__vector(this.bb_pos+t)+4*e):0}inputArgCountsLength(){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__vector_len(this.bb_pos+e):0}inputArgCountsArray(){let e=this.bb.__offset(this.bb_pos,26);return e?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}implicitInputs(e,t){let n=this.bb.__offset(this.bb_pos,28);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}implicitInputsLength(){let e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__vector_len(this.bb_pos+e):0}static startNode(e){e.startObject(13)}static addName(e,t){e.addFieldOffset(0,t,0)}static addDocString(e,t){e.addFieldOffset(1,t,0)}static addDomain(e,t){e.addFieldOffset(2,t,0)}static addSinceVersion(e,t){e.addFieldInt32(3,t,0)}static addIndex(e,t){e.addFieldInt32(4,t,0)}static addOpType(e,t){e.addFieldOffset(5,t,0)}static addType(t,n){t.addFieldInt32(6,n,e.experimental.fbs.NodeType.Primitive)}static addExecutionProviderType(e,t){e.addFieldOffset(7,t,0)}static addInputs(e,t){e.addFieldOffset(8,t,0)}static createInputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startInputsVector(e,t){e.startVector(4,t,4)}static addOutputs(e,t){e.addFieldOffset(9,t,0)}static createOutputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startOutputsVector(e,t){e.startVector(4,t,4)}static addAttributes(e,t){e.addFieldOffset(10,t,0)}static createAttributesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startAttributesVector(e,t){e.startVector(4,t,4)}static addInputArgCounts(e,t){e.addFieldOffset(11,t,0)}static createInputArgCountsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addInt32(t[n]);return e.endVector()}static startInputArgCountsVector(e,t){e.startVector(4,t,4)}static addImplicitInputs(e,t){e.addFieldOffset(12,t,0)}static createImplicitInputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startImplicitInputsVector(e,t){e.startVector(4,t,4)}static endNode(e){return e.endObject()}static createNode(e,t,r,o,i,a,s,u,l,c,p,d,f,h){return n.startNode(e),n.addName(e,t),n.addDocString(e,r),n.addDomain(e,o),n.addSinceVersion(e,i),n.addIndex(e,a),n.addOpType(e,s),n.addType(e,u),n.addExecutionProviderType(e,l),n.addInputs(e,c),n.addOutputs(e,p),n.addAttributes(e,d),n.addInputArgCounts(e,f),n.addImplicitInputs(e,h),n.endNode(e)}}t.Node=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsValueInfo(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsValueInfo(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}docString(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}type(t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new e.experimental.fbs.TypeInfo).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startValueInfo(e){e.startObject(3)}static addName(e,t){e.addFieldOffset(0,t,0)}static addDocString(e,t){e.addFieldOffset(1,t,0)}static addType(e,t){e.addFieldOffset(2,t,0)}static endValueInfo(e){return e.endObject()}static createValueInfo(e,t,r,o){return n.startValueInfo(e),n.addName(e,t),n.addDocString(e,r),n.addType(e,o),n.endValueInfo(e)}}t.ValueInfo=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTypeInfo(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTypeInfo(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}denotation(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}valueType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):e.experimental.fbs.TypeInfoValue.NONE}value(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}static startTypeInfo(e){e.startObject(3)}static addDenotation(e,t){e.addFieldOffset(0,t,0)}static addValueType(t,n){t.addFieldInt8(1,n,e.experimental.fbs.TypeInfoValue.NONE)}static addValue(e,t){e.addFieldOffset(2,t,0)}static endTypeInfo(e){return e.endObject()}static createTypeInfo(e,t,r,o){return n.startTypeInfo(e),n.addDenotation(e,t),n.addValueType(e,r),n.addValue(e,o),n.endTypeInfo(e)}}t.TypeInfo=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(e){!function(e){class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsOperatorSetId(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsOperatorSetId(e,n){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}domain(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}version(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}static startOperatorSetId(e){e.startObject(2)}static addDomain(e,t){e.addFieldOffset(0,t,0)}static addVersion(e,t){e.addFieldInt64(1,t,e.createLong(0,0))}static endOperatorSetId(e){return e.endObject()}static createOperatorSetId(e,n,r){return t.startOperatorSetId(e),t.addDomain(e,n),t.addVersion(e,r),t.endOperatorSetId(e)}}e.OperatorSetId=t}(e.fbs||(e.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTensor(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsTensor(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}docString(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}dims(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*e):this.bb.createLong(0,0)}dimsLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}dataType(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):e.experimental.fbs.TensorDataType.UNDEFINED}rawData(e){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readUint8(this.bb.__vector(this.bb_pos+t)+e):0}rawDataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}rawDataArray(){let e=this.bb.__offset(this.bb_pos,12);return e?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}stringData(e,t){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}stringDataLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}static startTensor(e){e.startObject(6)}static addName(e,t){e.addFieldOffset(0,t,0)}static addDocString(e,t){e.addFieldOffset(1,t,0)}static addDims(e,t){e.addFieldOffset(2,t,0)}static createDimsVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startDimsVector(e,t){e.startVector(8,t,8)}static addDataType(t,n){t.addFieldInt32(3,n,e.experimental.fbs.TensorDataType.UNDEFINED)}static addRawData(e,t){e.addFieldOffset(4,t,0)}static createRawDataVector(e,t){e.startVector(1,t.length,1);for(let n=t.length-1;n>=0;n--)e.addInt8(t[n]);return e.endVector()}static startRawDataVector(e,t){e.startVector(1,t,1)}static addStringData(e,t){e.addFieldOffset(5,t,0)}static createStringDataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startStringDataVector(e,t){e.startVector(4,t,4)}static endTensor(e){return e.endObject()}static createTensor(e,t,r,o,i,a,s){return n.startTensor(e),n.addName(e,t),n.addDocString(e,r),n.addDims(e,o),n.addDataType(e,i),n.addRawData(e,a),n.addStringData(e,s),n.endTensor(e)}}t.Tensor=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSparseTensor(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSparseTensor(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}values(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}indices(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dims(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*e):this.bb.createLong(0,0)}dimsLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSparseTensor(e){e.startObject(3)}static addValues(e,t){e.addFieldOffset(0,t,0)}static addIndices(e,t){e.addFieldOffset(1,t,0)}static addDims(e,t){e.addFieldOffset(2,t,0)}static createDimsVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startDimsVector(e,t){e.startVector(8,t,8)}static endSparseTensor(e){return e.endObject()}static createSparseTensor(e,t,r,o){return n.startSparseTensor(e),n.addValues(e,t),n.addIndices(e,r),n.addDims(e,o),n.endSparseTensor(e)}}t.SparseTensor=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsAttribute(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsAttribute(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}docString(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}type(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):e.experimental.fbs.AttributeType.UNDEFINED}f(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat32(this.bb_pos+e):0}i(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}s(e){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__string(this.bb_pos+t,e):null}t(t){let n=this.bb.__offset(this.bb_pos,16);return n?(t||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}g(t){let n=this.bb.__offset(this.bb_pos,18);return n?(t||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}floats(e){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readFloat32(this.bb.__vector(this.bb_pos+t)+4*e):0}floatsLength(){let e=this.bb.__offset(this.bb_pos,20);return e?this.bb.__vector_len(this.bb_pos+e):0}floatsArray(){let e=this.bb.__offset(this.bb_pos,20);return e?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}ints(e){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+8*e):this.bb.createLong(0,0)}intsLength(){let e=this.bb.__offset(this.bb_pos,22);return e?this.bb.__vector_len(this.bb_pos+e):0}strings(e,t){let n=this.bb.__offset(this.bb_pos,24);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}stringsLength(){let e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__vector_len(this.bb_pos+e):0}tensors(t,n){let r=this.bb.__offset(this.bb_pos,26);return r?(n||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}tensorsLength(){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__vector_len(this.bb_pos+e):0}graphs(t,n){let r=this.bb.__offset(this.bb_pos,28);return r?(n||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}graphsLength(){let e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__vector_len(this.bb_pos+e):0}static startAttribute(e){e.startObject(13)}static addName(e,t){e.addFieldOffset(0,t,0)}static addDocString(e,t){e.addFieldOffset(1,t,0)}static addType(t,n){t.addFieldInt32(2,n,e.experimental.fbs.AttributeType.UNDEFINED)}static addF(e,t){e.addFieldFloat32(3,t,0)}static addI(e,t){e.addFieldInt64(4,t,e.createLong(0,0))}static addS(e,t){e.addFieldOffset(5,t,0)}static addT(e,t){e.addFieldOffset(6,t,0)}static addG(e,t){e.addFieldOffset(7,t,0)}static addFloats(e,t){e.addFieldOffset(8,t,0)}static createFloatsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addFloat32(t[n]);return e.endVector()}static startFloatsVector(e,t){e.startVector(4,t,4)}static addInts(e,t){e.addFieldOffset(9,t,0)}static createIntsVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startIntsVector(e,t){e.startVector(8,t,8)}static addStrings(e,t){e.addFieldOffset(10,t,0)}static createStringsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startStringsVector(e,t){e.startVector(4,t,4)}static addTensors(e,t){e.addFieldOffset(11,t,0)}static createTensorsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startTensorsVector(e,t){e.startVector(4,t,4)}static addGraphs(e,t){e.addFieldOffset(12,t,0)}static createGraphsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startGraphsVector(e,t){e.startVector(4,t,4)}static endAttribute(e){return e.endObject()}static createAttribute(e,t,r,o,i,a,s,u,l,c,p,d,f,h){return n.startAttribute(e),n.addName(e,t),n.addDocString(e,r),n.addType(e,o),n.addF(e,i),n.addI(e,a),n.addS(e,s),n.addT(e,u),n.addG(e,l),n.addFloats(e,c),n.addInts(e,p),n.addStrings(e,d),n.addTensors(e,f),n.addGraphs(e,h),n.endAttribute(e)}}t.Attribute=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsGraph(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsGraph(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}initializers(t,n){let r=this.bb.__offset(this.bb_pos,4);return r?(n||new e.experimental.fbs.Tensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}initializersLength(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__vector_len(this.bb_pos+e):0}nodeArgs(t,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new e.experimental.fbs.ValueInfo).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}nodeArgsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}nodes(t,n){let r=this.bb.__offset(this.bb_pos,8);return r?(n||new e.experimental.fbs.Node).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}nodesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}maxNodeIndex(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readUint32(this.bb_pos+e):0}nodeEdges(t,n){let r=this.bb.__offset(this.bb_pos,12);return r?(n||new e.experimental.fbs.NodeEdge).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}nodeEdgesLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}inputs(e,t){let n=this.bb.__offset(this.bb_pos,14);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}inputsLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}outputs(e,t){let n=this.bb.__offset(this.bb_pos,16);return n?this.bb.__string(this.bb.__vector(this.bb_pos+n)+4*e,t):null}outputsLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}sparseInitializers(t,n){let r=this.bb.__offset(this.bb_pos,18);return r?(n||new e.experimental.fbs.SparseTensor).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}sparseInitializersLength(){let e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__vector_len(this.bb_pos+e):0}static startGraph(e){e.startObject(8)}static addInitializers(e,t){e.addFieldOffset(0,t,0)}static createInitializersVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startInitializersVector(e,t){e.startVector(4,t,4)}static addNodeArgs(e,t){e.addFieldOffset(1,t,0)}static createNodeArgsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startNodeArgsVector(e,t){e.startVector(4,t,4)}static addNodes(e,t){e.addFieldOffset(2,t,0)}static createNodesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startNodesVector(e,t){e.startVector(4,t,4)}static addMaxNodeIndex(e,t){e.addFieldInt32(3,t,0)}static addNodeEdges(e,t){e.addFieldOffset(4,t,0)}static createNodeEdgesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startNodeEdgesVector(e,t){e.startVector(4,t,4)}static addInputs(e,t){e.addFieldOffset(5,t,0)}static createInputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startInputsVector(e,t){e.startVector(4,t,4)}static addOutputs(e,t){e.addFieldOffset(6,t,0)}static createOutputsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startOutputsVector(e,t){e.startVector(4,t,4)}static addSparseInitializers(e,t){e.addFieldOffset(7,t,0)}static createSparseInitializersVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startSparseInitializersVector(e,t){e.startVector(4,t,4)}static endGraph(e){return e.endObject()}static createGraph(e,t,r,o,i,a,s,u,l){return n.startGraph(e),n.addInitializers(e,t),n.addNodeArgs(e,r),n.addNodes(e,o),n.addMaxNodeIndex(e,i),n.addNodeEdges(e,a),n.addInputs(e,s),n.addOutputs(e,u),n.addSparseInitializers(e,l),n.endGraph(e)}}t.Graph=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsModel(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsModel(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}irVersion(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}opsetImport(t,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new e.experimental.fbs.OperatorSetId).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}opsetImportLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}producerName(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__string(this.bb_pos+t,e):null}producerVersion(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__string(this.bb_pos+t,e):null}domain(e){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__string(this.bb_pos+t,e):null}modelVersion(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}docString(e){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__string(this.bb_pos+t,e):null}graph(t){let n=this.bb.__offset(this.bb_pos,18);return n?(t||new e.experimental.fbs.Graph).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}graphDocString(e){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__string(this.bb_pos+t,e):null}static startModel(e){e.startObject(9)}static addIrVersion(e,t){e.addFieldInt64(0,t,e.createLong(0,0))}static addOpsetImport(e,t){e.addFieldOffset(1,t,0)}static createOpsetImportVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startOpsetImportVector(e,t){e.startVector(4,t,4)}static addProducerName(e,t){e.addFieldOffset(2,t,0)}static addProducerVersion(e,t){e.addFieldOffset(3,t,0)}static addDomain(e,t){e.addFieldOffset(4,t,0)}static addModelVersion(e,t){e.addFieldInt64(5,t,e.createLong(0,0))}static addDocString(e,t){e.addFieldOffset(6,t,0)}static addGraph(e,t){e.addFieldOffset(7,t,0)}static addGraphDocString(e,t){e.addFieldOffset(8,t,0)}static endModel(e){return e.endObject()}static createModel(e,t,r,o,i,a,s,u,l,c){return n.startModel(e),n.addIrVersion(e,t),n.addOpsetImport(e,r),n.addProducerName(e,o),n.addProducerVersion(e,i),n.addDomain(e,a),n.addModelVersion(e,s),n.addDocString(e,u),n.addGraph(e,l),n.addGraphDocString(e,c),n.endModel(e)}}t.Model=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(e){!function(e){class t{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsKernelCreateInfos(e,n){return(n||new t).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsKernelCreateInfos(e,n){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(n||new t).__init(e.readInt32(e.position())+e.position(),e)}nodeIndices(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readUint32(this.bb.__vector(this.bb_pos+t)+4*e):0}nodeIndicesLength(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__vector_len(this.bb_pos+e):0}nodeIndicesArray(){let e=this.bb.__offset(this.bb_pos,4);return e?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}kernelDefHashes(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint64(this.bb.__vector(this.bb_pos+t)+8*e):this.bb.createLong(0,0)}kernelDefHashesLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}static startKernelCreateInfos(e){e.startObject(2)}static addNodeIndices(e,t){e.addFieldOffset(0,t,0)}static createNodeIndicesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addInt32(t[n]);return e.endVector()}static startNodeIndicesVector(e,t){e.startVector(4,t,4)}static addKernelDefHashes(e,t){e.addFieldOffset(1,t,0)}static createKernelDefHashesVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startKernelDefHashesVector(e,t){e.startVector(8,t,8)}static endKernelCreateInfos(e){return e.endObject()}static createKernelCreateInfos(e,n,r){return t.startKernelCreateInfos(e),t.addNodeIndices(e,n),t.addKernelDefHashes(e,r),t.endKernelCreateInfos(e)}}e.KernelCreateInfos=t}(e.fbs||(e.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSubGraphSessionState(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSubGraphSessionState(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}graphId(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}sessionState(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startSubGraphSessionState(e){e.startObject(2)}static addGraphId(e,t){e.addFieldOffset(0,t,0)}static addSessionState(e,t){e.addFieldOffset(1,t,0)}static endSubGraphSessionState(e){let t=e.endObject();return e.requiredField(t,4),t}static createSubGraphSessionState(e,t,r){return n.startSubGraphSessionState(e),n.addGraphId(e,t),n.addSessionState(e,r),n.endSubGraphSessionState(e)}}t.SubGraphSessionState=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSessionState(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSessionState(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}kernels(t){let n=this.bb.__offset(this.bb_pos,4);return n?(t||new e.experimental.fbs.KernelCreateInfos).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}subGraphSessionStates(t,n){let r=this.bb.__offset(this.bb_pos,6);return r?(n||new e.experimental.fbs.SubGraphSessionState).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}subGraphSessionStatesLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSessionState(e){e.startObject(2)}static addKernels(e,t){e.addFieldOffset(0,t,0)}static addSubGraphSessionStates(e,t){e.addFieldOffset(1,t,0)}static createSubGraphSessionStatesVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startSubGraphSessionStatesVector(e,t){e.startVector(4,t,4)}static endSessionState(e){return e.endObject()}static createSessionState(e,t,r){return n.startSessionState(e),n.addKernels(e,t),n.addSubGraphSessionStates(e,r),n.endSessionState(e)}}t.SessionState=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={})),function(e){!function(t){!function(t){class n{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsInferenceSession(e,t){return(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsInferenceSession(e,t){return e.setPosition(e.position()+r.flatbuffers.SIZE_PREFIX_LENGTH),(t||new n).__init(e.readInt32(e.position())+e.position(),e)}static bufferHasIdentifier(e){return e.__has_identifier("ORTM")}ortVersion(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}model(t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new e.experimental.fbs.Model).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}sessionState(t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new e.experimental.fbs.SessionState).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startInferenceSession(e){e.startObject(3)}static addOrtVersion(e,t){e.addFieldOffset(0,t,0)}static addModel(e,t){e.addFieldOffset(1,t,0)}static addSessionState(e,t){e.addFieldOffset(2,t,0)}static endInferenceSession(e){return e.endObject()}static finishInferenceSessionBuffer(e,t){e.finish(t,"ORTM")}static finishSizePrefixedInferenceSessionBuffer(e,t){e.finish(t,"ORTM",!0)}static createInferenceSession(e,t,r,o){return n.startInferenceSession(e),n.addOrtVersion(e,t),n.addModel(e,r),n.addSessionState(e,o),n.endInferenceSession(e)}}t.InferenceSession=n}(t.fbs||(t.fbs={}))}(e.experimental||(e.experimental={}))}(t.onnxruntime||(t.onnxruntime={}))},1723:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OnnxjsSessionHandler=void 0;const r=n(8453),o=n(9240);t.OnnxjsSessionHandler=class{constructor(e){this.session=e,this.inputNames=this.session.inputNames,this.outputNames=this.session.outputNames}async dispose(){}async run(e,t,n){const i=new Map;for(const t in e)if(Object.hasOwnProperty.call(e,t)){const n=e[t];i.set(t,new o.Tensor(n.dims,n.type,void 0,void 0,n.data))}const a=await this.session.run(i),s={};return a.forEach(((e,t)=>{s[t]=new r.Tensor(e.type,e.data,e.dims)})),s}startProfiling(){this.session.startProfiling()}endProfiling(){this.session.endProfiling()}}},6027:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Session=void 0;const r=n(7067),o=n(1296),i=n(1975),a=n(6496),s=n(1315),u=n(1745);t.Session=class{constructor(e={}){this._initialized=!1,this.backendHint=e.backendHint,this.profiler=s.Profiler.create(e.profiler),this.context={profiler:this.profiler,graphInputTypes:[],graphInputDims:[]}}get inputNames(){return this._model.graph.getInputNames()}get outputNames(){return this._model.graph.getOutputNames()}startProfiling(){this.profiler.start()}endProfiling(){this.profiler.stop()}async loadModel(e,t,n){await this.profiler.event("session","Session.loadModel",(async()=>{const a=await(0,i.resolveBackend)(this.backendHint);if(this.sessionHandler=a.createSessionHandler(this.context),this._model=new u.Model,"string"==typeof e){const t=e.endsWith(".ort");if("undefined"==typeof fetch){const n=await(0,o.promisify)(r.readFile)(e);this.initialize(n,t)}else{const n=await fetch(e),r=await n.arrayBuffer();this.initialize(new Uint8Array(r),t)}}else if(ArrayBuffer.isView(e))this.initialize(e);else{const r=new Uint8Array(e,t||0,n||e.byteLength);this.initialize(r)}}))}initialize(e,t){if(this._initialized)throw new Error("already initialized");this.profiler.event("session","Session.initialize",(()=>{const n=this.sessionHandler.transformGraph?this.sessionHandler:void 0;this._model.load(e,n,t),this.sessionHandler.onGraphInitialized&&this.sessionHandler.onGraphInitialized(this._model.graph),this.initializeOps(this._model.graph),this._executionPlan=new a.ExecutionPlan(this._model.graph,this._ops,this.profiler)})),this._initialized=!0}async run(e){if(!this._initialized)throw new Error("session not initialized yet");return this.profiler.event("session","Session.run",(async()=>{const t=this.normalizeAndValidateInputs(e),n=await this._executionPlan.execute(this.sessionHandler,t);return this.createOutput(n)}))}normalizeAndValidateInputs(e){const t=this._model.graph.getInputNames();if(Array.isArray(e)){if(e.length!==t.length)throw new Error(`incorrect input array length: expected ${t.length} but got ${e.length}`)}else{if(e.size!==t.length)throw new Error(`incorrect input map size: expected ${t.length} but got ${e.size}`);const n=new Array(e.size);let r=0;for(let o=0;o"string"==typeof e))))throw new TypeError("cache should be a string array");l&&(this.cache=new Array(s))}else{if(void 0!==i){const e=d(t);if(!(i instanceof e))throw new TypeError(`cache should be type ${e.name}`)}if(l){const e=new ArrayBuffer(s*function(e){switch(e){case"bool":case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;case"float64":return 8;default:throw new Error(`cannot calculate sizeof() on type ${e}`)}}(t));this.cache=function(e,t){return new(d(t))(e)}(e,t)}}}static fromProto(e){if(!e)throw new Error("cannot construct Value from an empty tensor");const t=u.ProtoUtil.tensorDataTypeFromProto(e.dataType),n=u.ProtoUtil.tensorDimsFromProto(e.dims),r=new c(n,t);if("string"===t)e.stringData.forEach(((e,t)=>{r.data[t]=(0,u.decodeUtf8String)(e)}));else if(e.rawData&&"number"==typeof e.rawData.byteLength&&e.rawData.byteLength>0){const t=r.data,n=new DataView(e.rawData.buffer,e.rawData.byteOffset,e.rawData.byteLength),o=p(e.dataType),i=e.rawData.byteLength/o;if(e.rawData.byteLength%o!=0)throw new Error("invalid buffer length");if(t.length!==i)throw new Error("buffer length mismatch");for(let r=0;r0){const t=r.data,n=new DataView(e.rawDataArray().buffer,e.rawDataArray().byteOffset,e.rawDataLength()),o=p(e.dataType()),i=e.rawDataLength()/o;if(e.rawDataLength()%o!=0)throw new Error("invalid buffer length");if(t.length!==i)throw new Error("buffer length mismatch");for(let r=0;r1&&u>1)return;a[i-s]=Math.max(n,u)}return a}static index(e,t){const n=new Array(t.length);return l.fillIndex(e,t,n),n}static fillIndex(e,t,n){const r=e.length-t.length;for(let o=0;o=0;e--)r[e]=c%i[e],c=Math.floor(c/i[e]);f||(l.fillIndex(r,e.dims,o),p=e.get(o)),h||(l.fillIndex(r,t.dims,s),d=t.get(s)),u.set(r,n(p,d))}}return u}}static isValidBroadcast(e,t){const n=e.length,r=t.length;if(n>r)return!1;for(let o=1;o<=n;o++)if(1!==e[n-o]&&e[n-o]!==t[r-o])return!1;return!0}static getBroadcastDims(e,t){const n=e.length,r=[];for(let o=0;o1&&1===a&&r.unshift(i)}return r}}t.BroadcastUtil=l,t.arrayCopyHelper=function(e,t,n,r,o){if(r<0||r>=t.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=e.length)throw new Error("targetIndex out of bounds");if(r+o>t.length)throw new Error("source indices to be copied are outside bounds");if(n+o>e.length)throw new Error("target array is too small to hold result");for(let i=0;ii.default.isLong(e)?e.toNumber():e))}static tensorValueTypeFromProto(e){return{tensorType:c.tensorDataTypeFromProto(e.elemType),shape:{dims:c.tensorDimsFromProto(e.shape.dim.map((e=>e.dimValue)))}}}static tensorDimsFromORTFormat(e){const t=[];for(let n=0;ne.length)throw new Error(`invalid dimension of ${t} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return d.getSizeFromDimensionRange(e,t,e.length)}static sizeToDimension(e,t){if(t<0||t>e.length)throw new Error(`invalid dimension of ${t} for sizeToDimension as Tensor has ${e.length} dimensions.`);return d.getSizeFromDimensionRange(e,0,t)}static getSizeFromDimensionRange(e,t,n){let r=1;for(let o=t;o=0;--r)n[r]=n[r+1]*e[r+1];return n}static transpose(e){return e.slice().reverse()}static indicesToOffset(e,t,n){void 0===n&&(n=e.length);let r=0;for(let o=0;o=t)throw new Error("unsupported axis for this operation.");return e<0?e+t:e}static normalizeAxes(e,t){return e.map((e=>this.normalizeAxis(e,t)))}static incrementIndex(e,t,n){if(0===t.length||0===e.length)throw new Error("Index incrementing unsupported for scalar Tensor");if(void 0===n)n=t.length;else if(n<=0||n>t.length)throw new Error("Incorrect axis to increment on");for(let r=n-1;r>=0&&(e[r]++,!(e[r]=e.length)throw new Error("the dimension with value zero exceeds the dimension size of the input tensor");r[a]=e[a]}else r[a]=t[a];i*=r[a]}}const a=d.size(e);if(-1!==o){if(a%i!=0)throw new Error(`the input tensor cannot be reshaped to the requested shape. Input shape: [${e}] Output shape: [${t}]`);r[o]=a/i}else if(i!==a)throw new Error("reshapedDims and originalDims don't have matching sizes");return r}static sortBasedOnPerm(e,t){return t?t.map((t=>e[t])):e.slice().reverse()}static padShape(e,t){const n=e.length;return e.map(((e,r)=>e+t[r]+t[r+n]))}static areEqual(e,t){return e.length===t.length&&e.every(((e,n)=>e===t[n]))}static validateDimsAndCalcSize(e){if(e.length>6)throw new TypeError("Only rank 0 to 6 is supported for tensor shape.");let t=1;for(const n of e){if(!Number.isInteger(n))throw new TypeError(`Invalid shape: ${n} is not an integer`);if(n<0||n>2147483647)throw new TypeError(`Invalid shape: length ${n} is not allowed`);t*=n}return t}static flattenShape(e,t){t<0&&(t+=e.length);const n=e.reduce(((e,t)=>e*t),1),r=e.slice(t).reduce(((e,t)=>e*t),1);return[n/r,r]}static squeezeShape(e,t){const n=new Array;t=d.normalizeAxes(t,e.length);for(let r=0;r=0;if(o&&1!==e[r])throw new Error("squeeze an axis of size different than 1");(0===t.length&&e[r]>1||t.length>0&&!o)&&n.push(e[r])}return n}static unsqueezeShape(e,t){const n=new Array(e.length+t.length);n.fill(0);for(let e=0;e=n.length)throw new Error("'axes' has an out of range axis");if(0!==n[r])throw new Error("'axes' has a duplicate axis");n[r]=1}let r=0;for(let t=0;t=t.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=e.length)throw new Error("targetIndex out of bounds");if(r+o>t.length)throw new Error("source indices to be copied are outside bounds");if(n+o>e.length)throw new Error("target array is too small to hold result");for(let i=0;i=t.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=e.length)throw new Error("targetIndex out of bounds");if(r+o>t.length)throw new Error("source indices to be copied are outside bounds");if(n+o>e.length)throw new Error("target array is too small to hold result");for(let a=0;a=t.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=e.length)throw new Error("targetIndex out of bounds");if(r+o>t.length)throw new Error("source indices to be copied are outside bounds");if(n+o>e.length)throw new Error("target array is too small to hold result");for(let a=0;a=t.length)throw new Error("sourceIndex out of bounds");if(n<0||n>=e.length)throw new Error("targetIndex out of bounds");if(r+o>t.length)throw new Error("source indices to be copied are outside bounds");if(n+o>e.length)throw new Error("target array is too small to hold result");for(let i=0;it.push(n)));const a=h.calcReduceShape(i,t,!0),u=d.size(a),c=new s.Tensor(a,e.type),p=d.computeStrides(a),f=d.computeStrides(i),g=new Array(i.length);for(let n=0;n=t.length)return i(e[o]);const u=t[r],l=u>=n.length?1:d.size(n.slice(u+1));for(let c=0;c0!==e))}}t.ReduceUtil=h;class g{static adjustPoolAttributes(e,t,n,r,o,i){if(!e&&n.length!==t.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(e)for(let e=0;e=n.length?n.push(t[e+2]):n[e]=t[e+2];for(let e=0;e=n[e]||i[e+n.length]>=n[e])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,t,n,r,o,i){if(i){if(o.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(t.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(r.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let a=0;a{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebGpuBackend=void 0;const r=n(8453),o=n(4955),i=n(7771),a=n(8510),s=n(8305);t.WebGpuBackend=class{constructor(){this.currentKernelId=null,this.commandEncoder=null,this.computePassEncoder=null,this.pendingDispatchNumber=0,this.profilingEnabled=!1}get currentKernelCustomData(){if(null===this.currentKernelId)throw new Error("currentKernelCustomData(): currentKernelId is null. (should not happen)");let e=this.kernelCustomData.get(this.currentKernelId);return e||(e={},this.kernelCustomData.set(this.currentKernelId,e)),e}async initialize(){if(!navigator.gpu)throw new Error("WebGpuBackend: WebGPU is not available.");const e=await navigator.gpu.requestAdapter();if(!e)throw new Error("WebGpuBackend: Failed to get GPU adapter.");const t={requiredLimits:{maxComputeWorkgroupStorageSize:e.limits.maxComputeWorkgroupStorageSize,maxComputeWorkgroupsPerDimension:e.limits.maxComputeWorkgroupsPerDimension,maxStorageBufferBindingSize:e.limits.maxStorageBufferBindingSize}};e.features.has("timestamp-query-inside-passes")&&"default"===r.env.webgpu.profilingMode&&(this.profilingEnabled=!0,t.requiredFeatures=["timestamp-query-inside-passes"]),this.device=await e.requestDevice(t),this.gpuDataManager=(0,i.createGpuDataManager)(this),this.programManager=new s.ProgramManager(this),this.kernels=new Map,this.kernelPersistentData=new Map,this.kernelCustomData=new Map,this.device.onuncapturederror=e=>{e.error instanceof GPUValidationError&&console.error(`An uncaught WebGPU validation error was raised: ${e.error.message}`)},this.profilingEnabled&&(this.profilingQuerySet=this.device.createQuerySet({type:"timestamp",count:2}))}dispose(){}getCommandEncoder(){return this.commandEncoder||(this.commandEncoder=this.device.createCommandEncoder()),this.commandEncoder}getComputePassEncoder(){return this.computePassEncoder||(this.computePassEncoder=this.getCommandEncoder().beginComputePass()),this.computePassEncoder}endComputePass(){this.computePassEncoder&&(this.computePassEncoder.end(),this.computePassEncoder=null)}flush(){this.endComputePass(),this.device.queue.submit([this.getCommandEncoder().finish()]),this.gpuDataManager.refreshPendingBuffers(),this.commandEncoder=null,this.pendingDispatchNumber=0}run(e,t,n,r,i){if(t.length!==e.inputTypes.length)throw new Error(`Input size must be equal to ${e.inputTypes.length}.`);const a=[];for(let e=0;e{const r=t.map((e=>`${e.join(",")}`)).join("_"),o=n.join("_");let i=e.name;return e.cacheHint&&(i+="["+e.cacheHint+"]"),i+=":"+r+";"+o,i})(e,t.map((e=>e.dims)),a.map((e=>e.type)));let u=this.programManager.getArtifact(s);const l=u?u.programInfo:"function"==typeof e.get?e.get():e,c=0===n.length?l.outputs.map(((e,t)=>t)):n;if(c.length!==l.outputs.length)throw new Error(`Output size ${c.length} must be equal to ${l.outputs.length}.`);const p=[],d=[];for(let e=0;e=l.outputs.length)throw new Error(`Invalid output index: ${c[e]}`);const t=-1===c[e],n=-2===c[e],o=t||n?i(l.outputs[e].dataType,l.outputs[e].dims):r(c[e],l.outputs[e].dataType,l.outputs[e].dims),a=this.gpuDataManager.get(o.data);if(!a)throw new Error(`no GPU data for output: ${o.data}`);if(t&&this.temporaryData.push(a),n){let e=this.kernelPersistentData.get(this.currentKernelId);e||(e=[],this.kernelPersistentData.set(this.currentKernelId,e)),e.push(a)}p.push(o),d.push(a)}const f=this.programManager.normalizeDispatchGroupSize(l.dispatchGroup(t));return u||(u=this.programManager.build(l,f),this.programManager.setArtifact(s,u)),(0,o.LOG_DEBUG)("info",(()=>`[ProgramManager] run "${l.name}" (key=${s}) with ${f[0]}x${f[1]}x${f[2]}`)),this.programManager.run(u,a,d,f),p}upload(e,t){this.gpuDataManager.upload(e,t)}memcpy(e,t){this.gpuDataManager.memcpy(e,t)}async download(e,t){const n=await this.gpuDataManager.download(e);t().set(new Uint8Array(n))}alloc(e){return this.gpuDataManager.create(e).id}free(e){return this.gpuDataManager.release(e)}createKernel(e,t,n){const r=a.WEBGPU_OP_RESOLVE_RULES.get(e);if(!r)throw new Error(`kernel not implemented: ${e}`);this.kernels.set(t,[e,r[0],[r[1],n]])}releaseKernel(e){const t=this.kernelPersistentData.get(e);if(t){for(const e of t)this.gpuDataManager.release(e.id);this.kernelPersistentData.delete(e)}this.kernelCustomData.delete(e),this.kernels.delete(e)}computeKernel(e,t){const n=this.kernels.get(e);if(!n)throw new Error(`kernel not created: ${e}`);const[r,i,a]=n;if(null!==this.currentKernelId)throw new Error(`kernel "${r}" is not allowed to be called recursively`);this.currentKernelId=e,a[0]&&(a[1]=a[0](a[1]),a[0]=void 0),(0,o.LOG_DEBUG)("info",(()=>`[WebGPU] Start to run kernel "${r}"...`)),this.temporaryData=[];try{return i(t,a[1]),0}catch(e){return(0,o.LOG_DEBUG)("warning",`[WebGPU] Kernel "${r}" failed. Error: ${e}`),1}finally{for(const e of this.temporaryData)this.gpuDataManager.release(e.id);this.temporaryData=[],this.currentKernelId=null}}}},7675:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.init=void 0;const r=n(7917),o=n(3838),i=n(4955),a=n(6952);class s{constructor(e,t,n,r){this.module=e,this.dataType=t,this.data=n,this.dims=r}getFloat32Array(){return new Float32Array(this.module.HEAP8.buffer,this.data,a.ShapeUtil.size(this.dims))}reshape(e){if(a.ShapeUtil.size(e)!==a.ShapeUtil.size(this.dims))throw new Error("Invalid new shape");return new s(this.module,this.dataType,this.data,e)}}class u{get customData(){return this.backend.currentKernelCustomData}constructor(e,t,n){this.module=e,this.backend=t;const r=e.HEAPU32;let o=n>>2;this.opKernelContext=r[o++];const i=r[o++],a=[];for(let t=0;t"number"==typeof e?this.inputs[e]:e)))&&void 0!==o?o:this.inputs,l=null!==(i=null==t?void 0:t.outputs)&&void 0!==i?i:[];return this.backend.run(e,u,l,((e,t,n)=>new s(this.module,t,this.output(e,n),n)),((e,t)=>{const n=(0,r.getTensorElementSize)(e);if(!n)throw new Error(`Unsupported data type: ${e}`);const o=n*a.ShapeUtil.size(t);return new s(this.module,e,this.backend.gpuDataManager.create(o).id,t)}))}output(e,t){const n=this.module.stackSave();try{const n=this.module.stackAlloc(4*(1+t.length));let r=n>>2;this.module.HEAPU32[r++]=t.length;for(let e=0;e{const t=e.jsepInit;if(t&&navigator.gpu){const n=new o.WebGpuBackend;await n.initialize(),t({backend:n},(e=>n.alloc(e)),(e=>n.free(e)),((t,r,o,a=!1)=>{if(a)(0,i.LOG_DEBUG)("verbose",(()=>`[WebGPU] jsepCopyGpuToGpu: src=${t}, dst=${r}, size=${o}`)),n.memcpy(t,r);else{(0,i.LOG_DEBUG)("verbose",(()=>`[WebGPU] jsepCopyCpuToGpu: dataOffset=${t}, gpuDataId=${r}, size=${o}`));const a=e.HEAPU8.subarray(t,t+o);n.upload(r,a)}}),(async(t,r,o)=>{(0,i.LOG_DEBUG)("verbose",(()=>`[WebGPU] jsepCopyGpuToCpu: gpuDataId=${t}, dataOffset=${r}, size=${o}`)),await n.download(t,(()=>e.HEAPU8.subarray(r,r+o)))}),((e,t,r)=>n.createKernel(e,t,r)),(e=>n.releaseKernel(e)),((t,r)=>{(0,i.LOG_DEBUG)("verbose",(()=>`[WebGPU] jsepRun: kernel=${t}, contextDataOffset=${r}`));const o=new u(e,n,r);return n.computeKernel(t,o)}))}}},4955:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LOG_DEBUG=t.LOG=void 0;const r=n(8453),o=n(7917),i=["V","I","W","E","F"];t.LOG=(e,t)=>{const n=(0,o.logLevelStringToEnum)(e);var a,s;n>=(0,o.logLevelStringToEnum)(r.env.logLevel)&&(a=n,s="function"==typeof t?t():t,console.log(`[${i[a]},${(new Date).toISOString()}]${s}`))},t.LOG_DEBUG=(...e)=>{r.env.debug&&(0,t.LOG)(...e)}},6952:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_CLIP=t.MIN_CLIP=t.GemmUtil=t.PoolConvUtil=t.ShapeUtil=t.BroadcastUtil=t.MatMulUtil=void 0;class n{static calcMatMulShape(e,t){return e[1]!==t[0]?void 0:[e[0],t[1]]}}t.MatMulUtil=n;class r{static calcShape(e,t,r=!1){const o=e.length,i=t.length;if(0===o)return t;if(0===i)return e;const a=Math.max(e.length,t.length),s=new Array(a);if(r){if(o<2||i<2)return;const r=n.calcMatMulShape([e[o-2],e[o-1]],[t[i-2],t[i-1]]);if(void 0===r)return;[s[a-2],s[a-1]]=r}for(let n=r?3:1;n<=a;n++){const r=o-n<0?1:e[o-n],u=i-n<0?1:t[i-n];if(r!==u&&r>1&&u>1)return;s[a-n]=Math.max(r,u)}return s}static isValidBroadcast(e,t){const n=e.length,r=t.length;if(n>r)return!1;for(let o=1;o<=n;o++)if(1!==e[n-o]&&e[n-o]!==t[r-o])return!1;return!0}}t.BroadcastUtil=r;class o{static size(e){return o.getSizeFromDimensionRange(e,0,e.length)}static sizeFromDimension(e,t){if(t<0||t>e.length)throw new Error(`invalid dimension of ${t} for sizeFromDimension as Tensor has ${e.length} dimensions.`);return o.getSizeFromDimensionRange(e,t,e.length)}static sizeToDimension(e,t){if(t<0||t>e.length)throw new Error(`invalid dimension of ${t} for sizeToDimension as Tensor has ${e.length} dimensions.`);return o.getSizeFromDimensionRange(e,0,t)}static getSizeFromDimensionRange(e,t,n){let r=1;for(let o=t;o=0;--r)n[r]=n[r+1]*e[r+1];return n}static normalizeAxis(e,t){if(e<-t&&e>=t)throw new Error("unsupported axis for this operation.");return e<0?e+t:e}static normalizeAxes(e,t){return e.map((n=>this.normalizeAxis(n,null!=t?t:e.length)))}static sortBasedOnPerm(e,t){return t?t.map((t=>e[t])):e.slice().reverse()}static padShape(e,t){const n=e.length;return e.map(((e,r)=>e+t[r]+t[r+n]))}static areEqual(e,t){return e.length===t.length&&e.every(((e,n)=>e===t[n]))}}t.ShapeUtil=o;class i{static adjustPoolAttributes(e,t,n,r,o,i){if(!e&&n.length!==t.length-2)throw new Error("length of specified kernel shapes should be 2 less than length of input dimensions");if(e)for(let e=0;e=n.length?n.push(t[e+2]):n[e]=t[e+2];for(let e=0;e=n[e]||i[e+n.length]>=n[e])throw new Error("pads should be smaller than kernel")}}static adjustPadsBasedOnAutoPad(e,t,n,r,o,a,s){if(s){if(o.length!==2*(e.length-2))throw new Error("length of pads should be twice the length of data dimensions");if(t.length!==e.length-2)throw new Error("length of strides should be the length of data dimensions");if(r.length!==e.length-2)throw new Error("length of kernel shapes should be the length of data dimensions");for(let u=0;u{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createAttributeWithCacheKey=void 0;class n{constructor(e){Object.assign(this,e)}get cacheKey(){return this._cacheKey||(this._cacheKey=Object.getOwnPropertyNames(this).sort().map((e=>`${this[e]}`)).join(";")),this._cacheKey}}t.createAttributeWithCacheKey=e=>new n(e)},7771:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createGpuDataManager=void 0;const r=n(4955),o=n(1163),i=e=>16*Math.ceil(e/16);let a=0;class s{constructor(e){this.backend=e,this.storageCache=new Map,this.downloadCache=new Map,this.buffersForUploadingPending=[],this.buffersPending=[]}upload(e,t){const n=t.buffer,o=t.byteOffset,a=t.byteLength,s=i(a),u=this.storageCache.get(e);if(!u)throw new Error("gpu data for uploading does not exist");if(u.originalSize!==a)throw new Error(`inconsistent data size. gpu data size=${u.originalSize}, data size=${a}`);const l=this.backend.device.createBuffer({mappedAtCreation:!0,size:s,usage:GPUBufferUsage.MAP_WRITE|GPUBufferUsage.COPY_SRC}),c=l.getMappedRange();new Uint8Array(c).set(new Uint8Array(n,o,a)),l.unmap();const p=this.backend.getCommandEncoder();this.backend.endComputePass(),p.copyBufferToBuffer(l,0,u.gpuData.buffer,0,s),(0,r.LOG_DEBUG)("verbose",(()=>`[WebGPU] GpuDataManager.upload(id=${e})`)),this.buffersForUploadingPending.push(l)}memcpy(e,t){const n=this.storageCache.get(e);if(!n)throw new Error("source gpu data for memcpy does not exist");const r=this.storageCache.get(t);if(!r)throw new Error("destination gpu data for memcpy does not exist");if(n.originalSize!==r.originalSize)throw new Error("inconsistent source and destination gpu data size");const o=i(n.originalSize);this.backend.getCommandEncoder().copyBufferToBuffer(n.gpuData.buffer,0,r.gpuData.buffer,0,o)}create(e,t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST){const n=i(e),s=this.backend.device.createBuffer({size:n,usage:t}),u={id:a++,type:o.GpuDataType.default,buffer:s};return this.storageCache.set(u.id,{gpuData:u,originalSize:e}),(0,r.LOG_DEBUG)("verbose",(()=>`[WebGPU] GpuDataManager.create(size=${e}) => id=${u.id}`)),u}get(e){var t;return null===(t=this.storageCache.get(e))||void 0===t?void 0:t.gpuData}release(e){const t=this.storageCache.get(e);if(!t)throw new Error("releasing data does not exist");return(0,r.LOG_DEBUG)("verbose",(()=>`[WebGPU] GpuDataManager.release(id=${e}), gpuDataId=${t.gpuData.id}`)),this.storageCache.delete(e),this.buffersPending.push(t.gpuData.buffer),this.downloadCache.get(e)&&this.downloadCache.delete(e),t.originalSize}async download(e){const t=this.downloadCache.get(e);if(t)return t.data;const n=this.storageCache.get(e);if(!n)throw new Error("data does not exist");const r=this.backend.getCommandEncoder();this.backend.endComputePass();const o=this.backend.device.createBuffer({size:n.originalSize,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});r.copyBufferToBuffer(n.gpuData.buffer,0,o,0,n.originalSize),this.backend.flush();const i=new Promise((e=>{o.mapAsync(GPUMapMode.READ).then((()=>{const t=o.getMappedRange().slice(0);o.destroy(),e(t)}))}));return this.downloadCache.set(e,{data:i}),i}refreshPendingBuffers(){for(const e of this.buffersForUploadingPending)e.destroy();for(const e of this.buffersPending)e.destroy()}}t.createGpuDataManager=(...e)=>new s(...e)},8510:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.WEBGPU_OP_RESOLVE_RULES=void 0;const a=i(n(504)),s=n(9770),u=n(4271),l=n(1522),c=i(n(5262)),p=n(2625),d=i(n(9302));t.WEBGPU_OP_RESOLVE_RULES=new Map([["Abs",[d.abs]],["Acos",[d.acos]],["Acosh",[d.acosh]],["Add",[a.add]],["Asin",[d.asin]],["Asinh",[d.asinh]],["Atan",[d.atan]],["Atanh",[d.atanh]],["AveragePool",[c.averagePool,c.parseAveragePoolAttributes]],["Ceil",[d.ceil]],["ClipV10",[d.clipV10]],["Clip",[d.clip]],["Conv",[s.conv,s.parseConvAttributes]],["Cos",[d.cos]],["Cosh",[d.cosh]],["Div",[a.div]],["Elu",[d.elu,d.parseAlphaAttributes]],["Erf",[d.erf]],["Exp",[d.exp]],["Floor",[d.floor]],["Gemm",[u.gemm,u.parseGemmAttributes]],["GlobalAveragePool",[c.globalAveragePool,c.parseGlobalAveragePoolAttributes]],["GlobalMaxPool",[c.globalMaxPool,c.parseGlobalMaxPoolAttributes]],["LeakyRelu",[d.leakyRelu,d.parseAlphaAttributes]],["MatMul",[l.matMul]],["MaxPool",[c.maxPool,c.parseMaxPoolAttributes]],["Mul",[a.mul]],["Neg",[d.neg]],["Pow",[a.pow]],["Reciprocal",[d.reciprocal]],["Relu",[d.relu]],["Sigmoid",[d.sigmoid]],["Sin",[d.sin]],["Sinh",[d.sinh]],["Sqrt",[d.sqrt]],["Sub",[a.sub]],["Tan",[d.tan]],["Tanh",[d.tanh]],["ThresholdedRelu",[d.thresholdedRelu,d.parseAlphaAttributes]],["Transpose",[p.transpose,p.parseTransposeAttributes]]])},1427:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.biasActivationSnippet=t.activationFnSnippet=t.typeSnippet=void 0,t.typeSnippet=e=>{switch(e){case 1:return"f32";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`${e}-component is not supported.`)}},t.activationFnSnippet=(e,t=!1,n=!1,r=3)=>"",t.biasActivationSnippet=(e,t)=>`\n ${e?"value = value + getBiasByOutputCoords(coords);":""}\n ${t?"value = activation(value, coords);":""}\n `},9456:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createConv2DMatMulProgramInfo=void 0;const r=n(4955),o=n(6952),i=n(1163),a=n(1427),s=n(4085),u=n(158);t.createConv2DMatMulProgramInfo=(e,t,n,l,c,p,d,f,h)=>{const g="NHWC"===n.format,m=g?e[0].dims[3]:e[0].dims[1],b=l[0],y=g?l[2]:l[3],w=g?l[1]:l[2],_=g?l[3]:l[1],v=((m%4==0||m%3==0)&&g||y%4==0&&!g)&&_%4==0,x=g?_:y*w,T=g?y*w:_,S=v?[8,8,1]:[x<=4?4:16,x>4&&T<=4?4:16,1],O=v?[4,4,1]:[x<=4?1:2,x>4&&T<=4?1:2,1],A=[Math.ceil(x/S[0]/O[0]),Math.ceil(T/S[1]/O[1]),Math.ceil(b/S[2]/O[1])];(0,r.LOG_DEBUG)("verbose",(()=>`[conv2d_mm_webgpu] dispatch = ${A}`));const E=v?g&&m%4!=0?3:4:O[0],I=S[1]*O[1],$=S[0]*O[0],P=Math.max(S[0]*E,S[1]),D=c%I==0,k=p%$==0,C=d%P==0,R=v?[E,4,4]:[1,1,1],M=[`@group(0) @binding(0) var x: array<${v&&4===E?"vec4":"f32"}>;`,`@group(0) @binding(1) var w: array<${v?"vec4":"f32"}>;`];let N=`\n fn setOutputAtIndex(flatIndex : i32, value : ${v?"vec4":"f32"}) {\n result[flatIndex] = ${v?"vec4":"f32"}(value);\n }\n fn setOutputAtCoords(d0 : i32, d1 : i32, d2 : i32, d3 : i32, value : ${v?"vec4":"f32"}) {\n let flatIndex = getOutputIndexFromCoords(vec4(d0, d1, d2, d3));\n setOutputAtIndex(flatIndex ${v?"/ 4":""}, value);\n }`;return f&&(M.push(`@group(0) @binding(2) var bias: array<${v?"vec4":"f32"}>;`),N+=`\n fn getBiasByOutputCoords(coords : vec4) -> ${v?"vec4":"f32"} {\n return bias[coords.${g?"w":"y"}${v?"/ 4":""}];\n }`),Object.assign(Object.assign({},t),{outputs:[{dims:l,dataType:e[0].dataType,gpuDataType:i.GpuDataType.default}],dispatchGroup:()=>({x:A[0],y:A[1],z:A[2]}),getShaderSource:()=>`\n ${s.utilFunctions}\n //struct Uniforms { xShape : vec4, wShape : vec4, outShape : vec4,\n // outShapeStrides: vec3, filterDims : vec2, pad : vec2, stride : vec2,\n // dilation : vec2, dimAOuter : i32, dimBOuter : i32, dimInner : i32 };\n ${M.join("")}\n @group(0) @binding(${M.length}) var result: array<${v?"vec4":"f32"}>;\n //@group(0) @binding(${M.length+1}) var uniforms: Uniforms;\n\n const xShape : vec4 = vec4(${e[0].dims.join(",")});\n const wShape : vec4 = vec4(${e[1].dims.join(",")});\n const outShape : vec4 = vec4(${l.join(",")});\n const outShapeStrides : vec3 = vec3(${o.ShapeUtil.computeStrides(l).slice(0,3).join(",")});\n const filterDims : vec2 = vec2(${n.kernelShape[0]}, ${n.kernelShape[1]});\n const pad : vec2 = vec2(${n.pads[0]}, ${n.pads[1]});\n const stride : vec2 = vec2(${n.strides[0]}, ${n.strides[1]});\n const dilation : vec2 = vec2(${n.dilations[0]}, ${n.dilations[1]});\n const dimAOuter : i32 = ${c};\n const dimBOuter : i32 = ${p};\n const dimInner : i32 = ${d};\n ${N}\n ${((e,t,n,r,o=!1,i,s=!1,u=4,l=4,c=4)=>{const p=e?"\n let coord = vec4(batch, xRow, xCol, xCh);\n ":"\n let coord = vec4(batch, xCh, xRow, xCol);\n ",d=e?"\n let coords = vec4(\n batch,\n row / outWidth,\n row % outWidth,\n col);\n ":"\n let coords = vec4(\n batch,\n row,\n col / outWidth,\n col % outWidth);\n ",f=e?"xShape[1]":"xShape[2]",h=e?"xShape[2]":"xShape[3]",g=e?"row":"col",m=e?"col":"row",b=`\n let inChannels = wShape[2];\n let outWidth = ${e?"outShape[2]":"outShape[3]"};\n let outRow = ${g} / outWidth;\n let outCol = ${g} % outWidth;\n\n let WRow = ${m} / (filterDims[1] * inChannels);\n let WCol = ${m} / inChannels % filterDims[1];\n let xRow = outRow * stride[0] + dilation[0] * WRow - pad[0];\n let xCol = outCol * stride[1] + dilation[1] * WCol - pad[1];\n let xCh = ${m} % inChannels;\n var resData = ${(0,a.typeSnippet)(u)}(0.0);\n // The bounds checking is always needed since we use it to pad zero for\n // the 'same' padding type.\n if (xRow >= 0 && xRow < ${f} && xCol >= 0 && xCol < ${h}) {\n ${p}\n let xIndex = getIndexFromCoords4D(coord, xShape);\n ${(e=>{switch(e){case 1:return"resData = x[xIndex];";case 3:return"resData = vec3(x[xIndex], x[xIndex + 1], x[xIndex + 2]);";case 4:return"resData = x[xIndex / 4];";default:throw new Error(`innerElementSize ${e} is not supported.`)}})(u)}\n }\n return resData;`,y=e?t&&r?`\n let col = colIn * ${u};\n ${b}`:`\n let col = colIn * ${u};\n if (row < dimAOuter && col < dimInner) {\n ${b}\n }\n return ${(0,a.typeSnippet)(u)}(0.0);`:r&&n?`\n let col = colIn * ${u};\n ${b}`:`\n let col = colIn * ${u};\n if (row < dimInner && col < dimBOuter) {\n ${b}\n }\n return ${(0,a.typeSnippet)(u)}(0.0);`,w=`${(e=>{switch(e){case 1:return"return w[row * wShape[3] + colIn];";case 4:return"return w[row * wShape[3] / 4 + colIn];";default:throw new Error(`innerElementSize ${e} is not supported.`)}})(l)}`,_=(0,a.typeSnippet)(c),v=e?(0,a.typeSnippet)(u):(0,a.typeSnippet)(l),x=e?(0,a.typeSnippet)(l):(0,a.typeSnippet)(u);return`\n ${(0,a.activationFnSnippet)(i,s,4===c,4)}\n fn mm_readA(batch: i32, row : i32, colIn : i32) -> ${v} {\n ${e?y:w}\n }\n\n fn mm_readB(batch: i32, row : i32, colIn : i32) -> ${x} {\n ${e?w:y}\n }\n\n fn mm_write(batch: i32, row : i32, colIn : i32, valueIn : ${_}) {\n let col = colIn * ${c};\n if (row < dimAOuter && col < dimBOuter)\n {\n var value = valueIn;\n let outWidth = ${e?"outShape[2]":"outShape[3]"};\n ${d}\n ${(0,a.biasActivationSnippet)(o,i)}\n setOutputAtCoords(coords[0], coords[1], coords[2], coords[3], value);\n }\n }`})(g,D,k,C,f,void 0,!1,R[0],R[1],R[2])}\n ${v?(0,u.makeMatMulPackedVec4Source)(O,S,!g,P):(0,u.makeMatMulPackedSource)(O,S,!g,P,!1,void 0,h)}`})}},4085:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.utilFunctions=void 0,t.utilFunctions="\nfn getIndexFromCoords4D(coords : vec4, shape : vec4) -> i32 {\n return dot(coords, vec4(\n shape.y * shape.z * shape.w, shape.z * shape.w, shape.w, 1));\n}\nfn getOutputIndexFromCoords(coords : vec4) -> i32 {\n return dot(coords, vec4(\n outShapeStrides.x, outShapeStrides.y, outShapeStrides.z, 1));\n}\n"},158:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.makeMatMulPackedSource=t.makeMatMulPackedVec4Source=void 0,t.makeMatMulPackedVec4Source=(e,t,n=!1,r=32,o=!1,i=32,a=!1)=>{const s=t[1]*e[1],u=t[0]*e[0],l=n?s:r,c=n?r:s,p=l/t[0],d=r/t[1];if((!n||4!==p||4!==e[1])&&(n||3!==p&&4!==p)||l%t[0]!=0||r%t[1]!=0||4!==e[0])throw new Error(`If transposeA ${n} is true, innerElementSize ${p} and workPerThread[1] ${e[1]} must be 4.\n Otherwise, innerElementSize ${p} must be 3 or 4.\n tileAWidth ${l} must be divisible by workgroupSize[0]${t[0]}. tileInner ${r} must be divisible by workgroupSize[1] ${t[1]}. colPerThread ${e[0]} must be 4.`);return`\nvar mm_Asub : array, ${l/p}>, ${c}>;\nvar mm_Bsub : array, ${u/e[0]}>, ${r}>;\n\nconst rowPerThread = ${e[1]};\nconst colPerThread = ${e[0]};\nconst innerElementSize = ${p};\nconst tileInner = ${r};\n\n@compute @workgroup_size(${t[0]}, ${t[1]}, ${t[2]})\nfn main(@builtin(local_invocation_id) localId : vec3,\n @builtin(global_invocation_id) globalId : vec3,\n @builtin(workgroup_id) workgroupId : vec3) {\n let localRow = i32(localId.y);\n let tileRow = ${a?"0":"localRow * rowPerThread"};\n let tileCol = i32(localId.x);\n\n let globalRow = ${a?"0":"i32(globalId.y) * rowPerThread"};\n let globalCol = i32(globalId.x);\n let batch = ${o?"0":"i32(globalId.z)"};\n let globalRowStart = i32(workgroupId.y) * ${s};\n\n let numTiles = ${o?`${Math.ceil(i/r)}`:"(dimInner - 1) / tileInner + 1"};\n var kStart = ${o?`i32(globalId.z) * ${i}`:"0"};\n\n var acc: array, rowPerThread>;\n\n // Loop over shared dimension.\n let tileRowB = localRow * ${d};\n for (var t = 0; t < numTiles; t = t + 1) {\n // Load one tile of A into local memory.\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n let inputRow = tileRow + innerRow;\n let inputCol = tileCol;\n ${f=n,f?"\n mm_Asub[inputRow][inputCol] = mm_readA(batch,\n kStart + inputRow,\n globalRowStart / innerElementSize + inputCol);\n ":"\n mm_Asub[inputRow][inputCol] = mm_readA(batch,\n globalRow + innerRow,\n kStart / innerElementSize + inputCol);\n "}\n }\n\n // Load one tile of B into local memory.\n for (var innerRow = 0; innerRow < ${d}; innerRow = innerRow + 1) {\n let inputRow = tileRowB + innerRow;\n let inputCol = tileCol;\n mm_Bsub[inputRow][inputCol] = mm_readB(batch, kStart + inputRow, globalCol);\n }\n kStart = kStart + tileInner;\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n for (var k = 0; k < tileInner / innerElementSize; k = k + 1) {\n let BCached0 = mm_Bsub[k * innerElementSize][tileCol];\n let BCached1 = mm_Bsub[k * innerElementSize + 1][tileCol];\n let BCached2 = mm_Bsub[k * innerElementSize + 2][tileCol];\n ${3===p?"":"let BCached3 = mm_Bsub[k * innerElementSize + 3][tileCol];"}\n\n ${((e,t)=>e?`\n let ACached0 = mm_Asub[k * innerElementSize][localRow];\n let ACached1 = mm_Asub[k * innerElementSize + 1][localRow];\n let ACached2 = mm_Asub[k * innerElementSize + 2][localRow];\n ${3===t?"":"let ACached3 = mm_Asub[k * innerElementSize + 3][localRow];"}\n for (var i = 0; i < rowPerThread; i = i + 1) {\n acc[i] = BCached0 * ACached0[i] + acc[i];\n acc[i] = BCached1 * ACached1[i] + acc[i];\n acc[i] = BCached2 * ACached2[i] + acc[i];\n ${3===t?"":"acc[i] = BCached3 * ACached3[i] + acc[i];"}\n }`:`\n for (var i = 0; i < rowPerThread; i = i + 1) {\n let ACached = mm_Asub[tileRow + i][k];\n acc[i] = BCached0 * ACached.x + acc[i];\n acc[i] = BCached1 * ACached.y + acc[i];\n acc[i] = BCached2 * ACached.z + acc[i];\n ${3===t?"":"acc[i] = BCached3 * ACached.w + acc[i];"}\n }`)(n,p)}\n }\n\n workgroupBarrier();\n }\n\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n mm_write(batch, globalRow + innerRow, globalCol, acc[innerRow]);\n }\n}`;var f};const n=e=>e?"\n mm_Asub[inputRow][inputCol] = mm_readA(batch,\n kStart + inputRow,\n globalRowStart + inputCol);\n ":"\n mm_Asub[inputRow][inputCol] = mm_readA(batch,\n globalRowStart + inputRow,\n kStart + inputCol);\n ";t.makeMatMulPackedSource=(e,t,r=!1,o=32,i=!1,a=32,s=!1)=>{const u=e[1]*t[1],l=e[0]*t[0],c=r?u:o,p=r?o:u;if(p%t[1]!=0||c%t[0]!=0||o%t[1]!=0)throw new Error(`tileAHight ${p} must be divisible by workgroupSize[1]${t[1]}, tileAWidth ${c} must be divisible by workgroupSize[0]${t[0]}, tileInner ${o} must be divisible by workgroupSize[1]${t[1]}`);const d=p/t[1],f=c/t[0],h=o/t[1],g=s?`\n let localRow = i32(localId.y);\n let localCol = i32(localId.x);\n let globalRowStart = i32(workgroupId.y) * ${u};\n let globalColStart = i32(workgroupId.x) * ${l};\n\n // Loop over shared dimension.\n for (var t = 0; t < numTiles; t = t + 1) {\n // Load one tile of A into local memory.\n for (var inputRow = localRow; inputRow < ${p}; inputRow = inputRow + ${t[1]}) {\n for (var inputCol = localCol; inputCol < ${c}; inputCol = inputCol + ${t[0]}) {\n ${n(r)}\n }\n }\n // Load one tile of B into local memory.\n for (var inputRow = localRow; inputRow < ${o}; inputRow = inputRow + ${t[1]}) {\n for (var inputCol = localCol; inputCol < ${l}; inputCol = inputCol + ${t[0]}) {\n mm_Bsub[inputRow][inputCol] = mm_readB(batch,\n kStart + inputRow,\n globalColStart + inputCol);\n }\n }\n kStart = kStart + tileInner;\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n var BCached : array;\n for (var k = 0; k < tileInner; k = k + 1) {\n for (var inner = 0; inner < colPerThread; inner = inner + 1) {\n BCached[inner] = mm_Bsub[k][localCol + inner * ${t[0]}];\n }\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n let ACached = ${r?`mm_Asub[k][localRow + innerRow * ${t[1]}];`:`mm_Asub[localRow + innerRow * ${t[1]}][k];`}\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n acc[innerRow][innerCol] = acc[innerRow][innerCol] +\n ACached * BCached[innerCol];\n }\n }\n }\n workgroupBarrier();\n }\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n let gRow = globalRowStart + localRow + innerRow * ${t[1]};\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n let gCol = globalColStart + localCol + innerCol * ${t[0]};\n mm_write(batch, gRow, gCol, acc[innerRow][innerCol]);\n }\n }\n `:`\nlet tileRow = i32(localId.y) * rowPerThread;\nlet tileCol = i32(localId.x) * colPerThread;\n\nlet globalRow = i32(globalId.y) * rowPerThread;\nlet globalCol = i32(globalId.x) * colPerThread;\nlet globalRowStart = i32(workgroupId.y) * ${u};\n\nlet tileRowA = i32(localId.y) * ${d};\nlet tileColA = i32(localId.x) * ${f};\nlet tileRowB = i32(localId.y) * ${h};\n// Loop over shared dimension.\nfor (var t = 0; t < numTiles; t = t + 1) {\n // Load one tile of A into local memory.\n for (var innerRow = 0; innerRow < ${d}; innerRow = innerRow + 1) {\n for (var innerCol = 0; innerCol < ${f}; innerCol = innerCol + 1) {\n let inputRow = tileRowA + innerRow;\n let inputCol = tileColA + innerCol;\n ${n(r)}\n }\n }\n\n // Load one tile of B into local memory.\n for (var innerRow = 0; innerRow < ${h}; innerRow = innerRow + 1) {\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n let inputRow = tileRowB + innerRow;\n let inputCol = tileCol + innerCol;\n mm_Bsub[inputRow][inputCol] = mm_readB(batch,\n kStart + inputRow,\n globalCol + innerCol);\n }\n }\n kStart = kStart + tileInner;\n workgroupBarrier();\n\n // Compute acc values for a single thread.\n var BCached : array;\n for (var k = 0; k < tileInner; k = k + 1) {\n for (var inner = 0; inner < colPerThread; inner = inner + 1) {\n BCached[inner] = mm_Bsub[k][tileCol + inner];\n }\n\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n ${(e=>e?"let ACached = mm_Asub[k][tileRow + innerRow];":"let ACached = mm_Asub[tileRow + innerRow][k];")(r)}\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n acc[innerRow][innerCol] = acc[innerRow][innerCol] + ACached * BCached[innerCol];\n }\n }\n }\n\n workgroupBarrier();\n}\n\nfor (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n mm_write(batch, globalRow + innerRow, globalCol + innerCol,\n acc[innerRow][innerCol]);\n }\n}\n`;return`\n var mm_Asub : array, ${p}>;\n var mm_Bsub : array, ${o}>;\n const rowPerThread = ${e[1]};\n const colPerThread = ${e[0]};\n const tileInner = ${o};\n\n@compute @workgroup_size(${t[0]}, ${t[1]}, ${t[2]})\nfn main(@builtin(local_invocation_id) localId : vec3,\n @builtin(global_invocation_id) globalId : vec3,\n @builtin(workgroup_id) workgroupId : vec3) {\n let batch = ${i?"0":"i32(globalId.z)"};\n let numTiles = ${i?`${Math.ceil(a/o)}`:"(dimInner - 1) / tileInner + 1"};\n var kStart = ${i?`i32(globalId.z) * ${a}`:"0"};\n\n var acc : array, rowPerThread>;\n\n // Without this initialization strange values show up in acc.\n for (var innerRow = 0; innerRow < rowPerThread; innerRow = innerRow + 1) {\n for (var innerCol = 0; innerCol < colPerThread; innerCol = innerCol + 1) {\n acc[innerRow][innerCol] = 0.0;\n }\n }\n ${g}\n }\n`}},504:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sub=t.pow=t.mul=t.div=t.add=void 0;const r=n(6952),o=n(1163),i=n(2075),a=(e,t,n,a,s)=>{const u={name:t,inputTypes:[o.GpuDataType.default,o.GpuDataType.default],cacheHint:s};return Object.assign(Object.assign({},u),{get:()=>((e,t,n,a,s,u=t.dataType)=>{var l,c;const p=!r.ShapeUtil.areEqual(t.dims,n.dims);let d=t.dims,f=r.ShapeUtil.size(t.dims),h=!1;if(p){const e=r.BroadcastUtil.calcShape(t.dims,n.dims,!1);if(!e)throw new Error("Can't perform binary op on the given tensors");d=e,f=r.ShapeUtil.size(d);let o=1;for(let e=0;e((e,t,n,o,a,s,u,l,c="f32",p="f32",d="f32")=>{const f=r.ShapeUtil.size(o),h=Math.ceil(f/4);let g,m;"string"==typeof u?g=m=(e,t)=>`${u}((${e}),(${t}))`:"function"==typeof u?g=m=u:(g=u.scalar,m=u.vector);let b="";const y=(0,i.createIndicesHelper)("output",o);if(s){const e=e=>{const t=r.ShapeUtil.computeStrides(e),n=[];for(let r=e.length-1;r>=0;r--){const i=0===o.length?"0u":1===o.length?"(*outputIndices)":`(*outputIndices)[${r+o.length-e.length}]`;n.push(`${t[r]}u * (${i} % ${e[r]}u)`)}return n.length>0?n.join("+"):"0u"};b=`\n ${y.o2iImpl}\n\n fn calcOffsetA(outputIndices: ptr) -> u32 {\n return ${e(t)};\n }\n\n fn calcOffsetB(outputIndices: ptr) -> u32 {\n return ${e(n)};\n }\n `}let w;if(a)w=s?`\n ${y.indicesVariableDeclaration("outputIndices")}\n ${y.o2iCall("global_idx * 4u","outputIndices")}\n let offsetA = calcOffsetA(&outputIndices);\n let offsetB = calcOffsetB(&outputIndices);\n outputData[global_idx] = ${m("aData[offsetA / 4u]","bData[offsetB / 4u]")};`:`outputData[global_idx] = ${m("aData[global_idx]","bData[global_idx]")};`;else{if(!s)throw new Error("no necessary to use scalar implementation for element-wise binary op implementation.");const e=e=>{const t=`aData[indexA${e}][componentA${e}]`,n=`bData[indexB${e}][componentB${e}]`;return`\n ${y.o2iCall(`global_idx * 4u + ${e}u`,"outputIndices")}\n let offsetA${e} = calcOffsetA(&outputIndices);\n let offsetB${e} = calcOffsetB(&outputIndices);\n let indexA${e} = offsetA${e} / 4u;\n let indexB${e} = offsetB${e} / 4u;\n let componentA${e} = offsetA${e} % 4u;\n let componentB${e} = offsetB${e} % 4u;\n outputData[global_idx][${e}] = ${g(t,n)};`};w=`\n ${y.indicesVariableDeclaration("outputIndices")}\n ${e(0)}\n ${e(1)}\n ${e(2)}\n ${e(3)}`}return`\n @group(0) @binding(0) var aData : array>;\n @group(0) @binding(1) var bData : array>;\n @group(0) @binding(2) var outputData : array>;\n\n ${null!=l?l:""}\n ${b}\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes(h)}\n ${w}\n }`})(e,t.dims,n.dims,d,h,p,a,s),outputs:[{dims:d,dataType:u,gpuDataType:o.GpuDataType.default}],dispatchGroup:()=>({x:Math.ceil(f/64/(h?4:1))})})})(u,e[0],e[1],n,a)})};t.add=e=>{e.compute(a(e.inputs,"Add",((e,t)=>`${e}+${t}`)))},t.div=e=>{e.compute(a(e.inputs,"Div",((e,t)=>`${e}/${t}`)))},t.mul=e=>{e.compute(a(e.inputs,"Mul",((e,t)=>`${e}*${t}`)))},t.pow=e=>{e.compute(a(e.inputs,"Pow",{scalar:(e,t)=>`pow_f32(${e},${t})`,vector:(e,t)=>`pow_vf32(${e},${t})`},"\n fn pow_f32(a : f32, b : f32) -> f32 {\n if (b == 0.0) {\n return 1.0;\n } else if (a < 0.0 && b != floor(b)) {\n return pow(a, b); // NaN\n }\n return select(sign(a), 1.0, round(abs(b) % 2.0) != 1.0) * pow(abs(a), b);\n }\n fn pow_vf32(a : vec4, b : vec4) -> vec4 {\n // TODO: implement vectorized pow\n return vec4(pow_f32(a.x, b.x), pow_f32(a.y, b.y), pow_f32(a.z, b.z), pow_f32(a.w, b.w));\n }\n "))},t.sub=e=>{e.compute(a(e.inputs,"Sub",((e,t)=>`${e}-${t}`)))}},2075:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createShaderHelper=t.createIndicesHelper=t.WORKGROUP_SIZE=void 0;const r=n(6952);t.WORKGROUP_SIZE=64,t.createIndicesHelper=(e,t)=>{const n=t.length<2?"u32":`array`,o=r.ShapeUtil.computeStrides(t);let i="";for(let e=0;e) {\n var current = offset;\n ${i}\n }`,s=[];if(0===t.length)s.push("0u");else if(t.length<2)s.push("(*indices)");else for(let e=t.length-1;e>=0;e--)s.push(`${o[e]}u * ((*indices)[${e}])`);return{o2iImpl:a,o2iCall:(n,r)=>t.length<2?`${r}=${n};`:`ih_o2i_${e}(${n}, &${r});`,i2oImpl:t.length<2?"":`\n fn ih_i2o_${e}(indices: ptr) -> u32 {\n return ${s.join("+")};\n }`,i2oExpression:(n,r)=>t.length<2?`(${r?"*":""}${n})`:`ih_i2o_${e}(${r?"":"&"}${n})`,indicesVariableDeclaration:(e,t)=>`var ${e}:${n}${t?`=${n}(${t.join(",")})`:""};`,iType:n}};class o{constructor(e){this.normalizedDispatchGroup=e}guardAgainstOutOfBoundsWorkgroupSizes(e){return`if (global_idx >= ${"number"==typeof e?`${e}u`:e}) { return; }`}mainStart(e=t.WORKGROUP_SIZE){const n="number"==typeof e?e:e[0],r="number"==typeof e?1:e[1],o="number"==typeof e?1:e[2],i=1===this.normalizedDispatchGroup[1]&&1===this.normalizedDispatchGroup[2];return`@compute @workgroup_size(${n}, ${r}, ${o})\n fn main(${i?"@builtin(global_invocation_id) global_id : vec3":"@builtin(local_invocation_index) local_index : u32,\n @builtin(workgroup_id) workgroup_id : vec3"}) {\n ${i?"let global_idx = global_id.x;":`let global_idx = (workgroup_id.z * ${this.normalizedDispatchGroup[0]*this.normalizedDispatchGroup[1]}u +\n workgroup_id.y * ${this.normalizedDispatchGroup[0]}u + workgroup_id.x) * ${n*r*o}u + local_index;`}\n `}}t.createShaderHelper=e=>new o(e)},9192:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createGroupedConvProgramInfoLoader=void 0;const r=n(6952),o=n(1163),i=n(2075),a=n(9770),s=n(3997);t.createGroupedConvProgramInfoLoader=(e,t,n)=>{const u=(l=e.length>2,c=t.cacheKey,{name:"GroupedConv",inputTypes:l?[o.GpuDataType.default,o.GpuDataType.default,o.GpuDataType.default]:[o.GpuDataType.default,o.GpuDataType.default],cacheHint:c});var l,c;return Object.assign(Object.assign({},u),{get:()=>((e,t,n,u)=>{const l=e.length>2,c=l?"value += b[output_channel];":"",p=e[0].dims,d=e[1].dims,f=d[0]/n.group,h="f32",{activationFunction:g,applyActivation:m}=(0,s.getActicationSnippet)(n),b=[`@group(0) @binding(0) var x : array<${h}>;`,`@group(0) @binding(1) var w : array<${h}>;`];l&&b.push(`@group(0) @binding(2) var b : array<${h}>;`);const y="NHWC"===n.format,w=(0,a.calculateOutputShape)(p,d,n.dilations,n.pads,n.strides,y),_=r.ShapeUtil.size(w),v=(0,i.createIndicesHelper)("output",w),x=(0,i.createIndicesHelper)("x",p),T=(0,i.createIndicesHelper)("w",d);return Object.assign(Object.assign({},t),{outputs:[{dims:u?u(w):w,dataType:e[0].dataType,gpuDataType:o.GpuDataType.default}],getShaderSource:e=>`\n const strides: vec2 = vec2(${n.strides[0]}u, ${n.strides[1]}u);\n const pads: vec2 = vec2(${n.pads[0]}u, ${n.pads[1]}u);\n\n ${b.join("\n")}\n @group(0) @binding(${b.length}) var output : array<${h}>;\n\n ${g}\n ${v.o2iImpl}\n ${x.i2oImpl}\n ${T.i2oImpl}\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes(_)}\n\n ${v.indicesVariableDeclaration("outputIndices")}\n ${v.o2iCall("global_idx","outputIndices")}\n let batch: u32 = outputIndices[0];\n let output_channel: u32 = outputIndices[${y?3:1}];\n let xRCCorner: vec2 = vec2(outputIndices[${y?1:2}], outputIndices[${y?2:3}]) * strides - pads;\n let group_id: u32 = output_channel / ${f}u;\n\n var value: ${h} = ${h}(0);\n for (var wInChannel: u32 = 0u; wInChannel < ${d[1]}u; wInChannel++) {\n let input_channel = group_id * ${d[1]}u + wInChannel;\n for (var wHeight: u32 = 0u; wHeight < ${d[2]}u; wHeight++) {\n let xHeight = xRCCorner.x + wHeight * ${n.dilations[0]}u;\n\n if (xHeight < 0u || xHeight >= ${p[y?1:2]}u) {\n continue;\n }\n\n for (var wWidth: u32 = 0u; wWidth < ${d[3]}u; wWidth++) {\n let xWidth = xRCCorner.y + wWidth * ${n.dilations[1]}u;\n if (xWidth < 0u || xWidth >= ${p[y?2:3]}u) {\n continue;\n }\n\n ${x.indicesVariableDeclaration("xIndices",y?["batch","xHeight","xWidth","input_channel"]:["batch","input_channel","xHeight","xWidth"])}\n let xVal = x[${x.i2oExpression("xIndices")}];\n ${T.indicesVariableDeclaration("wIndices",["output_channel","wInChannel","wHeight","wWidth"])}\n let wVal = w[${T.i2oExpression("wIndices")}];\n value += xVal*wVal;\n }\n }\n }\n ${c}\n ${m}\n output[global_idx] = value;\n }`,dispatchGroup:()=>({x:Math.ceil(_/64)})})})(e,u,t,n)})}},9770:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.conv=t.parseConvAttributes=t.calculateOutputShape=void 0;const r=n(6952),o=n(387),i=n(9192),a=n(3822),s=n(3997),u=n(2625);t.calculateOutputShape=(e,t,n,r,o,i)=>{const a=e[0],s=e.slice(i?1:2,i?3:4),u=s.length,l=t[0],c=t.slice(2).map(((e,t)=>e+(e-1)*(n[t]-1))),p=s.map(((e,t)=>e+r[t]+r[t+u])).map(((e,t)=>Math.floor((e-c[t]+o[t])/o[t])));return p.splice(0,0,a),p.splice(i?3:1,0,l),p};const l=(0,o.createAttributeWithCacheKey)({perm:[2,3,1,0]}),c=(e,t)=>{const n=e.kernelShape.slice();for(let e=2;e{const t=(0,s.parseInternalActivationAttributes)(e),n=e.format,r=["NOTSET","VALID","SAME_UPPER","SAME_LOWER"][e.auto_pad],i=e.dilations,a=e.group,u=e.kernel_shape,l=e.pads,c=e.strides,p=e.w_is_const();return(0,o.createAttributeWithCacheKey)(Object.assign({autoPad:r,format:n,dilations:i,group:a,kernelShape:u,pads:l,strides:c,wIsConst:p},t))},t.conv=(e,n)=>{((e,t)=>{if(!e||2!==e.length&&3!==e.length)throw new Error("Conv requires 2 or 3 inputs");if(4!==e[0].dims.length&&3!==e[0].dims.length)throw new Error("currently only support conv 1D and 2D");if(e[0].dims.length!==e[1].dims.length)throw new Error("filter does not have same dimension as input");if(e[0].dims["NHWC"===t.format?e[0].dims.length-1:1]!==e[1].dims[1]*t.group)throw new Error("FILTER_IN_CHANNEL should be equal to DATA_CHANNEL");if(3===e.length&&(1!==e[2].dims.length||e[1].dims[0]!==e[2].dims[0]))throw new Error("invalid bias");const n=e[0].dims.length-2;if(t.dilations.length!==n)throw new Error(`dilations should be ${n}D`);if(t.strides.length!==n)throw new Error(`strides should be ${n}D`);if(t.pads.length!==2*n)throw new Error(`pads should be ${2*n}D`);if(0!==t.kernelShape.length&&t.kernelShape.length!==e[1].dims.length-2)throw new Error("invalid kernel shape");if(1!==e[0].dataType||1!==e[1].dataType)throw new Error("Conv input(X,W) should be float tensor");if(3===e.length&&1!==e[2].dataType)throw new Error("Conv input(bias) should be float tensor")})(e.inputs,n),3===e.inputs[0].dims.length?((e,t)=>{const n="NHWC"===t.format,r=[e.inputs[0].reshape(n?[e.inputs[0].dims[0],1,e.inputs[0].dims[1],e.inputs[0].dims[2]]:[e.inputs[0].dims[0],e.inputs[0].dims[1],1,e.inputs[0].dims[2]]),e.inputs[1].reshape([e.inputs[1].dims[0],e.inputs[1].dims[1],1,e.inputs[1].dims[2]])];3===e.inputs.length&&r.push(e.inputs[2]);const o=[0,t.pads[0],0,t.pads[1]],a=[1].concat(t.strides),s=[1].concat(t.dilations),u=[1].concat(t.kernelShape),l=c(Object.assign(Object.assign({},t),{pads:o,strides:a,dilations:s,kernelShape:u}),r);e.compute((0,i.createGroupedConvProgramInfoLoader)(r,l,(e=>n?[e[0],e[2],e[3]]:[])))})(e,n):((e,n,r)=>{var o;const s=c(r,n),p=3===n.length,d="NHWC"===r.format,f=n[0].dims[d?1:2],h=n[0].dims[d?2:3],g=n[0].dims[d?3:1],m=n[1].dims[2],b=n[1].dims[3],y=(0,t.calculateOutputShape)(n[0].dims,n[1].dims,r.dilations,s.pads,r.strides,d),w=y[d?1:2],_=y[d?2:3],v=y[d?3:1];if(d&&m===f&&b===h&&"VALID"===r.autoPad||1===m&&1===b&&1===r.dilations[0]&&1===r.dilations[1]&&1===r.strides[0]&&1===r.strides[1]&&("SAME_UPPER"===r.autoPad||"SAME_LOWER"===r.autoPad||"VALID"===r.autoPad))return void e.compute((0,i.createGroupedConvProgramInfoLoader)(n,s));if(!d||1!==r.group)return void e.compute((0,i.createGroupedConvProgramInfoLoader)(n,s));const x=d?w*_:v,T=d?v:w*_,S=m*b*g,O=null!==(o=e.customData.wT)&&void 0!==o?o:e.compute(Object.assign(Object.assign({},u.transposeProgramMetadata),{cacheHint:l.cacheKey,get:()=>(0,u.createTransposeProgramInfo)(n[1],l.perm)}),{inputs:[1],outputs:[r.wIsConst?-2:-1]})[0];r.wIsConst&&!e.customData.wT&&(e.customData.wT=O);const A=[n[0],O];p&&(d||1!==n[2].dims.length?A.push(n[2]):A.push(n[2].reshape([n[2].dims[0],1,1]))),e.compute((0,a.createConv2DMatMulProgramInfoLoader)(A,s,y,x,T,S,p,!0),{inputs:A})})(e,e.inputs,n)}},3822:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createConv2DMatMulProgramInfoLoader=void 0;const r=n(1163),o=n(9456);t.createConv2DMatMulProgramInfoLoader=(e,t,n,i,a,s,u,l)=>{const c=((e,t)=>({name:"Conv2DMatMul",inputTypes:e?[r.GpuDataType.default,r.GpuDataType.default,r.GpuDataType.default]:[r.GpuDataType.default,r.GpuDataType.default],cacheHint:t}))(u,t.cacheKey);return Object.assign(Object.assign({},c),{get:()=>(0,o.createConv2DMatMulProgramInfo)(e,c,t,n,i,a,s,u,l)})}},3997:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseInternalActivationAttributes=t.getActicationSnippet=void 0;const r=n(6952);t.getActicationSnippet=e=>{switch(e.activation){case"Relu":return{activationFunction:"",applyActivation:"value = max(value, 0.0);"};case"Sigmoid":return{activationFunction:"",applyActivation:"value = (1.0 / (1.0 + exp(-value)));"};case"Clip":return{activationFunction:`const clip_min_=f32(${e.clipMin});const clip_max_=f32(${e.clipMax});`,applyActivation:"value = clamp(value, clip_min_, clip_max_);"};default:return{activationFunction:"",applyActivation:""}}},t.parseInternalActivationAttributes=e=>{const t=(null==e?void 0:e.activation)||"";if("Clip"===t){const[n,o]=(null==e?void 0:e.activation_params)||[r.MIN_CLIP,r.MAX_CLIP];return{activation:t,clipMax:o,clipMin:n,activationCacheKey:`${t}:${n},${o}`}}return{activation:t,activationCacheKey:t}}},4271:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseGemmAttributes=t.gemm=void 0;const r=n(6952),o=n(387),i=n(1163);t.gemm=(e,t)=>{(e=>{if(!e)throw new Error("Input is missing");if(e.length<2||e.length>3)throw new Error("Invaid input number.");if(3===e.length&&e[2].dims.length>2)throw new Error("Invalid input shape of C");if(1!==e[0].dataType||1!==e[1].dataType||3===e.length&&1!==e[2].dataType)throw new Error("Invalid input type.");if(e[0].dataType!==e[1].dataType||3===e.length&&e[0].dataType!==e[2].dataType)throw new Error("Input types are mismatched")})(e.inputs),e.compute(((e,t)=>{const n={name:"Gemm",inputTypes:3===e.length?[i.GpuDataType.default,i.GpuDataType.default,i.GpuDataType.default]:[i.GpuDataType.default,i.GpuDataType.default],cacheHint:t.cacheKey};return Object.assign(Object.assign({},n),{get:()=>((e,t,n)=>{const o=t[0].dims.slice(),a=t[1].dims.slice(),[s,u,l]=r.GemmUtil.getShapeOfGemmResult(o,n.transA,a,n.transB,3===t.length?t[2].dims:void 0),c=[s,u];if(!c)throw new Error("Can't use gemm on the given tensors");const p=r.ShapeUtil.size(c);let d="";n.transA&&n.transB?d="value += a[k * M + m] * b[n * K + k];":n.transA&&!n.transB?d="value += a[k * M + m] * b[k * N + n];":!n.transA&&n.transB?d="value += a[m * K + k] * b[n * K + k];":n.transA||n.transB||(d="value += a[m * K + k] * b[k * N + n];");const f="f32",h=1===n.alpha?"":"value *= alpha;",g=3===t.length?`value += beta * c[${((e,t,n)=>{if(0===n.length)return"0u";const r=1===n.length&&1!==e||2===n.length&&n[0]!==e,o=n[n.length-1]!==t;let i="0u";return r||(i+=`+ m * ${n[n.length-1]}u`),o||(i+="+n"),i})(s,u,t[2].dims)}];`:"",m=[`@group(0) @binding(0) var a : array<${f}>;`,`@group(0) @binding(1) var b : array<${f}>;`];return 3===t.length&&m.push(`@group(0) @binding(2) var c : array<${f}>;`),Object.assign(Object.assign({},e),{outputs:[{dims:c,dataType:t[0].dataType,gpuDataType:i.GpuDataType.default}],getShaderSource:e=>`\n const M: u32 = ${s}u;\n const N: u32 = ${u}u;\n const K: u32 = ${l}u;\n const alpha = ${f}(${n.alpha});\n const beta = ${f}(${n.beta});\n\n ${m.join("\n")}\n @group(0) @binding(${t.length}) var output : array<${f}>;\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes(p)}\n\n let m = global_id.x / N;\n let n = global_id.x % N;\n\n var value = ${f}(0);\n for (var k: u32 = 0u; k<${l}u; k++) {\n ${d}\n }\n\n ${h}\n ${g}\n output[global_id.x] = value;\n\n }`,dispatchGroup:()=>({x:Math.ceil(p/64)})})})(n,e,t)})})(e.inputs,t))},t.parseGemmAttributes=e=>(0,o.createAttributeWithCacheKey)(e)},1522:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.matMul=t.createMatmulProgramInfoLoader=void 0;const r=n(6952),o=n(1163),i=n(3997);t.createMatmulProgramInfoLoader=(e,t)=>{const n=(a=e.length>2,s=t.activationCacheKey,{name:"MatMul",inputTypes:a?[o.GpuDataType.default,o.GpuDataType.default,o.GpuDataType.default]:[o.GpuDataType.default,o.GpuDataType.default],cacheHint:s});var a,s;return Object.assign(Object.assign({},n),{get:()=>((e,t,n)=>{const a=t[0].dims,s=t[1].dims,u=r.BroadcastUtil.calcShape(a,s,!0);if(!u)throw new Error("Can't use matmul on the given tensors");const l=r.ShapeUtil.size(u),c="f32",{activationFunction:p,applyActivation:d}=(0,i.getActicationSnippet)(n),f=u[u.length-2],h=a[a.length-1],g=u[u.length-1];return Object.assign(Object.assign({},e),{outputs:[{dims:u,dataType:t[0].dataType,gpuDataType:o.GpuDataType.default}],getShaderSource:e=>`\n const M: u32 = ${f}u;\n const N: u32 = ${g}u;\n const K: u32 = ${h}u;\n\n @group(0) @binding(0) var a : array<${c}>;\n @group(0) @binding(1) var b : array<${c}>;\n @group(0) @binding(2) var output : array<${c}>;\n\n ${p}\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes(l)}\n\n let stack = global_idx / (M * N);\n let mn = global_idx % (M * N);\n let n = global_idx % N;\n let m = mn / N;\n\n let offsetA = stack * (M * K);\n let offsetB = stack * (K * N);\n\n var value = ${c}(0);\n for (var k: u32 = 0u; k<${h}u; k++) {\n value += a[offsetA + m * K + k] * b[offsetB + k * N + n];\n }\n ${d}\n output[global_idx] = value;\n }`,dispatchGroup:()=>({x:Math.ceil(l/64)})})})(n,e,t)})},t.matMul=e=>{(e=>{if(!e||2!==e.length)throw new Error("MatMul requires 2 inputs.");if(e[0].dims[e[0].dims.length-1]!==e[1].dims[e[1].dims.length-2])throw new Error("shared dimension does not match.");if(1!==e[0].dataType||1!==e[1].dataType)throw new Error("inputs should be float type")})(e.inputs),e.compute((0,t.createMatmulProgramInfoLoader)(e.inputs,{activation:"",activationCacheKey:""}))}},5262:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.globalMaxPool=t.parseGlobalMaxPoolAttributes=t.parseMaxPoolAttributes=t.maxPool=t.globalAveragePool=t.parseGlobalAveragePoolAttributes=t.averagePool=t.parseAveragePoolAttributes=void 0;const r=n(6952),o=n(387),i=n(1163),a=n(2075),s=e=>{if(!e||1!==e.length)throw new Error("Pool ops requires 1 input.");if(4!==e[0].dims.length)throw new Error("Pool ops supports 2-D inputs only for now.");if(1!==e[0].dataType)throw new Error("Invalid input type.")},u=(e,t,n)=>{const o="NHWC"===t.format,i=o?[e[0].dims[0],e[0].dims[3],e[0].dims[1],e[0].dims[2]]:e[0].dims.slice(),a=Object.hasOwnProperty.call(t,"dilations"),s=t.kernelShape.slice(),u=t.strides.slice(),l=a?t.dilations.slice():[],c=t.pads.slice();r.PoolConvUtil.adjustPoolAttributes(n,i,s,u,l,c);const p=r.PoolConvUtil.computePoolOutputShape(n,i,u,l,s,c,t.autoPad),d=Object.assign({},t);return a?Object.assign(d,{kernelShape:s,strides:u,pads:c,dilations:l,cacheKey:t.cacheKey}):Object.assign(d,{kernelShape:s,strides:u,pads:c,cacheKey:t.cacheKey}),[d,o?[p[0],p[2],p[3],p[1]]:p]},l=(e,t,n,o,i,s,u,l)=>{const c="NHWC"===o.format,p=t.length,d=r.ShapeUtil.size(n),f=(0,a.createIndicesHelper)("output",n),h=(0,a.createIndicesHelper)("x",t);if(o.kernelShape.length<=2){const n=o.kernelShape[o.kernelShape.length-1],r=o.strides[o.strides.length-1],a=o.pads[o.pads.length/2-1],g=p-(c?2:1);let m="",b="",y="";if(m=a+o.pads[o.pads.length-1]!==0?`\n for (var i: u32 = 0u; i < ${n}u; i++) {\n xIndices[${g}] = indices[${g}] * ${r} - ${a} + i;\n if (xIndices[${g}] < 0 || xIndices[${g}] >= ${t[g]}) {\n pad++;\n continue;\n }\n let x_val = x[${h.i2oExpression("xIndices")}];\n ${i}\n }`:`\n for (var i: u32 = 0u; i < ${n}u; i++) {\n xIndices[${g}] = indices[${g}] * ${r} - ${a} + i;\n let x_val = x[${h.i2oExpression("xIndices")}];\n ${i}\n }`,2===o.kernelShape.length){const e=o.kernelShape[o.kernelShape.length-2],r=o.strides[o.strides.length-2],i=o.pads[o.pads.length/2-2],a=o.pads[o.pads.length-2],s=p-(c?3:2),u=t[s];b=i+a!==0?`\n for (var j: u32 = 0u; j < ${e}u; j++) {\n xIndices[${s}] = indices[${s}] * ${r} - ${i} + j;\n if (xIndices[${s}] < 0 || xIndices[${s}] >= ${u}) {\n pad+= ${n};\n continue;\n }\n `:`\n for (var j: u32 = 0u; j < ${e}u; j++) {\n xIndices[${s}] = indices[${s}] * ${r} - ${i} + j;\n `,y="\n }\n "}return`\n @group(0) @binding(0) var x : array<${u}>;\n @group(0) @binding(1) var output : array<${u}>;\n\n ${f.o2iImpl}\n ${h.i2oImpl}\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes(d)}\n\n ${f.indicesVariableDeclaration("indices")}\n ${f.o2iCall("global_idx","indices")}\n ${f.indicesVariableDeclaration("xIndices")}\n ${f.o2iCall("global_idx","xIndices")}\n\n var value: ${u} = ${u}(${l});\n var pad = 0;\n ${b}\n ${m}\n ${y}\n ${s}\n\n output[global_idx] = value;\n }`}{if(c)throw new Error("Pooling with kernelShape.length > 2 is not supported for NHWC format.");const n=r.ShapeUtil.size(o.kernelShape),a=r.ShapeUtil.computeStrides(o.kernelShape),g=a.length,m=o.pads.length;let b="";return b=o.pads.reduce(((e,t)=>e+t))?`\n if (xIndices[j] >= inputDims[j]) {\n pad++;\n isPad = true;\n break;\n }\n }\n if (!isPad) {\n let x_val = x[${h.i2oExpression("xIndices")}];\n ${i}\n }`:`\n }\n let x_val = x[${h.i2oExpression("xIndices")}];\n ${i}\n `,`\n @group(0) @binding(0) var x : array<${u}>;\n @group(0) @binding(1) var output : array<${u}>;\n\n ${f.o2iImpl}\n ${h.i2oImpl}\n\n const pads = array(${o.pads.map((e=>`${e}u`)).join(",")});\n const inputDims = array(${t.map((e=>`${e}u`)).join(",")});\n const kernelStrides = array(${a.map((e=>`${e}u`)).join(",")});\n const strides = array(${o.strides.map((e=>`${e}u`)).join(",")});\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes(d)}\n\n ${f.indicesVariableDeclaration("indices")}\n ${f.o2iCall("global_idx","indices")}\n ${f.indicesVariableDeclaration("xIndices")}\n ${f.o2iCall("global_idx","xIndices")}\n\n var offsets: array;\n\n var value = ${u}(${l});\n var pad = 0;\n var isPad = false;\n\n for (var i: u32 = 0u; i < ${n}u; i++) {\n var offset = i;\n for (var j = 0u; j < ${g-1}u; j++) {\n offsets[j] = offset / kernelStrides[j];\n offset -= offsets[j] * kernelStrides[j];\n }\n offsets[${g-1}] = offset;\n\n isPad = false;\n for (var j = ${p-g}u; j < ${p}u; j++) {\n xIndices[j] = indices[j] * strides[j - ${p-g}u]\n + offsets[j - ${p-g}u] - pads[j - 2u];\n ${b}\n }\n ${s}\n\n output[global_idx] = value;\n }`}},c=e=>({format:e.format,autoPad:["NOTSET","VALID","SAME_UPPER","SAME_LOWER"][e.auto_pad],ceilMode:e.ceil_mode,kernelShape:e.kernel_shape,strides:e.strides,pads:e.pads}),p=(e,t,n,o)=>{const[a,s]=u(e,o,n),c=r.ShapeUtil.size(a.kernelShape),p="f32";let d="";return a.countIncludePad?d+=`value /= ${p}(${c});`:d+=`value /= ${p}(${c} - pad);`,Object.assign(Object.assign({},t),{outputs:[{dims:s,dataType:e[0].dataType,gpuDataType:i.GpuDataType.default}],getShaderSource:t=>l(t,e[0].dims,s,a,"value += x_val;",d,p,"0.0"),dispatchGroup:()=>({x:Math.ceil(r.ShapeUtil.size(s)/64)})})};t.parseAveragePoolAttributes=e=>{const t=0!==e.count_include_pad,n=c(e);if(0!==n.ceilMode)throw new Error("using ceil() in shape computation is not yet supported for AveragePool");return(0,o.createAttributeWithCacheKey)(Object.assign({countIncludePad:t},n))},t.averagePool=(e,t)=>{s(e.inputs);const n={name:"AveragePool",inputTypes:[i.GpuDataType.default],cacheHint:t.cacheKey};e.compute(Object.assign(Object.assign({},n),{get:()=>p(e.inputs,n,!1,t)}))};const d={autoPad:"",ceilMode:0,countIncludePad:!1,kernelShape:[],strides:[],pads:[],storageOrder:0,dilations:[],cacheKey:""};t.parseGlobalAveragePoolAttributes=e=>{const t=e.format;return Object.assign(Object.assign({format:t},d),{cacheKey:t})},t.globalAveragePool=(e,t)=>{s(e.inputs);const n={name:"GlobalAveragePool",inputTypes:[i.GpuDataType.default],cacheHint:t.cacheKey};e.compute(Object.assign(Object.assign({},n),{get:()=>p(e.inputs,n,!0,t)}))};const f=(e,t,n,o)=>{const[a,s]=u(e,o,n);return Object.assign(Object.assign({},t),{outputs:[{dims:s,dataType:e[0].dataType,gpuDataType:i.GpuDataType.default}],getShaderSource:t=>l(t,e[0].dims,s,a,"\n value = max(x_val, value);\n ","","f32","-1e5"),dispatchGroup:()=>({x:Math.ceil(r.ShapeUtil.size(s)/64)})})};t.maxPool=(e,t)=>{s(e.inputs);const n={name:"MaxPool",inputTypes:[i.GpuDataType.default],cacheHint:t.cacheKey};e.compute(Object.assign(Object.assign({},n),{get:()=>f(e.inputs,n,!1,t)}))},t.parseMaxPoolAttributes=e=>{const t=e.storage_order,n=e.dilations,r=c(e);if(0!==t)throw new Error("column major storage order is not yet supported for MaxPool");if(0!==r.ceilMode)throw new Error("using ceil() in shape computation is not yet supported for MaxPool");return(0,o.createAttributeWithCacheKey)(Object.assign({storageOrder:t,dilations:n},r))},t.parseGlobalMaxPoolAttributes=e=>{const t=e.format;return Object.assign(Object.assign({format:t},d),{cacheKey:t})},t.globalMaxPool=(e,t)=>{s(e.inputs);const n={name:"GlobalMaxPool",inputTypes:[i.GpuDataType.default],cacheHint:t.cacheKey};e.compute(Object.assign(Object.assign({},n),{get:()=>f(e.inputs,n,!0,t)}))}},2625:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseTransposeAttributes=t.transpose=t.createTransposeProgramInfo=t.transposeProgramMetadata=void 0;const r=n(6952),o=n(387),i=n(1163),a=n(2075);t.transposeProgramMetadata={name:"Transpose",inputTypes:[i.GpuDataType.default]};const s=(e,t)=>t&&t.length!==e.length?[...e.keys()].reverse():t;t.createTransposeProgramInfo=(e,n)=>{const o=e.dims,u=s(o,n),l=((e,t)=>r.ShapeUtil.sortBasedOnPerm(e,s(e,t)))(o,u),c=o.length,p=r.ShapeUtil.size(l),d=(0,a.createIndicesHelper)("output",l),f=(0,a.createIndicesHelper)("a",o);return Object.assign(Object.assign({},t.transposeProgramMetadata),{outputs:[{dims:l,dataType:e.dataType,gpuDataType:i.GpuDataType.default}],getShaderSource:e=>`\n @group(0) @binding(0) var a : array;\n @group(0) @binding(1) var output : array;\n\n ${((e,t)=>{const n=[];n.push(`fn perm(a: ptr>, i: ptr>) {`);for(let r=0;r({x:Math.ceil(p/64)})})},t.transpose=(e,n)=>{(e=>{if(!e||1!==e.length)throw new Error("Transpose requires 1 input.");if(1!==e[0].dataType)throw new Error("input should be float tensor")})(e.inputs),e.compute(Object.assign(Object.assign({},t.transposeProgramMetadata),{cacheHint:n.cacheKey,get:()=>(0,t.createTransposeProgramInfo)(e.inputs[0],n.perm)}))},t.parseTransposeAttributes=e=>(0,o.createAttributeWithCacheKey)({perm:e.perm})},9302:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.thresholdedRelu=t.tanh=t.tan=t.sqrt=t.sinh=t.sin=t.sigmoid=t.relu=t.reciprocal=t.neg=t.leakyRelu=t.floor=t.exp=t.erf=t.elu=t.parseAlphaAttributes=t.cosh=t.cos=t.ceil=t.clip=t.clipV10=t.atanh=t.atan=t.asinh=t.asin=t.acosh=t.acos=t.abs=void 0;const r=n(6952),o=n(387),i=n(1163),a=(e,t,n,o,a)=>{const s={name:t,inputTypes:[i.GpuDataType.default],cacheHint:a};return Object.assign(Object.assign({},s),{get:()=>((e,t,n,o)=>Object.assign(Object.assign({},e),{getShaderSource:e=>((e,t,n,r)=>{const o=Math.ceil(t/4);let i="";return i="string"==typeof n?`${n}(a)`:n("a"),`\n @group(0) @binding(0) var inputData : array>;\n @group(0) @binding(1) var outputData : array>;\n\n ${null!=r?r:""}\n\n ${e.mainStart()}\n ${e.guardAgainstOutOfBoundsWorkgroupSizes(o)}\n\n let a = inputData[global_idx];\n outputData[global_idx] = ${i};\n }`})(e,r.ShapeUtil.size(t.dims),n,o),outputs:[{dims:t.dims,dataType:t.dataType,gpuDataType:i.GpuDataType.default}],dispatchGroup:e=>({x:Math.ceil(r.ShapeUtil.size(e[0].dims)/64/4)})}))(s,e,n,o)})};t.abs=e=>{e.compute(a(e.inputs[0],"Abs","abs"))},t.acos=e=>{e.compute(a(e.inputs[0],"Acos","acos"))},t.acosh=e=>{e.compute(a(e.inputs[0],"Acosh","acosh"))},t.asin=e=>{e.compute(a(e.inputs[0],"Asin","asin"))},t.asinh=e=>{e.compute(a(e.inputs[0],"Asinh","asinh"))},t.atan=e=>{e.compute(a(e.inputs[0],"Atan","atan"))},t.atanh=e=>{e.compute(a(e.inputs[0],"Atanh","atanh"))},t.clipV10=(e,t)=>{e.compute(a(e.inputs[0],"Clip",(e=>`clamp(${e}, clip_min_, clip_max_)`),`\n const clip_min_: vec4 = vec4(f32(${t.min}));\n const clip_max_: vec4 = vec4(f32(${t.max}));\n`,t.cacheKey),{inputs:[0]})},t.clip=e=>{const n=(e=>{const t=e.length>=2?e[1].getFloat32Array()[0]:r.MIN_CLIP,n=e.length>=3?e[2].getFloat32Array()[0]:r.MAX_CLIP;return(0,o.createAttributeWithCacheKey)({min:t,max:n})})(e.inputs);(0,t.clipV10)(e,n)},t.ceil=e=>{e.compute(a(e.inputs[0],"Ceil","ceil"))},t.cos=e=>{e.compute(a(e.inputs[0],"Cos","cos"))},t.cosh=e=>{e.compute(a(e.inputs[0],"Cosh","cosh"))},t.parseAlphaAttributes=e=>(0,o.createAttributeWithCacheKey)(e),t.elu=(e,t)=>{e.compute(a(e.inputs[0],"Elu",(e=>`elu_vf32(${e})`),`\n const elu_alpha_: f32 = f32(${t.alpha});\n\n fn elu_f32(a: f32) -> f32 {\n return select((exp(a) - 1.0) * elu_alpha_, a, a >= 0.0);\n }\n\n fn elu_vf32(v: vec4) -> vec4 {\n return vec4(elu_f32(v.x), elu_f32(v.y), elu_f32(v.z), elu_f32(v.w));\n }`,t.cacheKey))},t.erf=e=>{e.compute(a(e.inputs[0],"Erf",(e=>`erf_vf32(${e})`),"\n const r0: f32 = 0.3275911;\n const r1: f32 = 0.254829592;\n const r2: f32 = -0.284496736;\n const r3: f32 = 1.421413741;\n const r4: f32 = -1.453152027;\n const r5: f32 = 1.061405429;\n\n fn erf_vf32(v: vec4) -> vec4 {\n let absv = abs(v);\n let x = 1.0 / (1.0 + r0 * absv);\n return sign(v) * (1.0 - ((((r5 * x + r4) * x + r3) * x + r2) * x + r1) * x * exp(-absv * absv));\n }"))},t.exp=e=>{e.compute(a(e.inputs[0],"Exp","exp"))},t.floor=e=>{e.compute(a(e.inputs[0],"Floor","floor"))},t.leakyRelu=(e,t)=>{e.compute(a(e.inputs[0],"LeakyRelu",(e=>`select(leaky_relu_alpha_ * ${e}, ${e}, ${e} >= vec4(0.0))`),`const leaky_relu_alpha_: f32 = f32(${t.alpha});`,t.cacheKey))},t.neg=e=>{e.compute(a(e.inputs[0],"Neg",(e=>`-${e}`)))},t.reciprocal=e=>{e.compute(a(e.inputs[0],"Reciprocal",(e=>`1.0/${e}`)))},t.relu=e=>{e.compute(a(e.inputs[0],"Relu",(e=>`select(vec4(0.0), ${e}, ${e} > vec4(0.0))`)))},t.sigmoid=e=>{e.compute(a(e.inputs[0],"Sigmoid",(e=>`(1.0 / (1.0 + exp(-${e})))`)))},t.sin=e=>{e.compute(a(e.inputs[0],"Sin","sin"))},t.sinh=e=>{e.compute(a(e.inputs[0],"Sinh","sinh"))},t.sqrt=e=>{e.compute(a(e.inputs[0],"Sqrt","sqrt"))},t.tan=e=>{e.compute(a(e.inputs[0],"Tan","tan"))},t.tanh=e=>{e.compute(a(e.inputs[0],"Tanh","tanh"))},t.thresholdedRelu=(e,t)=>(e.compute(a(e.inputs[0],"ThresholdedRelu",(e=>`select(vec4(0.0), ${e}, ${e} > thresholded_relu_alpha_)`),`const thresholded_relu_alpha_: vec4 = vec4(${t.alpha});`,t.cacheKey)),0)},8305:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ProgramManager=void 0;const r=n(4955),o=n(2075);t.ProgramManager=class{constructor(e){this.backend=e,this.repo=new Map,this.attributesBound=!1}getArtifact(e){return this.repo.get(e)}setArtifact(e,t){this.repo.set(e,t)}run(e,t,n,r){const o=this.backend.device,i=this.backend.getComputePassEncoder();this.backend.profilingEnabled&&i.writeTimestamp(this.backend.profilingQuerySet,0),i.setPipeline(e.computePipeline);const a=[];for(const e of t)a.push({binding:a.length,resource:{buffer:e.buffer}});for(const e of n)a.push({binding:a.length,resource:{buffer:e.buffer}});const s=o.createBindGroup({layout:e.computePipeline.getBindGroupLayout(0),entries:a});if(i.setBindGroup(0,s),i.dispatchWorkgroups(...r),this.backend.pendingDispatchNumber++,this.backend.profilingEnabled){i.writeTimestamp(this.backend.profilingQuerySet,1);const e=this.backend.gpuDataManager.create(16,GPUBufferUsage.COPY_SRC|GPUBufferUsage.QUERY_RESOLVE),t=this.backend.gpuDataManager.create(16,GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST);this.backend.endComputePass(),this.backend.getCommandEncoder().resolveQuerySet(this.backend.profilingQuerySet,0,2,e.buffer,0),this.backend.getCommandEncoder().copyBufferToBuffer(e.buffer,0,t.buffer,0,16),this.backend.flush();const n=this.backend.currentKernelId,r=this.backend.kernels.get(n)[0];t.buffer.mapAsync(GPUMapMode.READ).then((()=>{const o=new BigUint64Array(t.buffer.getMappedRange()),i=o[0],a=o[1];t.buffer.unmap(),void 0===this.backend.profilingTimeBase&&(this.backend.profilingTimeBase=i);const s=Number(i-this.backend.profilingTimeBase),u=Number(a-this.backend.profilingTimeBase);if(!Number.isSafeInteger(s)||!Number.isSafeInteger(u))throw new RangeError("incorrect timestamp range");this.backend.gpuDataManager.release(e.id),this.backend.gpuDataManager.release(t.id),console.log(`[profiling] kernel "${n}|${r}" execution time: ${u-s} ns`)}))}this.backend.pendingDispatchNumber>=16&&this.backend.flush()}dispose(){}build(e,t){const n=this.backend.device,i=e.getShaderSource((0,o.createShaderHelper)(t)),a=n.createShaderModule({code:i});return(0,r.LOG_DEBUG)("verbose",(()=>`[WebGPU] shader code: ${i}`)),{programInfo:e,computePipeline:n.createComputePipeline({compute:{module:a,entryPoint:"main"},layout:"auto"})}}normalizeDispatchGroupSize(e){const t="number"==typeof e?e:e.x,n="number"==typeof e?1:e.y||1,r="number"==typeof e?1:e.z||1,o=this.backend.device.limits.maxComputeWorkgroupsPerDimension;if(t<=o&&n<=o&&r<=o)return[t,n,r];const i=t*n*r;let a=Math.ceil(Math.sqrt(i));if(a>o){if(a=Math.ceil(Math.cbrt(i)),a>o)throw new Error("Total dispatch size exceeds WebGPU maximum.");return[a,a,a]}return[a,a,1]}}},1163:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.GpuDataType=void 0,(n=t.GpuDataType||(t.GpuDataType={}))[n.default=0]="default",n[n.upload=1]="upload",n[n.profile=2]="profile"},3899:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.iterateExtraOptions=void 0,t.iterateExtraOptions=(e,n,r,o)=>{if("object"==typeof e&&null!==e){if(r.has(e))throw new Error("Circular reference in options");r.add(e)}Object.entries(e).forEach((([e,i])=>{const a=n?n+e:e;if("object"==typeof i)(0,t.iterateExtraOptions)(i,a+".",r,o);else if("string"==typeof i||"number"==typeof i)o(a,i.toString());else{if("boolean"!=typeof i)throw new Error("Can't handle extra config type: "+typeof i);o(a,i?"1":"0")}}))}},9544:function(e,t,n){"use strict";var r,o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initOrt=t.initWasm=void 0;const s=n(8453),u=n(7675),l=a(n(1259)),c=n(263),p=()=>!!s.env.wasm.proxy&&"undefined"!=typeof document;let d,f,h,g=!1,m=!1,b=!1;const y=[],w=[],_=[],v=[],x=[],T=[],S=()=>{if(g||!m||b||!d)throw new Error("worker not ready")},O=e=>{switch(e.data.type){case"init-wasm":g=!1,e.data.err?(b=!0,f[1](e.data.err)):(m=!0,f[0]());break;case"init-ort":e.data.err?h[1](e.data.err):h[0]();break;case"create_allocate":e.data.err?y.shift()[1](e.data.err):y.shift()[0](e.data.out);break;case"create_finalize":e.data.err?w.shift()[1](e.data.err):w.shift()[0](e.data.out);break;case"create":e.data.err?_.shift()[1](e.data.err):_.shift()[0](e.data.out);break;case"release":e.data.err?v.shift()[1](e.data.err):v.shift()[0]();break;case"run":e.data.err?x.shift()[1](e.data.err):x.shift()[0](e.data.out);break;case"end-profiling":e.data.err?T.shift()[1](e.data.err):T.shift()[0]()}},A="undefined"!=typeof document?null===(r=null===document||void 0===document?void 0:document.currentScript)||void 0===r?void 0:r.src:void 0;t.initWasm=async()=>{if(p()){if(m)return;if(g)throw new Error("multiple calls to 'initWasm()' detected.");if(b)throw new Error("previous call to 'initWasm()' failed.");return g=!0,void 0===s.env.wasm.wasmPaths&&A&&0!==A.indexOf("blob:")&&(s.env.wasm.wasmPaths=A.substr(0,+A.lastIndexOf("/")+1)),new Promise(((e,t)=>{null==d||d.terminate(),d=n(8050).Z(),d.onmessage=O,f=[e,t];const r={type:"init-wasm",in:s.env.wasm};d.postMessage(r)}))}return(0,c.initializeWebAssembly)(s.env.wasm)},t.initOrt=async(e,t)=>{if(p())return S(),new Promise(((n,r)=>{h=[n,r];const o={type:"init-ort",in:{numThreads:e,loggingLevel:t}};d.postMessage(o)}));l.initOrt(e,t),await(0,u.init)((0,c.getInstance)())},t.createSessionAllocate=async e=>p()?(S(),new Promise(((t,n)=>{y.push([t,n]);const r={type:"create_allocate",in:{model:e}};d.postMessage(r,[e.buffer])}))):l.createSessionAllocate(e),t.createSessionFinalize=async(e,t)=>p()?(S(),new Promise(((n,r)=>{w.push([n,r]);const o={type:"create_finalize",in:{modeldata:e,options:t}};d.postMessage(o)}))):l.createSessionFinalize(e,t),t.createSession=async(e,t)=>p()?(S(),new Promise(((n,r)=>{_.push([n,r]);const o={type:"create",in:{model:e,options:t}};d.postMessage(o,[e.buffer])}))):l.createSession(e,t),t.releaseSession=async e=>{if(p())return S(),new Promise(((t,n)=>{v.push([t,n]);const r={type:"release",in:e};d.postMessage(r)}));l.releaseSession(e)},t.run=async(e,t,n,r,o)=>p()?(S(),new Promise(((i,a)=>{x.push([i,a]);const s={type:"run",in:{sessionId:e,inputIndices:t,inputs:n,outputIndices:r,options:o}};d.postMessage(s,l.extractTransferableBuffers(n))}))):l.run(e,t,n,r,o),t.endProfiling=async e=>{if(p())return S(),new Promise(((t,n)=>{T.push([t,n]);const r={type:"end-profiling",in:e};d.postMessage(r)}));l.endProfiling(e)}},7918:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setRunOptions=void 0;const r=n(3899),o=n(9444),i=n(263);t.setRunOptions=e=>{const t=(0,i.getInstance)();let n=0;const a=[],s=e||{};try{if(void 0===(null==e?void 0:e.logSeverityLevel))s.logSeverityLevel=2;else if("number"!=typeof e.logSeverityLevel||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${e.logSeverityLevel}`);if(void 0===(null==e?void 0:e.logVerbosityLevel))s.logVerbosityLevel=0;else if("number"!=typeof e.logVerbosityLevel||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);void 0===(null==e?void 0:e.terminate)&&(s.terminate=!1);let i=0;if(void 0!==(null==e?void 0:e.tag)&&(i=(0,o.allocWasmString)(e.tag,a)),n=t._OrtCreateRunOptions(s.logSeverityLevel,s.logVerbosityLevel,!!s.terminate,i),0===n)throw new Error("Can't create run options");return void 0!==(null==e?void 0:e.extra)&&(0,r.iterateExtraOptions)(e.extra,"",new WeakSet,((e,r)=>{const i=(0,o.allocWasmString)(e,a),s=(0,o.allocWasmString)(r,a);if(0!==t._OrtAddRunConfigEntry(n,i,s))throw new Error(`Can't set a run config entry: ${e} - ${r}`)})),[n,a]}catch(e){throw 0!==n&&t._OrtReleaseRunOptions(n),a.forEach(t._free),e}}},6640:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OnnxruntimeWebAssemblySessionHandler=void 0;const r=n(2806),o=n(8453),i=n(2850),a=n(9544),s=n(7917);let u;t.OnnxruntimeWebAssemblySessionHandler=class{async createSessionAllocate(e){const t=await fetch(e),n=await t.arrayBuffer();return(0,a.createSessionAllocate)(new Uint8Array(n))}async loadModel(e,t){if(u||(await(0,a.initOrt)(o.env.wasm.numThreads,(0,s.logLevelStringToEnum)(o.env.logLevel)),u=!0),"string"==typeof e)if("undefined"==typeof fetch){const n=await(0,i.promisify)(r.readFile)(e);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(n,t)}else{const n=await this.createSessionAllocate(e);[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSessionFinalize)(n,t)}else[this.sessionId,this.inputNames,this.outputNames]=await(0,a.createSession)(e,t)}async dispose(){return(0,a.releaseSession)(this.sessionId)}async run(e,t,n){const r=[],i=[];Object.entries(e).forEach((e=>{const t=e[0],n=e[1],o=this.inputNames.indexOf(t);if(-1===o)throw new Error(`invalid input '${t}'`);r.push(n),i.push(o)}));const s=[];Object.entries(t).forEach((e=>{const t=e[0],n=this.outputNames.indexOf(t);if(-1===n)throw new Error(`invalid output '${t}'`);s.push(n)}));const u=await(0,a.run)(this.sessionId,i,r.map((e=>[e.type,e.dims,e.data])),s,n),l={};for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSessionOptions=void 0;const r=n(3899),o=n(9444),i=n(263);t.setSessionOptions=e=>{var t,n,a,s;const u=(0,i.getInstance)();let l=0;const c=[],p=e||{};(e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});const t=e.extra.session;t.use_ort_model_bytes_directly||(t.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some((e=>"webgpu"===("string"==typeof e?e:e.name)))&&(e.enableMemPattern=!1)})(p);try{const e=(e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}})(null!==(t=p.graphOptimizationLevel)&&void 0!==t?t:"all"),d=(e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}})(null!==(n=p.executionMode)&&void 0!==n?n:"sequential"),f="string"==typeof p.logId?(0,o.allocWasmString)(p.logId,c):0,h=null!==(a=p.logSeverityLevel)&&void 0!==a?a:2;if(!Number.isInteger(h)||h<0||h>4)throw new Error(`log serverity level is not valid: ${h}`);const g=null!==(s=p.logVerbosityLevel)&&void 0!==s?s:0;if(!Number.isInteger(g)||g<0||g>4)throw new Error(`log verbosity level is not valid: ${g}`);const m="string"==typeof p.optimizedModelFilePath?(0,o.allocWasmString)(p.optimizedModelFilePath,c):0;if(l=u._OrtCreateSessionOptions(e,!!p.enableCpuMemArena,!!p.enableMemPattern,d,!!p.enableProfiling,0,f,h,g,m),0===l)throw new Error("Can't create session options");return p.executionProviders&&((e,t,n)=>{for(const r of t){let t="string"==typeof r?r:r.name;switch(t){case"xnnpack":t="XNNPACK";break;case"webgpu":t="JS";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${t}`)}const a=(0,o.allocWasmString)(t,n);if(0!==(0,i.getInstance)()._OrtAppendExecutionProvider(e,a))throw new Error(`Can't append execution provider: ${t}`)}})(l,p.executionProviders,c),void 0!==p.extra&&(0,r.iterateExtraOptions)(p.extra,"",new WeakSet,((e,t)=>{const n=(0,o.allocWasmString)(e,c),r=(0,o.allocWasmString)(t,c);if(0!==u._OrtAddSessionConfigEntry(l,n,r))throw new Error(`Can't set a session config entry: ${e} - ${t}`)})),[l,c]}catch(e){throw 0!==l&&u._OrtReleaseSessionOptions(l),c.forEach(u._free),e}}},9444:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allocWasmString=void 0;const r=n(263);t.allocWasmString=(e,t)=>{const n=(0,r.getInstance)(),o=n.lengthBytesUTF8(e)+1,i=n._malloc(o);return n.stringToUTF8(e,i,o),t.push(i),i}},7917:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelStringToEnum=t.tensorTypeToTypedArrayConstructor=t.getTensorElementSize=t.tensorDataTypeEnumToString=t.tensorDataTypeStringToEnum=void 0,t.tensorDataTypeStringToEnum=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${e}`)}},t.tensorDataTypeEnumToString=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${e}`)}},t.getTensorElementSize=e=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][e],t.tensorTypeToTypedArrayConstructor=e=>{switch(e){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${e}`)}},t.logLevelStringToEnum=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}}},1259:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTransferableBuffers=t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initOrt=void 0;const r=n(7918),o=n(7622),i=n(9444),a=n(7917),s=n(263);t.initOrt=(e,t)=>{const n=(0,s.getInstance)()._OrtInit(e,t);if(0!==n)throw new Error(`Can't initialize onnxruntime. error code = ${n}`)};const u=new Map;t.createSessionAllocate=e=>{const t=(0,s.getInstance)(),n=t._malloc(e.byteLength);return t.HEAPU8.set(e,n),[n,e.byteLength]},t.createSessionFinalize=(e,t)=>{const n=(0,s.getInstance)();let r=0,i=0,a=[];try{if([i,a]=(0,o.setSessionOptions)(t),r=n._OrtCreateSession(e[0],e[1],i),0===r)throw new Error("Can't create a session")}finally{n._free(e[0]),0!==i&&n._OrtReleaseSessionOptions(i),a.forEach(n._free)}const l=n._OrtGetInputCount(r),c=n._OrtGetOutputCount(r),p=[],d=[],f=[],h=[];for(let e=0;e{const r=(0,t.createSessionAllocate)(e);return(0,t.createSessionFinalize)(r,n)},t.releaseSession=e=>{const t=(0,s.getInstance)(),n=u.get(e);if(!n)throw new Error("invalid session id");const r=n[0],o=n[1],i=n[2];o.forEach(t._OrtFree),i.forEach(t._OrtFree),t._OrtReleaseSession(r),u.delete(e)},t.run=async(e,t,n,o,l)=>{const c=(0,s.getInstance)(),p=u.get(e);if(!p)throw new Error("invalid session id");const d=p[0],f=p[1],h=p[2],g=t.length,m=o.length;let b=0,y=[];const w=[],_=[];try{[b,y]=(0,r.setRunOptions)(l);for(let e=0;ec.HEAP32[e++]=t));const n=c._OrtCreateTensor((0,a.tensorDataTypeStringToEnum)(t),s,u,p,r.length);if(0===n)throw new Error("Can't create a tensor");w.push(n)}finally{c.stackRestore(l)}}const e=c.stackSave(),s=c.stackAlloc(4*g),u=c.stackAlloc(4*g),p=c.stackAlloc(4*m),v=c.stackAlloc(4*m);try{let e=s/4,n=u/4,r=p/4,i=v/4;for(let r=0;re*t));if(o=(0,a.tensorDataTypeEnumToString)(n),"string"===o){const e=[];let t=i/4;for(let n=0;n{const t=(0,s.getInstance)(),n=u.get(e);if(!n)throw new Error("invalid session id");const r=n[0],o=t._OrtEndProfiling(r);if(0===o)throw new Error("Can't get an profile file name");t._OrtFree(o)},t.extractTransferableBuffers=e=>{const t=[];for(const n of e){const e=n[2];!Array.isArray(e)&&e.buffer&&t.push(e.buffer)}return t}},263:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.dispose=t.getInstance=t.initializeWebAssembly=void 0;const a=i(n(6449)),s=n(932),u=n(3474);let l,c=!1,p=!1,d=!1;t.initializeWebAssembly=async e=>{if(c)return Promise.resolve();if(p)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(d)throw new Error("previous call to 'initializeWebAssembly()' failed.");p=!0;const t=e.initTimeout,r=e.numThreads,o=e.simd,i=r>1&&(()=>{try{return"undefined"!=typeof SharedArrayBuffer&&("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch(e){return!1}})(),f=o&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch(e){return!1}})(),h=e.wasmPaths,g="string"==typeof h?h:void 0,m=((e,t)=>t?e?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":e?"ort-wasm-simd.wasm":"ort-wasm.wasm")(f,i),b="object"==typeof h?h[m]:void 0;let y=!1;const w=[];if(t>0&&w.push(new Promise((e=>{setTimeout((()=>{y=!0,e()}),t)}))),w.push(new Promise(((e,t)=>{const r=i?u:s,o={locateFile:(e,t)=>i&&e.endsWith(".worker.js")&&"undefined"!=typeof Blob?URL.createObjectURL(new Blob([n(4154)],{type:"text/javascript"})):e.endsWith(".wasm")?b||(null!=g?g:t)+m:t+e};if(i)if("undefined"==typeof Blob)o.mainScriptUrlOrBlob=a.join("/","ort-wasm-threaded.js");else{const e=`var ortWasmThreaded=(function(){var _scriptDir;return ${r.toString()}})();`;o.mainScriptUrlOrBlob=new Blob([e],{type:"text/javascript"})}r(o).then((t=>{p=!1,c=!0,l=t,e()}),(e=>{p=!1,d=!0,t(e)}))}))),await Promise.race(w),y)throw new Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},t.getInstance=()=>{if(c&&l)return l;throw new Error("WebAssembly is not initialized yet.")},t.dispose=()=>{var e;!c||p||d||(p=!0,null===(e=l.PThread)||void 0===e||e.terminateAllThreads(),l=void 0,p=!1,c=!1,d=!0)}},8050:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});var r=n(6614),o=n.n(r);function i(){return o()('/*!\n* ONNX Runtime Web v1.15.0\n* Copyright (c) Microsoft Corporation. All rights reserved.\n* Licensed under the MIT License.\n*/\n(()=>{var e={899:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.iterateExtraOptions=void 0,t.iterateExtraOptions=(e,n,r,a)=>{if("object"==typeof e&&null!==e){if(r.has(e))throw new Error("Circular reference in options");r.add(e)}Object.entries(e).forEach((([e,o])=>{const i=n?n+e:e;if("object"==typeof o)(0,t.iterateExtraOptions)(o,i+".",r,a);else if("string"==typeof o||"number"==typeof o)a(i,o.toString());else{if("boolean"!=typeof o)throw new Error("Can\'t handle extra config type: "+typeof o);a(i,o?"1":"0")}}))}},918:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setRunOptions=void 0;const r=n(899),a=n(444),o=n(263);t.setRunOptions=e=>{const t=(0,o.getInstance)();let n=0;const i=[],s=e||{};try{if(void 0===(null==e?void 0:e.logSeverityLevel))s.logSeverityLevel=2;else if("number"!=typeof e.logSeverityLevel||!Number.isInteger(e.logSeverityLevel)||e.logSeverityLevel<0||e.logSeverityLevel>4)throw new Error(`log serverity level is not valid: ${e.logSeverityLevel}`);if(void 0===(null==e?void 0:e.logVerbosityLevel))s.logVerbosityLevel=0;else if("number"!=typeof e.logVerbosityLevel||!Number.isInteger(e.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);void 0===(null==e?void 0:e.terminate)&&(s.terminate=!1);let o=0;if(void 0!==(null==e?void 0:e.tag)&&(o=(0,a.allocWasmString)(e.tag,i)),n=t._OrtCreateRunOptions(s.logSeverityLevel,s.logVerbosityLevel,!!s.terminate,o),0===n)throw new Error("Can\'t create run options");return void 0!==(null==e?void 0:e.extra)&&(0,r.iterateExtraOptions)(e.extra,"",new WeakSet,((e,r)=>{const o=(0,a.allocWasmString)(e,i),s=(0,a.allocWasmString)(r,i);if(0!==t._OrtAddRunConfigEntry(n,o,s))throw new Error(`Can\'t set a run config entry: ${e} - ${r}`)})),[n,i]}catch(e){throw 0!==n&&t._OrtReleaseRunOptions(n),i.forEach(t._free),e}}},622:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setSessionOptions=void 0;const r=n(899),a=n(444),o=n(263);t.setSessionOptions=e=>{var t,n,i,s;const u=(0,o.getInstance)();let c=0;const l=[],f=e||{};(e=>{e.extra||(e.extra={}),e.extra.session||(e.extra.session={});const t=e.extra.session;t.use_ort_model_bytes_directly||(t.use_ort_model_bytes_directly="1"),e.executionProviders&&e.executionProviders.some((e=>"webgpu"===("string"==typeof e?e:e.name)))&&(e.enableMemPattern=!1)})(f);try{const e=(e=>{switch(e){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${e}`)}})(null!==(t=f.graphOptimizationLevel)&&void 0!==t?t:"all"),p=(e=>{switch(e){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${e}`)}})(null!==(n=f.executionMode)&&void 0!==n?n:"sequential"),d="string"==typeof f.logId?(0,a.allocWasmString)(f.logId,l):0,m=null!==(i=f.logSeverityLevel)&&void 0!==i?i:2;if(!Number.isInteger(m)||m<0||m>4)throw new Error(`log serverity level is not valid: ${m}`);const g=null!==(s=f.logVerbosityLevel)&&void 0!==s?s:0;if(!Number.isInteger(g)||g<0||g>4)throw new Error(`log verbosity level is not valid: ${g}`);const h="string"==typeof f.optimizedModelFilePath?(0,a.allocWasmString)(f.optimizedModelFilePath,l):0;if(c=u._OrtCreateSessionOptions(e,!!f.enableCpuMemArena,!!f.enableMemPattern,p,!!f.enableProfiling,0,d,m,g,h),0===c)throw new Error("Can\'t create session options");return f.executionProviders&&((e,t,n)=>{for(const r of t){let t="string"==typeof r?r:r.name;switch(t){case"xnnpack":t="XNNPACK";break;case"webgpu":t="JS";break;case"wasm":case"cpu":continue;default:throw new Error(`not supported EP: ${t}`)}const i=(0,a.allocWasmString)(t,n);if(0!==(0,o.getInstance)()._OrtAppendExecutionProvider(e,i))throw new Error(`Can\'t append execution provider: ${t}`)}})(c,f.executionProviders,l),void 0!==f.extra&&(0,r.iterateExtraOptions)(f.extra,"",new WeakSet,((e,t)=>{const n=(0,a.allocWasmString)(e,l),r=(0,a.allocWasmString)(t,l);if(0!==u._OrtAddSessionConfigEntry(c,n,r))throw new Error(`Can\'t set a session config entry: ${e} - ${t}`)})),[c,l]}catch(e){throw 0!==c&&u._OrtReleaseSessionOptions(c),l.forEach(u._free),e}}},444:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.allocWasmString=void 0;const r=n(263);t.allocWasmString=(e,t)=>{const n=(0,r.getInstance)(),a=n.lengthBytesUTF8(e)+1,o=n._malloc(a);return n.stringToUTF8(e,o,a),t.push(o),o}},917:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logLevelStringToEnum=t.tensorTypeToTypedArrayConstructor=t.getTensorElementSize=t.tensorDataTypeEnumToString=t.tensorDataTypeStringToEnum=void 0,t.tensorDataTypeStringToEnum=e=>{switch(e){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;default:throw new Error(`unsupported data type: ${e}`)}},t.tensorDataTypeEnumToString=e=>{switch(e){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";default:throw new Error(`unsupported data type: ${e}`)}},t.getTensorElementSize=e=>[void 0,4,1,1,2,2,4,8,void 0,1,2,8,4,8,void 0,void 0,void 0][e],t.tensorTypeToTypedArrayConstructor=e=>{switch(e){case"float32":return Float32Array;case"uint8":case"bool":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${e}`)}},t.logLevelStringToEnum=e=>{switch(e){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${e}`)}}},259:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.extractTransferableBuffers=t.endProfiling=t.run=t.releaseSession=t.createSession=t.createSessionFinalize=t.createSessionAllocate=t.initOrt=void 0;const r=n(918),a=n(622),o=n(444),i=n(917),s=n(263);t.initOrt=(e,t)=>{const n=(0,s.getInstance)()._OrtInit(e,t);if(0!==n)throw new Error(`Can\'t initialize onnxruntime. error code = ${n}`)};const u=new Map;t.createSessionAllocate=e=>{const t=(0,s.getInstance)(),n=t._malloc(e.byteLength);return t.HEAPU8.set(e,n),[n,e.byteLength]},t.createSessionFinalize=(e,t)=>{const n=(0,s.getInstance)();let r=0,o=0,i=[];try{if([o,i]=(0,a.setSessionOptions)(t),r=n._OrtCreateSession(e[0],e[1],o),0===r)throw new Error("Can\'t create a session")}finally{n._free(e[0]),0!==o&&n._OrtReleaseSessionOptions(o),i.forEach(n._free)}const c=n._OrtGetInputCount(r),l=n._OrtGetOutputCount(r),f=[],p=[],d=[],m=[];for(let e=0;e{const r=(0,t.createSessionAllocate)(e);return(0,t.createSessionFinalize)(r,n)},t.releaseSession=e=>{const t=(0,s.getInstance)(),n=u.get(e);if(!n)throw new Error("invalid session id");const r=n[0],a=n[1],o=n[2];a.forEach(t._OrtFree),o.forEach(t._OrtFree),t._OrtReleaseSession(r),u.delete(e)},t.run=async(e,t,n,a,c)=>{const l=(0,s.getInstance)(),f=u.get(e);if(!f)throw new Error("invalid session id");const p=f[0],d=f[1],m=f[2],g=t.length,h=a.length;let y=0,v=[];const b=[],w=[];try{[y,v]=(0,r.setRunOptions)(c);for(let e=0;el.HEAP32[e++]=t));const n=l._OrtCreateTensor((0,i.tensorDataTypeStringToEnum)(t),s,u,f,r.length);if(0===n)throw new Error("Can\'t create a tensor");b.push(n)}finally{l.stackRestore(c)}}const e=l.stackSave(),s=l.stackAlloc(4*g),u=l.stackAlloc(4*g),f=l.stackAlloc(4*h),_=l.stackAlloc(4*h);try{let e=s/4,n=u/4,r=f/4,o=_/4;for(let r=0;re*t));if(a=(0,i.tensorDataTypeEnumToString)(n),"string"===a){const e=[];let t=o/4;for(let n=0;n{const t=(0,s.getInstance)(),n=u.get(e);if(!n)throw new Error("invalid session id");const r=n[0],a=t._OrtEndProfiling(r);if(0===a)throw new Error("Can\'t get an profile file name");t._OrtFree(a)},t.extractTransferableBuffers=e=>{const t=[];for(const n of e){const e=n[2];!Array.isArray(e)&&e.buffer&&t.push(e.buffer)}return t}},263:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var a=Object.getOwnPropertyDescriptor(t,n);a&&!("get"in a?!t.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,a)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return a(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.dispose=t.getInstance=t.initializeWebAssembly=void 0;const i=o(n(449)),s=n(932),u=n(474);let c,l=!1,f=!1,p=!1;t.initializeWebAssembly=async e=>{if(l)return Promise.resolve();if(f)throw new Error("multiple calls to \'initializeWebAssembly()\' detected.");if(p)throw new Error("previous call to \'initializeWebAssembly()\' failed.");f=!0;const t=e.initTimeout,r=e.numThreads,a=e.simd,o=r>1&&(()=>{try{return"undefined"!=typeof SharedArrayBuffer&&("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])))}catch(e){return!1}})(),d=a&&(()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch(e){return!1}})(),m=e.wasmPaths,g="string"==typeof m?m:void 0,h=((e,t)=>t?e?"ort-wasm-simd-threaded.wasm":"ort-wasm-threaded.wasm":e?"ort-wasm-simd.wasm":"ort-wasm.wasm")(d,o),y="object"==typeof m?m[h]:void 0;let v=!1;const b=[];if(t>0&&b.push(new Promise((e=>{setTimeout((()=>{v=!0,e()}),t)}))),b.push(new Promise(((e,t)=>{const r=o?u:s,a={locateFile:(e,t)=>o&&e.endsWith(".worker.js")&&"undefined"!=typeof Blob?URL.createObjectURL(new Blob([n(154)],{type:"text/javascript"})):e.endsWith(".wasm")?y||(null!=g?g:t)+h:t+e};if(o)if("undefined"==typeof Blob)a.mainScriptUrlOrBlob=i.join("/","ort-wasm-threaded.js");else{const e=`var ortWasmThreaded=(function(){var _scriptDir;return ${r.toString()}})();`;a.mainScriptUrlOrBlob=new Blob([e],{type:"text/javascript"})}r(a).then((t=>{f=!1,l=!0,c=t,e()}),(e=>{f=!1,p=!0,t(e)}))}))),await Promise.race(b),v)throw new Error(`WebAssembly backend initializing failed due to timeout: ${t}ms`)},t.getInstance=()=>{if(l&&c)return c;throw new Error("WebAssembly is not initialized yet.")},t.dispose=()=>{var e;!l||f||p||(f=!0,null===(e=c.PThread)||void 0===e||e.terminateAllThreads(),c=void 0,f=!1,l=!1,p=!0)}},474:(e,t,n)=>{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){function t(){return P.buffer!=D&&G(P.buffer),F}function r(){return P.buffer!=D&&G(P.buffer),U}function a(){return P.buffer!=D&&G(P.buffer),I}function o(){return P.buffer!=D&&G(P.buffer),W}function i(){return P.buffer!=D&&G(P.buffer),j}var s,u,c;e=e||{},s||(s=void 0!==e?e:{}),s.ready=new Promise((function(e,t){u=e,c=t}));var l,f,p,d,m,g,h=Object.assign({},s),y="./this.program",v=(e,t)=>{throw t},b="object"==typeof window,w="function"==typeof importScripts,_="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,O=s.ENVIRONMENT_IS_PTHREAD||!1,S="";function T(e){return s.locateFile?s.locateFile(e,S):S+e}if(_){let t;S=w?n(908).dirname(S)+"/":"//",g=()=>{m||(d=n(384),m=n(908))},l=function(e,t){return g(),e=m.normalize(e),d.readFileSync(e,t?void 0:"utf8")},p=e=>((e=l(e,!0)).buffer||(e=new Uint8Array(e)),e),f=(e,t,n)=>{g(),e=m.normalize(e),d.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},1{if(C)throw process.exitCode=e,t;t instanceof ie||x("exiting due to exception: "+t),process.exit(e)},s.inspect=function(){return"[Emscripten Module object]"};try{t=n(925)}catch(e){throw console.error(\'The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?\'),e}n.g.Worker=t.Worker}else(b||w)&&(w?S=self.location.href:"undefined"!=typeof document&&document.currentScript&&(S=document.currentScript.src),_scriptDir&&(S=_scriptDir),S=0!==S.indexOf("blob:")?S.substr(0,S.replace(/[?#].*/,"").lastIndexOf("/")+1):"",_||(l=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},w&&(p=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),f=(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)}));_&&"undefined"==typeof performance&&(n.g.performance=n(953).performance);var A=console.log.bind(console),E=console.warn.bind(console);_&&(g(),A=e=>d.writeSync(1,e+"\\n"),E=e=>d.writeSync(2,e+"\\n"));var M,R=s.print||A,x=s.printErr||E;Object.assign(s,h),h=null,s.thisProgram&&(y=s.thisProgram),s.quit&&(v=s.quit),s.wasmBinary&&(M=s.wasmBinary);var C=s.noExitRuntime||!0;"object"!=typeof WebAssembly&&ne("no native wasm support detected");var P,k,D,F,U,I,W,j,H=!1,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function Y(e,t,n){var r=(t>>>=0)+n;for(n=t;e[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|o<<6|i:(7&a)<<18|o<<12|i<<6|63&e[t++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function z(e,t){return(e>>>=0)?Y(r(),e,t):""}function B(e,t,n,r){if(!(0>>=0;r=n+r-1;for(var o=0;o=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),127>=i){if(n>=r)break;t[n++>>>0]=i}else{if(2047>=i){if(n+1>=r)break;t[n++>>>0]=192|i>>6}else{if(65535>=i){if(n+2>=r)break;t[n++>>>0]=224|i>>12}else{if(n+3>=r)break;t[n++>>>0]=240|i>>18,t[n++>>>0]=128|i>>12&63}t[n++>>>0]=128|i>>6&63}t[n++>>>0]=128|63&i}}return t[n>>>0]=0,n-a}function N(e){for(var t=0,n=0;n=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t}function G(e){D=e,s.HEAP8=F=new Int8Array(e),s.HEAP16=new Int16Array(e),s.HEAP32=I=new Int32Array(e),s.HEAPU8=U=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAPU32=W=new Uint32Array(e),s.HEAPF32=new Float32Array(e),s.HEAPF64=j=new Float64Array(e)}O&&(D=s.buffer);var q=s.INITIAL_MEMORY||16777216;if(O)P=s.wasmMemory,D=s.buffer;else if(s.wasmMemory)P=s.wasmMemory;else if(!((P=new WebAssembly.Memory({initial:q/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw x("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"),_&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");P&&(D=P.buffer),q=D.byteLength,G(D);var $,V=[],J=[],Q=[];function X(){var e=s.preRun.shift();V.unshift(e)}var K,Z=0,ee=null,te=null;function ne(e){throw O?postMessage({cmd:"onAbort",arg:e}):s.onAbort&&s.onAbort(e),x(e="Aborted("+e+")"),H=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),c(e),e}function re(){return K.startsWith("data:application/octet-stream;base64,")}function ae(){var e=K;try{if(e==K&&M)return new Uint8Array(M);if(p)return p(e);throw"both async and sync fetching of the wasm failed"}catch(e){ne(e)}}K="ort-wasm-threaded.wasm",re()||(K=T(K));var oe={};function ie(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function se(e){(e=fe.La[e])||ne(),fe.Xa(e)}function ue(e){var t=fe.lb();if(!t)return 6;fe.Ra.push(t),fe.La[e.Ka]=t,t.Ka=e.Ka;var n={cmd:"run",start_routine:e.pb,arg:e.ib,pthread_ptr:e.Ka};return t.Qa=()=>{n.time=performance.now(),t.postMessage(n,e.vb)},t.loaded&&(t.Qa(),delete t.Qa),0}function ce(e){if(O)return He(1,1,e);C||(fe.qb(),s.onExit&&s.onExit(e),H=!0),v(e,new ie(e))}function le(e,t){if(!t&&O)throw de(e),"unwind";ce(e)}var fe={Oa:[],Ra:[],$a:[],La:{},Ua:function(){O&&fe.mb()},xb:function(){},mb:function(){fe.receiveObjectTransfer=fe.ob,fe.threadInitTLS=fe.Za,fe.setExitStatus=fe.Ya,C=!1},Ya:function(){},qb:function(){for(var e of Object.values(fe.La))fe.Xa(e);for(e of fe.Oa)e.terminate();fe.Oa=[]},Xa:function(e){var t=e.Ka;delete fe.La[t],fe.Oa.push(e),fe.Ra.splice(fe.Ra.indexOf(e),1),e.Ka=0,ct(t)},ob:function(){},Za:function(){fe.$a.forEach((e=>e()))},nb:function(e,t){e.onmessage=n=>{var r=(n=n.data).cmd;if(e.Ka&&(fe.kb=e.Ka),n.targetThread&&n.targetThread!=rt()){var a=fe.La[n.yb];a?a.postMessage(n,n.transferList):x(\'Internal error! Worker sent a message "\'+r+\'" to target pthread \'+n.targetThread+", but that thread no longer exists!")}else"processProxyingQueue"===r?De(n.queue):"spawnThread"===r?ue(n):"cleanupThread"===r?se(n.thread):"killThread"===r?(n=n.thread,r=fe.La[n],delete fe.La[n],r.terminate(),ct(n),fe.Ra.splice(fe.Ra.indexOf(r),1),r.Ka=0):"cancelThread"===r?fe.La[n.thread].postMessage({cmd:"cancel"}):"loaded"===r?(e.loaded=!0,t&&t(e),e.Qa&&(e.Qa(),delete e.Qa)):"print"===r?R("Thread "+n.threadId+": "+n.text):"printErr"===r?x("Thread "+n.threadId+": "+n.text):"alert"===r?alert("Thread "+n.threadId+": "+n.text):"setimmediate"===n.target?e.postMessage(n):"onAbort"===r?s.onAbort&&s.onAbort(n.arg):r&&x("worker sent an unknown command "+r);fe.kb=void 0},e.onerror=e=>{throw x("worker sent an error! "+e.filename+":"+e.lineno+": "+e.message),e},_&&(e.on("message",(function(t){e.onmessage({data:t})})),e.on("error",(function(t){e.onerror(t)})),e.on("detachedExit",(function(){}))),e.postMessage({cmd:"load",urlOrBlob:s.mainScriptUrlOrBlob||_scriptDir,wasmMemory:P,wasmModule:k})},hb:function(){var e=T("ort-wasm-threaded.worker.js");fe.Oa.push(new Worker(e))},lb:function(){return 0==fe.Oa.length&&(fe.hb(),fe.nb(fe.Oa[0])),fe.Oa.pop()}};function pe(e){for(;0>2>>>0];e=a()[e+48>>2>>>0],ft(t,t-e),dt(t)};var me,ge,he=[];function ye(e){this.Pa=e-24,this.gb=function(e){o()[this.Pa+4>>2>>>0]=e},this.cb=function(e){o()[this.Pa+8>>2>>>0]=e},this.eb=function(){a()[this.Pa>>2>>>0]=0},this.bb=function(){t()[this.Pa+12>>0>>>0]=0},this.fb=function(){t()[this.Pa+13>>0>>>0]=0},this.Ua=function(e,t){this.ab(),this.gb(e),this.cb(t),this.eb(),this.bb(),this.fb()},this.ab=function(){o()[this.Pa+16>>2>>>0]=0}}function ve(e,t,n,r){return O?He(3,1,e,t,n,r):be(e,t,n,r)}function be(e,t,n,r){if("undefined"==typeof SharedArrayBuffer)return x("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];return O&&0===a.length?ve(e,t,n,r):(e={pb:n,Ka:e,ib:r,vb:a},O?(e.wb="spawnThread",postMessage(e,a),0):ue(e))}function we(e,t,n){return O?He(4,1,e,t,n):0}function _e(e,t){if(O)return He(5,1,e,t)}function Oe(e,t){if(O)return He(6,1,e,t)}function Se(e,t,n){if(O)return He(7,1,e,t,n)}function Te(e,t,n){return O?He(8,1,e,t,n):0}function Ae(e,t){if(O)return He(9,1,e,t)}function Ee(e,t,n){if(O)return He(10,1,e,t,n)}function Me(e,t,n,r){if(O)return He(11,1,e,t,n,r)}function Re(e,t,n,r){if(O)return He(12,1,e,t,n,r)}function xe(e,t,n,r){if(O)return He(13,1,e,t,n,r)}function Ce(e){if(O)return He(14,1,e)}function Pe(e,t){if(O)return He(15,1,e,t)}function ke(e,t,n){if(O)return He(16,1,e,t,n)}function De(e){Atomics.store(a(),e>>2,1),rt()&&ut(e),Atomics.compareExchange(a(),e>>2,1,0)}function Fe(e){return o()[e>>>2]+4294967296*a()[e+4>>>2]}function Ue(e,t,n,r,a,o){return O?He(17,1,e,t,n,r,a,o):-52}function Ie(e,t,n,r,a,o){if(O)return He(18,1,e,t,n,r,a,o)}function We(e){var n=N(e)+1,r=at(n);return r&&B(e,t(),r,n),r}function je(e,t,n){function r(e){return(e=e.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?e[1]:"GMT"}if(O)return He(19,1,e,t,n);var i=(new Date).getFullYear(),s=new Date(i,0,1),u=new Date(i,6,1);i=s.getTimezoneOffset();var c=u.getTimezoneOffset(),l=Math.max(i,c);a()[e>>2>>>0]=60*l,a()[t>>2>>>0]=Number(i!=c),e=r(s),t=r(u),e=We(e),t=We(t),c>2>>>0]=e,o()[n+4>>2>>>0]=t):(o()[n>>2>>>0]=t,o()[n+4>>2>>>0]=e)}function He(e,t){var n=arguments.length-2,r=arguments;return function(e){var t=pt();return e=e(),dt(t),e}((()=>{for(var a=mt(8*n),o=a>>3,s=0;s>>0]=u}return st(e,n,a,t)}))}s.invokeEntryPoint=function(e,t){var n=he[e];n||(e>=he.length&&(he.length=e+1),he[e]=n=$.get(e)),e=n(t),C?fe.Ya(e):lt(e)},s.executeNotifiedProxyingQueue=De,ge=_?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:O?()=>performance.now()-s.__performance_now_clock_drift:()=>performance.now();var Le,Ye=[],ze={};function Be(){if(!Le){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",_:y||"./this.program"};for(e in ze)void 0===ze[e]?delete t[e]:t[e]=ze[e];var n=[];for(e in t)n.push(e+"="+t[e]);Le=n}return Le}function Ne(e,n){if(O)return He(20,1,e,n);var r=0;return Be().forEach((function(a,i){var s=n+r;for(i=o()[e+4*i>>2>>>0]=s,s=0;s>0>>>0]=a.charCodeAt(s);t()[i>>0>>>0]=0,r+=a.length+1})),0}function Ge(e,t){if(O)return He(21,1,e,t);var n=Be();o()[e>>2>>>0]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),o()[t>>2>>>0]=r,0}function qe(e){return O?He(22,1,e):52}function $e(e,t,n,r){return O?He(23,1,e,t,n,r):52}function Ve(e,t,n,r,a){return O?He(24,1,e,t,n,r,a):70}var Je=[null,[],[]];function Qe(e,t,n,a){if(O)return He(25,1,e,t,n,a);for(var i=0,s=0;s>2>>>0],c=o()[t+4>>2>>>0];t+=8;for(var l=0;l>>0],p=Je[e];0===f||10===f?((1===e?R:x)(Y(p,0)),p.length=0):p.push(f)}i+=c}return o()[a>>2>>>0]=i,0}function Xe(e){return 0==e%4&&(0!=e%100||0==e%400)}var Ke=[31,29,31,30,31,30,31,31,30,31,30,31],Ze=[31,28,31,30,31,30,31,31,30,31,30,31];function et(e,n,r,o){function i(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.lengthe?-1:0r-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 n=new Date(e.getFullYear()+1,0,4),t=c(new Date(e.getFullYear(),0,4)),n=c(n),0>=u(t,e)?0>=u(n,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var f=a()[o+40>>2>>>0];for(var p in o={tb:a()[o>>2>>>0],sb:a()[o+4>>2>>>0],Sa:a()[o+8>>2>>>0],Va:a()[o+12>>2>>>0],Ta:a()[o+16>>2>>>0],Na:a()[o+20>>2>>>0],Ja:a()[o+24>>2>>>0],Ma:a()[o+28>>2>>>0],zb:a()[o+32>>2>>>0],rb:a()[o+36>>2>>>0],ub:f?z(f):""},r=z(r),f={"%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"})r=r.replace(new RegExp(p,"g"),f[p]);var d="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),m="January February March April May June July August September October November December".split(" ");for(p in f={"%a":function(e){return d[e.Ja].substring(0,3)},"%A":function(e){return d[e.Ja]},"%b":function(e){return m[e.Ta].substring(0,3)},"%B":function(e){return m[e.Ta]},"%C":function(e){return s((e.Na+1900)/100|0,2)},"%d":function(e){return s(e.Va,2)},"%e":function(e){return i(e.Va,2," ")},"%g":function(e){return l(e).toString().substring(2)},"%G":function(e){return l(e)},"%H":function(e){return s(e.Sa,2)},"%I":function(e){return 0==(e=e.Sa)?e=12:12e.Sa?"AM":"PM"},"%S":function(e){return s(e.tb,2)},"%t":function(){return"\\t"},"%u":function(e){return e.Ja||7},"%U":function(e){return s(Math.floor((e.Ma+7-e.Ja)/7),2)},"%V":function(e){var t=Math.floor((e.Ma+7-(e.Ja+6)%7)/7);if(2>=(e.Ja+371-e.Ma-2)%7&&t++,t)53==t&&(4==(n=(e.Ja+371-e.Ma)%7)||3==n&&Xe(e.Na)||(t=1));else{t=52;var n=(e.Ja+7-e.Ma-1)%7;(4==n||5==n&&Xe(e.Na%400-1))&&t++}return s(t,2)},"%w":function(e){return e.Ja},"%W":function(e){return s(Math.floor((e.Ma+7-(e.Ja+6)%7)/7),2)},"%y":function(e){return(e.Na+1900).toString().substring(2)},"%Y":function(e){return e.Na+1900},"%z":function(e){var t=0<=(e=e.rb);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.ub},"%%":function(){return"%"}},r=r.replace(/%%/g,"\\0\\0"),f)r.includes(p)&&(r=r.replace(new RegExp(p,"g"),f[p](o)));return p=function(e){var t=Array(N(e)+1);return B(e,t,0,t.length),t}(r=r.replace(/\\0\\0/g,"%")),p.length>n?0:(function(e,n){t().set(e,n>>>0)}(p,e),p.length-1)}fe.Ua();var tt=[null,ce,de,ve,we,_e,Oe,Se,Te,Ae,Ee,Me,Re,xe,Ce,Pe,ke,Ue,Ie,je,Ne,Ge,qe,$e,Ve,Qe],nt={b:function(e){return at(e+24)+24},c:function(e,t,n){throw new ye(e).Ua(t,n),e},L:function(e){ot(e,!w,1,!b),fe.Za()},l:function(e){O?postMessage({cmd:"cleanupThread",thread:e}):se(e)},D:be,i:we,R:_e,z:Oe,B:Se,T:Te,P:Ae,I:Ee,O:Me,p:Re,A:xe,x:Ce,Q:Pe,y:ke,r:function(){},j:function(){ne("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},s:function(){ne("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},q:function(){return Date.now()},E:function(){return 2097152},V:function(){return!0},F:function(e,t,n,r){if(e==t)setTimeout((()=>De(r)));else if(O)postMessage({targetThread:e,cmd:"processProxyingQueue",queue:r});else{if(!(e=fe.La[e]))return;e.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},K:function(){return-1},W:function(e,t){e=new Date(1e3*Fe(e)),a()[t>>2>>>0]=e.getUTCSeconds(),a()[t+4>>2>>>0]=e.getUTCMinutes(),a()[t+8>>2>>>0]=e.getUTCHours(),a()[t+12>>2>>>0]=e.getUTCDate(),a()[t+16>>2>>>0]=e.getUTCMonth(),a()[t+20>>2>>>0]=e.getUTCFullYear()-1900,a()[t+24>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,a()[t+28>>2>>>0]=e},X:function(e,t){e=new Date(1e3*Fe(e)),a()[t>>2>>>0]=e.getSeconds(),a()[t+4>>2>>>0]=e.getMinutes(),a()[t+8>>2>>>0]=e.getHours(),a()[t+12>>2>>>0]=e.getDate(),a()[t+16>>2>>>0]=e.getMonth(),a()[t+20>>2>>>0]=e.getFullYear()-1900,a()[t+24>>2>>>0]=e.getDay();var n=new Date(e.getFullYear(),0,1),r=(e.getTime()-n.getTime())/864e5|0;a()[t+28>>2>>>0]=r,a()[t+36>>2>>>0]=-60*e.getTimezoneOffset(),r=new Date(e.getFullYear(),6,1).getTimezoneOffset(),e=0|(r!=(n=n.getTimezoneOffset())&&e.getTimezoneOffset()==Math.min(n,r)),a()[t+32>>2>>>0]=e},Y:function(e){var t=new Date(a()[e+20>>2>>>0]+1900,a()[e+16>>2>>>0],a()[e+12>>2>>>0],a()[e+8>>2>>>0],a()[e+4>>2>>>0],a()[e>>2>>>0],0),n=a()[e+32>>2>>>0],r=t.getTimezoneOffset(),o=new Date(t.getFullYear(),0,1),i=new Date(t.getFullYear(),6,1).getTimezoneOffset(),s=o.getTimezoneOffset(),u=Math.min(s,i);return 0>n?a()[e+32>>2>>>0]=Number(i!=s&&u==r):0>2>>>0]=t.getDay(),n=(t.getTime()-o.getTime())/864e5|0,a()[e+28>>2>>>0]=n,a()[e>>2>>>0]=t.getSeconds(),a()[e+4>>2>>>0]=t.getMinutes(),a()[e+8>>2>>>0]=t.getHours(),a()[e+12>>2>>>0]=t.getDate(),a()[e+16>>2>>>0]=t.getMonth(),t.getTime()/1e3|0},G:Ue,H:Ie,Z:function e(t,n,r){e.jb||(e.jb=!0,je(t,n,r))},d:function(){ne("")},m:function(){if(!_&&!w){var e="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";me||(me={}),me[e]||(me[e]=1,_&&(e="warning: "+e),x(e))}},w:function(){return 4294901760},f:ge,S:function(e,t,n){r().copyWithin(e>>>0,t>>>0,t+n>>>0)},g:function(){return _?n(993).cpus().length:navigator.hardwareConcurrency},J:function(e,t,n){Ye.length=t,n>>=3;for(var r=0;r>>0];return(0>e?oe[-e-1]:tt[e]).apply(null,Ye)},v:function(e){var t=r().length;if((e>>>=0)<=t||4294901760=n;n*=2){var a=t*(1+.2/n);a=Math.min(a,e+100663296);var o=Math;a=Math.max(e,a),o=o.min.call(o,4294901760,a+(65536-a%65536)%65536);e:{try{P.grow(o-D.byteLength+65535>>>16),G(P.buffer);var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},U:function(){throw"unwind"},M:Ne,N:Ge,k:le,h:qe,o:$e,t:Ve,n:Qe,u:function e(r,a){e.Wa||(e.Wa=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}if(_)try{var t=n(760);return()=>t.randomBytes(1)[0]}catch(e){}return()=>ne("randomDevice")}());for(var o=0;o>0>>>0]=e.Wa();return 0},a:P||s.wasmMemory,C:et,e:function(e,t,n,r){return et(e,t,n,r)}};!function(){function e(e,t){s.asm=e.exports,fe.$a.push(s.asm.wa),$=s.asm.za,J.unshift(s.asm._),k=t,O||(Z--,s.monitorRunDependencies&&s.monitorRunDependencies(Z),0==Z&&(null!==ee&&(clearInterval(ee),ee=null),te&&(e=te,te=null,e())))}function t(t){e(t.instance,t.module)}function n(e){return function(){if(!M&&(b||w)){if("function"==typeof fetch&&!K.startsWith("file://"))return fetch(K,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at \'"+K+"\'";return e.arrayBuffer()})).catch((function(){return ae()}));if(f)return new Promise((function(e,t){f(K,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ae()}))}().then((function(e){return WebAssembly.instantiate(e,r)})).then((function(e){return e})).then(e,(function(e){x("failed to asynchronously prepare wasm: "+e),ne(e)}))}var r={a:nt};if(O||(Z++,s.monitorRunDependencies&&s.monitorRunDependencies(Z)),s.instantiateWasm)try{return s.instantiateWasm(r,e)}catch(e){return x("Module.instantiateWasm callback failed with error: "+e),!1}(M||"function"!=typeof WebAssembly.instantiateStreaming||re()||K.startsWith("file://")||_||"function"!=typeof fetch?n(t):fetch(K,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,r).then(t,(function(e){return x("wasm streaming compile failed: "+e),x("falling back to ArrayBuffer instantiation"),n(t)}))}))).catch(c)}(),s.___wasm_call_ctors=function(){return(s.___wasm_call_ctors=s.asm._).apply(null,arguments)},s._OrtInit=function(){return(s._OrtInit=s.asm.$).apply(null,arguments)},s._OrtCreateSessionOptions=function(){return(s._OrtCreateSessionOptions=s.asm.aa).apply(null,arguments)},s._OrtAppendExecutionProvider=function(){return(s._OrtAppendExecutionProvider=s.asm.ba).apply(null,arguments)},s._OrtAddSessionConfigEntry=function(){return(s._OrtAddSessionConfigEntry=s.asm.ca).apply(null,arguments)},s._OrtReleaseSessionOptions=function(){return(s._OrtReleaseSessionOptions=s.asm.da).apply(null,arguments)},s._OrtCreateSession=function(){return(s._OrtCreateSession=s.asm.ea).apply(null,arguments)},s._OrtReleaseSession=function(){return(s._OrtReleaseSession=s.asm.fa).apply(null,arguments)},s._OrtGetInputCount=function(){return(s._OrtGetInputCount=s.asm.ga).apply(null,arguments)},s._OrtGetOutputCount=function(){return(s._OrtGetOutputCount=s.asm.ha).apply(null,arguments)},s._OrtGetInputName=function(){return(s._OrtGetInputName=s.asm.ia).apply(null,arguments)},s._OrtGetOutputName=function(){return(s._OrtGetOutputName=s.asm.ja).apply(null,arguments)},s._OrtFree=function(){return(s._OrtFree=s.asm.ka).apply(null,arguments)},s._OrtCreateTensor=function(){return(s._OrtCreateTensor=s.asm.la).apply(null,arguments)},s._OrtGetTensorData=function(){return(s._OrtGetTensorData=s.asm.ma).apply(null,arguments)},s._OrtReleaseTensor=function(){return(s._OrtReleaseTensor=s.asm.na).apply(null,arguments)},s._OrtCreateRunOptions=function(){return(s._OrtCreateRunOptions=s.asm.oa).apply(null,arguments)},s._OrtAddRunConfigEntry=function(){return(s._OrtAddRunConfigEntry=s.asm.pa).apply(null,arguments)},s._OrtReleaseRunOptions=function(){return(s._OrtReleaseRunOptions=s.asm.qa).apply(null,arguments)},s._OrtRun=function(){return(s._OrtRun=s.asm.ra).apply(null,arguments)},s._OrtEndProfiling=function(){return(s._OrtEndProfiling=s.asm.sa).apply(null,arguments)};var rt=s._pthread_self=function(){return(rt=s._pthread_self=s.asm.ta).apply(null,arguments)},at=s._malloc=function(){return(at=s._malloc=s.asm.ua).apply(null,arguments)};s._free=function(){return(s._free=s.asm.va).apply(null,arguments)},s.__emscripten_tls_init=function(){return(s.__emscripten_tls_init=s.asm.wa).apply(null,arguments)};var ot=s.__emscripten_thread_init=function(){return(ot=s.__emscripten_thread_init=s.asm.xa).apply(null,arguments)};s.__emscripten_thread_crashed=function(){return(s.__emscripten_thread_crashed=s.asm.ya).apply(null,arguments)};var it,st=s._emscripten_run_in_main_runtime_thread_js=function(){return(st=s._emscripten_run_in_main_runtime_thread_js=s.asm.Aa).apply(null,arguments)},ut=s.__emscripten_proxy_execute_task_queue=function(){return(ut=s.__emscripten_proxy_execute_task_queue=s.asm.Ba).apply(null,arguments)},ct=s.__emscripten_thread_free_data=function(){return(ct=s.__emscripten_thread_free_data=s.asm.Ca).apply(null,arguments)},lt=s.__emscripten_thread_exit=function(){return(lt=s.__emscripten_thread_exit=s.asm.Da).apply(null,arguments)},ft=s._emscripten_stack_set_limits=function(){return(ft=s._emscripten_stack_set_limits=s.asm.Ea).apply(null,arguments)},pt=s.stackSave=function(){return(pt=s.stackSave=s.asm.Fa).apply(null,arguments)},dt=s.stackRestore=function(){return(dt=s.stackRestore=s.asm.Ga).apply(null,arguments)},mt=s.stackAlloc=function(){return(mt=s.stackAlloc=s.asm.Ha).apply(null,arguments)};function gt(){function e(){if(!it&&(it=!0,s.calledRun=!0,!H)&&(O||pe(J),u(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),!O)){if(s.postRun)for("function"==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;){var e=s.postRun.shift();Q.unshift(e)}pe(Q)}}if(!(0{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){var t,r,a;e=e||{},t||(t=void 0!==e?e:{}),t.ready=new Promise((function(e,t){r=e,a=t}));var o,i,s,u,c,l,f=Object.assign({},t),p="./this.program",d=(e,t)=>{throw t},m="object"==typeof window,g="function"==typeof importScripts,h="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,y="";h?(y=g?n(908).dirname(y)+"/":"//",l=()=>{c||(u=n(384),c=n(908))},o=function(e,t){return l(),e=c.normalize(e),u.readFileSync(e,t?void 0:"utf8")},s=e=>((e=o(e,!0)).buffer||(e=new Uint8Array(e)),e),i=(e,t,n)=>{l(),e=c.normalize(e),u.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},1{if(_)throw process.exitCode=e,t;t instanceof $||w("exiting due to exception: "+t),process.exit(e)},t.inspect=function(){return"[Emscripten Module object]"}):(m||g)&&(g?y=self.location.href:"undefined"!=typeof document&&document.currentScript&&(y=document.currentScript.src),_scriptDir&&(y=_scriptDir),y=0!==y.indexOf("blob:")?y.substr(0,y.replace(/[?#].*/,"").lastIndexOf("/")+1):"",o=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},g&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),i=(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 v,b=t.print||console.log.bind(console),w=t.printErr||console.warn.bind(console);Object.assign(t,f),f=null,t.thisProgram&&(p=t.thisProgram),t.quit&&(d=t.quit),t.wasmBinary&&(v=t.wasmBinary);var _=t.noExitRuntime||!0;"object"!=typeof WebAssembly&&B("no native wasm support detected");var O,S,T,A,E,M,R=!1,x="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function C(e,t,n){var r=(t>>>=0)+n;for(n=t;e[n]&&!(n>=r);)++n;if(16(a=224==(240&a)?(15&a)<<12|o<<6|i:(7&a)<<18|o<<12|i<<6|63&e[t++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function P(e,t){return(e>>>=0)?C(A,e,t):""}function k(e,t,n,r){if(!(0>>=0;r=n+r-1;for(var o=0;o=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++o)),127>=i){if(n>=r)break;t[n++>>>0]=i}else{if(2047>=i){if(n+1>=r)break;t[n++>>>0]=192|i>>6}else{if(65535>=i){if(n+2>=r)break;t[n++>>>0]=224|i>>12}else{if(n+3>=r)break;t[n++>>>0]=240|i>>18,t[n++>>>0]=128|i>>12&63}t[n++>>>0]=128|i>>6&63}t[n++>>>0]=128|63&i}}return t[n>>>0]=0,n-a}function D(e){for(var t=0,n=0;n=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t}function F(){var e=O.buffer;S=e,t.HEAP8=T=new Int8Array(e),t.HEAP16=new Int16Array(e),t.HEAP32=E=new Int32Array(e),t.HEAPU8=A=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=M=new Uint32Array(e),t.HEAPF32=new Float32Array(e),t.HEAPF64=new Float64Array(e)}var U=[],I=[],W=[];function j(){var e=t.preRun.shift();U.unshift(e)}var H,L=0,Y=null,z=null;function B(e){throw t.onAbort&&t.onAbort(e),w(e="Aborted("+e+")"),R=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),a(e),e}function N(){return H.startsWith("data:application/octet-stream;base64,")}if(H="ort-wasm.wasm",!N()){var G=H;H=t.locateFile?t.locateFile(G,y):y+G}function q(){var e=H;try{if(e==H&&v)return new Uint8Array(v);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}catch(e){B(e)}}function $(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function V(e){for(;0>2>>>0]=e},this.Ba=function(e){M[this.sa+8>>2>>>0]=e},this.Ga=function(){E[this.sa>>2>>>0]=0},this.Aa=function(){T[this.sa+12>>0>>>0]=0},this.Ha=function(){T[this.sa+13>>0>>>0]=0},this.ya=function(e,t){this.za(),this.Ia(e),this.Ba(t),this.Ga(),this.Aa(),this.Ha()},this.za=function(){M[this.sa+16>>2>>>0]=0}}function Q(e){var t=D(e)+1,n=ie(t);return n&&k(e,T,n,t),n}var X={};function K(){if(!Z){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",_:p||"./this.program"};for(e in X)void 0===X[e]?delete t[e]:t[e]=X[e];var n=[];for(e in t)n.push(e+"="+t[e]);Z=n}return Z}var Z,ee=[null,[],[]];function te(e){return 0==e%4&&(0!=e%100||0==e%400)}var ne=[31,29,31,30,31,30,31,31,30,31,30,31],re=[31,28,31,30,31,30,31,31,30,31,30,31];function ae(e,t,n,r){function a(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.lengthe?-1:0r-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 n=new Date(e.getFullYear()+1,0,4),t=s(new Date(e.getFullYear(),0,4)),n=s(n),0>=i(t,e)?0>=i(n,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var c=E[r+40>>2>>>0];for(var l in r={Ea:E[r>>2>>>0],Da:E[r+4>>2>>>0],ta:E[r+8>>2>>>0],va:E[r+12>>2>>>0],ua:E[r+16>>2>>>0],ra:E[r+20>>2>>>0],la:E[r+24>>2>>>0],qa:E[r+28>>2>>>0],Ja:E[r+32>>2>>>0],Ca:E[r+36>>2>>>0],Fa:c?P(c):""},n=P(n),c={"%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(l,"g"),c[l]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),p="January February March April May June July August September October November December".split(" ");for(l in c={"%a":function(e){return f[e.la].substring(0,3)},"%A":function(e){return f[e.la]},"%b":function(e){return p[e.ua].substring(0,3)},"%B":function(e){return p[e.ua]},"%C":function(e){return o((e.ra+1900)/100|0,2)},"%d":function(e){return o(e.va,2)},"%e":function(e){return a(e.va,2," ")},"%g":function(e){return u(e).toString().substring(2)},"%G":function(e){return u(e)},"%H":function(e){return o(e.ta,2)},"%I":function(e){return 0==(e=e.ta)?e=12:12e.ta?"AM":"PM"},"%S":function(e){return o(e.Ea,2)},"%t":function(){return"\\t"},"%u":function(e){return e.la||7},"%U":function(e){return o(Math.floor((e.qa+7-e.la)/7),2)},"%V":function(e){var t=Math.floor((e.qa+7-(e.la+6)%7)/7);if(2>=(e.la+371-e.qa-2)%7&&t++,t)53==t&&(4==(n=(e.la+371-e.qa)%7)||3==n&&te(e.ra)||(t=1));else{t=52;var n=(e.la+7-e.qa-1)%7;(4==n||5==n&&te(e.ra%400-1))&&t++}return o(t,2)},"%w":function(e){return e.la},"%W":function(e){return o(Math.floor((e.qa+7-(e.la+6)%7)/7),2)},"%y":function(e){return(e.ra+1900).toString().substring(2)},"%Y":function(e){return e.ra+1900},"%z":function(e){var t=0<=(e=e.Ca);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.Fa},"%%":function(){return"%"}},n=n.replace(/%%/g,"\\0\\0"),c)n.includes(l)&&(n=n.replace(new RegExp(l,"g"),c[l](r)));return l=function(e){var t=Array(D(e)+1);return k(e,t,0,t.length),t}(n=n.replace(/\\0\\0/g,"%")),l.length>t?0:(T.set(l,e>>>0),l.length-1)}var oe={a:function(e){return ie(e+24)+24},b:function(e,t,n){throw new J(e).ya(t,n),e},g:function(){return 0},I:function(){},w:function(){},y:function(){},K:function(){return 0},G:function(){},C:function(){},F:function(){},k:function(){},x:function(){},u:function(){},H:function(){},v:function(){},n:function(){},p:function(){B("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},o:function(){B("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},l:function(){return Date.now()},L:function(){return!0},M:function(e,t){e=new Date(1e3*(M[e>>>2]+4294967296*E[e+4>>>2])),E[t>>2>>>0]=e.getUTCSeconds(),E[t+4>>2>>>0]=e.getUTCMinutes(),E[t+8>>2>>>0]=e.getUTCHours(),E[t+12>>2>>>0]=e.getUTCDate(),E[t+16>>2>>>0]=e.getUTCMonth(),E[t+20>>2>>>0]=e.getUTCFullYear()-1900,E[t+24>>2>>>0]=e.getUTCDay(),E[t+28>>2>>>0]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},N:function(e,t){e=new Date(1e3*(M[e>>>2]+4294967296*E[e+4>>>2])),E[t>>2>>>0]=e.getSeconds(),E[t+4>>2>>>0]=e.getMinutes(),E[t+8>>2>>>0]=e.getHours(),E[t+12>>2>>>0]=e.getDate(),E[t+16>>2>>>0]=e.getMonth(),E[t+20>>2>>>0]=e.getFullYear()-1900,E[t+24>>2>>>0]=e.getDay();var n=new Date(e.getFullYear(),0,1);E[t+28>>2>>>0]=(e.getTime()-n.getTime())/864e5|0,E[t+36>>2>>>0]=-60*e.getTimezoneOffset();var r=new Date(e.getFullYear(),6,1).getTimezoneOffset();n=n.getTimezoneOffset(),E[t+32>>2>>>0]=0|(r!=n&&e.getTimezoneOffset()==Math.min(n,r))},O:function(e){var t=new Date(E[e+20>>2>>>0]+1900,E[e+16>>2>>>0],E[e+12>>2>>>0],E[e+8>>2>>>0],E[e+4>>2>>>0],E[e>>2>>>0],0),n=E[e+32>>2>>>0],r=t.getTimezoneOffset(),a=new Date(t.getFullYear(),0,1),o=new Date(t.getFullYear(),6,1).getTimezoneOffset(),i=a.getTimezoneOffset(),s=Math.min(i,o);return 0>n?E[e+32>>2>>>0]=Number(o!=i&&s==r):0>2>>>0]=t.getDay(),E[e+28>>2>>>0]=(t.getTime()-a.getTime())/864e5|0,E[e>>2>>>0]=t.getSeconds(),E[e+4>>2>>>0]=t.getMinutes(),E[e+8>>2>>>0]=t.getHours(),E[e+12>>2>>>0]=t.getDate(),E[e+16>>2>>>0]=t.getMonth(),t.getTime()/1e3|0},z:function(){return-52},B:function(){},m:function e(t,n,r){e.xa||(e.xa=!0,function(e,t,n){function r(e){return(e=e.toTimeString().match(/\\(([A-Za-z ]+)\\)$/))?e[1]:"GMT"}var a=(new Date).getFullYear(),o=new Date(a,0,1),i=new Date(a,6,1);a=o.getTimezoneOffset();var s=i.getTimezoneOffset();E[e>>2>>>0]=60*Math.max(a,s),E[t>>2>>>0]=Number(a!=s),e=r(o),t=r(i),e=Q(e),t=Q(t),s>2>>>0]=e,M[n+4>>2>>>0]=t):(M[n>>2>>>0]=t,M[n+4>>2>>>0]=e)}(t,n,r))},d:function(){B("")},t:function(){return 4294901760},h:h?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.now(),J:function(e,t,n){A.copyWithin(e>>>0,t>>>0,t+n>>>0)},f:function(e){var t=A.length;if(4294901760<(e>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var a=Math;r=Math.max(e,r),a=a.min.call(a,4294901760,r+(65536-r%65536)%65536);e:{try{O.grow(a-S.byteLength+65535>>>16),F();var o=1;break e}catch(e){}o=void 0}if(o)return!0}return!1},D:function(e,t){var n=0;return K().forEach((function(r,a){var o=t+n;for(a=M[e+4*a>>2>>>0]=o,o=0;o>0>>>0]=r.charCodeAt(o);T[a>>0>>>0]=0,n+=r.length+1})),0},E:function(e,t){var n=K();M[e>>2>>>0]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),M[t>>2>>>0]=r,0},r:function(e){_||(t.onExit&&t.onExit(e),R=!0),d(e,new $(e))},e:function(){return 52},j:function(){return 52},q:function(){return 70},i:function(e,t,n,r){for(var a=0,o=0;o>2>>>0],s=M[t+4>>2>>>0];t+=8;for(var u=0;u>>0],l=ee[e];0===c||10===c?((1===e?b:w)(C(l,0)),l.length=0):l.push(c)}a+=s}return M[r>>2>>>0]=a,0},s:function e(t,r){e.wa||(e.wa=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}if(h)try{var t=n(760);return()=>t.randomBytes(1)[0]}catch(e){}return()=>B("randomDevice")}());for(var a=0;a>0>>>0]=e.wa();return 0},A:ae,c:function(e,t,n,r){return ae(e,t,n,r)}};!function(){function e(e){t.asm=e.exports,O=t.asm.P,F(),I.unshift(t.asm.Q),L--,t.monitorRunDependencies&&t.monitorRunDependencies(L),0==L&&(null!==Y&&(clearInterval(Y),Y=null),z&&(e=z,z=null,e()))}function n(t){e(t.instance)}function r(e){return function(){if(!v&&(m||g)){if("function"==typeof fetch&&!H.startsWith("file://"))return fetch(H,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at \'"+H+"\'";return e.arrayBuffer()})).catch((function(){return q()}));if(i)return new Promise((function(e,t){i(H,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return q()}))}().then((function(e){return WebAssembly.instantiate(e,o)})).then((function(e){return e})).then(e,(function(e){w("failed to asynchronously prepare wasm: "+e),B(e)}))}var o={a:oe};if(L++,t.monitorRunDependencies&&t.monitorRunDependencies(L),t.instantiateWasm)try{return t.instantiateWasm(o,e)}catch(e){return w("Module.instantiateWasm callback failed with error: "+e),!1}(v||"function"!=typeof WebAssembly.instantiateStreaming||N()||H.startsWith("file://")||h||"function"!=typeof fetch?r(n):fetch(H,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,o).then(n,(function(e){return w("wasm streaming compile failed: "+e),w("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(a)}(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.Q).apply(null,arguments)},t._OrtInit=function(){return(t._OrtInit=t.asm.R).apply(null,arguments)},t._OrtCreateSessionOptions=function(){return(t._OrtCreateSessionOptions=t.asm.S).apply(null,arguments)},t._OrtAppendExecutionProvider=function(){return(t._OrtAppendExecutionProvider=t.asm.T).apply(null,arguments)},t._OrtAddSessionConfigEntry=function(){return(t._OrtAddSessionConfigEntry=t.asm.U).apply(null,arguments)},t._OrtReleaseSessionOptions=function(){return(t._OrtReleaseSessionOptions=t.asm.V).apply(null,arguments)},t._OrtCreateSession=function(){return(t._OrtCreateSession=t.asm.W).apply(null,arguments)},t._OrtReleaseSession=function(){return(t._OrtReleaseSession=t.asm.X).apply(null,arguments)},t._OrtGetInputCount=function(){return(t._OrtGetInputCount=t.asm.Y).apply(null,arguments)},t._OrtGetOutputCount=function(){return(t._OrtGetOutputCount=t.asm.Z).apply(null,arguments)},t._OrtGetInputName=function(){return(t._OrtGetInputName=t.asm._).apply(null,arguments)},t._OrtGetOutputName=function(){return(t._OrtGetOutputName=t.asm.$).apply(null,arguments)},t._OrtFree=function(){return(t._OrtFree=t.asm.aa).apply(null,arguments)},t._OrtCreateTensor=function(){return(t._OrtCreateTensor=t.asm.ba).apply(null,arguments)},t._OrtGetTensorData=function(){return(t._OrtGetTensorData=t.asm.ca).apply(null,arguments)},t._OrtReleaseTensor=function(){return(t._OrtReleaseTensor=t.asm.da).apply(null,arguments)},t._OrtCreateRunOptions=function(){return(t._OrtCreateRunOptions=t.asm.ea).apply(null,arguments)},t._OrtAddRunConfigEntry=function(){return(t._OrtAddRunConfigEntry=t.asm.fa).apply(null,arguments)},t._OrtReleaseRunOptions=function(){return(t._OrtReleaseRunOptions=t.asm.ga).apply(null,arguments)},t._OrtRun=function(){return(t._OrtRun=t.asm.ha).apply(null,arguments)},t._OrtEndProfiling=function(){return(t._OrtEndProfiling=t.asm.ia).apply(null,arguments)};var ie=t._malloc=function(){return(ie=t._malloc=t.asm.ja).apply(null,arguments)};t._free=function(){return(t._free=t.asm.ka).apply(null,arguments)};var se,ue=t.stackSave=function(){return(ue=t.stackSave=t.asm.ma).apply(null,arguments)},ce=t.stackRestore=function(){return(ce=t.stackRestore=t.asm.na).apply(null,arguments)},le=t.stackAlloc=function(){return(le=t.stackAlloc=t.asm.oa).apply(null,arguments)};function fe(){function e(){if(!se&&(se=!0,t.calledRun=!0,!R)){if(V(I),r(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;){var e=t.postRun.shift();W.unshift(e)}V(W)}}if(!(0{"use strict";e.exports=\'"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}};\\n\'},760:()=>{},384:()=>{},993:()=>{},908:()=>{},953:()=>{},925:()=>{},449:()=>{}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{"use strict";const e=n(259),t=n(263);self.onmessage=n=>{switch(n.data.type){case"init-wasm":(0,t.initializeWebAssembly)(n.data.in).then((()=>postMessage({type:"init-wasm"})),(e=>postMessage({type:"init-wasm",err:e})));break;case"init-ort":try{const{numThreads:t,loggingLevel:r}=n.data.in;(0,e.initOrt)(t,r),postMessage({type:"init-ort"})}catch(e){postMessage({type:"init-ort",err:e})}break;case"create_allocate":try{const{model:t}=n.data.in,r=(0,e.createSessionAllocate)(t);postMessage({type:"create_allocate",out:r})}catch(e){postMessage({type:"create_allocate",err:e})}break;case"create_finalize":try{const{modeldata:t,options:r}=n.data.in,a=(0,e.createSessionFinalize)(t,r);postMessage({type:"create_finalize",out:a})}catch(e){postMessage({type:"create_finalize",err:e})}break;case"create":try{const{model:t,options:r}=n.data.in,a=(0,e.createSession)(t,r);postMessage({type:"create",out:a})}catch(e){postMessage({type:"create",err:e})}break;case"release":try{const t=n.data.in;(0,e.releaseSession)(t),postMessage({type:"release"})}catch(e){postMessage({type:"release",err:e})}break;case"run":try{const{sessionId:t,inputIndices:r,inputs:a,outputIndices:o,options:i}=n.data.in;(0,e.run)(t,r,a,o,i).then((t=>{postMessage({type:"run",out:t},(0,e.extractTransferableBuffers)(t))}),(e=>{postMessage({type:"run",err:e})}))}catch(e){postMessage({type:"run",err:e})}break;case"end-profiling":try{const t=n.data.in;(0,e.endProfiling)(t),postMessage({type:"end-profiling"})}catch(e){postMessage({type:"end-profiling",err:e})}}}})()})();\n',"Worker",void 0,void 0)}},6614:e=>{"use strict";e.exports=function(e,t,n,r){var o=self||window;try{try{var i;try{i=new o.Blob([e])}catch(t){(i=new(o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder)).append(e),i=i.getBlob()}var a=o.URL||o.webkitURL,s=a.createObjectURL(i),u=new o[t](s,n);return a.revokeObjectURL(s),u}catch(r){return new o[t]("data:application/javascript,".concat(encodeURIComponent(e)),n)}}catch(e){if(!r)throw Error("Inline worker is not supported");return new o[t](r,n)}}},3474:(e,t,n)=>{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){function t(){return D.buffer!=C&&H(D.buffer),R}function r(){return D.buffer!=C&&H(D.buffer),M}function o(){return D.buffer!=C&&H(D.buffer),N}function i(){return D.buffer!=C&&H(D.buffer),F}function a(){return D.buffer!=C&&H(D.buffer),L}var s,u,l;e=e||{},s||(s=void 0!==e?e:{}),s.ready=new Promise((function(e,t){u=e,l=t}));var c,p,d,f,h,g,m=Object.assign({},s),b="./this.program",y=(e,t)=>{throw t},w="object"==typeof window,_="function"==typeof importScripts,v="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,x=s.ENVIRONMENT_IS_PTHREAD||!1,T="";function S(e){return s.locateFile?s.locateFile(e,T):T+e}if(v){let t;T=_?n(908).dirname(T)+"/":"//",g=()=>{h||(f=n(1384),h=n(908))},c=function(e,t){return g(),e=h.normalize(e),f.readFileSync(e,t?void 0:"utf8")},d=e=>((e=c(e,!0)).buffer||(e=new Uint8Array(e)),e),p=(e,t,n)=>{g(),e=h.normalize(e),f.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},1{if(P)throw process.exitCode=e,t;t instanceof ae||$("exiting due to exception: "+t),process.exit(e)},s.inspect=function(){return"[Emscripten Module object]"};try{t=n(9925)}catch(e){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),e}n.g.Worker=t.Worker}else(w||_)&&(_?T=self.location.href:"undefined"!=typeof document&&document.currentScript&&(T=document.currentScript.src),_scriptDir&&(T=_scriptDir),T=0!==T.indexOf("blob:")?T.substr(0,T.replace(/[?#].*/,"").lastIndexOf("/")+1):"",v||(c=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},_&&(d=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),p=(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)}));v&&"undefined"==typeof performance&&(n.g.performance=n(6953).performance);var O=console.log.bind(console),A=console.warn.bind(console);v&&(g(),O=e=>f.writeSync(1,e+"\n"),A=e=>f.writeSync(2,e+"\n"));var E,I=s.print||O,$=s.printErr||A;Object.assign(s,m),m=null,s.thisProgram&&(b=s.thisProgram),s.quit&&(y=s.quit),s.wasmBinary&&(E=s.wasmBinary);var P=s.noExitRuntime||!0;"object"!=typeof WebAssembly&&ne("no native wasm support detected");var D,k,C,R,M,N,F,L,j=!1,U="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function B(e,t,n){var r=(t>>>=0)+n;for(n=t;e[n]&&!(n>=r);)++n;if(16(o=224==(240&o)?(15&o)<<12|i<<6|a:(7&o)<<18|i<<12|a<<6|63&e[t++])?r+=String.fromCharCode(o):(o-=65536,r+=String.fromCharCode(55296|o>>10,56320|1023&o))}}else r+=String.fromCharCode(o)}return r}function G(e,t){return(e>>>=0)?B(r(),e,t):""}function V(e,t,n,r){if(!(0>>=0;r=n+r-1;for(var i=0;i=a&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++i)),127>=a){if(n>=r)break;t[n++>>>0]=a}else{if(2047>=a){if(n+1>=r)break;t[n++>>>0]=192|a>>6}else{if(65535>=a){if(n+2>=r)break;t[n++>>>0]=224|a>>12}else{if(n+3>=r)break;t[n++>>>0]=240|a>>18,t[n++>>>0]=128|a>>12&63}t[n++>>>0]=128|a>>6&63}t[n++>>>0]=128|63&a}}return t[n>>>0]=0,n-o}function z(e){for(var t=0,n=0;n=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t}function H(e){C=e,s.HEAP8=R=new Int8Array(e),s.HEAP16=new Int16Array(e),s.HEAP32=N=new Int32Array(e),s.HEAPU8=M=new Uint8Array(e),s.HEAPU16=new Uint16Array(e),s.HEAPU32=F=new Uint32Array(e),s.HEAPF32=new Float32Array(e),s.HEAPF64=L=new Float64Array(e)}x&&(C=s.buffer);var W=s.INITIAL_MEMORY||16777216;if(x)D=s.wasmMemory,C=s.buffer;else if(s.wasmMemory)D=s.wasmMemory;else if(!((D=new WebAssembly.Memory({initial:W/65536,maximum:65536,shared:!0})).buffer instanceof SharedArrayBuffer))throw $("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"),v&&console.log("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and also use a recent version)"),Error("bad memory");D&&(C=D.buffer),W=C.byteLength,H(C);var q,K=[],X=[],Y=[];function J(){var e=s.preRun.shift();K.unshift(e)}var Z,Q=0,ee=null,te=null;function ne(e){throw x?postMessage({cmd:"onAbort",arg:e}):s.onAbort&&s.onAbort(e),$(e="Aborted("+e+")"),j=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),l(e),e}function re(){return Z.startsWith("data:application/octet-stream;base64,")}function oe(){var e=Z;try{if(e==Z&&E)return new Uint8Array(E);if(d)return d(e);throw"both async and sync fetching of the wasm failed"}catch(e){ne(e)}}Z="ort-wasm-threaded.wasm",re()||(Z=S(Z));var ie={};function ae(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function se(e){(e=pe.La[e])||ne(),pe.Xa(e)}function ue(e){var t=pe.lb();if(!t)return 6;pe.Ra.push(t),pe.La[e.Ka]=t,t.Ka=e.Ka;var n={cmd:"run",start_routine:e.pb,arg:e.ib,pthread_ptr:e.Ka};return t.Qa=()=>{n.time=performance.now(),t.postMessage(n,e.vb)},t.loaded&&(t.Qa(),delete t.Qa),0}function le(e){if(x)return je(1,1,e);P||(pe.qb(),s.onExit&&s.onExit(e),j=!0),y(e,new ae(e))}function ce(e,t){if(!t&&x)throw fe(e),"unwind";le(e)}var pe={Oa:[],Ra:[],$a:[],La:{},Ua:function(){x&&pe.mb()},xb:function(){},mb:function(){pe.receiveObjectTransfer=pe.ob,pe.threadInitTLS=pe.Za,pe.setExitStatus=pe.Ya,P=!1},Ya:function(){},qb:function(){for(var e of Object.values(pe.La))pe.Xa(e);for(e of pe.Oa)e.terminate();pe.Oa=[]},Xa:function(e){var t=e.Ka;delete pe.La[t],pe.Oa.push(e),pe.Ra.splice(pe.Ra.indexOf(e),1),e.Ka=0,lt(t)},ob:function(){},Za:function(){pe.$a.forEach((e=>e()))},nb:function(e,t){e.onmessage=n=>{var r=(n=n.data).cmd;if(e.Ka&&(pe.kb=e.Ka),n.targetThread&&n.targetThread!=rt()){var o=pe.La[n.yb];o?o.postMessage(n,n.transferList):$('Internal error! Worker sent a message "'+r+'" to target pthread '+n.targetThread+", but that thread no longer exists!")}else"processProxyingQueue"===r?Ce(n.queue):"spawnThread"===r?ue(n):"cleanupThread"===r?se(n.thread):"killThread"===r?(n=n.thread,r=pe.La[n],delete pe.La[n],r.terminate(),lt(n),pe.Ra.splice(pe.Ra.indexOf(r),1),r.Ka=0):"cancelThread"===r?pe.La[n.thread].postMessage({cmd:"cancel"}):"loaded"===r?(e.loaded=!0,t&&t(e),e.Qa&&(e.Qa(),delete e.Qa)):"print"===r?I("Thread "+n.threadId+": "+n.text):"printErr"===r?$("Thread "+n.threadId+": "+n.text):"alert"===r?alert("Thread "+n.threadId+": "+n.text):"setimmediate"===n.target?e.postMessage(n):"onAbort"===r?s.onAbort&&s.onAbort(n.arg):r&&$("worker sent an unknown command "+r);pe.kb=void 0},e.onerror=e=>{throw $("worker sent an error! "+e.filename+":"+e.lineno+": "+e.message),e},v&&(e.on("message",(function(t){e.onmessage({data:t})})),e.on("error",(function(t){e.onerror(t)})),e.on("detachedExit",(function(){}))),e.postMessage({cmd:"load",urlOrBlob:s.mainScriptUrlOrBlob||_scriptDir,wasmMemory:D,wasmModule:k})},hb:function(){var e=S("ort-wasm-threaded.worker.js");pe.Oa.push(new Worker(e))},lb:function(){return 0==pe.Oa.length&&(pe.hb(),pe.nb(pe.Oa[0])),pe.Oa.pop()}};function de(e){for(;0>2>>>0];e=o()[e+48>>2>>>0],pt(t,t-e),ft(t)};var he,ge,me=[];function be(e){this.Pa=e-24,this.gb=function(e){i()[this.Pa+4>>2>>>0]=e},this.cb=function(e){i()[this.Pa+8>>2>>>0]=e},this.eb=function(){o()[this.Pa>>2>>>0]=0},this.bb=function(){t()[this.Pa+12>>0>>>0]=0},this.fb=function(){t()[this.Pa+13>>0>>>0]=0},this.Ua=function(e,t){this.ab(),this.gb(e),this.cb(t),this.eb(),this.bb(),this.fb()},this.ab=function(){i()[this.Pa+16>>2>>>0]=0}}function ye(e,t,n,r){return x?je(3,1,e,t,n,r):we(e,t,n,r)}function we(e,t,n,r){if("undefined"==typeof SharedArrayBuffer)return $("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var o=[];return x&&0===o.length?ye(e,t,n,r):(e={pb:n,Ka:e,ib:r,vb:o},x?(e.wb="spawnThread",postMessage(e,o),0):ue(e))}function _e(e,t,n){return x?je(4,1,e,t,n):0}function ve(e,t){if(x)return je(5,1,e,t)}function xe(e,t){if(x)return je(6,1,e,t)}function Te(e,t,n){if(x)return je(7,1,e,t,n)}function Se(e,t,n){return x?je(8,1,e,t,n):0}function Oe(e,t){if(x)return je(9,1,e,t)}function Ae(e,t,n){if(x)return je(10,1,e,t,n)}function Ee(e,t,n,r){if(x)return je(11,1,e,t,n,r)}function Ie(e,t,n,r){if(x)return je(12,1,e,t,n,r)}function $e(e,t,n,r){if(x)return je(13,1,e,t,n,r)}function Pe(e){if(x)return je(14,1,e)}function De(e,t){if(x)return je(15,1,e,t)}function ke(e,t,n){if(x)return je(16,1,e,t,n)}function Ce(e){Atomics.store(o(),e>>2,1),rt()&&ut(e),Atomics.compareExchange(o(),e>>2,1,0)}function Re(e){return i()[e>>>2]+4294967296*o()[e+4>>>2]}function Me(e,t,n,r,o,i){return x?je(17,1,e,t,n,r,o,i):-52}function Ne(e,t,n,r,o,i){if(x)return je(18,1,e,t,n,r,o,i)}function Fe(e){var n=z(e)+1,r=ot(n);return r&&V(e,t(),r,n),r}function Le(e,t,n){function r(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}if(x)return je(19,1,e,t,n);var a=(new Date).getFullYear(),s=new Date(a,0,1),u=new Date(a,6,1);a=s.getTimezoneOffset();var l=u.getTimezoneOffset(),c=Math.max(a,l);o()[e>>2>>>0]=60*c,o()[t>>2>>>0]=Number(a!=l),e=r(s),t=r(u),e=Fe(e),t=Fe(t),l>2>>>0]=e,i()[n+4>>2>>>0]=t):(i()[n>>2>>>0]=t,i()[n+4>>2>>>0]=e)}function je(e,t){var n=arguments.length-2,r=arguments;return function(e){var t=dt();return e=e(),ft(t),e}((()=>{for(var o=ht(8*n),i=o>>3,s=0;s>>0]=u}return st(e,n,o,t)}))}s.invokeEntryPoint=function(e,t){var n=me[e];n||(e>=me.length&&(me.length=e+1),me[e]=n=q.get(e)),e=n(t),P?pe.Ya(e):ct(e)},s.executeNotifiedProxyingQueue=Ce,ge=v?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:x?()=>performance.now()-s.__performance_now_clock_drift:()=>performance.now();var Ue,Be=[],Ge={};function Ve(){if(!Ue){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",_:b||"./this.program"};for(e in Ge)void 0===Ge[e]?delete t[e]:t[e]=Ge[e];var n=[];for(e in t)n.push(e+"="+t[e]);Ue=n}return Ue}function ze(e,n){if(x)return je(20,1,e,n);var r=0;return Ve().forEach((function(o,a){var s=n+r;for(a=i()[e+4*a>>2>>>0]=s,s=0;s>0>>>0]=o.charCodeAt(s);t()[a>>0>>>0]=0,r+=o.length+1})),0}function He(e,t){if(x)return je(21,1,e,t);var n=Ve();i()[e>>2>>>0]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),i()[t>>2>>>0]=r,0}function We(e){return x?je(22,1,e):52}function qe(e,t,n,r){return x?je(23,1,e,t,n,r):52}function Ke(e,t,n,r,o){return x?je(24,1,e,t,n,r,o):70}var Xe=[null,[],[]];function Ye(e,t,n,o){if(x)return je(25,1,e,t,n,o);for(var a=0,s=0;s>2>>>0],l=i()[t+4>>2>>>0];t+=8;for(var c=0;c>>0],d=Xe[e];0===p||10===p?((1===e?I:$)(B(d,0)),d.length=0):d.push(p)}a+=l}return i()[o>>2>>>0]=a,0}function Je(e){return 0==e%4&&(0!=e%100||0==e%400)}var Ze=[31,29,31,30,31,30,31,31,30,31,30,31],Qe=[31,28,31,30,31,30,31,31,30,31,30,31];function et(e,n,r,i){function a(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.lengthe?-1:0r-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 n=new Date(e.getFullYear()+1,0,4),t=l(new Date(e.getFullYear(),0,4)),n=l(n),0>=u(t,e)?0>=u(n,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var p=o()[i+40>>2>>>0];for(var d in i={tb:o()[i>>2>>>0],sb:o()[i+4>>2>>>0],Sa:o()[i+8>>2>>>0],Va:o()[i+12>>2>>>0],Ta:o()[i+16>>2>>>0],Na:o()[i+20>>2>>>0],Ja:o()[i+24>>2>>>0],Ma:o()[i+28>>2>>>0],zb:o()[i+32>>2>>>0],rb:o()[i+36>>2>>>0],ub:p?G(p):""},r=G(r),p={"%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"})r=r.replace(new RegExp(d,"g"),p[d]);var f="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),h="January February March April May June July August September October November December".split(" ");for(d in p={"%a":function(e){return f[e.Ja].substring(0,3)},"%A":function(e){return f[e.Ja]},"%b":function(e){return h[e.Ta].substring(0,3)},"%B":function(e){return h[e.Ta]},"%C":function(e){return s((e.Na+1900)/100|0,2)},"%d":function(e){return s(e.Va,2)},"%e":function(e){return a(e.Va,2," ")},"%g":function(e){return c(e).toString().substring(2)},"%G":function(e){return c(e)},"%H":function(e){return s(e.Sa,2)},"%I":function(e){return 0==(e=e.Sa)?e=12:12e.Sa?"AM":"PM"},"%S":function(e){return s(e.tb,2)},"%t":function(){return"\t"},"%u":function(e){return e.Ja||7},"%U":function(e){return s(Math.floor((e.Ma+7-e.Ja)/7),2)},"%V":function(e){var t=Math.floor((e.Ma+7-(e.Ja+6)%7)/7);if(2>=(e.Ja+371-e.Ma-2)%7&&t++,t)53==t&&(4==(n=(e.Ja+371-e.Ma)%7)||3==n&&Je(e.Na)||(t=1));else{t=52;var n=(e.Ja+7-e.Ma-1)%7;(4==n||5==n&&Je(e.Na%400-1))&&t++}return s(t,2)},"%w":function(e){return e.Ja},"%W":function(e){return s(Math.floor((e.Ma+7-(e.Ja+6)%7)/7),2)},"%y":function(e){return(e.Na+1900).toString().substring(2)},"%Y":function(e){return e.Na+1900},"%z":function(e){var t=0<=(e=e.rb);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.ub},"%%":function(){return"%"}},r=r.replace(/%%/g,"\0\0"),p)r.includes(d)&&(r=r.replace(new RegExp(d,"g"),p[d](i)));return d=function(e){var t=Array(z(e)+1);return V(e,t,0,t.length),t}(r=r.replace(/\0\0/g,"%")),d.length>n?0:(function(e,n){t().set(e,n>>>0)}(d,e),d.length-1)}pe.Ua();var tt=[null,le,fe,ye,_e,ve,xe,Te,Se,Oe,Ae,Ee,Ie,$e,Pe,De,ke,Me,Ne,Le,ze,He,We,qe,Ke,Ye],nt={b:function(e){return ot(e+24)+24},c:function(e,t,n){throw new be(e).Ua(t,n),e},L:function(e){it(e,!_,1,!w),pe.Za()},l:function(e){x?postMessage({cmd:"cleanupThread",thread:e}):se(e)},D:we,i:_e,R:ve,z:xe,B:Te,T:Se,P:Oe,I:Ae,O:Ee,p:Ie,A:$e,x:Pe,Q:De,y:ke,r:function(){},j:function(){ne("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},s:function(){ne("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},q:function(){return Date.now()},E:function(){return 2097152},V:function(){return!0},F:function(e,t,n,r){if(e==t)setTimeout((()=>Ce(r)));else if(x)postMessage({targetThread:e,cmd:"processProxyingQueue",queue:r});else{if(!(e=pe.La[e]))return;e.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},K:function(){return-1},W:function(e,t){e=new Date(1e3*Re(e)),o()[t>>2>>>0]=e.getUTCSeconds(),o()[t+4>>2>>>0]=e.getUTCMinutes(),o()[t+8>>2>>>0]=e.getUTCHours(),o()[t+12>>2>>>0]=e.getUTCDate(),o()[t+16>>2>>>0]=e.getUTCMonth(),o()[t+20>>2>>>0]=e.getUTCFullYear()-1900,o()[t+24>>2>>>0]=e.getUTCDay(),e=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0,o()[t+28>>2>>>0]=e},X:function(e,t){e=new Date(1e3*Re(e)),o()[t>>2>>>0]=e.getSeconds(),o()[t+4>>2>>>0]=e.getMinutes(),o()[t+8>>2>>>0]=e.getHours(),o()[t+12>>2>>>0]=e.getDate(),o()[t+16>>2>>>0]=e.getMonth(),o()[t+20>>2>>>0]=e.getFullYear()-1900,o()[t+24>>2>>>0]=e.getDay();var n=new Date(e.getFullYear(),0,1),r=(e.getTime()-n.getTime())/864e5|0;o()[t+28>>2>>>0]=r,o()[t+36>>2>>>0]=-60*e.getTimezoneOffset(),r=new Date(e.getFullYear(),6,1).getTimezoneOffset(),e=0|(r!=(n=n.getTimezoneOffset())&&e.getTimezoneOffset()==Math.min(n,r)),o()[t+32>>2>>>0]=e},Y:function(e){var t=new Date(o()[e+20>>2>>>0]+1900,o()[e+16>>2>>>0],o()[e+12>>2>>>0],o()[e+8>>2>>>0],o()[e+4>>2>>>0],o()[e>>2>>>0],0),n=o()[e+32>>2>>>0],r=t.getTimezoneOffset(),i=new Date(t.getFullYear(),0,1),a=new Date(t.getFullYear(),6,1).getTimezoneOffset(),s=i.getTimezoneOffset(),u=Math.min(s,a);return 0>n?o()[e+32>>2>>>0]=Number(a!=s&&u==r):0>2>>>0]=t.getDay(),n=(t.getTime()-i.getTime())/864e5|0,o()[e+28>>2>>>0]=n,o()[e>>2>>>0]=t.getSeconds(),o()[e+4>>2>>>0]=t.getMinutes(),o()[e+8>>2>>>0]=t.getHours(),o()[e+12>>2>>>0]=t.getDate(),o()[e+16>>2>>>0]=t.getMonth(),t.getTime()/1e3|0},G:Me,H:Ne,Z:function e(t,n,r){e.jb||(e.jb=!0,Le(t,n,r))},d:function(){ne("")},m:function(){if(!v&&!_){var e="Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread";he||(he={}),he[e]||(he[e]=1,v&&(e="warning: "+e),$(e))}},w:function(){return 4294901760},f:ge,S:function(e,t,n){r().copyWithin(e>>>0,t>>>0,t+n>>>0)},g:function(){return v?n(3993).cpus().length:navigator.hardwareConcurrency},J:function(e,t,n){Be.length=t,n>>=3;for(var r=0;r>>0];return(0>e?ie[-e-1]:tt[e]).apply(null,Be)},v:function(e){var t=r().length;if((e>>>=0)<=t||4294901760=n;n*=2){var o=t*(1+.2/n);o=Math.min(o,e+100663296);var i=Math;o=Math.max(e,o),i=i.min.call(i,4294901760,o+(65536-o%65536)%65536);e:{try{D.grow(i-C.byteLength+65535>>>16),H(D.buffer);var a=1;break e}catch(e){}a=void 0}if(a)return!0}return!1},U:function(){throw"unwind"},M:ze,N:He,k:ce,h:We,o:qe,t:Ke,n:Ye,u:function e(r,o){e.Wa||(e.Wa=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}if(v)try{var t=n(760);return()=>t.randomBytes(1)[0]}catch(e){}return()=>ne("randomDevice")}());for(var i=0;i>0>>>0]=e.Wa();return 0},a:D||s.wasmMemory,C:et,e:function(e,t,n,r){return et(e,t,n,r)}};!function(){function e(e,t){s.asm=e.exports,pe.$a.push(s.asm.wa),q=s.asm.za,X.unshift(s.asm._),k=t,x||(Q--,s.monitorRunDependencies&&s.monitorRunDependencies(Q),0==Q&&(null!==ee&&(clearInterval(ee),ee=null),te&&(e=te,te=null,e())))}function t(t){e(t.instance,t.module)}function n(e){return function(){if(!E&&(w||_)){if("function"==typeof fetch&&!Z.startsWith("file://"))return fetch(Z,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Z+"'";return e.arrayBuffer()})).catch((function(){return oe()}));if(p)return new Promise((function(e,t){p(Z,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return oe()}))}().then((function(e){return WebAssembly.instantiate(e,r)})).then((function(e){return e})).then(e,(function(e){$("failed to asynchronously prepare wasm: "+e),ne(e)}))}var r={a:nt};if(x||(Q++,s.monitorRunDependencies&&s.monitorRunDependencies(Q)),s.instantiateWasm)try{return s.instantiateWasm(r,e)}catch(e){return $("Module.instantiateWasm callback failed with error: "+e),!1}(E||"function"!=typeof WebAssembly.instantiateStreaming||re()||Z.startsWith("file://")||v||"function"!=typeof fetch?n(t):fetch(Z,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,r).then(t,(function(e){return $("wasm streaming compile failed: "+e),$("falling back to ArrayBuffer instantiation"),n(t)}))}))).catch(l)}(),s.___wasm_call_ctors=function(){return(s.___wasm_call_ctors=s.asm._).apply(null,arguments)},s._OrtInit=function(){return(s._OrtInit=s.asm.$).apply(null,arguments)},s._OrtCreateSessionOptions=function(){return(s._OrtCreateSessionOptions=s.asm.aa).apply(null,arguments)},s._OrtAppendExecutionProvider=function(){return(s._OrtAppendExecutionProvider=s.asm.ba).apply(null,arguments)},s._OrtAddSessionConfigEntry=function(){return(s._OrtAddSessionConfigEntry=s.asm.ca).apply(null,arguments)},s._OrtReleaseSessionOptions=function(){return(s._OrtReleaseSessionOptions=s.asm.da).apply(null,arguments)},s._OrtCreateSession=function(){return(s._OrtCreateSession=s.asm.ea).apply(null,arguments)},s._OrtReleaseSession=function(){return(s._OrtReleaseSession=s.asm.fa).apply(null,arguments)},s._OrtGetInputCount=function(){return(s._OrtGetInputCount=s.asm.ga).apply(null,arguments)},s._OrtGetOutputCount=function(){return(s._OrtGetOutputCount=s.asm.ha).apply(null,arguments)},s._OrtGetInputName=function(){return(s._OrtGetInputName=s.asm.ia).apply(null,arguments)},s._OrtGetOutputName=function(){return(s._OrtGetOutputName=s.asm.ja).apply(null,arguments)},s._OrtFree=function(){return(s._OrtFree=s.asm.ka).apply(null,arguments)},s._OrtCreateTensor=function(){return(s._OrtCreateTensor=s.asm.la).apply(null,arguments)},s._OrtGetTensorData=function(){return(s._OrtGetTensorData=s.asm.ma).apply(null,arguments)},s._OrtReleaseTensor=function(){return(s._OrtReleaseTensor=s.asm.na).apply(null,arguments)},s._OrtCreateRunOptions=function(){return(s._OrtCreateRunOptions=s.asm.oa).apply(null,arguments)},s._OrtAddRunConfigEntry=function(){return(s._OrtAddRunConfigEntry=s.asm.pa).apply(null,arguments)},s._OrtReleaseRunOptions=function(){return(s._OrtReleaseRunOptions=s.asm.qa).apply(null,arguments)},s._OrtRun=function(){return(s._OrtRun=s.asm.ra).apply(null,arguments)},s._OrtEndProfiling=function(){return(s._OrtEndProfiling=s.asm.sa).apply(null,arguments)};var rt=s._pthread_self=function(){return(rt=s._pthread_self=s.asm.ta).apply(null,arguments)},ot=s._malloc=function(){return(ot=s._malloc=s.asm.ua).apply(null,arguments)};s._free=function(){return(s._free=s.asm.va).apply(null,arguments)},s.__emscripten_tls_init=function(){return(s.__emscripten_tls_init=s.asm.wa).apply(null,arguments)};var it=s.__emscripten_thread_init=function(){return(it=s.__emscripten_thread_init=s.asm.xa).apply(null,arguments)};s.__emscripten_thread_crashed=function(){return(s.__emscripten_thread_crashed=s.asm.ya).apply(null,arguments)};var at,st=s._emscripten_run_in_main_runtime_thread_js=function(){return(st=s._emscripten_run_in_main_runtime_thread_js=s.asm.Aa).apply(null,arguments)},ut=s.__emscripten_proxy_execute_task_queue=function(){return(ut=s.__emscripten_proxy_execute_task_queue=s.asm.Ba).apply(null,arguments)},lt=s.__emscripten_thread_free_data=function(){return(lt=s.__emscripten_thread_free_data=s.asm.Ca).apply(null,arguments)},ct=s.__emscripten_thread_exit=function(){return(ct=s.__emscripten_thread_exit=s.asm.Da).apply(null,arguments)},pt=s._emscripten_stack_set_limits=function(){return(pt=s._emscripten_stack_set_limits=s.asm.Ea).apply(null,arguments)},dt=s.stackSave=function(){return(dt=s.stackSave=s.asm.Fa).apply(null,arguments)},ft=s.stackRestore=function(){return(ft=s.stackRestore=s.asm.Ga).apply(null,arguments)},ht=s.stackAlloc=function(){return(ht=s.stackAlloc=s.asm.Ha).apply(null,arguments)};function gt(){function e(){if(!at&&(at=!0,s.calledRun=!0,!j)&&(x||de(X),u(s),s.onRuntimeInitialized&&s.onRuntimeInitialized(),!x)){if(s.postRun)for("function"==typeof s.postRun&&(s.postRun=[s.postRun]);s.postRun.length;){var e=s.postRun.shift();Y.unshift(e)}de(Y)}}if(!(0{var _scriptDir,r=(_scriptDir=(_scriptDir="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(e){var t,r,o;e=e||{},t||(t=void 0!==e?e:{}),t.ready=new Promise((function(e,t){r=e,o=t}));var i,a,s,u,l,c,p=Object.assign({},t),d="./this.program",f=(e,t)=>{throw t},h="object"==typeof window,g="function"==typeof importScripts,m="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,b="";m?(b=g?n(908).dirname(b)+"/":"//",c=()=>{l||(u=n(1384),l=n(908))},i=function(e,t){return c(),e=l.normalize(e),u.readFileSync(e,t?void 0:"utf8")},s=e=>((e=i(e,!0)).buffer||(e=new Uint8Array(e)),e),a=(e,t,n)=>{c(),e=l.normalize(e),u.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},1{if(v)throw process.exitCode=e,t;t instanceof q||_("exiting due to exception: "+t),process.exit(e)},t.inspect=function(){return"[Emscripten Module object]"}):(h||g)&&(g?b=self.location.href:"undefined"!=typeof document&&document.currentScript&&(b=document.currentScript.src),_scriptDir&&(b=_scriptDir),b=0!==b.indexOf("blob:")?b.substr(0,b.replace(/[?#].*/,"").lastIndexOf("/")+1):"",i=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},g&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),a=(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,w=t.print||console.log.bind(console),_=t.printErr||console.warn.bind(console);Object.assign(t,p),p=null,t.thisProgram&&(d=t.thisProgram),t.quit&&(f=t.quit),t.wasmBinary&&(y=t.wasmBinary);var v=t.noExitRuntime||!0;"object"!=typeof WebAssembly&&V("no native wasm support detected");var x,T,S,O,A,E,I=!1,$="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function P(e,t,n){var r=(t>>>=0)+n;for(n=t;e[n]&&!(n>=r);)++n;if(16(o=224==(240&o)?(15&o)<<12|i<<6|a:(7&o)<<18|i<<12|a<<6|63&e[t++])?r+=String.fromCharCode(o):(o-=65536,r+=String.fromCharCode(55296|o>>10,56320|1023&o))}}else r+=String.fromCharCode(o)}return r}function D(e,t){return(e>>>=0)?P(O,e,t):""}function k(e,t,n,r){if(!(0>>=0;r=n+r-1;for(var i=0;i=a&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++i)),127>=a){if(n>=r)break;t[n++>>>0]=a}else{if(2047>=a){if(n+1>=r)break;t[n++>>>0]=192|a>>6}else{if(65535>=a){if(n+2>=r)break;t[n++>>>0]=224|a>>12}else{if(n+3>=r)break;t[n++>>>0]=240|a>>18,t[n++>>>0]=128|a>>12&63}t[n++>>>0]=128|a>>6&63}t[n++>>>0]=128|63&a}}return t[n>>>0]=0,n-o}function C(e){for(var t=0,n=0;n=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t}function R(){var e=x.buffer;T=e,t.HEAP8=S=new Int8Array(e),t.HEAP16=new Int16Array(e),t.HEAP32=A=new Int32Array(e),t.HEAPU8=O=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=E=new Uint32Array(e),t.HEAPF32=new Float32Array(e),t.HEAPF64=new Float64Array(e)}var M=[],N=[],F=[];function L(){var e=t.preRun.shift();M.unshift(e)}var j,U=0,B=null,G=null;function V(e){throw t.onAbort&&t.onAbort(e),_(e="Aborted("+e+")"),I=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),o(e),e}function z(){return j.startsWith("data:application/octet-stream;base64,")}if(j="ort-wasm.wasm",!z()){var H=j;j=t.locateFile?t.locateFile(H,b):b+H}function W(){var e=j;try{if(e==j&&y)return new Uint8Array(y);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}catch(e){V(e)}}function q(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function K(e){for(;0>2>>>0]=e},this.Ba=function(e){E[this.sa+8>>2>>>0]=e},this.Ga=function(){A[this.sa>>2>>>0]=0},this.Aa=function(){S[this.sa+12>>0>>>0]=0},this.Ha=function(){S[this.sa+13>>0>>>0]=0},this.ya=function(e,t){this.za(),this.Ia(e),this.Ba(t),this.Ga(),this.Aa(),this.Ha()},this.za=function(){E[this.sa+16>>2>>>0]=0}}function Y(e){var t=C(e)+1,n=ae(t);return n&&k(e,S,n,t),n}var J={};function Z(){if(!Q){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",_:d||"./this.program"};for(e in J)void 0===J[e]?delete t[e]:t[e]=J[e];var n=[];for(e in t)n.push(e+"="+t[e]);Q=n}return Q}var Q,ee=[null,[],[]];function te(e){return 0==e%4&&(0!=e%100||0==e%400)}var ne=[31,29,31,30,31,30,31,31,30,31,30,31],re=[31,28,31,30,31,30,31,31,30,31,30,31];function oe(e,t,n,r){function o(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.lengthe?-1:0r-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 n=new Date(e.getFullYear()+1,0,4),t=s(new Date(e.getFullYear(),0,4)),n=s(n),0>=a(t,e)?0>=a(n,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var l=A[r+40>>2>>>0];for(var c in r={Ea:A[r>>2>>>0],Da:A[r+4>>2>>>0],ta:A[r+8>>2>>>0],va:A[r+12>>2>>>0],ua:A[r+16>>2>>>0],ra:A[r+20>>2>>>0],la:A[r+24>>2>>>0],qa:A[r+28>>2>>>0],Ja:A[r+32>>2>>>0],Ca:A[r+36>>2>>>0],Fa:l?D(l):""},n=D(n),l={"%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(c,"g"),l[c]);var p="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(c in l={"%a":function(e){return p[e.la].substring(0,3)},"%A":function(e){return p[e.la]},"%b":function(e){return d[e.ua].substring(0,3)},"%B":function(e){return d[e.ua]},"%C":function(e){return i((e.ra+1900)/100|0,2)},"%d":function(e){return i(e.va,2)},"%e":function(e){return o(e.va,2," ")},"%g":function(e){return u(e).toString().substring(2)},"%G":function(e){return u(e)},"%H":function(e){return i(e.ta,2)},"%I":function(e){return 0==(e=e.ta)?e=12:12e.ta?"AM":"PM"},"%S":function(e){return i(e.Ea,2)},"%t":function(){return"\t"},"%u":function(e){return e.la||7},"%U":function(e){return i(Math.floor((e.qa+7-e.la)/7),2)},"%V":function(e){var t=Math.floor((e.qa+7-(e.la+6)%7)/7);if(2>=(e.la+371-e.qa-2)%7&&t++,t)53==t&&(4==(n=(e.la+371-e.qa)%7)||3==n&&te(e.ra)||(t=1));else{t=52;var n=(e.la+7-e.qa-1)%7;(4==n||5==n&&te(e.ra%400-1))&&t++}return i(t,2)},"%w":function(e){return e.la},"%W":function(e){return i(Math.floor((e.qa+7-(e.la+6)%7)/7),2)},"%y":function(e){return(e.ra+1900).toString().substring(2)},"%Y":function(e){return e.ra+1900},"%z":function(e){var t=0<=(e=e.Ca);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.Fa},"%%":function(){return"%"}},n=n.replace(/%%/g,"\0\0"),l)n.includes(c)&&(n=n.replace(new RegExp(c,"g"),l[c](r)));return c=function(e){var t=Array(C(e)+1);return k(e,t,0,t.length),t}(n=n.replace(/\0\0/g,"%")),c.length>t?0:(S.set(c,e>>>0),c.length-1)}var ie={a:function(e){return ae(e+24)+24},b:function(e,t,n){throw new X(e).ya(t,n),e},g:function(){return 0},I:function(){},w:function(){},y:function(){},K:function(){return 0},G:function(){},C:function(){},F:function(){},k:function(){},x:function(){},u:function(){},H:function(){},v:function(){},n:function(){},p:function(){V("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},o:function(){V("To use dlopen, you need enable dynamic linking, see https://github.com/emscripten-core/emscripten/wiki/Linking")},l:function(){return Date.now()},L:function(){return!0},M:function(e,t){e=new Date(1e3*(E[e>>>2]+4294967296*A[e+4>>>2])),A[t>>2>>>0]=e.getUTCSeconds(),A[t+4>>2>>>0]=e.getUTCMinutes(),A[t+8>>2>>>0]=e.getUTCHours(),A[t+12>>2>>>0]=e.getUTCDate(),A[t+16>>2>>>0]=e.getUTCMonth(),A[t+20>>2>>>0]=e.getUTCFullYear()-1900,A[t+24>>2>>>0]=e.getUTCDay(),A[t+28>>2>>>0]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},N:function(e,t){e=new Date(1e3*(E[e>>>2]+4294967296*A[e+4>>>2])),A[t>>2>>>0]=e.getSeconds(),A[t+4>>2>>>0]=e.getMinutes(),A[t+8>>2>>>0]=e.getHours(),A[t+12>>2>>>0]=e.getDate(),A[t+16>>2>>>0]=e.getMonth(),A[t+20>>2>>>0]=e.getFullYear()-1900,A[t+24>>2>>>0]=e.getDay();var n=new Date(e.getFullYear(),0,1);A[t+28>>2>>>0]=(e.getTime()-n.getTime())/864e5|0,A[t+36>>2>>>0]=-60*e.getTimezoneOffset();var r=new Date(e.getFullYear(),6,1).getTimezoneOffset();n=n.getTimezoneOffset(),A[t+32>>2>>>0]=0|(r!=n&&e.getTimezoneOffset()==Math.min(n,r))},O:function(e){var t=new Date(A[e+20>>2>>>0]+1900,A[e+16>>2>>>0],A[e+12>>2>>>0],A[e+8>>2>>>0],A[e+4>>2>>>0],A[e>>2>>>0],0),n=A[e+32>>2>>>0],r=t.getTimezoneOffset(),o=new Date(t.getFullYear(),0,1),i=new Date(t.getFullYear(),6,1).getTimezoneOffset(),a=o.getTimezoneOffset(),s=Math.min(a,i);return 0>n?A[e+32>>2>>>0]=Number(i!=a&&s==r):0>2>>>0]=t.getDay(),A[e+28>>2>>>0]=(t.getTime()-o.getTime())/864e5|0,A[e>>2>>>0]=t.getSeconds(),A[e+4>>2>>>0]=t.getMinutes(),A[e+8>>2>>>0]=t.getHours(),A[e+12>>2>>>0]=t.getDate(),A[e+16>>2>>>0]=t.getMonth(),t.getTime()/1e3|0},z:function(){return-52},B:function(){},m:function e(t,n,r){e.xa||(e.xa=!0,function(e,t,n){function r(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}var o=(new Date).getFullYear(),i=new Date(o,0,1),a=new Date(o,6,1);o=i.getTimezoneOffset();var s=a.getTimezoneOffset();A[e>>2>>>0]=60*Math.max(o,s),A[t>>2>>>0]=Number(o!=s),e=r(i),t=r(a),e=Y(e),t=Y(t),s>2>>>0]=e,E[n+4>>2>>>0]=t):(E[n>>2>>>0]=t,E[n+4>>2>>>0]=e)}(t,n,r))},d:function(){V("")},t:function(){return 4294901760},h:m?()=>{var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.now(),J:function(e,t,n){O.copyWithin(e>>>0,t>>>0,t+n>>>0)},f:function(e){var t=O.length;if(4294901760<(e>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var o=Math;r=Math.max(e,r),o=o.min.call(o,4294901760,r+(65536-r%65536)%65536);e:{try{x.grow(o-T.byteLength+65535>>>16),R();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},D:function(e,t){var n=0;return Z().forEach((function(r,o){var i=t+n;for(o=E[e+4*o>>2>>>0]=i,i=0;i>0>>>0]=r.charCodeAt(i);S[o>>0>>>0]=0,n+=r.length+1})),0},E:function(e,t){var n=Z();E[e>>2>>>0]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),E[t>>2>>>0]=r,0},r:function(e){v||(t.onExit&&t.onExit(e),I=!0),f(e,new q(e))},e:function(){return 52},j:function(){return 52},q:function(){return 70},i:function(e,t,n,r){for(var o=0,i=0;i>2>>>0],s=E[t+4>>2>>>0];t+=8;for(var u=0;u>>0],c=ee[e];0===l||10===l?((1===e?w:_)(P(c,0)),c.length=0):c.push(l)}o+=s}return E[r>>2>>>0]=o,0},s:function e(t,r){e.wa||(e.wa=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}if(m)try{var t=n(760);return()=>t.randomBytes(1)[0]}catch(e){}return()=>V("randomDevice")}());for(var o=0;o>0>>>0]=e.wa();return 0},A:oe,c:function(e,t,n,r){return oe(e,t,n,r)}};!function(){function e(e){t.asm=e.exports,x=t.asm.P,R(),N.unshift(t.asm.Q),U--,t.monitorRunDependencies&&t.monitorRunDependencies(U),0==U&&(null!==B&&(clearInterval(B),B=null),G&&(e=G,G=null,e()))}function n(t){e(t.instance)}function r(e){return function(){if(!y&&(h||g)){if("function"==typeof fetch&&!j.startsWith("file://"))return fetch(j,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+j+"'";return e.arrayBuffer()})).catch((function(){return W()}));if(a)return new Promise((function(e,t){a(j,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return W()}))}().then((function(e){return WebAssembly.instantiate(e,i)})).then((function(e){return e})).then(e,(function(e){_("failed to asynchronously prepare wasm: "+e),V(e)}))}var i={a:ie};if(U++,t.monitorRunDependencies&&t.monitorRunDependencies(U),t.instantiateWasm)try{return t.instantiateWasm(i,e)}catch(e){return _("Module.instantiateWasm callback failed with error: "+e),!1}(y||"function"!=typeof WebAssembly.instantiateStreaming||z()||j.startsWith("file://")||m||"function"!=typeof fetch?r(n):fetch(j,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,i).then(n,(function(e){return _("wasm streaming compile failed: "+e),_("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(o)}(),t.___wasm_call_ctors=function(){return(t.___wasm_call_ctors=t.asm.Q).apply(null,arguments)},t._OrtInit=function(){return(t._OrtInit=t.asm.R).apply(null,arguments)},t._OrtCreateSessionOptions=function(){return(t._OrtCreateSessionOptions=t.asm.S).apply(null,arguments)},t._OrtAppendExecutionProvider=function(){return(t._OrtAppendExecutionProvider=t.asm.T).apply(null,arguments)},t._OrtAddSessionConfigEntry=function(){return(t._OrtAddSessionConfigEntry=t.asm.U).apply(null,arguments)},t._OrtReleaseSessionOptions=function(){return(t._OrtReleaseSessionOptions=t.asm.V).apply(null,arguments)},t._OrtCreateSession=function(){return(t._OrtCreateSession=t.asm.W).apply(null,arguments)},t._OrtReleaseSession=function(){return(t._OrtReleaseSession=t.asm.X).apply(null,arguments)},t._OrtGetInputCount=function(){return(t._OrtGetInputCount=t.asm.Y).apply(null,arguments)},t._OrtGetOutputCount=function(){return(t._OrtGetOutputCount=t.asm.Z).apply(null,arguments)},t._OrtGetInputName=function(){return(t._OrtGetInputName=t.asm._).apply(null,arguments)},t._OrtGetOutputName=function(){return(t._OrtGetOutputName=t.asm.$).apply(null,arguments)},t._OrtFree=function(){return(t._OrtFree=t.asm.aa).apply(null,arguments)},t._OrtCreateTensor=function(){return(t._OrtCreateTensor=t.asm.ba).apply(null,arguments)},t._OrtGetTensorData=function(){return(t._OrtGetTensorData=t.asm.ca).apply(null,arguments)},t._OrtReleaseTensor=function(){return(t._OrtReleaseTensor=t.asm.da).apply(null,arguments)},t._OrtCreateRunOptions=function(){return(t._OrtCreateRunOptions=t.asm.ea).apply(null,arguments)},t._OrtAddRunConfigEntry=function(){return(t._OrtAddRunConfigEntry=t.asm.fa).apply(null,arguments)},t._OrtReleaseRunOptions=function(){return(t._OrtReleaseRunOptions=t.asm.ga).apply(null,arguments)},t._OrtRun=function(){return(t._OrtRun=t.asm.ha).apply(null,arguments)},t._OrtEndProfiling=function(){return(t._OrtEndProfiling=t.asm.ia).apply(null,arguments)};var ae=t._malloc=function(){return(ae=t._malloc=t.asm.ja).apply(null,arguments)};t._free=function(){return(t._free=t.asm.ka).apply(null,arguments)};var se,ue=t.stackSave=function(){return(ue=t.stackSave=t.asm.ma).apply(null,arguments)},le=t.stackRestore=function(){return(le=t.stackRestore=t.asm.na).apply(null,arguments)},ce=t.stackAlloc=function(){return(ce=t.stackAlloc=t.asm.oa).apply(null,arguments)};function pe(){function e(){if(!se&&(se=!0,t.calledRun=!0,!I)){if(K(N),r(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;){var e=t.postRun.shift();F.unshift(e)}K(F)}}if(!(0{"use strict";e.exports=function(e,t){for(var n=new Array(arguments.length-1),r=0,o=2,i=!0;o{"use strict";var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var r=new Array(64),o=new Array(123),i=0;i<64;)o[r[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;n.encode=function(e,t,n){for(var o,i=null,a=[],s=0,u=0;t>2],o=(3&l)<<4,u=1;break;case 1:a[s++]=r[o|l>>4],o=(15&l)<<2,u=2;break;case 2:a[s++]=r[o|l>>6],a[s++]=r[63&l],u=0}s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,a)),s=0)}return u&&(a[s++]=r[o],a[s++]=61,1===u&&(a[s++]=61)),i?(s&&i.push(String.fromCharCode.apply(String,a.slice(0,s))),i.join("")):String.fromCharCode.apply(String,a.slice(0,s))};var a="invalid encoding";n.decode=function(e,t,n){for(var r,i=n,s=0,u=0;u1)break;if(void 0===(l=o[l]))throw Error(a);switch(s){case 0:r=l,s=1;break;case 1:t[n++]=r<<2|(48&l)>>4,r=l,s=2;break;case 2:t[n++]=(15&r)<<4|(60&l)>>2,r=l,s=3;break;case 3:t[n++]=(3&r)<<6|l,s=0}}if(1===s)throw Error(a);return n-i},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},9211:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],r=0;r{"use strict";function t(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),r=128===n[3];function o(e,r,o){t[0]=e,r[o]=n[0],r[o+1]=n[1],r[o+2]=n[2],r[o+3]=n[3]}function i(e,r,o){t[0]=e,r[o]=n[3],r[o+1]=n[2],r[o+2]=n[1],r[o+3]=n[0]}function a(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],t[0]}function s(e,r){return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t[0]}e.writeFloatLE=r?o:i,e.writeFloatBE=r?i:o,e.readFloatLE=r?a:s,e.readFloatBE=r?s:a}():function(){function t(e,t,n,r){var o=t<0?1:0;if(o&&(t=-t),0===t)e(1/t>0?0:2147483648,n,r);else if(isNaN(t))e(2143289344,n,r);else if(t>34028234663852886e22)e((o<<31|2139095040)>>>0,n,r);else if(t<11754943508222875e-54)e((o<<31|Math.round(t/1401298464324817e-60))>>>0,n,r);else{var i=Math.floor(Math.log(t)/Math.LN2);e((o<<31|i+127<<23|8388607&Math.round(t*Math.pow(2,-i)*8388608))>>>0,n,r)}}function a(e,t,n){var r=e(t,n),o=2*(r>>31)+1,i=r>>>23&255,a=8388607&r;return 255===i?a?NaN:o*(1/0):0===i?1401298464324817e-60*o*a:o*Math.pow(2,i-150)*(a+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,r),e.readFloatLE=a.bind(null,o),e.readFloatBE=a.bind(null,i)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),r=128===n[7];function o(e,r,o){t[0]=e,r[o]=n[0],r[o+1]=n[1],r[o+2]=n[2],r[o+3]=n[3],r[o+4]=n[4],r[o+5]=n[5],r[o+6]=n[6],r[o+7]=n[7]}function i(e,r,o){t[0]=e,r[o]=n[7],r[o+1]=n[6],r[o+2]=n[5],r[o+3]=n[4],r[o+4]=n[3],r[o+5]=n[2],r[o+6]=n[1],r[o+7]=n[0]}function a(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],n[4]=e[r+4],n[5]=e[r+5],n[6]=e[r+6],n[7]=e[r+7],t[0]}function s(e,r){return n[7]=e[r],n[6]=e[r+1],n[5]=e[r+2],n[4]=e[r+3],n[3]=e[r+4],n[2]=e[r+5],n[1]=e[r+6],n[0]=e[r+7],t[0]}e.writeDoubleLE=r?o:i,e.writeDoubleBE=r?i:o,e.readDoubleLE=r?a:s,e.readDoubleBE=r?s:a}():function(){function t(e,t,n,r,o,i){var a=r<0?1:0;if(a&&(r=-r),0===r)e(0,o,i+t),e(1/r>0?0:2147483648,o,i+n);else if(isNaN(r))e(0,o,i+t),e(2146959360,o,i+n);else if(r>17976931348623157e292)e(0,o,i+t),e((a<<31|2146435072)>>>0,o,i+n);else{var s;if(r<22250738585072014e-324)e((s=r/5e-324)>>>0,o,i+t),e((a<<31|s/4294967296)>>>0,o,i+n);else{var u=Math.floor(Math.log(r)/Math.LN2);1024===u&&(u=1023),e(4503599627370496*(s=r*Math.pow(2,-u))>>>0,o,i+t),e((a<<31|u+1023<<20|1048576*s&1048575)>>>0,o,i+n)}}}function a(e,t,n,r,o){var i=e(r,o+t),a=e(r,o+n),s=2*(a>>31)+1,u=a>>>20&2047,l=4294967296*(1048575&a)+i;return 2047===u?l?NaN:s*(1/0):0===u?5e-324*s*l:s*Math.pow(2,u-1075)*(l+4503599627370496)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,r,4,0),e.readDoubleLE=a.bind(null,o,0,4),e.readDoubleBE=a.bind(null,i,4,0)}(),e}function n(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function r(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function o(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function i(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},7199:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},6662:e=>{"use strict";e.exports=function(e,t,n){var r=n||8192,o=r>>>1,i=null,a=r;return function(n){if(n<1||n>o)return e(n);a+n>r&&(i=e(r),a=0);var s=t.call(i,a,a+=n);return 7&a&&(a=1+(7|a)),s}}},4997:(e,t)=>{"use strict";var n=t;n.length=function(e){for(var t=0,n=0,r=0;r191&&r<224?i[a++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[a++]=55296+(r>>10),i[a++]=56320+(1023&r)):i[a++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),a=0);return o?(a&&o.push(String.fromCharCode.apply(String,i.slice(0,a))),o.join("")):String.fromCharCode.apply(String,i.slice(0,a))},n.write=function(e,t,n){for(var r,o,i=n,a=0;a>6|192,t[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(o=e.charCodeAt(a+1)))?(r=65536+((1023&r)<<10)+(1023&o),++a,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128);return n-i}},3442:(e,t)=>{"use strict";t.__esModule=!0;var n=function(){function e(t){if(!t)throw new TypeError("Invalid argument; `value` has no value.");this.value=e.EMPTY,t&&e.isGuid(t)&&(this.value=t)}return e.isGuid=function(t){var n=t.toString();return t&&(t instanceof e||e.validator.test(n))},e.create=function(){return new e([e.gen(2),e.gen(1),e.gen(1),e.gen(1),e.gen(3)].join("-"))},e.createEmpty=function(){return new e("emptyguid")},e.parse=function(t){return new e(t)},e.raw=function(){return[e.gen(2),e.gen(1),e.gen(1),e.gen(1),e.gen(3)].join("-")},e.gen=function(e){for(var t="",n=0;n{e.exports=n;var t=null;try{t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function n(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function r(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=r;var o={},i={};function a(e,t){var n,r,a;return t?(a=0<=(e>>>=0)&&e<256)&&(r=i[e])?r:(n=u(e,(0|e)<0?-1:0,!0),a&&(i[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(r=o[e])?r:(n=u(e,e<0?-1:0,!1),a&&(o[e]=n),n)}function s(e,t){if(isNaN(e))return t?b:m;if(t){if(e<0)return b;if(e>=f)return x}else{if(e<=-h)return T;if(e+1>=h)return v}return e<0?s(-e,t).neg():u(e%d|0,e/d|0,t)}function u(e,t,r){return new n(e,t,r)}n.fromInt=a,n.fromNumber=s,n.fromBits=u;var l=Math.pow;function c(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return m;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||360)throw Error("interior hyphen");if(0===r)return c(e.substring(1),t,n).neg();for(var o=s(l(n,8)),i=m,a=0;a>>0:this.low},S.toNumber=function(){return this.unsigned?(this.high>>>0)*d+(this.low>>>0):this.high*d+(this.low>>>0)},S.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((i=u).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}},S.getHighBits=function(){return this.high},S.getHighBitsUnsigned=function(){return this.high>>>0},S.getLowBits=function(){return this.low},S.getLowBitsUnsigned=function(){return this.low>>>0},S.getNumBitsAbs=function(){if(this.isNegative())return this.eq(T)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},S.isOdd=function(){return 1==(1&this.low)},S.isEven=function(){return 0==(1&this.low)},S.equals=function(e){return r(e)||(e=p(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},S.eq=S.equals,S.notEquals=function(e){return!this.eq(e)},S.neq=S.notEquals,S.ne=S.notEquals,S.lessThan=function(e){return this.comp(e)<0},S.lt=S.lessThan,S.lessThanOrEqual=function(e){return this.comp(e)<=0},S.lte=S.lessThanOrEqual,S.le=S.lessThanOrEqual,S.greaterThan=function(e){return this.comp(e)>0},S.gt=S.greaterThan,S.greaterThanOrEqual=function(e){return this.comp(e)>=0},S.gte=S.greaterThanOrEqual,S.ge=S.greaterThanOrEqual,S.compare=function(e){if(r(e)||(e=p(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},S.comp=S.compare,S.negate=function(){return!this.unsigned&&this.eq(T)?T:this.not().add(y)},S.neg=S.negate,S.add=function(e){r(e)||(e=p(e));var t=this.high>>>16,n=65535&this.high,o=this.low>>>16,i=65535&this.low,a=e.high>>>16,s=65535&e.high,l=e.low>>>16,c=0,d=0,f=0,h=0;return f+=(h+=i+(65535&e.low))>>>16,d+=(f+=o+l)>>>16,c+=(d+=n+s)>>>16,c+=t+a,u((f&=65535)<<16|(h&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},S.subtract=function(e){return r(e)||(e=p(e)),this.add(e.neg())},S.sub=S.subtract,S.multiply=function(e){if(this.isZero())return m;if(r(e)||(e=p(e)),t)return u(t.mul(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned);if(e.isZero())return m;if(this.eq(T))return e.isOdd()?T:m;if(e.eq(T))return this.isOdd()?T:m;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(g)&&e.lt(g))return s(this.toNumber()*e.toNumber(),this.unsigned);var n=this.high>>>16,o=65535&this.high,i=this.low>>>16,a=65535&this.low,l=e.high>>>16,c=65535&e.high,d=e.low>>>16,f=65535&e.low,h=0,b=0,y=0,w=0;return y+=(w+=a*f)>>>16,b+=(y+=i*f)>>>16,y&=65535,b+=(y+=a*d)>>>16,h+=(b+=o*f)>>>16,b&=65535,h+=(b+=i*d)>>>16,b&=65535,h+=(b+=a*c)>>>16,h+=n*f+o*d+i*c+a*l,u((y&=65535)<<16|(w&=65535),(h&=65535)<<16|(b&=65535),this.unsigned)},S.mul=S.multiply,S.divide=function(e){if(r(e)||(e=p(e)),e.isZero())throw Error("division by zero");var n,o,i;if(t)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?u((this.unsigned?t.div_u:t.div_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?b:m;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return b;if(e.gt(this.shru(1)))return w;i=b}else{if(this.eq(T))return e.eq(y)||e.eq(_)?T:e.eq(T)?y:(n=this.shr(1).div(e).shl(1)).eq(m)?e.isNegative()?y:_:(o=this.sub(e.mul(n)),i=n.add(o.div(e)));if(e.eq(T))return this.unsigned?b:m;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=m}for(o=this;o.gte(e);){n=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),c=a<=48?1:l(2,a-48),d=s(n),f=d.mul(e);f.isNegative()||f.gt(o);)f=(d=s(n-=c,this.unsigned)).mul(e);d.isZero()&&(d=y),i=i.add(d),o=o.sub(f)}return i},S.div=S.divide,S.modulo=function(e){return r(e)||(e=p(e)),t?u((this.unsigned?t.rem_u:t.rem_s)(this.low,this.high,e.low,e.high),t.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},S.mod=S.modulo,S.rem=S.modulo,S.not=function(){return u(~this.low,~this.high,this.unsigned)},S.and=function(e){return r(e)||(e=p(e)),u(this.low&e.low,this.high&e.high,this.unsigned)},S.or=function(e){return r(e)||(e=p(e)),u(this.low|e.low,this.high|e.high,this.unsigned)},S.xor=function(e){return r(e)||(e=p(e)),u(this.low^e.low,this.high^e.high,this.unsigned)},S.shiftLeft=function(e){return r(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?u(this.low<>>32-e,this.unsigned):u(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):u(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},S.shr=S.shiftRight,S.shiftRightUnsigned=function(e){if(r(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?u(this.low>>>e|t<<32-e,t>>>e,this.unsigned):u(32===e?t:t>>>e-32,0,this.unsigned)},S.shru=S.shiftRightUnsigned,S.shr_u=S.shiftRightUnsigned,S.toSigned=function(){return this.unsigned?u(this.low,this.high,!1):this},S.toUnsigned=function(){return this.unsigned?this:u(this.low,this.high,!0)},S.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},S.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},S.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},1446:(e,t,n)=>{"use strict";var r,o,i,a=n(2100),s=a.Reader,u=a.Writer,l=a.util,c=a.roots.default||(a.roots.default={});c.onnx=((i={}).Version=(r={},(o=Object.create(r))[r[0]="_START_VERSION"]=0,o[r[1]="IR_VERSION_2017_10_10"]=1,o[r[2]="IR_VERSION_2017_10_30"]=2,o[r[3]="IR_VERSION_2017_11_3"]=3,o[r[4]="IR_VERSION_2019_1_22"]=4,o[r[5]="IR_VERSION"]=5,o),i.AttributeProto=function(){function e(e){if(this.floats=[],this.ints=[],this.strings=[],this.tensors=[],this.graphs=[],e)for(var t=Object.keys(e),n=0;n>>3){case 1:r.name=e.string();break;case 21:r.refAttrName=e.string();break;case 13:r.docString=e.string();break;case 20:r.type=e.int32();break;case 2:r.f=e.float();break;case 3:r.i=e.int64();break;case 4:r.s=e.bytes();break;case 5:r.t=c.onnx.TensorProto.decode(e,e.uint32());break;case 6:r.g=c.onnx.GraphProto.decode(e,e.uint32());break;case 7:if(r.floats&&r.floats.length||(r.floats=[]),2==(7&o))for(var i=e.uint32()+e.pos;e.pos>>0,e.i.high>>>0).toNumber())),null!=e.s&&("string"==typeof e.s?l.base64.decode(e.s,t.s=l.newBuffer(l.base64.length(e.s)),0):e.s.length&&(t.s=e.s)),null!=e.t){if("object"!=typeof e.t)throw TypeError(".onnx.AttributeProto.t: object expected");t.t=c.onnx.TensorProto.fromObject(e.t)}if(null!=e.g){if("object"!=typeof e.g)throw TypeError(".onnx.AttributeProto.g: object expected");t.g=c.onnx.GraphProto.fromObject(e.g)}if(e.floats){if(!Array.isArray(e.floats))throw TypeError(".onnx.AttributeProto.floats: array expected");t.floats=[];for(var n=0;n>>0,e.ints[n].high>>>0).toNumber())}if(e.strings){if(!Array.isArray(e.strings))throw TypeError(".onnx.AttributeProto.strings: array expected");for(t.strings=[],n=0;n>>0,e.i.high>>>0).toNumber():e.i),null!=e.s&&e.hasOwnProperty("s")&&(n.s=t.bytes===String?l.base64.encode(e.s,0,e.s.length):t.bytes===Array?Array.prototype.slice.call(e.s):e.s),null!=e.t&&e.hasOwnProperty("t")&&(n.t=c.onnx.TensorProto.toObject(e.t,t)),null!=e.g&&e.hasOwnProperty("g")&&(n.g=c.onnx.GraphProto.toObject(e.g,t)),e.floats&&e.floats.length){n.floats=[];for(var o=0;o>>0,e.ints[o].high>>>0).toNumber():e.ints[o];if(e.strings&&e.strings.length)for(n.strings=[],o=0;o>>3){case 1:r.name=e.string();break;case 2:r.type=c.onnx.TypeProto.decode(e,e.uint32());break;case 3:r.docString=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.name&&e.hasOwnProperty("name")&&!l.isString(e.name))return"name: string expected";if(null!=e.type&&e.hasOwnProperty("type")){var t=c.onnx.TypeProto.verify(e.type);if(t)return"type."+t}return null!=e.docString&&e.hasOwnProperty("docString")&&!l.isString(e.docString)?"docString: string expected":null},e.fromObject=function(e){if(e instanceof c.onnx.ValueInfoProto)return e;var t=new c.onnx.ValueInfoProto;if(null!=e.name&&(t.name=String(e.name)),null!=e.type){if("object"!=typeof e.type)throw TypeError(".onnx.ValueInfoProto.type: object expected");t.type=c.onnx.TypeProto.fromObject(e.type)}return null!=e.docString&&(t.docString=String(e.docString)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.name="",n.type=null,n.docString=""),null!=e.name&&e.hasOwnProperty("name")&&(n.name=e.name),null!=e.type&&e.hasOwnProperty("type")&&(n.type=c.onnx.TypeProto.toObject(e.type,t)),null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),i.NodeProto=function(){function e(e){if(this.input=[],this.output=[],this.attribute=[],e)for(var t=Object.keys(e),n=0;n>>3){case 1:r.input&&r.input.length||(r.input=[]),r.input.push(e.string());break;case 2:r.output&&r.output.length||(r.output=[]),r.output.push(e.string());break;case 3:r.name=e.string();break;case 4:r.opType=e.string();break;case 7:r.domain=e.string();break;case 5:r.attribute&&r.attribute.length||(r.attribute=[]),r.attribute.push(c.onnx.AttributeProto.decode(e,e.uint32()));break;case 6:r.docString=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.input&&e.hasOwnProperty("input")){if(!Array.isArray(e.input))return"input: array expected";for(var t=0;t>>3){case 1:r.irVersion=e.int64();break;case 8:r.opsetImport&&r.opsetImport.length||(r.opsetImport=[]),r.opsetImport.push(c.onnx.OperatorSetIdProto.decode(e,e.uint32()));break;case 2:r.producerName=e.string();break;case 3:r.producerVersion=e.string();break;case 4:r.domain=e.string();break;case 5:r.modelVersion=e.int64();break;case 6:r.docString=e.string();break;case 7:r.graph=c.onnx.GraphProto.decode(e,e.uint32());break;case 14:r.metadataProps&&r.metadataProps.length||(r.metadataProps=[]),r.metadataProps.push(c.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.irVersion&&e.hasOwnProperty("irVersion")&&!(l.isInteger(e.irVersion)||e.irVersion&&l.isInteger(e.irVersion.low)&&l.isInteger(e.irVersion.high)))return"irVersion: integer|Long expected";if(null!=e.opsetImport&&e.hasOwnProperty("opsetImport")){if(!Array.isArray(e.opsetImport))return"opsetImport: array expected";for(var t=0;t>>0,e.irVersion.high>>>0).toNumber())),e.opsetImport){if(!Array.isArray(e.opsetImport))throw TypeError(".onnx.ModelProto.opsetImport: array expected");t.opsetImport=[];for(var n=0;n>>0,e.modelVersion.high>>>0).toNumber())),null!=e.docString&&(t.docString=String(e.docString)),null!=e.graph){if("object"!=typeof e.graph)throw TypeError(".onnx.ModelProto.graph: object expected");t.graph=c.onnx.GraphProto.fromObject(e.graph)}if(e.metadataProps){if(!Array.isArray(e.metadataProps))throw TypeError(".onnx.ModelProto.metadataProps: array expected");for(t.metadataProps=[],n=0;n>>0,e.irVersion.high>>>0).toNumber():e.irVersion),null!=e.producerName&&e.hasOwnProperty("producerName")&&(n.producerName=e.producerName),null!=e.producerVersion&&e.hasOwnProperty("producerVersion")&&(n.producerVersion=e.producerVersion),null!=e.domain&&e.hasOwnProperty("domain")&&(n.domain=e.domain),null!=e.modelVersion&&e.hasOwnProperty("modelVersion")&&("number"==typeof e.modelVersion?n.modelVersion=t.longs===String?String(e.modelVersion):e.modelVersion:n.modelVersion=t.longs===String?l.Long.prototype.toString.call(e.modelVersion):t.longs===Number?new l.LongBits(e.modelVersion.low>>>0,e.modelVersion.high>>>0).toNumber():e.modelVersion),null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),null!=e.graph&&e.hasOwnProperty("graph")&&(n.graph=c.onnx.GraphProto.toObject(e.graph,t)),e.opsetImport&&e.opsetImport.length){n.opsetImport=[];for(var o=0;o>>3){case 1:r.key=e.string();break;case 2:r.value=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.key&&e.hasOwnProperty("key")&&!l.isString(e.key)?"key: string expected":null!=e.value&&e.hasOwnProperty("value")&&!l.isString(e.value)?"value: string expected":null},e.fromObject=function(e){if(e instanceof c.onnx.StringStringEntryProto)return e;var t=new c.onnx.StringStringEntryProto;return null!=e.key&&(t.key=String(e.key)),null!=e.value&&(t.value=String(e.value)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.key="",n.value=""),null!=e.key&&e.hasOwnProperty("key")&&(n.key=e.key),null!=e.value&&e.hasOwnProperty("value")&&(n.value=e.value),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),i.TensorAnnotation=function(){function e(e){if(this.quantParameterTensorNames=[],e)for(var t=Object.keys(e),n=0;n>>3){case 1:r.tensorName=e.string();break;case 2:r.quantParameterTensorNames&&r.quantParameterTensorNames.length||(r.quantParameterTensorNames=[]),r.quantParameterTensorNames.push(c.onnx.StringStringEntryProto.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.tensorName&&e.hasOwnProperty("tensorName")&&!l.isString(e.tensorName))return"tensorName: string expected";if(null!=e.quantParameterTensorNames&&e.hasOwnProperty("quantParameterTensorNames")){if(!Array.isArray(e.quantParameterTensorNames))return"quantParameterTensorNames: array expected";for(var t=0;t>>3){case 1:r.node&&r.node.length||(r.node=[]),r.node.push(c.onnx.NodeProto.decode(e,e.uint32()));break;case 2:r.name=e.string();break;case 5:r.initializer&&r.initializer.length||(r.initializer=[]),r.initializer.push(c.onnx.TensorProto.decode(e,e.uint32()));break;case 10:r.docString=e.string();break;case 11:r.input&&r.input.length||(r.input=[]),r.input.push(c.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 12:r.output&&r.output.length||(r.output=[]),r.output.push(c.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 13:r.valueInfo&&r.valueInfo.length||(r.valueInfo=[]),r.valueInfo.push(c.onnx.ValueInfoProto.decode(e,e.uint32()));break;case 14:r.quantizationAnnotation&&r.quantizationAnnotation.length||(r.quantizationAnnotation=[]),r.quantizationAnnotation.push(c.onnx.TensorAnnotation.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.node&&e.hasOwnProperty("node")){if(!Array.isArray(e.node))return"node: array expected";for(var t=0;t>>3){case 1:if(r.dims&&r.dims.length||(r.dims=[]),2==(7&o))for(var i=e.uint32()+e.pos;e.pos>>0,e.dims[n].high>>>0).toNumber())}if(null!=e.dataType&&(t.dataType=0|e.dataType),null!=e.segment){if("object"!=typeof e.segment)throw TypeError(".onnx.TensorProto.segment: object expected");t.segment=c.onnx.TensorProto.Segment.fromObject(e.segment)}if(e.floatData){if(!Array.isArray(e.floatData))throw TypeError(".onnx.TensorProto.floatData: array expected");for(t.floatData=[],n=0;n>>0,e.int64Data[n].high>>>0).toNumber())}if(null!=e.name&&(t.name=String(e.name)),null!=e.docString&&(t.docString=String(e.docString)),null!=e.rawData&&("string"==typeof e.rawData?l.base64.decode(e.rawData,t.rawData=l.newBuffer(l.base64.length(e.rawData)),0):e.rawData.length&&(t.rawData=e.rawData)),e.externalData){if(!Array.isArray(e.externalData))throw TypeError(".onnx.TensorProto.externalData: array expected");for(t.externalData=[],n=0;n>>0,e.uint64Data[n].high>>>0).toNumber(!0))}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.dims=[],n.floatData=[],n.int32Data=[],n.stringData=[],n.int64Data=[],n.doubleData=[],n.uint64Data=[],n.externalData=[]),t.defaults&&(n.dataType=0,n.segment=null,n.name="",t.bytes===String?n.rawData="":(n.rawData=[],t.bytes!==Array&&(n.rawData=l.newBuffer(n.rawData))),n.docString="",n.dataLocation=t.enums===String?"DEFAULT":0),e.dims&&e.dims.length){n.dims=[];for(var r=0;r>>0,e.dims[r].high>>>0).toNumber():e.dims[r]}if(null!=e.dataType&&e.hasOwnProperty("dataType")&&(n.dataType=e.dataType),null!=e.segment&&e.hasOwnProperty("segment")&&(n.segment=c.onnx.TensorProto.Segment.toObject(e.segment,t)),e.floatData&&e.floatData.length)for(n.floatData=[],r=0;r>>0,e.int64Data[r].high>>>0).toNumber():e.int64Data[r];if(null!=e.name&&e.hasOwnProperty("name")&&(n.name=e.name),null!=e.rawData&&e.hasOwnProperty("rawData")&&(n.rawData=t.bytes===String?l.base64.encode(e.rawData,0,e.rawData.length):t.bytes===Array?Array.prototype.slice.call(e.rawData):e.rawData),e.doubleData&&e.doubleData.length)for(n.doubleData=[],r=0;r>>0,e.uint64Data[r].high>>>0).toNumber(!0):e.uint64Data[r];if(null!=e.docString&&e.hasOwnProperty("docString")&&(n.docString=e.docString),e.externalData&&e.externalData.length)for(n.externalData=[],r=0;r>>3){case 1:r.begin=e.int64();break;case 2:r.end=e.int64();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.begin&&e.hasOwnProperty("begin")&&!(l.isInteger(e.begin)||e.begin&&l.isInteger(e.begin.low)&&l.isInteger(e.begin.high))?"begin: integer|Long expected":null!=e.end&&e.hasOwnProperty("end")&&!(l.isInteger(e.end)||e.end&&l.isInteger(e.end.low)&&l.isInteger(e.end.high))?"end: integer|Long expected":null},e.fromObject=function(e){if(e instanceof c.onnx.TensorProto.Segment)return e;var t=new c.onnx.TensorProto.Segment;return null!=e.begin&&(l.Long?(t.begin=l.Long.fromValue(e.begin)).unsigned=!1:"string"==typeof e.begin?t.begin=parseInt(e.begin,10):"number"==typeof e.begin?t.begin=e.begin:"object"==typeof e.begin&&(t.begin=new l.LongBits(e.begin.low>>>0,e.begin.high>>>0).toNumber())),null!=e.end&&(l.Long?(t.end=l.Long.fromValue(e.end)).unsigned=!1:"string"==typeof e.end?t.end=parseInt(e.end,10):"number"==typeof e.end?t.end=e.end:"object"==typeof e.end&&(t.end=new l.LongBits(e.end.low>>>0,e.end.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults){if(l.Long){var r=new l.Long(0,0,!1);n.begin=t.longs===String?r.toString():t.longs===Number?r.toNumber():r}else n.begin=t.longs===String?"0":0;l.Long?(r=new l.Long(0,0,!1),n.end=t.longs===String?r.toString():t.longs===Number?r.toNumber():r):n.end=t.longs===String?"0":0}return null!=e.begin&&e.hasOwnProperty("begin")&&("number"==typeof e.begin?n.begin=t.longs===String?String(e.begin):e.begin:n.begin=t.longs===String?l.Long.prototype.toString.call(e.begin):t.longs===Number?new l.LongBits(e.begin.low>>>0,e.begin.high>>>0).toNumber():e.begin),null!=e.end&&e.hasOwnProperty("end")&&("number"==typeof e.end?n.end=t.longs===String?String(e.end):e.end:n.end=t.longs===String?l.Long.prototype.toString.call(e.end):t.longs===Number?new l.LongBits(e.end.low>>>0,e.end.high>>>0).toNumber():e.end),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),e.DataLocation=function(){var e={},t=Object.create(e);return t[e[0]="DEFAULT"]=0,t[e[1]="EXTERNAL"]=1,t}(),e}(),i.TensorShapeProto=function(){function e(e){if(this.dim=[],e)for(var t=Object.keys(e),n=0;n>>3==1?(r.dim&&r.dim.length||(r.dim=[]),r.dim.push(c.onnx.TensorShapeProto.Dimension.decode(e,e.uint32()))):e.skipType(7&o)}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.dim&&e.hasOwnProperty("dim")){if(!Array.isArray(e.dim))return"dim: array expected";for(var t=0;t>>3){case 1:r.dimValue=e.int64();break;case 2:r.dimParam=e.string();break;case 3:r.denotation=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var t={};if(null!=e.dimValue&&e.hasOwnProperty("dimValue")&&(t.value=1,!(l.isInteger(e.dimValue)||e.dimValue&&l.isInteger(e.dimValue.low)&&l.isInteger(e.dimValue.high))))return"dimValue: integer|Long expected";if(null!=e.dimParam&&e.hasOwnProperty("dimParam")){if(1===t.value)return"value: multiple values";if(t.value=1,!l.isString(e.dimParam))return"dimParam: string expected"}return null!=e.denotation&&e.hasOwnProperty("denotation")&&!l.isString(e.denotation)?"denotation: string expected":null},e.fromObject=function(e){if(e instanceof c.onnx.TensorShapeProto.Dimension)return e;var t=new c.onnx.TensorShapeProto.Dimension;return null!=e.dimValue&&(l.Long?(t.dimValue=l.Long.fromValue(e.dimValue)).unsigned=!1:"string"==typeof e.dimValue?t.dimValue=parseInt(e.dimValue,10):"number"==typeof e.dimValue?t.dimValue=e.dimValue:"object"==typeof e.dimValue&&(t.dimValue=new l.LongBits(e.dimValue.low>>>0,e.dimValue.high>>>0).toNumber())),null!=e.dimParam&&(t.dimParam=String(e.dimParam)),null!=e.denotation&&(t.denotation=String(e.denotation)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.denotation=""),null!=e.dimValue&&e.hasOwnProperty("dimValue")&&("number"==typeof e.dimValue?n.dimValue=t.longs===String?String(e.dimValue):e.dimValue:n.dimValue=t.longs===String?l.Long.prototype.toString.call(e.dimValue):t.longs===Number?new l.LongBits(e.dimValue.low>>>0,e.dimValue.high>>>0).toNumber():e.dimValue,t.oneofs&&(n.value="dimValue")),null!=e.dimParam&&e.hasOwnProperty("dimParam")&&(n.dimParam=e.dimParam,t.oneofs&&(n.value="dimParam")),null!=e.denotation&&e.hasOwnProperty("denotation")&&(n.denotation=e.denotation),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),e}(),i.TypeProto=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:r.tensorType=c.onnx.TypeProto.Tensor.decode(e,e.uint32());break;case 6:r.denotation=e.string();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.tensorType&&e.hasOwnProperty("tensorType")){var t=c.onnx.TypeProto.Tensor.verify(e.tensorType);if(t)return"tensorType."+t}return null!=e.denotation&&e.hasOwnProperty("denotation")&&!l.isString(e.denotation)?"denotation: string expected":null},e.fromObject=function(e){if(e instanceof c.onnx.TypeProto)return e;var t=new c.onnx.TypeProto;if(null!=e.tensorType){if("object"!=typeof e.tensorType)throw TypeError(".onnx.TypeProto.tensorType: object expected");t.tensorType=c.onnx.TypeProto.Tensor.fromObject(e.tensorType)}return null!=e.denotation&&(t.denotation=String(e.denotation)),t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.denotation=""),null!=e.tensorType&&e.hasOwnProperty("tensorType")&&(n.tensorType=c.onnx.TypeProto.Tensor.toObject(e.tensorType,t),t.oneofs&&(n.value="tensorType")),null!=e.denotation&&e.hasOwnProperty("denotation")&&(n.denotation=e.denotation),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e.Tensor=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:r.elemType=e.int32();break;case 2:r.shape=c.onnx.TensorShapeProto.decode(e,e.uint32());break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elemType&&e.hasOwnProperty("elemType")&&!l.isInteger(e.elemType))return"elemType: integer expected";if(null!=e.shape&&e.hasOwnProperty("shape")){var t=c.onnx.TensorShapeProto.verify(e.shape);if(t)return"shape."+t}return null},e.fromObject=function(e){if(e instanceof c.onnx.TypeProto.Tensor)return e;var t=new c.onnx.TypeProto.Tensor;if(null!=e.elemType&&(t.elemType=0|e.elemType),null!=e.shape){if("object"!=typeof e.shape)throw TypeError(".onnx.TypeProto.Tensor.shape: object expected");t.shape=c.onnx.TensorShapeProto.fromObject(e.shape)}return t},e.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.elemType=0,n.shape=null),null!=e.elemType&&e.hasOwnProperty("elemType")&&(n.elemType=e.elemType),null!=e.shape&&e.hasOwnProperty("shape")&&(n.shape=c.onnx.TensorShapeProto.toObject(e.shape,t)),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),e}(),i.OperatorSetIdProto=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n>>3){case 1:r.domain=e.string();break;case 2:r.version=e.int64();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof s||(e=new s(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.domain&&e.hasOwnProperty("domain")&&!l.isString(e.domain)?"domain: string expected":null!=e.version&&e.hasOwnProperty("version")&&!(l.isInteger(e.version)||e.version&&l.isInteger(e.version.low)&&l.isInteger(e.version.high))?"version: integer|Long expected":null},e.fromObject=function(e){if(e instanceof c.onnx.OperatorSetIdProto)return e;var t=new c.onnx.OperatorSetIdProto;return null!=e.domain&&(t.domain=String(e.domain)),null!=e.version&&(l.Long?(t.version=l.Long.fromValue(e.version)).unsigned=!1:"string"==typeof e.version?t.version=parseInt(e.version,10):"number"==typeof e.version?t.version=e.version:"object"==typeof e.version&&(t.version=new l.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber())),t},e.toObject=function(e,t){t||(t={});var n={};if(t.defaults)if(n.domain="",l.Long){var r=new l.Long(0,0,!1);n.version=t.longs===String?r.toString():t.longs===Number?r.toNumber():r}else n.version=t.longs===String?"0":0;return null!=e.domain&&e.hasOwnProperty("domain")&&(n.domain=e.domain),null!=e.version&&e.hasOwnProperty("version")&&("number"==typeof e.version?n.version=t.longs===String?String(e.version):e.version:n.version=t.longs===String?l.Long.prototype.toString.call(e.version):t.longs===Number?new l.LongBits(e.version.low>>>0,e.version.high>>>0).toNumber():e.version),n},e.prototype.toJSON=function(){return this.constructor.toObject(this,a.util.toJSONOptions)},e}(),i),e.exports=c},2100:(e,t,n)=>{"use strict";e.exports=n(9482)},9482:(e,t,n)=>{"use strict";var r=t;function o(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(1173),r.BufferWriter=n(3155),r.Reader=n(1408),r.BufferReader=n(593),r.util=n(9693),r.rpc=n(5994),r.roots=n(5054),r.configure=o,o()},1408:(e,t,n)=>{"use strict";e.exports=u;var r,o=n(9693),i=o.LongBits,a=o.utf8;function s(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function u(e){this.buf=e,this.pos=0,this.len=e.length}var l,c="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new u(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new u(e);throw Error("illegal buffer")},p=function(){return o.Buffer?function(e){return(u.create=function(e){return o.Buffer.isBuffer(e)?new r(e):c(e)})(e)}:c};function d(){var e=new i(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw s(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw s(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function f(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function h(){if(this.pos+8>this.len)throw s(this,8);return new i(f(this.buf,this.pos+=4),f(this.buf,this.pos+=4))}u.create=p(),u.prototype._slice=o.Array.prototype.subarray||o.Array.prototype.slice,u.prototype.uint32=(l=4294967295,function(){if(l=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return l;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return l}),u.prototype.int32=function(){return 0|this.uint32()},u.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},u.prototype.bool=function(){return 0!==this.uint32()},u.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return f(this.buf,this.pos+=4)},u.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|f(this.buf,this.pos+=4)},u.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var e=o.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},u.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var e=o.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},u.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw s(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)},u.prototype.string=function(){var e=this.bytes();return a.read(e,0,e.length)},u.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw s(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw s(this)}while(128&this.buf[this.pos++]);return this},u.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},u._configure=function(e){r=e,u.create=p(),r._configure();var t=o.Long?"toLong":"toNumber";o.merge(u.prototype,{int64:function(){return d.call(this)[t](!1)},uint64:function(){return d.call(this)[t](!0)},sint64:function(){return d.call(this).zzDecode()[t](!1)},fixed64:function(){return h.call(this)[t](!0)},sfixed64:function(){return h.call(this)[t](!1)}})}},593:(e,t,n)=>{"use strict";e.exports=i;var r=n(1408);(i.prototype=Object.create(r.prototype)).constructor=i;var o=n(9693);function i(e){r.call(this,e)}i._configure=function(){o.Buffer&&(i.prototype._slice=o.Buffer.prototype.slice)},i.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},i._configure()},5054:e=>{"use strict";e.exports={}},5994:(e,t,n)=>{"use strict";t.Service=n(7948)},7948:(e,t,n)=>{"use strict";e.exports=o;var r=n(9693);function o(e,t,n){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(n)}(o.prototype=Object.create(r.EventEmitter.prototype)).constructor=o,o.prototype.rpcCall=function e(t,n,o,i,a){if(!i)throw TypeError("request must be specified");var s=this;if(!a)return r.asPromise(e,s,t,n,o,i);if(s.rpcImpl)try{return s.rpcImpl(t,n[s.requestDelimited?"encodeDelimited":"encode"](i).finish(),(function(e,n){if(e)return s.emit("error",e,t),a(e);if(null!==n){if(!(n instanceof o))try{n=o[s.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return s.emit("error",e,t),a(e)}return s.emit("data",n,t),a(null,n)}s.end(!0)}))}catch(e){return s.emit("error",e,t),void setTimeout((function(){a(e)}),0)}else setTimeout((function(){a(Error("already ended"))}),0)},o.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},1945:(e,t,n)=>{"use strict";e.exports=o;var r=n(9693);function o(e,t){this.lo=e>>>0,this.hi=t>>>0}var i=o.zero=new o(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var a=o.zeroHash="\0\0\0\0\0\0\0\0";o.fromNumber=function(e){if(0===e)return i;var t=e<0;t&&(e=-e);var n=e>>>0,r=(e-n)/4294967296>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new o(n,r)},o.from=function(e){if("number"==typeof e)return o.fromNumber(e);if(r.isString(e)){if(!r.Long)return o.fromNumber(parseInt(e,10));e=r.Long.fromString(e)}return e.low||e.high?new o(e.low>>>0,e.high>>>0):i},o.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+4294967296*n)}return this.lo+4294967296*this.hi},o.prototype.toLong=function(e){return r.Long?new r.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var s=String.prototype.charCodeAt;o.fromHash=function(e){return e===a?i:new o((s.call(e,0)|s.call(e,1)<<8|s.call(e,2)<<16|s.call(e,3)<<24)>>>0,(s.call(e,4)|s.call(e,5)<<8|s.call(e,6)<<16|s.call(e,7)<<24)>>>0)},o.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},o.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},o.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},o.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}},9693:function(e,t,n){"use strict";var r=t;function o(e,t,n){for(var r=Object.keys(t),o=0;o0)},r.Buffer=function(){try{var e=r.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(e){return"number"==typeof e?r.Buffer?r._Buffer_allocUnsafe(e):new r.Array(e):r.Buffer?r._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},r.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(e){return e?r.LongBits.from(e).toHash():r.LongBits.zeroHash},r.longFromHash=function(e,t){var n=r.LongBits.fromHash(e);return r.Long?r.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))},r.merge=o,r.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},r.newError=i,r.ProtocolError=i("ProtocolError"),r.oneOfGetter=function(e){for(var t={},n=0;n-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},r.oneOfSetter=function(e){return function(t){for(var n=0;n{"use strict";e.exports=p;var r,o=n(9693),i=o.LongBits,a=o.base64,s=o.utf8;function u(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function l(){}function c(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function p(){this.len=0,this.head=new u(l,0,0),this.tail=this.head,this.states=null}var d=function(){return o.Buffer?function(){return(p.create=function(){return new r})()}:function(){return new p}};function f(e,t,n){t[n]=255&e}function h(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function m(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}p.create=d(),p.alloc=function(e){return new o.Array(e)},o.Array!==Array&&(p.alloc=o.pool(p.alloc,o.Array.prototype.subarray)),p.prototype._push=function(e,t,n){return this.tail=this.tail.next=new u(e,t,n),this.len+=t,this},h.prototype=Object.create(u.prototype),h.prototype.fn=function(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e},p.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new h((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},p.prototype.int32=function(e){return e<0?this._push(g,10,i.fromNumber(e)):this.uint32(e)},p.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},p.prototype.uint64=function(e){var t=i.from(e);return this._push(g,t.length(),t)},p.prototype.int64=p.prototype.uint64,p.prototype.sint64=function(e){var t=i.from(e).zzEncode();return this._push(g,t.length(),t)},p.prototype.bool=function(e){return this._push(f,1,e?1:0)},p.prototype.fixed32=function(e){return this._push(m,4,e>>>0)},p.prototype.sfixed32=p.prototype.fixed32,p.prototype.fixed64=function(e){var t=i.from(e);return this._push(m,4,t.lo)._push(m,4,t.hi)},p.prototype.sfixed64=p.prototype.fixed64,p.prototype.float=function(e){return this._push(o.float.writeFloatLE,4,e)},p.prototype.double=function(e){return this._push(o.float.writeDoubleLE,8,e)};var b=o.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r>>0;if(!t)return this._push(f,1,0);if(o.isString(e)){var n=p.alloc(t=a.length(e));a.decode(e,n,0),e=n}return this.uint32(t)._push(b,t,e)},p.prototype.string=function(e){var t=s.length(e);return t?this.uint32(t)._push(s.write,t,e):this._push(f,1,0)},p.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new u(l,0,0),this.len=0,this},p.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new u(l,0,0),this.len=0),this},p.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},p.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},p._configure=function(e){r=e,p.create=d(),r._configure()}},3155:(e,t,n)=>{"use strict";e.exports=i;var r=n(1173);(i.prototype=Object.create(r.prototype)).constructor=i;var o=n(9693);function i(){r.call(this)}function a(e,t,n){e.length<40?o.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}i._configure=function(){i.alloc=o._Buffer_allocUnsafe,i.writeBytesBuffer=o.Buffer&&o.Buffer.prototype instanceof Uint8Array&&"set"===o.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var r=0;r>>0;return this.uint32(t),t&&this._push(i.writeBytesBuffer,t,e),this},i.prototype.string=function(e){var t=o.Buffer.byteLength(e);return this.uint32(t),t&&this._push(a,t,e),this},i._configure()},4154:e=>{"use strict";e.exports='"use strict";var e={},t="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;if(t){var r=require("worker_threads"),a=r.parentPort;a.on("message",(e=>onmessage({data:e})));var o=require("fs");Object.assign(global,{self:global,require:require,Module:e,location:{href:__filename},Worker:r.Worker,importScripts:function(e){(0,eval)(o.readFileSync(e,"utf8"))},postMessage:function(e){a.postMessage(e)},performance:global.performance||{now:function(){return Date.now()}}})}var s=!1,n=[],i=function(){var e=Array.prototype.slice.call(arguments).join(" ");t?o.writeSync(2,e+"\\n"):console.error(e)};self.alert=function(){var t=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:t,threadId:e._pthread_self()})},e.instantiateWasm=(t,r)=>{var a=new WebAssembly.Instance(e.wasmModule,t);return r(a),e.wasmModule=null,a.exports},self.onunhandledrejection=e=>{throw e.reason??e},self.onmessage=t=>{try{if("load"===t.data.cmd){if(e.wasmModule=t.data.wasmModule,e.wasmMemory=t.data.wasmMemory,e.buffer=e.wasmMemory.buffer,e.ENVIRONMENT_IS_PTHREAD=!0,"string"==typeof t.data.urlOrBlob)importScripts(t.data.urlOrBlob);else{var r=URL.createObjectURL(t.data.urlOrBlob);importScripts(r),URL.revokeObjectURL(r)}ortWasmThreaded(e).then((function(t){e=t}))}else if("run"===t.data.cmd){e.__performance_now_clock_drift=performance.now()-t.data.time,e.__emscripten_thread_init(t.data.pthread_ptr,0,0,1),e.establishStackSpace(),e.PThread.receiveObjectTransfer(t.data),e.PThread.threadInitTLS(),s||(n.forEach((t=>{e.executeNotifiedProxyingQueue(t)})),n=[],s=!0);try{e.invokeEntryPoint(t.data.start_routine,t.data.arg)}catch(t){if("unwind"!=t){if(!(t instanceof e.ExitStatus))throw t;e.keepRuntimeAlive()||e.__emscripten_thread_exit(t.status)}}}else"cancel"===t.data.cmd?e._pthread_self()&&e.__emscripten_thread_exit(-1):"setimmediate"===t.data.target||("processProxyingQueue"===t.data.cmd?s?e.executeNotifiedProxyingQueue(t.data.queue):n.push(t.data.queue):(i("worker.js received unknown command "+t.data.cmd),i(t.data)))}catch(t){throw i("worker.js onmessage() captured an uncaught exception: "+t),t&&t.stack&&i(t.stack),e.__emscripten_thread_crashed&&e.__emscripten_thread_crashed(),t}};\n'},7067:()=>{},1296:()=>{},760:()=>{},1384:()=>{},3993:()=>{},908:()=>{},6953:()=>{},9925:()=>{},2806:()=>{},6449:()=>{},2850:()=>{},5381:()=>{},5686:(e,t,n)=>{"use strict";n.r(t),n.d(t,{flatbuffers:()=>r});var r={};r.Offset,r.Table,r.SIZEOF_SHORT=2,r.SIZEOF_INT=4,r.FILE_IDENTIFIER_LENGTH=4,r.SIZE_PREFIX_LENGTH=4,r.Encoding={UTF8_BYTES:1,UTF16_STRING:2},r.int32=new Int32Array(2),r.float32=new Float32Array(r.int32.buffer),r.float64=new Float64Array(r.int32.buffer),r.isLittleEndian=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0],r.Long=function(e,t){this.low=0|e,this.high=0|t},r.Long.create=function(e,t){return 0==e&&0==t?r.Long.ZERO:new r.Long(e,t)},r.Long.prototype.toFloat64=function(){return(this.low>>>0)+4294967296*this.high},r.Long.prototype.equals=function(e){return this.low==e.low&&this.high==e.high},r.Long.ZERO=new r.Long(0,0),r.Builder=function(e){if(e)t=e;else var t=1024;this.bb=r.ByteBuffer.allocate(t),this.space=t,this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},r.Builder.prototype.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1},r.Builder.prototype.forceDefaults=function(e){this.force_defaults=e},r.Builder.prototype.dataBuffer=function(){return this.bb},r.Builder.prototype.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},r.Builder.prototype.prep=function(e,t){e>this.minalign&&(this.minalign=e);for(var n=1+~(this.bb.capacity()-this.space+t)&e-1;this.space=0&&0==this.vtable[t];t--);for(var n=t+1;t>=0;t--)this.addInt16(0!=this.vtable[t]?e-this.vtable[t]:0);this.addInt16(e-this.object_start);var o=(n+2)*r.SIZEOF_SHORT;this.addInt16(o);var i=0,a=this.space;e:for(t=0;t=0;a--)this.writeInt8(i.charCodeAt(a))}this.prep(this.minalign,r.SIZEOF_INT+o),this.addOffset(e),o&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},r.Builder.prototype.finishSizePrefixed=function(e,t){this.finish(e,t,!0)},r.Builder.prototype.requiredField=function(e,t){var n=this.bb.capacity()-e,r=n-this.bb.readInt32(n);if(0==this.bb.readInt16(r+t))throw new Error("FlatBuffers: field "+t+" must be set")},r.Builder.prototype.startVector=function(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(r.SIZEOF_INT,e*t),this.prep(n,e*t)},r.Builder.prototype.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},r.Builder.prototype.createString=function(e){if(e instanceof Uint8Array)var t=e;else{t=[];for(var n=0;n=56320?o:(o<<10)+e.charCodeAt(n++)+-56613888)<128?t.push(r):(r<2048?t.push(r>>6&31|192):(r<65536?t.push(r>>12&15|224):t.push(r>>18&7|240,r>>12&63|128),t.push(r>>6&63|128)),t.push(63&r|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),n=0;for(var i=this.space,a=this.bb.bytes();n>24},r.ByteBuffer.prototype.readUint8=function(e){return this.bytes_[e]},r.ByteBuffer.prototype.readInt16=function(e){return this.readUint16(e)<<16>>16},r.ByteBuffer.prototype.readUint16=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8},r.ByteBuffer.prototype.readInt32=function(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24},r.ByteBuffer.prototype.readUint32=function(e){return this.readInt32(e)>>>0},r.ByteBuffer.prototype.readInt64=function(e){return new r.Long(this.readInt32(e),this.readInt32(e+4))},r.ByteBuffer.prototype.readUint64=function(e){return new r.Long(this.readUint32(e),this.readUint32(e+4))},r.ByteBuffer.prototype.readFloat32=function(e){return r.int32[0]=this.readInt32(e),r.float32[0]},r.ByteBuffer.prototype.readFloat64=function(e){return r.int32[r.isLittleEndian?0:1]=this.readInt32(e),r.int32[r.isLittleEndian?1:0]=this.readInt32(e+4),r.float64[0]},r.ByteBuffer.prototype.writeInt8=function(e,t){this.bytes_[e]=t},r.ByteBuffer.prototype.writeUint8=function(e,t){this.bytes_[e]=t},r.ByteBuffer.prototype.writeInt16=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8},r.ByteBuffer.prototype.writeUint16=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8},r.ByteBuffer.prototype.writeInt32=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24},r.ByteBuffer.prototype.writeUint32=function(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24},r.ByteBuffer.prototype.writeInt64=function(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)},r.ByteBuffer.prototype.writeUint64=function(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)},r.ByteBuffer.prototype.writeFloat32=function(e,t){r.float32[0]=t,this.writeInt32(e,r.int32[0])},r.ByteBuffer.prototype.writeFloat64=function(e,t){r.float64[0]=t,this.writeInt32(e,r.int32[r.isLittleEndian?0:1]),this.writeInt32(e+4,r.int32[r.isLittleEndian?1:0])},r.ByteBuffer.prototype.getBufferIdentifier=function(){if(this.bytes_.length>10),56320+(1023&a)))}return o},r.ByteBuffer.prototype.__indirect=function(e){return e+this.readInt32(e)},r.ByteBuffer.prototype.__vector=function(e){return e+this.readInt32(e)+r.SIZEOF_INT},r.ByteBuffer.prototype.__vector_len=function(e){return this.readInt32(e+this.readInt32(e))},r.ByteBuffer.prototype.__has_identifier=function(e){if(e.length!=r.FILE_IDENTIFIER_LENGTH)throw new Error("FlatBuffers: file identifier must be length "+r.FILE_IDENTIFIER_LENGTH);for(var t=0;t{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(1057);return __webpack_exports__})())); diff --git a/Audio-Transcription/popup.css b/Audio-Transcription/popup.css deleted file mode 100644 index 7995e5e..0000000 --- a/Audio-Transcription/popup.css +++ /dev/null @@ -1,89 +0,0 @@ -body, h2 { - font-family: Ubuntu, sans-serif; -} - -body { - margin: 10px 15px 5px 15px; -} - -#status, #timeRem { - margin: 10px auto; - text-align: center; - font-size: 20px; - white-space: nowrap; -} - -.header { - display: flex; - align-items: center; - padding-bottom: 15px; - border-bottom: 2px solid darkred; - white-space: nowrap; -} - -.header img { - height: 64px; - margin: 0 20px 0 0; -} - -ul { - font-size: 16px; - font-weight: bold; - list-style: none; - padding: 0; -} - -li { - font-size: 14px; - font-weight: normal; - white-space: nowrap; - margin: 0 0 0 5px; -} - -.extra { - font-family: sans-serif; - white-space: nowrap; - font-style: italic; - margin: 3px; -} - -.links { - display: flex; - align-items: center; - justify-content: space-between; - font-family: sans-serif; -} - -.links p { - color: blue; - text-decoration: underline; - cursor: pointer; -} - -.buttonContainer { - display: flex; - justify-content: space-around; -} - -.button { - display: none; - text-align: center; - padding: 10px; - border: 2px solid darkred; - font-size: 16px; - font-weight: bold; - cursor: pointer; - background-color: lavenderblush; - border-radius: 5px; -} - -.button:hover { - color: red; - background-color: darkred; -} - -.notes { - padding: 10px; - font-size: 12px; - white-space: pre; -} diff --git a/Audio-Transcription/popup.html b/Audio-Transcription/popup.html index 6175d7f..b961819 100644 --- a/Audio-Transcription/popup.html +++ b/Audio-Transcription/popup.html @@ -1,29 +1,15 @@ + - - Audio Transcription - - - - -

Audio Transcription

-
-
-
-
Start Capture
-
Save Capture
-
Cancel Capture
-
-
After capture is finished, a new tab will be opened automatically for you to -name and save the file. Please do not close the tab before saving the file!
-
    Hotkeys: -
  • Ctrl/Command + Shift + to start capture on current tab
  • -
  • Ctrl/Command + Shift + X to stop capture on current tab
  • -
-

Hotkeys may not work if another extension is using the same hotkeys

-

Currently the max capture time is 20 minutes due to Chrome memory contraints

- - - + + Audio Capture + + + + +

Audio Transcription

+
+
Start Capture
+
Stop Capture
+
+ + \ No newline at end of file diff --git a/Audio-Transcription/popup.js b/Audio-Transcription/popup.js index f4bef18..a1fe516 100644 --- a/Audio-Transcription/popup.js +++ b/Audio-Transcription/popup.js @@ -1,145 +1,70 @@ -let interval; -let timeLeft; +// Wait for the DOM content to be fully loaded +document.addEventListener("DOMContentLoaded", function () { + const startButton = document.getElementById("startCapture"); + const stopButton = document.getElementById("stopCapture"); -const displayStatus = function() { //function to handle the display of time and buttons - chrome.tabs.query({active: true, currentWindow: true}, (tabs) => { - const status = document.getElementById("status"); - const timeRem = document.getElementById("timeRem"); - const startButton = document.getElementById('start'); - const finishButton = document.getElementById('finish'); - const cancelButton = document.getElementById('cancel'); - //CODE TO BLOCK CAPTURE ON YOUTUBE, DO NOT DELETE - // if(tabs[0].url.toLowerCase().includes("youtube")) { - // status.innerHTML = "Capture is disabled on this site due to copyright"; - // } else { - chrome.runtime.sendMessage({currentTab: tabs[0].id}, (response) => { - if(response) { - chrome.storage.sync.get({ - maxTime: 1200000, - limitRemoved: false - }, (options) => { - if(options.maxTime > 1200000) { - chrome.storage.sync.set({ - maxTime: 1200000 - }); - timeLeft = 1200000 - (Date.now() - response) - } else { - timeLeft = options.maxTime - (Date.now() - response) - } - status.innerHTML = "Tab is currently being captured"; - if(options.limitRemoved) { - timeRem.innerHTML = `${parseTime(Date.now() - response)}`; - interval = setInterval(() => { - timeRem.innerHTML = `${parseTime(Date.now() - response)}`; - }); - } else { - timeRem.innerHTML = `${parseTime(timeLeft)} remaining`; - interval = setInterval(() => { - timeLeft = timeLeft - 1000; - timeRem.innerHTML = `${parseTime(timeLeft)} remaining`; - }, 1000); - } - }); - finishButton.style.display = "block"; - cancelButton.style.display = "block"; - } else { - startButton.style.display = "block"; - } - }); - // } - }); -} + // Add click event listeners to the buttons + startButton.addEventListener("click", startCapture); + stopButton.addEventListener("click", stopCapture); -const parseTime = function(time) { //function to display time remaining or time elapsed - let minutes = Math.floor((time/1000)/60); - let seconds = Math.floor((time/1000) % 60); - if (minutes < 10 && minutes >= 0) { - minutes = '0' + minutes; - } else if (minutes < 0) { - minutes = '00'; - } - if (seconds < 10 && seconds >= 0) { - seconds = '0' + seconds; - } else if (seconds < 0) { - seconds = '00'; - } - return `${minutes}:${seconds}` -} - -//manipulation of the displayed buttons upon message from background -chrome.runtime.onMessage.addListener((request, sender) => { - chrome.tabs.query({active: true, currentWindow: true}, (tabs) => { - const status = document.getElementById("status"); - const timeRem = document.getElementById("timeRem"); - const buttons = document.getElementById("buttons"); - const startButton = document.getElementById('start'); - const finishButton = document.getElementById('finish'); - const cancelButton = document.getElementById('cancel'); - if(request.captureStarted && request.captureStarted === tabs[0].id) { - chrome.storage.sync.get({ - maxTime: 1200000, - limitRemoved: false - }, (options) => { - if(options.maxTime > 1200000) { - chrome.storage.sync.set({ - maxTime: 1200000 - }); - timeLeft = 1200000 - (Date.now() - request.startTime) - } else { - timeLeft = options.maxTime - (Date.now() - request.startTime) - } - status.innerHTML = "Tab is currently being captured"; - if(options.limitRemoved) { - timeRem.innerHTML = `${parseTime(Date.now() - request.startTime)}`; - interval = setInterval(() => { - timeRem.innerHTML = `${parseTime(Date.now() - request.startTime)}` - }, 1000); - } else { - timeRem.innerHTML = `${parseTime(timeLeft)} remaining`; - interval = setInterval(() => { - timeLeft = timeLeft - 1000; - timeRem.innerHTML = `${parseTime(timeLeft)} remaining`; - }, 1000); - } - }); - finishButton.style.display = "block"; - cancelButton.style.display = "block"; - startButton.style.display = "none"; - } else if(request.captureStopped && request.captureStopped === tabs[0].id) { - status.innerHTML = ""; - finishButton.style.display = "none"; - cancelButton.style.display = "none"; - startButton.style.display = "block"; - timeRem.innerHTML = ""; - clearInterval(interval); - } - }); -}); - - -//initial display for popup menu when opened -document.addEventListener('DOMContentLoaded', function() { - displayStatus(); - const startKey = document.getElementById("startKey"); - const endKey = document.getElementById("endKey"); - const startButton = document.getElementById('start'); - const finishButton = document.getElementById('finish'); - const cancelButton = document.getElementById('cancel'); - startButton.onclick = () => {chrome.runtime.sendMessage("startCapture")}; - finishButton.onclick = () => {chrome.runtime.sendMessage("stopCapture")}; - cancelButton.onclick = () => {chrome.runtime.sendMessage("cancelCapture")}; - chrome.runtime.getPlatformInfo((info) => { - if(info.os === "mac") { - startKey.innerHTML = "Command + Shift + U to start capture on current tab"; - endKey.innerHTML = "Command + Shift + X to stop capture on current tab"; + // Retrieve capturing state from storage on popup open + chrome.storage.local.get("capturingState", ({ capturingState }) => { + if (capturingState && capturingState.isCapturing) { + toggleCaptureButtons(true); } else { - startKey.innerHTML = "Ctrl + Shift + S to start capture on current tab"; - endKey.innerHTML = "Ctrl + Shift + X to stop capture on current tab"; + toggleCaptureButtons(false); } - }) - const options = document.getElementById("options"); - options.onclick = () => {chrome.runtime.openOptionsPage()}; - const git = document.getElementById("GitHub"); - git.onclick = () => {chrome.tabs.create({url: "https://github.com/arblast/Chrome-Audio-Capturer"})}; + }); -}); + // Function to handle the start capture button click event + async function startCapture() { + // Ignore click if the button is disabled + if (startButton.disabled) { + return; + } + + // Get the current active tab + const currentTab = await getCurrentTab(); + + // Send a message to the background script to start capturing + chrome.runtime.sendMessage({ action: "startCapture", tabId: currentTab.id }, () => { + // Update capturing state in storage and toggle the buttons + chrome.storage.local.set({ capturingState: { isCapturing: true } }, () => { + toggleCaptureButtons(true); + }); + }); + } + + // Function to handle the stop capture button click event + function stopCapture() { + // Ignore click if the button is disabled + if (stopButton.disabled) { + return; + } + + // Send a message to the background script to stop capturing + chrome.runtime.sendMessage({ action: "stopCapture" }, () => { + // Update capturing state in storage and toggle the buttons + chrome.storage.local.set({ capturingState: { isCapturing: false } }, () => { + toggleCaptureButtons(false); + }); + }); + } + + // Function to get the current active tab + async function getCurrentTab() { + return new Promise((resolve) => { + chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { + resolve(tabs[0]); + }); + }); + } + + // Function to toggle the capture buttons based on the capturing state + function toggleCaptureButtons(isCapturing) { + startButton.disabled = isCapturing; + stopButton.disabled = !isCapturing; + startButton.classList.toggle("disabled", isCapturing); + stopButton.classList.toggle("disabled", !isCapturing); + } +}); \ No newline at end of file diff --git a/Audio-Transcription/options.css b/Audio-Transcription/style.css similarity index 83% rename from Audio-Transcription/options.css rename to Audio-Transcription/style.css index aad1975..c1c56ca 100644 --- a/Audio-Transcription/options.css +++ b/Audio-Transcription/style.css @@ -54,20 +54,29 @@ label { margin-left: 15px; } +.button-container { + display: flex; + justify-content: space-between; + padding: 10px; +} + .button { padding: 10px; border: 2px solid darkred; font-size: 16px; - background-color: lavenderblush; font-weight: bold; - margin: 10px 20px; cursor: pointer; white-space: nowrap; - width: 110px; + width: 150px; border-radius: 5px; } -.button:hover { +.disabled { + opacity: 0.6; + cursor: not-allowed; +} + +.button:hover:not(:disabled) { color: red; background-color: darkred; } diff --git a/Audio-Transcription/worker.js b/Audio-Transcription/worker.js deleted file mode 100644 index 2406a6b..0000000 --- a/Audio-Transcription/worker.js +++ /dev/null @@ -1,148 +0,0 @@ -let recLength = 0, - recBuffers = [], - sampleRate, - numChannels; - -onmessage = function(e) { - switch (e.data.command) { - case 'init': - init(e.data.config); - break; - case 'record': - record(e.data.buffer); - break; - case 'exportWAV': - exportWAV(e.data.type); - break; - case 'getBuffer': - getBuffer(); - break; - case 'clear': - clear(); - break; - } -}; - -function init(config) { - sampleRate = config.sampleRate; - numChannels = config.numChannels; - initBuffers(); -} - -function record(inputBuffer) { - for (var channel = 0; channel < numChannels; channel++) { - recBuffers[channel].push(inputBuffer[channel]); - } - recLength += inputBuffer[0].length; -} - -function exportWAV(type) { - let buffers = []; - for (let channel = 0; channel < numChannels; channel++) { - buffers.push(mergeBuffers(recBuffers[channel], recLength)); - } - let interleaved; - if (numChannels === 2) { - interleaved = interleave(buffers[0], buffers[1]); - } else { - interleaved = buffers[0]; - } - let dataview = encodeWAV(interleaved); - let audioBlob = new Blob([dataview], {type: type}); - - this.postMessage({command: 'exportWAV', data: audioBlob}); -} - -function getBuffer() { - let buffers = []; - for (let channel = 0; channel < numChannels; channel++) { - buffers.push(mergeBuffers(recBuffers[channel], recLength)); - } - this.postMessage({command: 'getBuffer', data: buffers}); -} - -function clear() { - recLength = 0; - recBuffers = []; - initBuffers(); -} - -function initBuffers() { - for (let channel = 0; channel < numChannels; channel++) { - recBuffers[channel] = []; - } -} - -function mergeBuffers(recBuffers, recLength) { - let result = new Float32Array(recLength); - let offset = 0; - for (let i = 0; i < recBuffers.length; i++) { - result.set(recBuffers[i], offset); - offset += recBuffers[i].length; - } - return result; -} - -function interleave(inputL, inputR) { - let length = inputL.length + inputR.length; - let result = new Float32Array(length); - - let index = 0, - inputIndex = 0; - - while (index < length) { - result[index++] = inputL[inputIndex]; - result[index++] = inputR[inputIndex]; - inputIndex++; - } - return result; -} - -function floatTo16BitPCM(output, offset, input) { - for (let i = 0; i < input.length; i++, offset += 2) { - let s = Math.max(-1, Math.min(1, input[i])); - output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true); - } -} - -function writeString(view, offset, string) { - for (let i = 0; i < string.length; i++) { - view.setUint8(offset + i, string.charCodeAt(i)); - } -} - -function encodeWAV(samples) { - let buffer = new ArrayBuffer(44 + samples.length * 2); - let view = new DataView(buffer); - - /* RIFF identifier */ - writeString(view, 0, 'RIFF'); - /* RIFF chunk length */ - view.setUint32(4, 36 + samples.length * 2, true); - /* RIFF type */ - writeString(view, 8, 'WAVE'); - /* format chunk identifier */ - writeString(view, 12, 'fmt '); - /* format chunk length */ - view.setUint32(16, 16, true); - /* sample format (raw) */ - view.setUint16(20, 1, true); - /* channel count */ - view.setUint16(22, numChannels, true); - /* sample rate */ - view.setUint32(24, sampleRate, true); - /* byte rate (sample rate * block align) */ - view.setUint32(28, sampleRate * 4, true); - /* block align (channel count * bytes per sample) */ - view.setUint16(32, numChannels * 2, true); - /* bits per sample */ - view.setUint16(34, 16, true); - /* data chunk identifier */ - writeString(view, 36, 'data'); - /* data chunk length */ - view.setUint32(40, samples.length * 2, true); - - floatTo16BitPCM(view, 44, samples); - - return view; -} diff --git a/Audio-Transcription/workers/Mp3Worker.js b/Audio-Transcription/workers/Mp3Worker.js deleted file mode 100644 index 56814b2..0000000 --- a/Audio-Transcription/workers/Mp3Worker.js +++ /dev/null @@ -1,106 +0,0 @@ -importScripts("/../encoders/Mp3Encoder.min.js"); - -let NUM_CH = 2, // constant - sampleRate = 16000, - options = undefined, - maxBuffers = undefined, - encoder = undefined, - recBuffers = undefined, - socket = undefined, - bufferCount = 0; - -function error(message) { - self.postMessage({ command: "error", message: "mp3: " + message }); -} - -function init(data) { - if (data.config.numChannels === NUM_CH) { - sampleRate = data.config.sampleRate; - options = data.options; - } else - error("numChannels must be " + NUM_CH); -}; - -function setOptions(opt) { - if (encoder || recBuffers) - error("cannot set options during recording"); - else - options = opt; -} - -function start(bufferSize) { - maxBuffers = Math.ceil(options.timeLimit * sampleRate / bufferSize); - // TODO: get server address from user - socket = new WebSocket("ws://localhost:9090/"); - socket.onopen = function(e) { - socket.send("handshake"); - }; - socket.onmessage = (event) => { - self.postMessage({ command: "transcription", text: event.data}); - }; - - if (options.encodeAfterRecord) - recBuffers = []; - else - encoder = new Mp3LameEncoder(sampleRate, options.mp3.bitRate); -} - -function record(buffer) { - if (bufferCount++ < maxBuffers){ - if (encoder) - encoder.encode(buffer); - else - recBuffers.push(buffer); - - // send buffer to server - socket.send(buffer[0]); - } - else - self.postMessage({ command: "timeout" }); -}; - -function postProgress(progress) { - self.postMessage({ command: "progress", progress: progress }); -}; - -function finish() { - if (recBuffers) { - postProgress(0); - encoder = new Mp3LameEncoder(sampleRate, options.mp3.bitRate); - let timeout = Date.now() + options.progressInterval; - while (recBuffers.length > 0) { - encoder.encode(recBuffers.shift()); - let now = Date.now(); - if (now > timeout) { - postProgress((bufferCount - recBuffers.length) / bufferCount); - timeout = now + options.progressInterval; - } - } - postProgress(1); - } - self.postMessage({ - command: "complete", - blob: encoder.finish(options.mp3.mimeType) - }); - cleanup(); -}; - -function cleanup() { - encoder = recBuffers = undefined; - bufferCount = 0; - socket.close(); -} - -self.onmessage = function(event) { - let data = event.data; - switch (data.command) { - case "init": init(data); break; - case "options": setOptions(data.options); break; - case "start": start(data.bufferSize); break; - case "record": record(data.buffer); break; - case "finish": finish(); break; - case "cancel": cleanup(); - } -}; - -self.postMessage({ command: "loaded" }); diff --git a/Audio-Transcription/workers/WavWorker.js b/Audio-Transcription/workers/WavWorker.js deleted file mode 100644 index 84aaadd..0000000 --- a/Audio-Transcription/workers/WavWorker.js +++ /dev/null @@ -1,105 +0,0 @@ -importScripts("/../encoders/WavEncoder.min.js"); - - -let sampleRate = 16000, - numChannels = 2, - options = undefined, - maxBuffers = undefined, - encoder = undefined, - recBuffers = undefined, - socket = undefined, - bufferCount = 0; - -function error(message) { - self.postMessage({ command: "error", message: "wav: " + message }); -} - -function init(data) { - sampleRate = data.config.sampleRate; - numChannels = data.config.numChannels; - options = data.options; -}; - -function setOptions(opt) { - if (encoder || recBuffers) - error("cannot set options during recording"); - else - options = opt; -} - -function start(bufferSize) { - maxBuffers = Math.ceil(options.timeLimit * sampleRate / bufferSize); - // TODO: get server address from user - socket = new WebSocket("ws://localhost:9090/"); - socket.onopen = function(e) { - socket.send("handshake"); - }; - socket.onmessage = (event) => { - self.postMessage({ command: "transcription", text: event.data}); - }; - - if (options.encodeAfterRecord) - recBuffers = []; - else - encoder = new WavAudioEncoder(sampleRate, numChannels); -} - -function record(buffer) { - if (bufferCount++ < maxBuffers){ - if (encoder) - encoder.encode(buffer); - else if(recBuffers) - recBuffers.push(buffer); - - // send buffer to server - socket.send(buffer[0]); - } - else - self.postMessage({ command: "timeout" }); -}; - -function postProgress(progress) { - self.postMessage({ command: "progress", progress: progress }); -}; - -function finish() { - if (recBuffers) { - postProgress(0); - encoder = new WavAudioEncoder(sampleRate, numChannels); - var timeout = Date.now() + options.progressInterval; - while (recBuffers.length > 0) { - encoder.encode(recBuffers.shift()); - var now = Date.now(); - if (now > timeout) { - postProgress((bufferCount - recBuffers.length) / bufferCount); - timeout = now + options.progressInterval; - } - } - postProgress(1); - } - self.postMessage({ - command: "complete", - blob: encoder.finish(options.wav.mimeType) - }); - cleanup(); -}; - -function cleanup() { - encoder = recBuffers = undefined; - bufferCount = 0; - socket.close(); -} - -self.onmessage = function(event) { - var data = event.data; - switch (data.command) { - case "init": init(data); break; - case "options": setOptions(data.options); break; - case "start": start(data.bufferSize); break; - case "record": record(data.buffer); break; - case "finish": finish(); break; - case "cancel": cleanup(); - } -}; - -self.postMessage({ command: "loaded" }); diff --git a/Audio-Transcription/LICENSE b/LICENSE similarity index 94% rename from Audio-Transcription/LICENSE rename to LICENSE index 5a82679..375556f 100644 --- a/Audio-Transcription/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Justice Yen +Copyright (c) 2023 Vineet Suryan, Collabora Ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file