diff --git a/dist/manifest.json b/dist/manifest.json index 01a2395..aa48c25 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -1,9 +1,11 @@ { "name": "DeepL Crack", - "version": "1.1.8", + "version": "1.2.3", "description": "Unlock DeepL Pro features: character limit, document editing", "manifest_version": 3, - "action": {}, + "action": { + "default_popup": "popup.html" + }, "declarative_net_request": { "rule_resources": [ { @@ -38,8 +40,7 @@ ], "permissions": [ "declarativeNetRequest", - "cookies", - "webNavigation" + "cookies" ], "host_permissions": [ "*://*.deepl.com/*" diff --git a/dist/redirect.json b/dist/redirect.json index 45df34e..157eebc 100644 --- a/dist/redirect.json +++ b/dist/redirect.json @@ -5,7 +5,7 @@ "action": { "type": "redirect", "redirect": { - "url": "https://serverless.blueagle.top/deepl-crack/get-client-state" + "url": "https://v1-cf-api.blueagle.top/deepl-crack/get-client-state" } }, "condition": { diff --git a/package.json b/package.json index 36dba02..cae7576 100644 --- a/package.json +++ b/package.json @@ -2,44 +2,50 @@ "name": "deepl-crack", "license": "GPL-3.0", "description": "A browser extension to crack DeepL's 5000 characters limit and unlock editing restrictions", - "version": "1.1.8", + "version": "1.2.3", "scripts": { "build": "rollup --config rollup.config.prod.mjs && rollup --config rollup.config.background.prod.mjs", "dev": "rollup --config rollup.config.dev.mjs && rollup --config rollup.config.background.dev.mjs", - "validate": "deno run --allow-write --allow-read --allow-net ./deepl-api-validator.js" + "validate": "deno run --allow-write --allow-read --allow-net ./deepl-api-validator.ts" }, "dependencies": { - "@emotion/react": "^11.10.5", - "@emotion/styled": "^11.10.5", - "@mui/icons-material": "^5.10.16", - "@mui/material": "^5.10.17", + "@emotion/react": "^11.11.1", + "@emotion/styled": "^11.11.0", + "@mui/icons-material": "^5.11.16", + "@mui/material": "^5.13.5", + "@mui/x-data-grid-premium": "6.7.0", + "@mui/x-license-pro": "6.6.0", + "byte-guide": "^1.0.7", "jszip": "^3.10.1", "localforage": "^1.10.0", - "mobx": "^6.7.0", - "mobx-persist-store": "^1.1.2", - "mobx-react": "^7.6.0", - "notistack": "3.0.0-alpha.11", - "preact": "^10.11.3", - "pretty-bytes": "^6.0.0", + "mobx": "^6.9.0", + "mobx-persist-store": "^1.1.3", + "mobx-react": "^8.0.0", + "notistack": "3.0.1", + "preact": "^10.15.1", + "pretty-bytes": "^6.1.0", "random-useragent": "0.5.0", - "react-transition-group": "^4.4.5" + "react": "18.2.0", + "react-dom": "18.2.0" }, "devDependencies": { - "@babel/core": "7.20.7", - "@babel/preset-react": "^7.18.6", - "@emotion/babel-plugin": "^11.10.5", - "@rollup/plugin-alias": "4.0.2", + "@babel/core": "7.22.5", + "@babel/preset-react": "^7.22.5", + "@emotion/babel-plugin": "^11.11.0", + "@rollup/plugin-alias": "5.0.0", "@rollup/plugin-babel": "^6.0.3", - "@rollup/plugin-commonjs": "23.0.4", + "@rollup/plugin-commonjs": "25.0.1", "@rollup/plugin-json": "^6.0.0", - "@rollup/plugin-node-resolve": "^15.0.1", - "@rollup/plugin-replace": "^5.0.1", - "@rollup/plugin-terser": "0.2.0", - "@types/babel__core": "^7.1.20", + "@rollup/plugin-node-resolve": "^15.1.0", + "@rollup/plugin-replace": "^5.0.2", + "@rollup/plugin-terser": "0.4.3", + "@types/babel__core": "^7.20.1", "@types/random-useragent": "^0.3.1", + "@types/react": "^18.2.12", + "@types/react-dom": "^18.2.5", "babel-plugin-transform-imports": "^2.0.0", - "esbuild": "^0.16.2", - "rollup": "3.7.1-0", + "esbuild": "^0.18.2", + "rollup": "3.25.1", "rollup-plugin-esbuild": "^5.0.0", "rollup-plugin-worker": "^3.0.4" } diff --git a/src/App.jsx b/src/App.jsx index 7fe45d2..448122c 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,32 +1,18 @@ -import { memo, useEffect, useCallback, useState } from 'react' - - -import CookieIcon from '@mui/icons-material/Cookie'; -import TipsAndUpdates from '@mui/icons-material/TipsAndUpdates'; - -import Document from 'components/document'; -import Annoumcement from 'components/annoumcement'; -import Btns from 'components/Btns'; -import GlobalStyle from 'components/GlobalStyle'; -import Token from 'components/token'; -import Sponsor from 'components/Sponsor'; - -import store from 'store'; +import { memo } from 'react' import { createTheme, ThemeProvider } from '@mui/material/styles'; +import { SnackbarProvider } from 'notistack'; +import { LicenseInfo } from '@mui/x-license-pro'; -import { useLocalObservable, Observer } from 'mobx-react'; -import { SnackbarProvider, enqueueSnackbar } from 'notistack'; -import { cleanCookies, waitForSelector, sendMessage } from "utils"; -import api, { generateUpdateBtn } from "utils/api"; -import FolderIcon from '@mui/icons-material/Folder'; -import Loading from 'components/Loading'; -import GlobalStyles from '@mui/material/GlobalStyles'; -import DarkModeIcon from '@mui/icons-material/DarkMode'; -import LightModeIcon from '@mui/icons-material/LightMode'; -import { observe } from 'mobx'; -import TokenIcon from '@mui/icons-material/Token'; +import DocumentsManager from './components/DocumentsManager'; +import Announcements from './components/Announcements'; +import Banners from './components/Banners'; +import GlobalStyle from './components/GlobalStyle'; +import TokensAndCredentialsManager from './components/TokensAndCredentialsManager'; +import Sponsor from './components/Sponsor'; +import Loading from './components/Loading'; +import Guide from './components/Guide'; -import { proxy, unproxy } from "proxy"; +LicenseInfo.setLicenseKey("63cdcff003c86a961f1b47b5703dd5e0Tz0wLEU9MjUzNDA0ODY0MDAwMDAwLFM9cHJlbWl1bSxMTT1zdWJzY3JpcHRpb24sS1Y9Mg=="); const theme = createTheme({ palette: { @@ -45,196 +31,18 @@ const theme = createTheme({ } }); -const DarkModeStyle = ; - -function handleDomModifier(domModifier) { - for (const { selector, enabled, type, options } of domModifier ?? []) { - if (enabled) { - const handler = { - replaceContent: (el, { html }) => { - el.innerHTML = html; - }, - insertAdjacentHTML: (el, { html, location }) => { - el.insertAdjacentHTML(location, html); - }, - remove: (el) => { - el.remove(); - }, - setAttribute: (el, { attr, value }) => { - el.setAttribute(attr, value); - } - }[type]; - if (handler) { - (async function () { - handler(await waitForSelector(selector), options) - })() - } - } - } -} - -async function getDomModifier() { - let domModifier = []; - if (Date.now() - store.cacheStore.getPersistCache('lastGetDomModifier') < 10800000) { - domModifier = store.configStore.getDomModifier; - } else { - try { - domModifier = await api.getDomModifier(); - store.cacheStore.setPersistCache('lastGetDomModifier', Date.now()); - } catch (error) { - domModifier = store.configStore.getDomModifier; - enqueueSnackbar(`Get dom modifier failed: ${error.message}`, { variant: 'error' }) - } - } - handleDomModifier(domModifier); -} - -async function checkUpdate() { - if (Date.now() - store.cacheStore.getPersistCache('lastUpdateCheck') < 300000) return; - try { - const update = await api.getUpdate(); - if (update.available) { - enqueueSnackbar(`Update available: ${update.version}!`, { variant: 'info', action: () => generateUpdateBtn(update.url), }) - } - store.cacheStore.setPersistCache('lastUpdateCheck', Date.now()); - } catch (error) { - enqueueSnackbar(`Update check failed: ${error.message}`, { variant: 'error' }) - } -} - -async function loadRemoteScript() { - if (Date.now() - store.cacheStore.getPersistCache('lastGetRemoteScript') < 10800000) { - setTimeout(store.cacheStore.getPersistCache('remoteScript'), 0); - } else { - try { - const code = await sendMessage({ - method: 'proxyFetch', - params: { - url: `${process.env.NODE_ENV === 'development' ? "http://127.0.0.1:3001" : "https://serverless.blueagle.top"}/static/deepl-crack/remote-script.js`, - config: {} - } - }); - setTimeout(code, 0); - store.cacheStore.setPersistCache('lastGetRemoteScript', Date.now()); - store.cacheStore.setPersistCache('remoteScript', code); - } catch (error) { - if (store.cacheStore.getPersistCache('remoteScript')) { - setTimeout(store.cacheStore.getPersistCache('remoteScript'), 0); - } - enqueueSnackbar(`Get remote script failed: ${error.message}`, { variant: 'error' }) - } - } -} - -function App() { - - const [darkMode, setDarkMode] = useState(localStorage.getItem('darkMode') === 'true' ? true : false); - - const configStore = useLocalObservable(() => store.configStore); - const tokenStore = useLocalObservable(() => store.tokenStore); - - const handleToggleDocumentWindow = useCallback(() => store.windowStore.toggleDocumentWindow(), []); - const handleToggleAnnouncementWindow = useCallback(() => store.windowStore.toggleAnnouncementWindow(), []); - const handleToggleTokenWindow = useCallback(() => store.windowStore.toggleTokenWindow(), []); - const handleToggleDarkMode = useCallback(() => { - const value = !darkMode; - setDarkMode(value); - localStorage.setItem('darkMode', `${value}`); - }, [darkMode]); - const handleCleanCookies = useCallback(() => { - try { - cleanCookies() - } catch (error) { - enqueueSnackbar(error.message, { variant: 'error' }) - } - }, []); - - useEffect(() => { - const isHydratedListener = observe(configStore, 'isHydrated', ({ newValue }) => { - if (newValue) { - checkUpdate(); - loadRemoteScript(); - getDomModifier(); - isHydratedListener(); - } - }); - - const getAvailableListener = observe(configStore, 'getAvailable', ({ newValue }) => { - if (newValue) { - proxy(); - } else { - unproxy() - } - }); - - const visibleListener = document.addEventListener('visibilitychange', () => { - if (document.visibilityState === 'visible') { - checkUpdate(); - } - }) - - return () => { - getAvailableListener(); - isHydratedListener(); - document.removeEventListener('visibilitychange', visibleListener); - } - }, []) - +export default memo(function () { return ( - {darkMode && DarkModeStyle} - - {() => - , - onClick: handleToggleAnnouncementWindow, - show: (configStore.getAnnouncements ?? []).length > 0 - }, - { - label: 'Documents', - icon: , - onClick: handleToggleDocumentWindow, - show: true - }, - { - label: tokenStore.getActiveToken ? tokenStore.getActiveToken?.type === 'pro-session' ? 'Using Pro Account Session' : 'Using DeepL Api Free Token' : 'Tokens', - icon: , - onClick: handleToggleTokenWindow, - bounce: Boolean(tokenStore.getActiveToken), - show: true - }, - { - label: darkMode ? 'Light Mode' : 'Dark Mode', - icon: darkMode ? : , - onClick: handleToggleDarkMode, - show: true - }, - { - label: 'Clean Cookies', - icon: , - onClick: handleCleanCookies, - show: true - } - ]} - /> - } - - - + + + + + + ) -} - -export default memo(App, () => true); +}, () => true) diff --git a/src/background/index.js b/src/background/index.js index 9aee993..e845464 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -63,43 +63,41 @@ async function setHeader() { if (!id || (!regexFilter && !urlFilter)) { throw new Error('Missing required parameters'); } + const [IP, UA, COOKIE] = [ + ip || randomIp(), + userAgent || randomUserAgent((ua) => { + return /(Windows|Macintosh|Linux|Android|iPhone|iPad)/.test(ua.osName) && !/Legacy/.test(ua.folder); + }), + cookie || await generateCookie() + ]; const action = { type: "modifyHeaders", requestHeaders: [ { "header": "User-Agent", "operation": "set", - "value": userAgent || randomUserAgent() + "value": UA }, { "header": "Cookie", "operation": "set", - "value": cookie || await generateCookie() - }, - { - "header": "Sec-CH-UA", - "operation": "remove" - }, - { - "header": "Sec-CH-UA-Mobile", - "operation": "remove" - }, - { - "header": "Sec-CH-UA-Platform", - "operation": "remove" - }, - { - "header": "X-Forwarded-For", - "operation": "set", - "value": ip || randomIp() - }, - { - "header": "CF-Connecting-IP", - "operation": "set", - "value": ip || randomIp() + "value": COOKIE } ] }; + ["Sec-CH-UA", "Sec-CH-UA-Mobile", "Sec-CH-UA-Platform"].forEach((header) => { + action.requestHeaders.push({ + "header": header, + "operation": "remove" + }); + }); + ["X-Forwarded-For", "CF-Connecting-IP", "X-Originating-IP", "X-Remote-IP", "X-Client-IP", "X-Real-IP", "True-Client-IP"].forEach((header) => { + action.requestHeaders.push({ + "header": header, + "operation": "set", + "value": IP + }); + }); const condition = { resourceTypes }; const rule = createRule(action, condition, id); addFilters(rule, regexFilter, urlFilter); @@ -198,12 +196,4 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { success: false, error: 'Unknown method' }) -}); - -chrome.webNavigation.onBeforeNavigate.addListener(() => { - console.info("wake up"); -}); - -chrome.webNavigation.onHistoryStateUpdated.addListener((details) => { - console.info("wake up"); -}); +}); \ No newline at end of file diff --git a/src/components/Announcements.jsx b/src/components/Announcements.jsx new file mode 100644 index 0000000..5119d76 --- /dev/null +++ b/src/components/Announcements.jsx @@ -0,0 +1,85 @@ +import { useCallback, memo } from 'react' +import { useLocalObservable, Observer } from 'mobx-react'; + +import Drawer from '@mui/material/Drawer'; +import Stack from '@mui/material/Stack'; +import Card from '@mui/material/Card'; +import CardContent from '@mui/material/CardContent'; +import Button from '@mui/material/Button'; +import Typography from '@mui/material/Typography'; +import CardActions from '@mui/material/CardActions'; +import Divider from '@mui/material/Divider'; +import IconButton from '@mui/material/IconButton'; +import CloseIcon from '@mui/icons-material/Close'; + +import store from '../store'; + +const title = Announcements; + +function AnnouncementCard({ announcement }) { + return ( + + + + {announcement.type} + + + {announcement.title} + + + {announcement.content} + + + + { + (announcement.links).map((link, key) => + + ) + } + + + ); +} + +export default memo(function () { + const configStore = useLocalObservable(() => store.configStore); + const windowsStore = useLocalObservable(() => store.windowsStore); + const handleToggleWindow = useCallback(() => windowsStore.toggle('announcements'), []); + + return ( + + {() => ( + + {title} + + + + } spacing={2} id="dc-announcements"> + {(configStore.getAnnouncements ?? []).map((announcement, key) => ( + + ))} + + + )} + + ); +}, () => true); diff --git a/src/components/Banners.jsx b/src/components/Banners.jsx new file mode 100644 index 0000000..65a952e --- /dev/null +++ b/src/components/Banners.jsx @@ -0,0 +1,107 @@ +import { memo, useEffect, useCallback, useState, useMemo } from 'react'; +import { styled } from '@mui/material/styles'; +import Fab from '@mui/material/Fab'; +import Stack from '@mui/material/Stack'; +import Divider from '@mui/material/Divider'; +import Tooltip from '@mui/material/Tooltip'; +import Portal from '@mui/base/Portal'; +import TokenIcon from '@mui/icons-material/Token'; +import DarkModeIcon from '@mui/icons-material/DarkMode'; +import LightModeIcon from '@mui/icons-material/LightMode'; +import FolderIcon from '@mui/icons-material/Folder'; +import CookieIcon from '@mui/icons-material/Cookie'; +import TipsAndUpdates from '@mui/icons-material/TipsAndUpdates'; +import GlobalStyles from '@mui/material/GlobalStyles'; +import { useLocalObservable } from 'mobx-react'; +import injectAnalytics from '../utils/injectAnalytics'; +import { waitForSelector, cleanCookies } from '../utils'; +import store from '../store'; +import { enqueueSnackbar } from 'notistack'; + +const Wrapper = styled(Stack)({ + float: 'right', + '@media (max-width: 840px)': { + float: 'initial', + width: '100%', + marginBottom: '24px' + } +}); +function createContainerElement() { + const div = document.createElement('div'); + injectAnalytics(); + return div; +} +const DarkModeStyle = ; +export default memo(function () { + const [container, setContainer] = useState(false); + const activeTokenOrCredential = useLocalObservable(() => store.tokensAndCredentialsStore.activeTokenOrCredential); + const [darkMode, setDarkMode] = useState(localStorage.getItem('darkMode') === 'true'); + + const handleToggleAnnouncements = useCallback(() => store.windowsStore.toggle('announcements'), []); + const handleToggleDocumentsManager = useCallback(() => store.windowsStore.toggle('documentsManager'), []); + const handleToggleTokensAndCredentialsManager = useCallback(() => store.windowsStore.toggle('tokensAndCredentialsManager'), []); + + const handleToggleDarkMode = useCallback(() => { + setDarkMode(!darkMode); + localStorage.setItem('darkMode', `${!darkMode}`); + }, [darkMode]); + const handleCleanCookies = useCallback(async () => { + try { + await cleanCookies(); + location.reload(); + } catch (error) { + enqueueSnackbar(error.message, { variant: 'error' }) + } + }, []); + useEffect(() => { + waitForSelector('#dl_translator') + .then((el) => { + const div = createContainerElement(); + el.prepend(div); + setContainer(div); + }); + }, []); + const buttons = useMemo(() => [ + { label: 'Announcements', icon: , onClick: handleToggleAnnouncements }, + { label: 'Documents Manager', icon: , onClick: handleToggleDocumentsManager }, + { + label: !!activeTokenOrCredential?.type ? `Using ${activeTokenOrCredential.type}` : 'Tokens and Credentials Manager', + icon: , onClick: handleToggleTokensAndCredentialsManager + }, + { label: 'Clean Cookies', icon: , onClick: handleCleanCookies, id: 'dc-clean-cookies' }, + { + label: darkMode ? 'Light Mode' : 'Dark Mode', + icon: darkMode ? : , + onClick: handleToggleDarkMode, + id: 'dc-dark-mode' + } + ], [activeTokenOrCredential, darkMode]); + return (<> + {darkMode && DarkModeStyle} + { + !!container ? + } + spacing={2} + justifyContent="space-evenly" + id='dc-banners' + > + {buttons.map(({ label, icon, onClick, visible = true, id }) => visible && ( + + + {icon} + + + ))} + + : null + } + ) +}, () => true); \ No newline at end of file diff --git a/src/components/DocumentsManager/FileUploader.jsx b/src/components/DocumentsManager/FileUploader.jsx new file mode 100644 index 0000000..c0f01a6 --- /dev/null +++ b/src/components/DocumentsManager/FileUploader.jsx @@ -0,0 +1,80 @@ +import { useCallback, memo, useEffect, useRef } from 'react' +import Button from '@mui/material/Button'; +import Grid from '@mui/material/Grid'; +import CloudUploadIcon from '@mui/icons-material/CloudUpload'; + +const uploadUI = + + + + + Drag or Click to upload + +; + +export default memo(function ({ handleDocumentsChange }) { + + const handleDragEvent = useCallback((event) => { + event.preventDefault() + event.stopPropagation() + }, []) + + const handleDrop = useCallback((event) => { + event.preventDefault() + event.stopPropagation() + if (event.dataTransfer.files) { + handleDocumentsChange(event.dataTransfer.files) + } + }, []) + + const dragRef = useRef() + const inputRef = useRef() + + useEffect(() => { + if (dragRef.current) { + dragRef.current.ondragenter = handleDragEvent + dragRef.current.ondragover = handleDragEvent + dragRef.current.ondrop = handleDrop + dragRef.current.ondragleave = handleDragEvent + } + }, [dragRef.current]) + + const handleClick = useCallback(() => { + inputRef.current.click() + }, [inputRef.current]) + + const handleInputChange = useCallback((event) => { + handleDocumentsChange(event.target.files) + }, []) + + return ( + <> + + + + ) +}, () => true); diff --git a/src/components/DocumentsManager/index.jsx b/src/components/DocumentsManager/index.jsx new file mode 100644 index 0000000..173d592 --- /dev/null +++ b/src/components/DocumentsManager/index.jsx @@ -0,0 +1,168 @@ +import React, { useCallback, memo } from 'react'; +import { useLocalObservable, Observer } from 'mobx-react'; + +import Dialog from '@mui/material/Dialog'; +import DialogTitle from '@mui/material/DialogTitle'; +import DialogContent from '@mui/material/DialogContent'; +import DialogActions from '@mui/material/DialogActions'; +import Button from '@mui/material/Button'; +import Grid from '@mui/material/Grid'; +import Stack from '@mui/material/Stack'; +import FileUploader from './FileUploader'; +import { DataGridPremium, GridActionsCellItem } from '@mui/x-data-grid-premium'; +import prettyBytes from 'pretty-bytes'; +import LockOpenIcon from '@mui/icons-material/LockOpen'; +import DeleteIcon from '@mui/icons-material/Delete'; +import DownloadIcon from '@mui/icons-material/Download'; +import { styled } from '@mui/material/styles'; +import { enqueueSnackbar } from 'notistack'; + +import HelpButton from '../HelpButton'; +import store from '../../store'; +import { downloadDirectly } from '../../utils'; +import unlockDocument from '../../utils/unlockDocument'; + +const title = Documents Manager; + +const FullGrid = styled(Grid)({ + height: '100%', + width: '100%', +}); + +export default memo(function () { + const documentsStore = useLocalObservable(() => store.documentsStore); + const loadingStore = useLocalObservable(() => store.loadingStore); + const windowsStore = useLocalObservable(() => store.windowsStore); + + const handleDownloadDocument = useCallback(downloadDirectly, []); + const handleDeleteDocument = useCallback((name) => { + documentsStore.delete(name); + }, []); + const handleDecryptDocument = useCallback(async (document) => { + const loading = loadingStore.add(`Decrypting ${document.name}...`); + try { + const { blob, name } = document; + const decryptedBlob = await unlockDocument(blob); + documentsStore.modify(name, decryptedBlob); + enqueueSnackbar('Document decrypted successfully', { variant: 'success' }); + } catch (error) { + enqueueSnackbar(error.message, { variant: 'error' }); + } + loadingStore.remove(loading); + }, []); + + const handleDocumentsChange = useCallback((documents) => { + for (const document of documents) { + documentsStore.add(document); + } + }, []); + const handleCleanDocuments = useCallback(() => documentsStore.clean(), []); + const handleToggleWindow = useCallback(() => windowsStore.toggle('documentsManager'), []); + + return ( + + {() => ( + + + + + {title} + + + ({ + [theme.breakpoints.down('md')]: { + height: '20%', + }, + [theme.breakpoints.up('md')]: { + paddingRight: '24px' + } + })}> + + + ({ + [theme.breakpoints.down('md')]: { + height: '70%', + }, + })}> + [ + } + onClick={() => handleDeleteDocument(params.row.name)} + />, + } + onClick={() => handleDecryptDocument(params.row)} + />, + } + onClick={() => handleDownloadDocument(params.row.blob, params.row.name)} + />, + ], + width: 150, + }, + ]} + pinnedColumns={{ right: ['actions'] }} + rows={documentsStore.list.map((document) => ({ + id: document.name, + name: document.name, + type: document.blob?.type, + blob: document.blob, + }))} + /> + + + + + {documentsStore.list.length > 0 && ( + + )} + + + + )} + + ); +}, () => true); diff --git a/src/components/GlobalStyle.jsx b/src/components/GlobalStyle.jsx index 139bf2e..b50b9db 100644 --- a/src/components/GlobalStyle.jsx +++ b/src/components/GlobalStyle.jsx @@ -1,29 +1,33 @@ import GlobalStyles from '@mui/material/GlobalStyles'; -const gs = div': { - width: "calc(50vw - 25px)" + '@media (max-width: 840px)': { + 'button[role="tab"] > div': { + width: "calc(50vw - 25px)" + } + }, + '.dc-guide-mask': { + zIndex: 1301 + }, + '.dc-guide-modal': { + zIndex: 1302 } - } - }} -/> - -export default function () { - return gs; + }} + />; } \ No newline at end of file diff --git a/src/components/Guide.jsx b/src/components/Guide.jsx new file mode 100644 index 0000000..508f2fd --- /dev/null +++ b/src/components/Guide.jsx @@ -0,0 +1,246 @@ +import Guide from "byte-guide"; +import { memo } from "react"; +import Typography from "@mui/material/Typography"; +import store from "../store"; + +const steps = [ + { + selector: "#dc-banners", + title: "Wellcome to DeepL Crack", + content: ( +
+ + I'm a Chromium extension that helps you to bypass the DeepL Pro subscription. + + + I'm FREE. If you bought it from others, you should ask for refunds + + + I'm not a hack, but just a bypass. You should use me for testing purposes only and delete me after 24 hours. + +
+ ), + placement: "bottom-left" + }, + { + selector: "#dc-banners", + title: "Instructions", + content: ( +
+ + Read Github Readme carefully. + + + Features: + +
    +
  • Bypass the free translator's limit of 5,000 characters
  • +
  • Remove edit restriction (available for docx, doc, ppt, pptx, pdf)
  • +
  • Remove DeepL Pro Banner for docx, doc, ppt, pptx files
  • +
  • Use DeepL Pro Account Cookies/DeepL Api Free Token to translate (This can help you bypass frequency limitations of web api)
  • +
  • Unlock Formal/informal tone
  • +
  • Clean cookie and randomnize User Agent
  • +
+ + Limitations: + +
    +
  • DeepL may ban your IP due to high frequency of requests to web api. There are 2 solutions:
  • +
      +
    • Use DeepL Pro Account Cookies/DeepL Api Free Token to translate.
    • +
    • First, Use a proxy to change IP. Then, click clean cookie button.
    • +
    +
  • File translation quota and maximum upload size of 5 MB are not cracked due to server verification.
  • +
  • Edge users should disable Advanced Security for deepl.com so that this extension can unlock PDF.
  • +
+
+ ), + placement: "bottom-left" + }, + { + selector: "#dc-banners", + title: "Banner", + content: ( + + Common features of this extension are listed here. Click those buttons to use. + + ), + placement: "bottom-left", + beforeStepChange: () => { + store.windowsStore.toggle("announcements") + } + }, + { + selector: "#dc-announcements", + title: "Announcements", + content: ( +
+ + I will post announcements here. Please check it regularly. You can also see some guides here. + +
+ ), + placement: "right", + beforeStepChange: () => { + store.windowsStore.toggle("announcements") + store.windowsStore.toggle("tokensAndCredentialsManager") + }, + offset: { + x: -340, + } + }, + { + selector: "#dc-tokens-and-credentials-manager", + title: "Tokens and Credentials Manager", + content: ( +
+ + You can use DeepL Pro Credential/DeepL Api Free Token to translate. + This can help you bypass frequency limitations of web api. + Some free public resources may be provided. You can also add your own tokens/credentials. + + + If you sponsor me, I may provide you some private tokens/credentials for you. + Rememer to DM me on Telegram(@Blueagler) or Email(austinliu@blueagle.top) and remain your email address and UUID when you sponsor me. + +
+ ), + placement: "right", + beforeStepChange: () => { + store.windowsStore.toggle("tokensAndCredentialsManager") + store.windowsStore.toggle("documentsManager") + }, + offset: { + x: -320, + } + }, + { + selector: "#dc-documents-manager", + title: "Documents Manager", + content: ( +
+ + There are all your documents. If you download a document from DeepL, it will be added here automatically. + You can also add your own documents. + + + You can remove their editing restrictions and banners here. Decryption currently only supports docx, doc, ppt, pptx, pdf. + +
+ ), + placement: "right", + beforeStepChange: () => { + store.windowsStore.toggle("documentsManager") + }, + offset: { + x: -320, + } + }, + { + selector: "#dc-clean-cookies", + title: "Clean Cookies", + content: ( +
+ + Although I will clean cookies automatically, you can also click this button to clean cookies manually. + In case of reaching the frequency limit, you can try to change IP, then click this button to bypass the limit. + If you cannot change IP, you can try to use DeepL Pro Credentials/DeepL Api Free Token in Tokens and Credentials Manager or wait for a while. + +
+ ), + placement: "bottom-right", + }, + { + selector: "#dc-dark-mode", + title: "Dark Mode", + content: ( +
+ + You can switch between dark mode and light mode here. + +
+ ), + placement: "bottom-right", + beforeStepChange: () => { + document.querySelector('.lmt__docTrans-tab-container').querySelectorAll('button')[0].click() + } + }, + { + selector: "#panelTranslateText", + title: "Translate Text", + content: ( +
+ + You can translate text here. Normally, you may encounter the frequency limit, as I said before. + However, even if you do not use DeepL Pro Credentials/DeepL Api Free Token or change IP, you only need to wait for a shorter time compared to users without this extension. + Maybe 1 minute or less. + Because I ramdomnize User Agent and identifer cookies for each request, so that DeepL can only identify you by IP. + +
+ ), + placement: "right", + offset: { + x: -520, + }, + beforeStepChange: () => { + document.querySelector('.lmt__docTrans-tab-container').querySelectorAll('button')[1].click() + } + }, + { + selector: "#panelTranslateFiles", + title: "Translate Documents", + content: ( +
+ + You can translate documents here. + Remember that when you download a document, it will be added to Documents Manager automatically where you can remove their editing restrictions and banners. + As I said before, this extension cannot bypass file size limit. + So, if you want to translate a large file, you can split it into several small files. + If you encounter the frequency limit, you can try to change IP, then click Clean Cookies button to bypass the limit. + +
+ ), + offset: { + x: -520, + }, + placement: "right" + }, + { + selector: "#dc-sponsor", + title: "Sponsor", + content: ( +
+ + If you like this extension, you can sponsor me. + I may provide you some private tokens/credentials for you. + + + Rememer to DM me on Telegram(@Blueagler) or Email(austinliu@blueagle.top) and remain your email address and UUID. You can sponsor me via Buy Me A Coffee, Wechat Pay and Alipay. + +
+ ), + placement: "left-bottom" + }, +]; + +export default memo(function () { + return ( + `Step ${stepIndex} of ${stepCount}`} + nextText="Next" + okText="Finish" + maskClassName="dc-guide-mask" + modalClassName="dc-guide-modal" + onClose={() => { + document.documentElement.style.overflow = 'auto' + }} + visible={/translator/.test(window.location.href)} + /> + ); +}, () => true) \ No newline at end of file diff --git a/src/components/HelpButton.jsx b/src/components/HelpButton.jsx new file mode 100644 index 0000000..900be22 --- /dev/null +++ b/src/components/HelpButton.jsx @@ -0,0 +1,42 @@ +import { useCallback, memo, useState, useRef } from 'react' +import Popover from '@mui/material/Popover'; +import IconButton from '@mui/material/IconButton'; +import HelpIcon from '@mui/icons-material/Help'; +import Typography from '@mui/material/Typography'; + +export default memo(function ({ icon, content, anchorOrigin, transformOrigin }) { + const [helpPopover, setHelpPopover] = useState(false); + const buttonRef = useRef(null); + const handleOpen = useCallback(() => setHelpPopover(true), []); + const handleClose = useCallback(() => setHelpPopover(false), []); + return ( + <> + + {icon || } + + + + {content} + + + + ) +}, (prevProps, nextProps) => { + return prevProps.content === nextProps.content && prevProps.anchorOrigin === nextProps.anchorOrigin && prevProps.transformOrigin === nextProps.transformOrigin; +}); diff --git a/src/components/Loading.jsx b/src/components/Loading.jsx index 763c9c6..05d09f6 100644 --- a/src/components/Loading.jsx +++ b/src/components/Loading.jsx @@ -1,12 +1,10 @@ import { memo } from 'react' import { useLocalObservable, Observer } from 'mobx-react'; -import store from 'store'; - +import store from '../store'; import Backdrop from '@mui/material/Backdrop'; import CircularProgress from '@mui/material/CircularProgress'; import Stack from '@mui/material/Stack'; import Paper from '@mui/material/Paper'; - const progress = ; function renderTask({ task, id }) { @@ -41,7 +39,7 @@ function Loading() { {() => - {renderLoadingList(loadingStore.loadingList)} + {renderLoadingList(loadingStore.getList)} @@ -64,4 +62,4 @@ function Loading() { ) } -export default memo(Loading); +export default memo(Loading); \ No newline at end of file diff --git a/src/components/TokensAndCredentialsManager/index.jsx b/src/components/TokensAndCredentialsManager/index.jsx new file mode 100644 index 0000000..d743e7c --- /dev/null +++ b/src/components/TokensAndCredentialsManager/index.jsx @@ -0,0 +1,264 @@ +import React, { useCallback, memo, useState } from 'react'; +import { Observer, useLocalObservable } from 'mobx-react'; + +import store from '../../store'; +import api from "../../utils/api"; +import { uuid } from '../../utils' +import { enqueueSnackbar } from 'notistack'; + +import { DataGridPremium, GridActionsCellItem } from '@mui/x-data-grid-premium'; + +import AddIcon from '@mui/icons-material/Add'; +import Dialog from '@mui/material/Dialog'; +import DialogTitle from '@mui/material/DialogTitle'; +import DialogContent from '@mui/material/DialogContent'; +import DialogActions from '@mui/material/DialogActions'; +import Button from '@mui/material/Button'; +import Tooltip from '@mui/material/Tooltip'; +import Popover from '@mui/material/Popover'; +import IconButton from '@mui/material/IconButton'; +import RemoveIcon from '@mui/icons-material/Remove'; +import TextField from '@mui/material/TextField'; +import MenuItem from '@mui/material/MenuItem'; +import Stack from '@mui/material/Stack'; +import RefreshIcon from '@mui/icons-material/Refresh'; + +import HelpButton from '../HelpButton'; + +const title = Tokens And Credentials Manager; + +export default memo(function () { + const tokensAndCredentialsStore = useLocalObservable(() => store.tokensAndCredentialsStore); + const windowsStore = useLocalObservable(() => store.windowsStore); + const handleToggleWindow = useCallback(() => windowsStore.toggle('tokensAndCredentialsManager'), []); + + const [addTokenOrCredentialState, setAddTokenOrCredentialState] = useState({ + form: { + type: 'DeepLApiFreeToken', + name: '', + licensing: 'LOCAL', + DeepLApiFreeToken: { + token: '', + character_count: 0, + character_limit: 0, + }, + ProCredential: { + cookies: '', + ip: '', + userAgent: '', + useProxy: false + } + }, + popover: null, + }); + + const handleCopyUUID = useCallback(() => { + navigator.clipboard.writeText(tokensAndCredentialsStore.getUUID) + .then(() => enqueueSnackbar('UUID copied to clipboard', { variant: 'success' })) + .catch(() => alert(`Failed to copy UUID: ${tokensAndCredentialsStore.getUUID}`)); + }, [tokensAndCredentialsStore.getUUID]); + + const handleRefreshTokensAndCredentials = useCallback(() => { + api.getTokensAndCredentials() + .then(() => { + store.cacheStore.set('lastGetToken', Date.now(), true); + enqueueSnackbar('Token refreshed', { variant: 'success' }) + }); + }, []); + + const handleSetFormField = useCallback((field, value) => { + setAddTokenOrCredentialState((prevState) => ({ + ...prevState, + form: { + ...prevState.form, + [field]: value, + }, + })); + }, []); + + const handleSaveTokenOrCredential = useCallback(() => { + tokensAndCredentialsStore.addToken({ + ...addTokenOrCredentialState, + id: uuid(), + data: addTokenOrCredentialState[addTokenOrCredentialState.type], + }); + }, [addTokenOrCredentialState]); + + const handleAddTokenOrCredentialPopoverOpen = useCallback((e) => { + setAddTokenOrCredentialState((prevState) => ({ + ...prevState, + popover: e.currentTarget, + })); + }, []); + + const handleAddTokenOrCredentialPopoverClose = useCallback(() => { + setAddTokenOrCredentialState((prevState) => ({ + ...prevState, + popover: null, + })); + }, []); + + const fieldConfig = { + type: { + label: 'Type', + options: [ + { value: 'DeepLApiFreeToken', label: 'Deepl API Free Token' }, + { value: 'ProCredential', label: 'Deepl Pro Account Credential' }, + ], + }, + name: { + label: 'Name', + }, + 'DeepLApiFreeToken.token': { + label: 'Token', + helperText: 'This is your DeepL Api Free Token', + }, + 'ProCredential.cookies': { + label: 'Cookie', + }, + 'ProCredential.ip': { + label: 'IP', + }, + 'ProCredential.userAgent': { + label: 'User Agent', + }, + }; + + return ( + + {() => ( + + + + + + + + {title} + + [ + + {params.row.id === tokensAndCredentialsStore.activeTokenOrCredential?.id ? : } + + } + onClick={() => tokensAndCredentialsStore.setActiveId(params.row.id === tokensAndCredentialsStore.activeTokenOrCredential?.id ? null : params.row.id)} + />, + ], + width: 150, + }, + ]} + columnVisibilityModel={{ id: false }} + rows={tokensAndCredentialsStore.list.map(({ id, data, type, name, licensing }) => ({ + id, + left: data.character_limit ? data.character_limit - data.character_count > 0 ? data.character_limit - data.character_count : 0 : 'Unlimited', + type, + name, + license: licensing, + }))} + initialState={{ + sorting: { + sortModel: [{ field: 'left', sort: 'desc' }], + }, + }} + pinnedColumns={{ right: ['actions'] }} + pinnedRows={tokensAndCredentialsStore.activeTokenOrCredential ? { top: [tokensAndCredentialsStore.activeTokenOrCredential] } : {}} + /> + + + + + {Object.entries(fieldConfig).map(([field, config]) => ( + + handleSetFormField( + field.includes('.') ? field.split('.')[0] : field, + field.includes('.') + ? { + ...addTokenOrCredentialState.form[field.split('.')[0]], + [field.split('.')[1]]: e.target.value, + } + : e.target.value + ) + } + /> + ))} + + + + + + )} + + ); +}, () => true); diff --git a/src/index.js b/src/index.js index 7640fc3..f981ce4 100644 --- a/src/index.js +++ b/src/index.js @@ -1,18 +1,30 @@ -import { proxy } from "proxy"; - -import { render } from 'preact'; +import { proxy } from "./proxy"; +import { createRoot } from 'react-dom/client'; import App from './App' +import checkGFW from './utils/checkGFW'; proxy(); -if (window.location.pathname.includes('translator')) { - const root = document.createElement('div') - render(, root); - if (document.body) { - document.body.prepend(root) - } else { - document.addEventListener('DOMContentLoaded', () => { - document.body.prepend(root) - }) + +(async () => { + if (!localStorage.getItem('dc-api-server')) { + if (await checkGFW()) { + localStorage.setItem('dc-api-server', 'https://v1-hk-api.blueagle.top') + } else { + localStorage.setItem('dc-api-server', 'https://v1-cf-api.blueagle.top') + } + } + if (/(translator|write)/.test(window.location.pathname)) { + const rootContainer = document.createElement('div') + const root = createRoot(rootContainer); + if (document.body) { + root.render(); + document.body.prepend(rootContainer) + } else { + document.addEventListener('DOMContentLoaded', () => { + root.render(); + document.body.prepend(rootContainer) + }) + } } -} \ No newline at end of file +})(); \ No newline at end of file diff --git a/src/proxy/index.js b/src/proxy/index.js index 84ba8f5..b1a2521 100644 --- a/src/proxy/index.js +++ b/src/proxy/index.js @@ -1,5 +1,6 @@ import { openRules, sendRules } from './rules'; -import store from 'store'; +import store from '../store'; +import { enqueueSnackbar } from 'notistack'; const originalXhrOpen = XMLHttpRequest.prototype.open; const originalXhrSend = XMLHttpRequest.prototype.send; @@ -11,100 +12,116 @@ function getFileName() { if (fileNameInput) { return fileNameInput.value.split('.').slice(0, -1).join('.'); } - const hijackCacheName = store.cacheStore.getCache('nextDocumentHijackName'); + const hijackCacheName = store.cacheStore.get('nextDocumentHijackName'); if (hijackCacheName) { return hijackCacheName.split('.').slice(0, -1).join('.'); } - return Date(); + return String(Date.now()); } -function modifyHandler(rule) { +function overrideResponse(xhr, response) { + Object.defineProperty(xhr, 'responseText', { + get() { + return response.override; + }, + }); + Object.defineProperty(xhr, 'status', { + get() { + return 200; + }, + }); +} + +function handleResponse(xhr, response) { + Object.defineProperty(xhr, 'responseText', { + get() { + return response.handler.call(xhr); + }, + }); + Object.defineProperty(xhr, 'status', { + get() { + return 200; + }, + }); +} + +function modifyHandler(xhr, rule) { if (rule.response) { - switch (rule.response.type) { - case 'override': - Object.defineProperty(this, "responseText", { - get: () => rule.response.override, - }); - Object.defineProperty(this, "status", { - get: () => 200, - }); - break; - case 'handler': - Object.defineProperty(this, "responseText", { - get: () => rule.response.handler.call(this), - }); - Object.defineProperty(this, "status", { - get: () => 200, - }); - break; + if (rule.response.type === 'override') { + overrideResponse(xhr, rule.response); + } else if (rule.response.type === 'handler') { + handleResponse(xhr, rule.response); } rule.drop = true; } if (rule.onErrorHandler) { - this.addEventListener('error', rule.onErrorHandler); + xhr.addEventListener('error', rule.onErrorHandler); } if (rule.onLoadHandler) { - this.addEventListener('readystatechange', () => { - if (this.readyState === this.DONE) { - rule.onLoadHandler.call(this); + xhr.addEventListener('readystatechange', () => { + if (xhr.readyState === xhr.DONE) { + rule.onLoadHandler.call(xhr); } }); } if (rule.drop) { - Object.defineProperty(this, "send", { - get: () => () => { }, + Object.defineProperty(xhr, 'send', { + get() { + return () => { }; + }, }); - Object.defineProperty(this, "setRequestHeader", { - get: () => () => { }, + Object.defineProperty(xhr, 'setRequestHeader', { + get() { + return () => { }; + }, }); - Object.defineProperty(this, "readyState", { - get: () => this.DONE, + Object.defineProperty(xhr, 'readyState', { + get() { + return xhr.DONE; + }, }); - this.dispatchEvent(new Event('readystatechange')); - return 'abort' + xhr.dispatchEvent(new Event('readystatechange')); + return 'abort'; } } -function changeUrlHandler(rule) { - switch (rule.changeUrl.type) { - case 'handler': - this.url = rule.changeUrl.handler.call(this); - break; - case 'replace': - this.url = this.url.replace(rule.match, rule.changeUrl.replace); - break; - case 'override': - this.url = rule.changeUrl.override; - break; +function changeUrl(xhr, rule) { + if (rule.changeUrl.type === 'handler') { + xhr.url = rule.changeUrl.handler.call(xhr); + } else if (rule.changeUrl.type === 'replace') { + xhr.url = xhr.url.replace(rule.match, rule.changeUrl.replace); + } else if (rule.changeUrl.type === 'override') { + xhr.url = rule.changeUrl.override; } } -function changePayloadHandler(rule) { - switch (rule.changePayload.type) { - case 'replace': - this.payload = this.payload.replace(rule.matchPayload, rule.changePayload.replace); - break; +function changePayload(xhr, rule) { + if (rule.changePayload.type === 'replace') { + xhr.payload = xhr.payload.replace(rule.matchPayload, rule.changePayload.replace); } } -function downloadDocument() { - const loading = store.loadingStore.addLoading(`Downloading ${getFileName.call(this)}`); - fetch(this.getAttribute('action'), { +function downloadDocument(form) { + const loading = store.loadingStore.add(`Downloading ${getFileName.call(form)}`); + fetch(form.getAttribute('action'), { method: 'POST', - body: new FormData(this), + body: new FormData(form), credentials: 'include', }) .then(response => response.blob()) - .then(response => { - const name = getFileName.call(this); - store.documentStore.addDocument(response, name); - store.windowStore.toggleDocumentWindow(); + .then(blob => { + const name = getFileName.call(form); + store.documentsStore.add(blob, name); + store.windowsStore.toggle('documentsManager'); + enqueueSnackbar(`Your document ${name} has been downloaded to Documents Manager, if you want to remove editing protection, please click the unlock button.`, { + variant: 'info', + }); }) - .catch(() => originalSubmit.call(this)) - .finally(() => store.loadingStore.removeLoading(loading)) + .catch(() => originalSubmit.call(form)) + .finally(() => store.loadingStore.remove(loading)); } -export function proxy() { +function overrideXhrOpen() { XMLHttpRequest.prototype.open = async function (method, url, ...rest) { this.method = method; this.url = url; @@ -113,21 +130,22 @@ export function proxy() { if (rule.await) { await rule.await.call(this); } - if (modifyHandler.call(this, rule) === 'abort' || this.DONNOTSEND) { - return + if (modifyHandler(this, rule) === 'abort' || this.DONNOTSEND) { + return; } if (rule.changeUrl) { - changeUrlHandler.call(this, rule); + changeUrl(this, rule); } if (rule.changeMethod) { this.method = rule.changeMethod; } } } - method = this.method; - url = this.url; - return originalXhrOpen.call(this, method, url, ...rest); + return originalXhrOpen.call(this, this.method, this.url, ...rest); }; +} + +function overrideXhrSend() { XMLHttpRequest.prototype.send = function (payload, ...rest) { this.payload = payload; (async () => { @@ -136,36 +154,47 @@ export function proxy() { if (rule.await) { await rule.await.call(this); } - if (modifyHandler.call(this, rule) === 'abort' || this.DONNOTSEND) { - return + if (modifyHandler(this, rule) === 'abort' || this.DONNOTSEND) { + return; } if (rule.changePayload) { - changePayloadHandler.call(this, rule); + changePayload(this, rule); } } } - payload = this.payload; - originalXhrSend.call(this, payload, ...rest); + originalXhrSend.call(this, this.payload, ...rest); })(); }; +} + +function overrideSetAttribute() { Element.prototype.setAttribute = function (name, value) { if (this.tagName === 'INPUT') { if (name === 'value' && this.getAttribute('name') === 'expectsPro') { value = 'false'; } else if (name === 'value' && this.getAttribute('name') === 'fileName') { - store.cacheStore.setCache('nextDocumentHijackName', value); + store.cacheStore.set('nextDocumentHijackName', value); } } originalSetAttribute.call(this, name, value); - } + }; +} +function overrideFormSubmit() { HTMLFormElement.prototype.submit = function () { if (/documentTranslation/.test(this.getAttribute('action'))) { - downloadDocument.call(this); + downloadDocument(this); } else { originalSubmit.call(this); } - } + }; +} + +export function proxy() { + overrideXhrOpen(); + overrideXhrSend(); + overrideSetAttribute(); + overrideFormSubmit(); } export function unproxy() { @@ -173,4 +202,4 @@ export function unproxy() { XMLHttpRequest.prototype.open = originalXhrOpen; XMLHttpRequest.prototype.send = originalXhrSend; HTMLFormElement.prototype.submit = originalSubmit; -} \ No newline at end of file +} diff --git a/src/proxy/rules.js b/src/proxy/rules.js index bd4010f..7e787f0 100644 --- a/src/proxy/rules.js +++ b/src/proxy/rules.js @@ -1,22 +1,29 @@ -import { enqueueSnackbar } from 'notistack' -import { cleanCookies } from "utils"; +import { enqueueSnackbar, closeSnackbar } from 'notistack' import Button from '@mui/material/Button'; -import { sendMessage } from 'utils' -import store from 'store'; +import { sendMessage, cleanCookies } from '../utils' +import store from '../store' +import api from "../utils/api"; export const openRules = [ { match: /getClientState/, response: { type: 'override', - override: '{"jsonrpc":"2.0","id":0,"result":{"proAvailable":true,"updateNecessary":false,"featureSet":{"translator":{"service":"pro","formality":true},"documentTranslation":{"service":"free","pdf":"noAccountConsent","formality":true},"glossary":{"termbaseService":false,"sharing":false,"uploadAndDownload":false,"maxEntriesPerGlossary":0,"maxGlossaries":0}},"ep":true,"loginState":{"accountId":"0"},"notifications":[]}}' + override: '{"result":{"proAvailable":true,"updateNecessary":false,"featureSet":{"subscription":{"inactiveSubscriptionWarning":false,"billing":true,"usage":true,"api":true,"isSubaccount":false,"upgradeOptions":[],"signup":false,"management":true,"managedUpAndDowngrades":false,"checkoutForbiddenReasons":[],"newPaymentSystem":false},"support":{"contactForm":false,"tags":[],"openToAnyLoggedIn":false},"translator":{"service":"pro","maxCharactersPerRequest":null,"formality":true},"documentTranslation":{"service":"free","pdf":"ok","formality":true,"maxQuota":null,"sizeLimits":{"docx":5,"htm":0,"html":0,"pdf":5,"pptx":5,"txt":0,"xlf":0,"xliff":0}},"glossary":{"maxEntriesPerGlossary":0,"maxGlossaries":0,"termbaseService":false,"sharing":false,"uploadAndDownload":false},"speech":{"textToSpeech":"yes","speechRecognition":"yes"},"ocr":{"ocr":"yes"},"savedTranslations":{"enabled":true,"savedTranslationsEntryCount":9007199254740991},"translationHistory":{"historyEntryDurationSec":2592000,"historyEntryDuration":{"seconds":2592000,"nanos":0},"accessRight":"yes"},"quickTranslator":{"maxCharactersPerRequest":null},"virality":{"addFooterToCopiedOrSharedText":true},"api":{"manageKeys":true,"service":"pro","catToolsOnly":false,"serviceCatTools":"pro"}},"ep":null,"loginState":{"accountId":"id","ssoIdentityProviderName":null,"ssoIdentityProviderId":null},"notifications":[]},"id":0,"jsonrpc":"2.0"}' } }, { - match: /getAccountId/, + match: /getCurrentAccount/, response: { type: 'override', - override: '{"jsonrpc":"2.0","result":{"accountId":0},"id":0}' + override: '{"result":{"accountId":"id","email":"DeepL Crack / Blueagle ❤️","name":"","locale":{"languageCode":"en","countryCode":" "},"teamName":"DeepL Cracked"},"id":0,"jsonrpc":"2.0"}' + } + }, + { + match: /PHP\/backend\/account.php/, + response: { + type: 'override', + override: '{"jsonrpc":"2.0","result":{"messageCount":"0","activation":{"id":"0","apiKey":"0","characterLimit":"9007199254740991","characterCount":"0","endDate":"2099-01-01","startDate":"2000-01-01","subscriptionId":"2984841","type":"REGULAR","has_billing_data":"1","disabledTime":null,"cancelationTime":null,"additionalCharacterCount":"0","additionalPrice":"0.00","periodStartDate":"2000-01-01","periodEndDate":"2099-01-01","isCurrent":"t","allowChangePayment":true,"allowNewSubscription":false,"settlementId":null,"isTrialPeriod":"t","allowReactivateSubscriptionInTrial":true,"allowRescindCancellation":true,"hasDeletedPaymentToken":"0","isBalanced":true,"trialPeriodUntil":"2099-01-01","period":"DeepL Cracked","allowSeeAccount":true,"showReactivationContent":false,"showRescissionContent":true,"allowChangeKey":true,"isActive":true,"status":"activated on June 1, 2023","statusType":"activated","allowChangeData":true,"allowSeeKey":true,"allowSeeBillingData":true,"allowCancel":false},"subscription":{"id":"2984841","contractConfirmationTime":"2000-01-01 10:21:32.345966+00","billing_period_id":"1","activation_key":"0","type":"REGULAR","currency":"USD","characterLimit":"30000000","cancelationTime":null,"productCode":"silver","productId":"3000","productCharacterLimit":"1000000","price":"0.00","apiKey":"0","addressId":null,"costControl":"0","subscriptionKey":null,"activationKey":"0","isConfirmed":"1","accountLimit":9007199254740991,"documentLimit":9007199254740991,"accountDocumentLimit":9007199254740991,"payment_provider":"STRIPE","payment_provider_id":"20","can_charge":"1","is_invoicing":"0","basicPrice":"0","paymentMethod":"mastercard","card_number_suffix":"1234","expirationDate":"01/2099","remainingDays":"509","refreshLink":null,"clientSecret":null,"subsequentProductId":null,"subsequentBillingPeriodId":null,"subsequentAccountLimit":null,"settlementStartDate":"2023-05-31","settlementEndDate":"2099-01-01","payment_incomplete":"0.00","settlementLastDate":"2099-01-01","includedCharacterCount":"0","ssoIdentityProviderId":null,"supportsAPI":false,"supportsWebTranslator":true,"supportsCatTools":true,"allowsCostControl":false,"customerReference":null,"billingEmail":null,"allowUnlimitedUsers":"f","securityRequestMode":"AUTOMATIC","allowInvoicePayment":false,"allowCreditCardPayment":true,"allowDirectDebitPayment":false,"priceScaleId":"4","paymentMethodSuffix":"1234","expirationDateDescription":"01/2099","settlementStartDateRaw":"2000-01-01","settlementEndDateRaw":"2099-01-01","settlementLastDateRaw":"2099-01-01","isTrialPeriod":"t","isPaymentOverdue":false,"oneTimeSettlementOnUpgrade":{"gross":0,"net":0}},"settlements":[],"address":{},"availableCountries":[],"docConsumption":{"currentUserTranslatedDocuments":0,"currentUserDocumentLimit":9007199254740991,"totalDocumentBudget":9007199254740991,"totalTranslatedDocuments":0},"teamMembership":{"isTeamMember":false,"teamSubscriptionId":false,"teamName":"","teamEmail":"","teamIsActive":false,"isActiveMember":false,"statusText":""},"stripePublicKey":"0","products":{},"vatRates":{},"userPaymentAvailability":{"invoice":"ALLOWED","creditCard":"ALLOWED","directDebit":"ALLOWED"},"account":{"id":"0","email":"DeepL Cracked","tokenAndCredential":"0","name":"DeepL Cracked","accountStatus":990,"isAccountEligibleForFreeTrial":false,"timeout":9007199254740991}},"id":0}' } }, { @@ -47,14 +54,21 @@ export const openRules = [ override: '{"jsonrpc":"2.0","result":{"documentQuota":{"accountDocumentCount":9999,"accountDocumentLimit":9999},"billingPeriodStart":0,"billingPeriodEnd":4070880000000},"id":0}', } }, + { + match: /getPdfFeatureStatus/, + response: { + type: 'override', + override: '{"result":{"status":"noAccountConsent"},"id":0,"jsonrpc":"2.0"}', + } + }, { match: /LMT_handle_jobs/, changeUrl: { type: 'handler', handler() { - if (store.tokenStore.getActiveToken?.type === 'deepl-api-free-token') { + if (store.tokensAndCredentialsStore.activeTokenOrCredential?.type === 'DeepLApiFreeToken') { return 'https://api-free.deepl.com/v2/translate'; - } else if (store.tokenStore.getActiveToken?.type !== 'pro-session') { + } else if (store.tokensAndCredentialsStore.activeTokenOrCredential?.type !== 'ProCredential') { return this.url.replace('api.deepl.com', 'www2.deepl.com'); } return this.url @@ -107,7 +121,7 @@ export const openRules = [ onLoadHandler() { switch (this.status) { case 429: - enqueueSnackbar('Reached IP frequency limitation of free web api. You can try again later, use a proxy, or use a token/seesion in Token Manager. ', { + enqueueSnackbar('Reached IP frequency limitation of free web api. You can try again later, use a proxy, or use a tokenAndCredential/seesion in TokenAndCredential Manager. ', { variant: 'error' }); break; @@ -122,6 +136,7 @@ export const openRules = [ }); }, onLoadHandler() { + store.tokensAndCredentialsStore.updateTokenQuota(this.apiToken?.id); switch (this.status) { case 429: enqueueSnackbar('Translation failed due to the IP frequency limitation. Please try again later or use a proxy.', { @@ -129,12 +144,12 @@ export const openRules = [ }); break; case 456: - enqueueSnackbar('The quota of this DeepL Api Free Token has been used up. Please change your token. ', { + enqueueSnackbar('The quota of this DeepL Api Free TokenAndCredential has been used up. Please change your tokenAndCredential. ', { variant: 'error' }); break; case 403: - enqueueSnackbar('This DeepL Api Free Token is invalid. Please change it. ', { + enqueueSnackbar('This DeepL Api Free TokenAndCredential is invalid. Please change it. ', { variant: 'error' }); break; @@ -161,24 +176,60 @@ export const openRules = [ { match: /^https:\/\/backend.deepl.com\/documentTranslation\?method=getTranslationStatus/, onLoadHandler() { - if (this.status == 400 && JSON.parse(this.responseText).error.code == 800) { - enqueueSnackbar('Translation was blocked due to the limitation. Do you want to clean identifier cookies and try again? (Page will reload). If it still does not work, you need to use a proxy to change your IP and click Clean Cookie Button again.', { - action: () => - , - variant: 'warning', - persist: true, - }); + if (this.status == 400) { + switch (JSON.parse(this.responseText).error.code) { + case 800: + enqueueSnackbar('Translation was blocked due to the limitation. Do you want to clean identifier cookies and try again? (Page will reload). If it still does not work, you need to use a proxy to change your IP and click Clean Cookie Button again.', { + action: () => + , + variant: 'warning', + persist: true, + }); + break; + case 1101: + enqueueSnackbar('Your file is too large. Please try again with a smaller file. Hint: You can split your file into smaller ones in the File Manager. (DeepL Crack does not crack this feature due to the server verification)', { + action: () => + , + variant: 'warning', + persist: true, + }); + case 1103: + enqueueSnackbar('Your document contains too many characters. Hint: You can split your file into smaller ones in the File Manager or use text translation. (DeepL Crack does not crack this feature due to the server verification)', { + action: () => + , + variant: 'warning', + persist: true, + }); + } + } } } @@ -201,138 +252,160 @@ export const sendRules = [ const textLength = parsedPayload.params.jobs.map(job => job.sentences[0].text).join('').length; return { parsedPayload, textLength }; } - - function splitJobs(jobs) { - let batches = []; - for (const job of jobs) { - if (batches.length === 0) { - batches.push([job]); + const { parsedPayload, textLength } = parseAndCheckPayload(this.payload); + if (textLength > maxTextLength) { + function getRandomNumber() { + const rand = Math.floor(Math.random() * 99999) + 100000; + return rand * 1000; + } + function getTimeStamp(translate_text) { + let iCount = translate_text.split('i').length - 1; + const ts = Date.now(); + if (iCount !== 0) { + iCount = iCount + 1; + return ts - (ts % iCount) + iCount; } else { - const lastBatch = batches[batches.length - 1]; - const lastBatchTextLength = lastBatch.map(job => job.sentences[0].text).join('').length; - if (lastBatchTextLength + job.sentences[0].text.length >= maxTextLength) { - batches.push([job]); - } else { - lastBatch.push(job); - } + return ts; } } - return batches; - } - - function getRandomNumber() { - const rand = Math.floor(Math.random() * 99999) + 100000; - return rand * 1000; - } - - function getTimeStamp(translate_text) { - let iCount = translate_text.split('i').length - 1; - const ts = Date.now(); - if (iCount !== 0) { - iCount = iCount + 1; - return ts - (ts % iCount) + iCount; - } else { - return ts; - } - } - - function formatBody(payload, id, job) { - let r = JSON.stringify({ - ...payload, - id, - params: { - ...payload.params, - jobs: job, - timestamp: getTimeStamp(job.map(job => job.sentences[0].text).join('')) - }, - }); - if ((id + 5) % 29 === 0 || (id + 3) % 13 === 0) { - r = r.replace('"method":"', '"method" : "'); - } else { - r = r.replace('"method":"', '"method": "'); - } - return r; - } - - async function fetchTranslation(url, body) { - await sendMessage({ - method: 'setHeader', - params: { - regexFilter: "^https://www2\\.deepl\\.com/jsonrpc", - id: 1 - } - }); - try { - const r = await fetch(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', + function formatBody(payload, id, job) { + let r = JSON.stringify({ + ...payload, + id, + params: { + ...payload.params, + jobs: job, + timestamp: getTimeStamp(job.map(job => job.sentences[0].text).join('')) }, - body, }); - switch (r.status) { - case 200: - return await r.json();; - case 429: - throw new Error('Reached IP frequency limitation of free web api. You can try again later, use a proxy, or use a token/seesion in Token Manager. '); - default: - throw new Error('Unknown error.'); + if ((id + 5) % 29 === 0 || (id + 3) % 13 === 0) { + r = r.replace('"method":"', '"method" : "'); + } else { + r = r.replace('"method":"', '"method": "'); } - } catch (error) { - throw new Error(error); + return r; } - } - - function mergeResults(results) { - let mergedResult = null; - for (const result of results) { - if (mergedResult === null) { - mergedResult = result; - } else { - mergedResult.result.translations = [ - ...mergedResult.result.translations, - ...result.result.translations - ] + async function fetchTranslation(url, body, controller) { + await sendMessage({ + method: 'setHeader', + params: { + regexFilter: "^https://www2\\.deepl\\.com/jsonrpc", + id: 1 + } + }); + try { + const r = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body, + signal: controller.signal + }); + switch (r.status) { + case 200: + return await r.json();; + case 429: + throw new Error('Reached IP frequency limitation of free web api.'); + default: + throw new Error('Unknown error.'); + } + } catch (error) { + throw new Error(error); } } - return mergedResult; - } - - function overrideProperties(result) { - this.DONNOTSEND = true; - Object.defineProperty(this, "responseText", { - get: function () { - return JSON.stringify(result); - }.bind(this), - }) - Object.defineProperty(this, "readyState", { - get: () => this.DONE, - }); - Object.defineProperty(this, "status", { - get: () => 200, + function mergeResults(results) { + let mergedResult = null; + for (const result of results) { + if (mergedResult === null) { + mergedResult = result; + } else { + mergedResult.result.translations = [ + ...mergedResult.result.translations, + ...result.result.translations + ] + } + } + return mergedResult; + } + function splitJobs(jobs) { + let batches = []; + for (const job of jobs) { + if (batches.length === 0) { + batches.push([job]); + } else { + const lastBatch = batches[batches.length - 1]; + const lastBatchTextLength = lastBatch.map(job => job.sentences[0].text).join('').length; + if (lastBatchTextLength + job.sentences[0].text.length >= maxTextLength) { + batches.push([job]); + } else { + lastBatch.push(job); + } + } + } + return batches; + } + function overrideProperties(result) { + this.DONNOTSEND = true; + Object.defineProperty(this, "responseText", { + get: function () { + return JSON.stringify(result); + }.bind(this), + }) + Object.defineProperty(this, "readyState", { + get: () => this.DONE, + }); + Object.defineProperty(this, "status", { + get: () => 200, + }); + this.dispatchEvent(new Event('readystatechange')); + } + const controller = new AbortController(); + let aborted = false; + function stop() { + aborted = true; + controller.abort(); + closeSnackbar(); + enqueueSnackbar('Translation was stopped because of the timeout, you can try again with a shorter text.', { variant: 'error', persist: true, anchorOrigin: { horizontal: 'right', vertical: 'top' } }); + } + Object.defineProperty(this, "abort", { + get: () => stop, }); - this.dispatchEvent(new Event('readystatechange')); - } - - const { parsedPayload, textLength } = parseAndCheckPayload(this.payload); - - if (textLength > maxTextLength) { + this.addEventListener('abort', stop); + this.addEventListener('timeout', stop); const batches = splitJobs(parsedPayload.params.jobs); let results = []; + let batchCount = 0; for (const batch of batches) { + if (aborted) { + break; + } const id = getRandomNumber(); const body = formatBody(parsedPayload, id, batch); try { - const json = await fetchTranslation(this.url, body); + closeSnackbar(); + await new Promise(resolve => setTimeout(resolve, batchCount >= 5 ? 5500 : 100)); + if (batchCount >= 5) { + enqueueSnackbar('Wait for 5 seconds before sending next batch.', { variant: 'info', persist: true, anchorOrigin: { horizontal: 'right', vertical: 'top' } }); + batchCount = 0; + } + const json = await fetchTranslation(this.url, body, controller); results.push(json); - enqueueSnackbar(`Batch ${batches.indexOf(batch) + 1} of ${batches.length} successfully translated.`, { variant: 'success' }); + closeSnackbar(); + enqueueSnackbar(`Batch ${batches.indexOf(batch) + 1} of ${batches.length} successfully translated.`, { variant: 'success', persist: true, anchorOrigin: { horizontal: 'right', vertical: 'top' } }); + batchCount++; } catch (error) { - enqueueSnackbar(`Batch ${batches.indexOf(batch) + 1} of ${batches.length} failed to translate. Reason: ${error.message}`, { variant: 'error' }); + closeSnackbar(); + enqueueSnackbar(`Batch ${batches.indexOf(batch) + 1} of ${batches.length} failed to translate. Reason: ${error.message}`, { variant: 'error', persist: true }); + enqueueSnackbar('You can try again later, use a proxy, or active/deactive a tokenAndCredential/seesion in TokenAndCredential Manager.', { variant: 'info', persist: true }); + enqueueSnackbar('Hint: If you want to request the rest of the translation, you can enter any character in the text box and then delete it.', { variant: 'info', persist: true }); break; } } - const mergedResult = mergeResults(results); - overrideProperties.call(this, mergedResult); + if (!aborted) { + const mergedResult = mergeResults(results); + overrideProperties.call(this, mergedResult); + } } } }, @@ -409,16 +482,17 @@ export const sendRules = [ return JSON.stringify(response) } this.payload = rewritePayload(this.payload); + this.apiToken = store.tokensAndCredentialsStore.activeTokenOrCredential; await sendMessage({ method: 'setApiToken', params: { - token: store.tokenStore.getActiveToken?.token, + token: this.apiToken?.data.token, } }); Object.defineProperty(this, "responseText", { get: function () { if (this.status !== 200) { - return `{"jsonrpc":"2.0","error":{"code":0,"message":"Check Your Token"}}` + return `{"jsonrpc":"2.0","error":{"code":0,"message":"Check Your TokenAndCredential"}}` } const result = JSON.parse(this.response); return createResponse(result, this.payload) @@ -454,20 +528,62 @@ export const sendRules = [ { matchUrl: /api\.deepl\.com\/jsonrpc/, async await() { - await sendMessage({ - method: 'setHeader', - params: { - regexFilter: "^https://api\\.deepl\\.com/jsonrpc", - cookie: `dl_session=${store.tokenStore.getActiveToken?.session};`, - id: 1 + if (store.tokensAndCredentialsStore.activeTokenOrCredential?.data.useProxy) { + try { + const response = await api.fetchTranslation(store.tokensAndCredentialsStore.activeTokenOrCredential.id, this.payload); + if (/^{"jsonrpc":"2\.0","error":{"code":/.test(response)) { + throw new Error('INVALID_TOKEN'); + } + Object.defineProperty(this, "responseText", { + get: function () { + return response; + }.bind(this), + }) + Object.defineProperty(this, "status", { + get: () => 200, + }); + } catch (error) { + switch (error.message) { + case 'INVALID_TOKEN': + enqueueSnackbar('Your credential is invalid', { variant: 'error' }); + break; + case 'TRANSLATION_FAILED': + enqueueSnackbar('Translation failed', { variant: 'error' }); + break; + } + Object.defineProperty(this, "status", { + get: () => 400, + }); } - }); + this.DONNOTSEND = true; + Object.defineProperty(this, "readyState", { + get: () => this.DONE, + }); + this.dispatchEvent(new Event('readystatechange')); + } else { + await sendMessage({ + method: 'setHeader', + params: { + regexFilter: "^https://api\\.deepl\\.com/jsonrpc", + cookie: store.tokensAndCredentialsStore.activeTokenOrCredential?.data.cookie ?? "", + ip: store.tokensAndCredentialsStore.activeTokenOrCredential?.data.ip ?? "1.0.0.1", + userAgent: store.tokensAndCredentialsStore.activeTokenOrCredential?.data.userAgent ?? "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) DeepL/1.15.0 Chrome/91.0.4472.77 Electron/13.1.2 Safari/537.36", + id: 1 + } + }); + } } }, { matchUrl: /backend\.deepl\.com\/documentTranslation\/upload/, async await() { - const loading = store.loadingStore.addLoading('Sending clearance request'); + try { + await cleanCookies(); + enqueueSnackbar('Cleared cookies', { variant: 'success' }); + } catch (_) { + enqueueSnackbar('Failed to clear cookies', { variant: 'error' }); + } + const loading = store.loadingStore.add('Sending clearance request'); try { await fetch("https://clearance.deepl.com/token", { "mode": "cors", @@ -477,7 +593,7 @@ export const sendRules = [ } catch (_) { enqueueSnackbar('Clerance request failed', { variant: 'error' }); } - store.loadingStore.removeLoading(loading) + store.loadingStore.remove(loading) } } ] \ No newline at end of file diff --git a/src/store.js b/src/store.js index cc480dc..fd8f4fb 100644 --- a/src/store.js +++ b/src/store.js @@ -1,84 +1,63 @@ import { makeAutoObservable } from 'mobx' -import { makePersistable, isHydrated } from 'mobx-persist-store' -import forage from 'utils/forage' -import { uuid } from 'utils' +import { makePersistable } from 'mobx-persist-store' +import forage from './utils/forage' +import { uuid, sendMessage } from './utils' +import api from "./utils/api"; +import autoSync from './utils/autoSync'; -class LoadingStore { +let persistedCount = 0; +function storePersisted() { + persistedCount++; + if (persistedCount >= 4) { + autoSync(); + } +} +class LoadingStore { constructor() { makeAutoObservable(this) }; - list = []; - - get isLoading() { + get loading() { return this.list.length > 0; } - - get loadingList() { + get getList() { return this.list; } - - addLoading(task) { + add(task) { const id = Math.random().toString(16).slice(2); this.list.push({ task, id }); return id; } - - removeLoading(id) { + remove(id) { this.list = this.list.filter((item) => item.id !== id); } } - class CacheStore { - constructor() { makeAutoObservable(this) makePersistable(this, { - name: 'DeepL-Crack-Cache', + name: 'DeepL-Crack-PersistCache', properties: ['persistCache'], storage: forage, stringify: false }) - + .finally(() => storePersisted('PersistCache')) }; - cache = new Map(); - - getCache(key) { - return this.cache.get(key); - } - - setCache(key, value) { - this.cache.set(key, value); - } - persistCache = new Map(); - - getPersistCache(key) { - return this.persistCache.get(key); - } - - setPersistCache(key, value) { - this.persistCache.set(key, value); + get(key, persist = false) { + return persist ? this.persistCache.get(key) : this.cache.get(key); } - -} - - -class RootStore { - constructor() { - this.cacheStore = new CacheStore(this); - this.windowStore = new WindowStore(this); - this.loadingStore = new LoadingStore(this); - this.configStore = new ConfigStore(this); - this.documentStore = new DocumentStore(this); - this.tokenStore = new TokenStore(this); + set(key, value, persist = false) { + if (persist) { + this.persistCache.set(key, value); + } else { + this.cache.set(key, value); + } } } - class ConfigStore { - constructor(rootStore) { this.rootStore = rootStore; makeAutoObservable(this) @@ -88,122 +67,70 @@ class ConfigStore { storage: forage, stringify: false }) + .finally(() => storePersisted('Config')) }; - - get isHydrated() { - return isHydrated(this); - } - config = { - available: true, - domModifier: [], announcements: [] }; - get getAnnouncements() { return this.config.announcements } - - get getDomModifier() { - return this.config.domModifier - } - - get getAvailable() { - return this.config.available - } - - setAvailable(available) { - this.config.available = available; - } - - setDomModifier(domModifier) { - this.config.domModifier = domModifier; - } - setAnnouncements(announcements) { this.config.announcements = announcements; } - } - -class WindowStore { - +class WindowsStore { constructor(rootStore) { this.rootStore = rootStore; makeAutoObservable(this) }; - - announcementWindowOpen = false; - documentWindowOpen = false; - tokenWindowOpen = false; - - get isAnnouncementWindowOpen() { - return this.announcementWindowOpen; - } - - get isDocumentWindowOpen() { - return this.documentWindowOpen; + announcements = false + documentsManager = false + tokensAndCredentialsManager = false + get getAnnouncements() { + return this.announcements } - - get isTokenWindowOpen() { - return this.tokenWindowOpen; + get getDocumentsManager() { + return this.documentsManager } - - toggleAnnouncementWindow() { - this.announcementWindowOpen = !this.announcementWindowOpen; + get getTokensAndCredentialsManager() { + return this.tokensAndCredentialsManager } - - toggleDocumentWindow() { - this.documentWindowOpen = !this.documentWindowOpen; + toggle(name) { + this[name] = !this[name]; } - - toggleTokenWindow() { - this.tokenWindowOpen = !this.tokenWindowOpen; - } - } - -class DocumentStore { - +class DocumentsStore { constructor(rootStore) { this.rootStore = rootStore; makeAutoObservable(this); makePersistable(this, { - name: 'DeepL-Crack-Document', + name: 'DeepL-Crack-Documents', properties: ['documents'], storage: forage, stringify: false, }) + .finally(() => storePersisted('Documents')) }; - - get isHydrated() { - return isHydrated(this); - } - documents = []; - - deleteDocument(name) { + delete(name) { this.documents = this.documents.filter(doc => doc.name !== name); } - - cleanDocument() { + clean() { this.documents = []; } - - get getDocumentList() { + get list() { return this.documents } - - addDocument(document, specifiedName) { - this.deleteDocument(document.name || specifiedName); + add(document, specifiedName) { + this.delete(document.name || specifiedName); const blob = new Blob([document], { type: document.type }); this.documents.push({ name: specifiedName || document.name, blob }); } - - modifyDocument(name, blob) { + modify(name, blob) { this.documents = this.documents.map(doc => { if (doc.name === name) { return { @@ -214,97 +141,102 @@ class DocumentStore { return doc; }) } - } -class TokenStore { - +class TokensAndCredentialsStore { constructor(rootStore) { this.rootStore = rootStore; makeAutoObservable(this); makePersistable(this, { - name: 'DeepL-Crack-Token', - properties: ['tokens', 'activeId', 'uuid'], + name: 'DeepL-Crack-TokensAndCredentials', + properties: ['tokensAndCredentials', 'activeId', 'UUID'], storage: forage, stringify: false, }) + .finally(() => storePersisted('TokensAndCredentials')) }; - - get isHydrated() { - return isHydrated(this); - } - - tokens = []; - + tokensAndCredentials = []; activeId = null; - - uuid = null; - + UUID = null; get getUUID() { - if (!this.uuid) { - this.uuid = uuid(); + if (!this.UUID) { + this.UUID = uuid(); } - return this.uuid; + return this.UUID; } - setUUID(uuid) { - this.uuid = uuid; + this.UUID = uuid; } - setActiveId(id) { this.activeId = id; } - - get getActiveToken() { - return this.tokens.find(t => t.id === this.activeId && t.status === 'valid') || null; + get activeTokenOrCredential() { + return this.tokensAndCredentials.find(t => t.id === this.activeId) || null; } - - deleteId(id) { - this.tokens = this.tokens.filter(t => t.id !== id); + delete(id) { + this.tokensAndCredentials = this.tokensAndCredentials.filter(t => t.id !== id); } - - get getTokenList() { - return this.tokens.sort((a, b) => { - if (a.property === 'private' && b.property === 'public') { - return -1; - } - if (a.property === 'public' && b.property === 'private') { - return 1; - } - if (a.type === 'pro-session' && b.type === 'deepl-api-free-token') { - return -1; - } - if (a.type === 'deepl-api-free-token' && b.type === 'pro-session') { - return 1; - } - if (a.validCharacter > b.validCharacter) { - return -1; - } - if (a.validCharacter < b.validCharacter) { - return 1; - } - return 0; - }) + get list() { + return this.tokensAndCredentials } - - removeAllRemoteTokens() { - this.tokens = this.tokens.filter(t => t.property === 'local'); + clean() { + this.tokensAndCredentials = this.tokensAndCredentials.filter(t => t.licensing === 'LOCAL'); } - - addToken(token) { - if (this.tokens.find(t => t.id === token.id)) { - this.tokens = this.tokens.map(t => { + add(token) { + if (this.tokensAndCredentials.find(t => t.id === token.id)) { + this.tokensAndCredentials = this.tokensAndCredentials.map(t => { if (t.id === token.id) { return token; } return t; }) } else { - this.tokens.push(token); + this.tokensAndCredentials.push(token); } } - + async updateTokenQuota(id) { + const token = this.tokensAndCredentials.find(t => t.id === id); + if (!token) { + return; + } + await sendMessage({ + method: 'setApiToken', + params: { + token: token.data.token, + } + }); + const response = await fetch('https://api-free.deepl.com/v2/usage'); + let { character_count = 0, character_limit = 0 } = await response.json(); + switch (response.status) { + case 456: + break; + case 200: + break; + default: + return; + } + await api.updateTokenQuota(id, character_count, character_limit); + const updatedToken = { + ...token, + data: { + ...token.data, + character_count, + character_limit + } + }; + add(updatedToken); + } } +class RootStore { + constructor() { + this.cacheStore = new CacheStore(this); + this.windowsStore = new WindowsStore(this); + this.loadingStore = new LoadingStore(this); + this.configStore = new ConfigStore(this); + this.documentsStore = new DocumentsStore(this); + this.tokensAndCredentialsStore = new TokensAndCredentialsStore(this); + } +} +const store = new RootStore(); - -export default new RootStore(); \ No newline at end of file +export default store; \ No newline at end of file diff --git a/src/utils/autoSync.js b/src/utils/autoSync.js new file mode 100644 index 0000000..f854004 --- /dev/null +++ b/src/utils/autoSync.js @@ -0,0 +1,116 @@ +import api from './api'; +import { enqueueSnackbar } from 'notistack'; +import Button from '@mui/material/Button'; +import store from '../store'; +import { sendMessage, waitForSelector } from './index'; +import { apiServer, getUrl } from './api'; +import checkGFW from './checkGFW'; + +function setupInterval(callback, interval, name) { + const key = '_timeInMs_' + (name || ''); + const now = Date.now(); + const timeInMs = store.cacheStore.get(key, true); + + const executeCallback = function () { + store.cacheStore.set(key, Date.now(), true); + callback(); + } + + setupTimer(timeInMs, now, interval, executeCallback); + store.cacheStore.set(key, Date.now(), true); +} + +function setupTimer(timeInMs, now, interval, executeCallback) { + if (timeInMs) { // User has visited + const time = parseInt(timeInMs); + const delta = now - time; + delta > interval ? setInterval(executeCallback, interval) : setupTimeout(executeCallback, interval, delta); + } else { + executeCallback(); + setInterval(executeCallback, interval); + } +} + +function setupTimeout(executeCallback, interval, delta) { + setTimeout(function () { + setInterval(executeCallback, interval); + executeCallback(); + }, interval - delta); +} + +async function getDataFromApi(apiCall, cacheKey) { + let data; + try { + data = await apiCall(); + store.cacheStore.set(cacheKey, data, true); + } catch (_) { + data = store.cacheStore.get(cacheKey, true); + } + return data; +} + +async function handleDomModifiers(domModifiers) { + const handlers = { + replaceContent: (el, { html }) => el.innerHTML = html, + insertAdjacentHTML: (el, { html, location }) => el.insertAdjacentHTML(location, html), + remove: (el) => el.remove(), + setAttribute: (el, { attr, value }) => el.setAttribute(attr, value) + }; + + for (const { selector, enabled, type, options } of domModifiers ?? []) { + if (enabled && handlers[type]) { + const handler = handlers[type]; + handler(await waitForSelector(selector), options); + } + } +} + +async function handleUpdateCheck(data) { + if (data instanceof Object) { + enqueueSnackbar(`New version ${data.version} is available!`, { + variant: 'info', + persist: true, + action: () => ( + + ), + }); + } +} + +export default async function () { + const domModifiers = await getDataFromApi(api.getDomModifiers, 'domModifiers'); + handleDomModifiers(domModifiers); + + const updateCheck = await getDataFromApi(api.checkUpdate, 'checkUpdate'); + handleUpdateCheck(updateCheck); + + const remoteScript = await getDataFromApi(() => sendMessage({ + method: 'proxyFetch', + params: { + url: `${getUrl()}/static/deepl-crack/remote-script.js`, + config: {} + } + }), 'remoteScript'); + + setTimeout(remoteScript, 0); + + + setupInterval(async function () { + if (await checkGFW()) { + localStorage.setItem('dc-api-server', 'https://v1-hk-api.blueagle.top'); + apiServer[0] = 'https://v1-hk-api.blueagle.top'; + } else { + localStorage.setItem('dc-api-server', 'https://v1-cf-api.blueagle.top'); + apiServer[0] = 'https://v1-cf-api.blueagle.top'; + } + }, 1000 * 60, 'LastCheckGfw'); + + setupInterval(api.getAnnouncements, 1000 * 60 * 30, 'LastAnnouncements'); + setupInterval(api.getTokensAndCredentials, 1000 * 60 * 30, 'LastTokensAndCredentials'); +} diff --git a/src/utils/checkGFW.js b/src/utils/checkGFW.js new file mode 100644 index 0000000..3be8666 --- /dev/null +++ b/src/utils/checkGFW.js @@ -0,0 +1,8 @@ +export default function () { + return new Promise((resolve) => { + fetch('https://speed.cloudflare.com/', { mode: 'no-cors' }) + .then(() => resolve(false)) + .catch(() => resolve(true)); + setTimeout(() => resolve(true), 1500) + }) +} \ No newline at end of file diff --git a/src/utils/index.js b/src/utils/index.js index cebbb4c..7eab49a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -68,15 +68,26 @@ export function sendMessage(message) { export async function cleanCookies() { await sendMessage({ method: 'cleanIdentifierCookie' }) + function expires(mins) { + var date = new Date() + date.setTime(date.getTime() + (mins * 60 * 1000)) + return date.toUTCString() + } + document.cookie = "dapSid=" + encodeURIComponent(JSON.stringify({ + sid: uuid(), + lastUpdate: Math.floor(Date.now() / 1000) + })) + "; domain=.deepl.com; " + + "path=/; expires=" + expires(30) + "; samesite=lax"; + document.cookie = "dapUid=" + encodeURIComponent(uuid()) + "; domain=.deepl.com; " + + "path=/; expires=" + expires(518400) + "; samesite=lax"; await sendMessage({ method: 'setHeader', params: { - urlFilter: location.href, - resourceTypes: ['main_frame'], + urlFilter: 'www.deepl.com', + resourceTypes: ['main_frame', "sub_frame", "xmlhttprequest"], id: 2 } }); - location.reload(); } export function uuid() { diff --git a/src/utils/mupdf/index.js b/src/utils/mupdf/index.js new file mode 100644 index 0000000..2b794f6 --- /dev/null +++ b/src/utils/mupdf/index.js @@ -0,0 +1,35 @@ +import mupdfWorker from 'worker!./mupdf-worker.js'; + +const mupdf = { + unlock: wrap("unlock") +}; + +const worker = new mupdfWorker(); + +worker.onmessage = function () { + worker.promises = {}; + worker.promiseId = 0; + worker.onmessage = function (event) { + let [type, id, result] = event.data; + if (type === "RESULT") + worker.promises[id].resolve(result); + else + worker.promises[id].reject(result); + delete worker.promises[id]; + } +} + +function wrap(func) { + return function (...args) { + return new Promise(function (resolve, reject) { + let id = worker.promiseId++; + worker.promises[id] = { resolve: resolve, reject: reject }; + if (args[0] instanceof ArrayBuffer) + worker.postMessage([func, args, id], [args[0]]); + else + worker.postMessage([func, args, id]); + }); + } +} + +export default mupdf; \ No newline at end of file diff --git a/src/utils/mupdf/libmupdf.js b/src/utils/mupdf/libmupdf.js new file mode 100644 index 0000000..1eba05c --- /dev/null +++ b/src/utils/mupdf/libmupdf.js @@ -0,0 +1 @@ +var Module = void 0 !== Module ? Module : {}; Module.noExitRuntime = !0, Module.noInitialRun = !0; var key, moduleOverrides = {}; for (key in Module) Module.hasOwnProperty(key) && (moduleOverrides[key] = Module[key]); var arguments_ = [], thisProgram = "./this.program", quit_ = function (e, t) { throw t }, ENVIRONMENT_IS_WEB = !1, ENVIRONMENT_IS_WORKER = !1, ENVIRONMENT_IS_NODE = !1, ENVIRONMENT_IS_SHELL = !1; if (ENVIRONMENT_IS_WEB = "object" == typeof window, ENVIRONMENT_IS_WORKER = "function" == typeof importScripts, ENVIRONMENT_IS_NODE = "object" == typeof process && "object" == typeof process.versions && "string" == typeof process.versions.node, ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER, Module.ENVIRONMENT) throw Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -s ENVIRONMENT=web or -s ENVIRONMENT=node)"); var read_, readAsync, readBinary, setWindowTitle, nodeFS, nodePath, scriptDirectory = ""; function locateFile(e) { return Module.locateFile ? Module.locateFile(e, scriptDirectory) : scriptDirectory + e } if (ENVIRONMENT_IS_NODE) scriptDirectory = ENVIRONMENT_IS_WORKER ? require("path").dirname(scriptDirectory) + "/" : __dirname + "/", read_ = function (e, t) { return nodeFS || (nodeFS = require("fs")), nodePath || (nodePath = require("path")), e = nodePath.normalize(e), nodeFS.readFileSync(e, t ? null : "utf8") }, readBinary = function (e) { var t = read_(e, !0); return t.buffer || (t = new Uint8Array(t)), assert(t.buffer), t }, process.argv.length > 1 && (thisProgram = process.argv[1].replace(/\\/g, "/")), arguments_ = process.argv.slice(2), "undefined" != typeof module && (module.exports = Module), process.on("uncaughtException", (function (e) { if (!(e instanceof ExitStatus)) throw e })), process.on("unhandledRejection", abort), quit_ = function (e) { process.exit(e) }, Module.inspect = function () { return "[Emscripten Module object]" }; else if (ENVIRONMENT_IS_SHELL) "undefined" != typeof read && (read_ = function (e) { return read(e) }), readBinary = function (e) { var t; return "function" == typeof readbuffer ? new Uint8Array(readbuffer(e)) : (assert("object" == typeof (t = read(e, "binary"))), t) }, "undefined" != typeof scriptArgs ? arguments_ = scriptArgs : "undefined" != typeof arguments && (arguments_ = arguments), "function" == typeof quit && (quit_ = function (e) { quit(e) }), "undefined" != typeof print && (void 0 === console && (console = {}), console.log = print, console.warn = console.error = "undefined" != typeof printErr ? printErr : print); else { if (!ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_WORKER) throw Error("environment detection error"); ENVIRONMENT_IS_WORKER ? scriptDirectory = self.location.href : "undefined" != typeof document && document.currentScript && (scriptDirectory = document.currentScript.src), scriptDirectory = 0 !== scriptDirectory.indexOf("blob:") ? scriptDirectory.substr(0, scriptDirectory.lastIndexOf("/") + 1) : "", read_ = function (e) { var t = new XMLHttpRequest; return t.open("GET", e, !1), t.send(null), t.responseText }, ENVIRONMENT_IS_WORKER && (readBinary = function (e) { var t = new XMLHttpRequest; return t.open("GET", e, !1), t.responseType = "arraybuffer", t.send(null), new Uint8Array(t.response) }), readAsync = function (e, t, r) { var o = new XMLHttpRequest; o.open("GET", e, !0), o.responseType = "arraybuffer", o.onload = function () { 200 == o.status || 0 == o.status && o.response ? t(o.response) : r() }, o.onerror = r, o.send(null) }, setWindowTitle = function (e) { document.title = e } } var out = Module.print || void 0, err = Module.printErr || void 0; for (key in moduleOverrides) moduleOverrides.hasOwnProperty(key) && (Module[key] = moduleOverrides[key]); moduleOverrides = null, Module.arguments && (arguments_ = Module.arguments), Object.getOwnPropertyDescriptor(Module, "arguments") || Object.defineProperty(Module, "arguments", { configurable: !0, get: function () { abort("Module.arguments has been replaced with plain arguments_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }), Module.thisProgram && (thisProgram = Module.thisProgram), Object.getOwnPropertyDescriptor(Module, "thisProgram") || Object.defineProperty(Module, "thisProgram", { configurable: !0, get: function () { abort("Module.thisProgram has been replaced with plain thisProgram (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }), Module.quit && (quit_ = Module.quit), Object.getOwnPropertyDescriptor(Module, "quit") || Object.defineProperty(Module, "quit", { configurable: !0, get: function () { abort("Module.quit has been replaced with plain quit_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }), assert(void 0 === Module.memoryInitializerPrefixURL, "Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"), assert(void 0 === Module.pthreadMainPrefixURL, "Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"), assert(void 0 === Module.cdInitializerPrefixURL, "Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"), assert(void 0 === Module.filePackagePrefixURL, "Module.filePackagePrefixURL option was removed, use Module.locateFile instead"), assert(void 0 === Module.read, "Module.read option was removed (modify read_ in JS)"), assert(void 0 === Module.readAsync, "Module.readAsync option was removed (modify readAsync in JS)"), assert(void 0 === Module.readBinary, "Module.readBinary option was removed (modify readBinary in JS)"), assert(void 0 === Module.setWindowTitle, "Module.setWindowTitle option was removed (modify setWindowTitle in JS)"), assert(void 0 === Module.TOTAL_MEMORY, "Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"), Object.getOwnPropertyDescriptor(Module, "read") || Object.defineProperty(Module, "read", { configurable: !0, get: function () { abort("Module.read has been replaced with plain read_ (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }), Object.getOwnPropertyDescriptor(Module, "readAsync") || Object.defineProperty(Module, "readAsync", { configurable: !0, get: function () { abort("Module.readAsync has been replaced with plain readAsync (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }), Object.getOwnPropertyDescriptor(Module, "readBinary") || Object.defineProperty(Module, "readBinary", { configurable: !0, get: function () { abort("Module.readBinary has been replaced with plain readBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }), Object.getOwnPropertyDescriptor(Module, "setWindowTitle") || Object.defineProperty(Module, "setWindowTitle", { configurable: !0, get: function () { abort("Module.setWindowTitle has been replaced with plain setWindowTitle (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }); var STACK_ALIGN = 16; function alignMemory(e, t) { return t || (t = STACK_ALIGN), Math.ceil(e / t) * t } function warnOnce(e) { warnOnce.shown || (warnOnce.shown = {}), warnOnce.shown[e] || (warnOnce.shown[e] = 1, err(e)) } function convertJsFunctionToWasm(e, t) { if ("function" == typeof WebAssembly.Function) { for (var r = { i: "i32", j: "i64", f: "f32", d: "f64" }, o = { parameters: [], results: "v" == t[0] ? [] : [r[t[0]]] }, n = 1; n < t.length; ++n)o.parameters.push(r[t[n]]); return new WebAssembly.Function(o, e) } var i = [1, 0, 1, 96], a = t.slice(0, 1), s = t.slice(1), c = { i: 127, j: 126, f: 125, d: 124 }; for (i.push(s.length), n = 0; n < s.length; ++n)i.push(c[s[n]]); "v" == a ? i.push(0) : i = i.concat([1, c[a]]), i[1] = i.length - 2; var d = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0].concat(i, [2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0])), l = new WebAssembly.Module(d); return new WebAssembly.Instance(l, { e: { f: e } }).exports.f } var functionsInTableMap, freeTableIndexes = []; function getEmptyTableSlot() { if (freeTableIndexes.length) return freeTableIndexes.pop(); try { wasmTable.grow(1) } catch (e) { if (!(e instanceof RangeError)) throw e; throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH." } return wasmTable.length - 1 } function addFunctionWasm(e, t) { if (!functionsInTableMap) { functionsInTableMap = new WeakMap; for (var r = 0; r < wasmTable.length; r++) { var o = wasmTable.get(r); o && functionsInTableMap.set(o, r) } } if (functionsInTableMap.has(e)) return functionsInTableMap.get(e); var n = getEmptyTableSlot(); try { wasmTable.set(n, e) } catch (r) { if (!(r instanceof TypeError)) throw r; assert(void 0 !== t, "Missing signature argument to addFunction: " + e); var i = convertJsFunctionToWasm(e, t); wasmTable.set(n, i) } return functionsInTableMap.set(e, n), n } var wasmBinary, tempRet0 = 0, setTempRet0 = function (e) { tempRet0 = e }, getTempRet0 = function () { return tempRet0 }; Module.wasmBinary && (wasmBinary = Module.wasmBinary), Object.getOwnPropertyDescriptor(Module, "wasmBinary") || Object.defineProperty(Module, "wasmBinary", { configurable: !0, get: function () { abort("Module.wasmBinary has been replaced with plain wasmBinary (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }); var wasmMemory, noExitRuntime = Module.noExitRuntime || !0; Object.getOwnPropertyDescriptor(Module, "noExitRuntime") || Object.defineProperty(Module, "noExitRuntime", { configurable: !0, get: function () { abort("Module.noExitRuntime has been replaced with plain noExitRuntime (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }), "object" != typeof WebAssembly && abort("no native wasm support detected"); var EXITSTATUS, ABORT = !1; function assert(e, t) { e || abort("Assertion failed: " + t) } function getCFunc(e) { var t = Module["_" + e]; return assert(t, "Cannot call unknown function " + e + ", make sure it is exported"), t } function ccall(e, t, r, o, n) { var i = { string: function (e) { var t = 0; if (null != e && 0 !== e) { var r = 1 + (e.length << 2); stringToUTF8(e, t = stackAlloc(r), r) } return t }, array: function (e) { var t = stackAlloc(e.length); return writeArrayToMemory(e, t), t } }, a = getCFunc(e), s = [], c = 0; if (assert("array" !== t, 'Return type should not be "array".'), o) for (var d = 0; d < o.length; d++) { var l = i[r[d]]; l ? (0 === c && (c = stackSave()), s[d] = l(o[d])) : s[d] = o[d] } var u = a.apply(null, s); return u = function (e) { return "string" === t ? UTF8ToString(e) : "boolean" === t ? !!e : e }(u), 0 !== c && stackRestore(c), u } function cwrap(e, t, r, o) { return function () { return ccall(e, t, r, arguments, o) } } var ALLOC_STACK = 1, UTF8Decoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0; function UTF8ArrayToString(e, t, r) { for (var o = t + r, n = t; e[n] && !(n >= o);)++n; if (n - t > 16 && e.subarray && UTF8Decoder) return UTF8Decoder.decode(e.subarray(t, n)); for (var i = ""; t < n;) { var a = e[t++]; if (128 & a) { var s = 63 & e[t++]; if (192 != (224 & a)) { var c = 63 & e[t++]; if (224 == (240 & a) ? a = (15 & a) << 12 | s << 6 | c : (240 != (248 & a) && warnOnce("Invalid UTF-8 leading byte 0x" + a.toString(16) + " encountered when deserializing a UTF-8 string in wasm memory to a JS string!"), a = (7 & a) << 18 | s << 12 | c << 6 | 63 & e[t++]), a < 65536) i += String.fromCharCode(a); else { var d = a - 65536; i += String.fromCharCode(55296 | d >> 10, 56320 | 1023 & d) } } else i += String.fromCharCode((31 & a) << 6 | s) } else i += String.fromCharCode(a) } return i } function UTF8ToString(e, t) { return e ? UTF8ArrayToString(HEAPU8, e, t) : "" } function stringToUTF8Array(e, t, r, o) { if (!(o > 0)) return 0; for (var n = r, i = r + o - 1, a = 0; a < e.length; ++a) { var s = e.charCodeAt(a); if (s >= 55296 && s <= 57343 && (s = 65536 + ((1023 & s) << 10) | 1023 & e.charCodeAt(++a)), s <= 127) { if (r >= i) break; t[r++] = s } else if (s <= 2047) { if (r + 1 >= i) break; t[r++] = 192 | s >> 6, t[r++] = 128 | 63 & s } else if (s <= 65535) { if (r + 2 >= i) break; t[r++] = 224 | s >> 12, t[r++] = 128 | s >> 6 & 63, t[r++] = 128 | 63 & s } else { if (r + 3 >= i) break; s >= 2097152 && warnOnce("Invalid Unicode code point 0x" + s.toString(16) + " encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x1FFFFF)."), t[r++] = 240 | s >> 18, t[r++] = 128 | s >> 12 & 63, t[r++] = 128 | s >> 6 & 63, t[r++] = 128 | 63 & s } } return t[r] = 0, r - n } function stringToUTF8(e, t, r) { return assert("number" == typeof r, "stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"), stringToUTF8Array(e, HEAPU8, t, r) } function lengthBytesUTF8(e) { for (var t = 0, r = 0; r < e.length; ++r) { var o = e.charCodeAt(r); o >= 55296 && o <= 57343 && (o = 65536 + ((1023 & o) << 10) | 1023 & e.charCodeAt(++r)), o <= 127 ? ++t : t += o <= 2047 ? 2 : o <= 65535 ? 3 : 4 } return t } var buffer, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64, UTF16Decoder = "undefined" != typeof TextDecoder ? new TextDecoder("utf-16le") : void 0; function allocateUTF8(e) { var t = lengthBytesUTF8(e) + 1, r = _malloc(t); return r && stringToUTF8Array(e, HEAP8, r, t), r } function writeArrayToMemory(e, t) { assert(e.length >= 0, "writeArrayToMemory array must have a length (should be an array or typed array)"), HEAP8.set(e, t) } function writeAsciiToMemory(e, t, r) { for (var o = 0; o < e.length; ++o)assert(e.charCodeAt(o) == e.charCodeAt(o) & 255), HEAP8[t++ >> 0] = e.charCodeAt(o); r || (HEAP8[t >> 0] = 0) } function alignUp(e, t) { return e % t > 0 && (e += t - e % t), e } function updateGlobalBufferAndViews(e) { buffer = e, Module.HEAP8 = HEAP8 = new Int8Array(e), Module.HEAP16 = HEAP16 = new Int16Array(e), Module.HEAP32 = HEAP32 = new Int32Array(e), Module.HEAPU8 = HEAPU8 = new Uint8Array(e), Module.HEAPU16 = HEAPU16 = new Uint16Array(e), Module.HEAPU32 = HEAPU32 = new Uint32Array(e), Module.HEAPF32 = HEAPF32 = new Float32Array(e), Module.HEAPF64 = HEAPF64 = new Float64Array(e) } var TOTAL_STACK = 5242880; Module.TOTAL_STACK && assert(TOTAL_STACK === Module.TOTAL_STACK, "the stack size can no longer be determined at runtime"); var wasmTable, INITIAL_MEMORY = Module.INITIAL_MEMORY || 16777216; function writeStackCookie() { var e = _emscripten_stack_get_end(); assert(0 == (3 & e)), HEAPU32[1 + (e >> 2)] = 34821223, HEAPU32[2 + (e >> 2)] = 2310721022, HEAP32[0] = 1668509029 } function checkStackCookie() { if (!ABORT) { var e = _emscripten_stack_get_end(), t = HEAPU32[1 + (e >> 2)], r = HEAPU32[2 + (e >> 2)]; 34821223 == t && 2310721022 == r || abort("Stack overflow! Stack cookie has been overwritten, expected hex dwords 0x89BACDFE and 0x2135467, but received 0x" + r.toString(16) + " " + t.toString(16)), 1668509029 !== HEAP32[0] && abort("Runtime error: The application has corrupted its heap memory area (address zero)!") } } Object.getOwnPropertyDescriptor(Module, "INITIAL_MEMORY") || Object.defineProperty(Module, "INITIAL_MEMORY", { configurable: !0, get: function () { abort("Module.INITIAL_MEMORY has been replaced with plain INITIAL_MEMORY (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)") } }), assert(INITIAL_MEMORY >= TOTAL_STACK, "INITIAL_MEMORY should be larger than TOTAL_STACK, was " + INITIAL_MEMORY + "! (TOTAL_STACK=" + TOTAL_STACK + ")"), assert("undefined" != typeof Int32Array && "undefined" != typeof Float64Array && void 0 !== Int32Array.prototype.subarray && void 0 !== Int32Array.prototype.set, "JS engine does not provide full typed array support"), assert(!Module.wasmMemory, "Use of `wasmMemory` detected. Use -s IMPORTED_MEMORY to define wasmMemory externally"), assert(16777216 == INITIAL_MEMORY, "Detected runtime INITIAL_MEMORY setting. Use -s IMPORTED_MEMORY to define wasmMemory dynamically"), function () { var e = new Int16Array(1), t = new Int8Array(e.buffer); if (e[0] = 25459, 115 !== t[0] || 99 !== t[1]) throw "Runtime error: expected the system to be little-endian! (Run with -s SUPPORT_BIG_ENDIAN=1 to bypass)" }(); var __ATPRERUN__ = [], __ATINIT__ = [], __ATMAIN__ = [], __ATPOSTRUN__ = [], runtimeInitialized = !1, runtimeExited = !1; function preRun() { if (Module.preRun) for ("function" == typeof Module.preRun && (Module.preRun = [Module.preRun]); Module.preRun.length;)addOnPreRun(Module.preRun.shift()); callRuntimeCallbacks(__ATPRERUN__) } function initRuntime() { checkStackCookie(), assert(!runtimeInitialized), runtimeInitialized = !0, Module.noFSInit || FS.init.initialized || FS.init(), FS.ignorePermissions = !1, TTY.init(), callRuntimeCallbacks(__ATINIT__) } function exitRuntime() { checkStackCookie(), runtimeExited = !0 } function postRun() { if (checkStackCookie(), Module.postRun) for ("function" == typeof Module.postRun && (Module.postRun = [Module.postRun]); Module.postRun.length;)addOnPostRun(Module.postRun.shift()); callRuntimeCallbacks(__ATPOSTRUN__) } function addOnPreRun(e) { __ATPRERUN__.unshift(e) } function addOnInit(e) { __ATINIT__.unshift(e) } function addOnPostRun(e) { __ATPOSTRUN__.unshift(e) } assert(Math.imul, "This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"), assert(Math.fround, "This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"), assert(Math.clz32, "This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"), assert(Math.trunc, "This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"); var runDependencies = 0, runDependencyWatcher = null, dependenciesFulfilled = null, runDependencyTracking = {}; function getUniqueRunDependency(e) { for (var t = e; ;) { if (!runDependencyTracking[e]) return e; e = t + Math.random() } } function addRunDependency(e) { runDependencies++, Module.monitorRunDependencies && Module.monitorRunDependencies(runDependencies), e ? (assert(!runDependencyTracking[e]), runDependencyTracking[e] = 1, null === runDependencyWatcher && void 0 !== setInterval && (runDependencyWatcher = setInterval((function () { if (ABORT) return clearInterval(runDependencyWatcher), void (runDependencyWatcher = null); var e = !1; for (var t in runDependencyTracking) e || (e = !0, err("still waiting on run dependencies:")), err("dependency: " + t); e && err("(end of list)") }), 1e4))) : err("warning: run dependency added without ID") } function removeRunDependency(e) { if (runDependencies--, Module.monitorRunDependencies && Module.monitorRunDependencies(runDependencies), e ? (assert(runDependencyTracking[e]), delete runDependencyTracking[e]) : err("warning: run dependency removed without ID"), 0 == runDependencies && (null !== runDependencyWatcher && (clearInterval(runDependencyWatcher), runDependencyWatcher = null), dependenciesFulfilled)) { var t = dependenciesFulfilled; dependenciesFulfilled = null, t() } } function abort(e) { throw Module.onAbort && Module.onAbort(e), err(e += ""), ABORT = !0, EXITSTATUS = 1, e = "abort(" + e + ") at " + stackTrace(), new WebAssembly.RuntimeError(e) } Module.preloadedImages = {}, Module.preloadedAudios = {}; var wasmBinaryFile, tempDouble, tempI64, dataURIPrefix = "data:application/octet-stream;base64,"; function isDataURI(e) { return e.startsWith(dataURIPrefix) } function isFileURI(e) { return e.startsWith("file://") } function createExportWrapper(e, t) { return function () { var r = e, o = t; return t || (o = Module.asm), assert(runtimeInitialized, "native function `" + r + "` called before runtime initialization"), assert(!runtimeExited, "native function `" + r + "` called after runtime exit (use NO_EXIT_RUNTIME to keep it alive after main() exits)"), o[e] || assert(o[e], "exported native function `" + r + "` not found"), o[e].apply(null, arguments) } } function getBinary(e) { try { if (e == wasmBinaryFile && wasmBinary) return new Uint8Array(wasmBinary); if (readBinary) return readBinary(e); throw "both async and sync fetching of the wasm failed" } catch (e) { abort(e) } } function getBinaryPromise() { if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { if ("function" == typeof fetch && !isFileURI(wasmBinaryFile)) return fetch(wasmBinaryFile, { credentials: "same-origin" }).then((function (e) { if (!e.ok) throw "failed to load wasm binary file at '" + wasmBinaryFile + "'"; return e.arrayBuffer() })).catch((function () { return getBinary(wasmBinaryFile) })); if (readAsync) return new Promise((function (e, t) { readAsync(wasmBinaryFile, (function (t) { e(new Uint8Array(t)) }), t) })) } return Promise.resolve().then((function () { return getBinary(wasmBinaryFile) })) } function createWasm() { var e = { env: asmLibraryArg, wasi_snapshot_preview1: asmLibraryArg }; function t(e, t) { var r = e.exports; Module.asm = r, assert(wasmMemory = Module.asm.memory, "memory not found in wasm exports"), updateGlobalBufferAndViews(wasmMemory.buffer), assert(wasmTable = Module.asm.__indirect_function_table, "table not found in wasm exports"), addOnInit(Module.asm.__wasm_call_ctors), removeRunDependency("wasm-instantiate") } addRunDependency("wasm-instantiate"); var r = Module; function o(e) { assert(Module === r, "the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"), r = null, t(e.instance) } function n(t) { return getBinaryPromise().then((function (t) { return WebAssembly.instantiate(t, e) })).then(t, (function (e) { err("failed to asynchronously prepare wasm: " + e), isFileURI(wasmBinaryFile) && err("warning: Loading from a file URI (" + wasmBinaryFile + ") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing"), abort(e) })) } if (Module.instantiateWasm) try { return Module.instantiateWasm(e, t) } catch (e) { return err("Module.instantiateWasm callback failed with error: " + e), !1 } return wasmBinary || "function" != typeof WebAssembly.instantiateStreaming || isDataURI(wasmBinaryFile) || isFileURI(wasmBinaryFile) || "function" != typeof fetch ? n(o) : fetch(wasmBinaryFile, { credentials: "same-origin" }).then((function (t) { return WebAssembly.instantiateStreaming(t, e).then(o, (function (e) { return err("wasm streaming compile failed: " + e), err("falling back to ArrayBuffer instantiation"), n(o) })) })), {} } isDataURI(wasmBinaryFile = "https://v1-cf-api.blueagle.top/static/libmupdf.wasm") || (wasmBinaryFile = locateFile(wasmBinaryFile)); var ASM_CONSTS = { 355128: function (e) { throw Error(UTF8ToString(e)) }, 355167: function () { throw Error("Cannot create MuPDF context!") } }; function callRuntimeCallbacks(e) { for (; e.length > 0;) { var t = e.shift(); if ("function" != typeof t) { var r = t.func; "number" == typeof r ? void 0 === t.arg ? wasmTable.get(r)() : wasmTable.get(r)(t.arg) : r(void 0 === t.arg ? null : t.arg) } else t(Module) } } function demangle(e) { return warnOnce("warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling"), e } function demangleAll(e) { return e.replace(/\b_Z[\w\d_]+/g, (function (e) { var t = demangle(e); return e === t ? e : t + " [" + e + "]" })) } function jsStackTrace() { var e = Error(); if (!e.stack) { try { throw Error() } catch (t) { e = t } if (!e.stack) return "(no stack trace available)" } return e.stack.toString() } var runtimeKeepaliveCounter = 0; function keepRuntimeAlive() { return noExitRuntime || runtimeKeepaliveCounter > 0 } function stackTrace() { var e = jsStackTrace(); return Module.extraStackTrace && (e += "\n" + Module.extraStackTrace()), demangleAll(e) } function _gmtime_r(e, t) { var r = new Date(1e3 * HEAP32[e >> 2]); HEAP32[t >> 2] = r.getUTCSeconds(), HEAP32[t + 4 >> 2] = r.getUTCMinutes(), HEAP32[t + 8 >> 2] = r.getUTCHours(), HEAP32[t + 12 >> 2] = r.getUTCDate(), HEAP32[t + 16 >> 2] = r.getUTCMonth(), HEAP32[t + 20 >> 2] = r.getUTCFullYear() - 1900, HEAP32[t + 24 >> 2] = r.getUTCDay(), HEAP32[t + 36 >> 2] = 0, HEAP32[t + 32 >> 2] = 0; var o = Date.UTC(r.getUTCFullYear(), 0, 1, 0, 0, 0, 0), n = (r.getTime() - o) / 864e5 | 0; return HEAP32[t + 28 >> 2] = n, _gmtime_r.GMTString || (_gmtime_r.GMTString = allocateUTF8("GMT")), HEAP32[t + 40 >> 2] = _gmtime_r.GMTString, t } function ___gmtime_r(e, t) { return _gmtime_r(e, t) } function setErrNo(e) { return HEAP32[___errno_location() >> 2] = e, e } var PATH = { splitPath: function (e) { return /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1) }, normalizeArray: function (e, t) { for (var r = 0, o = e.length - 1; o >= 0; o--) { var n = e[o]; "." === n ? e.splice(o, 1) : ".." === n ? (e.splice(o, 1), r++) : r && (e.splice(o, 1), r--) } if (t) for (; r; r--)e.unshift(".."); return e }, normalize: function (e) { var t = "/" === e.charAt(0), r = "/" === e.substr(-1); return (e = PATH.normalizeArray(e.split("/").filter((function (e) { return !!e })), !t).join("/")) || t || (e = "."), e && r && (e += "/"), (t ? "/" : "") + e }, dirname: function (e) { var t = PATH.splitPath(e), r = t[0], o = t[1]; return r || o ? (o && (o = o.substr(0, o.length - 1)), r + o) : "." }, basename: function (e) { if ("/" === e) return "/"; var t = (e = (e = PATH.normalize(e)).replace(/\/$/, "")).lastIndexOf("/"); return -1 === t ? e : e.substr(t + 1) }, extname: function (e) { return PATH.splitPath(e)[3] }, join: function () { var e = [].slice.call(arguments, 0); return PATH.normalize(e.join("/")) }, join2: function (e, t) { return PATH.normalize(e + "/" + t) } }; function getRandomDevice() { if ("object" == typeof crypto && "function" == typeof crypto.getRandomValues) { var e = new Uint8Array(1); return function () { return crypto.getRandomValues(e), e[0] } } if (ENVIRONMENT_IS_NODE) try { var t = require("crypto"); return function () { return t.randomBytes(1)[0] } } catch (e) { } return function () { abort("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: function(array) { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };") } } var PATH_FS = { resolve: function () { for (var e = "", t = !1, r = arguments.length - 1; r >= -1 && !t; r--) { var o = r >= 0 ? arguments[r] : FS.cwd(); if ("string" != typeof o) throw new TypeError("Arguments to path.resolve must be strings"); if (!o) return ""; e = o + "/" + e, t = "/" === o.charAt(0) } return (t ? "/" : "") + (e = PATH.normalizeArray(e.split("/").filter((function (e) { return !!e })), !t).join("/")) || "." }, relative: function (e, t) { function r(e) { for (var t = 0; t < e.length && "" === e[t]; t++); for (var r = e.length - 1; r >= 0 && "" === e[r]; r--); return t > r ? [] : e.slice(t, r - t + 1) } e = PATH_FS.resolve(e).substr(1), t = PATH_FS.resolve(t).substr(1); for (var o = r(e.split("/")), n = r(t.split("/")), i = Math.min(o.length, n.length), a = i, s = 0; s < i; s++)if (o[s] !== n[s]) { a = s; break } var c = []; for (s = a; s < o.length; s++)c.push(".."); return (c = c.concat(n.slice(a))).join("/") } }, TTY = { ttys: [], init: function () { }, shutdown: function () { }, register: function (e, t) { TTY.ttys[e] = { input: [], output: [], ops: t }, FS.registerDevice(e, TTY.stream_ops) }, stream_ops: { open: function (e) { var t = TTY.ttys[e.node.rdev]; if (!t) throw new FS.ErrnoError(43); e.tty = t, e.seekable = !1 }, close: function (e) { e.tty.ops.flush(e.tty) }, flush: function (e) { e.tty.ops.flush(e.tty) }, read: function (e, t, r, o, n) { if (!e.tty || !e.tty.ops.get_char) throw new FS.ErrnoError(60); for (var i = 0, a = 0; a < o; a++) { var s; try { s = e.tty.ops.get_char(e.tty) } catch (e) { throw new FS.ErrnoError(29) } if (void 0 === s && 0 === i) throw new FS.ErrnoError(6); if (null == s) break; i++, t[r + a] = s } return i && (e.node.timestamp = Date.now()), i }, write: function (e, t, r, o, n) { if (!e.tty || !e.tty.ops.put_char) throw new FS.ErrnoError(60); try { for (var i = 0; i < o; i++)e.tty.ops.put_char(e.tty, t[r + i]) } catch (e) { throw new FS.ErrnoError(29) } return o && (e.node.timestamp = Date.now()), i } }, default_tty_ops: { get_char: function (e) { if (!e.input.length) { var t = null; if (ENVIRONMENT_IS_NODE) { var r = Buffer.alloc ? Buffer.alloc(256) : new Buffer(256), o = 0; try { o = nodeFS.readSync(process.stdin.fd, r, 0, 256, null) } catch (e) { if (!e.toString().includes("EOF")) throw e; o = 0 } t = o > 0 ? r.slice(0, o).toString("utf-8") : null } else "undefined" != typeof window && "function" == typeof window.prompt ? null !== (t = window.prompt("Input: ")) && (t += "\n") : "function" == typeof readline && null !== (t = readline()) && (t += "\n"); if (!t) return null; e.input = intArrayFromString(t, !0) } return e.input.shift() }, put_char: function (e, t) { null === t || 10 === t ? (out(UTF8ArrayToString(e.output, 0)), e.output = []) : 0 != t && e.output.push(t) }, flush: function (e) { e.output && e.output.length > 0 && (out(UTF8ArrayToString(e.output, 0)), e.output = []) } }, default_tty1_ops: { put_char: function (e, t) { null === t || 10 === t ? (err(UTF8ArrayToString(e.output, 0)), e.output = []) : 0 != t && e.output.push(t) }, flush: function (e) { e.output && e.output.length > 0 && (err(UTF8ArrayToString(e.output, 0)), e.output = []) } } }; function mmapAlloc(e) { for (var t = alignMemory(e, 65536), r = _malloc(t); e < t;)HEAP8[r + e++] = 0; return r } var MEMFS = { ops_table: null, mount: function (e) { return MEMFS.createNode(null, "/", 16895, 0) }, createNode: function (e, t, r, o) { if (FS.isBlkdev(r) || FS.isFIFO(r)) throw new FS.ErrnoError(63); 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 n = FS.createNode(e, t, r, o); return FS.isDir(n.mode) ? (n.node_ops = MEMFS.ops_table.dir.node, n.stream_ops = MEMFS.ops_table.dir.stream, n.contents = {}) : FS.isFile(n.mode) ? (n.node_ops = MEMFS.ops_table.file.node, n.stream_ops = MEMFS.ops_table.file.stream, n.usedBytes = 0, n.contents = null) : FS.isLink(n.mode) ? (n.node_ops = MEMFS.ops_table.link.node, n.stream_ops = MEMFS.ops_table.link.stream) : FS.isChrdev(n.mode) && (n.node_ops = MEMFS.ops_table.chrdev.node, n.stream_ops = MEMFS.ops_table.chrdev.stream), n.timestamp = Date.now(), e && (e.contents[t] = n, e.timestamp = n.timestamp), n }, getFileDataAsTypedArray: function (e) { return e.contents ? e.contents.subarray ? e.contents.subarray(0, e.usedBytes) : new Uint8Array(e.contents) : new Uint8Array(0) }, expandFileStorage: function (e, t) { var r = e.contents ? e.contents.length : 0; if (!(r >= t)) { t = Math.max(t, r * (r < 1048576 ? 2 : 1.125) >>> 0), 0 != r && (t = Math.max(t, 256)); var o = e.contents; e.contents = new Uint8Array(t), e.usedBytes > 0 && e.contents.set(o.subarray(0, e.usedBytes), 0) } }, resizeFileStorage: function (e, t) { if (e.usedBytes != t) if (0 == t) e.contents = null, e.usedBytes = 0; else { var r = e.contents; e.contents = new Uint8Array(t), r && e.contents.set(r.subarray(0, Math.min(t, e.usedBytes))), e.usedBytes = t } }, node_ops: { getattr: function (e) { var t = {}; return t.dev = FS.isChrdev(e.mode) ? e.id : 1, t.ino = e.id, t.mode = e.mode, t.nlink = 1, t.uid = 0, t.gid = 0, t.rdev = e.rdev, FS.isDir(e.mode) ? t.size = 4096 : FS.isFile(e.mode) ? t.size = e.usedBytes : FS.isLink(e.mode) ? t.size = e.link.length : t.size = 0, t.atime = new Date(e.timestamp), t.mtime = new Date(e.timestamp), t.ctime = new Date(e.timestamp), t.blksize = 4096, t.blocks = Math.ceil(t.size / t.blksize), t }, setattr: function (e, t) { void 0 !== t.mode && (e.mode = t.mode), void 0 !== t.timestamp && (e.timestamp = t.timestamp), void 0 !== t.size && MEMFS.resizeFileStorage(e, t.size) }, lookup: function (e, t) { throw FS.genericErrors[44] }, mknod: function (e, t, r, o) { return MEMFS.createNode(e, t, r, o) }, rename: function (e, t, r) { if (FS.isDir(e.mode)) { var o; try { o = FS.lookupNode(t, r) } catch (e) { } if (o) for (var n in o.contents) throw new FS.ErrnoError(55) } delete e.parent.contents[e.name], e.parent.timestamp = Date.now(), e.name = r, t.contents[r] = e, t.timestamp = e.parent.timestamp, e.parent = t }, unlink: function (e, t) { delete e.contents[t], e.timestamp = Date.now() }, rmdir: function (e, t) { var r = FS.lookupNode(e, t); for (var o in r.contents) throw new FS.ErrnoError(55); delete e.contents[t], e.timestamp = Date.now() }, readdir: function (e) { var t = [".", ".."]; for (var r in e.contents) e.contents.hasOwnProperty(r) && t.push(r); return t }, symlink: function (e, t, r) { var o = MEMFS.createNode(e, t, 41471, 0); return o.link = r, o }, readlink: function (e) { if (!FS.isLink(e.mode)) throw new FS.ErrnoError(28); return e.link } }, stream_ops: { read: function (e, t, r, o, n) { var i = e.node.contents; if (n >= e.node.usedBytes) return 0; var a = Math.min(e.node.usedBytes - n, o); if (assert(a >= 0), a > 8 && i.subarray) t.set(i.subarray(n, n + a), r); else for (var s = 0; s < a; s++)t[r + s] = i[n + s]; return a }, write: function (e, t, r, o, n, i) { if (assert(!(t instanceof ArrayBuffer)), t.buffer === HEAP8.buffer && (i = !1), !o) return 0; var a = e.node; if (a.timestamp = Date.now(), t.subarray && (!a.contents || a.contents.subarray)) { if (i) return assert(0 === n, "canOwn must imply no weird position inside the file"), a.contents = t.subarray(r, r + o), a.usedBytes = o, o; if (0 === a.usedBytes && 0 === n) return a.contents = t.slice(r, r + o), a.usedBytes = o, o; if (n + o <= a.usedBytes) return a.contents.set(t.subarray(r, r + o), n), o } if (MEMFS.expandFileStorage(a, n + o), a.contents.subarray && t.subarray) a.contents.set(t.subarray(r, r + o), n); else for (var s = 0; s < o; s++)a.contents[n + s] = t[r + s]; return a.usedBytes = Math.max(a.usedBytes, n + o), o }, llseek: function (e, t, r) { var o = t; if (1 === r ? o += e.position : 2 === r && FS.isFile(e.node.mode) && (o += e.node.usedBytes), o < 0) throw new FS.ErrnoError(28); return o }, allocate: function (e, t, r) { MEMFS.expandFileStorage(e.node, t + r), e.node.usedBytes = Math.max(e.node.usedBytes, t + r) }, mmap: function (e, t, r, o, n, i) { if (0 !== t) throw new FS.ErrnoError(28); if (!FS.isFile(e.node.mode)) throw new FS.ErrnoError(43); var a, s, c = e.node.contents; if (2 & i || c.buffer !== buffer) { if ((o > 0 || o + r < c.length) && (c = c.subarray ? c.subarray(o, o + r) : [].slice.call(c, o, o + r)), s = !0, !(a = mmapAlloc(r))) throw new FS.ErrnoError(48); HEAP8.set(c, a) } else s = !1, a = c.byteOffset; return { ptr: a, allocated: s } }, msync: function (e, t, r, o, n) { if (!FS.isFile(e.node.mode)) throw new FS.ErrnoError(43); return 2 & n || MEMFS.stream_ops.write(e, t, 0, o, r, !1), 0 } } }, ERRNO_MESSAGES = { 0: "Success", 1: "Arg list too long", 2: "Permission denied", 3: "Address already in use", 4: "Address not available", 5: "Address family not supported by protocol family", 6: "No more processes", 7: "Socket already connected", 8: "Bad file number", 9: "Trying to read unreadable message", 10: "Mount device busy", 11: "Operation canceled", 12: "No children", 13: "Connection aborted", 14: "Connection refused", 15: "Connection reset by peer", 16: "File locking deadlock error", 17: "Destination address required", 18: "Math arg out of domain of func", 19: "Quota exceeded", 20: "File exists", 21: "Bad address", 22: "File too large", 23: "Host is unreachable", 24: "Identifier removed", 25: "Illegal byte sequence", 26: "Connection already in progress", 27: "Interrupted system call", 28: "Invalid argument", 29: "I/O error", 30: "Socket is already connected", 31: "Is a directory", 32: "Too many symbolic links", 33: "Too many open files", 34: "Too many links", 35: "Message too long", 36: "Multihop attempted", 37: "File or path name too long", 38: "Network interface is not configured", 39: "Connection reset by network", 40: "Network is unreachable", 41: "Too many open files in system", 42: "No buffer space available", 43: "No such device", 44: "No such file or directory", 45: "Exec format error", 46: "No record locks available", 47: "The link has been severed", 48: "Not enough core", 49: "No message of desired type", 50: "Protocol not available", 51: "No space left on device", 52: "Function not implemented", 53: "Socket is not connected", 54: "Not a directory", 55: "Directory not empty", 56: "State not recoverable", 57: "Socket operation on non-socket", 59: "Not a typewriter", 60: "No such device or address", 61: "Value too large for defined data type", 62: "Previous owner died", 63: "Not super-user", 64: "Broken pipe", 65: "Protocol error", 66: "Unknown protocol", 67: "Protocol wrong type for socket", 68: "Math result not representable", 69: "Read only file system", 70: "Illegal seek", 71: "No such process", 72: "Stale file handle", 73: "Connection timed out", 74: "Text file busy", 75: "Cross-device link", 100: "Device not a stream", 101: "Bad font file fmt", 102: "Invalid slot", 103: "Invalid request code", 104: "No anode", 105: "Block device required", 106: "Channel number out of range", 107: "Level 3 halted", 108: "Level 3 reset", 109: "Link number out of range", 110: "Protocol driver not attached", 111: "No CSI structure available", 112: "Level 2 halted", 113: "Invalid exchange", 114: "Invalid request descriptor", 115: "Exchange full", 116: "No data (for no delay io)", 117: "Timer expired", 118: "Out of streams resources", 119: "Machine is not on the network", 120: "Package not installed", 121: "The object is remote", 122: "Advertise error", 123: "Srmount error", 124: "Communication error on send", 125: "Cross mount point (not really error)", 126: "Given log. name not unique", 127: "f.d. invalid for this operation", 128: "Remote address changed", 129: "Can access a needed shared lib", 130: "Accessing a corrupted shared lib", 131: ".lib section in a.out corrupted", 132: "Attempting to link in too many libs", 133: "Attempting to exec a shared library", 135: "Streams pipe error", 136: "Too many users", 137: "Socket type not supported", 138: "Not supported", 139: "Protocol family not supported", 140: "Can't send after socket shutdown", 141: "Too many references", 142: "Host is down", 148: "No medium (in tape drive)", 156: "Level 2 not synchronized" }, ERRNO_CODES = { EPERM: 63, ENOENT: 44, ESRCH: 71, EINTR: 27, EIO: 29, ENXIO: 60, E2BIG: 1, ENOEXEC: 45, EBADF: 8, ECHILD: 12, EAGAIN: 6, EWOULDBLOCK: 6, ENOMEM: 48, EACCES: 2, EFAULT: 21, ENOTBLK: 105, EBUSY: 10, EEXIST: 20, EXDEV: 75, ENODEV: 43, ENOTDIR: 54, EISDIR: 31, EINVAL: 28, ENFILE: 41, EMFILE: 33, ENOTTY: 59, ETXTBSY: 74, EFBIG: 22, ENOSPC: 51, ESPIPE: 70, EROFS: 69, EMLINK: 34, EPIPE: 64, EDOM: 18, ERANGE: 68, ENOMSG: 49, EIDRM: 24, ECHRNG: 106, EL2NSYNC: 156, EL3HLT: 107, EL3RST: 108, ELNRNG: 109, EUNATCH: 110, ENOCSI: 111, EL2HLT: 112, EDEADLK: 16, ENOLCK: 46, EBADE: 113, EBADR: 114, EXFULL: 115, ENOANO: 104, EBADRQC: 103, EBADSLT: 102, EDEADLOCK: 16, EBFONT: 101, ENOSTR: 100, ENODATA: 116, ETIME: 117, ENOSR: 118, ENONET: 119, ENOPKG: 120, EREMOTE: 121, ENOLINK: 47, EADV: 122, ESRMNT: 123, ECOMM: 124, EPROTO: 65, EMULTIHOP: 36, EDOTDOT: 125, EBADMSG: 9, ENOTUNIQ: 126, EBADFD: 127, EREMCHG: 128, ELIBACC: 129, ELIBBAD: 130, ELIBSCN: 131, ELIBMAX: 132, ELIBEXEC: 133, ENOSYS: 52, ENOTEMPTY: 55, ENAMETOOLONG: 37, ELOOP: 32, EOPNOTSUPP: 138, EPFNOSUPPORT: 139, ECONNRESET: 15, ENOBUFS: 42, EAFNOSUPPORT: 5, EPROTOTYPE: 67, ENOTSOCK: 57, ENOPROTOOPT: 50, ESHUTDOWN: 140, ECONNREFUSED: 14, EADDRINUSE: 3, ECONNABORTED: 13, ENETUNREACH: 40, ENETDOWN: 38, ETIMEDOUT: 73, EHOSTDOWN: 142, EHOSTUNREACH: 23, EINPROGRESS: 26, EALREADY: 7, EDESTADDRREQ: 17, EMSGSIZE: 35, EPROTONOSUPPORT: 66, ESOCKTNOSUPPORT: 137, EADDRNOTAVAIL: 4, ENETRESET: 39, EISCONN: 30, ENOTCONN: 53, ETOOMANYREFS: 141, EUSERS: 136, EDQUOT: 19, ESTALE: 72, ENOTSUP: 138, ENOMEDIUM: 148, EILSEQ: 25, EOVERFLOW: 61, ECANCELED: 11, ENOTRECOVERABLE: 56, EOWNERDEAD: 62, ESTRPIPE: 135 }, FS = { root: null, mounts: [], devices: {}, streams: [], nextInode: 1, nameTable: null, currentPath: "/", initialized: !1, ignorePermissions: !0, trackingDelegate: {}, tracking: { openFlags: { READ: 1, WRITE: 2 } }, ErrnoError: null, genericErrors: {}, filesystems: null, syncFSRequests: 0, lookupPath: function (e, t) { if (t = t || {}, !(e = PATH_FS.resolve(FS.cwd(), e))) return { path: "", node: null }; var r = { follow_mount: !0, recurse_count: 0 }; for (var o in r) void 0 === t[o] && (t[o] = r[o]); if (t.recurse_count > 8) throw new FS.ErrnoError(32); for (var n = PATH.normalizeArray(e.split("/").filter((function (e) { return !!e })), !1), i = FS.root, a = "/", s = 0; s < n.length; s++) { var c = s === n.length - 1; if (c && t.parent) break; if (i = FS.lookupNode(i, n[s]), a = PATH.join2(a, n[s]), FS.isMountpoint(i) && (!c || c && t.follow_mount) && (i = i.mounted.root), !c || t.follow) for (var d = 0; FS.isLink(i.mode);) { var l = FS.readlink(a); if (a = PATH_FS.resolve(PATH.dirname(a), l), i = FS.lookupPath(a, { recurse_count: t.recurse_count }).node, d++ > 40) throw new FS.ErrnoError(32) } } return { path: a, node: i } }, getPath: function (e) { for (var t; ;) { if (FS.isRoot(e)) { var r = e.mount.mountpoint; return t ? "/" !== r[r.length - 1] ? r + "/" + t : r + t : r } t = t ? e.name + "/" + t : e.name, e = e.parent } }, hashName: function (e, t) { for (var r = 0, o = 0; o < t.length; o++)r = (r << 5) - r + t.charCodeAt(o) | 0; return (e + r >>> 0) % FS.nameTable.length }, hashAddNode: function (e) { var t = FS.hashName(e.parent.id, e.name); e.name_next = FS.nameTable[t], FS.nameTable[t] = e }, hashRemoveNode: function (e) { var t = FS.hashName(e.parent.id, e.name); if (FS.nameTable[t] === e) FS.nameTable[t] = e.name_next; else for (var r = FS.nameTable[t]; r;) { if (r.name_next === e) { r.name_next = e.name_next; break } r = r.name_next } }, lookupNode: function (e, t) { var r = FS.mayLookup(e); if (r) throw new FS.ErrnoError(r, e); for (var o = FS.hashName(e.id, t), n = FS.nameTable[o]; n; n = n.name_next) { var i = n.name; if (n.parent.id === e.id && i === t) return n } return FS.lookup(e, t) }, createNode: function (e, t, r, o) { assert("object" == typeof e); var n = new FS.FSNode(e, t, r, o); return FS.hashAddNode(n), n }, destroyNode: function (e) { FS.hashRemoveNode(e) }, isRoot: function (e) { return e === e.parent }, isMountpoint: function (e) { return !!e.mounted }, isFile: function (e) { return 32768 == (61440 & e) }, isDir: function (e) { return 16384 == (61440 & e) }, isLink: function (e) { return 40960 == (61440 & e) }, isChrdev: function (e) { return 8192 == (61440 & e) }, isBlkdev: function (e) { return 24576 == (61440 & e) }, isFIFO: function (e) { return 4096 == (61440 & e) }, isSocket: function (e) { return 49152 == (49152 & e) }, flagModes: { r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090 }, modeStringToFlags: function (e) { var t = FS.flagModes[e]; if (void 0 === t) throw Error("Unknown file open mode: " + e); return t }, flagsToPermissionString: function (e) { var t = ["r", "w", "rw"][3 & e]; return 512 & e && (t += "w"), t }, nodePermissions: function (e, t) { return FS.ignorePermissions || (!t.includes("r") || 292 & e.mode) && (!t.includes("w") || 146 & e.mode) && (!t.includes("x") || 73 & e.mode) ? 0 : 2 }, mayLookup: function (e) { return FS.nodePermissions(e, "x") || (e.node_ops.lookup ? 0 : 2) }, mayCreate: function (e, t) { try { return FS.lookupNode(e, t), 20 } catch (e) { } return FS.nodePermissions(e, "wx") }, mayDelete: function (e, t, r) { var o; try { o = FS.lookupNode(e, t) } catch (e) { return e.errno } var n = FS.nodePermissions(e, "wx"); if (n) return n; if (r) { if (!FS.isDir(o.mode)) return 54; if (FS.isRoot(o) || FS.getPath(o) === FS.cwd()) return 10 } else if (FS.isDir(o.mode)) return 31; return 0 }, mayOpen: function (e, t) { return e ? FS.isLink(e.mode) ? 32 : FS.isDir(e.mode) && ("r" !== FS.flagsToPermissionString(t) || 512 & t) ? 31 : FS.nodePermissions(e, FS.flagsToPermissionString(t)) : 44 }, MAX_OPEN_FDS: 4096, nextfd: function (e, t) { e = e || 0, t = t || FS.MAX_OPEN_FDS; for (var r = e; r <= t; r++)if (!FS.streams[r]) return r; throw new FS.ErrnoError(33) }, getStream: function (e) { return FS.streams[e] }, createStream: function (e, t, r) { FS.FSStream || (FS.FSStream = function () { }, FS.FSStream.prototype = { object: { get: function () { return this.node }, set: function (e) { this.node = e } }, isRead: { get: function () { return 1 != (2097155 & this.flags) } }, isWrite: { get: function () { return 0 != (2097155 & this.flags) } }, isAppend: { get: function () { return 1024 & this.flags } } }); var o = new FS.FSStream; for (var n in e) o[n] = e[n]; e = o; var i = FS.nextfd(t, r); return e.fd = i, FS.streams[i] = e, e }, closeStream: function (e) { FS.streams[e] = null }, chrdev_stream_ops: { open: function (e) { var t = FS.getDevice(e.node.rdev); e.stream_ops = t.stream_ops, e.stream_ops.open && e.stream_ops.open(e) }, llseek: function () { throw new FS.ErrnoError(70) } }, major: function (e) { return e >> 8 }, minor: function (e) { return 255 & e }, makedev: function (e, t) { return e << 8 | t }, registerDevice: function (e, t) { FS.devices[e] = { stream_ops: t } }, getDevice: function (e) { return FS.devices[e] }, getMounts: function (e) { for (var t = [], r = [e]; r.length;) { var o = r.pop(); t.push(o), r.push.apply(r, o.mounts) } return t }, syncfs: function (e, t) { "function" == typeof e && (t = e, e = !1), FS.syncFSRequests++, FS.syncFSRequests > 1 && err("warning: " + FS.syncFSRequests + " FS.syncfs operations in flight at once, probably just doing extra work"); var r = FS.getMounts(FS.root.mount), o = 0; function n(e) { return assert(FS.syncFSRequests > 0), FS.syncFSRequests--, t(e) } function i(e) { if (e) return i.errored ? void 0 : (i.errored = !0, n(e)); ++o >= r.length && n(null) } r.forEach((function (t) { if (!t.type.syncfs) return i(null); t.type.syncfs(t, e, i) })) }, mount: function (e, t, r) { if ("string" == typeof e) throw e; var o, n = "/" === r, i = !r; if (n && FS.root) throw new FS.ErrnoError(10); if (!n && !i) { var a = FS.lookupPath(r, { follow_mount: !1 }); if (r = a.path, o = a.node, FS.isMountpoint(o)) throw new FS.ErrnoError(10); if (!FS.isDir(o.mode)) throw new FS.ErrnoError(54) } var s = { type: e, opts: t, mountpoint: r, mounts: [] }, c = e.mount(s); return c.mount = s, s.root = c, n ? FS.root = c : o && (o.mounted = s, o.mount && o.mount.mounts.push(s)), c }, unmount: function (e) { var t = FS.lookupPath(e, { follow_mount: !1 }); if (!FS.isMountpoint(t.node)) throw new FS.ErrnoError(28); var r = t.node, o = r.mounted, n = FS.getMounts(o); Object.keys(FS.nameTable).forEach((function (e) { for (var t = FS.nameTable[e]; t;) { var r = t.name_next; n.includes(t.mount) && FS.destroyNode(t), t = r } })), r.mounted = null; var i = r.mount.mounts.indexOf(o); assert(-1 !== i), r.mount.mounts.splice(i, 1) }, lookup: function (e, t) { return e.node_ops.lookup(e, t) }, mknod: function (e, t, r) { var o = FS.lookupPath(e, { parent: !0 }).node, n = PATH.basename(e); if (!n || "." === n || ".." === n) throw new FS.ErrnoError(28); var i = FS.mayCreate(o, n); if (i) throw new FS.ErrnoError(i); if (!o.node_ops.mknod) throw new FS.ErrnoError(63); return o.node_ops.mknod(o, n, t, r) }, create: function (e, t) { return t = void 0 !== t ? t : 438, t &= 4095, t |= 32768, FS.mknod(e, t, 0) }, mkdir: function (e, t) { return t = void 0 !== t ? t : 511, t &= 1023, t |= 16384, FS.mknod(e, t, 0) }, mkdirTree: function (e, t) { for (var r = e.split("/"), o = "", n = 0; n < r.length; ++n)if (r[n]) { o += "/" + r[n]; try { FS.mkdir(o, t) } catch (e) { if (20 != e.errno) throw e } } }, mkdev: function (e, t, r) { return void 0 === r && (r = t, t = 438), t |= 8192, FS.mknod(e, t, r) }, symlink: function (e, t) { if (!PATH_FS.resolve(e)) throw new FS.ErrnoError(44); var r = FS.lookupPath(t, { parent: !0 }).node; if (!r) throw new FS.ErrnoError(44); var o = PATH.basename(t), n = FS.mayCreate(r, o); if (n) throw new FS.ErrnoError(n); if (!r.node_ops.symlink) throw new FS.ErrnoError(63); return r.node_ops.symlink(r, o, e) }, rename: function (e, t) { var r, o, n = PATH.dirname(e), i = PATH.dirname(t), a = PATH.basename(e), s = PATH.basename(t); if (r = FS.lookupPath(e, { parent: !0 }).node, o = FS.lookupPath(t, { parent: !0 }).node, !r || !o) throw new FS.ErrnoError(44); if (r.mount !== o.mount) throw new FS.ErrnoError(75); var c, d = FS.lookupNode(r, a), l = PATH_FS.relative(e, i); if ("." !== l.charAt(0)) throw new FS.ErrnoError(28); if ("." !== (l = PATH_FS.relative(t, n)).charAt(0)) throw new FS.ErrnoError(55); try { c = FS.lookupNode(o, s) } catch (e) { } if (d !== c) { var u = FS.isDir(d.mode), p = FS.mayDelete(r, a, u); if (p) throw new FS.ErrnoError(p); if (p = c ? FS.mayDelete(o, s, u) : FS.mayCreate(o, s)) throw new FS.ErrnoError(p); if (!r.node_ops.rename) throw new FS.ErrnoError(63); if (FS.isMountpoint(d) || c && FS.isMountpoint(c)) throw new FS.ErrnoError(10); if (o !== r && (p = FS.nodePermissions(r, "w"))) throw new FS.ErrnoError(p); try { FS.trackingDelegate.willMovePath && FS.trackingDelegate.willMovePath(e, t) } catch (r) { err("FS.trackingDelegate['willMovePath']('" + e + "', '" + t + "') threw an exception: " + r.message) } FS.hashRemoveNode(d); try { r.node_ops.rename(d, o, s) } catch (e) { throw e } finally { FS.hashAddNode(d) } try { FS.trackingDelegate.onMovePath && FS.trackingDelegate.onMovePath(e, t) } catch (r) { err("FS.trackingDelegate['onMovePath']('" + e + "', '" + t + "') threw an exception: " + r.message) } } }, rmdir: function (e) { var t = FS.lookupPath(e, { parent: !0 }).node, r = PATH.basename(e), o = FS.lookupNode(t, r), n = FS.mayDelete(t, r, !0); if (n) throw new FS.ErrnoError(n); if (!t.node_ops.rmdir) throw new FS.ErrnoError(63); if (FS.isMountpoint(o)) throw new FS.ErrnoError(10); try { FS.trackingDelegate.willDeletePath && FS.trackingDelegate.willDeletePath(e) } catch (t) { err("FS.trackingDelegate['willDeletePath']('" + e + "') threw an exception: " + t.message) } t.node_ops.rmdir(t, r), FS.destroyNode(o); try { FS.trackingDelegate.onDeletePath && FS.trackingDelegate.onDeletePath(e) } catch (t) { err("FS.trackingDelegate['onDeletePath']('" + e + "') threw an exception: " + t.message) } }, readdir: function (e) { var t = FS.lookupPath(e, { follow: !0 }).node; if (!t.node_ops.readdir) throw new FS.ErrnoError(54); return t.node_ops.readdir(t) }, unlink: function (e) { var t = FS.lookupPath(e, { parent: !0 }).node, r = PATH.basename(e), o = FS.lookupNode(t, r), n = FS.mayDelete(t, r, !1); if (n) throw new FS.ErrnoError(n); if (!t.node_ops.unlink) throw new FS.ErrnoError(63); if (FS.isMountpoint(o)) throw new FS.ErrnoError(10); try { FS.trackingDelegate.willDeletePath && FS.trackingDelegate.willDeletePath(e) } catch (t) { err("FS.trackingDelegate['willDeletePath']('" + e + "') threw an exception: " + t.message) } t.node_ops.unlink(t, r), FS.destroyNode(o); try { FS.trackingDelegate.onDeletePath && FS.trackingDelegate.onDeletePath(e) } catch (t) { err("FS.trackingDelegate['onDeletePath']('" + e + "') threw an exception: " + t.message) } }, readlink: function (e) { var t = FS.lookupPath(e).node; if (!t) throw new FS.ErrnoError(44); if (!t.node_ops.readlink) throw new FS.ErrnoError(28); return PATH_FS.resolve(FS.getPath(t.parent), t.node_ops.readlink(t)) }, stat: function (e, t) { var r = FS.lookupPath(e, { follow: !t }).node; if (!r) throw new FS.ErrnoError(44); if (!r.node_ops.getattr) throw new FS.ErrnoError(63); return r.node_ops.getattr(r) }, lstat: function (e) { return FS.stat(e, !0) }, chmod: function (e, t, r) { var o; if (!(o = "string" == typeof e ? FS.lookupPath(e, { follow: !r }).node : e).node_ops.setattr) throw new FS.ErrnoError(63); o.node_ops.setattr(o, { mode: 4095 & t | -4096 & o.mode, timestamp: Date.now() }) }, lchmod: function (e, t) { FS.chmod(e, t, !0) }, fchmod: function (e, t) { var r = FS.getStream(e); if (!r) throw new FS.ErrnoError(8); FS.chmod(r.node, t) }, chown: function (e, t, r, o) { var n; if (!(n = "string" == typeof e ? FS.lookupPath(e, { follow: !o }).node : e).node_ops.setattr) throw new FS.ErrnoError(63); n.node_ops.setattr(n, { timestamp: Date.now() }) }, lchown: function (e, t, r) { FS.chown(e, t, r, !0) }, fchown: function (e, t, r) { var o = FS.getStream(e); if (!o) throw new FS.ErrnoError(8); FS.chown(o.node, t, r) }, truncate: function (e, t) { if (t < 0) throw new FS.ErrnoError(28); var r; if (!(r = "string" == typeof e ? FS.lookupPath(e, { follow: !0 }).node : e).node_ops.setattr) throw new FS.ErrnoError(63); if (FS.isDir(r.mode)) throw new FS.ErrnoError(31); if (!FS.isFile(r.mode)) throw new FS.ErrnoError(28); var o = FS.nodePermissions(r, "w"); if (o) throw new FS.ErrnoError(o); r.node_ops.setattr(r, { size: t, timestamp: Date.now() }) }, ftruncate: function (e, t) { var r = FS.getStream(e); if (!r) throw new FS.ErrnoError(8); if (0 == (2097155 & r.flags)) throw new FS.ErrnoError(28); FS.truncate(r.node, t) }, utime: function (e, t, r) { var o = FS.lookupPath(e, { follow: !0 }).node; o.node_ops.setattr(o, { timestamp: Math.max(t, r) }) }, open: function (e, t, r, o, n) { if ("" === e) throw new FS.ErrnoError(44); var i; if (r = void 0 === r ? 438 : r, r = 64 & (t = "string" == typeof t ? FS.modeStringToFlags(t) : t) ? 4095 & r | 32768 : 0, "object" == typeof e) i = e; else { e = PATH.normalize(e); try { i = FS.lookupPath(e, { follow: !(131072 & t) }).node } catch (e) { } } var a = !1; if (64 & t) if (i) { if (128 & t) throw new FS.ErrnoError(20) } else i = FS.mknod(e, r, 0), a = !0; if (!i) throw new FS.ErrnoError(44); if (FS.isChrdev(i.mode) && (t &= -513), 65536 & t && !FS.isDir(i.mode)) throw new FS.ErrnoError(54); if (!a) { var s = FS.mayOpen(i, t); if (s) throw new FS.ErrnoError(s) } 512 & t && FS.truncate(i, 0), t &= -131713; var c = FS.createStream({ node: i, path: FS.getPath(i), flags: t, seekable: !0, position: 0, stream_ops: i.stream_ops, ungotten: [], error: !1 }, o, n); c.stream_ops.open && c.stream_ops.open(c), !Module.logReadFiles || 1 & t || (FS.readFiles || (FS.readFiles = {}), e in FS.readFiles || (FS.readFiles[e] = 1, err("FS.trackingDelegate error on read file: " + e))); try { if (FS.trackingDelegate.onOpenFile) { var d = 0; 1 != (2097155 & t) && (d |= FS.tracking.openFlags.READ), 0 != (2097155 & t) && (d |= FS.tracking.openFlags.WRITE), FS.trackingDelegate.onOpenFile(e, d) } } catch (t) { err("FS.trackingDelegate['onOpenFile']('" + e + "', flags) threw an exception: " + t.message) } return c }, close: function (e) { if (FS.isClosed(e)) throw new FS.ErrnoError(8); e.getdents && (e.getdents = null); try { e.stream_ops.close && e.stream_ops.close(e) } catch (e) { throw e } finally { FS.closeStream(e.fd) } e.fd = null }, isClosed: function (e) { return null === e.fd }, llseek: function (e, t, r) { if (FS.isClosed(e)) throw new FS.ErrnoError(8); if (!e.seekable || !e.stream_ops.llseek) throw new FS.ErrnoError(70); if (0 != r && 1 != r && 2 != r) throw new FS.ErrnoError(28); return e.position = e.stream_ops.llseek(e, t, r), e.ungotten = [], e.position }, read: function (e, t, r, o, n) { if (o < 0 || n < 0) throw new FS.ErrnoError(28); if (FS.isClosed(e)) throw new FS.ErrnoError(8); if (1 == (2097155 & e.flags)) throw new FS.ErrnoError(8); if (FS.isDir(e.node.mode)) throw new FS.ErrnoError(31); if (!e.stream_ops.read) throw new FS.ErrnoError(28); var i = void 0 !== n; if (i) { if (!e.seekable) throw new FS.ErrnoError(70) } else n = e.position; var a = e.stream_ops.read(e, t, r, o, n); return i || (e.position += a), a }, write: function (e, t, r, o, n, i) { if (o < 0 || n < 0) throw new FS.ErrnoError(28); if (FS.isClosed(e)) throw new FS.ErrnoError(8); if (0 == (2097155 & e.flags)) throw new FS.ErrnoError(8); if (FS.isDir(e.node.mode)) throw new FS.ErrnoError(31); if (!e.stream_ops.write) throw new FS.ErrnoError(28); e.seekable && 1024 & e.flags && FS.llseek(e, 0, 2); var a = void 0 !== n; if (a) { if (!e.seekable) throw new FS.ErrnoError(70) } else n = e.position; var s = e.stream_ops.write(e, t, r, o, n, i); a || (e.position += s); try { e.path && FS.trackingDelegate.onWriteToFile && FS.trackingDelegate.onWriteToFile(e.path) } catch (t) { err("FS.trackingDelegate['onWriteToFile']('" + e.path + "') threw an exception: " + t.message) } return s }, allocate: function (e, t, r) { if (FS.isClosed(e)) throw new FS.ErrnoError(8); if (t < 0 || r <= 0) throw new FS.ErrnoError(28); if (0 == (2097155 & e.flags)) throw new FS.ErrnoError(8); if (!FS.isFile(e.node.mode) && !FS.isDir(e.node.mode)) throw new FS.ErrnoError(43); if (!e.stream_ops.allocate) throw new FS.ErrnoError(138); e.stream_ops.allocate(e, t, r) }, mmap: function (e, t, r, o, n, i) { if (0 != (2 & n) && 0 == (2 & i) && 2 != (2097155 & e.flags)) throw new FS.ErrnoError(2); if (1 == (2097155 & e.flags)) throw new FS.ErrnoError(2); if (!e.stream_ops.mmap) throw new FS.ErrnoError(43); return e.stream_ops.mmap(e, t, r, o, n, i) }, msync: function (e, t, r, o, n) { return e && e.stream_ops.msync ? e.stream_ops.msync(e, t, r, o, n) : 0 }, munmap: function (e) { return 0 }, ioctl: function (e, t, r) { if (!e.stream_ops.ioctl) throw new FS.ErrnoError(59); return e.stream_ops.ioctl(e, t, r) }, readFile: function (e, t) { if ((t = t || {}).flags = t.flags || 0, t.encoding = t.encoding || "binary", "utf8" !== t.encoding && "binary" !== t.encoding) throw Error('Invalid encoding type "' + t.encoding + '"'); var r, o = FS.open(e, t.flags), n = FS.stat(e).size, i = new Uint8Array(n); return FS.read(o, i, 0, n, 0), "utf8" === t.encoding ? r = UTF8ArrayToString(i, 0) : "binary" === t.encoding && (r = i), FS.close(o), r }, writeFile: function (e, t, r) { (r = r || {}).flags = r.flags || 577; var o = FS.open(e, r.flags, r.mode); if ("string" == typeof t) { var n = new Uint8Array(lengthBytesUTF8(t) + 1), i = stringToUTF8Array(t, n, 0, n.length); FS.write(o, n, 0, i, void 0, r.canOwn) } else { if (!ArrayBuffer.isView(t)) throw Error("Unsupported data type"); FS.write(o, t, 0, t.byteLength, void 0, r.canOwn) } FS.close(o) }, cwd: function () { return FS.currentPath }, chdir: function (e) { var t = FS.lookupPath(e, { follow: !0 }); if (null === t.node) throw new FS.ErrnoError(44); if (!FS.isDir(t.node.mode)) throw new FS.ErrnoError(54); var r = FS.nodePermissions(t.node, "x"); if (r) throw new FS.ErrnoError(r); FS.currentPath = t.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 (e, t, r, o, n) { return o } }), 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 e = getRandomDevice(); FS.createDevice("/dev", "random", e), FS.createDevice("/dev", "urandom", e), FS.mkdir("/dev/shm"), FS.mkdir("/dev/shm/tmp") }, createSpecialDirectories: function () { FS.mkdir("/proc"); var e = FS.mkdir("/proc/self"); FS.mkdir("/proc/self/fd"), FS.mount({ mount: function () { var t = FS.createNode(e, "fd", 16895, 73); return t.node_ops = { lookup: function (e, t) { var r = +t, o = FS.getStream(r); if (!o) throw new FS.ErrnoError(8); var n = { parent: null, mount: { mountpoint: "fake" }, node_ops: { readlink: function () { return o.path } } }; return n.parent = n, n } }, t } }, {}, "/proc/self/fd") }, createStandardStreams: function () { Module.stdin ? FS.createDevice("/dev", "stdin", Module.stdin) : FS.symlink("/dev/tty", "/dev/stdin"), Module.stdout ? FS.createDevice("/dev", "stdout", null, Module.stdout) : FS.symlink("/dev/tty", "/dev/stdout"), Module.stderr ? FS.createDevice("/dev", "stderr", null, Module.stderr) : FS.symlink("/dev/tty1", "/dev/stderr"); var e = FS.open("/dev/stdin", 0), t = FS.open("/dev/stdout", 1), r = FS.open("/dev/stderr", 1); assert(0 === e.fd, "invalid handle for stdin (" + e.fd + ")"), assert(1 === t.fd, "invalid handle for stdout (" + t.fd + ")"), assert(2 === r.fd, "invalid handle for stderr (" + r.fd + ")") }, ensureErrnoError: function () { FS.ErrnoError || (FS.ErrnoError = function (e, t) { this.node = t, this.setErrno = function (e) { for (var t in this.errno = e, ERRNO_CODES) if (ERRNO_CODES[t] === e) { this.code = t; break } }, this.setErrno(e), this.message = ERRNO_MESSAGES[e], this.stack && (Object.defineProperty(this, "stack", { value: Error().stack, writable: !0 }), this.stack = demangleAll(this.stack)) }, FS.ErrnoError.prototype = Error(), FS.ErrnoError.prototype.constructor = FS.ErrnoError, [44].forEach((function (e) { FS.genericErrors[e] = new FS.ErrnoError(e), FS.genericErrors[e].stack = "" }))) }, staticInit: function () { FS.ensureErrnoError(), FS.nameTable = Array(4096), FS.mount(MEMFS, {}, "/"), FS.createDefaultDirectories(), FS.createDefaultDevices(), FS.createSpecialDirectories(), FS.filesystems = { MEMFS: MEMFS } }, init: function (e, t, r) { 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 = !0, FS.ensureErrnoError(), Module.stdin = e || Module.stdin, Module.stdout = t || Module.stdout, Module.stderr = r || Module.stderr, FS.createStandardStreams() }, quit: function () { FS.init.initialized = !1; var e = Module._fflush; e && e(0); for (var t = 0; t < FS.streams.length; t++) { var r = FS.streams[t]; r && FS.close(r) } }, getMode: function (e, t) { var r = 0; return e && (r |= 365), t && (r |= 146), r }, findObject: function (e, t) { var r = FS.analyzePath(e, t); return r.exists ? r.object : null }, analyzePath: function (e, t) { try { e = (o = FS.lookupPath(e, { follow: !t })).path } catch (e) { } var r = { isRoot: !1, exists: !1, error: 0, name: null, path: null, object: null, parentExists: !1, parentPath: null, parentObject: null }; try { var o = FS.lookupPath(e, { parent: !0 }); r.parentExists = !0, r.parentPath = o.path, r.parentObject = o.node, r.name = PATH.basename(e), o = FS.lookupPath(e, { follow: !t }), r.exists = !0, r.path = o.path, r.object = o.node, r.name = o.node.name, r.isRoot = "/" === o.path } catch (e) { r.error = e.errno } return r }, createPath: function (e, t, r, o) { e = "string" == typeof e ? e : FS.getPath(e); for (var n = t.split("/").reverse(); n.length;) { var i = n.pop(); if (i) { var a = PATH.join2(e, i); try { FS.mkdir(a) } catch (e) { } e = a } } return a }, createFile: function (e, t, r, o, n) { var i = PATH.join2("string" == typeof e ? e : FS.getPath(e), t), a = FS.getMode(o, n); return FS.create(i, a) }, createDataFile: function (e, t, r, o, n, i) { var a = t ? PATH.join2("string" == typeof e ? e : FS.getPath(e), t) : e, s = FS.getMode(o, n), c = FS.create(a, s); if (r) { if ("string" == typeof r) { for (var d = Array(r.length), l = 0, u = r.length; l < u; ++l)d[l] = r.charCodeAt(l); r = d } FS.chmod(c, 146 | s); var p = FS.open(c, 577); FS.write(p, r, 0, r.length, 0, i), FS.close(p), FS.chmod(c, s) } return c }, createDevice: function (e, t, r, o) { var n = PATH.join2("string" == typeof e ? e : FS.getPath(e), t), i = FS.getMode(!!r, !!o); FS.createDevice.major || (FS.createDevice.major = 64); var a = FS.makedev(FS.createDevice.major++, 0); return FS.registerDevice(a, { open: function (e) { e.seekable = !1 }, close: function (e) { o && o.buffer && o.buffer.length && o(10) }, read: function (e, t, o, n, i) { for (var a = 0, s = 0; s < n; s++) { var c; try { c = r() } catch (e) { throw new FS.ErrnoError(29) } if (void 0 === c && 0 === a) throw new FS.ErrnoError(6); if (null == c) break; a++, t[o + s] = c } return a && (e.node.timestamp = Date.now()), a }, write: function (e, t, r, n, i) { for (var a = 0; a < n; a++)try { o(t[r + a]) } catch (e) { throw new FS.ErrnoError(29) } return n && (e.node.timestamp = Date.now()), a } }), FS.mkdev(n, i, a) }, forceLoadFile: function (e) { if (e.isDevice || e.isFolder || e.link || e.contents) return !0; if ("undefined" != typeof XMLHttpRequest) throw Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread."); if (!read_) throw Error("Cannot load without read() or XMLHttpRequest."); try { e.contents = intArrayFromString(read_(e.url), !0), e.usedBytes = e.contents.length } catch (e) { throw new FS.ErrnoError(29) } }, createLazyFile: function (e, t, r, o, n) { function i() { this.lengthKnown = !1, this.chunks = [] } if (i.prototype.get = function (e) { if (!(e > this.length - 1 || e < 0)) { var t = e % this.chunkSize, r = e / this.chunkSize | 0; return this.getter(r)[t] } }, i.prototype.setDataGetter = function (e) { this.getter = e }, i.prototype.cacheLength = function () { var e = new XMLHttpRequest; if (e.open("HEAD", r, !1), e.send(null), !(e.status >= 200 && e.status < 300 || 304 === e.status)) throw Error("Couldn't load " + r + ". Status: " + e.status); var t, o = +e.getResponseHeader("Content-length"), n = (t = e.getResponseHeader("Accept-Ranges")) && "bytes" === t, i = (t = e.getResponseHeader("Content-Encoding")) && "gzip" === t, a = 1048576; n || (a = o); var s = this; s.setDataGetter((function (e) { var t = e * a, n = (e + 1) * a - 1; if (n = Math.min(n, o - 1), void 0 === s.chunks[e] && (s.chunks[e] = function (e, t) { if (e > t) throw Error("invalid range (" + e + ", " + t + ") or no bytes requested!"); if (t > o - 1) throw Error("only " + o + " bytes available! programmer error!"); var n = new XMLHttpRequest; if (n.open("GET", r, !1), o !== a && n.setRequestHeader("Range", "bytes=" + e + "-" + t), "undefined" != typeof Uint8Array && (n.responseType = "arraybuffer"), n.overrideMimeType && n.overrideMimeType("text/plain; charset=x-user-defined"), n.send(null), !(n.status >= 200 && n.status < 300 || 304 === n.status)) throw Error("Couldn't load " + r + ". Status: " + n.status); return void 0 !== n.response ? new Uint8Array(n.response || []) : intArrayFromString(n.responseText || "", !0) }(t, n)), void 0 === s.chunks[e]) throw Error("doXHR failed!"); return s.chunks[e] })), !i && o || (a = o = 1, o = this.getter(0).length, a = o, out("LazyFiles on gzip forces download of the whole file when length is accessed")), this._length = o, this._chunkSize = a, this.lengthKnown = !0 }, "undefined" != typeof XMLHttpRequest) { if (!ENVIRONMENT_IS_WORKER) throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc"; var a = new i; Object.defineProperties(a, { length: { get: function () { return this.lengthKnown || this.cacheLength(), this._length } }, chunkSize: { get: function () { return this.lengthKnown || this.cacheLength(), this._chunkSize } } }); var s = { isDevice: !1, contents: a } } else s = { isDevice: !1, url: r }; var c = FS.createFile(e, t, s, o, n); s.contents ? c.contents = s.contents : s.url && (c.contents = null, c.url = s.url), Object.defineProperties(c, { usedBytes: { get: function () { return this.contents.length } } }); var d = {}; return Object.keys(c.stream_ops).forEach((function (e) { var t = c.stream_ops[e]; d[e] = function () { return FS.forceLoadFile(c), t.apply(null, arguments) } })), d.read = function (e, t, r, o, n) { FS.forceLoadFile(c); var i = e.node.contents; if (n >= i.length) return 0; var a = Math.min(i.length - n, o); if (assert(a >= 0), i.slice) for (var s = 0; s < a; s++)t[r + s] = i[n + s]; else for (s = 0; s < a; s++)t[r + s] = i.get(n + s); return a }, c.stream_ops = d, c }, createPreloadedFile: function (e, t, r, o, n, i, a, s, c, d) { Browser.init(); var l = t ? PATH_FS.resolve(PATH.join2(e, t)) : e, u = getUniqueRunDependency("cp " + l); function p(r) { function p(r) { d && d(), s || FS.createDataFile(e, t, r, o, n, c), i && i(), removeRunDependency(u) } var f = !1; Module.preloadPlugins.forEach((function (e) { f || e.canHandle(l) && (e.handle(r, l, p, (function () { a && a(), removeRunDependency(u) })), f = !0) })), f || p(r) } addRunDependency(u), "string" == typeof r ? Browser.asyncLoad(r, (function (e) { p(e) }), a) : p(r) }, indexedDB: function () { return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB }, DB_NAME: function () { return "EM_FS_" + window.location.pathname }, DB_VERSION: 20, DB_STORE_NAME: "FILE_DATA", saveFilesToDB: function (e, t, r) { t = t || function () { }, r = r || function () { }; var o = FS.indexedDB(); try { var n = o.open(FS.DB_NAME(), FS.DB_VERSION) } catch (e) { return r(e) } n.onupgradeneeded = function () { out("creating db"), n.result.createObjectStore(FS.DB_STORE_NAME) }, n.onsuccess = function () { var o = n.result.transaction([FS.DB_STORE_NAME], "readwrite"), i = o.objectStore(FS.DB_STORE_NAME), a = 0, s = 0, c = e.length; function d() { 0 == s ? t() : r() } e.forEach((function (e) { var t = i.put(FS.analyzePath(e).object.contents, e); t.onsuccess = function () { ++a + s == c && d() }, t.onerror = function () { s++, a + s == c && d() } })), o.onerror = r }, n.onerror = r }, loadFilesFromDB: function (e, t, r) { t = t || function () { }, r = r || function () { }; var o = FS.indexedDB(); try { var n = o.open(FS.DB_NAME(), FS.DB_VERSION) } catch (e) { return r(e) } n.onupgradeneeded = r, n.onsuccess = function () { var o = n.result; try { var i = o.transaction([FS.DB_STORE_NAME], "readonly") } catch (e) { return void r(e) } var a = i.objectStore(FS.DB_STORE_NAME), s = 0, c = 0, d = e.length; function l() { 0 == c ? t() : r() } e.forEach((function (e) { var t = a.get(e); t.onsuccess = function () { FS.analyzePath(e).exists && FS.unlink(e), FS.createDataFile(PATH.dirname(e), PATH.basename(e), t.result, !0, !0, !0), ++s + c == d && l() }, t.onerror = function () { c++, s + c == d && l() } })), i.onerror = r }, n.onerror = r }, absolutePath: function () { abort("FS.absolutePath has been removed; use PATH_FS.resolve instead") }, createFolder: function () { abort("FS.createFolder has been removed; use FS.mkdir instead") }, createLink: function () { abort("FS.createLink has been removed; use FS.symlink instead") }, joinPath: function () { abort("FS.joinPath has been removed; use PATH.join instead") }, mmapAlloc: function () { abort("FS.mmapAlloc has been replaced by the top level function mmapAlloc") }, standardizePath: function () { abort("FS.standardizePath has been removed; use PATH.normalize instead") } }, SYSCALLS = { mappings: {}, DEFAULT_POLLMASK: 5, umask: 511, calculateAt: function (e, t, r) { if ("/" === t[0]) return t; var o; if (-100 === e) o = FS.cwd(); else { var n = FS.getStream(e); if (!n) throw new FS.ErrnoError(8); o = n.path } if (0 == t.length) { if (!r) throw new FS.ErrnoError(44); return o } return PATH.join2(o, t) }, doStat: function (e, t, r) { try { var o = e(t) } catch (e) { if (e && e.node && PATH.normalize(t) !== PATH.normalize(FS.getPath(e.node))) return -54; throw e } return HEAP32[r >> 2] = o.dev, HEAP32[r + 4 >> 2] = 0, HEAP32[r + 8 >> 2] = o.ino, HEAP32[r + 12 >> 2] = o.mode, HEAP32[r + 16 >> 2] = o.nlink, HEAP32[r + 20 >> 2] = o.uid, HEAP32[r + 24 >> 2] = o.gid, HEAP32[r + 28 >> 2] = o.rdev, HEAP32[r + 32 >> 2] = 0, tempI64 = [o.size >>> 0, (tempDouble = o.size, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (0 | Math.min(+Math.floor(tempDouble / 4294967296), 4294967295)) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[r + 40 >> 2] = tempI64[0], HEAP32[r + 44 >> 2] = tempI64[1], HEAP32[r + 48 >> 2] = 4096, HEAP32[r + 52 >> 2] = o.blocks, HEAP32[r + 56 >> 2] = o.atime.getTime() / 1e3 | 0, HEAP32[r + 60 >> 2] = 0, HEAP32[r + 64 >> 2] = o.mtime.getTime() / 1e3 | 0, HEAP32[r + 68 >> 2] = 0, HEAP32[r + 72 >> 2] = o.ctime.getTime() / 1e3 | 0, HEAP32[r + 76 >> 2] = 0, tempI64 = [o.ino >>> 0, (tempDouble = o.ino, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (0 | Math.min(+Math.floor(tempDouble / 4294967296), 4294967295)) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[r + 80 >> 2] = tempI64[0], HEAP32[r + 84 >> 2] = tempI64[1], 0 }, doMsync: function (e, t, r, o, n) { var i = HEAPU8.slice(e, e + r); FS.msync(t, i, n, r, o) }, doMkdir: function (e, t) { return "/" === (e = PATH.normalize(e))[e.length - 1] && (e = e.substr(0, e.length - 1)), FS.mkdir(e, t, 0), 0 }, doMknod: function (e, t, r) { switch (61440 & t) { case 32768: case 8192: case 24576: case 4096: case 49152: break; default: return -28 }return FS.mknod(e, t, r), 0 }, doReadlink: function (e, t, r) { if (r <= 0) return -28; var o = FS.readlink(e), n = Math.min(r, lengthBytesUTF8(o)), i = HEAP8[t + n]; return stringToUTF8(o, t, r + 1), HEAP8[t + n] = i, n }, doAccess: function (e, t) { if (-8 & t) return -28; var r; if (!(r = FS.lookupPath(e, { follow: !0 }).node)) return -44; var o = ""; return 4 & t && (o += "r"), 2 & t && (o += "w"), 1 & t && (o += "x"), o && FS.nodePermissions(r, o) ? -2 : 0 }, doDup: function (e, t, r) { var o = FS.getStream(r); return o && FS.close(o), FS.open(e, t, 0, r, r).fd }, doReadv: function (e, t, r, o) { for (var n = 0, i = 0; i < r; i++) { var a = HEAP32[t + 8 * i >> 2], s = HEAP32[t + (8 * i + 4) >> 2], c = FS.read(e, HEAP8, a, s, o); if (c < 0) return -1; if (n += c, c < s) break } return n }, doWritev: function (e, t, r, o) { for (var n = 0, i = 0; i < r; i++) { var a = HEAP32[t + 8 * i >> 2], s = HEAP32[t + (8 * i + 4) >> 2], c = FS.write(e, HEAP8, a, s, o); if (c < 0) return -1; n += c } return n }, varargs: void 0, get: function () { return assert(null != SYSCALLS.varargs), SYSCALLS.varargs += 4, HEAP32[SYSCALLS.varargs - 4 >> 2] }, getStr: function (e) { return UTF8ToString(e) }, getStreamFromFD: function (e) { var t = FS.getStream(e); if (!t) throw new FS.ErrnoError(8); return t }, get64: function (e, t) { return assert(e >= 0 ? 0 === t : -1 === t), e } }; function ___sys_fcntl64(e, t, r) { SYSCALLS.varargs = r; try { var o = SYSCALLS.getStreamFromFD(e); switch (t) { case 0: return (n = SYSCALLS.get()) < 0 ? -28 : FS.open(o.path, o.flags, 0, n).fd; case 1: case 2: case 13: case 14: return 0; case 3: return o.flags; case 4: var n = SYSCALLS.get(); return o.flags |= n, 0; case 12: return n = SYSCALLS.get(), HEAP16[n + 0 >> 1] = 2, 0; case 16: case 8: default: return -28; case 9: return setErrNo(28), -1 } } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), -e.errno } } function ___sys_ftruncate64(e, t, r, o) { try { var n = SYSCALLS.get64(r, o); return FS.ftruncate(e, n), 0 } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), -e.errno } } function ___sys_ioctl(e, t, r) { SYSCALLS.varargs = r; try { var o = SYSCALLS.getStreamFromFD(e); switch (t) { case 21509: case 21505: case 21510: case 21511: case 21512: case 21506: case 21507: case 21508: case 21523: case 21524: return o.tty ? 0 : -59; case 21519: if (!o.tty) return -59; var n = SYSCALLS.get(); return HEAP32[n >> 2] = 0, 0; case 21520: return o.tty ? -28 : -59; case 21531: return n = SYSCALLS.get(), FS.ioctl(o, t, n); default: abort("bad ioctl syscall " + t) } } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), -e.errno } } function ___sys_open(e, t, r) { SYSCALLS.varargs = r; try { var o = SYSCALLS.getStr(e), n = r ? SYSCALLS.get() : 0; return FS.open(o, t, n).fd } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), -e.errno } } function ___sys_rmdir(e) { try { return e = SYSCALLS.getStr(e), FS.rmdir(e), 0 } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), -e.errno } } function ___sys_unlink(e) { try { return e = SYSCALLS.getStr(e), FS.unlink(e), 0 } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), -e.errno } } function __emscripten_throw_longjmp() { throw "longjmp" } var readAsmConstArgsArray = []; function readAsmConstArgs(e, t) { var r; for (assert(Array.isArray(readAsmConstArgsArray)), assert(t % 16 == 0), readAsmConstArgsArray.length = 0, t >>= 2; r = HEAPU8[e++];) { assert(100 === r || 102 === r || 105 === r); var o = r < 105; o && 1 & t && t++, readAsmConstArgsArray.push(o ? HEAPF64[t++ >> 1] : HEAP32[t]), ++t } return readAsmConstArgsArray } function _emscripten_asm_const_int(e, t, r) { var o = readAsmConstArgs(t, r); return ASM_CONSTS.hasOwnProperty(e) || abort("No EM_ASM constant found at address " + e), ASM_CONSTS[e].apply(null, o) } function _emscripten_memcpy_big(e, t, r) { HEAPU8.copyWithin(e, t, t + r) } function emscripten_realloc_buffer(e) { try { return wasmMemory.grow(e - buffer.byteLength + 65535 >>> 16), updateGlobalBufferAndViews(wasmMemory.buffer), 1 } catch (e) { } } function _emscripten_resize_heap(e) { var t = HEAPU8.length; assert((e >>>= 0) > t); var r = 2147483648; if (e > r) return err("Cannot enlarge memory, asked to go up to " + e + " bytes, but the limit is " + r + " bytes!"), !1; for (var o = 1; o <= 4; o *= 2) { var n = t * (1 + .2 / o), i = Math.min(r, alignUp(Math.max(e, n = Math.min(n, e + 100663296)), 65536)); if (emscripten_realloc_buffer(i)) return !0 } return err("Failed to grow the heap from " + t + " bytes to " + i + " bytes, not enough memory!"), !1 } var ENV = {}; function getExecutableName() { return thisProgram || "./this.program" } function getEnvStrings() { if (!getEnvStrings.strings) { var e = { 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", _: getExecutableName() }; for (var t in ENV) void 0 === ENV[t] ? delete e[t] : e[t] = ENV[t]; var r = []; for (var t in e) r.push(t + "=" + e[t]); getEnvStrings.strings = r } return getEnvStrings.strings } function _environ_get(e, t) { try { var r = 0; return getEnvStrings().forEach((function (o, n) { var i = t + r; HEAP32[e + 4 * n >> 2] = i, writeAsciiToMemory(o, i), r += o.length + 1 })), 0 } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), e.errno } } function _environ_sizes_get(e, t) { try { var r = getEnvStrings(); HEAP32[e >> 2] = r.length; var o = 0; return r.forEach((function (e) { o += e.length + 1 })), HEAP32[t >> 2] = o, 0 } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), e.errno } } function _exit(e) { exit(e) } function _fd_close(e) { try { var t = SYSCALLS.getStreamFromFD(e); return FS.close(t), 0 } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), e.errno } } function _fd_read(e, t, r, o) { try { var n = SYSCALLS.getStreamFromFD(e), i = SYSCALLS.doReadv(n, t, r); return HEAP32[o >> 2] = i, 0 } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), e.errno } } function _fd_seek(e, t, r, o, n) { try { var i = SYSCALLS.getStreamFromFD(e), a = 4294967296 * r + (t >>> 0), s = 9007199254740992; return a <= -s || a >= s ? -61 : (FS.llseek(i, a, o), tempI64 = [i.position >>> 0, (tempDouble = i.position, +Math.abs(tempDouble) >= 1 ? tempDouble > 0 ? (0 | Math.min(+Math.floor(tempDouble / 4294967296), 4294967295)) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296) >>> 0 : 0)], HEAP32[n >> 2] = tempI64[0], HEAP32[n + 4 >> 2] = tempI64[1], i.getdents && 0 === a && 0 === o && (i.getdents = null), 0) } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), e.errno } } function _fd_write(e, t, r, o) { try { var n = SYSCALLS.getStreamFromFD(e), i = SYSCALLS.doWritev(n, t, r); return HEAP32[o >> 2] = i, 0 } catch (e) { return void 0 !== FS && e instanceof FS.ErrnoError || abort(e), e.errno } } function _getTempRet0() { return getTempRet0() } function _setTempRet0(e) { setTempRet0(e) } function __isLeapYear(e) { return e % 4 == 0 && (e % 100 != 0 || e % 400 == 0) } function __arraySum(e, t) { for (var r = 0, o = 0; o <= t; r += e[o++]); return r } var __MONTH_DAYS_LEAP = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], __MONTH_DAYS_REGULAR = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; function __addDays(e, t) { for (var r = new Date(e.getTime()); t > 0;) { var o = __isLeapYear(r.getFullYear()), n = r.getMonth(), i = (o ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[n]; if (!(t > i - r.getDate())) return r.setDate(r.getDate() + t), r; t -= i - r.getDate() + 1, r.setDate(1), n < 11 ? r.setMonth(n + 1) : (r.setMonth(0), r.setFullYear(r.getFullYear() + 1)) } return r } function _strftime(e, t, r, o) { var n = HEAP32[o + 40 >> 2], i = { tm_sec: HEAP32[o >> 2], tm_min: HEAP32[o + 4 >> 2], tm_hour: HEAP32[o + 8 >> 2], tm_mday: HEAP32[o + 12 >> 2], tm_mon: HEAP32[o + 16 >> 2], tm_year: HEAP32[o + 20 >> 2], tm_wday: HEAP32[o + 24 >> 2], tm_yday: HEAP32[o + 28 >> 2], tm_isdst: HEAP32[o + 32 >> 2], tm_gmtoff: HEAP32[o + 36 >> 2], tm_zone: n ? UTF8ToString(n) : "" }, a = UTF8ToString(r), s = { "%c": "%a %b %d %H:%M:%S %Y", "%D": "%m/%d/%y", "%F": "%Y-%m-%d", "%h": "%b", "%r": "%I:%M:%S %p", "%R": "%H:%M", "%T": "%H:%M:%S", "%x": "%m/%d/%y", "%X": "%H:%M:%S", "%Ec": "%c", "%EC": "%C", "%Ex": "%m/%d/%y", "%EX": "%H:%M:%S", "%Ey": "%y", "%EY": "%Y", "%Od": "%d", "%Oe": "%e", "%OH": "%H", "%OI": "%I", "%Om": "%m", "%OM": "%M", "%OS": "%S", "%Ou": "%u", "%OU": "%U", "%OV": "%V", "%Ow": "%w", "%OW": "%W", "%Oy": "%y" }; for (var c in s) a = a.replace(RegExp(c, "g"), s[c]); var d = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], l = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; function u(e, t, r) { for (var o = "number" == typeof e ? e.toString() : e || ""; o.length < t;)o = r[0] + o; return o } function p(e, t) { return u(e, t, "0") } function f(e, t) { function r(e) { return e < 0 ? -1 : e > 0 ? 1 : 0 } var o; return 0 === (o = r(e.getFullYear() - t.getFullYear())) && 0 === (o = r(e.getMonth() - t.getMonth())) && (o = r(e.getDate() - t.getDate())), o } function E(e) { switch (e.getDay()) { case 0: return new Date(e.getFullYear() - 1, 11, 29); case 1: return e; case 2: return new Date(e.getFullYear(), 0, 3); case 3: return new Date(e.getFullYear(), 0, 2); case 4: return new Date(e.getFullYear(), 0, 1); case 5: return new Date(e.getFullYear() - 1, 11, 31); case 6: return new Date(e.getFullYear() - 1, 11, 30) } } function _(e) { var t = __addDays(new Date(e.tm_year + 1900, 0, 1), e.tm_yday), r = new Date(t.getFullYear(), 0, 4), o = new Date(t.getFullYear() + 1, 0, 4), n = E(r), i = E(o); return f(n, t) <= 0 ? f(i, t) <= 0 ? t.getFullYear() + 1 : t.getFullYear() : t.getFullYear() - 1 } var M = { "%a": function (e) { return d[e.tm_wday].substring(0, 3) }, "%A": function (e) { return d[e.tm_wday] }, "%b": function (e) { return l[e.tm_mon].substring(0, 3) }, "%B": function (e) { return l[e.tm_mon] }, "%C": function (e) { return p((e.tm_year + 1900) / 100 | 0, 2) }, "%d": function (e) { return p(e.tm_mday, 2) }, "%e": function (e) { return u(e.tm_mday, 2, " ") }, "%g": function (e) { return _(e).toString().substring(2) }, "%G": function (e) { return _(e) }, "%H": function (e) { return p(e.tm_hour, 2) }, "%I": function (e) { var t = e.tm_hour; return 0 == t ? t = 12 : t > 12 && (t -= 12), p(t, 2) }, "%j": function (e) { return p(e.tm_mday + __arraySum(__isLeapYear(e.tm_year + 1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, e.tm_mon - 1), 3) }, "%m": function (e) { return p(e.tm_mon + 1, 2) }, "%M": function (e) { return p(e.tm_min, 2) }, "%n": function () { return "\n" }, "%p": function (e) { return e.tm_hour >= 0 && e.tm_hour < 12 ? "AM" : "PM" }, "%S": function (e) { return p(e.tm_sec, 2) }, "%t": function () { return "\t" }, "%u": function (e) { return e.tm_wday || 7 }, "%U": function (e) { var t = new Date(e.tm_year + 1900, 0, 1), r = 0 === t.getDay() ? t : __addDays(t, 7 - t.getDay()), o = new Date(e.tm_year + 1900, e.tm_mon, e.tm_mday); if (f(r, o) < 0) { var n = __arraySum(__isLeapYear(o.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, o.getMonth() - 1) - 31, i = 31 - r.getDate() + n + o.getDate(); return p(Math.ceil(i / 7), 2) } return 0 === f(r, t) ? "01" : "00" }, "%V": function (e) { var t, r = new Date(e.tm_year + 1900, 0, 4), o = new Date(e.tm_year + 1901, 0, 4), n = E(r), i = E(o), a = __addDays(new Date(e.tm_year + 1900, 0, 1), e.tm_yday); return f(a, n) < 0 ? "53" : f(i, a) <= 0 ? "01" : (t = n.getFullYear() < e.tm_year + 1900 ? e.tm_yday + 32 - n.getDate() : e.tm_yday + 1 - n.getDate(), p(Math.ceil(t / 7), 2)) }, "%w": function (e) { return e.tm_wday }, "%W": function (e) { var t = new Date(e.tm_year, 0, 1), r = 1 === t.getDay() ? t : __addDays(t, 0 === t.getDay() ? 1 : 7 - t.getDay() + 1), o = new Date(e.tm_year + 1900, e.tm_mon, e.tm_mday); if (f(r, o) < 0) { var n = __arraySum(__isLeapYear(o.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, o.getMonth() - 1) - 31, i = 31 - r.getDate() + n + o.getDate(); return p(Math.ceil(i / 7), 2) } return 0 === f(r, t) ? "01" : "00" }, "%y": function (e) { return ("" + (e.tm_year + 1900)).substring(2) }, "%Y": function (e) { return e.tm_year + 1900 }, "%z": function (e) { var t = e.tm_gmtoff; return (t >= 0 ? "+" : "-") + ("0000" + (t = (t = Math.abs(t) / 60) / 60 * 100 + t % 60)).slice(-4) }, "%Z": function (e) { return e.tm_zone }, "%%": function () { return "%" } }; for (var c in M) a.includes(c) && (a = a.replace(RegExp(c, "g"), M[c](i))); var T = intArrayFromString(a, !1); return T.length > t ? 0 : (writeArrayToMemory(T, e), T.length - 1) } function _time(e) { var t = Date.now() / 1e3 | 0; return e && (HEAP32[e >> 2] = t), t } function _tzset() { if (!_tzset.called) { _tzset.called = !0; var e = (new Date).getFullYear(), t = new Date(e, 0, 1), r = new Date(e, 6, 1), o = t.getTimezoneOffset(), n = r.getTimezoneOffset(), i = Math.max(o, n); HEAP32[__get_timezone() >> 2] = 60 * i, HEAP32[__get_daylight() >> 2] = +(o != n); var a = l(t), s = l(r), c = allocateUTF8(a), d = allocateUTF8(s); n < o ? (HEAP32[__get_tzname() >> 2] = c, HEAP32[__get_tzname() + 4 >> 2] = d) : (HEAP32[__get_tzname() >> 2] = d, HEAP32[__get_tzname() + 4 >> 2] = c) } function l(e) { var t = e.toTimeString().match(/\(([A-Za-z ]+)\)$/); return t ? t[1] : "GMT" } } function _timegm(e) { _tzset(); var t = Date.UTC(HEAP32[e + 20 >> 2] + 1900, HEAP32[e + 16 >> 2], HEAP32[e + 12 >> 2], HEAP32[e + 8 >> 2], HEAP32[e + 4 >> 2], HEAP32[e >> 2], 0), r = new Date(t); HEAP32[e + 24 >> 2] = r.getUTCDay(); var o = Date.UTC(r.getUTCFullYear(), 0, 1, 0, 0, 0, 0), n = (r.getTime() - o) / 864e5 | 0; return HEAP32[e + 28 >> 2] = n, r.getTime() / 1e3 | 0 } var FSNode = function (e, t, r, o) { e || (e = this), this.parent = e, this.mount = e.mount, this.mounted = null, this.id = FS.nextInode++, this.name = t, this.mode = r, this.node_ops = {}, this.stream_ops = {}, this.rdev = o }, readMode = 365, writeMode = 146; Object.defineProperties(FSNode.prototype, { read: { get: function () { return (this.mode & readMode) === readMode }, set: function (e) { e ? this.mode |= readMode : this.mode &= ~readMode } }, write: { get: function () { return (this.mode & writeMode) === writeMode }, set: function (e) { e ? this.mode |= writeMode : this.mode &= ~writeMode } }, isFolder: { get: function () { return FS.isDir(this.mode) } }, isDevice: { get: function () { return FS.isChrdev(this.mode) } } }), FS.FSNode = FSNode, FS.staticInit(), Module.FS_createPath = FS.createPath, Module.FS_createDataFile = FS.createDataFile, Module.FS_createPreloadedFile = FS.createPreloadedFile, Module.FS_createLazyFile = FS.createLazyFile, Module.FS_createDevice = FS.createDevice, Module.FS_unlink = FS.unlink; var ASSERTIONS = !0; function intArrayFromString(e, t, r) { var o = r > 0 ? r : lengthBytesUTF8(e) + 1, n = Array(o), i = stringToUTF8Array(e, n, 0, n.length); return t && (n.length = i), n } var calledRun, asmLibraryArg = { __gmtime_r: ___gmtime_r, __sys_fcntl64: ___sys_fcntl64, __sys_ftruncate64: ___sys_ftruncate64, __sys_ioctl: ___sys_ioctl, __sys_open: ___sys_open, __sys_rmdir: ___sys_rmdir, __sys_unlink: ___sys_unlink, _emscripten_throw_longjmp: __emscripten_throw_longjmp, emscripten_asm_const_int: _emscripten_asm_const_int, emscripten_memcpy_big: _emscripten_memcpy_big, emscripten_resize_heap: _emscripten_resize_heap, environ_get: _environ_get, environ_sizes_get: _environ_sizes_get, exit: _exit, fd_close: _fd_close, fd_read: _fd_read, fd_seek: _fd_seek, fd_write: _fd_write, getTempRet0: _getTempRet0, invoke_ffi: invoke_ffi, invoke_fi: invoke_fi, invoke_fii: invoke_fii, invoke_fiii: invoke_fiii, invoke_fiiifiif: invoke_fiiifiif, invoke_fiiii: invoke_fiiii, invoke_fiiiii: invoke_fiiiii, invoke_ii: invoke_ii, invoke_iif: invoke_iif, invoke_iii: invoke_iii, invoke_iiiffffiii: invoke_iiiffffiii, invoke_iiiffiiiiiii: invoke_iiiffiiiiiii, invoke_iiii: invoke_iiii, invoke_iiiif: invoke_iiiif, invoke_iiiifi: invoke_iiiifi, invoke_iiiii: invoke_iiiii, invoke_iiiiiffi: invoke_iiiiiffi, invoke_iiiiiffii: invoke_iiiiiffii, invoke_iiiiiffiifiii: invoke_iiiiiffiifiii, invoke_iiiiifiiii: invoke_iiiiifiiii, invoke_iiiiii: invoke_iiiiii, invoke_iiiiiii: invoke_iiiiiii, invoke_iiiiiiifi: invoke_iiiiiiifi, invoke_iiiiiiii: invoke_iiiiiiii, invoke_iiiiiiiii: invoke_iiiiiiiii, invoke_iiiiiiiiii: invoke_iiiiiiiiii, invoke_iiiiiiiiiii: invoke_iiiiiiiiiii, invoke_iiiiiiiiiiiiii: invoke_iiiiiiiiiiiiii, invoke_iiiiiiiiiiiiiiiii: invoke_iiiiiiiiiiiiiiiii, invoke_iiiiiiiij: invoke_iiiiiiiij, invoke_iiiiiiji: invoke_iiiiiiji, invoke_iiiiij: invoke_iiiiij, invoke_iiij: invoke_iiij, invoke_iiijj: invoke_iiijj, invoke_iij: invoke_iij, invoke_jii: invoke_jii, invoke_jiij: invoke_jiij, invoke_v: invoke_v, invoke_vi: invoke_vi, invoke_vif: invoke_vif, invoke_viff: invoke_viff, invoke_viffi: invoke_viffi, invoke_vii: invoke_vii, invoke_viid: invoke_viid, invoke_viif: invoke_viif, invoke_viiff: invoke_viiff, invoke_viifff: invoke_viifff, invoke_viiffff: invoke_viiffff, invoke_viiffffff: invoke_viiffffff, invoke_viiffii: invoke_viiffii, invoke_viifi: invoke_viifi, invoke_viii: invoke_viii, invoke_viiid: invoke_viiid, invoke_viiif: invoke_viiif, invoke_viiifffffiii: invoke_viiifffffiii, invoke_viiii: invoke_viiii, invoke_viiiif: invoke_viiiif, invoke_viiiiff: invoke_viiiiff, invoke_viiiifi: invoke_viiiifi, invoke_viiiii: invoke_viiiii, invoke_viiiiifii: invoke_viiiiifii, invoke_viiiiii: invoke_viiiiii, invoke_viiiiiifi: invoke_viiiiiifi, invoke_viiiiiii: invoke_viiiiiii, invoke_viiiiiiif: invoke_viiiiiiif, invoke_viiiiiiifi: invoke_viiiiiiifi, invoke_viiiiiiifiiifffffiii: invoke_viiiiiiifiiifffffiii, invoke_viiiiiiii: invoke_viiiiiiii, invoke_viiiiiiiii: invoke_viiiiiiiii, invoke_viiiiiiiiii: invoke_viiiiiiiiii, invoke_viiiiiiiiiii: invoke_viiiiiiiiiii, invoke_viiiiiiiiiiiii: invoke_viiiiiiiiiiiii, invoke_viiiiiijj: invoke_viiiiiijj, invoke_viiiij: invoke_viiiij, invoke_viiij: invoke_viiij, invoke_viij: invoke_viij, invoke_viiji: invoke_viiji, invoke_vij: invoke_vij, setTempRet0: _setTempRet0, strftime: _strftime, time: _time, timegm: _timegm }, asm = createWasm(), ___wasm_call_ctors = Module.___wasm_call_ctors = createExportWrapper("__wasm_call_ctors"), _initContext = Module._initContext = createExportWrapper("initContext"), _openDocumentFromBuffer = Module._openDocumentFromBuffer = createExportWrapper("openDocumentFromBuffer"), _malloc = Module._malloc = createExportWrapper("malloc"), _saveSetjmp = Module._saveSetjmp = createExportWrapper("saveSetjmp"), _free = Module._free = createExportWrapper("free"), _writeDocument = Module._writeDocument = createExportWrapper("writeDocument"), _freeDocument = Module._freeDocument = createExportWrapper("freeDocument"), _countPages = Module._countPages = createExportWrapper("countPages"), _pageText = Module._pageText = createExportWrapper("pageText"), _doDrawPageAsPNG = Module._doDrawPageAsPNG = createExportWrapper("doDrawPageAsPNG"), _doDrawPageAsPNGGray = Module._doDrawPageAsPNGGray = createExportWrapper("doDrawPageAsPNGGray"), _getLastDrawData = Module._getLastDrawData = createExportWrapper("getLastDrawData"), _getLastDrawSize = Module._getLastDrawSize = createExportWrapper("getLastDrawSize"), _pageWidth = Module._pageWidth = createExportWrapper("pageWidth"), _pageHeight = Module._pageHeight = createExportWrapper("pageHeight"), _pageLinks = Module._pageLinks = createExportWrapper("pageLinks"), _search = Module._search = createExportWrapper("search"), _documentTitle = Module._documentTitle = createExportWrapper("documentTitle"), _loadOutline = Module._loadOutline = createExportWrapper("loadOutline"), _freeOutline = Module._freeOutline = createExportWrapper("freeOutline"), _outlineTitle = Module._outlineTitle = createExportWrapper("outlineTitle"), _outlinePage = Module._outlinePage = createExportWrapper("outlinePage"), _outlineDown = Module._outlineDown = createExportWrapper("outlineDown"), _outlineNext = Module._outlineNext = createExportWrapper("outlineNext"), ___errno_location = Module.___errno_location = createExportWrapper("__errno_location"), _fflush = Module._fflush = createExportWrapper("fflush"), __get_tzname = Module.__get_tzname = createExportWrapper("_get_tzname"), __get_daylight = Module.__get_daylight = createExportWrapper("_get_daylight"), __get_timezone = Module.__get_timezone = createExportWrapper("_get_timezone"), stackSave = Module.stackSave = createExportWrapper("stackSave"), stackRestore = Module.stackRestore = createExportWrapper("stackRestore"), stackAlloc = Module.stackAlloc = createExportWrapper("stackAlloc"), _emscripten_stack_init = Module._emscripten_stack_init = function () { return (_emscripten_stack_init = Module._emscripten_stack_init = Module.asm.emscripten_stack_init).apply(null, arguments) }, _emscripten_stack_get_free = Module._emscripten_stack_get_free = function () { return (_emscripten_stack_get_free = Module._emscripten_stack_get_free = Module.asm.emscripten_stack_get_free).apply(null, arguments) }, _emscripten_stack_get_end = Module._emscripten_stack_get_end = function () { return (_emscripten_stack_get_end = Module._emscripten_stack_get_end = Module.asm.emscripten_stack_get_end).apply(null, arguments) }, _setThrew = Module._setThrew = createExportWrapper("setThrew"), dynCall_jji = Module.dynCall_jji = createExportWrapper("dynCall_jji"), dynCall_iji = Module.dynCall_iji = createExportWrapper("dynCall_iji"), dynCall_vij = Module.dynCall_vij = createExportWrapper("dynCall_vij"), dynCall_jii = Module.dynCall_jii = createExportWrapper("dynCall_jii"), dynCall_viiji = Module.dynCall_viiji = createExportWrapper("dynCall_viiji"), dynCall_iij = Module.dynCall_iij = createExportWrapper("dynCall_iij"), dynCall_viiij = Module.dynCall_viiij = createExportWrapper("dynCall_viiij"), dynCall_viij = Module.dynCall_viij = createExportWrapper("dynCall_viij"), dynCall_iiijj = Module.dynCall_iiijj = createExportWrapper("dynCall_iiijj"), dynCall_iiiiiiiij = Module.dynCall_iiiiiiiij = createExportWrapper("dynCall_iiiiiiiij"), dynCall_iiiiiiji = Module.dynCall_iiiiiiji = createExportWrapper("dynCall_iiiiiiji"), dynCall_viiiij = Module.dynCall_viiiij = createExportWrapper("dynCall_viiiij"), dynCall_viiiiiijj = Module.dynCall_viiiiiijj = createExportWrapper("dynCall_viiiiiijj"), dynCall_jiij = Module.dynCall_jiij = createExportWrapper("dynCall_jiij"), dynCall_iiij = Module.dynCall_iiij = createExportWrapper("dynCall_iiij"), dynCall_iiiiij = Module.dynCall_iiiiij = createExportWrapper("dynCall_iiiiij"), dynCall_iiji = Module.dynCall_iiji = createExportWrapper("dynCall_iiji"), dynCall_jiji = Module.dynCall_jiji = createExportWrapper("dynCall_jiji"); function invoke_vi(e, t) { var r = stackSave(); try { wasmTable.get(e)(t) } catch (e) { if (stackRestore(r), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_ii(e, t) { var r = stackSave(); try { return wasmTable.get(e)(t) } catch (e) { if (stackRestore(r), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiii(e, t, r, o) { var n = stackSave(); try { return wasmTable.get(e)(t, r, o) } catch (e) { if (stackRestore(n), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iii(e, t, r) { var o = stackSave(); try { return wasmTable.get(e)(t, r) } catch (e) { if (stackRestore(o), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_vii(e, t, r) { var o = stackSave(); try { wasmTable.get(e)(t, r) } catch (e) { if (stackRestore(o), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiif(e, t, r, o, n) { var i = stackSave(); try { wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viff(e, t, r, o) { var n = stackSave(); try { wasmTable.get(e)(t, r, o) } catch (e) { if (stackRestore(n), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiii(e, t, r, o, n, i) { var a = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i) } catch (e) { if (stackRestore(a), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viii(e, t, r, o) { var n = stackSave(); try { wasmTable.get(e)(t, r, o) } catch (e) { if (stackRestore(n), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiii(e, t, r, o, n) { var i = stackSave(); try { wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiii(e, t, r, o, n, i, a) { var s = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiii(e, t, r, o, n, i, a) { var s = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiii(e, t, r, o, n) { var i = stackSave(); try { return wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiii(e, t, r, o, n, i) { var a = stackSave(); try { wasmTable.get(e)(t, r, o, n, i) } catch (e) { if (stackRestore(a), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiiifi(e, t, r, o, n, i, a, s, c, d) { var l = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c, d) } catch (e) { if (stackRestore(l), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiifi(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiifi(e, t, r, o, n, i, a) { var s = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiii(e, t, r, o, n, i, a, s) { var c = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s) } catch (e) { if (stackRestore(c), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiiif(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiffii(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viif(e, t, r, o) { var n = stackSave(); try { wasmTable.get(e)(t, r, o) } catch (e) { if (stackRestore(n), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiiii(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiffffiii(e, t, r, o, n, i, a, s, c, d) { var l = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c, d) } catch (e) { if (stackRestore(l), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiifiiii(e, t, r, o, n, i, a, s, c, d) { var l = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c, d) } catch (e) { if (stackRestore(l), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiiiiii(e, t, r, o, n, i, a, s, c, d, l) { var u = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l) } catch (e) { if (stackRestore(u), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiiiii(e, t, r, o, n, i, a, s, c, d) { var l = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c, d) } catch (e) { if (stackRestore(l), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiff(e, t, r, o, n) { var i = stackSave(); try { wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiii(e, t, r, o, n, i, a, s) { var c = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s) } catch (e) { if (stackRestore(c), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_fi(e, t) { var r = stackSave(); try { return wasmTable.get(e)(t) } catch (e) { if (stackRestore(r), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiffiiiiiii(e, t, r, o, n, i, a, s, c, d, l, u) { var p = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l, u) } catch (e) { if (stackRestore(p), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiiii(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_fiiiii(e, t, r, o, n, i) { var a = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i) } catch (e) { if (stackRestore(a), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_v(e) { var t = stackSave(); try { wasmTable.get(e)() } catch (e) { if (stackRestore(t), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiiiii(e, t, r, o, n, i, a, s, c, d) { var l = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c, d) } catch (e) { if (stackRestore(l), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiiiiiiiiiiii(e, t, r, o, n, i, a, s, c, d, l, u, p, f, E, _, M) { var T = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l, u, p, f, E, _, M) } catch (e) { if (stackRestore(T), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiiiiii(e, t, r, o, n, i, a, s, c, d, l) { var u = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l) } catch (e) { if (stackRestore(u), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiiiiiiiii(e, t, r, o, n, i, a, s, c, d, l, u, p, f) { var E = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l, u, p, f) } catch (e) { if (stackRestore(E), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiiiiiiiii(e, t, r, o, n, i, a, s, c, d, l, u, p, f) { var E = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l, u, p, f) } catch (e) { if (stackRestore(E), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_fii(e, t, r) { var o = stackSave(); try { return wasmTable.get(e)(t, r) } catch (e) { if (stackRestore(o), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiiiiiii(e, t, r, o, n, i, a, s, c, d, l, u) { var p = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l, u) } catch (e) { if (stackRestore(p), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_ffi(e, t, r) { var o = stackSave(); try { return wasmTable.get(e)(t, r) } catch (e) { if (stackRestore(o), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viffi(e, t, r, o, n) { var i = stackSave(); try { wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_fiiii(e, t, r, o, n) { var i = stackSave(); try { return wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_vif(e, t, r) { var o = stackSave(); try { wasmTable.get(e)(t, r) } catch (e) { if (stackRestore(o), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiid(e, t, r, o, n) { var i = stackSave(); try { wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viid(e, t, r, o) { var n = stackSave(); try { wasmTable.get(e)(t, r, o) } catch (e) { if (stackRestore(n), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_fiii(e, t, r, o) { var n = stackSave(); try { return wasmTable.get(e)(t, r, o) } catch (e) { if (stackRestore(n), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iif(e, t, r) { var o = stackSave(); try { return wasmTable.get(e)(t, r) } catch (e) { if (stackRestore(o), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiif(e, t, r, o, n) { var i = stackSave(); try { return wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viifi(e, t, r, o, n) { var i = stackSave(); try { wasmTable.get(e)(t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiifi(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_fiiifiif(e, t, r, o, n, i, a, s) { var c = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s) } catch (e) { if (stackRestore(c), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiffffff(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiifi(e, t, r, o, n, i) { var a = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i) } catch (e) { if (stackRestore(a), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiffff(e, t, r, o, n, i, a) { var s = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiifffffiii(e, t, r, o, n, i, a, s, c, d, l, u) { var p = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l, u) } catch (e) { if (stackRestore(p), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiiifiiifffffiii(e, t, r, o, n, i, a, s, c, d, l, u, p, f, E, _, M, T, m, S) { var g = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l, u, p, f, E, _, M, T, m, S) } catch (e) { if (stackRestore(g), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiffi(e, t, r, o, n, i, a, s) { var c = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s) } catch (e) { if (stackRestore(c), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiffiifiii(e, t, r, o, n, i, a, s, c, d, l, u, p) { var f = stackSave(); try { return wasmTable.get(e)(t, r, o, n, i, a, s, c, d, l, u, p) } catch (e) { if (stackRestore(f), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiifii(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiff(e, t, r, o, n, i, a) { var s = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiffii(e, t, r, o, n, i, a) { var s = stackSave(); try { wasmTable.get(e)(t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viifff(e, t, r, o, n, i) { var a = stackSave(); try { wasmTable.get(e)(t, r, o, n, i) } catch (e) { if (stackRestore(a), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiif(e, t, r, o, n, i) { var a = stackSave(); try { wasmTable.get(e)(t, r, o, n, i) } catch (e) { if (stackRestore(a), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_vij(e, t, r, o) { var n = stackSave(); try { dynCall_vij(e, t, r, o) } catch (e) { if (stackRestore(n), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_jii(e, t, r) { var o = stackSave(); try { return dynCall_jii(e, t, r) } catch (e) { if (stackRestore(o), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iij(e, t, r, o) { var n = stackSave(); try { return dynCall_iij(e, t, r, o) } catch (e) { if (stackRestore(n), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiij(e, t, r, o, n, i) { var a = stackSave(); try { dynCall_viiij(e, t, r, o, n, i) } catch (e) { if (stackRestore(a), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viij(e, t, r, o, n) { var i = stackSave(); try { dynCall_viij(e, t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiijj(e, t, r, o, n, i, a) { var s = stackSave(); try { return dynCall_iiijj(e, t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiji(e, t, r, o, n, i) { var a = stackSave(); try { dynCall_viiji(e, t, r, o, n, i) } catch (e) { if (stackRestore(a), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiij(e, t, r, o, n, i, a) { var s = stackSave(); try { dynCall_viiiij(e, t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiji(e, t, r, o, n, i, a, s, c) { var d = stackSave(); try { return dynCall_iiiiiiji(e, t, r, o, n, i, a, s, c) } catch (e) { if (stackRestore(d), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiiiiij(e, t, r, o, n, i, a, s, c, d) { var l = stackSave(); try { return dynCall_iiiiiiiij(e, t, r, o, n, i, a, s, c, d) } catch (e) { if (stackRestore(l), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_viiiiiijj(e, t, r, o, n, i, a, s, c, d, l) { var u = stackSave(); try { dynCall_viiiiiijj(e, t, r, o, n, i, a, s, c, d, l) } catch (e) { if (stackRestore(u), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_jiij(e, t, r, o, n) { var i = stackSave(); try { return dynCall_jiij(e, t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiij(e, t, r, o, n) { var i = stackSave(); try { return dynCall_iiij(e, t, r, o, n) } catch (e) { if (stackRestore(i), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function invoke_iiiiij(e, t, r, o, n, i, a) { var s = stackSave(); try { return dynCall_iiiiij(e, t, r, o, n, i, a) } catch (e) { if (stackRestore(s), e !== e + 0 && "longjmp" !== e) throw e; _setThrew(1, 0) } } function ExitStatus(e) { this.name = "ExitStatus", this.message = "Program terminated with exit(" + e + ")", this.status = e } function stackCheckInit() { _emscripten_stack_init(), writeStackCookie() } function run(e) { function t() { calledRun || (calledRun = !0, Module.calledRun = !0, ABORT || (initRuntime(), Module.onRuntimeInitialized && Module.onRuntimeInitialized(), assert(!Module._main, 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'), postRun())) } e = e || arguments_, runDependencies > 0 || (stackCheckInit(), preRun(), runDependencies > 0 || (Module.setStatus ? (Module.setStatus("Running..."), setTimeout((function () { setTimeout((function () { Module.setStatus("") }), 1), t() }), 1)) : t(), checkStackCookie())) } function checkUnflushedContent() { var e = out, t = err, r = !1; out = err = function (e) { r = !0 }; try { var o = Module._fflush; o && o(0), ["stdout", "stderr"].forEach((function (e) { var t = FS.analyzePath("/dev/" + e); if (t) { var o = t.object.rdev, n = TTY.ttys[o]; n && n.output && n.output.length && (r = !0) } })) } catch (e) { } out = e, err = t, r && warnOnce("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc.") } function exit(e, t) { EXITSTATUS = e, checkUnflushedContent(), t && keepRuntimeAlive() && 0 === e || (keepRuntimeAlive() ? t || err("program exited (with status: " + e + "), but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)") : (exitRuntime(), Module.onExit && Module.onExit(e), ABORT = !0), quit_(e, new ExitStatus(e))) } if (Object.getOwnPropertyDescriptor(Module, "intArrayFromString") || (Module.intArrayFromString = function () { abort("'intArrayFromString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "intArrayToString") || (Module.intArrayToString = function () { abort("'intArrayToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Module.ccall = ccall, Module.cwrap = cwrap, Object.getOwnPropertyDescriptor(Module, "setValue") || (Module.setValue = function () { abort("'setValue' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getValue") || (Module.getValue = function () { abort("'getValue' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "allocate") || (Module.allocate = function () { abort("'allocate' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "UTF8ArrayToString") || (Module.UTF8ArrayToString = function () { abort("'UTF8ArrayToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "UTF8ToString") || (Module.UTF8ToString = function () { abort("'UTF8ToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stringToUTF8Array") || (Module.stringToUTF8Array = function () { abort("'stringToUTF8Array' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stringToUTF8") || (Module.stringToUTF8 = function () { abort("'stringToUTF8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF8") || (Module.lengthBytesUTF8 = function () { abort("'lengthBytesUTF8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stackTrace") || (Module.stackTrace = function () { abort("'stackTrace' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "addOnPreRun") || (Module.addOnPreRun = function () { abort("'addOnPreRun' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "addOnInit") || (Module.addOnInit = function () { abort("'addOnInit' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "addOnPreMain") || (Module.addOnPreMain = function () { abort("'addOnPreMain' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "addOnExit") || (Module.addOnExit = function () { abort("'addOnExit' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "addOnPostRun") || (Module.addOnPostRun = function () { abort("'addOnPostRun' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeStringToMemory") || (Module.writeStringToMemory = function () { abort("'writeStringToMemory' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeArrayToMemory") || (Module.writeArrayToMemory = function () { abort("'writeArrayToMemory' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeAsciiToMemory") || (Module.writeAsciiToMemory = function () { abort("'writeAsciiToMemory' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Module.addRunDependency = addRunDependency, Module.removeRunDependency = removeRunDependency, Object.getOwnPropertyDescriptor(Module, "FS_createFolder") || (Module.FS_createFolder = function () { abort("'FS_createFolder' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Module.FS_createPath = FS.createPath, Module.FS_createDataFile = FS.createDataFile, Module.FS_createPreloadedFile = FS.createPreloadedFile, Module.FS_createLazyFile = FS.createLazyFile, Object.getOwnPropertyDescriptor(Module, "FS_createLink") || (Module.FS_createLink = function () { abort("'FS_createLink' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Module.FS_createDevice = FS.createDevice, Module.FS_unlink = FS.unlink, Object.getOwnPropertyDescriptor(Module, "getLEB") || (Module.getLEB = function () { abort("'getLEB' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getFunctionTables") || (Module.getFunctionTables = function () { abort("'getFunctionTables' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "alignFunctionTables") || (Module.alignFunctionTables = function () { abort("'alignFunctionTables' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerFunctions") || (Module.registerFunctions = function () { abort("'registerFunctions' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "addFunction") || (Module.addFunction = function () { abort("'addFunction' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "removeFunction") || (Module.removeFunction = function () { abort("'removeFunction' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getFuncWrapper") || (Module.getFuncWrapper = function () { abort("'getFuncWrapper' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "prettyPrint") || (Module.prettyPrint = function () { abort("'prettyPrint' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "dynCall") || (Module.dynCall = function () { abort("'dynCall' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getCompilerSetting") || (Module.getCompilerSetting = function () { abort("'getCompilerSetting' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "print") || (Module.print = function () { abort("'print' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "printErr") || (Module.printErr = function () { abort("'printErr' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getTempRet0") || (Module.getTempRet0 = function () { abort("'getTempRet0' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "setTempRet0") || (Module.setTempRet0 = function () { abort("'setTempRet0' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "callMain") || (Module.callMain = function () { abort("'callMain' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "abort") || (Module.abort = function () { abort("'abort' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stringToNewUTF8") || (Module.stringToNewUTF8 = function () { abort("'stringToNewUTF8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "setFileTime") || (Module.setFileTime = function () { abort("'setFileTime' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "emscripten_realloc_buffer") || (Module.emscripten_realloc_buffer = function () { abort("'emscripten_realloc_buffer' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "ENV") || (Module.ENV = function () { abort("'ENV' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "ERRNO_CODES") || (Module.ERRNO_CODES = function () { abort("'ERRNO_CODES' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "ERRNO_MESSAGES") || (Module.ERRNO_MESSAGES = function () { abort("'ERRNO_MESSAGES' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "setErrNo") || (Module.setErrNo = function () { abort("'setErrNo' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "inetPton4") || (Module.inetPton4 = function () { abort("'inetPton4' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "inetNtop4") || (Module.inetNtop4 = function () { abort("'inetNtop4' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "inetPton6") || (Module.inetPton6 = function () { abort("'inetPton6' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "inetNtop6") || (Module.inetNtop6 = function () { abort("'inetNtop6' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "readSockaddr") || (Module.readSockaddr = function () { abort("'readSockaddr' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeSockaddr") || (Module.writeSockaddr = function () { abort("'writeSockaddr' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "DNS") || (Module.DNS = function () { abort("'DNS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getHostByName") || (Module.getHostByName = function () { abort("'getHostByName' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "GAI_ERRNO_MESSAGES") || (Module.GAI_ERRNO_MESSAGES = function () { abort("'GAI_ERRNO_MESSAGES' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "Protocols") || (Module.Protocols = function () { abort("'Protocols' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "Sockets") || (Module.Sockets = function () { abort("'Sockets' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getRandomDevice") || (Module.getRandomDevice = function () { abort("'getRandomDevice' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "traverseStack") || (Module.traverseStack = function () { abort("'traverseStack' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "UNWIND_CACHE") || (Module.UNWIND_CACHE = function () { abort("'UNWIND_CACHE' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "withBuiltinMalloc") || (Module.withBuiltinMalloc = function () { abort("'withBuiltinMalloc' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "readAsmConstArgsArray") || (Module.readAsmConstArgsArray = function () { abort("'readAsmConstArgsArray' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "readAsmConstArgs") || (Module.readAsmConstArgs = function () { abort("'readAsmConstArgs' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "mainThreadEM_ASM") || (Module.mainThreadEM_ASM = function () { abort("'mainThreadEM_ASM' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "jstoi_q") || (Module.jstoi_q = function () { abort("'jstoi_q' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "jstoi_s") || (Module.jstoi_s = function () { abort("'jstoi_s' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getExecutableName") || (Module.getExecutableName = function () { abort("'getExecutableName' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "listenOnce") || (Module.listenOnce = function () { abort("'listenOnce' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "autoResumeAudioContext") || (Module.autoResumeAudioContext = function () { abort("'autoResumeAudioContext' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "dynCallLegacy") || (Module.dynCallLegacy = function () { abort("'dynCallLegacy' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getDynCaller") || (Module.getDynCaller = function () { abort("'getDynCaller' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "dynCall") || (Module.dynCall = function () { abort("'dynCall' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "callRuntimeCallbacks") || (Module.callRuntimeCallbacks = function () { abort("'callRuntimeCallbacks' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "runtimeKeepaliveCounter") || (Module.runtimeKeepaliveCounter = function () { abort("'runtimeKeepaliveCounter' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "keepRuntimeAlive") || (Module.keepRuntimeAlive = function () { abort("'keepRuntimeAlive' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "runtimeKeepalivePush") || (Module.runtimeKeepalivePush = function () { abort("'runtimeKeepalivePush' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "runtimeKeepalivePop") || (Module.runtimeKeepalivePop = function () { abort("'runtimeKeepalivePop' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "callUserCallback") || (Module.callUserCallback = function () { abort("'callUserCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "maybeExit") || (Module.maybeExit = function () { abort("'maybeExit' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "asmjsMangle") || (Module.asmjsMangle = function () { abort("'asmjsMangle' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "reallyNegative") || (Module.reallyNegative = function () { abort("'reallyNegative' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "unSign") || (Module.unSign = function () { abort("'unSign' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "reSign") || (Module.reSign = function () { abort("'reSign' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "formatString") || (Module.formatString = function () { abort("'formatString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "PATH") || (Module.PATH = function () { abort("'PATH' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "PATH_FS") || (Module.PATH_FS = function () { abort("'PATH_FS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "SYSCALLS") || (Module.SYSCALLS = function () { abort("'SYSCALLS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "syscallMmap2") || (Module.syscallMmap2 = function () { abort("'syscallMmap2' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "syscallMunmap") || (Module.syscallMunmap = function () { abort("'syscallMunmap' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getSocketFromFD") || (Module.getSocketFromFD = function () { abort("'getSocketFromFD' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getSocketAddress") || (Module.getSocketAddress = function () { abort("'getSocketAddress' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "JSEvents") || (Module.JSEvents = function () { abort("'JSEvents' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerKeyEventCallback") || (Module.registerKeyEventCallback = function () { abort("'registerKeyEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "specialHTMLTargets") || (Module.specialHTMLTargets = function () { abort("'specialHTMLTargets' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "maybeCStringToJsString") || (Module.maybeCStringToJsString = function () { abort("'maybeCStringToJsString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "findEventTarget") || (Module.findEventTarget = function () { abort("'findEventTarget' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "findCanvasEventTarget") || (Module.findCanvasEventTarget = function () { abort("'findCanvasEventTarget' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getBoundingClientRect") || (Module.getBoundingClientRect = function () { abort("'getBoundingClientRect' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillMouseEventData") || (Module.fillMouseEventData = function () { abort("'fillMouseEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerMouseEventCallback") || (Module.registerMouseEventCallback = function () { abort("'registerMouseEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerWheelEventCallback") || (Module.registerWheelEventCallback = function () { abort("'registerWheelEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerUiEventCallback") || (Module.registerUiEventCallback = function () { abort("'registerUiEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerFocusEventCallback") || (Module.registerFocusEventCallback = function () { abort("'registerFocusEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillDeviceOrientationEventData") || (Module.fillDeviceOrientationEventData = function () { abort("'fillDeviceOrientationEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerDeviceOrientationEventCallback") || (Module.registerDeviceOrientationEventCallback = function () { abort("'registerDeviceOrientationEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillDeviceMotionEventData") || (Module.fillDeviceMotionEventData = function () { abort("'fillDeviceMotionEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerDeviceMotionEventCallback") || (Module.registerDeviceMotionEventCallback = function () { abort("'registerDeviceMotionEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "screenOrientation") || (Module.screenOrientation = function () { abort("'screenOrientation' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillOrientationChangeEventData") || (Module.fillOrientationChangeEventData = function () { abort("'fillOrientationChangeEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerOrientationChangeEventCallback") || (Module.registerOrientationChangeEventCallback = function () { abort("'registerOrientationChangeEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillFullscreenChangeEventData") || (Module.fillFullscreenChangeEventData = function () { abort("'fillFullscreenChangeEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerFullscreenChangeEventCallback") || (Module.registerFullscreenChangeEventCallback = function () { abort("'registerFullscreenChangeEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerRestoreOldStyle") || (Module.registerRestoreOldStyle = function () { abort("'registerRestoreOldStyle' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "hideEverythingExceptGivenElement") || (Module.hideEverythingExceptGivenElement = function () { abort("'hideEverythingExceptGivenElement' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "restoreHiddenElements") || (Module.restoreHiddenElements = function () { abort("'restoreHiddenElements' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "setLetterbox") || (Module.setLetterbox = function () { abort("'setLetterbox' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "currentFullscreenStrategy") || (Module.currentFullscreenStrategy = function () { abort("'currentFullscreenStrategy' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "restoreOldWindowedStyle") || (Module.restoreOldWindowedStyle = function () { abort("'restoreOldWindowedStyle' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "softFullscreenResizeWebGLRenderTarget") || (Module.softFullscreenResizeWebGLRenderTarget = function () { abort("'softFullscreenResizeWebGLRenderTarget' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "doRequestFullscreen") || (Module.doRequestFullscreen = function () { abort("'doRequestFullscreen' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillPointerlockChangeEventData") || (Module.fillPointerlockChangeEventData = function () { abort("'fillPointerlockChangeEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerPointerlockChangeEventCallback") || (Module.registerPointerlockChangeEventCallback = function () { abort("'registerPointerlockChangeEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerPointerlockErrorEventCallback") || (Module.registerPointerlockErrorEventCallback = function () { abort("'registerPointerlockErrorEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "requestPointerLock") || (Module.requestPointerLock = function () { abort("'requestPointerLock' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillVisibilityChangeEventData") || (Module.fillVisibilityChangeEventData = function () { abort("'fillVisibilityChangeEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerVisibilityChangeEventCallback") || (Module.registerVisibilityChangeEventCallback = function () { abort("'registerVisibilityChangeEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerTouchEventCallback") || (Module.registerTouchEventCallback = function () { abort("'registerTouchEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillGamepadEventData") || (Module.fillGamepadEventData = function () { abort("'fillGamepadEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerGamepadEventCallback") || (Module.registerGamepadEventCallback = function () { abort("'registerGamepadEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerBeforeUnloadEventCallback") || (Module.registerBeforeUnloadEventCallback = function () { abort("'registerBeforeUnloadEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "fillBatteryEventData") || (Module.fillBatteryEventData = function () { abort("'fillBatteryEventData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "battery") || (Module.battery = function () { abort("'battery' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "registerBatteryEventCallback") || (Module.registerBatteryEventCallback = function () { abort("'registerBatteryEventCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "setCanvasElementSize") || (Module.setCanvasElementSize = function () { abort("'setCanvasElementSize' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getCanvasElementSize") || (Module.getCanvasElementSize = function () { abort("'getCanvasElementSize' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "polyfillSetImmediate") || (Module.polyfillSetImmediate = function () { abort("'polyfillSetImmediate' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "demangle") || (Module.demangle = function () { abort("'demangle' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "demangleAll") || (Module.demangleAll = function () { abort("'demangleAll' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "jsStackTrace") || (Module.jsStackTrace = function () { abort("'jsStackTrace' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stackTrace") || (Module.stackTrace = function () { abort("'stackTrace' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getEnvStrings") || (Module.getEnvStrings = function () { abort("'getEnvStrings' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "checkWasiClock") || (Module.checkWasiClock = function () { abort("'checkWasiClock' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeI53ToI64") || (Module.writeI53ToI64 = function () { abort("'writeI53ToI64' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeI53ToI64Clamped") || (Module.writeI53ToI64Clamped = function () { abort("'writeI53ToI64Clamped' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeI53ToI64Signaling") || (Module.writeI53ToI64Signaling = function () { abort("'writeI53ToI64Signaling' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeI53ToU64Clamped") || (Module.writeI53ToU64Clamped = function () { abort("'writeI53ToU64Clamped' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeI53ToU64Signaling") || (Module.writeI53ToU64Signaling = function () { abort("'writeI53ToU64Signaling' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "readI53FromI64") || (Module.readI53FromI64 = function () { abort("'readI53FromI64' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "readI53FromU64") || (Module.readI53FromU64 = function () { abort("'readI53FromU64' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "convertI32PairToI53") || (Module.convertI32PairToI53 = function () { abort("'convertI32PairToI53' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "convertU32PairToI53") || (Module.convertU32PairToI53 = function () { abort("'convertU32PairToI53' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "uncaughtExceptionCount") || (Module.uncaughtExceptionCount = function () { abort("'uncaughtExceptionCount' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "exceptionLast") || (Module.exceptionLast = function () { abort("'exceptionLast' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "exceptionCaught") || (Module.exceptionCaught = function () { abort("'exceptionCaught' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "ExceptionInfoAttrs") || (Module.ExceptionInfoAttrs = function () { abort("'ExceptionInfoAttrs' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "ExceptionInfo") || (Module.ExceptionInfo = function () { abort("'ExceptionInfo' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "CatchInfo") || (Module.CatchInfo = function () { abort("'CatchInfo' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "exception_addRef") || (Module.exception_addRef = function () { abort("'exception_addRef' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "exception_decRef") || (Module.exception_decRef = function () { abort("'exception_decRef' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "Browser") || (Module.Browser = function () { abort("'Browser' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "funcWrappers") || (Module.funcWrappers = function () { abort("'funcWrappers' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "getFuncWrapper") || (Module.getFuncWrapper = function () { abort("'getFuncWrapper' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "setMainLoop") || (Module.setMainLoop = function () { abort("'setMainLoop' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "FS") || (Module.FS = function () { abort("'FS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "mmapAlloc") || (Module.mmapAlloc = function () { abort("'mmapAlloc' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "MEMFS") || (Module.MEMFS = function () { abort("'MEMFS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "TTY") || (Module.TTY = function () { abort("'TTY' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "PIPEFS") || (Module.PIPEFS = function () { abort("'PIPEFS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "SOCKFS") || (Module.SOCKFS = function () { abort("'SOCKFS' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "_setNetworkCallback") || (Module._setNetworkCallback = function () { abort("'_setNetworkCallback' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "tempFixedLengthArray") || (Module.tempFixedLengthArray = function () { abort("'tempFixedLengthArray' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "miniTempWebGLFloatBuffers") || (Module.miniTempWebGLFloatBuffers = function () { abort("'miniTempWebGLFloatBuffers' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "heapObjectForWebGLType") || (Module.heapObjectForWebGLType = function () { abort("'heapObjectForWebGLType' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "heapAccessShiftForWebGLHeap") || (Module.heapAccessShiftForWebGLHeap = function () { abort("'heapAccessShiftForWebGLHeap' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "GL") || (Module.GL = function () { abort("'GL' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGet") || (Module.emscriptenWebGLGet = function () { abort("'emscriptenWebGLGet' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "computeUnpackAlignedImageSize") || (Module.computeUnpackAlignedImageSize = function () { abort("'computeUnpackAlignedImageSize' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetTexPixelData") || (Module.emscriptenWebGLGetTexPixelData = function () { abort("'emscriptenWebGLGetTexPixelData' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetUniform") || (Module.emscriptenWebGLGetUniform = function () { abort("'emscriptenWebGLGetUniform' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "webglGetUniformLocation") || (Module.webglGetUniformLocation = function () { abort("'webglGetUniformLocation' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "webglPrepareUniformLocationsBeforeFirstUse") || (Module.webglPrepareUniformLocationsBeforeFirstUse = function () { abort("'webglPrepareUniformLocationsBeforeFirstUse' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "webglGetLeftBracePos") || (Module.webglGetLeftBracePos = function () { abort("'webglGetLeftBracePos' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "emscriptenWebGLGetVertexAttrib") || (Module.emscriptenWebGLGetVertexAttrib = function () { abort("'emscriptenWebGLGetVertexAttrib' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "writeGLArray") || (Module.writeGLArray = function () { abort("'writeGLArray' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "AL") || (Module.AL = function () { abort("'AL' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "SDL_unicode") || (Module.SDL_unicode = function () { abort("'SDL_unicode' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "SDL_ttfContext") || (Module.SDL_ttfContext = function () { abort("'SDL_ttfContext' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "SDL_audio") || (Module.SDL_audio = function () { abort("'SDL_audio' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "SDL") || (Module.SDL = function () { abort("'SDL' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "SDL_gfx") || (Module.SDL_gfx = function () { abort("'SDL_gfx' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "GLUT") || (Module.GLUT = function () { abort("'GLUT' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "EGL") || (Module.EGL = function () { abort("'EGL' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "GLFW_Window") || (Module.GLFW_Window = function () { abort("'GLFW_Window' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "GLFW") || (Module.GLFW = function () { abort("'GLFW' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "GLEW") || (Module.GLEW = function () { abort("'GLEW' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "IDBStore") || (Module.IDBStore = function () { abort("'IDBStore' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "runAndAbortIfError") || (Module.runAndAbortIfError = function () { abort("'runAndAbortIfError' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "warnOnce") || (Module.warnOnce = function () { abort("'warnOnce' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stackSave") || (Module.stackSave = function () { abort("'stackSave' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stackRestore") || (Module.stackRestore = function () { abort("'stackRestore' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stackAlloc") || (Module.stackAlloc = function () { abort("'stackAlloc' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "AsciiToString") || (Module.AsciiToString = function () { abort("'AsciiToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stringToAscii") || (Module.stringToAscii = function () { abort("'stringToAscii' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "UTF16ToString") || (Module.UTF16ToString = function () { abort("'UTF16ToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stringToUTF16") || (Module.stringToUTF16 = function () { abort("'stringToUTF16' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF16") || (Module.lengthBytesUTF16 = function () { abort("'lengthBytesUTF16' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "UTF32ToString") || (Module.UTF32ToString = function () { abort("'UTF32ToString' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "stringToUTF32") || (Module.stringToUTF32 = function () { abort("'stringToUTF32' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "lengthBytesUTF32") || (Module.lengthBytesUTF32 = function () { abort("'lengthBytesUTF32' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "allocateUTF8") || (Module.allocateUTF8 = function () { abort("'allocateUTF8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Object.getOwnPropertyDescriptor(Module, "allocateUTF8OnStack") || (Module.allocateUTF8OnStack = function () { abort("'allocateUTF8OnStack' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") }), Module.writeStackCookie = writeStackCookie, Module.checkStackCookie = checkStackCookie, Object.getOwnPropertyDescriptor(Module, "ALLOC_NORMAL") || Object.defineProperty(Module, "ALLOC_NORMAL", { configurable: !0, get: function () { abort("'ALLOC_NORMAL' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") } }), Object.getOwnPropertyDescriptor(Module, "ALLOC_STACK") || Object.defineProperty(Module, "ALLOC_STACK", { configurable: !0, get: function () { abort("'ALLOC_STACK' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)") } }), dependenciesFulfilled = function e() { calledRun || run(), calledRun || (dependenciesFulfilled = e) }, Module.run = run, Module.preInit) for ("function" == typeof Module.preInit && (Module.preInit = [Module.preInit]); Module.preInit.length > 0;)Module.preInit.pop()(); run(); \ No newline at end of file diff --git a/src/utils/mupdf/libmupdf.wasm b/src/utils/mupdf/libmupdf.wasm new file mode 100644 index 0000000..81c51a1 Binary files /dev/null and b/src/utils/mupdf/libmupdf.wasm differ diff --git a/src/utils/mupdf/mupdf-worker.js b/src/utils/mupdf/mupdf-worker.js new file mode 100644 index 0000000..540e5c8 --- /dev/null +++ b/src/utils/mupdf/mupdf-worker.js @@ -0,0 +1,38 @@ +importScripts("https://v1-cf-api.blueagle.top/static/libmupdf.js"); + +const mupdf = { + unlock(data) { + FS.writeFile("test_1.pdf", data) + mupdf.writeDocument(); + let content = FS.readFile("/test_2.pdf"); + FS.unlink("/test_1.pdf"); + FS.unlink("/test_2.pdf"); + return content; + } +}; + +let ready = false; + +Module.onRuntimeInitialized = function () { + Module.ccall('initContext'); + mupdf.writeDocument = Module.cwrap('writeDocument', 'null', []); + postMessage("READY"); + ready = true; +}; + +onmessage = function (event) { + let [func, args, id] = event.data; + if (!ready) { + postMessage(["ERROR", id, { name: "NotReadyError", message: "WASM module is not ready yet" }]); + return; + } + try { + let result = mupdf[func](...args); + if (result instanceof ArrayBuffer) + postMessage(["RESULT", id, result], [result]); + else + postMessage(["RESULT", id, result]); + } catch (error) { + postMessage(["ERROR", id, { name: error.name, message: error.message }]); + } +} diff --git a/src/utils/unlockDocument.js b/src/utils/unlockDocument.js index fa02f7b..3dba8cb 100644 --- a/src/utils/unlockDocument.js +++ b/src/utils/unlockDocument.js @@ -1,11 +1,11 @@ import JSZip from 'jszip'; -import mupdf from './pdfUnlock'; +import mupdf from './mupdf'; -async function parseXMLFromZip(zip, path) { +export async function parseXMLFromZip(zip, path) { return new DOMParser().parseFromString(await zip.file(path).async('string'), 'application/xml'); } -function saveXMLToZip(zip, path, xml) { +export function saveXMLToZip(zip, path, xml) { return zip.file(path, new XMLSerializer().serializeToString(xml)); } @@ -78,7 +78,16 @@ const typeHandlers = [ { type: 'application/pdf', handler: async function (blob) { - return new Blob([await mupdf.unlock(new Uint8Array(await blob.arrayBuffer()))], { type: blob.type }); + try { + const pdf = await mupdf.unlock(new Uint8Array(await blob.arrayBuffer())); + return new Blob([pdf], { type: blob.type }); + } catch (error) { + if (/NaN/.test(error.message)) { + throw new Error('Decryption module not loaded, please wait a few seconds and try again. Make sure you are connected to the internet. (PRC user may need to use a VPN)'); + } else { + throw error; + } + } } } ]