mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 11:47:54 +01:00
web: add support for at rest encryption and app lock
This commit is contained in:
@@ -20,3 +20,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
export * from "./constants";
|
||||
export type { AppRouter } from "./api";
|
||||
export { type UpdateInfo } from "builder-util-runtime";
|
||||
export { type DesktopIntegration } from "./utils/config";
|
||||
|
||||
67
apps/web/at-rest-encryption.md
Normal file
67
apps/web/at-rest-encryption.md
Normal file
@@ -0,0 +1,67 @@
|
||||
How at rest encryption works:
|
||||
|
||||
There are 3 keys:
|
||||
|
||||
1. App lock pin/password (if app lock is enabled) - set by user
|
||||
2. Database encryption key (local) - randomly generated
|
||||
3. User encryption key (global) - generated from user's password
|
||||
|
||||
If app lock is not set, the flow looks like this:
|
||||
|
||||
Database encryption key
|
||||
-> User encryption key
|
||||
-> Database
|
||||
|
||||
If the user enables app lock, the flow becomes:
|
||||
|
||||
App lock pin/password
|
||||
-> Database encryption key
|
||||
---> User encryption key
|
||||
---> Database
|
||||
|
||||
Where each level of depth indicates parent-child relation.
|
||||
|
||||
Storing credentials:
|
||||
|
||||
The app lock pin/password must not be stored anywhere. This is akin to a "master password" and should be the responsibility of the user to keep safe.
|
||||
|
||||
The database encryption key & the user encryption key are always stored in the `keystore`. Once the user unlocks the app lock, the decrypted database encryption key is kept in memory. This is done to make the process of further encryption/decryption simpler.
|
||||
|
||||
The flow will be as follows:
|
||||
|
||||
1. Open app
|
||||
2. Find out if app lock is enabled
|
||||
3. If enabled, show the app lock and wait for the user to enter the pin
|
||||
4. Take the pin and decrypt the machine generated database password + user's actual encryption key (we will store both together)
|
||||
5. Use the database password to init the db & keep the user's encryption key in memory. (we have 2 choices here: either keep the encryption key in memory or keep the pin in memory)
|
||||
6. If not enabled, we will ask the keystore to give us the database password + user's encryption key
|
||||
|
||||
We should store both the database password and the user's encryption key in a keychain. If user sets a pin, we can just double encrypt these values. This will keep things simple and seemless.
|
||||
|
||||
Q: How to find out if app lock is enabled?
|
||||
|
||||
One option is to just store a boolean in the localStorage.
|
||||
|
||||
Q: What would be the initial state of things?
|
||||
|
||||
Initially, when user logs in there will be no app lock so we will be doing step 6. If a user sets up an app lock, we will do step 3 to 5.
|
||||
|
||||
Q: Changing app lock pin
|
||||
|
||||
Changing the app lock pin will ask for both current pin and older pin for conventional reasons. We will verify the current pin similar to how we verified it before (by decrypting the values stored in the keychain) and then we will reencrypt these values using the new pin.
|
||||
|
||||
Q: Disabling app lock
|
||||
|
||||
Disabling app lock will ask for the current pin. This pin will be used to remove encryption from the values stored in the keychain.
|
||||
|
||||
Q: Logged out users
|
||||
|
||||
For logged out users, we will simply use default at rest encryption.
|
||||
|
||||
Q: App lock levels
|
||||
|
||||
1. None
|
||||
2. Medium - app is locked only on close
|
||||
3. High - app is locked on tab switch & app close
|
||||
|
||||
Some users have requested app lock timeout which basically locks the app after a certain period of inactivity. What is inactivity? Mouse movement? Key presses? This can be added on all levels, I think?
|
||||
409
apps/web/package-lock.json
generated
409
apps/web/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -42,6 +42,7 @@
|
||||
"allotment": "^1.19.3",
|
||||
"async-mutex": "^0.4.0",
|
||||
"axios": "^1.3.4",
|
||||
"cbor-x": "^1.5.7",
|
||||
"clipboard-polyfill": "4.0.0",
|
||||
"comlink": "^4.3.1",
|
||||
"cronosjs": "^1.7.1",
|
||||
|
||||
@@ -142,8 +142,8 @@ function isSessionExpired(path: Routes): RouteWithPath<AuthProps> | null {
|
||||
}
|
||||
|
||||
export async function init() {
|
||||
await initializeLogger();
|
||||
await initializeFeatureChecks();
|
||||
await initializeLogger();
|
||||
|
||||
const { path, route } = getRoute();
|
||||
return { ...route, path };
|
||||
|
||||
@@ -33,19 +33,17 @@ import { SqliteAdapter, SqliteQueryCompiler, SqliteIntrospector } from "kysely";
|
||||
// @ts-ignore
|
||||
let db: Database = {};
|
||||
async function initializeDatabase(persistence: DatabasePersistence) {
|
||||
console.log("initi");
|
||||
logger.measure("Database initialization");
|
||||
|
||||
const { database } = await import("@notesnook/common");
|
||||
const { FileStorage } = await import("../interfaces/fs");
|
||||
const { Compressor } = await import("../utils/compressor");
|
||||
const { KeyChain } = await import("../interfaces/key-store");
|
||||
|
||||
db = database;
|
||||
|
||||
// // const ss = wrap<SQLiteWorker>(new Worker());
|
||||
// // await ss.init("test.db", false, uri);
|
||||
|
||||
// const res = await ss.run("query", `.table`);
|
||||
// console.log(res);
|
||||
// await ss.close();
|
||||
const databaseKey = await KeyChain.extractKey();
|
||||
|
||||
db.host({
|
||||
API_HOST: "https://api.notesnook.com",
|
||||
@@ -55,6 +53,7 @@ async function initializeDatabase(persistence: DatabasePersistence) {
|
||||
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co"
|
||||
});
|
||||
|
||||
const storage = new NNStorage("Notesnook", KeyChain, persistence);
|
||||
database.setup({
|
||||
sqliteOptions: {
|
||||
dialect: (name) => ({
|
||||
@@ -69,14 +68,16 @@ async function initializeDatabase(persistence: DatabasePersistence) {
|
||||
synchronous: "normal",
|
||||
pageSize: 8192,
|
||||
cacheSize: -16000,
|
||||
lockingMode: "exclusive"
|
||||
lockingMode: "exclusive",
|
||||
password: databaseKey
|
||||
},
|
||||
storage: await NNStorage.createInstance("Notesnook", persistence),
|
||||
storage: storage,
|
||||
eventsource: EventSource,
|
||||
fs: FileStorage,
|
||||
compressor: new Compressor(),
|
||||
batchSize: 500
|
||||
});
|
||||
|
||||
// if (IS_TESTING) {
|
||||
|
||||
// } else {
|
||||
|
||||
@@ -24,7 +24,6 @@ import { store as editorStore } from "../stores/editor-store";
|
||||
import { store as noteStore } from "../stores/note-store";
|
||||
import { db } from "./db";
|
||||
import { showToast } from "../utils/toast";
|
||||
import { Text } from "@theme-ui/components";
|
||||
import Config from "../utils/config";
|
||||
import { AppVersion, getChangelog } from "../utils/version";
|
||||
import { Period } from "../dialogs/buy-dialog/types";
|
||||
@@ -37,6 +36,7 @@ import { ThemeMetadata } from "@notesnook/themes-server";
|
||||
import { Color, Reminder, Tag } from "@notesnook/core";
|
||||
import { AuthenticatorType } from "@notesnook/core/dist/api/user-manager";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { PasswordDialogProps } from "../dialogs/password-dialog";
|
||||
|
||||
type DialogTypes = typeof Dialogs;
|
||||
type DialogIds = keyof DialogTypes;
|
||||
@@ -290,138 +290,25 @@ export function showMoveNoteDialog(noteIds: string[]) {
|
||||
));
|
||||
}
|
||||
|
||||
function getDialogData(type: string) {
|
||||
switch (type) {
|
||||
case "create_vault":
|
||||
return {
|
||||
title: "Create your vault",
|
||||
subtitle: "A vault stores your notes in a password-encrypted storage.",
|
||||
positiveButtonText: "Create vault"
|
||||
};
|
||||
case "clear_vault":
|
||||
return {
|
||||
title: "Clear your vault",
|
||||
subtitle:
|
||||
"Enter vault password to unlock and remove all notes from the vault.",
|
||||
positiveButtonText: "Clear vault"
|
||||
};
|
||||
case "delete_vault":
|
||||
return {
|
||||
title: "Delete your vault",
|
||||
subtitle: "Enter your account password to delete your vault.",
|
||||
positiveButtonText: "Delete vault",
|
||||
checks: [
|
||||
{ key: "deleteAllLockedNotes", title: "Delete all locked notes?" }
|
||||
]
|
||||
};
|
||||
case "lock_note":
|
||||
return {
|
||||
title: "Lock note",
|
||||
subtitle: "Please open your vault to encrypt & lock this note.",
|
||||
positiveButtonText: "Lock note"
|
||||
};
|
||||
case "unlock_note":
|
||||
return {
|
||||
title: "Unlock note",
|
||||
subtitle: "Your note will be unencrypted and removed from the vault.",
|
||||
positiveButtonText: "Unlock note"
|
||||
};
|
||||
case "unlock_and_delete_note":
|
||||
return {
|
||||
title: "Delete note",
|
||||
subtitle: "Please unlock this note to move it to trash.",
|
||||
positiveButtonText: "Unlock & delete"
|
||||
};
|
||||
case "change_password":
|
||||
return {
|
||||
title: "Change vault password",
|
||||
subtitle:
|
||||
"All locked notes will be re-encrypted with the new password.",
|
||||
positiveButtonText: "Change password"
|
||||
};
|
||||
case "ask_vault_password":
|
||||
return {
|
||||
title: "Unlock vault",
|
||||
subtitle: "Please enter your vault password to continue.",
|
||||
positiveButtonText: "Unlock"
|
||||
};
|
||||
case "change_account_password":
|
||||
return {
|
||||
title: "Change account password",
|
||||
subtitle: (
|
||||
<>
|
||||
All your data will be re-encrypted and synced with the new password.
|
||||
<Text
|
||||
as="div"
|
||||
mt={1}
|
||||
p={1}
|
||||
bg="var(--background-error)"
|
||||
sx={{ color: "var(--paragraph-error)" }}
|
||||
>
|
||||
<Text as="p" my={0} sx={{ color: "inherit" }}>
|
||||
It is recommended that you <b>log out from all other devices</b>{" "}
|
||||
before continuing.
|
||||
</Text>
|
||||
<Text as="p" my={0} mt={1} sx={{ color: "inherit" }}>
|
||||
If this process is interrupted, there is a high chance of data
|
||||
corruption so{" "}
|
||||
<b>please do NOT shut down your device or close your browser</b>{" "}
|
||||
until this process completes.
|
||||
</Text>
|
||||
</Text>
|
||||
</>
|
||||
),
|
||||
positiveButtonText: "Change password"
|
||||
};
|
||||
case "verify_account":
|
||||
return {
|
||||
title: "Verify it's you",
|
||||
subtitle: "Enter your account password to proceed.",
|
||||
positiveButtonText: "Verify"
|
||||
};
|
||||
case "delete_account":
|
||||
return {
|
||||
title: "Delete your account",
|
||||
subtitle: (
|
||||
<Text as="span" sx={{ color: "var(--paragraph-error)" }}>
|
||||
All your data will be permanently deleted with{" "}
|
||||
<b>no way of recovery</b>. Proceed with caution.
|
||||
</Text>
|
||||
),
|
||||
positiveButtonText: "Delete Account"
|
||||
};
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export function showPasswordDialog(
|
||||
type: string,
|
||||
validate: ({
|
||||
password
|
||||
}: {
|
||||
password?: string;
|
||||
oldPassword?: string;
|
||||
newPassword?: string;
|
||||
deleteAllLockedNotes?: boolean;
|
||||
}) => boolean | Promise<boolean>
|
||||
) {
|
||||
const { title, subtitle, positiveButtonText, checks } = getDialogData(type);
|
||||
return showDialog<"PasswordDialog", boolean>(
|
||||
export function showPasswordDialog<
|
||||
TInputId extends string,
|
||||
TCheckId extends string
|
||||
>(props: Omit<PasswordDialogProps<TInputId, TCheckId>, "onClose">) {
|
||||
return showDialog<
|
||||
"PasswordDialog",
|
||||
(Dialog, perform) => (
|
||||
<Dialog
|
||||
type={type}
|
||||
title={title}
|
||||
subtitle={subtitle}
|
||||
checks={checks}
|
||||
positiveButtonText={positiveButtonText}
|
||||
validate={validate}
|
||||
onClose={() => perform(false)}
|
||||
onDone={() => perform(true)}
|
||||
/>
|
||||
)
|
||||
);
|
||||
string extends TCheckId ? boolean : false | Record<TCheckId, boolean>
|
||||
>("PasswordDialog", (Dialog, perform) => (
|
||||
<Dialog
|
||||
{...props}
|
||||
onClose={(result) =>
|
||||
perform(
|
||||
result as string extends TCheckId
|
||||
? boolean
|
||||
: false | Record<TCheckId, boolean>
|
||||
)
|
||||
}
|
||||
/>
|
||||
));
|
||||
}
|
||||
|
||||
export function showBackupPasswordDialog(
|
||||
|
||||
@@ -261,8 +261,18 @@ async function restoreWithProgress(
|
||||
|
||||
export async function verifyAccount() {
|
||||
if (!(await db.user?.getUser())) return true;
|
||||
return showPasswordDialog("verify_account", async ({ password }) => {
|
||||
return !!password && (await db.user?.verifyPassword(password));
|
||||
return await showPasswordDialog({
|
||||
title: "Verify it's you",
|
||||
subtitle: "Enter your account password to proceed.",
|
||||
inputs: {
|
||||
password: {
|
||||
label: "Password",
|
||||
autoComplete: "current-password"
|
||||
}
|
||||
},
|
||||
validate: async ({ password }) => {
|
||||
return !!password && (await db.user?.verifyPassword(password));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ async function init(dbName: string, async: boolean, url?: string) {
|
||||
: new AccessHandlePoolVFS(dbName);
|
||||
if ("isReady" in vfs) await vfs.isReady;
|
||||
|
||||
sqlite.vfs_register(vfs, true);
|
||||
db = await sqlite.open_v2(dbName); //, undefined, dbName);
|
||||
sqlite.vfs_register(vfs, false);
|
||||
db = await sqlite.open_v2(dbName, undefined, `multipleciphers-${vfs.name}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,105 +5,142 @@ var Module = (() => {
|
||||
return (
|
||||
function(moduleArg = {}) {
|
||||
|
||||
var f=moduleArg,aa,ba;f.ready=new Promise((a,b)=>{aa=a;ba=b});var ca=Object.assign({},f),da="./this.program",ea=(a,b)=>{throw b;},fa="object"==typeof window,ia="function"==typeof importScripts,p="",ja;
|
||||
if(fa||ia)ia?p=self.location.href:"undefined"!=typeof document&&document.currentScript&&(p=document.currentScript.src),_scriptDir&&(p=_scriptDir),0!==p.indexOf("blob:")?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="",ia&&(ja=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ka=f.print||console.log.bind(console),t=f.printErr||console.error.bind(console);Object.assign(f,ca);ca=null;f.thisProgram&&(da=f.thisProgram);
|
||||
f.quit&&(ea=f.quit);var la;f.wasmBinary&&(la=f.wasmBinary);"object"!=typeof WebAssembly&&u("no native wasm support detected");var ma,v=!1,na,w,y,oa,z,B,pa,qa;function ra(){var a=ma.buffer;f.HEAP8=w=new Int8Array(a);f.HEAP16=oa=new Int16Array(a);f.HEAPU8=y=new Uint8Array(a);f.HEAPU16=new Uint16Array(a);f.HEAP32=z=new Int32Array(a);f.HEAPU32=B=new Uint32Array(a);f.HEAPF32=pa=new Float32Array(a);f.HEAPF64=qa=new Float64Array(a)}var sa=[],ta=[],ua=[],va=[];
|
||||
function wa(){var a=f.preRun.shift();sa.unshift(a)}var C=0,xa=null,ya=null;function u(a){if(f.onAbort)f.onAbort(a);a="Aborted("+a+")";t(a);v=!0;na=1;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");ba(a);throw a;}var za=a=>a.startsWith("data:application/octet-stream;base64,"),Aa;if(f.locateFile){if(Aa="wa-sqlite-async.wasm",!za(Aa)){var Ba=Aa;Aa=f.locateFile?f.locateFile(Ba,p):p+Ba}}else Aa=(new URL("wa-sqlite-async.wasm",import.meta.url)).href;
|
||||
function Ca(a){if(a==Aa&&la)return new Uint8Array(la);if(ja)return ja(a);throw"both async and sync fetching of the wasm failed";}function Da(a){return la||!fa&&!ia||"function"!=typeof fetch?Promise.resolve().then(()=>Ca(a)):fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw"failed to load wasm binary file at '"+a+"'";return b.arrayBuffer()}).catch(()=>Ca(a))}
|
||||
function Ea(a,b,c){return Da(a).then(d=>WebAssembly.instantiate(d,b)).then(d=>d).then(c,d=>{t(`failed to asynchronously prepare wasm: ${d}`);u(d)})}function Fa(a,b){var c=Aa;return la||"function"!=typeof WebAssembly.instantiateStreaming||za(c)||"function"!=typeof fetch?Ea(c,a,b):fetch(c,{credentials:"same-origin"}).then(d=>WebAssembly.instantiateStreaming(d,a).then(b,function(e){t(`wasm streaming compile failed: ${e}`);t("falling back to ArrayBuffer instantiation");return Ea(c,a,b)}))}var D,F;
|
||||
function Ga(a){this.name="ExitStatus";this.message=`Program terminated with exit(${a})`;this.status=a}var Ha=a=>{for(;0<a.length;)a.shift()(f)};function I(a,b="i8"){b.endsWith("*")&&(b="*");switch(b){case "i1":return w[a>>0];case "i8":return w[a>>0];case "i16":return oa[a>>1];case "i32":return z[a>>2];case "i64":u("to do getValue(i64) use WASM_BIGINT");case "float":return pa[a>>2];case "double":return qa[a>>3];case "*":return B[a>>2];default:u(`invalid type for getValue: ${b}`)}}
|
||||
var Ia=f.noExitRuntime||!0;function J(a,b,c="i8"){c.endsWith("*")&&(c="*");switch(c){case "i1":w[a>>0]=b;break;case "i8":w[a>>0]=b;break;case "i16":oa[a>>1]=b;break;case "i32":z[a>>2]=b;break;case "i64":u("to do setValue(i64) use WASM_BIGINT");case "float":pa[a>>2]=b;break;case "double":qa[a>>3]=b;break;case "*":B[a>>2]=b;break;default:u(`invalid type for setValue: ${c}`)}}
|
||||
var Ja="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,K=(a,b,c)=>{var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.buffer&&Ja)return Ja.decode(a.subarray(b,c));for(d="";b<c;){var e=a[b++];if(e&128){var h=a[b++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|h);else{var g=a[b++]&63;e=224==(e&240)?(e&15)<<12|h<<6|g:(e&7)<<18|h<<12|g<<6|a[b++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d},
|
||||
Ka=(a,b)=>{for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a},M=a=>{var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=Ka(a.split("/").filter(d=>!!d),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},La=a=>{var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b},Ma=a=>{if("/"===
|
||||
a)return"/";a=M(a);a=a.replace(/\/$/,"");var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)},Na=()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return a=>crypto.getRandomValues(a);u("initRandomDevice")},Oa=a=>(Oa=Na())(a);
|
||||
function Pa(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!=typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=Ka(a.split("/").filter(d=>!!d),!b).join("/");return(b?"/":"")+a||"."}
|
||||
var Qa=[],Ra=a=>{for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);127>=d?b++:2047>=d?b+=2:55296<=d&&57343>=d?(b+=4,++c):b+=3}return b},Sa=(a,b,c,d)=>{if(!(0<d))return 0;var e=c;d=c+d-1;for(var h=0;h<a.length;++h){var g=a.charCodeAt(h);if(55296<=g&&57343>=g){var n=a.charCodeAt(++h);g=65536+((g&1023)<<10)|n&1023}if(127>=g){if(c>=d)break;b[c++]=g}else{if(2047>=g){if(c+1>=d)break;b[c++]=192|g>>6}else{if(65535>=g){if(c+2>=d)break;b[c++]=224|g>>12}else{if(c+3>=d)break;b[c++]=240|g>>18;b[c++]=128|g>>
|
||||
12&63}b[c++]=128|g>>6&63}b[c++]=128|g&63}}b[c]=0;return c-e},Ta=[];function Ua(a,b){Ta[a]={input:[],Rb:[],bc:b};Va(a,Wa)}
|
||||
var Wa={open(a){var b=Ta[a.node.ec];if(!b)throw new N(43);a.Sb=b;a.seekable=!1},close(a){a.Sb.bc.ic(a.Sb)},ic(a){a.Sb.bc.ic(a.Sb)},read(a,b,c,d){if(!a.Sb||!a.Sb.bc.xc)throw new N(60);for(var e=0,h=0;h<d;h++){try{var g=a.Sb.bc.xc(a.Sb)}catch(n){throw new N(29);}if(void 0===g&&0===e)throw new N(6);if(null===g||void 0===g)break;e++;b[c+h]=g}e&&(a.node.timestamp=Date.now());return e},write(a,b,c,d){if(!a.Sb||!a.Sb.bc.rc)throw new N(60);try{for(var e=0;e<d;e++)a.Sb.bc.rc(a.Sb,b[c+e])}catch(h){throw new N(29);
|
||||
}d&&(a.node.timestamp=Date.now());return e}},Xa={xc(){a:{if(!Qa.length){var a=null;"undefined"!=typeof window&&"function"==typeof window.prompt?(a=window.prompt("Input: "),null!==a&&(a+="\n")):"function"==typeof readline&&(a=readline(),null!==a&&(a+="\n"));if(!a){var b=null;break a}b=Array(Ra(a)+1);a=Sa(a,b,0,b.length);b.length=a;Qa=b}b=Qa.shift()}return b},rc(a,b){null===b||10===b?(ka(K(a.Rb,0)),a.Rb=[]):0!=b&&a.Rb.push(b)},ic(a){a.Rb&&0<a.Rb.length&&(ka(K(a.Rb,0)),a.Rb=[])},Yc(){return{Uc:25856,
|
||||
Wc:5,Tc:191,Vc:35387,Sc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},Zc(){return 0},$c(){return[24,80]}},Ya={rc(a,b){null===b||10===b?(t(K(a.Rb,0)),a.Rb=[]):0!=b&&a.Rb.push(b)},ic(a){a.Rb&&0<a.Rb.length&&(t(K(a.Rb,0)),a.Rb=[])}};function Za(a,b){var c=a.Nb?a.Nb.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Nb,a.Nb=new Uint8Array(b),0<a.Pb&&a.Nb.set(c.subarray(0,a.Pb),0))}
|
||||
var O={Vb:null,Ub(){return O.createNode(null,"/",16895,0)},createNode(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new N(63);O.Vb||(O.Vb={dir:{node:{Tb:O.Cb.Tb,Qb:O.Cb.Qb,cc:O.Cb.cc,jc:O.Cb.jc,Bc:O.Cb.Bc,oc:O.Cb.oc,mc:O.Cb.mc,Ac:O.Cb.Ac,nc:O.Cb.nc},stream:{Zb:O.Mb.Zb}},file:{node:{Tb:O.Cb.Tb,Qb:O.Cb.Qb},stream:{Zb:O.Mb.Zb,read:O.Mb.read,write:O.Mb.write,uc:O.Mb.uc,kc:O.Mb.kc,lc:O.Mb.lc}},link:{node:{Tb:O.Cb.Tb,Qb:O.Cb.Qb,fc:O.Cb.fc},stream:{}},vc:{node:{Tb:O.Cb.Tb,Qb:O.Cb.Qb},stream:$a}});
|
||||
c=ab(a,b,c,d);P(c.mode)?(c.Cb=O.Vb.dir.node,c.Mb=O.Vb.dir.stream,c.Nb={}):32768===(c.mode&61440)?(c.Cb=O.Vb.file.node,c.Mb=O.Vb.file.stream,c.Pb=0,c.Nb=null):40960===(c.mode&61440)?(c.Cb=O.Vb.link.node,c.Mb=O.Vb.link.stream):8192===(c.mode&61440)&&(c.Cb=O.Vb.vc.node,c.Mb=O.Vb.vc.stream);c.timestamp=Date.now();a&&(a.Nb[b]=c,a.timestamp=c.timestamp);return c},Xc(a){return a.Nb?a.Nb.subarray?a.Nb.subarray(0,a.Pb):new Uint8Array(a.Nb):new Uint8Array(0)},Cb:{Tb(a){var b={};b.Hc=8192===(a.mode&61440)?a.id:
|
||||
1;b.yc=a.id;b.mode=a.mode;b.Nc=1;b.uid=0;b.Kc=0;b.ec=a.ec;P(a.mode)?b.size=4096:32768===(a.mode&61440)?b.size=a.Pb:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.Dc=new Date(a.timestamp);b.Mc=new Date(a.timestamp);b.Gc=new Date(a.timestamp);b.Ec=4096;b.Fc=Math.ceil(b.size/b.Ec);return b},Qb(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=b.timestamp);if(void 0!==b.size&&(b=b.size,a.Pb!=b))if(0==b)a.Nb=null,a.Pb=0;else{var c=a.Nb;a.Nb=new Uint8Array(b);c&&a.Nb.set(c.subarray(0,
|
||||
Math.min(b,a.Pb)));a.Pb=b}},cc(){throw bb[44];},jc(a,b,c,d){return O.createNode(a,b,c,d)},Bc(a,b,c){if(P(a.mode)){try{var d=cb(b,c)}catch(h){}if(d)for(var e in d.Nb)throw new N(55);}delete a.parent.Nb[a.name];a.parent.timestamp=Date.now();a.name=c;b.Nb[c]=a;b.timestamp=a.parent.timestamp;a.parent=b},oc(a,b){delete a.Nb[b];a.timestamp=Date.now()},mc(a,b){var c=cb(a,b),d;for(d in c.Nb)throw new N(55);delete a.Nb[b];a.timestamp=Date.now()},Ac(a){var b=[".",".."],c;for(c in a.Nb)a.Nb.hasOwnProperty(c)&&
|
||||
b.push(c);return b},nc(a,b,c){a=O.createNode(a,b,41471,0);a.link=c;return a},fc(a){if(40960!==(a.mode&61440))throw new N(28);return a.link}},Mb:{read(a,b,c,d,e){var h=a.node.Nb;if(e>=a.node.Pb)return 0;a=Math.min(a.node.Pb-e,d);if(8<a&&h.subarray)b.set(h.subarray(e,e+a),c);else for(d=0;d<a;d++)b[c+d]=h[e+d];return a},write(a,b,c,d,e,h){b.buffer===w.buffer&&(h=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Nb||a.Nb.subarray)){if(h)return a.Nb=b.subarray(c,c+d),a.Pb=d;if(0===
|
||||
a.Pb&&0===e)return a.Nb=b.slice(c,c+d),a.Pb=d;if(e+d<=a.Pb)return a.Nb.set(b.subarray(c,c+d),e),d}Za(a,e+d);if(a.Nb.subarray&&b.subarray)a.Nb.set(b.subarray(c,c+d),e);else for(h=0;h<d;h++)a.Nb[e+h]=b[c+h];a.Pb=Math.max(a.Pb,e+d);return d},Zb(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.Pb);if(0>b)throw new N(28);return b},uc(a,b,c){Za(a.node,b+c);a.node.Pb=Math.max(a.node.Pb,b+c)},kc(a,b,c,d,e){if(32768!==(a.node.mode&61440))throw new N(43);a=a.node.Nb;if(e&2||a.buffer!==
|
||||
w.buffer){if(0<c||c+b<a.length)a.subarray?a=a.subarray(c,c+b):a=Array.prototype.slice.call(a,c,c+b);c=!0;b=65536*Math.ceil(b/65536);(e=db(65536,b))?(y.fill(0,e,e+b),b=e):b=0;if(!b)throw new N(48);w.set(a,b)}else c=!1,b=a.byteOffset;return{Oc:b,Cc:c}},lc(a,b,c,d){O.Mb.write(a,b,0,d,c,!1);return 0}}},eb=(a,b)=>{var c=0;a&&(c|=365);b&&(c|=146);return c},fb=null,gb={},hb=[],ib=1,Q=null,jb=!0,N=null,bb={};
|
||||
function R(a,b={}){a=Pa(a);if(!a)return{path:"",node:null};b=Object.assign({wc:!0,sc:0},b);if(8<b.sc)throw new N(32);a=a.split("/").filter(g=>!!g);for(var c=fb,d="/",e=0;e<a.length;e++){var h=e===a.length-1;if(h&&b.parent)break;c=cb(c,a[e]);d=M(d+"/"+a[e]);c.$b&&(!h||h&&b.wc)&&(c=c.$b.root);if(!h||b.Yb)for(h=0;40960===(c.mode&61440);)if(c=kb(d),d=Pa(La(d),c),c=R(d,{sc:b.sc+1}).node,40<h++)throw new N(32);}return{path:d,node:c}}
|
||||
function lb(a){for(var b;;){if(a===a.parent)return a=a.Ub.zc,b?"/"!==a[a.length-1]?`${a}/${b}`:a+b:a;b=b?`${a.name}/${b}`:a.name;a=a.parent}}function mb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%Q.length}function nb(a){var b=mb(a.parent.id,a.name);if(Q[b]===a)Q[b]=a.ac;else for(b=Q[b];b;){if(b.ac===a){b.ac=a.ac;break}b=b.ac}}
|
||||
function cb(a,b){var c;if(c=(c=ob(a,"x"))?c:a.Cb.cc?0:2)throw new N(c,a);for(c=Q[mb(a.id,b)];c;c=c.ac){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Cb.cc(a,b)}function ab(a,b,c,d){a=new pb(a,b,c,d);b=mb(a.parent.id,a.name);a.ac=Q[b];return Q[b]=a}function P(a){return 16384===(a&61440)}function qb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}
|
||||
function ob(a,b){if(jb)return 0;if(!b.includes("r")||a.mode&292){if(b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73))return 2}else return 2;return 0}function rb(a,b){try{return cb(a,b),20}catch(c){}return ob(a,"wx")}function sb(a,b,c){try{var d=cb(a,b)}catch(e){return e.Ob}if(a=ob(a,"wx"))return a;if(c){if(!P(d.mode))return 54;if(d===d.parent||"/"===lb(d))return 10}else if(P(d.mode))return 31;return 0}function tb(){for(var a=0;4096>=a;a++)if(!hb[a])return a;throw new N(33);}
|
||||
function S(a){a=hb[a];if(!a)throw new N(8);return a}function ub(a,b=-1){vb||(vb=function(){this.hc={}},vb.prototype={},Object.defineProperties(vb.prototype,{object:{get(){return this.node},set(c){this.node=c}},flags:{get(){return this.hc.flags},set(c){this.hc.flags=c}},position:{get(){return this.hc.position},set(c){this.hc.position=c}}}));a=Object.assign(new vb,a);-1==b&&(b=tb());a.Wb=b;return hb[b]=a}var $a={open(a){a.Mb=gb[a.node.ec].Mb;a.Mb.open&&a.Mb.open(a)},Zb(){throw new N(70);}};
|
||||
function Va(a,b){gb[a]={Mb:b}}function wb(a,b){var c="/"===b,d=!b;if(c&&fb)throw new N(10);if(!c&&!d){var e=R(b,{wc:!1});b=e.path;e=e.node;if(e.$b)throw new N(10);if(!P(e.mode))throw new N(54);}b={type:a,bd:{},zc:b,Lc:[]};a=a.Ub(b);a.Ub=b;b.root=a;c?fb=a:e&&(e.$b=b,e.Ub&&e.Ub.Lc.push(b))}function xb(a,b,c){var d=R(a,{parent:!0}).node;a=Ma(a);if(!a||"."===a||".."===a)throw new N(28);var e=rb(d,a);if(e)throw new N(e);if(!d.Cb.jc)throw new N(63);return d.Cb.jc(d,a,b,c)}
|
||||
function T(a,b){return xb(a,(void 0!==b?b:511)&1023|16384,0)}function yb(a,b,c){"undefined"==typeof c&&(c=b,b=438);xb(a,b|8192,c)}function zb(a,b){if(!Pa(a))throw new N(44);var c=R(b,{parent:!0}).node;if(!c)throw new N(44);b=Ma(b);var d=rb(c,b);if(d)throw new N(d);if(!c.Cb.nc)throw new N(63);c.Cb.nc(c,b,a)}function Ab(a){var b=R(a,{parent:!0}).node;a=Ma(a);var c=cb(b,a),d=sb(b,a,!0);if(d)throw new N(d);if(!b.Cb.mc)throw new N(63);if(c.$b)throw new N(10);b.Cb.mc(b,a);nb(c)}
|
||||
function kb(a){a=R(a).node;if(!a)throw new N(44);if(!a.Cb.fc)throw new N(28);return Pa(lb(a.parent),a.Cb.fc(a))}function Bb(a,b){a=R(a,{Yb:!b}).node;if(!a)throw new N(44);if(!a.Cb.Tb)throw new N(63);return a.Cb.Tb(a)}function Cb(a){return Bb(a,!0)}function Db(a,b){a="string"==typeof a?R(a,{Yb:!0}).node:a;if(!a.Cb.Qb)throw new N(63);a.Cb.Qb(a,{mode:b&4095|a.mode&-4096,timestamp:Date.now()})}
|
||||
function Eb(a,b){if(0>b)throw new N(28);a="string"==typeof a?R(a,{Yb:!0}).node:a;if(!a.Cb.Qb)throw new N(63);if(P(a.mode))throw new N(31);if(32768!==(a.mode&61440))throw new N(28);var c=ob(a,"w");if(c)throw new N(c);a.Cb.Qb(a,{size:b,timestamp:Date.now()})}
|
||||
function Fb(a,b,c){if(""===a)throw new N(44);if("string"==typeof b){var d={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[b];if("undefined"==typeof d)throw Error(`Unknown file open mode: ${b}`);b=d}c=b&64?("undefined"==typeof c?438:c)&4095|32768:0;if("object"==typeof a)var e=a;else{a=M(a);try{e=R(a,{Yb:!(b&131072)}).node}catch(h){}}d=!1;if(b&64)if(e){if(b&128)throw new N(20);}else e=xb(a,c,0),d=!0;if(!e)throw new N(44);8192===(e.mode&61440)&&(b&=-513);if(b&65536&&!P(e.mode))throw new N(54);if(!d&&(c=
|
||||
e?40960===(e.mode&61440)?32:P(e.mode)&&("r"!==qb(b)||b&512)?31:ob(e,qb(b)):44))throw new N(c);b&512&&!d&&Eb(e,0);b&=-131713;e=ub({node:e,path:lb(e),flags:b,seekable:!0,position:0,Mb:e.Mb,Rc:[],error:!1});e.Mb.open&&e.Mb.open(e);!f.logReadFiles||b&1||(Gb||(Gb={}),a in Gb||(Gb[a]=1));return e}function Hb(a,b,c){if(null===a.Wb)throw new N(8);if(!a.seekable||!a.Mb.Zb)throw new N(70);if(0!=c&&1!=c&&2!=c)throw new N(28);a.position=a.Mb.Zb(a,b,c);a.Rc=[]}
|
||||
function Ib(){N||(N=function(a,b){this.name="ErrnoError";this.node=b;this.Pc=function(c){this.Ob=c};this.Pc(a);this.message="FS error"},N.prototype=Error(),N.prototype.constructor=N,[44].forEach(a=>{bb[a]=new N(a);bb[a].stack="<generic error, no stack>"}))}var Jb;
|
||||
function Kb(a,b,c){a=M("/dev/"+a);var d=eb(!!b,!!c);Lb||(Lb=64);var e=Lb++<<8|0;Va(e,{open(h){h.seekable=!1},close(){c&&c.buffer&&c.buffer.length&&c(10)},read(h,g,n,k){for(var l=0,r=0;r<k;r++){try{var m=b()}catch(q){throw new N(29);}if(void 0===m&&0===l)throw new N(6);if(null===m||void 0===m)break;l++;g[n+r]=m}l&&(h.node.timestamp=Date.now());return l},write(h,g,n,k){for(var l=0;l<k;l++)try{c(g[n+l])}catch(r){throw new N(29);}k&&(h.node.timestamp=Date.now());return l}});yb(a,d,e)}var Lb,U={},vb,Gb;
|
||||
function Mb(a,b,c){if("/"===b.charAt(0))return b;a=-100===a?"/":S(a).path;if(0==b.length){if(!c)throw new N(44);return a}return M(a+"/"+b)}
|
||||
function Nb(a,b,c){try{var d=a(b)}catch(h){if(h&&h.node&&M(b)!==M(lb(h.node)))return-54;throw h;}z[c>>2]=d.Hc;z[c+4>>2]=d.mode;B[c+8>>2]=d.Nc;z[c+12>>2]=d.uid;z[c+16>>2]=d.Kc;z[c+20>>2]=d.ec;F=[d.size>>>0,(D=d.size,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];z[c+24>>2]=F[0];z[c+28>>2]=F[1];z[c+32>>2]=4096;z[c+36>>2]=d.Fc;a=d.Dc.getTime();b=d.Mc.getTime();var e=d.Gc.getTime();F=[Math.floor(a/1E3)>>>0,(D=Math.floor(a/1E3),1<=+Math.abs(D)?0<D?+Math.floor(D/
|
||||
4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];z[c+40>>2]=F[0];z[c+44>>2]=F[1];B[c+48>>2]=a%1E3*1E3;F=[Math.floor(b/1E3)>>>0,(D=Math.floor(b/1E3),1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];z[c+56>>2]=F[0];z[c+60>>2]=F[1];B[c+64>>2]=b%1E3*1E3;F=[Math.floor(e/1E3)>>>0,(D=Math.floor(e/1E3),1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];z[c+72>>2]=F[0];z[c+76>>2]=F[1];B[c+80>>2]=
|
||||
e%1E3*1E3;F=[d.yc>>>0,(D=d.yc,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];z[c+88>>2]=F[0];z[c+92>>2]=F[1];return 0}var Ob=void 0;function Pb(){var a=z[+Ob>>2];Ob+=4;return a}
|
||||
var Qb=(a,b)=>b+2097152>>>0<4194305-!!a?(a>>>0)+4294967296*b:NaN,Rb=[0,31,60,91,121,152,182,213,244,274,305,335],Sb=[0,31,59,90,120,151,181,212,243,273,304,334],Ub=a=>{var b=Ra(a)+1,c=Tb(b);c&&Sa(a,y,c,b);return c},Vb={},Xb=()=>{if(!Wb){var a={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",_:da||"./this.program"},b;for(b in Vb)void 0===Vb[b]?delete a[b]:a[b]=Vb[b];
|
||||
var c=[];for(b in a)c.push(`${b}=${a[b]}`);Wb=c}return Wb},Wb;function Yb(){}function Zb(){}function $b(){}function ac(){}function bc(){}function cc(){}function dc(){}function ec(){}function fc(){}function gc(){}function hc(){}function ic(){}function jc(){}function kc(){}function lc(){}function mc(){}function nc(){}function oc(){}function pc(){}function qc(){}function rc(){}function sc(){}function tc(){}function uc(){}function vc(){}function wc(){}function xc(){}function yc(){}function zc(){}
|
||||
function Ac(){}function Bc(){}function Cc(){}function Dc(){}function Ec(){}function Fc(){}function Gc(){}function Hc(){}function Ic(){}function Jc(){}var Kc=0,Lc=a=>{na=a;if(!(Ia||0<Kc)){if(f.onExit)f.onExit(a);v=!0}ea(a,new Ga(a))},Mc=a=>{a instanceof Ga||"unwind"==a||ea(1,a)},Nc=a=>{try{a()}catch(b){u(b)}};
|
||||
function Oc(){var a=V,b={},c;for(c in a)(function(d){var e=a[d];b[d]="function"==typeof e?function(){Pc.push(d);try{return e.apply(null,arguments)}finally{v||(Pc.pop()===d||u(),X&&1===Y&&0===Pc.length&&(Y=0,Nc(Qc),"undefined"!=typeof Fibers&&Fibers.cd()))}}:e})(c);return b}var Y=0,X=null,Rc=0,Pc=[],Sc={},Tc={},Uc=0,Vc=null,Wc=[];function Xc(){return new Promise((a,b)=>{Vc={resolve:a,reject:b}})}
|
||||
function Yc(){var a=Tb(16396),b=a+12;B[a>>2]=b;B[a+4>>2]=b+16384;b=Pc[0];var c=Sc[b];void 0===c&&(c=Uc++,Sc[b]=c,Tc[c]=b);z[a+8>>2]=c;return a}
|
||||
function Zc(a){if(!v){if(0===Y){var b=!1,c=!1;a((d=0)=>{if(!v&&(Rc=d,b=!0,c)){Y=2;Nc(()=>$c(X));"undefined"!=typeof Browser&&Browser.qc.Jc&&Browser.qc.resume();d=!1;try{var e=(0,V[Tc[z[X+8>>2]]])()}catch(n){e=n,d=!0}var h=!1;if(!X){var g=Vc;g&&(Vc=null,(d?g.reject:g.resolve)(e),h=!0)}if(d&&!h)throw e;}});c=!0;b||(Y=1,X=Yc(),"undefined"!=typeof Browser&&Browser.qc.Jc&&Browser.qc.pause(),Nc(()=>ad(X)))}else 2===Y?(Y=0,Nc(bd),cd(X),X=null,Wc.forEach(d=>{if(!v)try{if(d(),!(Ia||0<Kc))try{na=d=na,Lc(d)}catch(e){Mc(e)}}catch(e){Mc(e)}})):
|
||||
u(`invalid state: ${Y}`);return Rc}}function dd(a){return Zc(b=>{a().then(b)})}
|
||||
var ed={},Z=(a,b,c,d,e)=>{function h(m){--Kc;0!==k&&fd(k);return"string"===b?m?K(y,m):"":"boolean"===b?!!m:m}var g={string:m=>{var q=0;if(null!==m&&void 0!==m&&0!==m){q=Ra(m)+1;var x=gd(q);Sa(m,y,x,q);q=x}return q},array:m=>{var q=gd(m.length);w.set(m,q);return q}};a=f["_"+a];var n=[],k=0;if(d)for(var l=0;l<d.length;l++){var r=g[c[l]];r?(0===k&&(k=hd()),n[l]=r(d[l])):n[l]=d[l]}c=X;d=a.apply(null,n);e=e&&e.async;Kc+=1;if(X!=c)return Xc().then(h);d=h(d);return e?Promise.resolve(d):d};
|
||||
function pb(a,b,c,d){a||(a=this);this.parent=a;this.Ub=a.Ub;this.$b=null;this.id=ib++;this.name=b;this.mode=c;this.Cb={};this.Mb={};this.ec=d}Object.defineProperties(pb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Ib();Q=Array(4096);wb(O,"/");T("/tmp");T("/home");T("/home/web_user");
|
||||
(function(){T("/dev");Va(259,{read:()=>0,write:(d,e,h,g)=>g});yb("/dev/null",259);Ua(1280,Xa);Ua(1536,Ya);yb("/dev/tty",1280);yb("/dev/tty1",1536);var a=new Uint8Array(1024),b=0,c=()=>{0===b&&(b=Oa(a).byteLength);return a[--b]};Kb("random",c);Kb("urandom",c);T("/dev/shm");T("/dev/shm/tmp")})();
|
||||
(function(){T("/proc");var a=T("/proc/self");T("/proc/self/fd");wb({Ub(){var b=ab(a,"fd",16895,73);b.Cb={cc(c,d){var e=S(+d);c={parent:null,Ub:{zc:"fake"},Cb:{fc:()=>e.path}};return c.parent=c}};return b}},"/proc/self/fd")})();
|
||||
(function(){const a=new Map;f.setAuthorizer=function(b,c,d){c?a.set(b,{f:c,tc:d}):a.delete(b);return Z("set_authorizer","number",["number"],[b])};Yb=function(b,c,d,e,h,g){if(a.has(b)){const {f:n,tc:k}=a.get(b);return n(k,c,d?d?K(y,d):"":null,e?e?K(y,e):"":null,h?h?K(y,h):"":null,g?g?K(y,g):"":null)}return 0}})();
|
||||
(function(){const a=new Map,b=new Map;f.createFunction=function(c,d,e,h,g,n){const k=a.size;a.set(k,{f:n,Xb:g});return Z("create_function","number","number string number number number number".split(" "),[c,d,e,h,k,0])};f.createAggregate=function(c,d,e,h,g,n,k){const l=a.size;a.set(l,{step:n,Ic:k,Xb:g});return Z("create_function","number","number string number number number number".split(" "),[c,d,e,h,l,1])};f.getFunctionUserData=function(c){return b.get(c)};$b=function(c,d,e,h){c=a.get(c);b.set(d,
|
||||
c.Xb);c.f(d,new Uint32Array(y.buffer,h,e));b.delete(d)};bc=function(c,d,e,h){c=a.get(c);b.set(d,c.Xb);c.step(d,new Uint32Array(y.buffer,h,e));b.delete(d)};Zb=function(c,d){c=a.get(c);b.set(d,c.Xb);c.Ic(d);b.delete(d)}})();(function(){const a=new Map;f.progressHandler=function(b,c,d,e){d?a.set(b,{f:d,tc:e}):a.delete(b);return Z("progress_handler",null,["number","number"],[b,c])};ac=function(b){if(a.has(b)){const {f:c,tc:d}=a.get(b);return c(d)}return 0}})();
|
||||
(function(){function a(k,l){const r=`get${k}`,m=`set${k}`;return new Proxy(new DataView(y.buffer,l,"Int32"===k?4:8),{get(q,x){if(x===r)return function(A,G){if(!G)throw Error("must be little endian");return q[x](A,G)};if(x===m)return function(A,G,E){if(!E)throw Error("must be little endian");return q[x](A,G,E)};if("string"===typeof x&&x.match(/^(get)|(set)/))throw Error("invalid type");return q[x]}})}const b="object"===typeof ed,c=new Map,d=new Map,e=new Map,h=b?new Set:null,g=b?new Set:null,n=new Map;
|
||||
sc=function(k,l,r,m){n.set(k?K(y,k):"",{size:l,dc:Array.from(new Uint32Array(y.buffer,m,r))})};f.createModule=function(k,l,r,m){b&&(r.handleAsync=dd);const q=c.size;c.set(q,{module:r,Xb:m});m=0;r.xCreate&&(m|=1);r.xConnect&&(m|=2);r.xBestIndex&&(m|=4);r.xDisconnect&&(m|=8);r.xDestroy&&(m|=16);r.xOpen&&(m|=32);r.xClose&&(m|=64);r.xFilter&&(m|=128);r.xNext&&(m|=256);r.xEof&&(m|=512);r.xColumn&&(m|=1024);r.xRowid&&(m|=2048);r.xUpdate&&(m|=4096);r.xBegin&&(m|=8192);r.xSync&&(m|=16384);r.xCommit&&(m|=
|
||||
32768);r.xRollback&&(m|=65536);r.xFindFunction&&(m|=131072);r.xRename&&(m|=262144);return Z("create_module","number",["number","string","number","number"],[k,l,q,m])};ic=function(k,l,r,m,q,x){l=c.get(l);d.set(q,l);if(b){h.delete(q);for(const A of h)d.delete(A)}m=Array.from(new Uint32Array(y.buffer,m,r)).map(A=>A?K(y,A):"");return l.module.xCreate(k,l.Xb,m,q,a("Int32",x))};hc=function(k,l,r,m,q,x){l=c.get(l);d.set(q,l);if(b){h.delete(q);for(const A of h)d.delete(A)}m=Array.from(new Uint32Array(y.buffer,
|
||||
m,r)).map(A=>A?K(y,A):"");return l.module.xConnect(k,l.Xb,m,q,a("Int32",x))};dc=function(k,l){var r=d.get(k),m=n.get("sqlite3_index_info").dc;const q={};q.nConstraint=I(l+m[0],"i32");q.aConstraint=[];var x=I(l+m[1],"*"),A=n.get("sqlite3_index_constraint").size;for(var G=0;G<q.nConstraint;++G){var E=q.aConstraint,L=E.push,H=x+G*A,ha=n.get("sqlite3_index_constraint").dc,W={};W.iColumn=I(H+ha[0],"i32");W.op=I(H+ha[1],"i8");W.usable=!!I(H+ha[2],"i8");L.call(E,W)}q.nOrderBy=I(l+m[2],"i32");q.aOrderBy=
|
||||
[];x=I(l+m[3],"*");A=n.get("sqlite3_index_orderby").size;for(G=0;G<q.nOrderBy;++G)E=q.aOrderBy,L=E.push,H=x+G*A,ha=n.get("sqlite3_index_orderby").dc,W={},W.iColumn=I(H+ha[0],"i32"),W.desc=!!I(H+ha[1],"i8"),L.call(E,W);q.aConstraintUsage=[];for(x=0;x<q.nConstraint;++x)q.aConstraintUsage.push({argvIndex:0,omit:!1});q.idxNum=I(l+m[5],"i32");q.idxStr=null;q.orderByConsumed=!!I(l+m[8],"i8");q.estimatedCost=I(l+m[9],"double");q.estimatedRows=I(l+m[10],"i32");q.idxFlags=I(l+m[11],"i32");q.colUsed=I(l+m[12],
|
||||
"i32");k=r.module.xBestIndex(k,q);r=n.get("sqlite3_index_info").dc;m=I(l+r[4],"*");x=n.get("sqlite3_index_constraint_usage").size;for(L=0;L<q.nConstraint;++L)A=m+L*x,E=q.aConstraintUsage[L],H=n.get("sqlite3_index_constraint_usage").dc,J(A+H[0],E.argvIndex,"i32"),J(A+H[1],E.omit?1:0,"i8");J(l+r[5],q.idxNum,"i32");"string"===typeof q.idxStr&&(m=Ra(q.idxStr),x=Z("sqlite3_malloc","number",["number"],[m+1]),Sa(q.idxStr,y,x,m+1),J(l+r[6],x,"*"),J(l+r[7],1,"i32"));J(l+r[8],q.orderByConsumed,"i32");J(l+r[9],
|
||||
q.estimatedCost,"double");J(l+r[10],q.estimatedRows,"i32");J(l+r[11],q.idxFlags,"i32");return k};kc=function(k){const l=d.get(k);b?h.add(k):d.delete(k);return l.module.xDisconnect(k)};jc=function(k){const l=d.get(k);b?h.add(k):d.delete(k);return l.module.xDestroy(k)};oc=function(k,l){const r=d.get(k);e.set(l,r);if(b){g.delete(l);for(const m of g)e.delete(m)}return r.module.xOpen(k,l)};ec=function(k){const l=e.get(k);b?g.add(k):e.delete(k);return l.module.xClose(k)};lc=function(k){return e.get(k).module.xEof(k)?
|
||||
1:0};mc=function(k,l,r,m,q){const x=e.get(k);r=r?r?K(y,r):"":null;q=new Uint32Array(y.buffer,q,m);return x.module.xFilter(k,l,r,q)};nc=function(k){return e.get(k).module.xNext(k)};fc=function(k,l,r){return e.get(k).module.xColumn(k,l,r)};rc=function(k,l){return e.get(k).module.xRowid(k,a("BigInt64",l))};uc=function(k,l,r,m){const q=d.get(k);r=new Uint32Array(y.buffer,r,l);return q.module.xUpdate(k,r,a("BigInt64",m))};cc=function(k){return d.get(k).module.xBegin(k)};tc=function(k){return d.get(k).module.xSync(k)};
|
||||
gc=function(k){return d.get(k).module.xCommit(k)};qc=function(k){return d.get(k).module.xRollback(k)};pc=function(k,l){const r=d.get(k);l=l?K(y,l):"";return r.module.xRename(k,l)}})();
|
||||
(function(){function a(g,n){const k=`get${g}`,l=`set${g}`;return new Proxy(new DataView(y.buffer,n,"Int32"===g?4:8),{get(r,m){if(m===k)return function(q,x){if(!x)throw Error("must be little endian");return r[m](q,x)};if(m===l)return function(q,x,A){if(!A)throw Error("must be little endian");return r[m](q,x,A)};if("string"===typeof m&&m.match(/^(get)|(set)/))throw Error("invalid type");return r[m]}})}function b(g){g>>=2;return B[g]+B[g+1]*2**32}const c="object"===typeof ed,d=new Map,e=new Map;f.registerVFS=
|
||||
function(g,n){if(Z("sqlite3_vfs_find","number",["string"],[g.name]))throw Error(`VFS '${g.name}' already registered`);c&&(g.handleAsync=dd);var k=g.ad??64;const l=f._malloc(4);n=Z("register_vfs","number",["string","number","number","number"],[g.name,k,n?1:0,l]);n||(k=I(l,"*"),d.set(k,g));f._free(l);return n};const h=c?new Set:null;xc=function(g){const n=e.get(g);c?h.add(g):e.delete(g);return n.xClose(g)};Ec=function(g,n,k,l){return e.get(g).xRead(g,y.subarray(n,n+k),b(l))};Jc=function(g,n,k,l){return e.get(g).xWrite(g,
|
||||
y.subarray(n,n+k),b(l))};Hc=function(g,n){return e.get(g).xTruncate(g,b(n))};Gc=function(g,n){return e.get(g).xSync(g,n)};Bc=function(g,n){const k=e.get(g);n=a("BigInt64",n);return k.xFileSize(g,n)};Cc=function(g,n){return e.get(g).xLock(g,n)};Ic=function(g,n){return e.get(g).xUnlock(g,n)};wc=function(g,n){const k=e.get(g);n=a("Int32",n);return k.xCheckReservedLock(g,n)};Ac=function(g,n,k){const l=e.get(g);k=new DataView(y.buffer,k);return l.xFileControl(g,n,k)};Fc=function(g){return e.get(g).xSectorSize(g)};
|
||||
zc=function(g){return e.get(g).xDeviceCharacteristics(g)};Dc=function(g,n,k,l,r){g=d.get(g);e.set(k,g);if(c){h.delete(k);for(var m of h)e.delete(m)}m=null;if(l&64){m=1;const q=[];for(;m;){const x=y[n++];if(x)q.push(x);else switch(y[n]||(m=null),m){case 1:q.push(63);m=2;break;case 2:q.push(61);m=3;break;case 3:q.push(38),m=2}}m=(new TextDecoder).decode(new Uint8Array(q))}else n&&(m=n?K(y,n):"");r=a("Int32",r);return g.xOpen(m,k,l,r)};yc=function(g,n,k){return d.get(g).xDelete(n?K(y,n):"",k)};vc=function(g,
|
||||
n,k,l){g=d.get(g);l=a("Int32",l);return g.xAccess(n?K(y,n):"",k,l)}})();
|
||||
var kd={a:(a,b,c,d)=>{u(`Assertion failed: ${a?K(y,a):""}, at: `+[b?b?K(y,b):"":"unknown filename",c,d?d?K(y,d):"":"unknown function"])},K:function(a,b){try{return a=a?K(y,a):"",Db(a,b),0}catch(c){if("undefined"==typeof U||"ErrnoError"!==c.name)throw c;return-c.Ob}},M:function(a,b,c){try{b=b?K(y,b):"";b=Mb(a,b);if(c&-8)return-28;var d=R(b,{Yb:!0}).node;if(!d)return-44;a="";c&4&&(a+="r");c&2&&(a+="w");c&1&&(a+="x");return a&&ob(d,a)?-2:0}catch(e){if("undefined"==typeof U||"ErrnoError"!==e.name)throw e;
|
||||
return-e.Ob}},L:function(a,b){try{var c=S(a);Db(c.node,b);return 0}catch(d){if("undefined"==typeof U||"ErrnoError"!==d.name)throw d;return-d.Ob}},J:function(a){try{var b=S(a).node;var c="string"==typeof b?R(b,{Yb:!0}).node:b;if(!c.Cb.Qb)throw new N(63);c.Cb.Qb(c,{timestamp:Date.now()});return 0}catch(d){if("undefined"==typeof U||"ErrnoError"!==d.name)throw d;return-d.Ob}},b:function(a,b,c){Ob=c;try{var d=S(a);switch(b){case 0:var e=Pb();if(0>e)return-28;for(;hb[e];)e++;return ub(d,e).Wb;case 1:case 2:return 0;
|
||||
case 3:return d.flags;case 4:return e=Pb(),d.flags|=e,0;case 5:return e=Pb(),oa[e+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return z[jd()>>2]=28,-1;default:return-28}}catch(h){if("undefined"==typeof U||"ErrnoError"!==h.name)throw h;return-h.Ob}},I:function(a,b){try{var c=S(a);return Nb(Bb,c.path,b)}catch(d){if("undefined"==typeof U||"ErrnoError"!==d.name)throw d;return-d.Ob}},n:function(a,b,c){b=Qb(b,c);try{if(isNaN(b))return 61;var d=S(a);if(0===(d.flags&2097155))throw new N(28);
|
||||
Eb(d.node,b);return 0}catch(e){if("undefined"==typeof U||"ErrnoError"!==e.name)throw e;return-e.Ob}},C:function(a,b){try{if(0===b)return-28;var c=Ra("/")+1;if(b<c)return-68;Sa("/",y,a,b);return c}catch(d){if("undefined"==typeof U||"ErrnoError"!==d.name)throw d;return-d.Ob}},F:function(a,b){try{return a=a?K(y,a):"",Nb(Cb,a,b)}catch(c){if("undefined"==typeof U||"ErrnoError"!==c.name)throw c;return-c.Ob}},z:function(a,b,c){try{return b=b?K(y,b):"",b=Mb(a,b),b=M(b),"/"===b[b.length-1]&&(b=b.substr(0,
|
||||
b.length-1)),T(b,c),0}catch(d){if("undefined"==typeof U||"ErrnoError"!==d.name)throw d;return-d.Ob}},E:function(a,b,c,d){try{b=b?K(y,b):"";var e=d&256;b=Mb(a,b,d&4096);return Nb(e?Cb:Bb,b,c)}catch(h){if("undefined"==typeof U||"ErrnoError"!==h.name)throw h;return-h.Ob}},y:function(a,b,c,d){Ob=d;try{b=b?K(y,b):"";b=Mb(a,b);var e=d?Pb():0;return Fb(b,c,e).Wb}catch(h){if("undefined"==typeof U||"ErrnoError"!==h.name)throw h;return-h.Ob}},w:function(a,b,c,d){try{b=b?K(y,b):"";b=Mb(a,b);if(0>=d)return-28;
|
||||
var e=kb(b),h=Math.min(d,Ra(e)),g=w[c+h];Sa(e,y,c,d+1);w[c+h]=g;return h}catch(n){if("undefined"==typeof U||"ErrnoError"!==n.name)throw n;return-n.Ob}},u:function(a){try{return a=a?K(y,a):"",Ab(a),0}catch(b){if("undefined"==typeof U||"ErrnoError"!==b.name)throw b;return-b.Ob}},H:function(a,b){try{return a=a?K(y,a):"",Nb(Bb,a,b)}catch(c){if("undefined"==typeof U||"ErrnoError"!==c.name)throw c;return-c.Ob}},r:function(a,b,c){try{b=b?K(y,b):"";b=Mb(a,b);if(0===c){a=b;var d=R(a,{parent:!0}).node;if(!d)throw new N(44);
|
||||
var e=Ma(a),h=cb(d,e),g=sb(d,e,!1);if(g)throw new N(g);if(!d.Cb.oc)throw new N(63);if(h.$b)throw new N(10);d.Cb.oc(d,e);nb(h)}else 512===c?Ab(b):u("Invalid flags passed to unlinkat");return 0}catch(n){if("undefined"==typeof U||"ErrnoError"!==n.name)throw n;return-n.Ob}},q:function(a,b,c){try{b=b?K(y,b):"";b=Mb(a,b,!0);if(c){var d=B[c>>2]+4294967296*z[c+4>>2],e=z[c+8>>2];h=1E3*d+e/1E6;c+=16;d=B[c>>2]+4294967296*z[c+4>>2];e=z[c+8>>2];g=1E3*d+e/1E6}else var h=Date.now(),g=h;a=h;var n=R(b,{Yb:!0}).node;
|
||||
n.Cb.Qb(n,{timestamp:Math.max(a,g)});return 0}catch(k){if("undefined"==typeof U||"ErrnoError"!==k.name)throw k;return-k.Ob}},l:function(a,b,c){a=new Date(1E3*Qb(a,b));z[c>>2]=a.getSeconds();z[c+4>>2]=a.getMinutes();z[c+8>>2]=a.getHours();z[c+12>>2]=a.getDate();z[c+16>>2]=a.getMonth();z[c+20>>2]=a.getFullYear()-1900;z[c+24>>2]=a.getDay();b=a.getFullYear();z[c+28>>2]=(0!==b%4||0===b%100&&0!==b%400?Sb:Rb)[a.getMonth()]+a.getDate()-1|0;z[c+36>>2]=-(60*a.getTimezoneOffset());b=(new Date(a.getFullYear(),
|
||||
6,1)).getTimezoneOffset();var d=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();z[c+32>>2]=(b!=d&&a.getTimezoneOffset()==Math.min(d,b))|0},i:function(a,b,c,d,e,h,g,n){e=Qb(e,h);try{if(isNaN(e))return 61;var k=S(d);if(0!==(b&2)&&0===(c&2)&&2!==(k.flags&2097155))throw new N(2);if(1===(k.flags&2097155))throw new N(2);if(!k.Mb.kc)throw new N(43);var l=k.Mb.kc(k,a,e,b,c);var r=l.Oc;z[g>>2]=l.Cc;B[n>>2]=r;return 0}catch(m){if("undefined"==typeof U||"ErrnoError"!==m.name)throw m;return-m.Ob}},j:function(a,
|
||||
b,c,d,e,h,g){h=Qb(h,g);try{if(isNaN(h))return 61;var n=S(e);if(c&2){if(32768!==(n.node.mode&61440))throw new N(43);d&2||n.Mb.lc&&n.Mb.lc(n,y.slice(a,a+b),h,b,d)}}catch(k){if("undefined"==typeof U||"ErrnoError"!==k.name)throw k;return-k.Ob}},s:(a,b,c)=>{function d(k){return(k=k.toTimeString().match(/\(([A-Za-z ]+)\)$/))?k[1]:"GMT"}var e=(new Date).getFullYear(),h=new Date(e,0,1),g=new Date(e,6,1);e=h.getTimezoneOffset();var n=g.getTimezoneOffset();B[a>>2]=60*Math.max(e,n);z[b>>2]=Number(e!=n);a=d(h);
|
||||
b=d(g);a=Ub(a);b=Ub(b);n<e?(B[c>>2]=a,B[c+4>>2]=b):(B[c>>2]=b,B[c+4>>2]=a)},e:()=>Date.now(),d:()=>performance.now(),o:a=>{var b=y.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);var e=Math;d=Math.max(a,d);a:{e=(e.min.call(e,2147483648,d+(65536-d%65536)%65536)-ma.buffer.byteLength+65535)/65536;try{ma.grow(e);ra();var h=1;break a}catch(g){}h=void 0}if(h)return!0}return!1},A:(a,b)=>{var c=0;Xb().forEach((d,e)=>{var h=b+c;e=B[a+4*e>>2]=h;for(h=
|
||||
0;h<d.length;++h)w[e++>>0]=d.charCodeAt(h);w[e>>0]=0;c+=d.length+1});return 0},B:(a,b)=>{var c=Xb();B[a>>2]=c.length;var d=0;c.forEach(e=>d+=e.length+1);B[b>>2]=d;return 0},f:function(a){try{var b=S(a);if(null===b.Wb)throw new N(8);b.pc&&(b.pc=null);try{b.Mb.close&&b.Mb.close(b)}catch(c){throw c;}finally{hb[b.Wb]=null}b.Wb=null;return 0}catch(c){if("undefined"==typeof U||"ErrnoError"!==c.name)throw c;return c.Ob}},p:function(a,b){try{var c=S(a);w[b>>0]=c.Sb?2:P(c.mode)?3:40960===(c.mode&61440)?7:
|
||||
4;oa[b+2>>1]=0;F=[0,(D=0,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];z[b+8>>2]=F[0];z[b+12>>2]=F[1];F=[0,(D=0,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];z[b+16>>2]=F[0];z[b+20>>2]=F[1];return 0}catch(d){if("undefined"==typeof U||"ErrnoError"!==d.name)throw d;return d.Ob}},x:function(a,b,c,d){try{a:{var e=S(a);a=b;for(var h,g=b=0;g<c;g++){var n=B[a>>2],k=B[a+4>>2];a+=8;var l=e,r=n,m=k,q=h,x=
|
||||
w;if(0>m||0>q)throw new N(28);if(null===l.Wb)throw new N(8);if(1===(l.flags&2097155))throw new N(8);if(P(l.node.mode))throw new N(31);if(!l.Mb.read)throw new N(28);var A="undefined"!=typeof q;if(!A)q=l.position;else if(!l.seekable)throw new N(70);var G=l.Mb.read(l,x,r,m,q);A||(l.position+=G);var E=G;if(0>E){var L=-1;break a}b+=E;if(E<k)break;"undefined"!==typeof h&&(h+=E)}L=b}B[d>>2]=L;return 0}catch(H){if("undefined"==typeof U||"ErrnoError"!==H.name)throw H;return H.Ob}},m:function(a,b,c,d,e){b=
|
||||
Qb(b,c);try{if(isNaN(b))return 61;var h=S(a);Hb(h,b,d);F=[h.position>>>0,(D=h.position,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];z[e>>2]=F[0];z[e+4>>2]=F[1];h.pc&&0===b&&0===d&&(h.pc=null);return 0}catch(g){if("undefined"==typeof U||"ErrnoError"!==g.name)throw g;return g.Ob}},D:function(a){try{var b=S(a);return Zc(c=>{var d=b.node.Ub;d.type.Qc?d.type.Qc(d,!1,e=>{e?c(29):c(0)}):c(0)})}catch(c){if("undefined"==typeof U||"ErrnoError"!==c.name)throw c;
|
||||
return c.Ob}},t:function(a,b,c,d){try{a:{var e=S(a);a=b;for(var h,g=b=0;g<c;g++){var n=B[a>>2],k=B[a+4>>2];a+=8;var l=e,r=n,m=k,q=h,x=w;if(0>m||0>q)throw new N(28);if(null===l.Wb)throw new N(8);if(0===(l.flags&2097155))throw new N(8);if(P(l.node.mode))throw new N(31);if(!l.Mb.write)throw new N(28);l.seekable&&l.flags&1024&&Hb(l,0,2);var A="undefined"!=typeof q;if(!A)q=l.position;else if(!l.seekable)throw new N(70);var G=l.Mb.write(l,x,r,m,q,void 0);A||(l.position+=G);var E=G;if(0>E){var L=-1;break a}b+=
|
||||
E;"undefined"!==typeof h&&(h+=E)}L=b}B[d>>2]=L;return 0}catch(H){if("undefined"==typeof U||"ErrnoError"!==H.name)throw H;return H.Ob}},ra:Yb,N:Zb,ga:$b,ca:ac,Y:bc,la:cc,G:dc,h:ec,oa:fc,ja:gc,ea:hc,fa:ic,k:jc,v:kc,pa:lc,g:mc,qa:nc,da:oc,ha:pc,ia:qc,na:rc,c:sc,ka:tc,ma:uc,aa:vc,V:wc,$:xc,ba:yc,S:zc,U:Ac,Z:Bc,X:Cc,R:Dc,Q:Ec,T:Fc,_:Gc,O:Hc,W:Ic,P:Jc},V=function(){function a(c){V=c.exports;V=Oc();ma=V.sa;ra();ta.unshift(V.ta);C--;f.monitorRunDependencies&&f.monitorRunDependencies(C);0==C&&(null!==xa&&
|
||||
(clearInterval(xa),xa=null),ya&&(c=ya,ya=null,c()));return V}var b={a:kd};C++;f.monitorRunDependencies&&f.monitorRunDependencies(C);if(f.instantiateWasm)try{return f.instantiateWasm(b,a)}catch(c){t(`Module.instantiateWasm callback failed with error: ${c}`),ba(c)}Fa(b,function(c){a(c.instance)}).catch(ba);return{}}();f._sqlite3_vfs_find=a=>(f._sqlite3_vfs_find=V.ua)(a);f._sqlite3_malloc=a=>(f._sqlite3_malloc=V.va)(a);f._sqlite3_free=a=>(f._sqlite3_free=V.wa)(a);
|
||||
f._sqlite3_prepare_v2=(a,b,c,d,e)=>(f._sqlite3_prepare_v2=V.xa)(a,b,c,d,e);f._sqlite3_step=a=>(f._sqlite3_step=V.ya)(a);f._sqlite3_column_int64=(a,b)=>(f._sqlite3_column_int64=V.za)(a,b);f._sqlite3_column_int=(a,b)=>(f._sqlite3_column_int=V.Aa)(a,b);f._sqlite3_finalize=a=>(f._sqlite3_finalize=V.Ba)(a);f._sqlite3_reset=a=>(f._sqlite3_reset=V.Ca)(a);f._sqlite3_clear_bindings=a=>(f._sqlite3_clear_bindings=V.Da)(a);f._sqlite3_value_blob=a=>(f._sqlite3_value_blob=V.Ea)(a);
|
||||
f._sqlite3_value_text=a=>(f._sqlite3_value_text=V.Fa)(a);f._sqlite3_value_bytes=a=>(f._sqlite3_value_bytes=V.Ga)(a);f._sqlite3_value_double=a=>(f._sqlite3_value_double=V.Ha)(a);f._sqlite3_value_int=a=>(f._sqlite3_value_int=V.Ia)(a);f._sqlite3_value_int64=a=>(f._sqlite3_value_int64=V.Ja)(a);f._sqlite3_value_type=a=>(f._sqlite3_value_type=V.Ka)(a);f._sqlite3_result_blob=(a,b,c,d)=>(f._sqlite3_result_blob=V.La)(a,b,c,d);f._sqlite3_result_double=(a,b)=>(f._sqlite3_result_double=V.Ma)(a,b);
|
||||
f._sqlite3_result_error=(a,b,c)=>(f._sqlite3_result_error=V.Na)(a,b,c);f._sqlite3_result_int=(a,b)=>(f._sqlite3_result_int=V.Oa)(a,b);f._sqlite3_result_int64=(a,b,c)=>(f._sqlite3_result_int64=V.Pa)(a,b,c);f._sqlite3_result_null=a=>(f._sqlite3_result_null=V.Qa)(a);f._sqlite3_result_text=(a,b,c,d)=>(f._sqlite3_result_text=V.Ra)(a,b,c,d);f._sqlite3_column_count=a=>(f._sqlite3_column_count=V.Sa)(a);f._sqlite3_data_count=a=>(f._sqlite3_data_count=V.Ta)(a);
|
||||
f._sqlite3_column_blob=(a,b)=>(f._sqlite3_column_blob=V.Ua)(a,b);f._sqlite3_column_bytes=(a,b)=>(f._sqlite3_column_bytes=V.Va)(a,b);f._sqlite3_column_double=(a,b)=>(f._sqlite3_column_double=V.Wa)(a,b);f._sqlite3_column_text=(a,b)=>(f._sqlite3_column_text=V.Xa)(a,b);f._sqlite3_column_type=(a,b)=>(f._sqlite3_column_type=V.Ya)(a,b);f._sqlite3_column_name=(a,b)=>(f._sqlite3_column_name=V.Za)(a,b);f._sqlite3_bind_blob=(a,b,c,d,e)=>(f._sqlite3_bind_blob=V._a)(a,b,c,d,e);
|
||||
f._sqlite3_bind_double=(a,b,c)=>(f._sqlite3_bind_double=V.$a)(a,b,c);f._sqlite3_bind_int=(a,b,c)=>(f._sqlite3_bind_int=V.ab)(a,b,c);f._sqlite3_bind_int64=(a,b,c,d)=>(f._sqlite3_bind_int64=V.bb)(a,b,c,d);f._sqlite3_bind_null=(a,b)=>(f._sqlite3_bind_null=V.cb)(a,b);f._sqlite3_bind_text=(a,b,c,d,e)=>(f._sqlite3_bind_text=V.db)(a,b,c,d,e);f._sqlite3_bind_parameter_count=a=>(f._sqlite3_bind_parameter_count=V.eb)(a);f._sqlite3_bind_parameter_name=(a,b)=>(f._sqlite3_bind_parameter_name=V.fb)(a,b);
|
||||
f._sqlite3_sql=a=>(f._sqlite3_sql=V.gb)(a);f._sqlite3_exec=(a,b,c,d,e)=>(f._sqlite3_exec=V.hb)(a,b,c,d,e);f._sqlite3_errmsg=a=>(f._sqlite3_errmsg=V.ib)(a);f._sqlite3_declare_vtab=(a,b)=>(f._sqlite3_declare_vtab=V.jb)(a,b);f._sqlite3_libversion=()=>(f._sqlite3_libversion=V.kb)();f._sqlite3_libversion_number=()=>(f._sqlite3_libversion_number=V.lb)();f._sqlite3_changes=a=>(f._sqlite3_changes=V.mb)(a);f._sqlite3_close=a=>(f._sqlite3_close=V.nb)(a);
|
||||
f._sqlite3_limit=(a,b,c)=>(f._sqlite3_limit=V.ob)(a,b,c);f._sqlite3_open_v2=(a,b,c,d)=>(f._sqlite3_open_v2=V.pb)(a,b,c,d);f._sqlite3_get_autocommit=a=>(f._sqlite3_get_autocommit=V.qb)(a);var jd=()=>(jd=V.rb)(),Tb=f._malloc=a=>(Tb=f._malloc=V.sb)(a),cd=f._free=a=>(cd=f._free=V.tb)(a);f._RegisterExtensionFunctions=a=>(f._RegisterExtensionFunctions=V.ub)(a);f._set_authorizer=a=>(f._set_authorizer=V.vb)(a);f._create_function=(a,b,c,d,e,h)=>(f._create_function=V.wb)(a,b,c,d,e,h);
|
||||
f._create_module=(a,b,c,d)=>(f._create_module=V.xb)(a,b,c,d);f._progress_handler=(a,b)=>(f._progress_handler=V.yb)(a,b);f._register_vfs=(a,b,c,d)=>(f._register_vfs=V.zb)(a,b,c,d);f._getSqliteFree=()=>(f._getSqliteFree=V.Ab)();var ld=f._main=(a,b)=>(ld=f._main=V.Bb)(a,b),db=(a,b)=>(db=V.Db)(a,b),md=()=>(md=V.Eb)(),hd=()=>(hd=V.Fb)(),fd=a=>(fd=V.Gb)(a),gd=a=>(gd=V.Hb)(a),ad=a=>(ad=V.Ib)(a),Qc=()=>(Qc=V.Jb)(),$c=a=>($c=V.Kb)(a),bd=()=>(bd=V.Lb)();f.getTempRet0=md;f.ccall=Z;
|
||||
f.cwrap=(a,b,c,d)=>{var e=!c||c.every(h=>"number"===h||"boolean"===h);return"string"!==b&&e&&!d?f["_"+a]:function(){return Z(a,b,c,arguments,d)}};f.setValue=J;f.getValue=I;f.UTF8ToString=(a,b)=>a?K(y,a,b):"";f.stringToUTF8=(a,b,c)=>Sa(a,y,b,c);f.lengthBytesUTF8=Ra;var nd;ya=function od(){nd||pd();nd||(ya=od)};
|
||||
function pd(){function a(){if(!nd&&(nd=!0,f.calledRun=!0,!v)){f.noFSInit||Jb||(Jb=!0,Ib(),f.stdin=f.stdin,f.stdout=f.stdout,f.stderr=f.stderr,f.stdin?Kb("stdin",f.stdin):zb("/dev/tty","/dev/stdin"),f.stdout?Kb("stdout",null,f.stdout):zb("/dev/tty","/dev/stdout"),f.stderr?Kb("stderr",null,f.stderr):zb("/dev/tty1","/dev/stderr"),Fb("/dev/stdin",0),Fb("/dev/stdout",1),Fb("/dev/stderr",1));jb=!1;Ha(ta);Ha(ua);aa(f);if(f.onRuntimeInitialized)f.onRuntimeInitialized();if(qd){var b=ld;try{var c=b(0,0);na=
|
||||
c;Lc(c)}catch(d){Mc(d)}}if(f.postRun)for("function"==typeof f.postRun&&(f.postRun=[f.postRun]);f.postRun.length;)b=f.postRun.shift(),va.unshift(b);Ha(va)}}if(!(0<C)){if(f.preRun)for("function"==typeof f.preRun&&(f.preRun=[f.preRun]);f.preRun.length;)wa();Ha(sa);0<C||(f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("")},1);a()},1)):a())}}if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);0<f.preInit.length;)f.preInit.pop()();
|
||||
var qd=!0;f.noInitialRun&&(qd=!1);pd();
|
||||
var d=moduleArg,aa,ba;d.ready=new Promise((a,b)=>{aa=a;ba=b});var ca=Object.assign({},d),da="./this.program",ea=(a,b)=>{throw b;},fa="object"==typeof window,ha="function"==typeof importScripts,g="",ia;
|
||||
if(fa||ha)ha?g=self.location.href:"undefined"!=typeof document&&document.currentScript&&(g=document.currentScript.src),_scriptDir&&(g=_scriptDir),0!==g.indexOf("blob:")?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",ha&&(ia=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ja=d.print||console.log.bind(console),r=d.printErr||console.error.bind(console);Object.assign(d,ca);ca=null;d.thisProgram&&(da=d.thisProgram);
|
||||
d.quit&&(ea=d.quit);var ka;d.wasmBinary&&(ka=d.wasmBinary);"object"!=typeof WebAssembly&&u("no native wasm support detected");var ma,na=!1,oa,v,w,x,pa,z,A,qa,ra;function sa(){var a=ma.buffer;d.HEAP8=v=new Int8Array(a);d.HEAP16=x=new Int16Array(a);d.HEAPU8=w=new Uint8Array(a);d.HEAPU16=pa=new Uint16Array(a);d.HEAP32=z=new Int32Array(a);d.HEAPU32=A=new Uint32Array(a);d.HEAPF32=qa=new Float32Array(a);d.HEAPF64=ra=new Float64Array(a)}var ta=[],ua=[],va=[],wa=[];
|
||||
function xa(){var a=d.preRun.shift();ta.unshift(a)}var ya=0,za=null,Aa=null;function u(a){if(d.onAbort)d.onAbort(a);a="Aborted("+a+")";r(a);na=!0;oa=1;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");ba(a);throw a;}var Ba=a=>a.startsWith("data:application/octet-stream;base64,"),Ca;if(d.locateFile){if(Ca="wa-sqlite-async.wasm",!Ba(Ca)){var Da=Ca;Ca=d.locateFile?d.locateFile(Da,g):g+Da}}else Ca=(new URL("wa-sqlite-async.wasm",import.meta.url)).href;
|
||||
function Ea(a){if(a==Ca&&ka)return new Uint8Array(ka);if(ia)return ia(a);throw"both async and sync fetching of the wasm failed";}function Fa(a){return ka||!fa&&!ha||"function"!=typeof fetch?Promise.resolve().then(()=>Ea(a)):fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw"failed to load wasm binary file at '"+a+"'";return b.arrayBuffer()}).catch(()=>Ea(a))}
|
||||
function Ga(a,b,c){return Fa(a).then(e=>WebAssembly.instantiate(e,b)).then(e=>e).then(c,e=>{r(`failed to asynchronously prepare wasm: ${e}`);u(e)})}function Ha(a,b){var c=Ca;return ka||"function"!=typeof WebAssembly.instantiateStreaming||Ba(c)||"function"!=typeof fetch?Ga(c,a,b):fetch(c,{credentials:"same-origin"}).then(e=>WebAssembly.instantiateStreaming(e,a).then(b,function(f){r(`wasm streaming compile failed: ${f}`);r("falling back to ArrayBuffer instantiation");return Ga(c,a,b)}))}var C,D;
|
||||
function Ia(a){this.name="ExitStatus";this.message=`Program terminated with exit(${a})`;this.status=a}var Ja=a=>{for(;0<a.length;)a.shift()(d)};function F(a,b="i8"){b.endsWith("*")&&(b="*");switch(b){case "i1":return v[a>>0];case "i8":return v[a>>0];case "i16":return x[a>>1];case "i32":return z[a>>2];case "i64":u("to do getValue(i64) use WASM_BIGINT");case "float":return qa[a>>2];case "double":return ra[a>>3];case "*":return A[a>>2];default:u(`invalid type for getValue: ${b}`)}}
|
||||
var Ka=d.noExitRuntime||!0;function H(a,b,c="i8"){c.endsWith("*")&&(c="*");switch(c){case "i1":v[a>>0]=b;break;case "i8":v[a>>0]=b;break;case "i16":x[a>>1]=b;break;case "i32":z[a>>2]=b;break;case "i64":u("to do setValue(i64) use WASM_BIGINT");case "float":qa[a>>2]=b;break;case "double":ra[a>>3]=b;break;case "*":A[a>>2]=b;break;default:u(`invalid type for setValue: ${c}`)}}
|
||||
var La="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,J=(a,b,c)=>{var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.buffer&&La)return La.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var h=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|h);else{var k=a[b++]&63;f=224==(f&240)?(f&15)<<12|h<<6|k:(f&7)<<18|h<<12|k<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e},
|
||||
Ma=(a,b)=>{for(var c=0,e=a.length-1;0<=e;e--){var f=a[e];"."===f?a.splice(e,1):".."===f?(a.splice(e,1),c++):c&&(a.splice(e,1),c--)}if(b)for(;c;c--)a.unshift("..");return a},K=a=>{var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=Ma(a.split("/").filter(e=>!!e),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},Na=a=>{var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b},Oa=a=>{if("/"===
|
||||
a)return"/";a=K(a);a=a.replace(/\/$/,"");var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)},Pa=()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return a=>crypto.getRandomValues(a);u("initRandomDevice")},Qa=a=>(Qa=Pa())(a);
|
||||
function Ra(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!=typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=Ma(a.split("/").filter(e=>!!e),!b).join("/");return(b?"/":"")+a||"."}
|
||||
var Sa=[],Ta=a=>{for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);127>=e?b++:2047>=e?b+=2:55296<=e&&57343>=e?(b+=4,++c):b+=3}return b},Ua=(a,b,c,e)=>{if(!(0<e))return 0;var f=c;e=c+e-1;for(var h=0;h<a.length;++h){var k=a.charCodeAt(h);if(55296<=k&&57343>=k){var n=a.charCodeAt(++h);k=65536+((k&1023)<<10)|n&1023}if(127>=k){if(c>=e)break;b[c++]=k}else{if(2047>=k){if(c+1>=e)break;b[c++]=192|k>>6}else{if(65535>=k){if(c+2>=e)break;b[c++]=224|k>>12}else{if(c+3>=e)break;b[c++]=240|k>>18;b[c++]=128|k>>
|
||||
12&63}b[c++]=128|k>>6&63}b[c++]=128|k&63}}b[c]=0;return c-f};function Va(a,b,c){c=Array(0<c?c:Ta(a)+1);a=Ua(a,c,0,c.length);b&&(c.length=a);return c}var Wa=[];function Xa(a,b){Wa[a]={input:[],Qf:[],ag:b};Ya(a,Za)}
|
||||
var Za={open(a){var b=Wa[a.node.dg];if(!b)throw new M(43);a.Rf=b;a.seekable=!1},close(a){a.Rf.ag.gg(a.Rf)},gg(a){a.Rf.ag.gg(a.Rf)},read(a,b,c,e){if(!a.Rf||!a.Rf.ag.vg)throw new M(60);for(var f=0,h=0;h<e;h++){try{var k=a.Rf.ag.vg(a.Rf)}catch(n){throw new M(29);}if(void 0===k&&0===f)throw new M(6);if(null===k||void 0===k)break;f++;b[c+h]=k}f&&(a.node.timestamp=Date.now());return f},write(a,b,c,e){if(!a.Rf||!a.Rf.ag.pg)throw new M(60);try{for(var f=0;f<e;f++)a.Rf.ag.pg(a.Rf,b[c+f])}catch(h){throw new M(29);
|
||||
}e&&(a.node.timestamp=Date.now());return f}},$a={vg(){a:{if(!Sa.length){var a=null;"undefined"!=typeof window&&"function"==typeof window.prompt?(a=window.prompt("Input: "),null!==a&&(a+="\n")):"function"==typeof readline&&(a=readline(),null!==a&&(a+="\n"));if(!a){a=null;break a}Sa=Va(a,!0)}a=Sa.shift()}return a},pg(a,b){null===b||10===b?(ja(J(a.Qf,0)),a.Qf=[]):0!=b&&a.Qf.push(b)},gg(a){a.Qf&&0<a.Qf.length&&(ja(J(a.Qf,0)),a.Qf=[])},Wg(){return{Sg:25856,Ug:5,Rg:191,Tg:35387,Qg:[3,28,127,21,4,0,1,0,
|
||||
17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},Xg(){return 0},Yg(){return[24,80]}},ab={pg(a,b){null===b||10===b?(r(J(a.Qf,0)),a.Qf=[]):0!=b&&a.Qf.push(b)},gg(a){a.Qf&&0<a.Qf.length&&(r(J(a.Qf,0)),a.Qf=[])}};function bb(a,b){var c=a.Mf?a.Mf.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Mf,a.Mf=new Uint8Array(b),0<a.Of&&a.Mf.set(c.subarray(0,a.Of),0))}
|
||||
var N={Uf:null,Tf(){return N.createNode(null,"/",16895,0)},createNode(a,b,c,e){if(24576===(c&61440)||4096===(c&61440))throw new M(63);N.Uf||(N.Uf={dir:{node:{Sf:N.Kf.Sf,Pf:N.Kf.Pf,bg:N.Kf.bg,hg:N.Kf.hg,zg:N.Kf.zg,mg:N.Kf.mg,kg:N.Kf.kg,yg:N.Kf.yg,lg:N.Kf.lg},stream:{Yf:N.Lf.Yf}},file:{node:{Sf:N.Kf.Sf,Pf:N.Kf.Pf},stream:{Yf:N.Lf.Yf,read:N.Lf.read,write:N.Lf.write,sg:N.Lf.sg,ig:N.Lf.ig,jg:N.Lf.jg}},link:{node:{Sf:N.Kf.Sf,Pf:N.Kf.Pf,eg:N.Kf.eg},stream:{}},tg:{node:{Sf:N.Kf.Sf,Pf:N.Kf.Pf},stream:cb}});
|
||||
c=db(a,b,c,e);O(c.mode)?(c.Kf=N.Uf.dir.node,c.Lf=N.Uf.dir.stream,c.Mf={}):32768===(c.mode&61440)?(c.Kf=N.Uf.file.node,c.Lf=N.Uf.file.stream,c.Of=0,c.Mf=null):40960===(c.mode&61440)?(c.Kf=N.Uf.link.node,c.Lf=N.Uf.link.stream):8192===(c.mode&61440)&&(c.Kf=N.Uf.tg.node,c.Lf=N.Uf.tg.stream);c.timestamp=Date.now();a&&(a.Mf[b]=c,a.timestamp=c.timestamp);return c},Vg(a){return a.Mf?a.Mf.subarray?a.Mf.subarray(0,a.Of):new Uint8Array(a.Mf):new Uint8Array(0)},Kf:{Sf(a){var b={};b.Fg=8192===(a.mode&61440)?a.id:
|
||||
1;b.wg=a.id;b.mode=a.mode;b.Lg=1;b.uid=0;b.Ig=0;b.dg=a.dg;O(a.mode)?b.size=4096:32768===(a.mode&61440)?b.size=a.Of:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.Bg=new Date(a.timestamp);b.Kg=new Date(a.timestamp);b.Eg=new Date(a.timestamp);b.Cg=4096;b.Dg=Math.ceil(b.size/b.Cg);return b},Pf(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=b.timestamp);if(void 0!==b.size&&(b=b.size,a.Of!=b))if(0==b)a.Mf=null,a.Of=0;else{var c=a.Mf;a.Mf=new Uint8Array(b);c&&a.Mf.set(c.subarray(0,
|
||||
Math.min(b,a.Of)));a.Of=b}},bg(){throw eb[44];},hg(a,b,c,e){return N.createNode(a,b,c,e)},zg(a,b,c){if(O(a.mode)){try{var e=fb(b,c)}catch(h){}if(e)for(var f in e.Mf)throw new M(55);}delete a.parent.Mf[a.name];a.parent.timestamp=Date.now();a.name=c;b.Mf[c]=a;b.timestamp=a.parent.timestamp;a.parent=b},mg(a,b){delete a.Mf[b];a.timestamp=Date.now()},kg(a,b){var c=fb(a,b),e;for(e in c.Mf)throw new M(55);delete a.Mf[b];a.timestamp=Date.now()},yg(a){var b=[".",".."],c;for(c in a.Mf)a.Mf.hasOwnProperty(c)&&
|
||||
b.push(c);return b},lg(a,b,c){a=N.createNode(a,b,41471,0);a.link=c;return a},eg(a){if(40960!==(a.mode&61440))throw new M(28);return a.link}},Lf:{read(a,b,c,e,f){var h=a.node.Mf;if(f>=a.node.Of)return 0;a=Math.min(a.node.Of-f,e);if(8<a&&h.subarray)b.set(h.subarray(f,f+a),c);else for(e=0;e<a;e++)b[c+e]=h[f+e];return a},write(a,b,c,e,f,h){b.buffer===v.buffer&&(h=!1);if(!e)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Mf||a.Mf.subarray)){if(h)return a.Mf=b.subarray(c,c+e),a.Of=e;if(0===
|
||||
a.Of&&0===f)return a.Mf=b.slice(c,c+e),a.Of=e;if(f+e<=a.Of)return a.Mf.set(b.subarray(c,c+e),f),e}bb(a,f+e);if(a.Mf.subarray&&b.subarray)a.Mf.set(b.subarray(c,c+e),f);else for(h=0;h<e;h++)a.Mf[f+h]=b[c+h];a.Of=Math.max(a.Of,f+e);return e},Yf(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.Of);if(0>b)throw new M(28);return b},sg(a,b,c){bb(a.node,b+c);a.node.Of=Math.max(a.node.Of,b+c)},ig(a,b,c,e,f){if(32768!==(a.node.mode&61440))throw new M(43);a=a.node.Mf;if(f&2||a.buffer!==
|
||||
v.buffer){if(0<c||c+b<a.length)a.subarray?a=a.subarray(c,c+b):a=Array.prototype.slice.call(a,c,c+b);c=!0;b=65536*Math.ceil(b/65536);(f=gb(65536,b))?(w.fill(0,f,f+b),b=f):b=0;if(!b)throw new M(48);v.set(a,b)}else c=!1,b=a.byteOffset;return{Mg:b,Ag:c}},jg(a,b,c,e){N.Lf.write(a,b,0,e,c,!1);return 0}}},hb=(a,b)=>{var c=0;a&&(c|=365);b&&(c|=146);return c},ib=null,jb={},kb=[],lb=1,P=null,mb=!0,M=null,eb={};
|
||||
function Q(a,b={}){a=Ra(a);if(!a)return{path:"",node:null};b=Object.assign({ug:!0,qg:0},b);if(8<b.qg)throw new M(32);a=a.split("/").filter(k=>!!k);for(var c=ib,e="/",f=0;f<a.length;f++){var h=f===a.length-1;if(h&&b.parent)break;c=fb(c,a[f]);e=K(e+"/"+a[f]);c.Zf&&(!h||h&&b.ug)&&(c=c.Zf.root);if(!h||b.Xf)for(h=0;40960===(c.mode&61440);)if(c=nb(e),e=Ra(Na(e),c),c=Q(e,{qg:b.qg+1}).node,40<h++)throw new M(32);}return{path:e,node:c}}
|
||||
function ob(a){for(var b;;){if(a===a.parent)return a=a.Tf.xg,b?"/"!==a[a.length-1]?`${a}/${b}`:a+b:a;b=b?`${a.name}/${b}`:a.name;a=a.parent}}function pb(a,b){for(var c=0,e=0;e<b.length;e++)c=(c<<5)-c+b.charCodeAt(e)|0;return(a+c>>>0)%P.length}function qb(a){var b=pb(a.parent.id,a.name);if(P[b]===a)P[b]=a.$f;else for(b=P[b];b;){if(b.$f===a){b.$f=a.$f;break}b=b.$f}}
|
||||
function fb(a,b){var c;if(c=(c=rb(a,"x"))?c:a.Kf.bg?0:2)throw new M(c,a);for(c=P[pb(a.id,b)];c;c=c.$f){var e=c.name;if(c.parent.id===a.id&&e===b)return c}return a.Kf.bg(a,b)}function db(a,b,c,e){a=new sb(a,b,c,e);b=pb(a.parent.id,a.name);a.$f=P[b];return P[b]=a}function O(a){return 16384===(a&61440)}function tb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}
|
||||
function rb(a,b){if(mb)return 0;if(!b.includes("r")||a.mode&292){if(b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73))return 2}else return 2;return 0}function ub(a,b){try{return fb(a,b),20}catch(c){}return rb(a,"wx")}function vb(a,b,c){try{var e=fb(a,b)}catch(f){return f.Nf}if(a=rb(a,"wx"))return a;if(c){if(!O(e.mode))return 54;if(e===e.parent||"/"===ob(e))return 10}else if(O(e.mode))return 31;return 0}function wb(){for(var a=0;4096>=a;a++)if(!kb[a])return a;throw new M(33);}
|
||||
function R(a){a=kb[a];if(!a)throw new M(8);return a}function xb(a,b=-1){yb||(yb=function(){this.fg={}},yb.prototype={},Object.defineProperties(yb.prototype,{object:{get(){return this.node},set(c){this.node=c}},flags:{get(){return this.fg.flags},set(c){this.fg.flags=c}},position:{get(){return this.fg.position},set(c){this.fg.position=c}}}));a=Object.assign(new yb,a);-1==b&&(b=wb());a.Vf=b;return kb[b]=a}var cb={open(a){a.Lf=jb[a.node.dg].Lf;a.Lf.open&&a.Lf.open(a)},Yf(){throw new M(70);}};
|
||||
function Ya(a,b){jb[a]={Lf:b}}function zb(a,b){var c="/"===b,e=!b;if(c&&ib)throw new M(10);if(!c&&!e){var f=Q(b,{ug:!1});b=f.path;f=f.node;if(f.Zf)throw new M(10);if(!O(f.mode))throw new M(54);}b={type:a,$g:{},xg:b,Jg:[]};a=a.Tf(b);a.Tf=b;b.root=a;c?ib=a:f&&(f.Zf=b,f.Tf&&f.Tf.Jg.push(b))}function Ab(a,b,c){var e=Q(a,{parent:!0}).node;a=Oa(a);if(!a||"."===a||".."===a)throw new M(28);var f=ub(e,a);if(f)throw new M(f);if(!e.Kf.hg)throw new M(63);return e.Kf.hg(e,a,b,c)}
|
||||
function S(a,b){return Ab(a,(void 0!==b?b:511)&1023|16384,0)}function Bb(a,b,c){"undefined"==typeof c&&(c=b,b=438);Ab(a,b|8192,c)}function Cb(a,b){if(!Ra(a))throw new M(44);var c=Q(b,{parent:!0}).node;if(!c)throw new M(44);b=Oa(b);var e=ub(c,b);if(e)throw new M(e);if(!c.Kf.lg)throw new M(63);c.Kf.lg(c,b,a)}function Db(a){var b=Q(a,{parent:!0}).node;a=Oa(a);var c=fb(b,a),e=vb(b,a,!0);if(e)throw new M(e);if(!b.Kf.kg)throw new M(63);if(c.Zf)throw new M(10);b.Kf.kg(b,a);qb(c)}
|
||||
function nb(a){a=Q(a).node;if(!a)throw new M(44);if(!a.Kf.eg)throw new M(28);return Ra(ob(a.parent),a.Kf.eg(a))}function Eb(a,b){a=Q(a,{Xf:!b}).node;if(!a)throw new M(44);if(!a.Kf.Sf)throw new M(63);return a.Kf.Sf(a)}function Fb(a){return Eb(a,!0)}function Gb(a,b){a="string"==typeof a?Q(a,{Xf:!0}).node:a;if(!a.Kf.Pf)throw new M(63);a.Kf.Pf(a,{mode:b&4095|a.mode&-4096,timestamp:Date.now()})}
|
||||
function Hb(a,b){if(0>b)throw new M(28);a="string"==typeof a?Q(a,{Xf:!0}).node:a;if(!a.Kf.Pf)throw new M(63);if(O(a.mode))throw new M(31);if(32768!==(a.mode&61440))throw new M(28);var c=rb(a,"w");if(c)throw new M(c);a.Kf.Pf(a,{size:b,timestamp:Date.now()})}
|
||||
function Ib(a,b,c){if(""===a)throw new M(44);if("string"==typeof b){var e={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[b];if("undefined"==typeof e)throw Error(`Unknown file open mode: ${b}`);b=e}c=b&64?("undefined"==typeof c?438:c)&4095|32768:0;if("object"==typeof a)var f=a;else{a=K(a);try{f=Q(a,{Xf:!(b&131072)}).node}catch(h){}}e=!1;if(b&64)if(f){if(b&128)throw new M(20);}else f=Ab(a,c,0),e=!0;if(!f)throw new M(44);8192===(f.mode&61440)&&(b&=-513);if(b&65536&&!O(f.mode))throw new M(54);if(!e&&(c=
|
||||
f?40960===(f.mode&61440)?32:O(f.mode)&&("r"!==tb(b)||b&512)?31:rb(f,tb(b)):44))throw new M(c);b&512&&!e&&Hb(f,0);b&=-131713;f=xb({node:f,path:ob(f),flags:b,seekable:!0,position:0,Lf:f.Lf,Pg:[],error:!1});f.Lf.open&&f.Lf.open(f);!d.logReadFiles||b&1||(Jb||(Jb={}),a in Jb||(Jb[a]=1));return f}function Kb(a,b,c){if(null===a.Vf)throw new M(8);if(!a.seekable||!a.Lf.Yf)throw new M(70);if(0!=c&&1!=c&&2!=c)throw new M(28);a.position=a.Lf.Yf(a,b,c);a.Pg=[]}
|
||||
function Lb(){M||(M=function(a,b){this.name="ErrnoError";this.node=b;this.Ng=function(c){this.Nf=c};this.Ng(a);this.message="FS error"},M.prototype=Error(),M.prototype.constructor=M,[44].forEach(a=>{eb[a]=new M(a);eb[a].stack="<generic error, no stack>"}))}var Mb;
|
||||
function Nb(a,b,c){a=K("/dev/"+a);var e=hb(!!b,!!c);Ob||(Ob=64);var f=Ob++<<8|0;Ya(f,{open(h){h.seekable=!1},close(){c&&c.buffer&&c.buffer.length&&c(10)},read(h,k,n,l){for(var m=0,q=0;q<l;q++){try{var p=b()}catch(t){throw new M(29);}if(void 0===p&&0===m)throw new M(6);if(null===p||void 0===p)break;m++;k[n+q]=p}m&&(h.node.timestamp=Date.now());return m},write(h,k,n,l){for(var m=0;m<l;m++)try{c(k[n+m])}catch(q){throw new M(29);}l&&(h.node.timestamp=Date.now());return m}});Bb(a,e,f)}var Ob,T={},yb,Jb;
|
||||
function Pb(a,b,c){if("/"===b.charAt(0))return b;a=-100===a?"/":R(a).path;if(0==b.length){if(!c)throw new M(44);return a}return K(a+"/"+b)}
|
||||
function Qb(a,b,c){try{var e=a(b)}catch(h){if(h&&h.node&&K(b)!==K(ob(h.node)))return-54;throw h;}z[c>>2]=e.Fg;z[c+4>>2]=e.mode;A[c+8>>2]=e.Lg;z[c+12>>2]=e.uid;z[c+16>>2]=e.Ig;z[c+20>>2]=e.dg;D=[e.size>>>0,(C=e.size,1<=+Math.abs(C)?0<C?+Math.floor(C/4294967296)>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)];z[c+24>>2]=D[0];z[c+28>>2]=D[1];z[c+32>>2]=4096;z[c+36>>2]=e.Dg;a=e.Bg.getTime();b=e.Kg.getTime();var f=e.Eg.getTime();D=[Math.floor(a/1E3)>>>0,(C=Math.floor(a/1E3),1<=+Math.abs(C)?0<C?+Math.floor(C/
|
||||
4294967296)>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)];z[c+40>>2]=D[0];z[c+44>>2]=D[1];A[c+48>>2]=a%1E3*1E3;D=[Math.floor(b/1E3)>>>0,(C=Math.floor(b/1E3),1<=+Math.abs(C)?0<C?+Math.floor(C/4294967296)>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)];z[c+56>>2]=D[0];z[c+60>>2]=D[1];A[c+64>>2]=b%1E3*1E3;D=[Math.floor(f/1E3)>>>0,(C=Math.floor(f/1E3),1<=+Math.abs(C)?0<C?+Math.floor(C/4294967296)>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)];z[c+72>>2]=D[0];z[c+76>>2]=D[1];A[c+80>>2]=
|
||||
f%1E3*1E3;D=[e.wg>>>0,(C=e.wg,1<=+Math.abs(C)?0<C?+Math.floor(C/4294967296)>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)];z[c+88>>2]=D[0];z[c+92>>2]=D[1];return 0}var Rb=void 0;function Sb(){var a=z[+Rb>>2];Rb+=4;return a}
|
||||
var Tb=(a,b)=>b+2097152>>>0<4194305-!!a?(a>>>0)+4294967296*b:NaN,Ub=[0,31,60,91,121,152,182,213,244,274,305,335],Vb=[0,31,59,90,120,151,181,212,243,273,304,334],Xb=a=>{var b=Ta(a)+1,c=Wb(b);c&&Ua(a,w,c,b);return c},Yb={},$b=()=>{if(!Zb){var a={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",_:da||"./this.program"},b;for(b in Yb)void 0===Yb[b]?delete a[b]:a[b]=Yb[b];
|
||||
var c=[];for(b in a)c.push(`${b}=${a[b]}`);Zb=c}return Zb},Zb;function ac(){}function bc(){}function cc(){}function dc(){}function ec(){}function fc(){}function gc(){}function hc(){}function ic(){}function jc(){}function kc(){}function lc(){}function mc(){}function nc(){}function oc(){}function pc(){}function qc(){}function rc(){}function sc(){}function tc(){}function uc(){}function vc(){}function wc(){}function xc(){}function yc(){}function zc(){}function Ac(){}function Bc(){}function Cc(){}
|
||||
function Dc(){}function Ec(){}function Fc(){}function Gc(){}function Hc(){}function Ic(){}function Jc(){}function Kc(){}function Lc(){}function Mc(){}var Nc=0,Oc=a=>{oa=a;if(!(Ka||0<Nc)){if(d.onExit)d.onExit(a);na=!0}ea(a,new Ia(a))},Pc=a=>{a instanceof Ia||"unwind"==a||ea(1,a)},Qc=a=>{try{a()}catch(b){u(b)}};
|
||||
function Rc(){var a=U,b={},c;for(c in a)(function(e){var f=a[e];b[e]="function"==typeof f?function(){Sc.push(e);try{return f.apply(null,arguments)}finally{na||(Sc.pop()===e||u(),V&&1===W&&0===Sc.length&&(W=0,Qc(Tc),"undefined"!=typeof Fibers&&Fibers.ah()))}}:f})(c);return b}var W=0,V=null,Uc=0,Sc=[],Vc={},Wc={},Xc=0,Yc=null,Zc=[];function $c(){return new Promise((a,b)=>{Yc={resolve:a,reject:b}})}
|
||||
function ad(){var a=Wb(16396),b=a+12;A[a>>2]=b;A[a+4>>2]=b+16384;b=Sc[0];var c=Vc[b];void 0===c&&(c=Xc++,Vc[b]=c,Wc[c]=b);z[a+8>>2]=c;return a}
|
||||
function bd(a){if(!na){if(0===W){var b=!1,c=!1;a((e=0)=>{if(!na&&(Uc=e,b=!0,c)){W=2;Qc(()=>cd(V));"undefined"!=typeof Browser&&Browser.og.Hg&&Browser.og.resume();e=!1;try{var f=(0,U[Wc[z[V+8>>2]]])()}catch(n){f=n,e=!0}var h=!1;if(!V){var k=Yc;k&&(Yc=null,(e?k.reject:k.resolve)(f),h=!0)}if(e&&!h)throw f;}});c=!0;b||(W=1,V=ad(),"undefined"!=typeof Browser&&Browser.og.Hg&&Browser.og.pause(),Qc(()=>dd(V)))}else 2===W?(W=0,Qc(ed),fd(V),V=null,Zc.forEach(e=>{if(!na)try{if(e(),!(Ka||0<Nc))try{oa=e=oa,Oc(e)}catch(f){Pc(f)}}catch(f){Pc(f)}})):
|
||||
u(`invalid state: ${W}`);return Uc}}function gd(a){return bd(b=>{a().then(b)})}
|
||||
var hd={},jd=[],X,kd,ld=[],Z=(a,b,c,e,f)=>{function h(p){--Nc;0!==l&&md(l);return"string"===b?p?J(w,p):"":"boolean"===b?!!p:p}var k={string:p=>{var t=0;if(null!==p&&void 0!==p&&0!==p){t=Ta(p)+1;var y=nd(t);Ua(p,w,y,t);t=y}return t},array:p=>{var t=nd(p.length);v.set(p,t);return t}};a=d["_"+a];var n=[],l=0;if(e)for(var m=0;m<e.length;m++){var q=k[c[m]];q?(0===l&&(l=od()),n[m]=q(e[m])):n[m]=e[m]}c=V;e=a.apply(null,n);f=f&&f.async;Nc+=1;if(V!=c)return $c().then(h);e=h(e);return f?Promise.resolve(e):
|
||||
e},pd="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function sb(a,b,c,e){a||(a=this);this.parent=a;this.Tf=a.Tf;this.Zf=null;this.id=lb++;this.name=b;this.mode=c;this.Kf={};this.Lf={};this.dg=e}Object.defineProperties(sb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Lb();P=Array(4096);zb(N,"/");S("/tmp");S("/home");
|
||||
S("/home/web_user");(function(){S("/dev");Ya(259,{read:()=>0,write:(e,f,h,k)=>k});Bb("/dev/null",259);Xa(1280,$a);Xa(1536,ab);Bb("/dev/tty",1280);Bb("/dev/tty1",1536);var a=new Uint8Array(1024),b=0,c=()=>{0===b&&(b=Qa(a).byteLength);return a[--b]};Nb("random",c);Nb("urandom",c);S("/dev/shm");S("/dev/shm/tmp")})();
|
||||
(function(){S("/proc");var a=S("/proc/self");S("/proc/self/fd");zb({Tf(){var b=db(a,"fd",16895,73);b.Kf={bg(c,e){var f=R(+e);c={parent:null,Tf:{xg:"fake"},Kf:{eg:()=>f.path}};return c.parent=c}};return b}},"/proc/self/fd")})();
|
||||
(function(){const a=new Map;d.setAuthorizer=function(b,c,e){c?a.set(b,{f:c,rg:e}):a.delete(b);return Z("set_authorizer","number",["number"],[b])};ac=function(b,c,e,f,h,k){if(a.has(b)){const {f:n,rg:l}=a.get(b);return n(l,c,e?e?J(w,e):"":null,f?f?J(w,f):"":null,h?h?J(w,h):"":null,k?k?J(w,k):"":null)}return 0}})();
|
||||
(function(){const a=new Map,b=new Map;d.createFunction=function(c,e,f,h,k,n){const l=a.size;a.set(l,{f:n,Wf:k});return Z("create_function","number","number string number number number number".split(" "),[c,e,f,h,l,0])};d.createAggregate=function(c,e,f,h,k,n,l){const m=a.size;a.set(m,{step:n,Gg:l,Wf:k});return Z("create_function","number","number string number number number number".split(" "),[c,e,f,h,m,1])};d.getFunctionUserData=function(c){return b.get(c)};cc=function(c,e,f,h){c=a.get(c);b.set(e,
|
||||
c.Wf);c.f(e,new Uint32Array(w.buffer,h,f));b.delete(e)};ec=function(c,e,f,h){c=a.get(c);b.set(e,c.Wf);c.step(e,new Uint32Array(w.buffer,h,f));b.delete(e)};bc=function(c,e){c=a.get(c);b.set(e,c.Wf);c.Gg(e);b.delete(e)}})();(function(){const a=new Map;d.progressHandler=function(b,c,e,f){e?a.set(b,{f:e,rg:f}):a.delete(b);return Z("progress_handler",null,["number","number"],[b,c])};dc=function(b){if(a.has(b)){const {f:c,rg:e}=a.get(b);return c(e)}return 0}})();
|
||||
(function(){function a(l,m){const q=`get${l}`,p=`set${l}`;return new Proxy(new DataView(w.buffer,m,"Int32"===l?4:8),{get(t,y){if(y===q)return function(B,G){if(!G)throw Error("must be little endian");return t[y](B,G)};if(y===p)return function(B,G,E){if(!E)throw Error("must be little endian");return t[y](B,G,E)};if("string"===typeof y&&y.match(/^(get)|(set)/))throw Error("invalid type");return t[y]}})}const b="object"===typeof hd,c=new Map,e=new Map,f=new Map,h=b?new Set:null,k=b?new Set:null,n=new Map;
|
||||
vc=function(l,m,q,p){n.set(l?J(w,l):"",{size:m,cg:Array.from(new Uint32Array(w.buffer,p,q))})};d.createModule=function(l,m,q,p){b&&(q.handleAsync=gd);const t=c.size;c.set(t,{module:q,Wf:p});p=0;q.xCreate&&(p|=1);q.xConnect&&(p|=2);q.xBestIndex&&(p|=4);q.xDisconnect&&(p|=8);q.xDestroy&&(p|=16);q.xOpen&&(p|=32);q.xClose&&(p|=64);q.xFilter&&(p|=128);q.xNext&&(p|=256);q.xEof&&(p|=512);q.xColumn&&(p|=1024);q.xRowid&&(p|=2048);q.xUpdate&&(p|=4096);q.xBegin&&(p|=8192);q.xSync&&(p|=16384);q.xCommit&&(p|=
|
||||
32768);q.xRollback&&(p|=65536);q.xFindFunction&&(p|=131072);q.xRename&&(p|=262144);return Z("create_module","number",["number","string","number","number"],[l,m,t,p])};lc=function(l,m,q,p,t,y){m=c.get(m);e.set(t,m);if(b){h.delete(t);for(const B of h)e.delete(B)}p=Array.from(new Uint32Array(w.buffer,p,q)).map(B=>B?J(w,B):"");return m.module.xCreate(l,m.Wf,p,t,a("Int32",y))};kc=function(l,m,q,p,t,y){m=c.get(m);e.set(t,m);if(b){h.delete(t);for(const B of h)e.delete(B)}p=Array.from(new Uint32Array(w.buffer,
|
||||
p,q)).map(B=>B?J(w,B):"");return m.module.xConnect(l,m.Wf,p,t,a("Int32",y))};gc=function(l,m){var q=e.get(l),p=n.get("sqlite3_index_info").cg;const t={};t.nConstraint=F(m+p[0],"i32");t.aConstraint=[];var y=F(m+p[1],"*"),B=n.get("sqlite3_index_constraint").size;for(var G=0;G<t.nConstraint;++G){var E=t.aConstraint,L=E.push,I=y+G*B,la=n.get("sqlite3_index_constraint").cg,Y={};Y.iColumn=F(I+la[0],"i32");Y.op=F(I+la[1],"i8");Y.usable=!!F(I+la[2],"i8");L.call(E,Y)}t.nOrderBy=F(m+p[2],"i32");t.aOrderBy=
|
||||
[];y=F(m+p[3],"*");B=n.get("sqlite3_index_orderby").size;for(G=0;G<t.nOrderBy;++G)E=t.aOrderBy,L=E.push,I=y+G*B,la=n.get("sqlite3_index_orderby").cg,Y={},Y.iColumn=F(I+la[0],"i32"),Y.desc=!!F(I+la[1],"i8"),L.call(E,Y);t.aConstraintUsage=[];for(y=0;y<t.nConstraint;++y)t.aConstraintUsage.push({argvIndex:0,omit:!1});t.idxNum=F(m+p[5],"i32");t.idxStr=null;t.orderByConsumed=!!F(m+p[8],"i8");t.estimatedCost=F(m+p[9],"double");t.estimatedRows=F(m+p[10],"i32");t.idxFlags=F(m+p[11],"i32");t.colUsed=F(m+p[12],
|
||||
"i32");l=q.module.xBestIndex(l,t);q=n.get("sqlite3_index_info").cg;p=F(m+q[4],"*");y=n.get("sqlite3_index_constraint_usage").size;for(L=0;L<t.nConstraint;++L)B=p+L*y,E=t.aConstraintUsage[L],I=n.get("sqlite3_index_constraint_usage").cg,H(B+I[0],E.argvIndex,"i32"),H(B+I[1],E.omit?1:0,"i8");H(m+q[5],t.idxNum,"i32");"string"===typeof t.idxStr&&(p=Ta(t.idxStr),y=Z("sqlite3_malloc","number",["number"],[p+1]),Ua(t.idxStr,w,y,p+1),H(m+q[6],y,"*"),H(m+q[7],1,"i32"));H(m+q[8],t.orderByConsumed,"i32");H(m+q[9],
|
||||
t.estimatedCost,"double");H(m+q[10],t.estimatedRows,"i32");H(m+q[11],t.idxFlags,"i32");return l};nc=function(l){const m=e.get(l);b?h.add(l):e.delete(l);return m.module.xDisconnect(l)};mc=function(l){const m=e.get(l);b?h.add(l):e.delete(l);return m.module.xDestroy(l)};rc=function(l,m){const q=e.get(l);f.set(m,q);if(b){k.delete(m);for(const p of k)f.delete(p)}return q.module.xOpen(l,m)};hc=function(l){const m=f.get(l);b?k.add(l):f.delete(l);return m.module.xClose(l)};oc=function(l){return f.get(l).module.xEof(l)?
|
||||
1:0};pc=function(l,m,q,p,t){const y=f.get(l);q=q?q?J(w,q):"":null;t=new Uint32Array(w.buffer,t,p);return y.module.xFilter(l,m,q,t)};qc=function(l){return f.get(l).module.xNext(l)};ic=function(l,m,q){return f.get(l).module.xColumn(l,m,q)};uc=function(l,m){return f.get(l).module.xRowid(l,a("BigInt64",m))};xc=function(l,m,q,p){const t=e.get(l);q=new Uint32Array(w.buffer,q,m);return t.module.xUpdate(l,q,a("BigInt64",p))};fc=function(l){return e.get(l).module.xBegin(l)};wc=function(l){return e.get(l).module.xSync(l)};
|
||||
jc=function(l){return e.get(l).module.xCommit(l)};tc=function(l){return e.get(l).module.xRollback(l)};sc=function(l,m){const q=e.get(l);m=m?J(w,m):"";return q.module.xRename(l,m)}})();
|
||||
(function(){function a(h,k){const n=`get${h}`,l=`set${h}`;return new Proxy(new DataView(w.buffer,k,"Int32"===h?4:8),{get(m,q){if(q===n)return function(p,t){if(!t)throw Error("must be little endian");return m[q](p,t)};if(q===l)return function(p,t,y){if(!y)throw Error("must be little endian");return m[q](p,t,y)};if("string"===typeof q&&q.match(/^(get)|(set)/))throw Error("invalid type");return m[q]}})}const b="object"===typeof hd;b&&(d.handleAsync=gd);const c=new Map,e=new Map;d.registerVFS=function(h,
|
||||
k){if(Z("sqlite3_vfs_find","number",["string"],[h.name]))throw Error(`VFS '${h.name}' already registered`);b&&(h.handleAsync=gd);var n=h.Zg??64;const l=d._malloc(4);k=Z("register_vfs","number",["string","number","number","number"],[h.name,n,k?1:0,l]);k||(n=F(l,"*"),c.set(n,h));d._free(l);return k};const f=b?new Set:null;Ac=function(h){const k=e.get(h);b?f.add(h):e.delete(h);return k.xClose(h)};Hc=function(h,k,n,l,m){return e.get(h).xRead(h,w.subarray(k,k+n),4294967296*m+l+(0>l?2**32:0))};Mc=function(h,
|
||||
k,n,l,m){return e.get(h).xWrite(h,w.subarray(k,k+n),4294967296*m+l+(0>l?2**32:0))};Kc=function(h,k,n){return e.get(h).xTruncate(h,4294967296*n+k+(0>k?2**32:0))};Jc=function(h,k){return e.get(h).xSync(h,k)};Ec=function(h,k){const n=e.get(h);k=a("BigInt64",k);return n.xFileSize(h,k)};Fc=function(h,k){return e.get(h).xLock(h,k)};Lc=function(h,k){return e.get(h).xUnlock(h,k)};zc=function(h,k){const n=e.get(h);k=a("Int32",k);return n.xCheckReservedLock(h,k)};Dc=function(h,k,n){const l=e.get(h);n=new DataView(w.buffer,
|
||||
n);return l.xFileControl(h,k,n)};Ic=function(h){return e.get(h).xSectorSize(h)};Cc=function(h){return e.get(h).xDeviceCharacteristics(h)};Gc=function(h,k,n,l,m){h=c.get(h);e.set(n,h);if(b){f.delete(n);for(var q of f)e.delete(q)}q=null;if(l&64){q=1;const p=[];for(;q;){const t=w[k++];if(t)p.push(t);else switch(w[k]||(q=null),q){case 1:p.push(63);q=2;break;case 2:p.push(61);q=3;break;case 3:p.push(38),q=2}}q=(new TextDecoder).decode(new Uint8Array(p))}else k&&(q=k?J(w,k):"");m=a("Int32",m);return h.xOpen(q,
|
||||
n,l,m)};Bc=function(h,k,n){return c.get(h).xDelete(k?J(w,k):"",n)};yc=function(h,k,n,l){h=c.get(h);l=a("Int32",l);return h.xAccess(k?J(w,k):"",n,l)}})();
|
||||
var rd={a:(a,b,c,e)=>{u(`Assertion failed: ${a?J(w,a):""}, at: `+[b?b?J(w,b):"":"unknown filename",c,e?e?J(w,e):"":"unknown function"])},P:function(a,b){try{return a=a?J(w,a):"",Gb(a,b),0}catch(c){if("undefined"==typeof T||"ErrnoError"!==c.name)throw c;return-c.Nf}},S:function(a,b,c){try{b=b?J(w,b):"";b=Pb(a,b);if(c&-8)return-28;var e=Q(b,{Xf:!0}).node;if(!e)return-44;a="";c&4&&(a+="r");c&2&&(a+="w");c&1&&(a+="x");return a&&rb(e,a)?-2:0}catch(f){if("undefined"==typeof T||"ErrnoError"!==f.name)throw f;
|
||||
return-f.Nf}},Q:function(a,b){try{var c=R(a);Gb(c.node,b);return 0}catch(e){if("undefined"==typeof T||"ErrnoError"!==e.name)throw e;return-e.Nf}},O:function(a){try{var b=R(a).node;var c="string"==typeof b?Q(b,{Xf:!0}).node:b;if(!c.Kf.Pf)throw new M(63);c.Kf.Pf(c,{timestamp:Date.now()});return 0}catch(e){if("undefined"==typeof T||"ErrnoError"!==e.name)throw e;return-e.Nf}},b:function(a,b,c){Rb=c;try{var e=R(a);switch(b){case 0:var f=Sb();if(0>f)return-28;for(;kb[f];)f++;return xb(e,f).Vf;case 1:case 2:return 0;
|
||||
case 3:return e.flags;case 4:return f=Sb(),e.flags|=f,0;case 5:return f=Sb(),x[f+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return z[qd()>>2]=28,-1;default:return-28}}catch(h){if("undefined"==typeof T||"ErrnoError"!==h.name)throw h;return-h.Nf}},N:function(a,b){try{var c=R(a);return Qb(Eb,c.path,b)}catch(e){if("undefined"==typeof T||"ErrnoError"!==e.name)throw e;return-e.Nf}},n:function(a,b,c){b=Tb(b,c);try{if(isNaN(b))return 61;var e=R(a);if(0===(e.flags&2097155))throw new M(28);
|
||||
Hb(e.node,b);return 0}catch(f){if("undefined"==typeof T||"ErrnoError"!==f.name)throw f;return-f.Nf}},H:function(a,b){try{if(0===b)return-28;var c=Ta("/")+1;if(b<c)return-68;Ua("/",w,a,b);return c}catch(e){if("undefined"==typeof T||"ErrnoError"!==e.name)throw e;return-e.Nf}},L:function(a,b){try{return a=a?J(w,a):"",Qb(Fb,a,b)}catch(c){if("undefined"==typeof T||"ErrnoError"!==c.name)throw c;return-c.Nf}},E:function(a,b,c){try{return b=b?J(w,b):"",b=Pb(a,b),b=K(b),"/"===b[b.length-1]&&(b=b.substr(0,
|
||||
b.length-1)),S(b,c),0}catch(e){if("undefined"==typeof T||"ErrnoError"!==e.name)throw e;return-e.Nf}},J:function(a,b,c,e){try{b=b?J(w,b):"";var f=e&256;b=Pb(a,b,e&4096);return Qb(f?Fb:Eb,b,c)}catch(h){if("undefined"==typeof T||"ErrnoError"!==h.name)throw h;return-h.Nf}},D:function(a,b,c,e){Rb=e;try{b=b?J(w,b):"";b=Pb(a,b);var f=e?Sb():0;return Ib(b,c,f).Vf}catch(h){if("undefined"==typeof T||"ErrnoError"!==h.name)throw h;return-h.Nf}},B:function(a,b,c,e){try{b=b?J(w,b):"";b=Pb(a,b);if(0>=e)return-28;
|
||||
var f=nb(b),h=Math.min(e,Ta(f)),k=v[c+h];Ua(f,w,c,e+1);v[c+h]=k;return h}catch(n){if("undefined"==typeof T||"ErrnoError"!==n.name)throw n;return-n.Nf}},A:function(a){try{return a=a?J(w,a):"",Db(a),0}catch(b){if("undefined"==typeof T||"ErrnoError"!==b.name)throw b;return-b.Nf}},M:function(a,b){try{return a=a?J(w,a):"",Qb(Eb,a,b)}catch(c){if("undefined"==typeof T||"ErrnoError"!==c.name)throw c;return-c.Nf}},v:function(a,b,c){try{b=b?J(w,b):"";b=Pb(a,b);if(0===c){a=b;var e=Q(a,{parent:!0}).node;if(!e)throw new M(44);
|
||||
var f=Oa(a),h=fb(e,f),k=vb(e,f,!1);if(k)throw new M(k);if(!e.Kf.mg)throw new M(63);if(h.Zf)throw new M(10);e.Kf.mg(e,f);qb(h)}else 512===c?Db(b):u("Invalid flags passed to unlinkat");return 0}catch(n){if("undefined"==typeof T||"ErrnoError"!==n.name)throw n;return-n.Nf}},u:function(a,b,c){try{b=b?J(w,b):"";b=Pb(a,b,!0);if(c){var e=A[c>>2]+4294967296*z[c+4>>2],f=z[c+8>>2];h=1E3*e+f/1E6;c+=16;e=A[c>>2]+4294967296*z[c+4>>2];f=z[c+8>>2];k=1E3*e+f/1E6}else var h=Date.now(),k=h;a=h;var n=Q(b,{Xf:!0}).node;
|
||||
n.Kf.Pf(n,{timestamp:Math.max(a,k)});return 0}catch(l){if("undefined"==typeof T||"ErrnoError"!==l.name)throw l;return-l.Nf}},l:function(a,b,c){a=new Date(1E3*Tb(a,b));z[c>>2]=a.getSeconds();z[c+4>>2]=a.getMinutes();z[c+8>>2]=a.getHours();z[c+12>>2]=a.getDate();z[c+16>>2]=a.getMonth();z[c+20>>2]=a.getFullYear()-1900;z[c+24>>2]=a.getDay();b=a.getFullYear();z[c+28>>2]=(0!==b%4||0===b%100&&0!==b%400?Vb:Ub)[a.getMonth()]+a.getDate()-1|0;z[c+36>>2]=-(60*a.getTimezoneOffset());b=(new Date(a.getFullYear(),
|
||||
6,1)).getTimezoneOffset();var e=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();z[c+32>>2]=(b!=e&&a.getTimezoneOffset()==Math.min(e,b))|0},j:function(a,b,c,e,f,h,k,n){f=Tb(f,h);try{if(isNaN(f))return 61;var l=R(e);if(0!==(b&2)&&0===(c&2)&&2!==(l.flags&2097155))throw new M(2);if(1===(l.flags&2097155))throw new M(2);if(!l.Lf.ig)throw new M(43);var m=l.Lf.ig(l,a,f,b,c);var q=m.Mg;z[k>>2]=m.Ag;A[n>>2]=q;return 0}catch(p){if("undefined"==typeof T||"ErrnoError"!==p.name)throw p;return-p.Nf}},k:function(a,
|
||||
b,c,e,f,h,k){h=Tb(h,k);try{if(isNaN(h))return 61;var n=R(f);if(c&2){if(32768!==(n.node.mode&61440))throw new M(43);e&2||n.Lf.jg&&n.Lf.jg(n,w.slice(a,a+b),h,b,e)}}catch(l){if("undefined"==typeof T||"ErrnoError"!==l.name)throw l;return-l.Nf}},w:(a,b,c)=>{function e(l){return(l=l.toTimeString().match(/\(([A-Za-z ]+)\)$/))?l[1]:"GMT"}var f=(new Date).getFullYear(),h=new Date(f,0,1),k=new Date(f,6,1);f=h.getTimezoneOffset();var n=k.getTimezoneOffset();A[a>>2]=60*Math.max(f,n);z[b>>2]=Number(f!=n);a=e(h);
|
||||
b=e(k);a=Xb(a);b=Xb(b);n<f?(A[c>>2]=a,A[c+4>>2]=b):(A[c>>2]=b,A[c+4>>2]=a)},ua:()=>{u("")},e:()=>Date.now(),d:()=>performance.now(),x:(a,b,c)=>w.copyWithin(a,b,b+c),s:a=>{var b=w.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);var f=Math;e=Math.max(a,e);a:{f=(f.min.call(f,2147483648,e+(65536-e%65536)%65536)-ma.buffer.byteLength+65535)/65536;try{ma.grow(f);sa();var h=1;break a}catch(k){}h=void 0}if(h)return!0}return!1},F:(a,b)=>{var c=0;$b().forEach((e,
|
||||
f)=>{var h=b+c;f=A[a+4*f>>2]=h;for(h=0;h<e.length;++h)v[f++>>0]=e.charCodeAt(h);v[f>>0]=0;c+=e.length+1});return 0},G:(a,b)=>{var c=$b();A[a>>2]=c.length;var e=0;c.forEach(f=>e+=f.length+1);A[b>>2]=e;return 0},f:function(a){try{var b=R(a);if(null===b.Vf)throw new M(8);b.ng&&(b.ng=null);try{b.Lf.close&&b.Lf.close(b)}catch(c){throw c;}finally{kb[b.Vf]=null}b.Vf=null;return 0}catch(c){if("undefined"==typeof T||"ErrnoError"!==c.name)throw c;return c.Nf}},t:function(a,b){try{var c=R(a);v[b>>0]=c.Rf?2:
|
||||
O(c.mode)?3:40960===(c.mode&61440)?7:4;x[b+2>>1]=0;D=[0,(C=0,1<=+Math.abs(C)?0<C?+Math.floor(C/4294967296)>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)];z[b+8>>2]=D[0];z[b+12>>2]=D[1];D=[0,(C=0,1<=+Math.abs(C)?0<C?+Math.floor(C/4294967296)>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)];z[b+16>>2]=D[0];z[b+20>>2]=D[1];return 0}catch(e){if("undefined"==typeof T||"ErrnoError"!==e.name)throw e;return e.Nf}},C:function(a,b,c,e){try{a:{var f=R(a);a=b;for(var h,k=b=0;k<c;k++){var n=A[a>>2],l=
|
||||
A[a+4>>2];a+=8;var m=f,q=n,p=l,t=h,y=v;if(0>p||0>t)throw new M(28);if(null===m.Vf)throw new M(8);if(1===(m.flags&2097155))throw new M(8);if(O(m.node.mode))throw new M(31);if(!m.Lf.read)throw new M(28);var B="undefined"!=typeof t;if(!B)t=m.position;else if(!m.seekable)throw new M(70);var G=m.Lf.read(m,y,q,p,t);B||(m.position+=G);var E=G;if(0>E){var L=-1;break a}b+=E;if(E<l)break;"undefined"!==typeof h&&(h+=E)}L=b}A[e>>2]=L;return 0}catch(I){if("undefined"==typeof T||"ErrnoError"!==I.name)throw I;return I.Nf}},
|
||||
m:function(a,b,c,e,f){b=Tb(b,c);try{if(isNaN(b))return 61;var h=R(a);Kb(h,b,e);D=[h.position>>>0,(C=h.position,1<=+Math.abs(C)?0<C?+Math.floor(C/4294967296)>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)];z[f>>2]=D[0];z[f+4>>2]=D[1];h.ng&&0===b&&0===e&&(h.ng=null);return 0}catch(k){if("undefined"==typeof T||"ErrnoError"!==k.name)throw k;return k.Nf}},I:function(a){try{var b=R(a);return bd(c=>{var e=b.node.Tf;e.type.Og?e.type.Og(e,!1,f=>{f?c(29):c(0)}):c(0)})}catch(c){if("undefined"==typeof T||
|
||||
"ErrnoError"!==c.name)throw c;return c.Nf}},y:function(a,b,c,e){try{a:{var f=R(a);a=b;for(var h,k=b=0;k<c;k++){var n=A[a>>2],l=A[a+4>>2];a+=8;var m=f,q=n,p=l,t=h,y=v;if(0>p||0>t)throw new M(28);if(null===m.Vf)throw new M(8);if(0===(m.flags&2097155))throw new M(8);if(O(m.node.mode))throw new M(31);if(!m.Lf.write)throw new M(28);m.seekable&&m.flags&1024&&Kb(m,0,2);var B="undefined"!=typeof t;if(!B)t=m.position;else if(!m.seekable)throw new M(70);var G=m.Lf.write(m,y,q,p,t,void 0);B||(m.position+=G);
|
||||
var E=G;if(0>E){var L=-1;break a}b+=E;"undefined"!==typeof h&&(h+=E)}L=b}A[e>>2]=L;return 0}catch(I){if("undefined"==typeof T||"ErrnoError"!==I.name)throw I;return I.Nf}},g:(a,b)=>{Qa(w.subarray(a,a+b));return 0},aa:ac,z:bc,R:cc,ea:dc,K:ec,ma:fc,o:gc,ta:hc,pa:ic,ka:jc,ga:kc,ha:lc,h:mc,i:nc,qa:oc,sa:pc,ra:qc,fa:rc,ia:sc,ja:tc,oa:uc,c:vc,la:wc,na:xc,ca:yc,X:zc,ba:Ac,da:Bc,U:Cc,W:Dc,_:Ec,Z:Fc,T:Gc,r:Hc,V:Ic,$:Jc,p:Kc,Y:Lc,q:Mc},U=function(){function a(c){U=c.exports;U=Rc();ma=U.va;sa();X=U.Af;ua.unshift(U.wa);
|
||||
ya--;d.monitorRunDependencies&&d.monitorRunDependencies(ya);0==ya&&(null!==za&&(clearInterval(za),za=null),Aa&&(c=Aa,Aa=null,c()));return U}var b={a:rd};ya++;d.monitorRunDependencies&&d.monitorRunDependencies(ya);if(d.instantiateWasm)try{return d.instantiateWasm(b,a)}catch(c){r(`Module.instantiateWasm callback failed with error: ${c}`),ba(c)}Ha(b,function(c){a(c.instance)}).catch(ba);return{}}();d._sqlite3_status64=(a,b,c,e)=>(d._sqlite3_status64=U.xa)(a,b,c,e);
|
||||
d._sqlite3_status=(a,b,c,e)=>(d._sqlite3_status=U.ya)(a,b,c,e);d._sqlite3_db_status=(a,b,c,e,f)=>(d._sqlite3_db_status=U.za)(a,b,c,e,f);d._sqlite3_msize=a=>(d._sqlite3_msize=U.Aa)(a);d._sqlite3_vfs_find=a=>(d._sqlite3_vfs_find=U.Ba)(a);d._sqlite3_vfs_register=(a,b)=>(d._sqlite3_vfs_register=U.Ca)(a,b);d._sqlite3_vfs_unregister=a=>(d._sqlite3_vfs_unregister=U.Da)(a);d._sqlite3_release_memory=a=>(d._sqlite3_release_memory=U.Ea)(a);
|
||||
d._sqlite3_soft_heap_limit64=(a,b)=>(d._sqlite3_soft_heap_limit64=U.Fa)(a,b);d._sqlite3_memory_used=()=>(d._sqlite3_memory_used=U.Ga)();d._sqlite3_hard_heap_limit64=(a,b)=>(d._sqlite3_hard_heap_limit64=U.Ha)(a,b);d._sqlite3_memory_highwater=a=>(d._sqlite3_memory_highwater=U.Ia)(a);d._sqlite3_malloc=a=>(d._sqlite3_malloc=U.Ja)(a);d._sqlite3_malloc64=(a,b)=>(d._sqlite3_malloc64=U.Ka)(a,b);d._sqlite3_free=a=>(d._sqlite3_free=U.La)(a);d._sqlite3_realloc=(a,b)=>(d._sqlite3_realloc=U.Ma)(a,b);
|
||||
d._sqlite3_realloc64=(a,b,c)=>(d._sqlite3_realloc64=U.Na)(a,b,c);d._sqlite3_str_vappendf=(a,b,c)=>(d._sqlite3_str_vappendf=U.Oa)(a,b,c);d._sqlite3_str_append=(a,b,c)=>(d._sqlite3_str_append=U.Pa)(a,b,c);d._sqlite3_str_appendchar=(a,b,c)=>(d._sqlite3_str_appendchar=U.Qa)(a,b,c);d._sqlite3_str_appendall=(a,b)=>(d._sqlite3_str_appendall=U.Ra)(a,b);d._sqlite3_str_appendf=(a,b,c)=>(d._sqlite3_str_appendf=U.Sa)(a,b,c);d._sqlite3_str_finish=a=>(d._sqlite3_str_finish=U.Ta)(a);
|
||||
d._sqlite3_str_errcode=a=>(d._sqlite3_str_errcode=U.Ua)(a);d._sqlite3_str_length=a=>(d._sqlite3_str_length=U.Va)(a);d._sqlite3_str_value=a=>(d._sqlite3_str_value=U.Wa)(a);d._sqlite3_str_reset=a=>(d._sqlite3_str_reset=U.Xa)(a);d._sqlite3_str_new=a=>(d._sqlite3_str_new=U.Ya)(a);d._sqlite3_vmprintf=(a,b)=>(d._sqlite3_vmprintf=U.Za)(a,b);d._sqlite3_mprintf=(a,b)=>(d._sqlite3_mprintf=U._a)(a,b);d._sqlite3_vsnprintf=(a,b,c,e)=>(d._sqlite3_vsnprintf=U.$a)(a,b,c,e);
|
||||
d._sqlite3_snprintf=(a,b,c,e)=>(d._sqlite3_snprintf=U.ab)(a,b,c,e);d._sqlite3_log=(a,b,c)=>(d._sqlite3_log=U.bb)(a,b,c);d._sqlite3_randomness=(a,b)=>(d._sqlite3_randomness=U.cb)(a,b);d._sqlite3_stricmp=(a,b)=>(d._sqlite3_stricmp=U.db)(a,b);d._sqlite3_strnicmp=(a,b,c)=>(d._sqlite3_strnicmp=U.eb)(a,b,c);d._sqlite3_os_init=()=>(d._sqlite3_os_init=U.fb)();d._sqlite3_os_end=()=>(d._sqlite3_os_end=U.gb)();d._sqlite3_serialize=(a,b,c,e)=>(d._sqlite3_serialize=U.hb)(a,b,c,e);
|
||||
d._sqlite3_prepare_v2=(a,b,c,e,f)=>(d._sqlite3_prepare_v2=U.ib)(a,b,c,e,f);d._sqlite3_step=a=>(d._sqlite3_step=U.jb)(a);d._sqlite3_column_int64=(a,b)=>(d._sqlite3_column_int64=U.kb)(a,b);d._sqlite3_column_int=(a,b)=>(d._sqlite3_column_int=U.lb)(a,b);d._sqlite3_finalize=a=>(d._sqlite3_finalize=U.mb)(a);d._sqlite3_deserialize=(a,b,c,e,f,h,k,n)=>(d._sqlite3_deserialize=U.nb)(a,b,c,e,f,h,k,n);d._sqlite3_database_file_object=a=>(d._sqlite3_database_file_object=U.ob)(a);
|
||||
d._sqlite3_backup_init=(a,b,c,e)=>(d._sqlite3_backup_init=U.pb)(a,b,c,e);d._sqlite3_backup_step=(a,b)=>(d._sqlite3_backup_step=U.qb)(a,b);d._sqlite3_backup_finish=a=>(d._sqlite3_backup_finish=U.rb)(a);d._sqlite3_backup_remaining=a=>(d._sqlite3_backup_remaining=U.sb)(a);d._sqlite3_backup_pagecount=a=>(d._sqlite3_backup_pagecount=U.tb)(a);d._sqlite3_reset=a=>(d._sqlite3_reset=U.ub)(a);d._sqlite3_clear_bindings=a=>(d._sqlite3_clear_bindings=U.vb)(a);d._sqlite3_value_blob=a=>(d._sqlite3_value_blob=U.wb)(a);
|
||||
d._sqlite3_value_text=a=>(d._sqlite3_value_text=U.xb)(a);d._sqlite3_value_bytes=a=>(d._sqlite3_value_bytes=U.yb)(a);d._sqlite3_value_bytes16=a=>(d._sqlite3_value_bytes16=U.zb)(a);d._sqlite3_value_double=a=>(d._sqlite3_value_double=U.Ab)(a);d._sqlite3_value_int=a=>(d._sqlite3_value_int=U.Bb)(a);d._sqlite3_value_int64=a=>(d._sqlite3_value_int64=U.Cb)(a);d._sqlite3_value_subtype=a=>(d._sqlite3_value_subtype=U.Db)(a);d._sqlite3_value_pointer=(a,b)=>(d._sqlite3_value_pointer=U.Eb)(a,b);
|
||||
d._sqlite3_value_text16=a=>(d._sqlite3_value_text16=U.Fb)(a);d._sqlite3_value_text16be=a=>(d._sqlite3_value_text16be=U.Gb)(a);d._sqlite3_value_text16le=a=>(d._sqlite3_value_text16le=U.Hb)(a);d._sqlite3_value_type=a=>(d._sqlite3_value_type=U.Ib)(a);d._sqlite3_value_encoding=a=>(d._sqlite3_value_encoding=U.Jb)(a);d._sqlite3_value_nochange=a=>(d._sqlite3_value_nochange=U.Kb)(a);d._sqlite3_value_frombind=a=>(d._sqlite3_value_frombind=U.Lb)(a);d._sqlite3_value_dup=a=>(d._sqlite3_value_dup=U.Mb)(a);
|
||||
d._sqlite3_value_free=a=>(d._sqlite3_value_free=U.Nb)(a);d._sqlite3_result_blob=(a,b,c,e)=>(d._sqlite3_result_blob=U.Ob)(a,b,c,e);d._sqlite3_result_blob64=(a,b,c,e,f)=>(d._sqlite3_result_blob64=U.Pb)(a,b,c,e,f);d._sqlite3_result_double=(a,b)=>(d._sqlite3_result_double=U.Qb)(a,b);d._sqlite3_result_error=(a,b,c)=>(d._sqlite3_result_error=U.Rb)(a,b,c);d._sqlite3_result_error16=(a,b,c)=>(d._sqlite3_result_error16=U.Sb)(a,b,c);d._sqlite3_result_int=(a,b)=>(d._sqlite3_result_int=U.Tb)(a,b);
|
||||
d._sqlite3_result_int64=(a,b,c)=>(d._sqlite3_result_int64=U.Ub)(a,b,c);d._sqlite3_result_null=a=>(d._sqlite3_result_null=U.Vb)(a);d._sqlite3_result_pointer=(a,b,c,e)=>(d._sqlite3_result_pointer=U.Wb)(a,b,c,e);d._sqlite3_result_subtype=(a,b)=>(d._sqlite3_result_subtype=U.Xb)(a,b);d._sqlite3_result_text=(a,b,c,e)=>(d._sqlite3_result_text=U.Yb)(a,b,c,e);d._sqlite3_result_text64=(a,b,c,e,f,h)=>(d._sqlite3_result_text64=U.Zb)(a,b,c,e,f,h);
|
||||
d._sqlite3_result_text16=(a,b,c,e)=>(d._sqlite3_result_text16=U._b)(a,b,c,e);d._sqlite3_result_text16be=(a,b,c,e)=>(d._sqlite3_result_text16be=U.$b)(a,b,c,e);d._sqlite3_result_text16le=(a,b,c,e)=>(d._sqlite3_result_text16le=U.ac)(a,b,c,e);d._sqlite3_result_value=(a,b)=>(d._sqlite3_result_value=U.bc)(a,b);d._sqlite3_result_error_toobig=a=>(d._sqlite3_result_error_toobig=U.cc)(a);d._sqlite3_result_zeroblob=(a,b)=>(d._sqlite3_result_zeroblob=U.dc)(a,b);
|
||||
d._sqlite3_result_zeroblob64=(a,b,c)=>(d._sqlite3_result_zeroblob64=U.ec)(a,b,c);d._sqlite3_result_error_code=(a,b)=>(d._sqlite3_result_error_code=U.fc)(a,b);d._sqlite3_result_error_nomem=a=>(d._sqlite3_result_error_nomem=U.gc)(a);d._sqlite3_user_data=a=>(d._sqlite3_user_data=U.hc)(a);d._sqlite3_context_db_handle=a=>(d._sqlite3_context_db_handle=U.ic)(a);d._sqlite3_vtab_nochange=a=>(d._sqlite3_vtab_nochange=U.jc)(a);d._sqlite3_vtab_in_first=(a,b)=>(d._sqlite3_vtab_in_first=U.kc)(a,b);
|
||||
d._sqlite3_vtab_in_next=(a,b)=>(d._sqlite3_vtab_in_next=U.lc)(a,b);d._sqlite3_aggregate_context=(a,b)=>(d._sqlite3_aggregate_context=U.mc)(a,b);d._sqlite3_get_auxdata=(a,b)=>(d._sqlite3_get_auxdata=U.nc)(a,b);d._sqlite3_set_auxdata=(a,b,c,e)=>(d._sqlite3_set_auxdata=U.oc)(a,b,c,e);d._sqlite3_column_count=a=>(d._sqlite3_column_count=U.pc)(a);d._sqlite3_data_count=a=>(d._sqlite3_data_count=U.qc)(a);d._sqlite3_column_blob=(a,b)=>(d._sqlite3_column_blob=U.rc)(a,b);
|
||||
d._sqlite3_column_bytes=(a,b)=>(d._sqlite3_column_bytes=U.sc)(a,b);d._sqlite3_column_bytes16=(a,b)=>(d._sqlite3_column_bytes16=U.tc)(a,b);d._sqlite3_column_double=(a,b)=>(d._sqlite3_column_double=U.uc)(a,b);d._sqlite3_column_text=(a,b)=>(d._sqlite3_column_text=U.vc)(a,b);d._sqlite3_column_value=(a,b)=>(d._sqlite3_column_value=U.wc)(a,b);d._sqlite3_column_text16=(a,b)=>(d._sqlite3_column_text16=U.xc)(a,b);d._sqlite3_column_type=(a,b)=>(d._sqlite3_column_type=U.yc)(a,b);
|
||||
d._sqlite3_column_name=(a,b)=>(d._sqlite3_column_name=U.zc)(a,b);d._sqlite3_column_name16=(a,b)=>(d._sqlite3_column_name16=U.Ac)(a,b);d._sqlite3_bind_blob=(a,b,c,e,f)=>(d._sqlite3_bind_blob=U.Bc)(a,b,c,e,f);d._sqlite3_bind_blob64=(a,b,c,e,f,h)=>(d._sqlite3_bind_blob64=U.Cc)(a,b,c,e,f,h);d._sqlite3_bind_double=(a,b,c)=>(d._sqlite3_bind_double=U.Dc)(a,b,c);d._sqlite3_bind_int=(a,b,c)=>(d._sqlite3_bind_int=U.Ec)(a,b,c);d._sqlite3_bind_int64=(a,b,c,e)=>(d._sqlite3_bind_int64=U.Fc)(a,b,c,e);
|
||||
d._sqlite3_bind_null=(a,b)=>(d._sqlite3_bind_null=U.Gc)(a,b);d._sqlite3_bind_pointer=(a,b,c,e,f)=>(d._sqlite3_bind_pointer=U.Hc)(a,b,c,e,f);d._sqlite3_bind_text=(a,b,c,e,f)=>(d._sqlite3_bind_text=U.Ic)(a,b,c,e,f);d._sqlite3_bind_text64=(a,b,c,e,f,h,k)=>(d._sqlite3_bind_text64=U.Jc)(a,b,c,e,f,h,k);d._sqlite3_bind_text16=(a,b,c,e,f)=>(d._sqlite3_bind_text16=U.Kc)(a,b,c,e,f);d._sqlite3_bind_value=(a,b,c)=>(d._sqlite3_bind_value=U.Lc)(a,b,c);
|
||||
d._sqlite3_bind_zeroblob=(a,b,c)=>(d._sqlite3_bind_zeroblob=U.Mc)(a,b,c);d._sqlite3_bind_zeroblob64=(a,b,c,e)=>(d._sqlite3_bind_zeroblob64=U.Nc)(a,b,c,e);d._sqlite3_bind_parameter_count=a=>(d._sqlite3_bind_parameter_count=U.Oc)(a);d._sqlite3_bind_parameter_name=(a,b)=>(d._sqlite3_bind_parameter_name=U.Pc)(a,b);d._sqlite3_bind_parameter_index=(a,b)=>(d._sqlite3_bind_parameter_index=U.Qc)(a,b);d._sqlite3_db_handle=a=>(d._sqlite3_db_handle=U.Rc)(a);
|
||||
d._sqlite3_stmt_readonly=a=>(d._sqlite3_stmt_readonly=U.Sc)(a);d._sqlite3_stmt_isexplain=a=>(d._sqlite3_stmt_isexplain=U.Tc)(a);d._sqlite3_stmt_explain=(a,b)=>(d._sqlite3_stmt_explain=U.Uc)(a,b);d._sqlite3_stmt_busy=a=>(d._sqlite3_stmt_busy=U.Vc)(a);d._sqlite3_next_stmt=(a,b)=>(d._sqlite3_next_stmt=U.Wc)(a,b);d._sqlite3_stmt_status=(a,b,c)=>(d._sqlite3_stmt_status=U.Xc)(a,b,c);d._sqlite3_sql=a=>(d._sqlite3_sql=U.Yc)(a);d._sqlite3_expanded_sql=a=>(d._sqlite3_expanded_sql=U.Zc)(a);
|
||||
d._sqlite3_value_numeric_type=a=>(d._sqlite3_value_numeric_type=U._c)(a);d._sqlite3_blob_open=(a,b,c,e,f,h,k,n)=>(d._sqlite3_blob_open=U.$c)(a,b,c,e,f,h,k,n);d._sqlite3_blob_close=a=>(d._sqlite3_blob_close=U.ad)(a);d._sqlite3_blob_read=(a,b,c,e)=>(d._sqlite3_blob_read=U.bd)(a,b,c,e);d._sqlite3_blob_write=(a,b,c,e)=>(d._sqlite3_blob_write=U.cd)(a,b,c,e);d._sqlite3_blob_bytes=a=>(d._sqlite3_blob_bytes=U.dd)(a);d._sqlite3_blob_reopen=(a,b,c)=>(d._sqlite3_blob_reopen=U.ed)(a,b,c);
|
||||
d._sqlite3_set_authorizer=(a,b,c)=>(d._sqlite3_set_authorizer=U.fd)(a,b,c);d._sqlite3_strglob=(a,b)=>(d._sqlite3_strglob=U.gd)(a,b);d._sqlite3_strlike=(a,b,c)=>(d._sqlite3_strlike=U.hd)(a,b,c);d._sqlite3_exec=(a,b,c,e,f)=>(d._sqlite3_exec=U.id)(a,b,c,e,f);d._sqlite3_errmsg=a=>(d._sqlite3_errmsg=U.jd)(a);d._sqlite3_auto_extension=a=>(d._sqlite3_auto_extension=U.kd)(a);d._sqlite3_cancel_auto_extension=a=>(d._sqlite3_cancel_auto_extension=U.ld)(a);
|
||||
d._sqlite3_reset_auto_extension=()=>(d._sqlite3_reset_auto_extension=U.md)();d._sqlite3_prepare=(a,b,c,e,f)=>(d._sqlite3_prepare=U.nd)(a,b,c,e,f);d._sqlite3_prepare_v3=(a,b,c,e,f,h)=>(d._sqlite3_prepare_v3=U.od)(a,b,c,e,f,h);d._sqlite3_prepare16=(a,b,c,e,f)=>(d._sqlite3_prepare16=U.pd)(a,b,c,e,f);d._sqlite3_prepare16_v2=(a,b,c,e,f)=>(d._sqlite3_prepare16_v2=U.qd)(a,b,c,e,f);d._sqlite3_prepare16_v3=(a,b,c,e,f,h)=>(d._sqlite3_prepare16_v3=U.rd)(a,b,c,e,f,h);
|
||||
d._sqlite3_get_table=(a,b,c,e,f,h)=>(d._sqlite3_get_table=U.sd)(a,b,c,e,f,h);d._sqlite3_free_table=a=>(d._sqlite3_free_table=U.td)(a);d._sqlite3_create_module=(a,b,c,e)=>(d._sqlite3_create_module=U.ud)(a,b,c,e);d._sqlite3_create_module_v2=(a,b,c,e,f)=>(d._sqlite3_create_module_v2=U.vd)(a,b,c,e,f);d._sqlite3_drop_modules=(a,b)=>(d._sqlite3_drop_modules=U.wd)(a,b);d._sqlite3_declare_vtab=(a,b)=>(d._sqlite3_declare_vtab=U.xd)(a,b);d._sqlite3_vtab_on_conflict=a=>(d._sqlite3_vtab_on_conflict=U.yd)(a);
|
||||
d._sqlite3_vtab_config=(a,b,c)=>(d._sqlite3_vtab_config=U.zd)(a,b,c);d._sqlite3_vtab_collation=(a,b)=>(d._sqlite3_vtab_collation=U.Ad)(a,b);d._sqlite3_vtab_in=(a,b,c)=>(d._sqlite3_vtab_in=U.Bd)(a,b,c);d._sqlite3_vtab_rhs_value=(a,b,c)=>(d._sqlite3_vtab_rhs_value=U.Cd)(a,b,c);d._sqlite3_vtab_distinct=a=>(d._sqlite3_vtab_distinct=U.Dd)(a);d._sqlite3_keyword_name=(a,b,c)=>(d._sqlite3_keyword_name=U.Ed)(a,b,c);d._sqlite3_keyword_count=()=>(d._sqlite3_keyword_count=U.Fd)();
|
||||
d._sqlite3_keyword_check=(a,b)=>(d._sqlite3_keyword_check=U.Gd)(a,b);d._sqlite3_complete=a=>(d._sqlite3_complete=U.Hd)(a);d._sqlite3_complete16=a=>(d._sqlite3_complete16=U.Id)(a);d._sqlite3_libversion=()=>(d._sqlite3_libversion=U.Jd)();d._sqlite3_libversion_number=()=>(d._sqlite3_libversion_number=U.Kd)();d._sqlite3_threadsafe=()=>(d._sqlite3_threadsafe=U.Ld)();d._sqlite3_initialize=()=>(d._sqlite3_initialize=U.Md)();d._sqlite3_shutdown=()=>(d._sqlite3_shutdown=U.Nd)();
|
||||
d._sqlite3_config=(a,b)=>(d._sqlite3_config=U.Od)(a,b);d._sqlite3_db_mutex=a=>(d._sqlite3_db_mutex=U.Pd)(a);d._sqlite3_db_release_memory=a=>(d._sqlite3_db_release_memory=U.Qd)(a);d._sqlite3_db_cacheflush=a=>(d._sqlite3_db_cacheflush=U.Rd)(a);d._sqlite3_db_config=(a,b,c)=>(d._sqlite3_db_config=U.Sd)(a,b,c);d._sqlite3_last_insert_rowid=a=>(d._sqlite3_last_insert_rowid=U.Td)(a);d._sqlite3_set_last_insert_rowid=(a,b,c)=>(d._sqlite3_set_last_insert_rowid=U.Ud)(a,b,c);
|
||||
d._sqlite3_changes64=a=>(d._sqlite3_changes64=U.Vd)(a);d._sqlite3_changes=a=>(d._sqlite3_changes=U.Wd)(a);d._sqlite3_total_changes64=a=>(d._sqlite3_total_changes64=U.Xd)(a);d._sqlite3_total_changes=a=>(d._sqlite3_total_changes=U.Yd)(a);d._sqlite3_txn_state=(a,b)=>(d._sqlite3_txn_state=U.Zd)(a,b);d._sqlite3_close=a=>(d._sqlite3_close=U._d)(a);d._sqlite3_close_v2=a=>(d._sqlite3_close_v2=U.$d)(a);d._sqlite3_busy_handler=(a,b,c)=>(d._sqlite3_busy_handler=U.ae)(a,b,c);
|
||||
d._sqlite3_progress_handler=(a,b,c,e)=>(d._sqlite3_progress_handler=U.be)(a,b,c,e);d._sqlite3_busy_timeout=(a,b)=>(d._sqlite3_busy_timeout=U.ce)(a,b);d._sqlite3_interrupt=a=>(d._sqlite3_interrupt=U.de)(a);d._sqlite3_is_interrupted=a=>(d._sqlite3_is_interrupted=U.ee)(a);d._sqlite3_create_function=(a,b,c,e,f,h,k,n)=>(d._sqlite3_create_function=U.fe)(a,b,c,e,f,h,k,n);d._sqlite3_create_function_v2=(a,b,c,e,f,h,k,n,l)=>(d._sqlite3_create_function_v2=U.ge)(a,b,c,e,f,h,k,n,l);
|
||||
d._sqlite3_create_window_function=(a,b,c,e,f,h,k,n,l,m)=>(d._sqlite3_create_window_function=U.he)(a,b,c,e,f,h,k,n,l,m);d._sqlite3_create_function16=(a,b,c,e,f,h,k,n)=>(d._sqlite3_create_function16=U.ie)(a,b,c,e,f,h,k,n);d._sqlite3_overload_function=(a,b,c)=>(d._sqlite3_overload_function=U.je)(a,b,c);d._sqlite3_trace_v2=(a,b,c,e)=>(d._sqlite3_trace_v2=U.ke)(a,b,c,e);d._sqlite3_commit_hook=(a,b,c)=>(d._sqlite3_commit_hook=U.le)(a,b,c);
|
||||
d._sqlite3_update_hook=(a,b,c)=>(d._sqlite3_update_hook=U.me)(a,b,c);d._sqlite3_rollback_hook=(a,b,c)=>(d._sqlite3_rollback_hook=U.ne)(a,b,c);d._sqlite3_autovacuum_pages=(a,b,c,e)=>(d._sqlite3_autovacuum_pages=U.oe)(a,b,c,e);d._sqlite3_wal_autocheckpoint=(a,b)=>(d._sqlite3_wal_autocheckpoint=U.pe)(a,b);d._sqlite3_wal_hook=(a,b,c)=>(d._sqlite3_wal_hook=U.qe)(a,b,c);d._sqlite3_wal_checkpoint_v2=(a,b,c,e,f)=>(d._sqlite3_wal_checkpoint_v2=U.re)(a,b,c,e,f);
|
||||
d._sqlite3_wal_checkpoint=(a,b)=>(d._sqlite3_wal_checkpoint=U.se)(a,b);d._sqlite3_error_offset=a=>(d._sqlite3_error_offset=U.te)(a);d._sqlite3_errmsg16=a=>(d._sqlite3_errmsg16=U.ue)(a);d._sqlite3_errcode=a=>(d._sqlite3_errcode=U.ve)(a);d._sqlite3_extended_errcode=a=>(d._sqlite3_extended_errcode=U.we)(a);d._sqlite3_system_errno=a=>(d._sqlite3_system_errno=U.xe)(a);d._sqlite3_errstr=a=>(d._sqlite3_errstr=U.ye)(a);d._sqlite3_limit=(a,b,c)=>(d._sqlite3_limit=U.ze)(a,b,c);
|
||||
d._sqlite3_open=(a,b)=>(d._sqlite3_open=U.Ae)(a,b);d._sqlite3_open_v2=(a,b,c,e)=>(d._sqlite3_open_v2=U.Be)(a,b,c,e);d._sqlite3_open16=(a,b)=>(d._sqlite3_open16=U.Ce)(a,b);d._sqlite3_create_collation=(a,b,c,e,f)=>(d._sqlite3_create_collation=U.De)(a,b,c,e,f);d._sqlite3_create_collation_v2=(a,b,c,e,f,h)=>(d._sqlite3_create_collation_v2=U.Ee)(a,b,c,e,f,h);d._sqlite3_create_collation16=(a,b,c,e,f)=>(d._sqlite3_create_collation16=U.Fe)(a,b,c,e,f);
|
||||
d._sqlite3_collation_needed=(a,b,c)=>(d._sqlite3_collation_needed=U.Ge)(a,b,c);d._sqlite3_collation_needed16=(a,b,c)=>(d._sqlite3_collation_needed16=U.He)(a,b,c);d._sqlite3_get_clientdata=(a,b)=>(d._sqlite3_get_clientdata=U.Ie)(a,b);d._sqlite3_set_clientdata=(a,b,c,e)=>(d._sqlite3_set_clientdata=U.Je)(a,b,c,e);d._sqlite3_get_autocommit=a=>(d._sqlite3_get_autocommit=U.Ke)(a);d._sqlite3_table_column_metadata=(a,b,c,e,f,h,k,n,l)=>(d._sqlite3_table_column_metadata=U.Le)(a,b,c,e,f,h,k,n,l);
|
||||
d._sqlite3_sleep=a=>(d._sqlite3_sleep=U.Me)(a);d._sqlite3_extended_result_codes=(a,b)=>(d._sqlite3_extended_result_codes=U.Ne)(a,b);d._sqlite3_file_control=(a,b,c,e)=>(d._sqlite3_file_control=U.Oe)(a,b,c,e);d._sqlite3_test_control=(a,b)=>(d._sqlite3_test_control=U.Pe)(a,b);d._sqlite3_create_filename=(a,b,c,e,f)=>(d._sqlite3_create_filename=U.Qe)(a,b,c,e,f);d._sqlite3_free_filename=a=>(d._sqlite3_free_filename=U.Re)(a);d._sqlite3_uri_parameter=(a,b)=>(d._sqlite3_uri_parameter=U.Se)(a,b);
|
||||
d._sqlite3_uri_key=(a,b)=>(d._sqlite3_uri_key=U.Te)(a,b);d._sqlite3_uri_boolean=(a,b,c)=>(d._sqlite3_uri_boolean=U.Ue)(a,b,c);d._sqlite3_uri_int64=(a,b,c,e)=>(d._sqlite3_uri_int64=U.Ve)(a,b,c,e);d._sqlite3_filename_database=a=>(d._sqlite3_filename_database=U.We)(a);d._sqlite3_filename_journal=a=>(d._sqlite3_filename_journal=U.Xe)(a);d._sqlite3_filename_wal=a=>(d._sqlite3_filename_wal=U.Ye)(a);d._sqlite3_db_name=(a,b)=>(d._sqlite3_db_name=U.Ze)(a,b);
|
||||
d._sqlite3_db_filename=(a,b)=>(d._sqlite3_db_filename=U._e)(a,b);d._sqlite3_db_readonly=(a,b)=>(d._sqlite3_db_readonly=U.$e)(a,b);d._sqlite3_compileoption_used=a=>(d._sqlite3_compileoption_used=U.af)(a);d._sqlite3_compileoption_get=a=>(d._sqlite3_compileoption_get=U.bf)(a);d._sqlite3_sourceid=()=>(d._sqlite3_sourceid=U.cf)();d._sqlite3mc_config=(a,b,c)=>(d._sqlite3mc_config=U.df)(a,b,c);d._sqlite3mc_cipher_count=()=>(d._sqlite3mc_cipher_count=U.ef)();
|
||||
d._sqlite3mc_cipher_index=a=>(d._sqlite3mc_cipher_index=U.ff)(a);d._sqlite3mc_cipher_name=a=>(d._sqlite3mc_cipher_name=U.gf)(a);d._sqlite3mc_config_cipher=(a,b,c,e)=>(d._sqlite3mc_config_cipher=U.hf)(a,b,c,e);d._sqlite3mc_codec_data=(a,b,c)=>(d._sqlite3mc_codec_data=U.jf)(a,b,c);d._sqlite3_key=(a,b,c)=>(d._sqlite3_key=U.kf)(a,b,c);d._sqlite3_key_v2=(a,b,c,e)=>(d._sqlite3_key_v2=U.lf)(a,b,c,e);d._sqlite3_rekey_v2=(a,b,c,e)=>(d._sqlite3_rekey_v2=U.mf)(a,b,c,e);
|
||||
d._sqlite3_rekey=(a,b,c)=>(d._sqlite3_rekey=U.nf)(a,b,c);d._sqlite3mc_register_cipher=(a,b,c)=>(d._sqlite3mc_register_cipher=U.of)(a,b,c);var qd=()=>(qd=U.pf)(),Wb=d._malloc=a=>(Wb=d._malloc=U.qf)(a),fd=d._free=a=>(fd=d._free=U.rf)(a);d._RegisterExtensionFunctions=a=>(d._RegisterExtensionFunctions=U.sf)(a);d._set_authorizer=a=>(d._set_authorizer=U.tf)(a);d._create_function=(a,b,c,e,f,h)=>(d._create_function=U.uf)(a,b,c,e,f,h);d._create_module=(a,b,c,e)=>(d._create_module=U.vf)(a,b,c,e);
|
||||
d._progress_handler=(a,b)=>(d._progress_handler=U.wf)(a,b);d._register_vfs=(a,b,c,e)=>(d._register_vfs=U.xf)(a,b,c,e);d._getSqliteFree=()=>(d._getSqliteFree=U.yf)();var sd=d._main=(a,b)=>(sd=d._main=U.zf)(a,b),gb=(a,b)=>(gb=U.Bf)(a,b),td=()=>(td=U.Cf)(),od=()=>(od=U.Df)(),md=a=>(md=U.Ef)(a),nd=a=>(nd=U.Ff)(a),dd=a=>(dd=U.Gf)(a),Tc=()=>(Tc=U.Hf)(),cd=a=>(cd=U.If)(a),ed=()=>(ed=U.Jf)();d._sqlite3_version=11592;d.getTempRet0=td;d.ccall=Z;
|
||||
d.cwrap=(a,b,c,e)=>{var f=!c||c.every(h=>"number"===h||"boolean"===h);return"string"!==b&&f&&!e?d["_"+a]:function(){return Z(a,b,c,arguments,e)}};
|
||||
d.addFunction=(a,b)=>{if(!kd){kd=new WeakMap;var c=X.length;if(kd)for(var e=0;e<0+c;e++){var f=e;var h=jd[f];h||(f>=jd.length&&(jd.length=f+1),jd[f]=h=X.get(f));(f=h)&&kd.set(f,e)}}if(c=kd.get(a)||0)return c;if(ld.length)c=ld.pop();else{try{X.grow(1)}catch(n){if(!(n instanceof RangeError))throw n;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";}c=X.length-1}try{e=c,X.set(e,a),jd[e]=X.get(e)}catch(n){if(!(n instanceof TypeError))throw n;if("function"==typeof WebAssembly.Function){e=WebAssembly.Function;
|
||||
f={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"};h={parameters:[],results:"v"==b[0]?[]:[f[b[0]]]};for(var k=1;k<b.length;++k)h.parameters.push(f[b[k]]);b=new e(h,a)}else{e=[1];f=b.slice(0,1);b=b.slice(1);h={i:127,p:127,j:126,f:125,d:124,e:111};e.push(96);k=b.length;128>k?e.push(k):e.push(k%128|128,k>>7);for(k=0;k<b.length;++k)e.push(h[b[k]]);"v"==f?e.push(0):e.push(1,h[f]);b=[0,97,115,109,1,0,0,0,1];f=e.length;128>f?b.push(f):b.push(f%128|128,f>>7);b.push.apply(b,e);b.push(2,7,1,1,101,1,
|
||||
102,0,0,7,5,1,1,102,0,0);b=new WebAssembly.Module(new Uint8Array(b));b=(new WebAssembly.Instance(b,{e:{f:a}})).exports.f}e=c;X.set(e,b);jd[e]=X.get(e)}kd.set(a,c);return c};d.setValue=H;d.getValue=F;d.UTF8ToString=(a,b)=>a?J(w,a,b):"";d.stringToUTF8=(a,b,c)=>Ua(a,w,b,c);d.lengthBytesUTF8=Ta;d.intArrayFromString=Va;d.intArrayToString=function(a){for(var b=[],c=0;c<a.length;c++){var e=a[c];255<e&&(e&=255);b.push(String.fromCharCode(e))}return b.join("")};
|
||||
d.AsciiToString=a=>{for(var b="";;){var c=w[a++>>0];if(!c)return b;b+=String.fromCharCode(c)}};d.UTF16ToString=(a,b)=>{var c=a>>1;for(var e=c+b/2;!(c>=e)&&pa[c];)++c;c<<=1;if(32<c-a&&pd)return pd.decode(w.subarray(a,c));c="";for(e=0;!(e>=b/2);++e){var f=x[a+2*e>>1];if(0==f)break;c+=String.fromCharCode(f)}return c};d.stringToUTF16=(a,b,c)=>{void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)x[b>>1]=a.charCodeAt(f),b+=2;x[b>>1]=0;return b-e};
|
||||
d.UTF32ToString=(a,b)=>{for(var c=0,e="";!(c>=b/4);){var f=z[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e};d.stringToUTF32=(a,b,c)=>{void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+c-4;for(var f=0;f<a.length;++f){var h=a.charCodeAt(f);if(55296<=h&&57343>=h){var k=a.charCodeAt(++f);h=65536+((h&1023)<<10)|k&1023}z[b>>2]=h;b+=4;if(b+4>c)break}z[b>>2]=0;return b-e};d.writeArrayToMemory=(a,b)=>{v.set(a,b)};var ud;
|
||||
Aa=function vd(){ud||wd();ud||(Aa=vd)};
|
||||
function wd(){function a(){if(!ud&&(ud=!0,d.calledRun=!0,!na)){d.noFSInit||Mb||(Mb=!0,Lb(),d.stdin=d.stdin,d.stdout=d.stdout,d.stderr=d.stderr,d.stdin?Nb("stdin",d.stdin):Cb("/dev/tty","/dev/stdin"),d.stdout?Nb("stdout",null,d.stdout):Cb("/dev/tty","/dev/stdout"),d.stderr?Nb("stderr",null,d.stderr):Cb("/dev/tty1","/dev/stderr"),Ib("/dev/stdin",0),Ib("/dev/stdout",1),Ib("/dev/stderr",1));mb=!1;Ja(ua);Ja(va);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(xd){var b=sd;try{var c=b(0,0);oa=
|
||||
c;Oc(c)}catch(e){Pc(e)}}if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;)b=d.postRun.shift(),wa.unshift(b);Ja(wa)}}if(!(0<ya)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)xa();Ja(ta);0<ya||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();
|
||||
var xd=!0;d.noInitialRun&&(xd=!1);wd();
|
||||
|
||||
|
||||
return moduleArg.ready
|
||||
|
||||
Binary file not shown.
@@ -5,101 +5,137 @@ var Module = (() => {
|
||||
return (
|
||||
function(moduleArg = {}) {
|
||||
|
||||
var f=moduleArg,aa,ba;f.ready=new Promise((a,b)=>{aa=a;ba=b});var ca=Object.assign({},f),ea="./this.program",fa=(a,b)=>{throw b;},ha="object"==typeof window,ia="function"==typeof importScripts,q="",ja;
|
||||
if(ha||ia)ia?q=self.location.href:"undefined"!=typeof document&&document.currentScript&&(q=document.currentScript.src),_scriptDir&&(q=_scriptDir),0!==q.indexOf("blob:")?q=q.substr(0,q.replace(/[?#].*/,"").lastIndexOf("/")+1):q="",ia&&(ja=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ka=f.print||console.log.bind(console),t=f.printErr||console.error.bind(console);Object.assign(f,ca);ca=null;f.thisProgram&&(ea=f.thisProgram);
|
||||
f.quit&&(fa=f.quit);var la;f.wasmBinary&&(la=f.wasmBinary);"object"!=typeof WebAssembly&&u("no native wasm support detected");var ma,na=!1,v,w,oa,x,z,pa,qa;function ra(){var a=ma.buffer;f.HEAP8=v=new Int8Array(a);f.HEAP16=oa=new Int16Array(a);f.HEAPU8=w=new Uint8Array(a);f.HEAPU16=new Uint16Array(a);f.HEAP32=x=new Int32Array(a);f.HEAPU32=z=new Uint32Array(a);f.HEAPF32=pa=new Float32Array(a);f.HEAPF64=qa=new Float64Array(a)}var sa=[],ta=[],ua=[],va=[];
|
||||
function wa(){var a=f.preRun.shift();sa.unshift(a)}var B=0,xa=null,ya=null;function u(a){if(f.onAbort)f.onAbort(a);a="Aborted("+a+")";t(a);na=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");ba(a);throw a;}var za=a=>a.startsWith("data:application/octet-stream;base64,"),C;if(f.locateFile){if(C="wa-sqlite.wasm",!za(C)){var Aa=C;C=f.locateFile?f.locateFile(Aa,q):q+Aa}}else C=(new URL("wa-sqlite.wasm",import.meta.url)).href;
|
||||
function Ba(a){if(a==C&&la)return new Uint8Array(la);if(ja)return ja(a);throw"both async and sync fetching of the wasm failed";}function Ca(a){return la||!ha&&!ia||"function"!=typeof fetch?Promise.resolve().then(()=>Ba(a)):fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw"failed to load wasm binary file at '"+a+"'";return b.arrayBuffer()}).catch(()=>Ba(a))}
|
||||
function Da(a,b,c){return Ca(a).then(d=>WebAssembly.instantiate(d,b)).then(d=>d).then(c,d=>{t(`failed to asynchronously prepare wasm: ${d}`);u(d)})}function Ea(a,b){var c=C;return la||"function"!=typeof WebAssembly.instantiateStreaming||za(c)||"function"!=typeof fetch?Da(c,a,b):fetch(c,{credentials:"same-origin"}).then(d=>WebAssembly.instantiateStreaming(d,a).then(b,function(e){t(`wasm streaming compile failed: ${e}`);t("falling back to ArrayBuffer instantiation");return Da(c,a,b)}))}var D,F;
|
||||
function Fa(a){this.name="ExitStatus";this.message=`Program terminated with exit(${a})`;this.status=a}var Ga=a=>{for(;0<a.length;)a.shift()(f)};function I(a,b="i8"){b.endsWith("*")&&(b="*");switch(b){case "i1":return v[a>>0];case "i8":return v[a>>0];case "i16":return oa[a>>1];case "i32":return x[a>>2];case "i64":u("to do getValue(i64) use WASM_BIGINT");case "float":return pa[a>>2];case "double":return qa[a>>3];case "*":return z[a>>2];default:u(`invalid type for getValue: ${b}`)}}
|
||||
var Ha=f.noExitRuntime||!0;function J(a,b,c="i8"){c.endsWith("*")&&(c="*");switch(c){case "i1":v[a>>0]=b;break;case "i8":v[a>>0]=b;break;case "i16":oa[a>>1]=b;break;case "i32":x[a>>2]=b;break;case "i64":u("to do setValue(i64) use WASM_BIGINT");case "float":pa[a>>2]=b;break;case "double":qa[a>>3]=b;break;case "*":z[a>>2]=b;break;default:u(`invalid type for setValue: ${c}`)}}
|
||||
var Ia="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,K=(a,b,c)=>{var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.buffer&&Ia)return Ia.decode(a.subarray(b,c));for(d="";b<c;){var e=a[b++];if(e&128){var h=a[b++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|h);else{var g=a[b++]&63;e=224==(e&240)?(e&15)<<12|h<<6|g:(e&7)<<18|h<<12|g<<6|a[b++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d},
|
||||
Ja=(a,b)=>{for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a},M=a=>{var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=Ja(a.split("/").filter(d=>!!d),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},Ka=a=>{var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b},La=a=>{if("/"===
|
||||
a)return"/";a=M(a);a=a.replace(/\/$/,"");var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)},Ma=()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return a=>crypto.getRandomValues(a);u("initRandomDevice")},Na=a=>(Na=Ma())(a);
|
||||
function Oa(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!=typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=Ja(a.split("/").filter(d=>!!d),!b).join("/");return(b?"/":"")+a||"."}
|
||||
var Pa=[],N=a=>{for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);127>=d?b++:2047>=d?b+=2:55296<=d&&57343>=d?(b+=4,++c):b+=3}return b},O=(a,b,c,d)=>{if(!(0<d))return 0;var e=c;d=c+d-1;for(var h=0;h<a.length;++h){var g=a.charCodeAt(h);if(55296<=g&&57343>=g){var m=a.charCodeAt(++h);g=65536+((g&1023)<<10)|m&1023}if(127>=g){if(c>=d)break;b[c++]=g}else{if(2047>=g){if(c+1>=d)break;b[c++]=192|g>>6}else{if(65535>=g){if(c+2>=d)break;b[c++]=224|g>>12}else{if(c+3>=d)break;b[c++]=240|g>>18;b[c++]=128|g>>
|
||||
12&63}b[c++]=128|g>>6&63}b[c++]=128|g&63}}b[c]=0;return c-e},Qa=[];function Ra(a,b){Qa[a]={input:[],Nb:[],Zb:b};Sa(a,Ta)}
|
||||
var Ta={open(a){var b=Qa[a.node.bc];if(!b)throw new P(43);a.Ob=b;a.seekable=!1},close(a){a.Ob.Zb.Wb(a.Ob)},Wb(a){a.Ob.Zb.Wb(a.Ob)},read(a,b,c,d){if(!a.Ob||!a.Ob.Zb.sc)throw new P(60);for(var e=0,h=0;h<d;h++){try{var g=a.Ob.Zb.sc(a.Ob)}catch(m){throw new P(29);}if(void 0===g&&0===e)throw new P(6);if(null===g||void 0===g)break;e++;b[c+h]=g}e&&(a.node.timestamp=Date.now());return e},write(a,b,c,d){if(!a.Ob||!a.Ob.Zb.mc)throw new P(60);try{for(var e=0;e<d;e++)a.Ob.Zb.mc(a.Ob,b[c+e])}catch(h){throw new P(29);
|
||||
}d&&(a.node.timestamp=Date.now());return e}},Ua={sc(){a:{if(!Pa.length){var a=null;"undefined"!=typeof window&&"function"==typeof window.prompt?(a=window.prompt("Input: "),null!==a&&(a+="\n")):"function"==typeof readline&&(a=readline(),null!==a&&(a+="\n"));if(!a){var b=null;break a}b=Array(N(a)+1);a=O(a,b,0,b.length);b.length=a;Pa=b}b=Pa.shift()}return b},mc(a,b){null===b||10===b?(ka(K(a.Nb,0)),a.Nb=[]):0!=b&&a.Nb.push(b)},Wb(a){a.Nb&&0<a.Nb.length&&(ka(K(a.Nb,0)),a.Nb=[])},Sc(){return{Oc:25856,Qc:5,
|
||||
Nc:191,Pc:35387,Mc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},Tc(){return 0},Uc(){return[24,80]}},Va={mc(a,b){null===b||10===b?(t(K(a.Nb,0)),a.Nb=[]):0!=b&&a.Nb.push(b)},Wb(a){a.Nb&&0<a.Nb.length&&(t(K(a.Nb,0)),a.Nb=[])}};function Wa(a,b){var c=a.Jb?a.Jb.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Jb,a.Jb=new Uint8Array(b),0<a.Lb&&a.Jb.set(c.subarray(0,a.Lb),0))}
|
||||
var Q={Qb:null,Rb(){return Q.createNode(null,"/",16895,0)},createNode(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new P(63);Q.Qb||(Q.Qb={dir:{node:{Pb:Q.Cb.Pb,Mb:Q.Cb.Mb,$b:Q.Cb.$b,ec:Q.Cb.ec,wc:Q.Cb.wc,kc:Q.Cb.kc,ic:Q.Cb.ic,vc:Q.Cb.vc,jc:Q.Cb.jc},stream:{Vb:Q.Ib.Vb}},file:{node:{Pb:Q.Cb.Pb,Mb:Q.Cb.Mb},stream:{Vb:Q.Ib.Vb,read:Q.Ib.read,write:Q.Ib.write,pc:Q.Ib.pc,fc:Q.Ib.fc,hc:Q.Ib.hc}},link:{node:{Pb:Q.Cb.Pb,Mb:Q.Cb.Mb,cc:Q.Cb.cc},stream:{}},qc:{node:{Pb:Q.Cb.Pb,Mb:Q.Cb.Mb},stream:Xa}});
|
||||
c=Ya(a,b,c,d);R(c.mode)?(c.Cb=Q.Qb.dir.node,c.Ib=Q.Qb.dir.stream,c.Jb={}):32768===(c.mode&61440)?(c.Cb=Q.Qb.file.node,c.Ib=Q.Qb.file.stream,c.Lb=0,c.Jb=null):40960===(c.mode&61440)?(c.Cb=Q.Qb.link.node,c.Ib=Q.Qb.link.stream):8192===(c.mode&61440)&&(c.Cb=Q.Qb.qc.node,c.Ib=Q.Qb.qc.stream);c.timestamp=Date.now();a&&(a.Jb[b]=c,a.timestamp=c.timestamp);return c},Rc(a){return a.Jb?a.Jb.subarray?a.Jb.subarray(0,a.Lb):new Uint8Array(a.Jb):new Uint8Array(0)},Cb:{Pb(a){var b={};b.Cc=8192===(a.mode&61440)?a.id:
|
||||
1;b.tc=a.id;b.mode=a.mode;b.Ic=1;b.uid=0;b.Ec=0;b.bc=a.bc;R(a.mode)?b.size=4096:32768===(a.mode&61440)?b.size=a.Lb:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.yc=new Date(a.timestamp);b.Hc=new Date(a.timestamp);b.Bc=new Date(a.timestamp);b.zc=4096;b.Ac=Math.ceil(b.size/b.zc);return b},Mb(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=b.timestamp);if(void 0!==b.size&&(b=b.size,a.Lb!=b))if(0==b)a.Jb=null,a.Lb=0;else{var c=a.Jb;a.Jb=new Uint8Array(b);c&&a.Jb.set(c.subarray(0,
|
||||
Math.min(b,a.Lb)));a.Lb=b}},$b(){throw Za[44];},ec(a,b,c,d){return Q.createNode(a,b,c,d)},wc(a,b,c){if(R(a.mode)){try{var d=$a(b,c)}catch(h){}if(d)for(var e in d.Jb)throw new P(55);}delete a.parent.Jb[a.name];a.parent.timestamp=Date.now();a.name=c;b.Jb[c]=a;b.timestamp=a.parent.timestamp;a.parent=b},kc(a,b){delete a.Jb[b];a.timestamp=Date.now()},ic(a,b){var c=$a(a,b),d;for(d in c.Jb)throw new P(55);delete a.Jb[b];a.timestamp=Date.now()},vc(a){var b=[".",".."],c;for(c in a.Jb)a.Jb.hasOwnProperty(c)&&
|
||||
b.push(c);return b},jc(a,b,c){a=Q.createNode(a,b,41471,0);a.link=c;return a},cc(a){if(40960!==(a.mode&61440))throw new P(28);return a.link}},Ib:{read(a,b,c,d,e){var h=a.node.Jb;if(e>=a.node.Lb)return 0;a=Math.min(a.node.Lb-e,d);if(8<a&&h.subarray)b.set(h.subarray(e,e+a),c);else for(d=0;d<a;d++)b[c+d]=h[e+d];return a},write(a,b,c,d,e,h){b.buffer===v.buffer&&(h=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Jb||a.Jb.subarray)){if(h)return a.Jb=b.subarray(c,c+d),a.Lb=d;if(0===
|
||||
a.Lb&&0===e)return a.Jb=b.slice(c,c+d),a.Lb=d;if(e+d<=a.Lb)return a.Jb.set(b.subarray(c,c+d),e),d}Wa(a,e+d);if(a.Jb.subarray&&b.subarray)a.Jb.set(b.subarray(c,c+d),e);else for(h=0;h<d;h++)a.Jb[e+h]=b[c+h];a.Lb=Math.max(a.Lb,e+d);return d},Vb(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.Lb);if(0>b)throw new P(28);return b},pc(a,b,c){Wa(a.node,b+c);a.node.Lb=Math.max(a.node.Lb,b+c)},fc(a,b,c,d,e){if(32768!==(a.node.mode&61440))throw new P(43);a=a.node.Jb;if(e&2||a.buffer!==
|
||||
v.buffer){if(0<c||c+b<a.length)a.subarray?a=a.subarray(c,c+b):a=Array.prototype.slice.call(a,c,c+b);c=!0;b=65536*Math.ceil(b/65536);(e=ab(65536,b))?(w.fill(0,e,e+b),b=e):b=0;if(!b)throw new P(48);v.set(a,b)}else c=!1,b=a.byteOffset;return{Jc:b,xc:c}},hc(a,b,c,d){Q.Ib.write(a,b,0,d,c,!1);return 0}}},bb=(a,b)=>{var c=0;a&&(c|=365);b&&(c|=146);return c},cb=null,db={},eb=[],fb=1,S=null,gb=!0,P=null,Za={};
|
||||
function T(a,b={}){a=Oa(a);if(!a)return{path:"",node:null};b=Object.assign({rc:!0,nc:0},b);if(8<b.nc)throw new P(32);a=a.split("/").filter(g=>!!g);for(var c=cb,d="/",e=0;e<a.length;e++){var h=e===a.length-1;if(h&&b.parent)break;c=$a(c,a[e]);d=M(d+"/"+a[e]);c.Xb&&(!h||h&&b.rc)&&(c=c.Xb.root);if(!h||b.Ub)for(h=0;40960===(c.mode&61440);)if(c=hb(d),d=Oa(Ka(d),c),c=T(d,{nc:b.nc+1}).node,40<h++)throw new P(32);}return{path:d,node:c}}
|
||||
function ib(a){for(var b;;){if(a===a.parent)return a=a.Rb.uc,b?"/"!==a[a.length-1]?`${a}/${b}`:a+b:a;b=b?`${a.name}/${b}`:a.name;a=a.parent}}function jb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%S.length}function kb(a){var b=jb(a.parent.id,a.name);if(S[b]===a)S[b]=a.Yb;else for(b=S[b];b;){if(b.Yb===a){b.Yb=a.Yb;break}b=b.Yb}}
|
||||
function $a(a,b){var c;if(c=(c=lb(a,"x"))?c:a.Cb.$b?0:2)throw new P(c,a);for(c=S[jb(a.id,b)];c;c=c.Yb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Cb.$b(a,b)}function Ya(a,b,c,d){a=new mb(a,b,c,d);b=jb(a.parent.id,a.name);a.Yb=S[b];return S[b]=a}function R(a){return 16384===(a&61440)}function nb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}
|
||||
function lb(a,b){if(gb)return 0;if(!b.includes("r")||a.mode&292){if(b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73))return 2}else return 2;return 0}function ob(a,b){try{return $a(a,b),20}catch(c){}return lb(a,"wx")}function pb(a,b,c){try{var d=$a(a,b)}catch(e){return e.Kb}if(a=lb(a,"wx"))return a;if(c){if(!R(d.mode))return 54;if(d===d.parent||"/"===ib(d))return 10}else if(R(d.mode))return 31;return 0}function qb(){for(var a=0;4096>=a;a++)if(!eb[a])return a;throw new P(33);}
|
||||
function V(a){a=eb[a];if(!a)throw new P(8);return a}function rb(a,b=-1){sb||(sb=function(){this.dc={}},sb.prototype={},Object.defineProperties(sb.prototype,{object:{get(){return this.node},set(c){this.node=c}},flags:{get(){return this.dc.flags},set(c){this.dc.flags=c}},position:{get(){return this.dc.position},set(c){this.dc.position=c}}}));a=Object.assign(new sb,a);-1==b&&(b=qb());a.Sb=b;return eb[b]=a}var Xa={open(a){a.Ib=db[a.node.bc].Ib;a.Ib.open&&a.Ib.open(a)},Vb(){throw new P(70);}};
|
||||
function Sa(a,b){db[a]={Ib:b}}function tb(a,b){var c="/"===b,d=!b;if(c&&cb)throw new P(10);if(!c&&!d){var e=T(b,{rc:!1});b=e.path;e=e.node;if(e.Xb)throw new P(10);if(!R(e.mode))throw new P(54);}b={type:a,Wc:{},uc:b,Gc:[]};a=a.Rb(b);a.Rb=b;b.root=a;c?cb=a:e&&(e.Xb=b,e.Rb&&e.Rb.Gc.push(b))}function ub(a,b,c){var d=T(a,{parent:!0}).node;a=La(a);if(!a||"."===a||".."===a)throw new P(28);var e=ob(d,a);if(e)throw new P(e);if(!d.Cb.ec)throw new P(63);return d.Cb.ec(d,a,b,c)}
|
||||
function W(a,b){return ub(a,(void 0!==b?b:511)&1023|16384,0)}function vb(a,b,c){"undefined"==typeof c&&(c=b,b=438);ub(a,b|8192,c)}function wb(a,b){if(!Oa(a))throw new P(44);var c=T(b,{parent:!0}).node;if(!c)throw new P(44);b=La(b);var d=ob(c,b);if(d)throw new P(d);if(!c.Cb.jc)throw new P(63);c.Cb.jc(c,b,a)}function xb(a){var b=T(a,{parent:!0}).node;a=La(a);var c=$a(b,a),d=pb(b,a,!0);if(d)throw new P(d);if(!b.Cb.ic)throw new P(63);if(c.Xb)throw new P(10);b.Cb.ic(b,a);kb(c)}
|
||||
function hb(a){a=T(a).node;if(!a)throw new P(44);if(!a.Cb.cc)throw new P(28);return Oa(ib(a.parent),a.Cb.cc(a))}function yb(a,b){a=T(a,{Ub:!b}).node;if(!a)throw new P(44);if(!a.Cb.Pb)throw new P(63);return a.Cb.Pb(a)}function zb(a){return yb(a,!0)}function Ab(a,b){a="string"==typeof a?T(a,{Ub:!0}).node:a;if(!a.Cb.Mb)throw new P(63);a.Cb.Mb(a,{mode:b&4095|a.mode&-4096,timestamp:Date.now()})}
|
||||
function Bb(a,b){if(0>b)throw new P(28);a="string"==typeof a?T(a,{Ub:!0}).node:a;if(!a.Cb.Mb)throw new P(63);if(R(a.mode))throw new P(31);if(32768!==(a.mode&61440))throw new P(28);var c=lb(a,"w");if(c)throw new P(c);a.Cb.Mb(a,{size:b,timestamp:Date.now()})}
|
||||
function Cb(a,b,c){if(""===a)throw new P(44);if("string"==typeof b){var d={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[b];if("undefined"==typeof d)throw Error(`Unknown file open mode: ${b}`);b=d}c=b&64?("undefined"==typeof c?438:c)&4095|32768:0;if("object"==typeof a)var e=a;else{a=M(a);try{e=T(a,{Ub:!(b&131072)}).node}catch(h){}}d=!1;if(b&64)if(e){if(b&128)throw new P(20);}else e=ub(a,c,0),d=!0;if(!e)throw new P(44);8192===(e.mode&61440)&&(b&=-513);if(b&65536&&!R(e.mode))throw new P(54);if(!d&&(c=
|
||||
e?40960===(e.mode&61440)?32:R(e.mode)&&("r"!==nb(b)||b&512)?31:lb(e,nb(b)):44))throw new P(c);b&512&&!d&&Bb(e,0);b&=-131713;e=rb({node:e,path:ib(e),flags:b,seekable:!0,position:0,Ib:e.Ib,Lc:[],error:!1});e.Ib.open&&e.Ib.open(e);!f.logReadFiles||b&1||(Db||(Db={}),a in Db||(Db[a]=1));return e}function Eb(a,b,c){if(null===a.Sb)throw new P(8);if(!a.seekable||!a.Ib.Vb)throw new P(70);if(0!=c&&1!=c&&2!=c)throw new P(28);a.position=a.Ib.Vb(a,b,c);a.Lc=[]}
|
||||
function Fb(){P||(P=function(a,b){this.name="ErrnoError";this.node=b;this.Kc=function(c){this.Kb=c};this.Kc(a);this.message="FS error"},P.prototype=Error(),P.prototype.constructor=P,[44].forEach(a=>{Za[a]=new P(a);Za[a].stack="<generic error, no stack>"}))}var Gb;
|
||||
function Hb(a,b,c){a=M("/dev/"+a);var d=bb(!!b,!!c);Ib||(Ib=64);var e=Ib++<<8|0;Sa(e,{open(h){h.seekable=!1},close(){c&&c.buffer&&c.buffer.length&&c(10)},read(h,g,m,l){for(var k=0,p=0;p<l;p++){try{var n=b()}catch(r){throw new P(29);}if(void 0===n&&0===k)throw new P(6);if(null===n||void 0===n)break;k++;g[m+p]=n}k&&(h.node.timestamp=Date.now());return k},write(h,g,m,l){for(var k=0;k<l;k++)try{c(g[m+k])}catch(p){throw new P(29);}l&&(h.node.timestamp=Date.now());return k}});vb(a,d,e)}var Ib,X={},sb,Db;
|
||||
function Jb(a,b,c){if("/"===b.charAt(0))return b;a=-100===a?"/":V(a).path;if(0==b.length){if(!c)throw new P(44);return a}return M(a+"/"+b)}
|
||||
function Kb(a,b,c){try{var d=a(b)}catch(h){if(h&&h.node&&M(b)!==M(ib(h.node)))return-54;throw h;}x[c>>2]=d.Cc;x[c+4>>2]=d.mode;z[c+8>>2]=d.Ic;x[c+12>>2]=d.uid;x[c+16>>2]=d.Ec;x[c+20>>2]=d.bc;F=[d.size>>>0,(D=d.size,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];x[c+24>>2]=F[0];x[c+28>>2]=F[1];x[c+32>>2]=4096;x[c+36>>2]=d.Ac;a=d.yc.getTime();b=d.Hc.getTime();var e=d.Bc.getTime();F=[Math.floor(a/1E3)>>>0,(D=Math.floor(a/1E3),1<=+Math.abs(D)?0<D?+Math.floor(D/
|
||||
4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];x[c+40>>2]=F[0];x[c+44>>2]=F[1];z[c+48>>2]=a%1E3*1E3;F=[Math.floor(b/1E3)>>>0,(D=Math.floor(b/1E3),1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];x[c+56>>2]=F[0];x[c+60>>2]=F[1];z[c+64>>2]=b%1E3*1E3;F=[Math.floor(e/1E3)>>>0,(D=Math.floor(e/1E3),1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];x[c+72>>2]=F[0];x[c+76>>2]=F[1];z[c+80>>2]=
|
||||
e%1E3*1E3;F=[d.tc>>>0,(D=d.tc,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];x[c+88>>2]=F[0];x[c+92>>2]=F[1];return 0}var Lb=void 0;function Mb(){var a=x[+Lb>>2];Lb+=4;return a}
|
||||
var Nb=(a,b)=>b+2097152>>>0<4194305-!!a?(a>>>0)+4294967296*b:NaN,Ob=[0,31,60,91,121,152,182,213,244,274,305,335],Pb=[0,31,59,90,120,151,181,212,243,273,304,334],Rb=a=>{var b=N(a)+1,c=Qb(b);c&&O(a,w,c,b);return c},Sb={},Ub=()=>{if(!Tb){var a={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",_:ea||"./this.program"},b;for(b in Sb)void 0===Sb[b]?delete a[b]:a[b]=Sb[b];
|
||||
var c=[];for(b in a)c.push(`${b}=${a[b]}`);Tb=c}return Tb},Tb;function Vb(){}function Wb(){}function Xb(){}function Yb(){}function Zb(){}function $b(){}function ac(){}function bc(){}function cc(){}function dc(){}function ec(){}function fc(){}function gc(){}function hc(){}function ic(){}function jc(){}function kc(){}function lc(){}function mc(){}function nc(){}function oc(){}function pc(){}function qc(){}function rc(){}function sc(){}function tc(){}function uc(){}function vc(){}function wc(){}
|
||||
function xc(){}function yc(){}function zc(){}function Ac(){}function Bc(){}function Cc(){}function Dc(){}function Ec(){}function Fc(){}function Gc(){}
|
||||
var Y=(a,b,c,d)=>{var e={string:k=>{var p=0;if(null!==k&&void 0!==k&&0!==k){p=N(k)+1;var n=Hc(p);O(k,w,n,p);p=n}return p},array:k=>{var p=Hc(k.length);v.set(k,p);return p}};a=f["_"+a];var h=[],g=0;if(d)for(var m=0;m<d.length;m++){var l=e[c[m]];l?(0===g&&(g=Ic()),h[m]=l(d[m])):h[m]=d[m]}c=a.apply(null,h);return c=function(k){0!==g&&Jc(g);return"string"===b?k?K(w,k):"":"boolean"===b?!!k:k}(c)};
|
||||
function mb(a,b,c,d){a||(a=this);this.parent=a;this.Rb=a.Rb;this.Xb=null;this.id=fb++;this.name=b;this.mode=c;this.Cb={};this.Ib={};this.bc=d}Object.defineProperties(mb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Fb();S=Array(4096);tb(Q,"/");W("/tmp");W("/home");W("/home/web_user");
|
||||
(function(){W("/dev");Sa(259,{read:()=>0,write:(d,e,h,g)=>g});vb("/dev/null",259);Ra(1280,Ua);Ra(1536,Va);vb("/dev/tty",1280);vb("/dev/tty1",1536);var a=new Uint8Array(1024),b=0,c=()=>{0===b&&(b=Na(a).byteLength);return a[--b]};Hb("random",c);Hb("urandom",c);W("/dev/shm");W("/dev/shm/tmp")})();
|
||||
(function(){W("/proc");var a=W("/proc/self");W("/proc/self/fd");tb({Rb(){var b=Ya(a,"fd",16895,73);b.Cb={$b(c,d){var e=V(+d);c={parent:null,Rb:{uc:"fake"},Cb:{cc:()=>e.path}};return c.parent=c}};return b}},"/proc/self/fd")})();
|
||||
(function(){const a=new Map;f.setAuthorizer=function(b,c,d){c?a.set(b,{f:c,oc:d}):a.delete(b);return Y("set_authorizer","number",["number"],[b])};Vb=function(b,c,d,e,h,g){if(a.has(b)){const {f:m,oc:l}=a.get(b);return m(l,c,d?d?K(w,d):"":null,e?e?K(w,e):"":null,h?h?K(w,h):"":null,g?g?K(w,g):"":null)}return 0}})();
|
||||
(function(){const a=new Map,b=new Map;f.createFunction=function(c,d,e,h,g,m){const l=a.size;a.set(l,{f:m,Tb:g});return Y("create_function","number","number string number number number number".split(" "),[c,d,e,h,l,0])};f.createAggregate=function(c,d,e,h,g,m,l){const k=a.size;a.set(k,{step:m,Dc:l,Tb:g});return Y("create_function","number","number string number number number number".split(" "),[c,d,e,h,k,1])};f.getFunctionUserData=function(c){return b.get(c)};Xb=function(c,d,e,h){c=a.get(c);b.set(d,
|
||||
c.Tb);c.f(d,new Uint32Array(w.buffer,h,e));b.delete(d)};Zb=function(c,d,e,h){c=a.get(c);b.set(d,c.Tb);c.step(d,new Uint32Array(w.buffer,h,e));b.delete(d)};Wb=function(c,d){c=a.get(c);b.set(d,c.Tb);c.Dc(d);b.delete(d)}})();(function(){const a=new Map;f.progressHandler=function(b,c,d,e){d?a.set(b,{f:d,oc:e}):a.delete(b);return Y("progress_handler",null,["number","number"],[b,c])};Yb=function(b){if(a.has(b)){const {f:c,oc:d}=a.get(b);return c(d)}return 0}})();
|
||||
(function(){function a(l,k){const p=`get${l}`,n=`set${l}`;return new Proxy(new DataView(w.buffer,k,"Int32"===l?4:8),{get(r,y){if(y===p)return function(A,G){if(!G)throw Error("must be little endian");return r[y](A,G)};if(y===n)return function(A,G,E){if(!E)throw Error("must be little endian");return r[y](A,G,E)};if("string"===typeof y&&y.match(/^(get)|(set)/))throw Error("invalid type");return r[y]}})}const b="object"===typeof Asyncify,c=new Map,d=new Map,e=new Map,h=b?new Set:null,g=b?new Set:null,
|
||||
m=new Map;pc=function(l,k,p,n){m.set(l?K(w,l):"",{size:k,ac:Array.from(new Uint32Array(w.buffer,n,p))})};f.createModule=function(l,k,p,n){b&&(p.handleAsync=Asyncify.Fc);const r=c.size;c.set(r,{module:p,Tb:n});n=0;p.xCreate&&(n|=1);p.xConnect&&(n|=2);p.xBestIndex&&(n|=4);p.xDisconnect&&(n|=8);p.xDestroy&&(n|=16);p.xOpen&&(n|=32);p.xClose&&(n|=64);p.xFilter&&(n|=128);p.xNext&&(n|=256);p.xEof&&(n|=512);p.xColumn&&(n|=1024);p.xRowid&&(n|=2048);p.xUpdate&&(n|=4096);p.xBegin&&(n|=8192);p.xSync&&(n|=16384);
|
||||
p.xCommit&&(n|=32768);p.xRollback&&(n|=65536);p.xFindFunction&&(n|=131072);p.xRename&&(n|=262144);return Y("create_module","number",["number","string","number","number"],[l,k,r,n])};fc=function(l,k,p,n,r,y){k=c.get(k);d.set(r,k);if(b){h.delete(r);for(const A of h)d.delete(A)}n=Array.from(new Uint32Array(w.buffer,n,p)).map(A=>A?K(w,A):"");return k.module.xCreate(l,k.Tb,n,r,a("Int32",y))};ec=function(l,k,p,n,r,y){k=c.get(k);d.set(r,k);if(b){h.delete(r);for(const A of h)d.delete(A)}n=Array.from(new Uint32Array(w.buffer,
|
||||
n,p)).map(A=>A?K(w,A):"");return k.module.xConnect(l,k.Tb,n,r,a("Int32",y))};ac=function(l,k){var p=d.get(l),n=m.get("sqlite3_index_info").ac;const r={};r.nConstraint=I(k+n[0],"i32");r.aConstraint=[];var y=I(k+n[1],"*"),A=m.get("sqlite3_index_constraint").size;for(var G=0;G<r.nConstraint;++G){var E=r.aConstraint,L=E.push,H=y+G*A,da=m.get("sqlite3_index_constraint").ac,U={};U.iColumn=I(H+da[0],"i32");U.op=I(H+da[1],"i8");U.usable=!!I(H+da[2],"i8");L.call(E,U)}r.nOrderBy=I(k+n[2],"i32");r.aOrderBy=
|
||||
[];y=I(k+n[3],"*");A=m.get("sqlite3_index_orderby").size;for(G=0;G<r.nOrderBy;++G)E=r.aOrderBy,L=E.push,H=y+G*A,da=m.get("sqlite3_index_orderby").ac,U={},U.iColumn=I(H+da[0],"i32"),U.desc=!!I(H+da[1],"i8"),L.call(E,U);r.aConstraintUsage=[];for(y=0;y<r.nConstraint;++y)r.aConstraintUsage.push({argvIndex:0,omit:!1});r.idxNum=I(k+n[5],"i32");r.idxStr=null;r.orderByConsumed=!!I(k+n[8],"i8");r.estimatedCost=I(k+n[9],"double");r.estimatedRows=I(k+n[10],"i32");r.idxFlags=I(k+n[11],"i32");r.colUsed=I(k+n[12],
|
||||
"i32");l=p.module.xBestIndex(l,r);p=m.get("sqlite3_index_info").ac;n=I(k+p[4],"*");y=m.get("sqlite3_index_constraint_usage").size;for(L=0;L<r.nConstraint;++L)A=n+L*y,E=r.aConstraintUsage[L],H=m.get("sqlite3_index_constraint_usage").ac,J(A+H[0],E.argvIndex,"i32"),J(A+H[1],E.omit?1:0,"i8");J(k+p[5],r.idxNum,"i32");"string"===typeof r.idxStr&&(n=N(r.idxStr),y=Y("sqlite3_malloc","number",["number"],[n+1]),O(r.idxStr,w,y,n+1),J(k+p[6],y,"*"),J(k+p[7],1,"i32"));J(k+p[8],r.orderByConsumed,"i32");J(k+p[9],
|
||||
r.estimatedCost,"double");J(k+p[10],r.estimatedRows,"i32");J(k+p[11],r.idxFlags,"i32");return l};hc=function(l){const k=d.get(l);b?h.add(l):d.delete(l);return k.module.xDisconnect(l)};gc=function(l){const k=d.get(l);b?h.add(l):d.delete(l);return k.module.xDestroy(l)};lc=function(l,k){const p=d.get(l);e.set(k,p);if(b){g.delete(k);for(const n of g)e.delete(n)}return p.module.xOpen(l,k)};bc=function(l){const k=e.get(l);b?g.add(l):e.delete(l);return k.module.xClose(l)};ic=function(l){return e.get(l).module.xEof(l)?
|
||||
1:0};jc=function(l,k,p,n,r){const y=e.get(l);p=p?p?K(w,p):"":null;r=new Uint32Array(w.buffer,r,n);return y.module.xFilter(l,k,p,r)};kc=function(l){return e.get(l).module.xNext(l)};cc=function(l,k,p){return e.get(l).module.xColumn(l,k,p)};oc=function(l,k){return e.get(l).module.xRowid(l,a("BigInt64",k))};rc=function(l,k,p,n){const r=d.get(l);p=new Uint32Array(w.buffer,p,k);return r.module.xUpdate(l,p,a("BigInt64",n))};$b=function(l){return d.get(l).module.xBegin(l)};qc=function(l){return d.get(l).module.xSync(l)};
|
||||
dc=function(l){return d.get(l).module.xCommit(l)};nc=function(l){return d.get(l).module.xRollback(l)};mc=function(l,k){const p=d.get(l);k=k?K(w,k):"";return p.module.xRename(l,k)}})();
|
||||
(function(){function a(g,m){const l=`get${g}`,k=`set${g}`;return new Proxy(new DataView(w.buffer,m,"Int32"===g?4:8),{get(p,n){if(n===l)return function(r,y){if(!y)throw Error("must be little endian");return p[n](r,y)};if(n===k)return function(r,y,A){if(!A)throw Error("must be little endian");return p[n](r,y,A)};if("string"===typeof n&&n.match(/^(get)|(set)/))throw Error("invalid type");return p[n]}})}function b(g){g>>=2;return z[g]+z[g+1]*2**32}const c="object"===typeof Asyncify,d=new Map,e=new Map;
|
||||
f.registerVFS=function(g,m){if(Y("sqlite3_vfs_find","number",["string"],[g.name]))throw Error(`VFS '${g.name}' already registered`);c&&(g.handleAsync=Asyncify.Fc);var l=g.Vc??64;const k=f._malloc(4);m=Y("register_vfs","number",["string","number","number","number"],[g.name,l,m?1:0,k]);m||(l=I(k,"*"),d.set(l,g));f._free(k);return m};const h=c?new Set:null;uc=function(g){const m=e.get(g);c?h.add(g):e.delete(g);return m.xClose(g)};Bc=function(g,m,l,k){return e.get(g).xRead(g,w.subarray(m,m+l),b(k))};
|
||||
Gc=function(g,m,l,k){return e.get(g).xWrite(g,w.subarray(m,m+l),b(k))};Ec=function(g,m){return e.get(g).xTruncate(g,b(m))};Dc=function(g,m){return e.get(g).xSync(g,m)};yc=function(g,m){const l=e.get(g);m=a("BigInt64",m);return l.xFileSize(g,m)};zc=function(g,m){return e.get(g).xLock(g,m)};Fc=function(g,m){return e.get(g).xUnlock(g,m)};tc=function(g,m){const l=e.get(g);m=a("Int32",m);return l.xCheckReservedLock(g,m)};xc=function(g,m,l){const k=e.get(g);l=new DataView(w.buffer,l);return k.xFileControl(g,
|
||||
m,l)};Cc=function(g){return e.get(g).xSectorSize(g)};wc=function(g){return e.get(g).xDeviceCharacteristics(g)};Ac=function(g,m,l,k,p){g=d.get(g);e.set(l,g);if(c){h.delete(l);for(var n of h)e.delete(n)}n=null;if(k&64){n=1;const r=[];for(;n;){const y=w[m++];if(y)r.push(y);else switch(w[m]||(n=null),n){case 1:r.push(63);n=2;break;case 2:r.push(61);n=3;break;case 3:r.push(38),n=2}}n=(new TextDecoder).decode(new Uint8Array(r))}else m&&(n=m?K(w,m):"");p=a("Int32",p);return g.xOpen(n,l,k,p)};vc=function(g,
|
||||
m,l){return d.get(g).xDelete(m?K(w,m):"",l)};sc=function(g,m,l,k){g=d.get(g);k=a("Int32",k);return g.xAccess(m?K(w,m):"",l,k)}})();
|
||||
var Lc={a:(a,b,c,d)=>{u(`Assertion failed: ${a?K(w,a):""}, at: `+[b?b?K(w,b):"":"unknown filename",c,d?d?K(w,d):"":"unknown function"])},K:function(a,b){try{return a=a?K(w,a):"",Ab(a,b),0}catch(c){if("undefined"==typeof X||"ErrnoError"!==c.name)throw c;return-c.Kb}},M:function(a,b,c){try{b=b?K(w,b):"";b=Jb(a,b);if(c&-8)return-28;var d=T(b,{Ub:!0}).node;if(!d)return-44;a="";c&4&&(a+="r");c&2&&(a+="w");c&1&&(a+="x");return a&&lb(d,a)?-2:0}catch(e){if("undefined"==typeof X||"ErrnoError"!==e.name)throw e;
|
||||
return-e.Kb}},L:function(a,b){try{var c=V(a);Ab(c.node,b);return 0}catch(d){if("undefined"==typeof X||"ErrnoError"!==d.name)throw d;return-d.Kb}},J:function(a){try{var b=V(a).node;var c="string"==typeof b?T(b,{Ub:!0}).node:b;if(!c.Cb.Mb)throw new P(63);c.Cb.Mb(c,{timestamp:Date.now()});return 0}catch(d){if("undefined"==typeof X||"ErrnoError"!==d.name)throw d;return-d.Kb}},b:function(a,b,c){Lb=c;try{var d=V(a);switch(b){case 0:var e=Mb();if(0>e)return-28;for(;eb[e];)e++;return rb(d,e).Sb;case 1:case 2:return 0;
|
||||
case 3:return d.flags;case 4:return e=Mb(),d.flags|=e,0;case 5:return e=Mb(),oa[e+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return x[Kc()>>2]=28,-1;default:return-28}}catch(h){if("undefined"==typeof X||"ErrnoError"!==h.name)throw h;return-h.Kb}},I:function(a,b){try{var c=V(a);return Kb(yb,c.path,b)}catch(d){if("undefined"==typeof X||"ErrnoError"!==d.name)throw d;return-d.Kb}},n:function(a,b,c){b=Nb(b,c);try{if(isNaN(b))return 61;var d=V(a);if(0===(d.flags&2097155))throw new P(28);
|
||||
Bb(d.node,b);return 0}catch(e){if("undefined"==typeof X||"ErrnoError"!==e.name)throw e;return-e.Kb}},C:function(a,b){try{if(0===b)return-28;var c=N("/")+1;if(b<c)return-68;O("/",w,a,b);return c}catch(d){if("undefined"==typeof X||"ErrnoError"!==d.name)throw d;return-d.Kb}},F:function(a,b){try{return a=a?K(w,a):"",Kb(zb,a,b)}catch(c){if("undefined"==typeof X||"ErrnoError"!==c.name)throw c;return-c.Kb}},z:function(a,b,c){try{return b=b?K(w,b):"",b=Jb(a,b),b=M(b),"/"===b[b.length-1]&&(b=b.substr(0,b.length-
|
||||
1)),W(b,c),0}catch(d){if("undefined"==typeof X||"ErrnoError"!==d.name)throw d;return-d.Kb}},E:function(a,b,c,d){try{b=b?K(w,b):"";var e=d&256;b=Jb(a,b,d&4096);return Kb(e?zb:yb,b,c)}catch(h){if("undefined"==typeof X||"ErrnoError"!==h.name)throw h;return-h.Kb}},y:function(a,b,c,d){Lb=d;try{b=b?K(w,b):"";b=Jb(a,b);var e=d?Mb():0;return Cb(b,c,e).Sb}catch(h){if("undefined"==typeof X||"ErrnoError"!==h.name)throw h;return-h.Kb}},w:function(a,b,c,d){try{b=b?K(w,b):"";b=Jb(a,b);if(0>=d)return-28;var e=hb(b),
|
||||
h=Math.min(d,N(e)),g=v[c+h];O(e,w,c,d+1);v[c+h]=g;return h}catch(m){if("undefined"==typeof X||"ErrnoError"!==m.name)throw m;return-m.Kb}},u:function(a){try{return a=a?K(w,a):"",xb(a),0}catch(b){if("undefined"==typeof X||"ErrnoError"!==b.name)throw b;return-b.Kb}},H:function(a,b){try{return a=a?K(w,a):"",Kb(yb,a,b)}catch(c){if("undefined"==typeof X||"ErrnoError"!==c.name)throw c;return-c.Kb}},r:function(a,b,c){try{b=b?K(w,b):"";b=Jb(a,b);if(0===c){a=b;var d=T(a,{parent:!0}).node;if(!d)throw new P(44);
|
||||
var e=La(a),h=$a(d,e),g=pb(d,e,!1);if(g)throw new P(g);if(!d.Cb.kc)throw new P(63);if(h.Xb)throw new P(10);d.Cb.kc(d,e);kb(h)}else 512===c?xb(b):u("Invalid flags passed to unlinkat");return 0}catch(m){if("undefined"==typeof X||"ErrnoError"!==m.name)throw m;return-m.Kb}},q:function(a,b,c){try{b=b?K(w,b):"";b=Jb(a,b,!0);if(c){var d=z[c>>2]+4294967296*x[c+4>>2],e=x[c+8>>2];h=1E3*d+e/1E6;c+=16;d=z[c>>2]+4294967296*x[c+4>>2];e=x[c+8>>2];g=1E3*d+e/1E6}else var h=Date.now(),g=h;a=h;var m=T(b,{Ub:!0}).node;
|
||||
m.Cb.Mb(m,{timestamp:Math.max(a,g)});return 0}catch(l){if("undefined"==typeof X||"ErrnoError"!==l.name)throw l;return-l.Kb}},l:function(a,b,c){a=new Date(1E3*Nb(a,b));x[c>>2]=a.getSeconds();x[c+4>>2]=a.getMinutes();x[c+8>>2]=a.getHours();x[c+12>>2]=a.getDate();x[c+16>>2]=a.getMonth();x[c+20>>2]=a.getFullYear()-1900;x[c+24>>2]=a.getDay();b=a.getFullYear();x[c+28>>2]=(0!==b%4||0===b%100&&0!==b%400?Pb:Ob)[a.getMonth()]+a.getDate()-1|0;x[c+36>>2]=-(60*a.getTimezoneOffset());b=(new Date(a.getFullYear(),
|
||||
6,1)).getTimezoneOffset();var d=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();x[c+32>>2]=(b!=d&&a.getTimezoneOffset()==Math.min(d,b))|0},i:function(a,b,c,d,e,h,g,m){e=Nb(e,h);try{if(isNaN(e))return 61;var l=V(d);if(0!==(b&2)&&0===(c&2)&&2!==(l.flags&2097155))throw new P(2);if(1===(l.flags&2097155))throw new P(2);if(!l.Ib.fc)throw new P(43);var k=l.Ib.fc(l,a,e,b,c);var p=k.Jc;x[g>>2]=k.xc;z[m>>2]=p;return 0}catch(n){if("undefined"==typeof X||"ErrnoError"!==n.name)throw n;return-n.Kb}},j:function(a,
|
||||
b,c,d,e,h,g){h=Nb(h,g);try{if(isNaN(h))return 61;var m=V(e);if(c&2){if(32768!==(m.node.mode&61440))throw new P(43);d&2||m.Ib.hc&&m.Ib.hc(m,w.slice(a,a+b),h,b,d)}}catch(l){if("undefined"==typeof X||"ErrnoError"!==l.name)throw l;return-l.Kb}},s:(a,b,c)=>{function d(l){return(l=l.toTimeString().match(/\(([A-Za-z ]+)\)$/))?l[1]:"GMT"}var e=(new Date).getFullYear(),h=new Date(e,0,1),g=new Date(e,6,1);e=h.getTimezoneOffset();var m=g.getTimezoneOffset();z[a>>2]=60*Math.max(e,m);x[b>>2]=Number(e!=m);a=d(h);
|
||||
b=d(g);a=Rb(a);b=Rb(b);m<e?(z[c>>2]=a,z[c+4>>2]=b):(z[c>>2]=b,z[c+4>>2]=a)},e:()=>Date.now(),d:()=>performance.now(),o:a=>{var b=w.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);var e=Math;d=Math.max(a,d);a:{e=(e.min.call(e,2147483648,d+(65536-d%65536)%65536)-ma.buffer.byteLength+65535)/65536;try{ma.grow(e);ra();var h=1;break a}catch(g){}h=void 0}if(h)return!0}return!1},A:(a,b)=>{var c=0;Ub().forEach((d,e)=>{var h=b+c;e=z[a+4*e>>2]=h;for(h=
|
||||
0;h<d.length;++h)v[e++>>0]=d.charCodeAt(h);v[e>>0]=0;c+=d.length+1});return 0},B:(a,b)=>{var c=Ub();z[a>>2]=c.length;var d=0;c.forEach(e=>d+=e.length+1);z[b>>2]=d;return 0},f:function(a){try{var b=V(a);if(null===b.Sb)throw new P(8);b.lc&&(b.lc=null);try{b.Ib.close&&b.Ib.close(b)}catch(c){throw c;}finally{eb[b.Sb]=null}b.Sb=null;return 0}catch(c){if("undefined"==typeof X||"ErrnoError"!==c.name)throw c;return c.Kb}},p:function(a,b){try{var c=V(a);v[b>>0]=c.Ob?2:R(c.mode)?3:40960===(c.mode&61440)?7:
|
||||
4;oa[b+2>>1]=0;F=[0,(D=0,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];x[b+8>>2]=F[0];x[b+12>>2]=F[1];F=[0,(D=0,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];x[b+16>>2]=F[0];x[b+20>>2]=F[1];return 0}catch(d){if("undefined"==typeof X||"ErrnoError"!==d.name)throw d;return d.Kb}},x:function(a,b,c,d){try{a:{var e=V(a);a=b;for(var h,g=b=0;g<c;g++){var m=z[a>>2],l=z[a+4>>2];a+=8;var k=e,p=m,n=l,r=h,y=
|
||||
v;if(0>n||0>r)throw new P(28);if(null===k.Sb)throw new P(8);if(1===(k.flags&2097155))throw new P(8);if(R(k.node.mode))throw new P(31);if(!k.Ib.read)throw new P(28);var A="undefined"!=typeof r;if(!A)r=k.position;else if(!k.seekable)throw new P(70);var G=k.Ib.read(k,y,p,n,r);A||(k.position+=G);var E=G;if(0>E){var L=-1;break a}b+=E;if(E<l)break;"undefined"!==typeof h&&(h+=E)}L=b}z[d>>2]=L;return 0}catch(H){if("undefined"==typeof X||"ErrnoError"!==H.name)throw H;return H.Kb}},m:function(a,b,c,d,e){b=
|
||||
Nb(b,c);try{if(isNaN(b))return 61;var h=V(a);Eb(h,b,d);F=[h.position>>>0,(D=h.position,1<=+Math.abs(D)?0<D?+Math.floor(D/4294967296)>>>0:~~+Math.ceil((D-+(~~D>>>0))/4294967296)>>>0:0)];x[e>>2]=F[0];x[e+4>>2]=F[1];h.lc&&0===b&&0===d&&(h.lc=null);return 0}catch(g){if("undefined"==typeof X||"ErrnoError"!==g.name)throw g;return g.Kb}},D:function(a){try{var b=V(a);return b.Ib&&b.Ib.Wb?b.Ib.Wb(b):0}catch(c){if("undefined"==typeof X||"ErrnoError"!==c.name)throw c;return c.Kb}},t:function(a,b,c,d){try{a:{var e=
|
||||
V(a);a=b;for(var h,g=b=0;g<c;g++){var m=z[a>>2],l=z[a+4>>2];a+=8;var k=e,p=m,n=l,r=h,y=v;if(0>n||0>r)throw new P(28);if(null===k.Sb)throw new P(8);if(0===(k.flags&2097155))throw new P(8);if(R(k.node.mode))throw new P(31);if(!k.Ib.write)throw new P(28);k.seekable&&k.flags&1024&&Eb(k,0,2);var A="undefined"!=typeof r;if(!A)r=k.position;else if(!k.seekable)throw new P(70);var G=k.Ib.write(k,y,p,n,r,void 0);A||(k.position+=G);var E=G;if(0>E){var L=-1;break a}b+=E;"undefined"!==typeof h&&(h+=E)}L=b}z[d>>
|
||||
2]=L;return 0}catch(H){if("undefined"==typeof X||"ErrnoError"!==H.name)throw H;return H.Kb}},ra:Vb,N:Wb,ga:Xb,ca:Yb,Y:Zb,la:$b,G:ac,h:bc,oa:cc,ja:dc,ea:ec,fa:fc,k:gc,v:hc,pa:ic,g:jc,qa:kc,da:lc,ha:mc,ia:nc,na:oc,c:pc,ka:qc,ma:rc,aa:sc,V:tc,$:uc,ba:vc,S:wc,U:xc,Z:yc,X:zc,R:Ac,Q:Bc,T:Cc,_:Dc,O:Ec,W:Fc,P:Gc},Z=function(){function a(c){Z=c.exports;ma=Z.sa;ra();ta.unshift(Z.ta);B--;f.monitorRunDependencies&&f.monitorRunDependencies(B);0==B&&(null!==xa&&(clearInterval(xa),xa=null),ya&&(c=ya,ya=null,c()));
|
||||
return Z}var b={a:Lc};B++;f.monitorRunDependencies&&f.monitorRunDependencies(B);if(f.instantiateWasm)try{return f.instantiateWasm(b,a)}catch(c){t(`Module.instantiateWasm callback failed with error: ${c}`),ba(c)}Ea(b,function(c){a(c.instance)}).catch(ba);return{}}();f._sqlite3_vfs_find=a=>(f._sqlite3_vfs_find=Z.ua)(a);f._sqlite3_malloc=a=>(f._sqlite3_malloc=Z.va)(a);f._sqlite3_free=a=>(f._sqlite3_free=Z.wa)(a);f._sqlite3_prepare_v2=(a,b,c,d,e)=>(f._sqlite3_prepare_v2=Z.xa)(a,b,c,d,e);
|
||||
f._sqlite3_step=a=>(f._sqlite3_step=Z.ya)(a);f._sqlite3_column_int64=(a,b)=>(f._sqlite3_column_int64=Z.za)(a,b);f._sqlite3_column_int=(a,b)=>(f._sqlite3_column_int=Z.Aa)(a,b);f._sqlite3_finalize=a=>(f._sqlite3_finalize=Z.Ba)(a);f._sqlite3_reset=a=>(f._sqlite3_reset=Z.Ca)(a);f._sqlite3_clear_bindings=a=>(f._sqlite3_clear_bindings=Z.Da)(a);f._sqlite3_value_blob=a=>(f._sqlite3_value_blob=Z.Ea)(a);f._sqlite3_value_text=a=>(f._sqlite3_value_text=Z.Fa)(a);
|
||||
f._sqlite3_value_bytes=a=>(f._sqlite3_value_bytes=Z.Ga)(a);f._sqlite3_value_double=a=>(f._sqlite3_value_double=Z.Ha)(a);f._sqlite3_value_int=a=>(f._sqlite3_value_int=Z.Ia)(a);f._sqlite3_value_int64=a=>(f._sqlite3_value_int64=Z.Ja)(a);f._sqlite3_value_type=a=>(f._sqlite3_value_type=Z.Ka)(a);f._sqlite3_result_blob=(a,b,c,d)=>(f._sqlite3_result_blob=Z.La)(a,b,c,d);f._sqlite3_result_double=(a,b)=>(f._sqlite3_result_double=Z.Ma)(a,b);
|
||||
f._sqlite3_result_error=(a,b,c)=>(f._sqlite3_result_error=Z.Na)(a,b,c);f._sqlite3_result_int=(a,b)=>(f._sqlite3_result_int=Z.Oa)(a,b);f._sqlite3_result_int64=(a,b,c)=>(f._sqlite3_result_int64=Z.Pa)(a,b,c);f._sqlite3_result_null=a=>(f._sqlite3_result_null=Z.Qa)(a);f._sqlite3_result_text=(a,b,c,d)=>(f._sqlite3_result_text=Z.Ra)(a,b,c,d);f._sqlite3_column_count=a=>(f._sqlite3_column_count=Z.Sa)(a);f._sqlite3_data_count=a=>(f._sqlite3_data_count=Z.Ta)(a);
|
||||
f._sqlite3_column_blob=(a,b)=>(f._sqlite3_column_blob=Z.Ua)(a,b);f._sqlite3_column_bytes=(a,b)=>(f._sqlite3_column_bytes=Z.Va)(a,b);f._sqlite3_column_double=(a,b)=>(f._sqlite3_column_double=Z.Wa)(a,b);f._sqlite3_column_text=(a,b)=>(f._sqlite3_column_text=Z.Xa)(a,b);f._sqlite3_column_type=(a,b)=>(f._sqlite3_column_type=Z.Ya)(a,b);f._sqlite3_column_name=(a,b)=>(f._sqlite3_column_name=Z.Za)(a,b);f._sqlite3_bind_blob=(a,b,c,d,e)=>(f._sqlite3_bind_blob=Z._a)(a,b,c,d,e);
|
||||
f._sqlite3_bind_double=(a,b,c)=>(f._sqlite3_bind_double=Z.$a)(a,b,c);f._sqlite3_bind_int=(a,b,c)=>(f._sqlite3_bind_int=Z.ab)(a,b,c);f._sqlite3_bind_int64=(a,b,c,d)=>(f._sqlite3_bind_int64=Z.bb)(a,b,c,d);f._sqlite3_bind_null=(a,b)=>(f._sqlite3_bind_null=Z.cb)(a,b);f._sqlite3_bind_text=(a,b,c,d,e)=>(f._sqlite3_bind_text=Z.db)(a,b,c,d,e);f._sqlite3_bind_parameter_count=a=>(f._sqlite3_bind_parameter_count=Z.eb)(a);f._sqlite3_bind_parameter_name=(a,b)=>(f._sqlite3_bind_parameter_name=Z.fb)(a,b);
|
||||
f._sqlite3_sql=a=>(f._sqlite3_sql=Z.gb)(a);f._sqlite3_exec=(a,b,c,d,e)=>(f._sqlite3_exec=Z.hb)(a,b,c,d,e);f._sqlite3_errmsg=a=>(f._sqlite3_errmsg=Z.ib)(a);f._sqlite3_declare_vtab=(a,b)=>(f._sqlite3_declare_vtab=Z.jb)(a,b);f._sqlite3_libversion=()=>(f._sqlite3_libversion=Z.kb)();f._sqlite3_libversion_number=()=>(f._sqlite3_libversion_number=Z.lb)();f._sqlite3_changes=a=>(f._sqlite3_changes=Z.mb)(a);f._sqlite3_close=a=>(f._sqlite3_close=Z.nb)(a);
|
||||
f._sqlite3_limit=(a,b,c)=>(f._sqlite3_limit=Z.ob)(a,b,c);f._sqlite3_open_v2=(a,b,c,d)=>(f._sqlite3_open_v2=Z.pb)(a,b,c,d);f._sqlite3_get_autocommit=a=>(f._sqlite3_get_autocommit=Z.qb)(a);var Kc=()=>(Kc=Z.rb)(),Qb=f._malloc=a=>(Qb=f._malloc=Z.sb)(a);f._free=a=>(f._free=Z.tb)(a);f._RegisterExtensionFunctions=a=>(f._RegisterExtensionFunctions=Z.ub)(a);f._set_authorizer=a=>(f._set_authorizer=Z.vb)(a);f._create_function=(a,b,c,d,e,h)=>(f._create_function=Z.wb)(a,b,c,d,e,h);
|
||||
f._create_module=(a,b,c,d)=>(f._create_module=Z.xb)(a,b,c,d);f._progress_handler=(a,b)=>(f._progress_handler=Z.yb)(a,b);f._register_vfs=(a,b,c,d)=>(f._register_vfs=Z.zb)(a,b,c,d);f._getSqliteFree=()=>(f._getSqliteFree=Z.Ab)();var Mc=f._main=(a,b)=>(Mc=f._main=Z.Bb)(a,b),ab=(a,b)=>(ab=Z.Db)(a,b),Nc=()=>(Nc=Z.Eb)(),Ic=()=>(Ic=Z.Fb)(),Jc=a=>(Jc=Z.Gb)(a),Hc=a=>(Hc=Z.Hb)(a);f.getTempRet0=Nc;f.ccall=Y;
|
||||
f.cwrap=(a,b,c,d)=>{var e=!c||c.every(h=>"number"===h||"boolean"===h);return"string"!==b&&e&&!d?f["_"+a]:function(){return Y(a,b,c,arguments,d)}};f.setValue=J;f.getValue=I;f.UTF8ToString=(a,b)=>a?K(w,a,b):"";f.stringToUTF8=(a,b,c)=>O(a,w,b,c);f.lengthBytesUTF8=N;var Oc;ya=function Pc(){Oc||Qc();Oc||(ya=Pc)};
|
||||
function Qc(){function a(){if(!Oc&&(Oc=!0,f.calledRun=!0,!na)){f.noFSInit||Gb||(Gb=!0,Fb(),f.stdin=f.stdin,f.stdout=f.stdout,f.stderr=f.stderr,f.stdin?Hb("stdin",f.stdin):wb("/dev/tty","/dev/stdin"),f.stdout?Hb("stdout",null,f.stdout):wb("/dev/tty","/dev/stdout"),f.stderr?Hb("stderr",null,f.stderr):wb("/dev/tty1","/dev/stderr"),Cb("/dev/stdin",0),Cb("/dev/stdout",1),Cb("/dev/stderr",1));gb=!1;Ga(ta);Ga(ua);aa(f);if(f.onRuntimeInitialized)f.onRuntimeInitialized();if(Rc){var b=Mc;try{var c=b(0,0);if(!Ha){if(f.onExit)f.onExit(c);
|
||||
na=!0}fa(c,new Fa(c))}catch(d){d instanceof Fa||"unwind"==d||fa(1,d)}}if(f.postRun)for("function"==typeof f.postRun&&(f.postRun=[f.postRun]);f.postRun.length;)b=f.postRun.shift(),va.unshift(b);Ga(va)}}if(!(0<B)){if(f.preRun)for("function"==typeof f.preRun&&(f.preRun=[f.preRun]);f.preRun.length;)wa();Ga(sa);0<B||(f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("")},1);a()},1)):a())}}
|
||||
if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);0<f.preInit.length;)f.preInit.pop()();var Rc=!0;f.noInitialRun&&(Rc=!1);Qc();
|
||||
var d=moduleArg,aa,ba;d.ready=new Promise((a,b)=>{aa=a;ba=b});var ca=Object.assign({},d),da="./this.program",ea=(a,b)=>{throw b;},fa="object"==typeof window,ha="function"==typeof importScripts,g="",ja;
|
||||
if(fa||ha)ha?g=self.location.href:"undefined"!=typeof document&&document.currentScript&&(g=document.currentScript.src),_scriptDir&&(g=_scriptDir),0!==g.indexOf("blob:")?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",ha&&(ja=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ka=d.print||console.log.bind(console),r=d.printErr||console.error.bind(console);Object.assign(d,ca);ca=null;d.thisProgram&&(da=d.thisProgram);
|
||||
d.quit&&(ea=d.quit);var la;d.wasmBinary&&(la=d.wasmBinary);"object"!=typeof WebAssembly&&u("no native wasm support detected");var ma,na=!1,v,w,x,oa,y,B,pa,qa;function ra(){var a=ma.buffer;d.HEAP8=v=new Int8Array(a);d.HEAP16=x=new Int16Array(a);d.HEAPU8=w=new Uint8Array(a);d.HEAPU16=oa=new Uint16Array(a);d.HEAP32=y=new Int32Array(a);d.HEAPU32=B=new Uint32Array(a);d.HEAPF32=pa=new Float32Array(a);d.HEAPF64=qa=new Float64Array(a)}var sa=[],ta=[],ua=[],va=[];
|
||||
function wa(){var a=d.preRun.shift();sa.unshift(a)}var C=0,xa=null,ya=null;function u(a){if(d.onAbort)d.onAbort(a);a="Aborted("+a+")";r(a);na=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");ba(a);throw a;}var za=a=>a.startsWith("data:application/octet-stream;base64,"),D;if(d.locateFile){if(D="wa-sqlite.wasm",!za(D)){var Aa=D;D=d.locateFile?d.locateFile(Aa,g):g+Aa}}else D=(new URL("wa-sqlite.wasm",import.meta.url)).href;
|
||||
function Ba(a){if(a==D&&la)return new Uint8Array(la);if(ja)return ja(a);throw"both async and sync fetching of the wasm failed";}function Ca(a){return la||!fa&&!ha||"function"!=typeof fetch?Promise.resolve().then(()=>Ba(a)):fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw"failed to load wasm binary file at '"+a+"'";return b.arrayBuffer()}).catch(()=>Ba(a))}
|
||||
function Da(a,b,c){return Ca(a).then(e=>WebAssembly.instantiate(e,b)).then(e=>e).then(c,e=>{r(`failed to asynchronously prepare wasm: ${e}`);u(e)})}function Ea(a,b){var c=D;return la||"function"!=typeof WebAssembly.instantiateStreaming||za(c)||"function"!=typeof fetch?Da(c,a,b):fetch(c,{credentials:"same-origin"}).then(e=>WebAssembly.instantiateStreaming(e,a).then(b,function(f){r(`wasm streaming compile failed: ${f}`);r("falling back to ArrayBuffer instantiation");return Da(c,a,b)}))}var F,H;
|
||||
function Fa(a){this.name="ExitStatus";this.message=`Program terminated with exit(${a})`;this.status=a}var Ga=a=>{for(;0<a.length;)a.shift()(d)};function J(a,b="i8"){b.endsWith("*")&&(b="*");switch(b){case "i1":return v[a>>0];case "i8":return v[a>>0];case "i16":return x[a>>1];case "i32":return y[a>>2];case "i64":u("to do getValue(i64) use WASM_BIGINT");case "float":return pa[a>>2];case "double":return qa[a>>3];case "*":return B[a>>2];default:u(`invalid type for getValue: ${b}`)}}
|
||||
var Ha=d.noExitRuntime||!0;function K(a,b,c="i8"){c.endsWith("*")&&(c="*");switch(c){case "i1":v[a>>0]=b;break;case "i8":v[a>>0]=b;break;case "i16":x[a>>1]=b;break;case "i32":y[a>>2]=b;break;case "i64":u("to do setValue(i64) use WASM_BIGINT");case "float":pa[a>>2]=b;break;case "double":qa[a>>3]=b;break;case "*":B[a>>2]=b;break;default:u(`invalid type for setValue: ${c}`)}}
|
||||
var Ia="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,M=(a,b,c)=>{var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.buffer&&Ia)return Ia.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var h=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|h);else{var k=a[b++]&63;f=224==(f&240)?(f&15)<<12|h<<6|k:(f&7)<<18|h<<12|k<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e},
|
||||
Ja=(a,b)=>{for(var c=0,e=a.length-1;0<=e;e--){var f=a[e];"."===f?a.splice(e,1):".."===f?(a.splice(e,1),c++):c&&(a.splice(e,1),c--)}if(b)for(;c;c--)a.unshift("..");return a},N=a=>{var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=Ja(a.split("/").filter(e=>!!e),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},Ka=a=>{var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b},La=a=>{if("/"===
|
||||
a)return"/";a=N(a);a=a.replace(/\/$/,"");var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)},Ma=()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return a=>crypto.getRandomValues(a);u("initRandomDevice")},Na=a=>(Na=Ma())(a);
|
||||
function Oa(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!=typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=Ja(a.split("/").filter(e=>!!e),!b).join("/");return(b?"/":"")+a||"."}
|
||||
var Pa=[],Qa=a=>{for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);127>=e?b++:2047>=e?b+=2:55296<=e&&57343>=e?(b+=4,++c):b+=3}return b},Ra=(a,b,c,e)=>{if(!(0<e))return 0;var f=c;e=c+e-1;for(var h=0;h<a.length;++h){var k=a.charCodeAt(h);if(55296<=k&&57343>=k){var n=a.charCodeAt(++h);k=65536+((k&1023)<<10)|n&1023}if(127>=k){if(c>=e)break;b[c++]=k}else{if(2047>=k){if(c+1>=e)break;b[c++]=192|k>>6}else{if(65535>=k){if(c+2>=e)break;b[c++]=224|k>>12}else{if(c+3>=e)break;b[c++]=240|k>>18;b[c++]=128|k>>
|
||||
12&63}b[c++]=128|k>>6&63}b[c++]=128|k&63}}b[c]=0;return c-f};function Sa(a,b,c){c=Array(0<c?c:Qa(a)+1);a=Ra(a,c,0,c.length);b&&(c.length=a);return c}var Ta=[];function Ua(a,b){Ta[a]={input:[],Mf:[],Yf:b};Va(a,Wa)}
|
||||
var Wa={open(a){var b=Ta[a.node.ag];if(!b)throw new O(43);a.Nf=b;a.seekable=!1},close(a){a.Nf.Yf.Vf(a.Nf)},Vf(a){a.Nf.Yf.Vf(a.Nf)},read(a,b,c,e){if(!a.Nf||!a.Nf.Yf.qg)throw new O(60);for(var f=0,h=0;h<e;h++){try{var k=a.Nf.Yf.qg(a.Nf)}catch(n){throw new O(29);}if(void 0===k&&0===f)throw new O(6);if(null===k||void 0===k)break;f++;b[c+h]=k}f&&(a.node.timestamp=Date.now());return f},write(a,b,c,e){if(!a.Nf||!a.Nf.Yf.kg)throw new O(60);try{for(var f=0;f<e;f++)a.Nf.Yf.kg(a.Nf,b[c+f])}catch(h){throw new O(29);
|
||||
}e&&(a.node.timestamp=Date.now());return f}},Xa={qg(){a:{if(!Pa.length){var a=null;"undefined"!=typeof window&&"function"==typeof window.prompt?(a=window.prompt("Input: "),null!==a&&(a+="\n")):"function"==typeof readline&&(a=readline(),null!==a&&(a+="\n"));if(!a){a=null;break a}Pa=Sa(a,!0)}a=Pa.shift()}return a},kg(a,b){null===b||10===b?(ka(M(a.Mf,0)),a.Mf=[]):0!=b&&a.Mf.push(b)},Vf(a){a.Mf&&0<a.Mf.length&&(ka(M(a.Mf,0)),a.Mf=[])},Qg(){return{Mg:25856,Og:5,Lg:191,Ng:35387,Kg:[3,28,127,21,4,0,1,0,
|
||||
17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},Rg(){return 0},Sg(){return[24,80]}},Ya={kg(a,b){null===b||10===b?(r(M(a.Mf,0)),a.Mf=[]):0!=b&&a.Mf.push(b)},Vf(a){a.Mf&&0<a.Mf.length&&(r(M(a.Mf,0)),a.Mf=[])}};function Za(a,b){var c=a.If?a.If.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.If,a.If=new Uint8Array(b),0<a.Kf&&a.If.set(c.subarray(0,a.Kf),0))}
|
||||
var P={Pf:null,Qf(){return P.createNode(null,"/",16895,0)},createNode(a,b,c,e){if(24576===(c&61440)||4096===(c&61440))throw new O(63);P.Pf||(P.Pf={dir:{node:{Of:P.Gf.Of,Lf:P.Gf.Lf,Zf:P.Gf.Zf,dg:P.Gf.dg,vg:P.Gf.vg,ig:P.Gf.ig,gg:P.Gf.gg,ug:P.Gf.ug,hg:P.Gf.hg},stream:{Uf:P.Hf.Uf}},file:{node:{Of:P.Gf.Of,Lf:P.Gf.Lf},stream:{Uf:P.Hf.Uf,read:P.Hf.read,write:P.Hf.write,ng:P.Hf.ng,eg:P.Hf.eg,fg:P.Hf.fg}},link:{node:{Of:P.Gf.Of,Lf:P.Gf.Lf,bg:P.Gf.bg},stream:{}},og:{node:{Of:P.Gf.Of,Lf:P.Gf.Lf},stream:$a}});
|
||||
c=ab(a,b,c,e);Q(c.mode)?(c.Gf=P.Pf.dir.node,c.Hf=P.Pf.dir.stream,c.If={}):32768===(c.mode&61440)?(c.Gf=P.Pf.file.node,c.Hf=P.Pf.file.stream,c.Kf=0,c.If=null):40960===(c.mode&61440)?(c.Gf=P.Pf.link.node,c.Hf=P.Pf.link.stream):8192===(c.mode&61440)&&(c.Gf=P.Pf.og.node,c.Hf=P.Pf.og.stream);c.timestamp=Date.now();a&&(a.If[b]=c,a.timestamp=c.timestamp);return c},Pg(a){return a.If?a.If.subarray?a.If.subarray(0,a.Kf):new Uint8Array(a.If):new Uint8Array(0)},Gf:{Of(a){var b={};b.Bg=8192===(a.mode&61440)?a.id:
|
||||
1;b.sg=a.id;b.mode=a.mode;b.Gg=1;b.uid=0;b.Dg=0;b.ag=a.ag;Q(a.mode)?b.size=4096:32768===(a.mode&61440)?b.size=a.Kf:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.xg=new Date(a.timestamp);b.Fg=new Date(a.timestamp);b.Ag=new Date(a.timestamp);b.yg=4096;b.zg=Math.ceil(b.size/b.yg);return b},Lf(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=b.timestamp);if(void 0!==b.size&&(b=b.size,a.Kf!=b))if(0==b)a.If=null,a.Kf=0;else{var c=a.If;a.If=new Uint8Array(b);c&&a.If.set(c.subarray(0,
|
||||
Math.min(b,a.Kf)));a.Kf=b}},Zf(){throw bb[44];},dg(a,b,c,e){return P.createNode(a,b,c,e)},vg(a,b,c){if(Q(a.mode)){try{var e=cb(b,c)}catch(h){}if(e)for(var f in e.If)throw new O(55);}delete a.parent.If[a.name];a.parent.timestamp=Date.now();a.name=c;b.If[c]=a;b.timestamp=a.parent.timestamp;a.parent=b},ig(a,b){delete a.If[b];a.timestamp=Date.now()},gg(a,b){var c=cb(a,b),e;for(e in c.If)throw new O(55);delete a.If[b];a.timestamp=Date.now()},ug(a){var b=[".",".."],c;for(c in a.If)a.If.hasOwnProperty(c)&&
|
||||
b.push(c);return b},hg(a,b,c){a=P.createNode(a,b,41471,0);a.link=c;return a},bg(a){if(40960!==(a.mode&61440))throw new O(28);return a.link}},Hf:{read(a,b,c,e,f){var h=a.node.If;if(f>=a.node.Kf)return 0;a=Math.min(a.node.Kf-f,e);if(8<a&&h.subarray)b.set(h.subarray(f,f+a),c);else for(e=0;e<a;e++)b[c+e]=h[f+e];return a},write(a,b,c,e,f,h){b.buffer===v.buffer&&(h=!1);if(!e)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.If||a.If.subarray)){if(h)return a.If=b.subarray(c,c+e),a.Kf=e;if(0===
|
||||
a.Kf&&0===f)return a.If=b.slice(c,c+e),a.Kf=e;if(f+e<=a.Kf)return a.If.set(b.subarray(c,c+e),f),e}Za(a,f+e);if(a.If.subarray&&b.subarray)a.If.set(b.subarray(c,c+e),f);else for(h=0;h<e;h++)a.If[f+h]=b[c+h];a.Kf=Math.max(a.Kf,f+e);return e},Uf(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.Kf);if(0>b)throw new O(28);return b},ng(a,b,c){Za(a.node,b+c);a.node.Kf=Math.max(a.node.Kf,b+c)},eg(a,b,c,e,f){if(32768!==(a.node.mode&61440))throw new O(43);a=a.node.If;if(f&2||a.buffer!==
|
||||
v.buffer){if(0<c||c+b<a.length)a.subarray?a=a.subarray(c,c+b):a=Array.prototype.slice.call(a,c,c+b);c=!0;b=65536*Math.ceil(b/65536);(f=db(65536,b))?(w.fill(0,f,f+b),b=f):b=0;if(!b)throw new O(48);v.set(a,b)}else c=!1,b=a.byteOffset;return{Hg:b,wg:c}},fg(a,b,c,e){P.Hf.write(a,b,0,e,c,!1);return 0}}},eb=(a,b)=>{var c=0;a&&(c|=365);b&&(c|=146);return c},fb=null,gb={},hb=[],ib=1,R=null,jb=!0,O=null,bb={};
|
||||
function S(a,b={}){a=Oa(a);if(!a)return{path:"",node:null};b=Object.assign({pg:!0,lg:0},b);if(8<b.lg)throw new O(32);a=a.split("/").filter(k=>!!k);for(var c=fb,e="/",f=0;f<a.length;f++){var h=f===a.length-1;if(h&&b.parent)break;c=cb(c,a[f]);e=N(e+"/"+a[f]);c.Wf&&(!h||h&&b.pg)&&(c=c.Wf.root);if(!h||b.Tf)for(h=0;40960===(c.mode&61440);)if(c=kb(e),e=Oa(Ka(e),c),c=S(e,{lg:b.lg+1}).node,40<h++)throw new O(32);}return{path:e,node:c}}
|
||||
function lb(a){for(var b;;){if(a===a.parent)return a=a.Qf.tg,b?"/"!==a[a.length-1]?`${a}/${b}`:a+b:a;b=b?`${a.name}/${b}`:a.name;a=a.parent}}function mb(a,b){for(var c=0,e=0;e<b.length;e++)c=(c<<5)-c+b.charCodeAt(e)|0;return(a+c>>>0)%R.length}function nb(a){var b=mb(a.parent.id,a.name);if(R[b]===a)R[b]=a.Xf;else for(b=R[b];b;){if(b.Xf===a){b.Xf=a.Xf;break}b=b.Xf}}
|
||||
function cb(a,b){var c;if(c=(c=ob(a,"x"))?c:a.Gf.Zf?0:2)throw new O(c,a);for(c=R[mb(a.id,b)];c;c=c.Xf){var e=c.name;if(c.parent.id===a.id&&e===b)return c}return a.Gf.Zf(a,b)}function ab(a,b,c,e){a=new pb(a,b,c,e);b=mb(a.parent.id,a.name);a.Xf=R[b];return R[b]=a}function Q(a){return 16384===(a&61440)}function qb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}
|
||||
function ob(a,b){if(jb)return 0;if(!b.includes("r")||a.mode&292){if(b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73))return 2}else return 2;return 0}function rb(a,b){try{return cb(a,b),20}catch(c){}return ob(a,"wx")}function sb(a,b,c){try{var e=cb(a,b)}catch(f){return f.Jf}if(a=ob(a,"wx"))return a;if(c){if(!Q(e.mode))return 54;if(e===e.parent||"/"===lb(e))return 10}else if(Q(e.mode))return 31;return 0}function tb(){for(var a=0;4096>=a;a++)if(!hb[a])return a;throw new O(33);}
|
||||
function T(a){a=hb[a];if(!a)throw new O(8);return a}function ub(a,b=-1){vb||(vb=function(){this.cg={}},vb.prototype={},Object.defineProperties(vb.prototype,{object:{get(){return this.node},set(c){this.node=c}},flags:{get(){return this.cg.flags},set(c){this.cg.flags=c}},position:{get(){return this.cg.position},set(c){this.cg.position=c}}}));a=Object.assign(new vb,a);-1==b&&(b=tb());a.Rf=b;return hb[b]=a}var $a={open(a){a.Hf=gb[a.node.ag].Hf;a.Hf.open&&a.Hf.open(a)},Uf(){throw new O(70);}};
|
||||
function Va(a,b){gb[a]={Hf:b}}function wb(a,b){var c="/"===b,e=!b;if(c&&fb)throw new O(10);if(!c&&!e){var f=S(b,{pg:!1});b=f.path;f=f.node;if(f.Wf)throw new O(10);if(!Q(f.mode))throw new O(54);}b={type:a,Ug:{},tg:b,Eg:[]};a=a.Qf(b);a.Qf=b;b.root=a;c?fb=a:f&&(f.Wf=b,f.Qf&&f.Qf.Eg.push(b))}function xb(a,b,c){var e=S(a,{parent:!0}).node;a=La(a);if(!a||"."===a||".."===a)throw new O(28);var f=rb(e,a);if(f)throw new O(f);if(!e.Gf.dg)throw new O(63);return e.Gf.dg(e,a,b,c)}
|
||||
function U(a,b){return xb(a,(void 0!==b?b:511)&1023|16384,0)}function yb(a,b,c){"undefined"==typeof c&&(c=b,b=438);xb(a,b|8192,c)}function zb(a,b){if(!Oa(a))throw new O(44);var c=S(b,{parent:!0}).node;if(!c)throw new O(44);b=La(b);var e=rb(c,b);if(e)throw new O(e);if(!c.Gf.hg)throw new O(63);c.Gf.hg(c,b,a)}function Ab(a){var b=S(a,{parent:!0}).node;a=La(a);var c=cb(b,a),e=sb(b,a,!0);if(e)throw new O(e);if(!b.Gf.gg)throw new O(63);if(c.Wf)throw new O(10);b.Gf.gg(b,a);nb(c)}
|
||||
function kb(a){a=S(a).node;if(!a)throw new O(44);if(!a.Gf.bg)throw new O(28);return Oa(lb(a.parent),a.Gf.bg(a))}function Bb(a,b){a=S(a,{Tf:!b}).node;if(!a)throw new O(44);if(!a.Gf.Of)throw new O(63);return a.Gf.Of(a)}function Cb(a){return Bb(a,!0)}function Db(a,b){a="string"==typeof a?S(a,{Tf:!0}).node:a;if(!a.Gf.Lf)throw new O(63);a.Gf.Lf(a,{mode:b&4095|a.mode&-4096,timestamp:Date.now()})}
|
||||
function Eb(a,b){if(0>b)throw new O(28);a="string"==typeof a?S(a,{Tf:!0}).node:a;if(!a.Gf.Lf)throw new O(63);if(Q(a.mode))throw new O(31);if(32768!==(a.mode&61440))throw new O(28);var c=ob(a,"w");if(c)throw new O(c);a.Gf.Lf(a,{size:b,timestamp:Date.now()})}
|
||||
function Fb(a,b,c){if(""===a)throw new O(44);if("string"==typeof b){var e={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[b];if("undefined"==typeof e)throw Error(`Unknown file open mode: ${b}`);b=e}c=b&64?("undefined"==typeof c?438:c)&4095|32768:0;if("object"==typeof a)var f=a;else{a=N(a);try{f=S(a,{Tf:!(b&131072)}).node}catch(h){}}e=!1;if(b&64)if(f){if(b&128)throw new O(20);}else f=xb(a,c,0),e=!0;if(!f)throw new O(44);8192===(f.mode&61440)&&(b&=-513);if(b&65536&&!Q(f.mode))throw new O(54);if(!e&&(c=
|
||||
f?40960===(f.mode&61440)?32:Q(f.mode)&&("r"!==qb(b)||b&512)?31:ob(f,qb(b)):44))throw new O(c);b&512&&!e&&Eb(f,0);b&=-131713;f=ub({node:f,path:lb(f),flags:b,seekable:!0,position:0,Hf:f.Hf,Jg:[],error:!1});f.Hf.open&&f.Hf.open(f);!d.logReadFiles||b&1||(Gb||(Gb={}),a in Gb||(Gb[a]=1));return f}function Hb(a,b,c){if(null===a.Rf)throw new O(8);if(!a.seekable||!a.Hf.Uf)throw new O(70);if(0!=c&&1!=c&&2!=c)throw new O(28);a.position=a.Hf.Uf(a,b,c);a.Jg=[]}
|
||||
function Ib(){O||(O=function(a,b){this.name="ErrnoError";this.node=b;this.Ig=function(c){this.Jf=c};this.Ig(a);this.message="FS error"},O.prototype=Error(),O.prototype.constructor=O,[44].forEach(a=>{bb[a]=new O(a);bb[a].stack="<generic error, no stack>"}))}var Jb;
|
||||
function Kb(a,b,c){a=N("/dev/"+a);var e=eb(!!b,!!c);Lb||(Lb=64);var f=Lb++<<8|0;Va(f,{open(h){h.seekable=!1},close(){c&&c.buffer&&c.buffer.length&&c(10)},read(h,k,n,l){for(var m=0,p=0;p<l;p++){try{var q=b()}catch(t){throw new O(29);}if(void 0===q&&0===m)throw new O(6);if(null===q||void 0===q)break;m++;k[n+p]=q}m&&(h.node.timestamp=Date.now());return m},write(h,k,n,l){for(var m=0;m<l;m++)try{c(k[n+m])}catch(p){throw new O(29);}l&&(h.node.timestamp=Date.now());return m}});yb(a,e,f)}var Lb,V={},vb,Gb;
|
||||
function Mb(a,b,c){if("/"===b.charAt(0))return b;a=-100===a?"/":T(a).path;if(0==b.length){if(!c)throw new O(44);return a}return N(a+"/"+b)}
|
||||
function Nb(a,b,c){try{var e=a(b)}catch(h){if(h&&h.node&&N(b)!==N(lb(h.node)))return-54;throw h;}y[c>>2]=e.Bg;y[c+4>>2]=e.mode;B[c+8>>2]=e.Gg;y[c+12>>2]=e.uid;y[c+16>>2]=e.Dg;y[c+20>>2]=e.ag;H=[e.size>>>0,(F=e.size,1<=+Math.abs(F)?0<F?+Math.floor(F/4294967296)>>>0:~~+Math.ceil((F-+(~~F>>>0))/4294967296)>>>0:0)];y[c+24>>2]=H[0];y[c+28>>2]=H[1];y[c+32>>2]=4096;y[c+36>>2]=e.zg;a=e.xg.getTime();b=e.Fg.getTime();var f=e.Ag.getTime();H=[Math.floor(a/1E3)>>>0,(F=Math.floor(a/1E3),1<=+Math.abs(F)?0<F?+Math.floor(F/
|
||||
4294967296)>>>0:~~+Math.ceil((F-+(~~F>>>0))/4294967296)>>>0:0)];y[c+40>>2]=H[0];y[c+44>>2]=H[1];B[c+48>>2]=a%1E3*1E3;H=[Math.floor(b/1E3)>>>0,(F=Math.floor(b/1E3),1<=+Math.abs(F)?0<F?+Math.floor(F/4294967296)>>>0:~~+Math.ceil((F-+(~~F>>>0))/4294967296)>>>0:0)];y[c+56>>2]=H[0];y[c+60>>2]=H[1];B[c+64>>2]=b%1E3*1E3;H=[Math.floor(f/1E3)>>>0,(F=Math.floor(f/1E3),1<=+Math.abs(F)?0<F?+Math.floor(F/4294967296)>>>0:~~+Math.ceil((F-+(~~F>>>0))/4294967296)>>>0:0)];y[c+72>>2]=H[0];y[c+76>>2]=H[1];B[c+80>>2]=
|
||||
f%1E3*1E3;H=[e.sg>>>0,(F=e.sg,1<=+Math.abs(F)?0<F?+Math.floor(F/4294967296)>>>0:~~+Math.ceil((F-+(~~F>>>0))/4294967296)>>>0:0)];y[c+88>>2]=H[0];y[c+92>>2]=H[1];return 0}var Ob=void 0;function Pb(){var a=y[+Ob>>2];Ob+=4;return a}
|
||||
var Qb=(a,b)=>b+2097152>>>0<4194305-!!a?(a>>>0)+4294967296*b:NaN,Rb=[0,31,60,91,121,152,182,213,244,274,305,335],Sb=[0,31,59,90,120,151,181,212,243,273,304,334],Ub=a=>{var b=Qa(a)+1,c=Tb(b);c&&Ra(a,w,c,b);return c},Vb={},Xb=()=>{if(!Wb){var a={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",_:da||"./this.program"},b;for(b in Vb)void 0===Vb[b]?delete a[b]:a[b]=Vb[b];
|
||||
var c=[];for(b in a)c.push(`${b}=${a[b]}`);Wb=c}return Wb},Wb;function Yb(){}function Zb(){}function $b(){}function ac(){}function bc(){}function cc(){}function dc(){}function ec(){}function fc(){}function gc(){}function hc(){}function ic(){}function jc(){}function kc(){}function lc(){}function mc(){}function nc(){}function oc(){}function pc(){}function qc(){}function rc(){}function sc(){}function tc(){}function uc(){}function vc(){}function wc(){}function xc(){}function yc(){}function zc(){}
|
||||
function Ac(){}function Bc(){}function Cc(){}function Dc(){}function Ec(){}function Fc(){}function Gc(){}function Hc(){}function Ic(){}function Jc(){}
|
||||
var Kc=[],X,Lc,Mc=[],Y=(a,b,c,e)=>{var f={string:m=>{var p=0;if(null!==m&&void 0!==m&&0!==m){p=Qa(m)+1;var q=Nc(p);Ra(m,w,q,p);p=q}return p},array:m=>{var p=Nc(m.length);v.set(m,p);return p}};a=d["_"+a];var h=[],k=0;if(e)for(var n=0;n<e.length;n++){var l=f[c[n]];l?(0===k&&(k=Oc()),h[n]=l(e[n])):h[n]=e[n]}c=a.apply(null,h);return c=function(m){0!==k&&Pc(k);return"string"===b?m?M(w,m):"":"boolean"===b?!!m:m}(c)},Qc="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
|
||||
function pb(a,b,c,e){a||(a=this);this.parent=a;this.Qf=a.Qf;this.Wf=null;this.id=ib++;this.name=b;this.mode=c;this.Gf={};this.Hf={};this.ag=e}Object.defineProperties(pb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Ib();R=Array(4096);wb(P,"/");U("/tmp");U("/home");U("/home/web_user");
|
||||
(function(){U("/dev");Va(259,{read:()=>0,write:(e,f,h,k)=>k});yb("/dev/null",259);Ua(1280,Xa);Ua(1536,Ya);yb("/dev/tty",1280);yb("/dev/tty1",1536);var a=new Uint8Array(1024),b=0,c=()=>{0===b&&(b=Na(a).byteLength);return a[--b]};Kb("random",c);Kb("urandom",c);U("/dev/shm");U("/dev/shm/tmp")})();
|
||||
(function(){U("/proc");var a=U("/proc/self");U("/proc/self/fd");wb({Qf(){var b=ab(a,"fd",16895,73);b.Gf={Zf(c,e){var f=T(+e);c={parent:null,Qf:{tg:"fake"},Gf:{bg:()=>f.path}};return c.parent=c}};return b}},"/proc/self/fd")})();
|
||||
(function(){const a=new Map;d.setAuthorizer=function(b,c,e){c?a.set(b,{f:c,mg:e}):a.delete(b);return Y("set_authorizer","number",["number"],[b])};Yb=function(b,c,e,f,h,k){if(a.has(b)){const {f:n,mg:l}=a.get(b);return n(l,c,e?e?M(w,e):"":null,f?f?M(w,f):"":null,h?h?M(w,h):"":null,k?k?M(w,k):"":null)}return 0}})();
|
||||
(function(){const a=new Map,b=new Map;d.createFunction=function(c,e,f,h,k,n){const l=a.size;a.set(l,{f:n,Sf:k});return Y("create_function","number","number string number number number number".split(" "),[c,e,f,h,l,0])};d.createAggregate=function(c,e,f,h,k,n,l){const m=a.size;a.set(m,{step:n,Cg:l,Sf:k});return Y("create_function","number","number string number number number number".split(" "),[c,e,f,h,m,1])};d.getFunctionUserData=function(c){return b.get(c)};$b=function(c,e,f,h){c=a.get(c);b.set(e,
|
||||
c.Sf);c.f(e,new Uint32Array(w.buffer,h,f));b.delete(e)};bc=function(c,e,f,h){c=a.get(c);b.set(e,c.Sf);c.step(e,new Uint32Array(w.buffer,h,f));b.delete(e)};Zb=function(c,e){c=a.get(c);b.set(e,c.Sf);c.Cg(e);b.delete(e)}})();(function(){const a=new Map;d.progressHandler=function(b,c,e,f){e?a.set(b,{f:e,mg:f}):a.delete(b);return Y("progress_handler",null,["number","number"],[b,c])};ac=function(b){if(a.has(b)){const {f:c,mg:e}=a.get(b);return c(e)}return 0}})();
|
||||
(function(){function a(l,m){const p=`get${l}`,q=`set${l}`;return new Proxy(new DataView(w.buffer,m,"Int32"===l?4:8),{get(t,z){if(z===p)return function(A,G){if(!G)throw Error("must be little endian");return t[z](A,G)};if(z===q)return function(A,G,E){if(!E)throw Error("must be little endian");return t[z](A,G,E)};if("string"===typeof z&&z.match(/^(get)|(set)/))throw Error("invalid type");return t[z]}})}const b="object"===typeof Asyncify,c=new Map,e=new Map,f=new Map,h=b?new Set:null,k=b?new Set:null,
|
||||
n=new Map;sc=function(l,m,p,q){n.set(l?M(w,l):"",{size:m,$f:Array.from(new Uint32Array(w.buffer,q,p))})};d.createModule=function(l,m,p,q){b&&(p.handleAsync=Asyncify.rg);const t=c.size;c.set(t,{module:p,Sf:q});q=0;p.xCreate&&(q|=1);p.xConnect&&(q|=2);p.xBestIndex&&(q|=4);p.xDisconnect&&(q|=8);p.xDestroy&&(q|=16);p.xOpen&&(q|=32);p.xClose&&(q|=64);p.xFilter&&(q|=128);p.xNext&&(q|=256);p.xEof&&(q|=512);p.xColumn&&(q|=1024);p.xRowid&&(q|=2048);p.xUpdate&&(q|=4096);p.xBegin&&(q|=8192);p.xSync&&(q|=16384);
|
||||
p.xCommit&&(q|=32768);p.xRollback&&(q|=65536);p.xFindFunction&&(q|=131072);p.xRename&&(q|=262144);return Y("create_module","number",["number","string","number","number"],[l,m,t,q])};ic=function(l,m,p,q,t,z){m=c.get(m);e.set(t,m);if(b){h.delete(t);for(const A of h)e.delete(A)}q=Array.from(new Uint32Array(w.buffer,q,p)).map(A=>A?M(w,A):"");return m.module.xCreate(l,m.Sf,q,t,a("Int32",z))};hc=function(l,m,p,q,t,z){m=c.get(m);e.set(t,m);if(b){h.delete(t);for(const A of h)e.delete(A)}q=Array.from(new Uint32Array(w.buffer,
|
||||
q,p)).map(A=>A?M(w,A):"");return m.module.xConnect(l,m.Sf,q,t,a("Int32",z))};dc=function(l,m){var p=e.get(l),q=n.get("sqlite3_index_info").$f;const t={};t.nConstraint=J(m+q[0],"i32");t.aConstraint=[];var z=J(m+q[1],"*"),A=n.get("sqlite3_index_constraint").size;for(var G=0;G<t.nConstraint;++G){var E=t.aConstraint,L=E.push,I=z+G*A,ia=n.get("sqlite3_index_constraint").$f,W={};W.iColumn=J(I+ia[0],"i32");W.op=J(I+ia[1],"i8");W.usable=!!J(I+ia[2],"i8");L.call(E,W)}t.nOrderBy=J(m+q[2],"i32");t.aOrderBy=
|
||||
[];z=J(m+q[3],"*");A=n.get("sqlite3_index_orderby").size;for(G=0;G<t.nOrderBy;++G)E=t.aOrderBy,L=E.push,I=z+G*A,ia=n.get("sqlite3_index_orderby").$f,W={},W.iColumn=J(I+ia[0],"i32"),W.desc=!!J(I+ia[1],"i8"),L.call(E,W);t.aConstraintUsage=[];for(z=0;z<t.nConstraint;++z)t.aConstraintUsage.push({argvIndex:0,omit:!1});t.idxNum=J(m+q[5],"i32");t.idxStr=null;t.orderByConsumed=!!J(m+q[8],"i8");t.estimatedCost=J(m+q[9],"double");t.estimatedRows=J(m+q[10],"i32");t.idxFlags=J(m+q[11],"i32");t.colUsed=J(m+q[12],
|
||||
"i32");l=p.module.xBestIndex(l,t);p=n.get("sqlite3_index_info").$f;q=J(m+p[4],"*");z=n.get("sqlite3_index_constraint_usage").size;for(L=0;L<t.nConstraint;++L)A=q+L*z,E=t.aConstraintUsage[L],I=n.get("sqlite3_index_constraint_usage").$f,K(A+I[0],E.argvIndex,"i32"),K(A+I[1],E.omit?1:0,"i8");K(m+p[5],t.idxNum,"i32");"string"===typeof t.idxStr&&(q=Qa(t.idxStr),z=Y("sqlite3_malloc","number",["number"],[q+1]),Ra(t.idxStr,w,z,q+1),K(m+p[6],z,"*"),K(m+p[7],1,"i32"));K(m+p[8],t.orderByConsumed,"i32");K(m+p[9],
|
||||
t.estimatedCost,"double");K(m+p[10],t.estimatedRows,"i32");K(m+p[11],t.idxFlags,"i32");return l};kc=function(l){const m=e.get(l);b?h.add(l):e.delete(l);return m.module.xDisconnect(l)};jc=function(l){const m=e.get(l);b?h.add(l):e.delete(l);return m.module.xDestroy(l)};oc=function(l,m){const p=e.get(l);f.set(m,p);if(b){k.delete(m);for(const q of k)f.delete(q)}return p.module.xOpen(l,m)};ec=function(l){const m=f.get(l);b?k.add(l):f.delete(l);return m.module.xClose(l)};lc=function(l){return f.get(l).module.xEof(l)?
|
||||
1:0};mc=function(l,m,p,q,t){const z=f.get(l);p=p?p?M(w,p):"":null;t=new Uint32Array(w.buffer,t,q);return z.module.xFilter(l,m,p,t)};nc=function(l){return f.get(l).module.xNext(l)};fc=function(l,m,p){return f.get(l).module.xColumn(l,m,p)};rc=function(l,m){return f.get(l).module.xRowid(l,a("BigInt64",m))};uc=function(l,m,p,q){const t=e.get(l);p=new Uint32Array(w.buffer,p,m);return t.module.xUpdate(l,p,a("BigInt64",q))};cc=function(l){return e.get(l).module.xBegin(l)};tc=function(l){return e.get(l).module.xSync(l)};
|
||||
gc=function(l){return e.get(l).module.xCommit(l)};qc=function(l){return e.get(l).module.xRollback(l)};pc=function(l,m){const p=e.get(l);m=m?M(w,m):"";return p.module.xRename(l,m)}})();
|
||||
(function(){function a(h,k){const n=`get${h}`,l=`set${h}`;return new Proxy(new DataView(w.buffer,k,"Int32"===h?4:8),{get(m,p){if(p===n)return function(q,t){if(!t)throw Error("must be little endian");return m[p](q,t)};if(p===l)return function(q,t,z){if(!z)throw Error("must be little endian");return m[p](q,t,z)};if("string"===typeof p&&p.match(/^(get)|(set)/))throw Error("invalid type");return m[p]}})}const b="object"===typeof Asyncify;b&&(d.handleAsync=Asyncify.rg);const c=new Map,e=new Map;d.registerVFS=
|
||||
function(h,k){if(Y("sqlite3_vfs_find","number",["string"],[h.name]))throw Error(`VFS '${h.name}' already registered`);b&&(h.handleAsync=Asyncify.rg);var n=h.Tg??64;const l=d._malloc(4);k=Y("register_vfs","number",["string","number","number","number"],[h.name,n,k?1:0,l]);k||(n=J(l,"*"),c.set(n,h));d._free(l);return k};const f=b?new Set:null;xc=function(h){const k=e.get(h);b?f.add(h):e.delete(h);return k.xClose(h)};Ec=function(h,k,n,l,m){return e.get(h).xRead(h,w.subarray(k,k+n),4294967296*m+l+(0>l?
|
||||
2**32:0))};Jc=function(h,k,n,l,m){return e.get(h).xWrite(h,w.subarray(k,k+n),4294967296*m+l+(0>l?2**32:0))};Hc=function(h,k,n){return e.get(h).xTruncate(h,4294967296*n+k+(0>k?2**32:0))};Gc=function(h,k){return e.get(h).xSync(h,k)};Bc=function(h,k){const n=e.get(h);k=a("BigInt64",k);return n.xFileSize(h,k)};Cc=function(h,k){return e.get(h).xLock(h,k)};Ic=function(h,k){return e.get(h).xUnlock(h,k)};wc=function(h,k){const n=e.get(h);k=a("Int32",k);return n.xCheckReservedLock(h,k)};Ac=function(h,k,n){const l=
|
||||
e.get(h);n=new DataView(w.buffer,n);return l.xFileControl(h,k,n)};Fc=function(h){return e.get(h).xSectorSize(h)};zc=function(h){return e.get(h).xDeviceCharacteristics(h)};Dc=function(h,k,n,l,m){h=c.get(h);e.set(n,h);if(b){f.delete(n);for(var p of f)e.delete(p)}p=null;if(l&64){p=1;const q=[];for(;p;){const t=w[k++];if(t)q.push(t);else switch(w[k]||(p=null),p){case 1:q.push(63);p=2;break;case 2:q.push(61);p=3;break;case 3:q.push(38),p=2}}p=(new TextDecoder).decode(new Uint8Array(q))}else k&&(p=k?M(w,
|
||||
k):"");m=a("Int32",m);return h.xOpen(p,n,l,m)};yc=function(h,k,n){return c.get(h).xDelete(k?M(w,k):"",n)};vc=function(h,k,n,l){h=c.get(h);l=a("Int32",l);return h.xAccess(k?M(w,k):"",n,l)}})();
|
||||
var Sc={a:(a,b,c,e)=>{u(`Assertion failed: ${a?M(w,a):""}, at: `+[b?b?M(w,b):"":"unknown filename",c,e?e?M(w,e):"":"unknown function"])},P:function(a,b){try{return a=a?M(w,a):"",Db(a,b),0}catch(c){if("undefined"==typeof V||"ErrnoError"!==c.name)throw c;return-c.Jf}},S:function(a,b,c){try{b=b?M(w,b):"";b=Mb(a,b);if(c&-8)return-28;var e=S(b,{Tf:!0}).node;if(!e)return-44;a="";c&4&&(a+="r");c&2&&(a+="w");c&1&&(a+="x");return a&&ob(e,a)?-2:0}catch(f){if("undefined"==typeof V||"ErrnoError"!==f.name)throw f;
|
||||
return-f.Jf}},Q:function(a,b){try{var c=T(a);Db(c.node,b);return 0}catch(e){if("undefined"==typeof V||"ErrnoError"!==e.name)throw e;return-e.Jf}},O:function(a){try{var b=T(a).node;var c="string"==typeof b?S(b,{Tf:!0}).node:b;if(!c.Gf.Lf)throw new O(63);c.Gf.Lf(c,{timestamp:Date.now()});return 0}catch(e){if("undefined"==typeof V||"ErrnoError"!==e.name)throw e;return-e.Jf}},b:function(a,b,c){Ob=c;try{var e=T(a);switch(b){case 0:var f=Pb();if(0>f)return-28;for(;hb[f];)f++;return ub(e,f).Rf;case 1:case 2:return 0;
|
||||
case 3:return e.flags;case 4:return f=Pb(),e.flags|=f,0;case 5:return f=Pb(),x[f+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return y[Rc()>>2]=28,-1;default:return-28}}catch(h){if("undefined"==typeof V||"ErrnoError"!==h.name)throw h;return-h.Jf}},N:function(a,b){try{var c=T(a);return Nb(Bb,c.path,b)}catch(e){if("undefined"==typeof V||"ErrnoError"!==e.name)throw e;return-e.Jf}},n:function(a,b,c){b=Qb(b,c);try{if(isNaN(b))return 61;var e=T(a);if(0===(e.flags&2097155))throw new O(28);
|
||||
Eb(e.node,b);return 0}catch(f){if("undefined"==typeof V||"ErrnoError"!==f.name)throw f;return-f.Jf}},H:function(a,b){try{if(0===b)return-28;var c=Qa("/")+1;if(b<c)return-68;Ra("/",w,a,b);return c}catch(e){if("undefined"==typeof V||"ErrnoError"!==e.name)throw e;return-e.Jf}},L:function(a,b){try{return a=a?M(w,a):"",Nb(Cb,a,b)}catch(c){if("undefined"==typeof V||"ErrnoError"!==c.name)throw c;return-c.Jf}},E:function(a,b,c){try{return b=b?M(w,b):"",b=Mb(a,b),b=N(b),"/"===b[b.length-1]&&(b=b.substr(0,
|
||||
b.length-1)),U(b,c),0}catch(e){if("undefined"==typeof V||"ErrnoError"!==e.name)throw e;return-e.Jf}},J:function(a,b,c,e){try{b=b?M(w,b):"";var f=e&256;b=Mb(a,b,e&4096);return Nb(f?Cb:Bb,b,c)}catch(h){if("undefined"==typeof V||"ErrnoError"!==h.name)throw h;return-h.Jf}},D:function(a,b,c,e){Ob=e;try{b=b?M(w,b):"";b=Mb(a,b);var f=e?Pb():0;return Fb(b,c,f).Rf}catch(h){if("undefined"==typeof V||"ErrnoError"!==h.name)throw h;return-h.Jf}},B:function(a,b,c,e){try{b=b?M(w,b):"";b=Mb(a,b);if(0>=e)return-28;
|
||||
var f=kb(b),h=Math.min(e,Qa(f)),k=v[c+h];Ra(f,w,c,e+1);v[c+h]=k;return h}catch(n){if("undefined"==typeof V||"ErrnoError"!==n.name)throw n;return-n.Jf}},A:function(a){try{return a=a?M(w,a):"",Ab(a),0}catch(b){if("undefined"==typeof V||"ErrnoError"!==b.name)throw b;return-b.Jf}},M:function(a,b){try{return a=a?M(w,a):"",Nb(Bb,a,b)}catch(c){if("undefined"==typeof V||"ErrnoError"!==c.name)throw c;return-c.Jf}},v:function(a,b,c){try{b=b?M(w,b):"";b=Mb(a,b);if(0===c){a=b;var e=S(a,{parent:!0}).node;if(!e)throw new O(44);
|
||||
var f=La(a),h=cb(e,f),k=sb(e,f,!1);if(k)throw new O(k);if(!e.Gf.ig)throw new O(63);if(h.Wf)throw new O(10);e.Gf.ig(e,f);nb(h)}else 512===c?Ab(b):u("Invalid flags passed to unlinkat");return 0}catch(n){if("undefined"==typeof V||"ErrnoError"!==n.name)throw n;return-n.Jf}},u:function(a,b,c){try{b=b?M(w,b):"";b=Mb(a,b,!0);if(c){var e=B[c>>2]+4294967296*y[c+4>>2],f=y[c+8>>2];h=1E3*e+f/1E6;c+=16;e=B[c>>2]+4294967296*y[c+4>>2];f=y[c+8>>2];k=1E3*e+f/1E6}else var h=Date.now(),k=h;a=h;var n=S(b,{Tf:!0}).node;
|
||||
n.Gf.Lf(n,{timestamp:Math.max(a,k)});return 0}catch(l){if("undefined"==typeof V||"ErrnoError"!==l.name)throw l;return-l.Jf}},l:function(a,b,c){a=new Date(1E3*Qb(a,b));y[c>>2]=a.getSeconds();y[c+4>>2]=a.getMinutes();y[c+8>>2]=a.getHours();y[c+12>>2]=a.getDate();y[c+16>>2]=a.getMonth();y[c+20>>2]=a.getFullYear()-1900;y[c+24>>2]=a.getDay();b=a.getFullYear();y[c+28>>2]=(0!==b%4||0===b%100&&0!==b%400?Sb:Rb)[a.getMonth()]+a.getDate()-1|0;y[c+36>>2]=-(60*a.getTimezoneOffset());b=(new Date(a.getFullYear(),
|
||||
6,1)).getTimezoneOffset();var e=(new Date(a.getFullYear(),0,1)).getTimezoneOffset();y[c+32>>2]=(b!=e&&a.getTimezoneOffset()==Math.min(e,b))|0},j:function(a,b,c,e,f,h,k,n){f=Qb(f,h);try{if(isNaN(f))return 61;var l=T(e);if(0!==(b&2)&&0===(c&2)&&2!==(l.flags&2097155))throw new O(2);if(1===(l.flags&2097155))throw new O(2);if(!l.Hf.eg)throw new O(43);var m=l.Hf.eg(l,a,f,b,c);var p=m.Hg;y[k>>2]=m.wg;B[n>>2]=p;return 0}catch(q){if("undefined"==typeof V||"ErrnoError"!==q.name)throw q;return-q.Jf}},k:function(a,
|
||||
b,c,e,f,h,k){h=Qb(h,k);try{if(isNaN(h))return 61;var n=T(f);if(c&2){if(32768!==(n.node.mode&61440))throw new O(43);e&2||n.Hf.fg&&n.Hf.fg(n,w.slice(a,a+b),h,b,e)}}catch(l){if("undefined"==typeof V||"ErrnoError"!==l.name)throw l;return-l.Jf}},w:(a,b,c)=>{function e(l){return(l=l.toTimeString().match(/\(([A-Za-z ]+)\)$/))?l[1]:"GMT"}var f=(new Date).getFullYear(),h=new Date(f,0,1),k=new Date(f,6,1);f=h.getTimezoneOffset();var n=k.getTimezoneOffset();B[a>>2]=60*Math.max(f,n);y[b>>2]=Number(f!=n);a=e(h);
|
||||
b=e(k);a=Ub(a);b=Ub(b);n<f?(B[c>>2]=a,B[c+4>>2]=b):(B[c>>2]=b,B[c+4>>2]=a)},ua:()=>{u("")},e:()=>Date.now(),d:()=>performance.now(),x:(a,b,c)=>w.copyWithin(a,b,b+c),s:a=>{var b=w.length;a>>>=0;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);var f=Math;e=Math.max(a,e);a:{f=(f.min.call(f,2147483648,e+(65536-e%65536)%65536)-ma.buffer.byteLength+65535)/65536;try{ma.grow(f);ra();var h=1;break a}catch(k){}h=void 0}if(h)return!0}return!1},F:(a,b)=>{var c=0;Xb().forEach((e,
|
||||
f)=>{var h=b+c;f=B[a+4*f>>2]=h;for(h=0;h<e.length;++h)v[f++>>0]=e.charCodeAt(h);v[f>>0]=0;c+=e.length+1});return 0},G:(a,b)=>{var c=Xb();B[a>>2]=c.length;var e=0;c.forEach(f=>e+=f.length+1);B[b>>2]=e;return 0},f:function(a){try{var b=T(a);if(null===b.Rf)throw new O(8);b.jg&&(b.jg=null);try{b.Hf.close&&b.Hf.close(b)}catch(c){throw c;}finally{hb[b.Rf]=null}b.Rf=null;return 0}catch(c){if("undefined"==typeof V||"ErrnoError"!==c.name)throw c;return c.Jf}},t:function(a,b){try{var c=T(a);v[b>>0]=c.Nf?2:
|
||||
Q(c.mode)?3:40960===(c.mode&61440)?7:4;x[b+2>>1]=0;H=[0,(F=0,1<=+Math.abs(F)?0<F?+Math.floor(F/4294967296)>>>0:~~+Math.ceil((F-+(~~F>>>0))/4294967296)>>>0:0)];y[b+8>>2]=H[0];y[b+12>>2]=H[1];H=[0,(F=0,1<=+Math.abs(F)?0<F?+Math.floor(F/4294967296)>>>0:~~+Math.ceil((F-+(~~F>>>0))/4294967296)>>>0:0)];y[b+16>>2]=H[0];y[b+20>>2]=H[1];return 0}catch(e){if("undefined"==typeof V||"ErrnoError"!==e.name)throw e;return e.Jf}},C:function(a,b,c,e){try{a:{var f=T(a);a=b;for(var h,k=b=0;k<c;k++){var n=B[a>>2],l=
|
||||
B[a+4>>2];a+=8;var m=f,p=n,q=l,t=h,z=v;if(0>q||0>t)throw new O(28);if(null===m.Rf)throw new O(8);if(1===(m.flags&2097155))throw new O(8);if(Q(m.node.mode))throw new O(31);if(!m.Hf.read)throw new O(28);var A="undefined"!=typeof t;if(!A)t=m.position;else if(!m.seekable)throw new O(70);var G=m.Hf.read(m,z,p,q,t);A||(m.position+=G);var E=G;if(0>E){var L=-1;break a}b+=E;if(E<l)break;"undefined"!==typeof h&&(h+=E)}L=b}B[e>>2]=L;return 0}catch(I){if("undefined"==typeof V||"ErrnoError"!==I.name)throw I;return I.Jf}},
|
||||
m:function(a,b,c,e,f){b=Qb(b,c);try{if(isNaN(b))return 61;var h=T(a);Hb(h,b,e);H=[h.position>>>0,(F=h.position,1<=+Math.abs(F)?0<F?+Math.floor(F/4294967296)>>>0:~~+Math.ceil((F-+(~~F>>>0))/4294967296)>>>0:0)];y[f>>2]=H[0];y[f+4>>2]=H[1];h.jg&&0===b&&0===e&&(h.jg=null);return 0}catch(k){if("undefined"==typeof V||"ErrnoError"!==k.name)throw k;return k.Jf}},I:function(a){try{var b=T(a);return b.Hf&&b.Hf.Vf?b.Hf.Vf(b):0}catch(c){if("undefined"==typeof V||"ErrnoError"!==c.name)throw c;return c.Jf}},y:function(a,
|
||||
b,c,e){try{a:{var f=T(a);a=b;for(var h,k=b=0;k<c;k++){var n=B[a>>2],l=B[a+4>>2];a+=8;var m=f,p=n,q=l,t=h,z=v;if(0>q||0>t)throw new O(28);if(null===m.Rf)throw new O(8);if(0===(m.flags&2097155))throw new O(8);if(Q(m.node.mode))throw new O(31);if(!m.Hf.write)throw new O(28);m.seekable&&m.flags&1024&&Hb(m,0,2);var A="undefined"!=typeof t;if(!A)t=m.position;else if(!m.seekable)throw new O(70);var G=m.Hf.write(m,z,p,q,t,void 0);A||(m.position+=G);var E=G;if(0>E){var L=-1;break a}b+=E;"undefined"!==typeof h&&
|
||||
(h+=E)}L=b}B[e>>2]=L;return 0}catch(I){if("undefined"==typeof V||"ErrnoError"!==I.name)throw I;return I.Jf}},g:(a,b)=>{Na(w.subarray(a,a+b));return 0},aa:Yb,z:Zb,R:$b,ea:ac,K:bc,ma:cc,o:dc,ta:ec,pa:fc,ka:gc,ga:hc,ha:ic,h:jc,i:kc,qa:lc,sa:mc,ra:nc,fa:oc,ia:pc,ja:qc,oa:rc,c:sc,la:tc,na:uc,ca:vc,X:wc,ba:xc,da:yc,U:zc,W:Ac,_:Bc,Z:Cc,T:Dc,r:Ec,V:Fc,$:Gc,p:Hc,Y:Ic,q:Jc},Z=function(){function a(c){Z=c.exports;ma=Z.va;ra();X=Z.Af;ta.unshift(Z.wa);C--;d.monitorRunDependencies&&d.monitorRunDependencies(C);
|
||||
0==C&&(null!==xa&&(clearInterval(xa),xa=null),ya&&(c=ya,ya=null,c()));return Z}var b={a:Sc};C++;d.monitorRunDependencies&&d.monitorRunDependencies(C);if(d.instantiateWasm)try{return d.instantiateWasm(b,a)}catch(c){r(`Module.instantiateWasm callback failed with error: ${c}`),ba(c)}Ea(b,function(c){a(c.instance)}).catch(ba);return{}}();d._sqlite3_status64=(a,b,c,e)=>(d._sqlite3_status64=Z.xa)(a,b,c,e);d._sqlite3_status=(a,b,c,e)=>(d._sqlite3_status=Z.ya)(a,b,c,e);
|
||||
d._sqlite3_db_status=(a,b,c,e,f)=>(d._sqlite3_db_status=Z.za)(a,b,c,e,f);d._sqlite3_msize=a=>(d._sqlite3_msize=Z.Aa)(a);d._sqlite3_vfs_find=a=>(d._sqlite3_vfs_find=Z.Ba)(a);d._sqlite3_vfs_register=(a,b)=>(d._sqlite3_vfs_register=Z.Ca)(a,b);d._sqlite3_vfs_unregister=a=>(d._sqlite3_vfs_unregister=Z.Da)(a);d._sqlite3_release_memory=a=>(d._sqlite3_release_memory=Z.Ea)(a);d._sqlite3_soft_heap_limit64=(a,b)=>(d._sqlite3_soft_heap_limit64=Z.Fa)(a,b);d._sqlite3_memory_used=()=>(d._sqlite3_memory_used=Z.Ga)();
|
||||
d._sqlite3_hard_heap_limit64=(a,b)=>(d._sqlite3_hard_heap_limit64=Z.Ha)(a,b);d._sqlite3_memory_highwater=a=>(d._sqlite3_memory_highwater=Z.Ia)(a);d._sqlite3_malloc=a=>(d._sqlite3_malloc=Z.Ja)(a);d._sqlite3_malloc64=(a,b)=>(d._sqlite3_malloc64=Z.Ka)(a,b);d._sqlite3_free=a=>(d._sqlite3_free=Z.La)(a);d._sqlite3_realloc=(a,b)=>(d._sqlite3_realloc=Z.Ma)(a,b);d._sqlite3_realloc64=(a,b,c)=>(d._sqlite3_realloc64=Z.Na)(a,b,c);d._sqlite3_str_vappendf=(a,b,c)=>(d._sqlite3_str_vappendf=Z.Oa)(a,b,c);
|
||||
d._sqlite3_str_append=(a,b,c)=>(d._sqlite3_str_append=Z.Pa)(a,b,c);d._sqlite3_str_appendchar=(a,b,c)=>(d._sqlite3_str_appendchar=Z.Qa)(a,b,c);d._sqlite3_str_appendall=(a,b)=>(d._sqlite3_str_appendall=Z.Ra)(a,b);d._sqlite3_str_appendf=(a,b,c)=>(d._sqlite3_str_appendf=Z.Sa)(a,b,c);d._sqlite3_str_finish=a=>(d._sqlite3_str_finish=Z.Ta)(a);d._sqlite3_str_errcode=a=>(d._sqlite3_str_errcode=Z.Ua)(a);d._sqlite3_str_length=a=>(d._sqlite3_str_length=Z.Va)(a);d._sqlite3_str_value=a=>(d._sqlite3_str_value=Z.Wa)(a);
|
||||
d._sqlite3_str_reset=a=>(d._sqlite3_str_reset=Z.Xa)(a);d._sqlite3_str_new=a=>(d._sqlite3_str_new=Z.Ya)(a);d._sqlite3_vmprintf=(a,b)=>(d._sqlite3_vmprintf=Z.Za)(a,b);d._sqlite3_mprintf=(a,b)=>(d._sqlite3_mprintf=Z._a)(a,b);d._sqlite3_vsnprintf=(a,b,c,e)=>(d._sqlite3_vsnprintf=Z.$a)(a,b,c,e);d._sqlite3_snprintf=(a,b,c,e)=>(d._sqlite3_snprintf=Z.ab)(a,b,c,e);d._sqlite3_log=(a,b,c)=>(d._sqlite3_log=Z.bb)(a,b,c);d._sqlite3_randomness=(a,b)=>(d._sqlite3_randomness=Z.cb)(a,b);
|
||||
d._sqlite3_stricmp=(a,b)=>(d._sqlite3_stricmp=Z.db)(a,b);d._sqlite3_strnicmp=(a,b,c)=>(d._sqlite3_strnicmp=Z.eb)(a,b,c);d._sqlite3_os_init=()=>(d._sqlite3_os_init=Z.fb)();d._sqlite3_os_end=()=>(d._sqlite3_os_end=Z.gb)();d._sqlite3_serialize=(a,b,c,e)=>(d._sqlite3_serialize=Z.hb)(a,b,c,e);d._sqlite3_prepare_v2=(a,b,c,e,f)=>(d._sqlite3_prepare_v2=Z.ib)(a,b,c,e,f);d._sqlite3_step=a=>(d._sqlite3_step=Z.jb)(a);d._sqlite3_column_int64=(a,b)=>(d._sqlite3_column_int64=Z.kb)(a,b);
|
||||
d._sqlite3_column_int=(a,b)=>(d._sqlite3_column_int=Z.lb)(a,b);d._sqlite3_finalize=a=>(d._sqlite3_finalize=Z.mb)(a);d._sqlite3_deserialize=(a,b,c,e,f,h,k,n)=>(d._sqlite3_deserialize=Z.nb)(a,b,c,e,f,h,k,n);d._sqlite3_database_file_object=a=>(d._sqlite3_database_file_object=Z.ob)(a);d._sqlite3_backup_init=(a,b,c,e)=>(d._sqlite3_backup_init=Z.pb)(a,b,c,e);d._sqlite3_backup_step=(a,b)=>(d._sqlite3_backup_step=Z.qb)(a,b);d._sqlite3_backup_finish=a=>(d._sqlite3_backup_finish=Z.rb)(a);
|
||||
d._sqlite3_backup_remaining=a=>(d._sqlite3_backup_remaining=Z.sb)(a);d._sqlite3_backup_pagecount=a=>(d._sqlite3_backup_pagecount=Z.tb)(a);d._sqlite3_reset=a=>(d._sqlite3_reset=Z.ub)(a);d._sqlite3_clear_bindings=a=>(d._sqlite3_clear_bindings=Z.vb)(a);d._sqlite3_value_blob=a=>(d._sqlite3_value_blob=Z.wb)(a);d._sqlite3_value_text=a=>(d._sqlite3_value_text=Z.xb)(a);d._sqlite3_value_bytes=a=>(d._sqlite3_value_bytes=Z.yb)(a);d._sqlite3_value_bytes16=a=>(d._sqlite3_value_bytes16=Z.zb)(a);
|
||||
d._sqlite3_value_double=a=>(d._sqlite3_value_double=Z.Ab)(a);d._sqlite3_value_int=a=>(d._sqlite3_value_int=Z.Bb)(a);d._sqlite3_value_int64=a=>(d._sqlite3_value_int64=Z.Cb)(a);d._sqlite3_value_subtype=a=>(d._sqlite3_value_subtype=Z.Db)(a);d._sqlite3_value_pointer=(a,b)=>(d._sqlite3_value_pointer=Z.Eb)(a,b);d._sqlite3_value_text16=a=>(d._sqlite3_value_text16=Z.Fb)(a);d._sqlite3_value_text16be=a=>(d._sqlite3_value_text16be=Z.Gb)(a);d._sqlite3_value_text16le=a=>(d._sqlite3_value_text16le=Z.Hb)(a);
|
||||
d._sqlite3_value_type=a=>(d._sqlite3_value_type=Z.Ib)(a);d._sqlite3_value_encoding=a=>(d._sqlite3_value_encoding=Z.Jb)(a);d._sqlite3_value_nochange=a=>(d._sqlite3_value_nochange=Z.Kb)(a);d._sqlite3_value_frombind=a=>(d._sqlite3_value_frombind=Z.Lb)(a);d._sqlite3_value_dup=a=>(d._sqlite3_value_dup=Z.Mb)(a);d._sqlite3_value_free=a=>(d._sqlite3_value_free=Z.Nb)(a);d._sqlite3_result_blob=(a,b,c,e)=>(d._sqlite3_result_blob=Z.Ob)(a,b,c,e);
|
||||
d._sqlite3_result_blob64=(a,b,c,e,f)=>(d._sqlite3_result_blob64=Z.Pb)(a,b,c,e,f);d._sqlite3_result_double=(a,b)=>(d._sqlite3_result_double=Z.Qb)(a,b);d._sqlite3_result_error=(a,b,c)=>(d._sqlite3_result_error=Z.Rb)(a,b,c);d._sqlite3_result_error16=(a,b,c)=>(d._sqlite3_result_error16=Z.Sb)(a,b,c);d._sqlite3_result_int=(a,b)=>(d._sqlite3_result_int=Z.Tb)(a,b);d._sqlite3_result_int64=(a,b,c)=>(d._sqlite3_result_int64=Z.Ub)(a,b,c);d._sqlite3_result_null=a=>(d._sqlite3_result_null=Z.Vb)(a);
|
||||
d._sqlite3_result_pointer=(a,b,c,e)=>(d._sqlite3_result_pointer=Z.Wb)(a,b,c,e);d._sqlite3_result_subtype=(a,b)=>(d._sqlite3_result_subtype=Z.Xb)(a,b);d._sqlite3_result_text=(a,b,c,e)=>(d._sqlite3_result_text=Z.Yb)(a,b,c,e);d._sqlite3_result_text64=(a,b,c,e,f,h)=>(d._sqlite3_result_text64=Z.Zb)(a,b,c,e,f,h);d._sqlite3_result_text16=(a,b,c,e)=>(d._sqlite3_result_text16=Z._b)(a,b,c,e);d._sqlite3_result_text16be=(a,b,c,e)=>(d._sqlite3_result_text16be=Z.$b)(a,b,c,e);
|
||||
d._sqlite3_result_text16le=(a,b,c,e)=>(d._sqlite3_result_text16le=Z.ac)(a,b,c,e);d._sqlite3_result_value=(a,b)=>(d._sqlite3_result_value=Z.bc)(a,b);d._sqlite3_result_error_toobig=a=>(d._sqlite3_result_error_toobig=Z.cc)(a);d._sqlite3_result_zeroblob=(a,b)=>(d._sqlite3_result_zeroblob=Z.dc)(a,b);d._sqlite3_result_zeroblob64=(a,b,c)=>(d._sqlite3_result_zeroblob64=Z.ec)(a,b,c);d._sqlite3_result_error_code=(a,b)=>(d._sqlite3_result_error_code=Z.fc)(a,b);
|
||||
d._sqlite3_result_error_nomem=a=>(d._sqlite3_result_error_nomem=Z.gc)(a);d._sqlite3_user_data=a=>(d._sqlite3_user_data=Z.hc)(a);d._sqlite3_context_db_handle=a=>(d._sqlite3_context_db_handle=Z.ic)(a);d._sqlite3_vtab_nochange=a=>(d._sqlite3_vtab_nochange=Z.jc)(a);d._sqlite3_vtab_in_first=(a,b)=>(d._sqlite3_vtab_in_first=Z.kc)(a,b);d._sqlite3_vtab_in_next=(a,b)=>(d._sqlite3_vtab_in_next=Z.lc)(a,b);d._sqlite3_aggregate_context=(a,b)=>(d._sqlite3_aggregate_context=Z.mc)(a,b);
|
||||
d._sqlite3_get_auxdata=(a,b)=>(d._sqlite3_get_auxdata=Z.nc)(a,b);d._sqlite3_set_auxdata=(a,b,c,e)=>(d._sqlite3_set_auxdata=Z.oc)(a,b,c,e);d._sqlite3_column_count=a=>(d._sqlite3_column_count=Z.pc)(a);d._sqlite3_data_count=a=>(d._sqlite3_data_count=Z.qc)(a);d._sqlite3_column_blob=(a,b)=>(d._sqlite3_column_blob=Z.rc)(a,b);d._sqlite3_column_bytes=(a,b)=>(d._sqlite3_column_bytes=Z.sc)(a,b);d._sqlite3_column_bytes16=(a,b)=>(d._sqlite3_column_bytes16=Z.tc)(a,b);
|
||||
d._sqlite3_column_double=(a,b)=>(d._sqlite3_column_double=Z.uc)(a,b);d._sqlite3_column_text=(a,b)=>(d._sqlite3_column_text=Z.vc)(a,b);d._sqlite3_column_value=(a,b)=>(d._sqlite3_column_value=Z.wc)(a,b);d._sqlite3_column_text16=(a,b)=>(d._sqlite3_column_text16=Z.xc)(a,b);d._sqlite3_column_type=(a,b)=>(d._sqlite3_column_type=Z.yc)(a,b);d._sqlite3_column_name=(a,b)=>(d._sqlite3_column_name=Z.zc)(a,b);d._sqlite3_column_name16=(a,b)=>(d._sqlite3_column_name16=Z.Ac)(a,b);
|
||||
d._sqlite3_bind_blob=(a,b,c,e,f)=>(d._sqlite3_bind_blob=Z.Bc)(a,b,c,e,f);d._sqlite3_bind_blob64=(a,b,c,e,f,h)=>(d._sqlite3_bind_blob64=Z.Cc)(a,b,c,e,f,h);d._sqlite3_bind_double=(a,b,c)=>(d._sqlite3_bind_double=Z.Dc)(a,b,c);d._sqlite3_bind_int=(a,b,c)=>(d._sqlite3_bind_int=Z.Ec)(a,b,c);d._sqlite3_bind_int64=(a,b,c,e)=>(d._sqlite3_bind_int64=Z.Fc)(a,b,c,e);d._sqlite3_bind_null=(a,b)=>(d._sqlite3_bind_null=Z.Gc)(a,b);d._sqlite3_bind_pointer=(a,b,c,e,f)=>(d._sqlite3_bind_pointer=Z.Hc)(a,b,c,e,f);
|
||||
d._sqlite3_bind_text=(a,b,c,e,f)=>(d._sqlite3_bind_text=Z.Ic)(a,b,c,e,f);d._sqlite3_bind_text64=(a,b,c,e,f,h,k)=>(d._sqlite3_bind_text64=Z.Jc)(a,b,c,e,f,h,k);d._sqlite3_bind_text16=(a,b,c,e,f)=>(d._sqlite3_bind_text16=Z.Kc)(a,b,c,e,f);d._sqlite3_bind_value=(a,b,c)=>(d._sqlite3_bind_value=Z.Lc)(a,b,c);d._sqlite3_bind_zeroblob=(a,b,c)=>(d._sqlite3_bind_zeroblob=Z.Mc)(a,b,c);d._sqlite3_bind_zeroblob64=(a,b,c,e)=>(d._sqlite3_bind_zeroblob64=Z.Nc)(a,b,c,e);
|
||||
d._sqlite3_bind_parameter_count=a=>(d._sqlite3_bind_parameter_count=Z.Oc)(a);d._sqlite3_bind_parameter_name=(a,b)=>(d._sqlite3_bind_parameter_name=Z.Pc)(a,b);d._sqlite3_bind_parameter_index=(a,b)=>(d._sqlite3_bind_parameter_index=Z.Qc)(a,b);d._sqlite3_db_handle=a=>(d._sqlite3_db_handle=Z.Rc)(a);d._sqlite3_stmt_readonly=a=>(d._sqlite3_stmt_readonly=Z.Sc)(a);d._sqlite3_stmt_isexplain=a=>(d._sqlite3_stmt_isexplain=Z.Tc)(a);d._sqlite3_stmt_explain=(a,b)=>(d._sqlite3_stmt_explain=Z.Uc)(a,b);
|
||||
d._sqlite3_stmt_busy=a=>(d._sqlite3_stmt_busy=Z.Vc)(a);d._sqlite3_next_stmt=(a,b)=>(d._sqlite3_next_stmt=Z.Wc)(a,b);d._sqlite3_stmt_status=(a,b,c)=>(d._sqlite3_stmt_status=Z.Xc)(a,b,c);d._sqlite3_sql=a=>(d._sqlite3_sql=Z.Yc)(a);d._sqlite3_expanded_sql=a=>(d._sqlite3_expanded_sql=Z.Zc)(a);d._sqlite3_value_numeric_type=a=>(d._sqlite3_value_numeric_type=Z._c)(a);d._sqlite3_blob_open=(a,b,c,e,f,h,k,n)=>(d._sqlite3_blob_open=Z.$c)(a,b,c,e,f,h,k,n);d._sqlite3_blob_close=a=>(d._sqlite3_blob_close=Z.ad)(a);
|
||||
d._sqlite3_blob_read=(a,b,c,e)=>(d._sqlite3_blob_read=Z.bd)(a,b,c,e);d._sqlite3_blob_write=(a,b,c,e)=>(d._sqlite3_blob_write=Z.cd)(a,b,c,e);d._sqlite3_blob_bytes=a=>(d._sqlite3_blob_bytes=Z.dd)(a);d._sqlite3_blob_reopen=(a,b,c)=>(d._sqlite3_blob_reopen=Z.ed)(a,b,c);d._sqlite3_set_authorizer=(a,b,c)=>(d._sqlite3_set_authorizer=Z.fd)(a,b,c);d._sqlite3_strglob=(a,b)=>(d._sqlite3_strglob=Z.gd)(a,b);d._sqlite3_strlike=(a,b,c)=>(d._sqlite3_strlike=Z.hd)(a,b,c);
|
||||
d._sqlite3_exec=(a,b,c,e,f)=>(d._sqlite3_exec=Z.id)(a,b,c,e,f);d._sqlite3_errmsg=a=>(d._sqlite3_errmsg=Z.jd)(a);d._sqlite3_auto_extension=a=>(d._sqlite3_auto_extension=Z.kd)(a);d._sqlite3_cancel_auto_extension=a=>(d._sqlite3_cancel_auto_extension=Z.ld)(a);d._sqlite3_reset_auto_extension=()=>(d._sqlite3_reset_auto_extension=Z.md)();d._sqlite3_prepare=(a,b,c,e,f)=>(d._sqlite3_prepare=Z.nd)(a,b,c,e,f);d._sqlite3_prepare_v3=(a,b,c,e,f,h)=>(d._sqlite3_prepare_v3=Z.od)(a,b,c,e,f,h);
|
||||
d._sqlite3_prepare16=(a,b,c,e,f)=>(d._sqlite3_prepare16=Z.pd)(a,b,c,e,f);d._sqlite3_prepare16_v2=(a,b,c,e,f)=>(d._sqlite3_prepare16_v2=Z.qd)(a,b,c,e,f);d._sqlite3_prepare16_v3=(a,b,c,e,f,h)=>(d._sqlite3_prepare16_v3=Z.rd)(a,b,c,e,f,h);d._sqlite3_get_table=(a,b,c,e,f,h)=>(d._sqlite3_get_table=Z.sd)(a,b,c,e,f,h);d._sqlite3_free_table=a=>(d._sqlite3_free_table=Z.td)(a);d._sqlite3_create_module=(a,b,c,e)=>(d._sqlite3_create_module=Z.ud)(a,b,c,e);
|
||||
d._sqlite3_create_module_v2=(a,b,c,e,f)=>(d._sqlite3_create_module_v2=Z.vd)(a,b,c,e,f);d._sqlite3_drop_modules=(a,b)=>(d._sqlite3_drop_modules=Z.wd)(a,b);d._sqlite3_declare_vtab=(a,b)=>(d._sqlite3_declare_vtab=Z.xd)(a,b);d._sqlite3_vtab_on_conflict=a=>(d._sqlite3_vtab_on_conflict=Z.yd)(a);d._sqlite3_vtab_config=(a,b,c)=>(d._sqlite3_vtab_config=Z.zd)(a,b,c);d._sqlite3_vtab_collation=(a,b)=>(d._sqlite3_vtab_collation=Z.Ad)(a,b);d._sqlite3_vtab_in=(a,b,c)=>(d._sqlite3_vtab_in=Z.Bd)(a,b,c);
|
||||
d._sqlite3_vtab_rhs_value=(a,b,c)=>(d._sqlite3_vtab_rhs_value=Z.Cd)(a,b,c);d._sqlite3_vtab_distinct=a=>(d._sqlite3_vtab_distinct=Z.Dd)(a);d._sqlite3_keyword_name=(a,b,c)=>(d._sqlite3_keyword_name=Z.Ed)(a,b,c);d._sqlite3_keyword_count=()=>(d._sqlite3_keyword_count=Z.Fd)();d._sqlite3_keyword_check=(a,b)=>(d._sqlite3_keyword_check=Z.Gd)(a,b);d._sqlite3_complete=a=>(d._sqlite3_complete=Z.Hd)(a);d._sqlite3_complete16=a=>(d._sqlite3_complete16=Z.Id)(a);d._sqlite3_libversion=()=>(d._sqlite3_libversion=Z.Jd)();
|
||||
d._sqlite3_libversion_number=()=>(d._sqlite3_libversion_number=Z.Kd)();d._sqlite3_threadsafe=()=>(d._sqlite3_threadsafe=Z.Ld)();d._sqlite3_initialize=()=>(d._sqlite3_initialize=Z.Md)();d._sqlite3_shutdown=()=>(d._sqlite3_shutdown=Z.Nd)();d._sqlite3_config=(a,b)=>(d._sqlite3_config=Z.Od)(a,b);d._sqlite3_db_mutex=a=>(d._sqlite3_db_mutex=Z.Pd)(a);d._sqlite3_db_release_memory=a=>(d._sqlite3_db_release_memory=Z.Qd)(a);d._sqlite3_db_cacheflush=a=>(d._sqlite3_db_cacheflush=Z.Rd)(a);
|
||||
d._sqlite3_db_config=(a,b,c)=>(d._sqlite3_db_config=Z.Sd)(a,b,c);d._sqlite3_last_insert_rowid=a=>(d._sqlite3_last_insert_rowid=Z.Td)(a);d._sqlite3_set_last_insert_rowid=(a,b,c)=>(d._sqlite3_set_last_insert_rowid=Z.Ud)(a,b,c);d._sqlite3_changes64=a=>(d._sqlite3_changes64=Z.Vd)(a);d._sqlite3_changes=a=>(d._sqlite3_changes=Z.Wd)(a);d._sqlite3_total_changes64=a=>(d._sqlite3_total_changes64=Z.Xd)(a);d._sqlite3_total_changes=a=>(d._sqlite3_total_changes=Z.Yd)(a);
|
||||
d._sqlite3_txn_state=(a,b)=>(d._sqlite3_txn_state=Z.Zd)(a,b);d._sqlite3_close=a=>(d._sqlite3_close=Z._d)(a);d._sqlite3_close_v2=a=>(d._sqlite3_close_v2=Z.$d)(a);d._sqlite3_busy_handler=(a,b,c)=>(d._sqlite3_busy_handler=Z.ae)(a,b,c);d._sqlite3_progress_handler=(a,b,c,e)=>(d._sqlite3_progress_handler=Z.be)(a,b,c,e);d._sqlite3_busy_timeout=(a,b)=>(d._sqlite3_busy_timeout=Z.ce)(a,b);d._sqlite3_interrupt=a=>(d._sqlite3_interrupt=Z.de)(a);d._sqlite3_is_interrupted=a=>(d._sqlite3_is_interrupted=Z.ee)(a);
|
||||
d._sqlite3_create_function=(a,b,c,e,f,h,k,n)=>(d._sqlite3_create_function=Z.fe)(a,b,c,e,f,h,k,n);d._sqlite3_create_function_v2=(a,b,c,e,f,h,k,n,l)=>(d._sqlite3_create_function_v2=Z.ge)(a,b,c,e,f,h,k,n,l);d._sqlite3_create_window_function=(a,b,c,e,f,h,k,n,l,m)=>(d._sqlite3_create_window_function=Z.he)(a,b,c,e,f,h,k,n,l,m);d._sqlite3_create_function16=(a,b,c,e,f,h,k,n)=>(d._sqlite3_create_function16=Z.ie)(a,b,c,e,f,h,k,n);
|
||||
d._sqlite3_overload_function=(a,b,c)=>(d._sqlite3_overload_function=Z.je)(a,b,c);d._sqlite3_trace_v2=(a,b,c,e)=>(d._sqlite3_trace_v2=Z.ke)(a,b,c,e);d._sqlite3_commit_hook=(a,b,c)=>(d._sqlite3_commit_hook=Z.le)(a,b,c);d._sqlite3_update_hook=(a,b,c)=>(d._sqlite3_update_hook=Z.me)(a,b,c);d._sqlite3_rollback_hook=(a,b,c)=>(d._sqlite3_rollback_hook=Z.ne)(a,b,c);d._sqlite3_autovacuum_pages=(a,b,c,e)=>(d._sqlite3_autovacuum_pages=Z.oe)(a,b,c,e);
|
||||
d._sqlite3_wal_autocheckpoint=(a,b)=>(d._sqlite3_wal_autocheckpoint=Z.pe)(a,b);d._sqlite3_wal_hook=(a,b,c)=>(d._sqlite3_wal_hook=Z.qe)(a,b,c);d._sqlite3_wal_checkpoint_v2=(a,b,c,e,f)=>(d._sqlite3_wal_checkpoint_v2=Z.re)(a,b,c,e,f);d._sqlite3_wal_checkpoint=(a,b)=>(d._sqlite3_wal_checkpoint=Z.se)(a,b);d._sqlite3_error_offset=a=>(d._sqlite3_error_offset=Z.te)(a);d._sqlite3_errmsg16=a=>(d._sqlite3_errmsg16=Z.ue)(a);d._sqlite3_errcode=a=>(d._sqlite3_errcode=Z.ve)(a);
|
||||
d._sqlite3_extended_errcode=a=>(d._sqlite3_extended_errcode=Z.we)(a);d._sqlite3_system_errno=a=>(d._sqlite3_system_errno=Z.xe)(a);d._sqlite3_errstr=a=>(d._sqlite3_errstr=Z.ye)(a);d._sqlite3_limit=(a,b,c)=>(d._sqlite3_limit=Z.ze)(a,b,c);d._sqlite3_open=(a,b)=>(d._sqlite3_open=Z.Ae)(a,b);d._sqlite3_open_v2=(a,b,c,e)=>(d._sqlite3_open_v2=Z.Be)(a,b,c,e);d._sqlite3_open16=(a,b)=>(d._sqlite3_open16=Z.Ce)(a,b);d._sqlite3_create_collation=(a,b,c,e,f)=>(d._sqlite3_create_collation=Z.De)(a,b,c,e,f);
|
||||
d._sqlite3_create_collation_v2=(a,b,c,e,f,h)=>(d._sqlite3_create_collation_v2=Z.Ee)(a,b,c,e,f,h);d._sqlite3_create_collation16=(a,b,c,e,f)=>(d._sqlite3_create_collation16=Z.Fe)(a,b,c,e,f);d._sqlite3_collation_needed=(a,b,c)=>(d._sqlite3_collation_needed=Z.Ge)(a,b,c);d._sqlite3_collation_needed16=(a,b,c)=>(d._sqlite3_collation_needed16=Z.He)(a,b,c);d._sqlite3_get_clientdata=(a,b)=>(d._sqlite3_get_clientdata=Z.Ie)(a,b);d._sqlite3_set_clientdata=(a,b,c,e)=>(d._sqlite3_set_clientdata=Z.Je)(a,b,c,e);
|
||||
d._sqlite3_get_autocommit=a=>(d._sqlite3_get_autocommit=Z.Ke)(a);d._sqlite3_table_column_metadata=(a,b,c,e,f,h,k,n,l)=>(d._sqlite3_table_column_metadata=Z.Le)(a,b,c,e,f,h,k,n,l);d._sqlite3_sleep=a=>(d._sqlite3_sleep=Z.Me)(a);d._sqlite3_extended_result_codes=(a,b)=>(d._sqlite3_extended_result_codes=Z.Ne)(a,b);d._sqlite3_file_control=(a,b,c,e)=>(d._sqlite3_file_control=Z.Oe)(a,b,c,e);d._sqlite3_test_control=(a,b)=>(d._sqlite3_test_control=Z.Pe)(a,b);
|
||||
d._sqlite3_create_filename=(a,b,c,e,f)=>(d._sqlite3_create_filename=Z.Qe)(a,b,c,e,f);d._sqlite3_free_filename=a=>(d._sqlite3_free_filename=Z.Re)(a);d._sqlite3_uri_parameter=(a,b)=>(d._sqlite3_uri_parameter=Z.Se)(a,b);d._sqlite3_uri_key=(a,b)=>(d._sqlite3_uri_key=Z.Te)(a,b);d._sqlite3_uri_boolean=(a,b,c)=>(d._sqlite3_uri_boolean=Z.Ue)(a,b,c);d._sqlite3_uri_int64=(a,b,c,e)=>(d._sqlite3_uri_int64=Z.Ve)(a,b,c,e);d._sqlite3_filename_database=a=>(d._sqlite3_filename_database=Z.We)(a);
|
||||
d._sqlite3_filename_journal=a=>(d._sqlite3_filename_journal=Z.Xe)(a);d._sqlite3_filename_wal=a=>(d._sqlite3_filename_wal=Z.Ye)(a);d._sqlite3_db_name=(a,b)=>(d._sqlite3_db_name=Z.Ze)(a,b);d._sqlite3_db_filename=(a,b)=>(d._sqlite3_db_filename=Z._e)(a,b);d._sqlite3_db_readonly=(a,b)=>(d._sqlite3_db_readonly=Z.$e)(a,b);d._sqlite3_compileoption_used=a=>(d._sqlite3_compileoption_used=Z.af)(a);d._sqlite3_compileoption_get=a=>(d._sqlite3_compileoption_get=Z.bf)(a);
|
||||
d._sqlite3_sourceid=()=>(d._sqlite3_sourceid=Z.cf)();d._sqlite3mc_config=(a,b,c)=>(d._sqlite3mc_config=Z.df)(a,b,c);d._sqlite3mc_cipher_count=()=>(d._sqlite3mc_cipher_count=Z.ef)();d._sqlite3mc_cipher_index=a=>(d._sqlite3mc_cipher_index=Z.ff)(a);d._sqlite3mc_cipher_name=a=>(d._sqlite3mc_cipher_name=Z.gf)(a);d._sqlite3mc_config_cipher=(a,b,c,e)=>(d._sqlite3mc_config_cipher=Z.hf)(a,b,c,e);d._sqlite3mc_codec_data=(a,b,c)=>(d._sqlite3mc_codec_data=Z.jf)(a,b,c);
|
||||
d._sqlite3_key=(a,b,c)=>(d._sqlite3_key=Z.kf)(a,b,c);d._sqlite3_key_v2=(a,b,c,e)=>(d._sqlite3_key_v2=Z.lf)(a,b,c,e);d._sqlite3_rekey_v2=(a,b,c,e)=>(d._sqlite3_rekey_v2=Z.mf)(a,b,c,e);d._sqlite3_rekey=(a,b,c)=>(d._sqlite3_rekey=Z.nf)(a,b,c);d._sqlite3mc_register_cipher=(a,b,c)=>(d._sqlite3mc_register_cipher=Z.of)(a,b,c);var Rc=()=>(Rc=Z.pf)(),Tb=d._malloc=a=>(Tb=d._malloc=Z.qf)(a);d._free=a=>(d._free=Z.rf)(a);d._RegisterExtensionFunctions=a=>(d._RegisterExtensionFunctions=Z.sf)(a);
|
||||
d._set_authorizer=a=>(d._set_authorizer=Z.tf)(a);d._create_function=(a,b,c,e,f,h)=>(d._create_function=Z.uf)(a,b,c,e,f,h);d._create_module=(a,b,c,e)=>(d._create_module=Z.vf)(a,b,c,e);d._progress_handler=(a,b)=>(d._progress_handler=Z.wf)(a,b);d._register_vfs=(a,b,c,e)=>(d._register_vfs=Z.xf)(a,b,c,e);d._getSqliteFree=()=>(d._getSqliteFree=Z.yf)();var Tc=d._main=(a,b)=>(Tc=d._main=Z.zf)(a,b),db=(a,b)=>(db=Z.Bf)(a,b),Uc=()=>(Uc=Z.Cf)(),Oc=()=>(Oc=Z.Df)(),Pc=a=>(Pc=Z.Ef)(a),Nc=a=>(Nc=Z.Ff)(a);
|
||||
d._sqlite3_version=11592;d.getTempRet0=Uc;d.ccall=Y;d.cwrap=(a,b,c,e)=>{var f=!c||c.every(h=>"number"===h||"boolean"===h);return"string"!==b&&f&&!e?d["_"+a]:function(){return Y(a,b,c,arguments,e)}};
|
||||
d.addFunction=(a,b)=>{if(!Lc){Lc=new WeakMap;var c=X.length;if(Lc)for(var e=0;e<0+c;e++){var f=e;var h=Kc[f];h||(f>=Kc.length&&(Kc.length=f+1),Kc[f]=h=X.get(f));(f=h)&&Lc.set(f,e)}}if(c=Lc.get(a)||0)return c;if(Mc.length)c=Mc.pop();else{try{X.grow(1)}catch(n){if(!(n instanceof RangeError))throw n;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";}c=X.length-1}try{e=c,X.set(e,a),Kc[e]=X.get(e)}catch(n){if(!(n instanceof TypeError))throw n;if("function"==typeof WebAssembly.Function){e=WebAssembly.Function;
|
||||
f={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"};h={parameters:[],results:"v"==b[0]?[]:[f[b[0]]]};for(var k=1;k<b.length;++k)h.parameters.push(f[b[k]]);b=new e(h,a)}else{e=[1];f=b.slice(0,1);b=b.slice(1);h={i:127,p:127,j:126,f:125,d:124,e:111};e.push(96);k=b.length;128>k?e.push(k):e.push(k%128|128,k>>7);for(k=0;k<b.length;++k)e.push(h[b[k]]);"v"==f?e.push(0):e.push(1,h[f]);b=[0,97,115,109,1,0,0,0,1];f=e.length;128>f?b.push(f):b.push(f%128|128,f>>7);b.push.apply(b,e);b.push(2,7,1,1,101,1,
|
||||
102,0,0,7,5,1,1,102,0,0);b=new WebAssembly.Module(new Uint8Array(b));b=(new WebAssembly.Instance(b,{e:{f:a}})).exports.f}e=c;X.set(e,b);Kc[e]=X.get(e)}Lc.set(a,c);return c};d.setValue=K;d.getValue=J;d.UTF8ToString=(a,b)=>a?M(w,a,b):"";d.stringToUTF8=(a,b,c)=>Ra(a,w,b,c);d.lengthBytesUTF8=Qa;d.intArrayFromString=Sa;d.intArrayToString=function(a){for(var b=[],c=0;c<a.length;c++){var e=a[c];255<e&&(e&=255);b.push(String.fromCharCode(e))}return b.join("")};
|
||||
d.AsciiToString=a=>{for(var b="";;){var c=w[a++>>0];if(!c)return b;b+=String.fromCharCode(c)}};d.UTF16ToString=(a,b)=>{var c=a>>1;for(var e=c+b/2;!(c>=e)&&oa[c];)++c;c<<=1;if(32<c-a&&Qc)return Qc.decode(w.subarray(a,c));c="";for(e=0;!(e>=b/2);++e){var f=x[a+2*e>>1];if(0==f)break;c+=String.fromCharCode(f)}return c};d.stringToUTF16=(a,b,c)=>{void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)x[b>>1]=a.charCodeAt(f),b+=2;x[b>>1]=0;return b-e};
|
||||
d.UTF32ToString=(a,b)=>{for(var c=0,e="";!(c>=b/4);){var f=y[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e};d.stringToUTF32=(a,b,c)=>{void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+c-4;for(var f=0;f<a.length;++f){var h=a.charCodeAt(f);if(55296<=h&&57343>=h){var k=a.charCodeAt(++f);h=65536+((h&1023)<<10)|k&1023}y[b>>2]=h;b+=4;if(b+4>c)break}y[b>>2]=0;return b-e};d.writeArrayToMemory=(a,b)=>{v.set(a,b)};var Vc;
|
||||
ya=function Wc(){Vc||Xc();Vc||(ya=Wc)};
|
||||
function Xc(){function a(){if(!Vc&&(Vc=!0,d.calledRun=!0,!na)){d.noFSInit||Jb||(Jb=!0,Ib(),d.stdin=d.stdin,d.stdout=d.stdout,d.stderr=d.stderr,d.stdin?Kb("stdin",d.stdin):zb("/dev/tty","/dev/stdin"),d.stdout?Kb("stdout",null,d.stdout):zb("/dev/tty","/dev/stdout"),d.stderr?Kb("stderr",null,d.stderr):zb("/dev/tty1","/dev/stderr"),Fb("/dev/stdin",0),Fb("/dev/stdout",1),Fb("/dev/stderr",1));jb=!1;Ga(ta);Ga(ua);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(Yc){var b=Tc;try{var c=b(0,0);if(!Ha){if(d.onExit)d.onExit(c);
|
||||
na=!0}ea(c,new Fa(c))}catch(e){e instanceof Fa||"unwind"==e||ea(1,e)}}if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;)b=d.postRun.shift(),va.unshift(b);Ga(va)}}if(!(0<C)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)wa();Ga(sa);0<C||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
|
||||
if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();var Yc=!0;d.noInitialRun&&(Yc=!1);Xc();
|
||||
|
||||
|
||||
return moduleArg.ready
|
||||
|
||||
Binary file not shown.
@@ -25,76 +25,108 @@ import { VAULT_ERRORS } from "@notesnook/core/dist/api/vault";
|
||||
class Vault {
|
||||
static async createVault() {
|
||||
if (await db.vault.exists()) return false;
|
||||
return await showPasswordDialog("create_vault", async ({ password }) => {
|
||||
if (!password) return false;
|
||||
await db.vault.create(password);
|
||||
showToast("success", "Vault created.");
|
||||
return true;
|
||||
return showPasswordDialog({
|
||||
title: "Create your vault",
|
||||
subtitle: "A vault stores your notes in a password-encrypted storage.",
|
||||
inputs: {
|
||||
password: { label: "Password", autoComplete: "new-password" }
|
||||
},
|
||||
validate: async ({ password }) => {
|
||||
await db.vault.create(password);
|
||||
showToast("success", "Vault created.");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static async clearVault() {
|
||||
if (!(await db.vault.exists())) return false;
|
||||
return await showPasswordDialog("clear_vault", async ({ password }) => {
|
||||
if (!password) return false;
|
||||
try {
|
||||
|
||||
return showPasswordDialog({
|
||||
title: "Clear your vault",
|
||||
subtitle:
|
||||
"Enter vault password to unlock and remove all notes from the vault.",
|
||||
inputs: {
|
||||
password: { label: "Password", autoComplete: "current-password" }
|
||||
},
|
||||
validate: async ({ password }) => {
|
||||
await db.vault.clear(password);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static async deleteVault() {
|
||||
if (!(await db.vault.exists())) return false;
|
||||
return await showPasswordDialog(
|
||||
"delete_vault",
|
||||
async ({ password, deleteAllLockedNotes }) => {
|
||||
if (!password) return false;
|
||||
if (!(await db.user.verifyPassword(password))) return false;
|
||||
await db.vault.delete(!!deleteAllLockedNotes);
|
||||
return true;
|
||||
const result = await showPasswordDialog({
|
||||
title: "Delete your vault",
|
||||
subtitle: "Enter your account password to delete your vault.",
|
||||
inputs: {
|
||||
password: { label: "Password", autoComplete: "current-password" }
|
||||
},
|
||||
checks: {
|
||||
deleteAllLockedNotes: {
|
||||
text: "Delete all locked notes?",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
validate: ({ password }) => {
|
||||
return db.user.verifyPassword(password);
|
||||
}
|
||||
);
|
||||
});
|
||||
if (result) {
|
||||
await db.vault.delete(result.deleteAllLockedNotes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
static unlockVault() {
|
||||
return showPasswordDialog("ask_vault_password", ({ password }) => {
|
||||
if (!password) return false;
|
||||
return db.vault
|
||||
.unlock(password)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
return showPasswordDialog({
|
||||
title: "Unlock vault",
|
||||
subtitle: "Please enter your vault password to continue.",
|
||||
inputs: {
|
||||
password: { label: "Password", autoComplete: "current-password" }
|
||||
},
|
||||
validate: ({ password }) => {
|
||||
return db.vault.unlock(password).catch(() => false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static changeVaultPassword() {
|
||||
return showPasswordDialog(
|
||||
"change_password",
|
||||
async ({ oldPassword, newPassword }) => {
|
||||
if (!oldPassword || !newPassword) return false;
|
||||
return showPasswordDialog({
|
||||
title: "Change vault password",
|
||||
subtitle: "All locked notes will be re-encrypted with the new password.",
|
||||
inputs: {
|
||||
oldPassword: {
|
||||
label: "Old password",
|
||||
autoComplete: "current-password"
|
||||
},
|
||||
newPassword: { label: "New password", autoComplete: "new-password" }
|
||||
},
|
||||
validate: async ({ oldPassword, newPassword }) => {
|
||||
await db.vault.changePassword(oldPassword, newPassword);
|
||||
showToast("success", "Vault password changed.");
|
||||
return true;
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
static unlockNote(id: string, type = "unlock_note") {
|
||||
return showPasswordDialog(type, ({ password }) => {
|
||||
if (!password) return false;
|
||||
return db.vault
|
||||
.remove(id, password)
|
||||
.then(() => true)
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
return false;
|
||||
});
|
||||
static unlockNote(id: string) {
|
||||
return showPasswordDialog({
|
||||
title: "Unlock note",
|
||||
subtitle: "Your note will be unencrypted and removed from the vault.",
|
||||
inputs: {
|
||||
password: { label: "Password", autoComplete: "current-password" }
|
||||
},
|
||||
validate: async ({ password }) => {
|
||||
return db.vault
|
||||
.remove(id, password)
|
||||
.then(() => true)
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -117,9 +149,15 @@ class Vault {
|
||||
}
|
||||
|
||||
static askPassword(action: (password: string) => Promise<boolean>) {
|
||||
return showPasswordDialog("ask_vault_password", ({ password }) => {
|
||||
if (!password) return false;
|
||||
return action(password);
|
||||
return showPasswordDialog({
|
||||
title: "Unlock vault",
|
||||
subtitle: "Please enter your vault password to continue.",
|
||||
inputs: {
|
||||
password: { label: "Password", autoComplete: "current-password" }
|
||||
},
|
||||
validate: async ({ password }) => {
|
||||
return action(password);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ function ConfirmDialog<TCheckId extends string>(
|
||||
e.currentTarget.checked)
|
||||
}
|
||||
/>
|
||||
{check.text}{" "}
|
||||
{check.text}
|
||||
</Label>
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { useState, useCallback, useMemo } from "react";
|
||||
import { Box, Text } from "@theme-ui/components";
|
||||
import Dialog from "../components/dialog";
|
||||
import Field from "../components/field";
|
||||
import { Checkbox, Label } from "@theme-ui/components";
|
||||
|
||||
function PasswordDialog(props) {
|
||||
const { type, checks } = props;
|
||||
const [error, setError] = useState();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const isChangePasswordDialog = useMemo(() => {
|
||||
return type === "change_password" || type === "change_account_password";
|
||||
}, [type]);
|
||||
|
||||
const submit = useCallback(
|
||||
async (data) => {
|
||||
setIsLoading(true);
|
||||
setError(false);
|
||||
try {
|
||||
if (await props.validate(data)) {
|
||||
props.onDone();
|
||||
} else {
|
||||
setError("Wrong password.");
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (e) {
|
||||
setError(e.message);
|
||||
setIsLoading(false);
|
||||
}
|
||||
},
|
||||
[props]
|
||||
);
|
||||
return (
|
||||
<Dialog
|
||||
testId="password-dialog"
|
||||
isOpen={true}
|
||||
title={props.title}
|
||||
description={props.subtitle}
|
||||
icon={props.icon}
|
||||
onClose={() => props.onClose(false)}
|
||||
positiveButton={{
|
||||
form: "passwordForm",
|
||||
type: "submit",
|
||||
text: props.positiveButtonText,
|
||||
loading: isLoading,
|
||||
disabled: isLoading
|
||||
}}
|
||||
negativeButton={{
|
||||
text: "Cancel",
|
||||
onClick: () => props.onClose(false),
|
||||
disabled: isLoading
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
id="passwordForm"
|
||||
as="form"
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
const data = Object.fromEntries(new FormData(e.target).entries());
|
||||
setError();
|
||||
await submit(data);
|
||||
}}
|
||||
>
|
||||
<Field
|
||||
autoFocus
|
||||
required
|
||||
data-test-id="dialog-password"
|
||||
label={isChangePasswordDialog ? "Old password" : "Password"}
|
||||
type="password"
|
||||
autoComplete={
|
||||
type === "create_vault" ? "new-password" : "current-password"
|
||||
}
|
||||
id={isChangePasswordDialog ? "oldPassword" : "password"}
|
||||
name={isChangePasswordDialog ? "oldPassword" : "password"}
|
||||
/>
|
||||
|
||||
{isChangePasswordDialog ? (
|
||||
<Field
|
||||
required
|
||||
data-test-id="dialog-new-password"
|
||||
label="New password"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
id="newPassword"
|
||||
name="newPassword"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{checks &&
|
||||
checks.map((check) => (
|
||||
<Label
|
||||
key={check.key}
|
||||
mt={2}
|
||||
sx={{
|
||||
fontSize: "body",
|
||||
fontFamily: "body",
|
||||
alignItems: "center",
|
||||
color: "paragraph"
|
||||
}}
|
||||
>
|
||||
<Checkbox id={check.key} name={check.key} />
|
||||
{check.title}
|
||||
</Label>
|
||||
))}
|
||||
|
||||
{error && (
|
||||
<Text mt={1} variant={"error"}>
|
||||
{error}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
export default PasswordDialog;
|
||||
154
apps/web/src/dialogs/password-dialog.tsx
Normal file
154
apps/web/src/dialogs/password-dialog.tsx
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { useState } from "react";
|
||||
import { Box, Text } from "@theme-ui/components";
|
||||
import Dialog from "../components/dialog";
|
||||
import Field, { FieldProps } from "../components/field";
|
||||
import { Checkbox, Label } from "@theme-ui/components";
|
||||
import { Perform } from "../common/dialog-controller";
|
||||
import { mdToHtml } from "../utils/md";
|
||||
|
||||
type Check = { text: string; default?: boolean };
|
||||
export type PasswordDialogProps<
|
||||
TInputId extends string,
|
||||
TCheckId extends string
|
||||
> = {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
message?: string;
|
||||
inputs: Record<TInputId, FieldProps>;
|
||||
validate: (passwords: Record<TInputId, string>) => Promise<boolean>;
|
||||
checks?: Record<TCheckId, Check>;
|
||||
onClose: Perform<boolean | Record<TCheckId, boolean>>;
|
||||
};
|
||||
function PasswordDialog<TInputId extends string, TCheckId extends string>(
|
||||
props: PasswordDialogProps<TInputId, TCheckId>
|
||||
) {
|
||||
const { checks, inputs, message, validate, onClose } = props;
|
||||
const [error, setError] = useState<string>();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
testId="password-dialog"
|
||||
isOpen={true}
|
||||
title={props.title}
|
||||
description={props.subtitle}
|
||||
onClose={() => onClose(false)}
|
||||
positiveButton={{
|
||||
form: "passwordForm",
|
||||
type: "submit",
|
||||
text: "Submit",
|
||||
loading: isLoading,
|
||||
disabled: isLoading
|
||||
}}
|
||||
negativeButton={{ text: "Cancel", onClick: () => onClose(false) }}
|
||||
>
|
||||
<Box
|
||||
id="passwordForm"
|
||||
as="form"
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
setIsLoading(true);
|
||||
setError(undefined);
|
||||
try {
|
||||
const formData = new FormData(e.target as HTMLFormElement);
|
||||
const passwords = Object.fromEntries(
|
||||
Object.keys(inputs).map((id) => {
|
||||
const inputData = formData.get(id);
|
||||
if (!inputData) throw new Error(`${id} is required.`);
|
||||
return [id, inputData.toString()];
|
||||
})
|
||||
) as Record<TInputId, string>;
|
||||
|
||||
if (await validate(passwords)) {
|
||||
onClose(
|
||||
checks
|
||||
? (Object.fromEntries(
|
||||
Object.keys(checks).map((id) => {
|
||||
return [id, formData.has(id)];
|
||||
})
|
||||
) as Record<TCheckId, boolean>)
|
||||
: true
|
||||
);
|
||||
} else {
|
||||
setError("Wrong password.");
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : JSON.stringify(e));
|
||||
setIsLoading(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{message ? (
|
||||
<Text
|
||||
as="span"
|
||||
variant="body"
|
||||
dangerouslySetInnerHTML={{ __html: mdToHtml(message) }}
|
||||
/>
|
||||
) : null}
|
||||
{Object.entries<FieldProps>(inputs).map(([id, input], index) => (
|
||||
<Field
|
||||
autoFocus={index === 0}
|
||||
{...input}
|
||||
key={id}
|
||||
id={id}
|
||||
name={id}
|
||||
data-test-id={id}
|
||||
required
|
||||
type="password"
|
||||
/>
|
||||
))}
|
||||
|
||||
{checks
|
||||
? Object.entries<Check>(checks).map(([id, check]) => (
|
||||
<Label
|
||||
key={id}
|
||||
mt={2}
|
||||
sx={{
|
||||
fontSize: "body",
|
||||
fontFamily: "body",
|
||||
alignItems: "center",
|
||||
color: "paragraph"
|
||||
}}
|
||||
>
|
||||
<Checkbox
|
||||
id={id}
|
||||
name={id}
|
||||
defaultChecked={check.default}
|
||||
sx={{ mr: "small", width: 18, height: 18 }}
|
||||
/>
|
||||
{check.text}
|
||||
</Label>
|
||||
))
|
||||
: null}
|
||||
|
||||
{error && (
|
||||
<Text mt={1} variant={"error"}>
|
||||
{error}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
export default PasswordDialog;
|
||||
255
apps/web/src/dialogs/settings/app-lock-settings.tsx
Normal file
255
apps/web/src/dialogs/settings/app-lock-settings.tsx
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SettingsGroup } from "./types";
|
||||
import { useStore as useSettingStore } from "../../stores/setting-store";
|
||||
import { useStore as useUserStore } from "../../stores/user-store";
|
||||
import {
|
||||
showPasswordDialog,
|
||||
showPromptDialog
|
||||
} from "../../common/dialog-controller";
|
||||
import { KeyChain } from "../../interfaces/key-store";
|
||||
import { showToast } from "../../utils/toast";
|
||||
import { WebAuthn } from "../../utils/webauthn";
|
||||
import { generatePassword } from "../../utils/password-generator";
|
||||
|
||||
export const AppLockSettings: SettingsGroup[] = [
|
||||
{
|
||||
key: "vault",
|
||||
section: "app-lock",
|
||||
header: "App lock",
|
||||
settings: [
|
||||
{
|
||||
key: "enable-app-lock",
|
||||
title: "Enable app lock",
|
||||
onStateChange: (listener) =>
|
||||
useSettingStore.subscribe((s) => s.appLockSettings, listener),
|
||||
components: [
|
||||
{
|
||||
type: "toggle",
|
||||
toggle: async () => {
|
||||
const isEnabled =
|
||||
useSettingStore.getState().appLockSettings.enabled;
|
||||
const result = await showPasswordDialog({
|
||||
title: "App lock",
|
||||
subtitle: `Enter pin or password to ${
|
||||
isEnabled ? "disable" : "enable"
|
||||
} app lock.`,
|
||||
inputs: {
|
||||
password: {
|
||||
label: "Password",
|
||||
autoComplete: "new-password"
|
||||
}
|
||||
},
|
||||
async validate({ password }) {
|
||||
if (isEnabled)
|
||||
await KeyChain.unlock(
|
||||
{
|
||||
type: "password",
|
||||
id: "primary",
|
||||
password
|
||||
},
|
||||
{ permanent: true }
|
||||
);
|
||||
else
|
||||
await KeyChain.lock({
|
||||
type: "password",
|
||||
id: "primary",
|
||||
password
|
||||
});
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (result)
|
||||
useSettingStore.getState().setAppLockSettings({
|
||||
enabled: !isEnabled
|
||||
});
|
||||
},
|
||||
isToggled: () => useSettingStore.getState().appLockSettings.enabled
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "lock-app-after",
|
||||
title: "Lock app after",
|
||||
description:
|
||||
"How long should the app wait to lock itself after going into the background or going idle?",
|
||||
isHidden: () => !useSettingStore.getState().appLockSettings.enabled,
|
||||
onStateChange: (listener) =>
|
||||
useSettingStore.subscribe((s) => s.appLockSettings, listener),
|
||||
components: [
|
||||
{
|
||||
type: "dropdown",
|
||||
options: [
|
||||
{ title: "Immediately", value: "0" },
|
||||
{ title: "1 minute", value: "1" },
|
||||
{ title: "5 minutes", value: "5" },
|
||||
{ title: "10 minutes", value: "10" },
|
||||
{ title: "15 minutes", value: "15" },
|
||||
{ title: "30 minutes", value: "30" },
|
||||
{ title: "45 minutes", value: "45" },
|
||||
{ title: "1 hour", value: "60" },
|
||||
{ title: "Never", value: "-1" }
|
||||
],
|
||||
onSelectionChanged: (value) =>
|
||||
useSettingStore
|
||||
.getState()
|
||||
.setAppLockSettings({ lockAfter: parseInt(value) }),
|
||||
selectedOption: () =>
|
||||
useSettingStore.getState().appLockSettings.lockAfter.toString()
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "password-pin",
|
||||
title: "Password/pin",
|
||||
description: "The password/pin for unlocking the app.",
|
||||
isHidden: () => !useSettingStore.getState().appLockSettings.enabled,
|
||||
onStateChange: (listener) =>
|
||||
useSettingStore.subscribe((s) => s.appLockSettings, listener),
|
||||
components: [
|
||||
{
|
||||
type: "button",
|
||||
title: "Change",
|
||||
action: async () => {
|
||||
const result = await showPasswordDialog({
|
||||
title: "Change app lock password",
|
||||
inputs: {
|
||||
oldPassword: {
|
||||
label: "Old password",
|
||||
autoComplete: "current-password"
|
||||
},
|
||||
newPassword: {
|
||||
label: "New password",
|
||||
autoComplete: "new-password"
|
||||
}
|
||||
},
|
||||
validate({ newPassword, oldPassword }) {
|
||||
return KeyChain.changeCredential(
|
||||
{
|
||||
type: "password",
|
||||
id: "primary",
|
||||
password: oldPassword
|
||||
},
|
||||
{
|
||||
type: "password",
|
||||
id: "primary",
|
||||
password: newPassword
|
||||
}
|
||||
)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
}
|
||||
});
|
||||
if (result) showToast("success", "App lock password changed!");
|
||||
},
|
||||
variant: "secondary"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
key: "security-key",
|
||||
title: "Use security key",
|
||||
description: "Use security key (e.g. YubiKey) for unlocking the app.",
|
||||
isHidden: () => !useSettingStore.getState().appLockSettings.enabled,
|
||||
onStateChange: (listener) =>
|
||||
useSettingStore.subscribe((s) => s.appLockSettings, listener),
|
||||
components: () => [
|
||||
useSettingStore.getState().appLockSettings.securityKey
|
||||
? {
|
||||
type: "button",
|
||||
title: "Unregister",
|
||||
async action() {
|
||||
await KeyChain.removeCredential({
|
||||
type: "key",
|
||||
id: "securityKey"
|
||||
});
|
||||
useSettingStore
|
||||
.getState()
|
||||
.setAppLockSettings({ securityKey: undefined });
|
||||
},
|
||||
variant: "secondary"
|
||||
}
|
||||
: {
|
||||
type: "button",
|
||||
title: "Register",
|
||||
action: async () => {
|
||||
const user = useUserStore.getState().user;
|
||||
const username =
|
||||
user?.email ||
|
||||
(await showPromptDialog({
|
||||
title: "Enter your username",
|
||||
description:
|
||||
"This username will be used to distinguish between different credentials in your security key. Make sure it is unique."
|
||||
}));
|
||||
if (!username)
|
||||
return showToast("error", "Username is required.");
|
||||
|
||||
const userId = user
|
||||
? Buffer.from(user.id, "hex")
|
||||
: // fixed id for unregistered users to avoid creating duplicate credentials
|
||||
new Uint8Array([0x61, 0xd1, 0x20, 0x82]);
|
||||
|
||||
try {
|
||||
const { firstSalt, rawId, transports } =
|
||||
await WebAuthn.registerSecurityKey(userId, username);
|
||||
|
||||
showToast(
|
||||
"success",
|
||||
"Security key registered. Generating encryption key..."
|
||||
);
|
||||
|
||||
const label = generatePassword();
|
||||
const { encryptionKey } = await WebAuthn.getEncryptionKey({
|
||||
firstSalt,
|
||||
label,
|
||||
rawId,
|
||||
transports
|
||||
});
|
||||
|
||||
await KeyChain.lock({
|
||||
type: "key",
|
||||
key: encryptionKey,
|
||||
id: "securityKey"
|
||||
});
|
||||
|
||||
useSettingStore.getState().setAppLockSettings({
|
||||
securityKey: {
|
||||
firstSalt: Buffer.from(firstSalt).toString("base64"),
|
||||
label,
|
||||
rawId: Buffer.from(rawId).toString("base64"),
|
||||
transports
|
||||
}
|
||||
});
|
||||
|
||||
showToast(
|
||||
"success",
|
||||
"Security key successfully registered."
|
||||
);
|
||||
} catch (e) {
|
||||
showToast("error", (e as Error).message);
|
||||
}
|
||||
},
|
||||
variant: "secondary"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
@@ -47,17 +47,31 @@ export const AuthenticationSettings: SettingsGroup[] = [
|
||||
variant: "secondary",
|
||||
action: async () => {
|
||||
await createBackup();
|
||||
const result = await showPasswordDialog(
|
||||
"change_account_password",
|
||||
async ({ newPassword, oldPassword }) => {
|
||||
if (!newPassword || !oldPassword) return false;
|
||||
const result = await showPasswordDialog({
|
||||
title: "Change account password",
|
||||
message: `All your data will be re-encrypted and synced with the new password.
|
||||
|
||||
It is recommended that you **log out from all other devices** before continuing.
|
||||
|
||||
If this process is interrupted, there is a high chance of data corruption so **please do NOT shut down your device or close your browser** until this process completes.`,
|
||||
inputs: {
|
||||
oldPassword: {
|
||||
label: "Old password",
|
||||
autoComplete: "current-password"
|
||||
},
|
||||
newPassword: {
|
||||
label: "New password",
|
||||
autoComplete: "new-password"
|
||||
}
|
||||
},
|
||||
validate: async ({ oldPassword, newPassword }) => {
|
||||
await db.user.clearSessions();
|
||||
return (
|
||||
(await db.user.changePassword(oldPassword, newPassword)) ||
|
||||
false
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
if (result) {
|
||||
showToast("success", "Account password changed!");
|
||||
await showRecoveryKeyDialog();
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
Appearance,
|
||||
Backup,
|
||||
Behaviour,
|
||||
CellphoneLock,
|
||||
Desktop,
|
||||
Documentation,
|
||||
Editor,
|
||||
@@ -67,6 +68,7 @@ import { AppearanceSettings } from "./appearance-settings";
|
||||
import { debounce } from "@notesnook/common";
|
||||
import { SubscriptionSettings } from "./subscription-settings";
|
||||
import { ScopedThemeProvider } from "../../components/theme-provider";
|
||||
import { AppLockSettings } from "./app-lock-settings";
|
||||
|
||||
type SettingsDialogProps = { onClose: Perform };
|
||||
|
||||
@@ -124,6 +126,7 @@ const sectionGroups: SectionGroup[] = [
|
||||
key: "security",
|
||||
title: "Security & privacy",
|
||||
sections: [
|
||||
{ key: "app-lock", title: "App lock", icon: CellphoneLock },
|
||||
{ key: "vault", title: "Vault", icon: ShieldLock },
|
||||
{ key: "privacy", title: "Privacy", icon: Privacy }
|
||||
]
|
||||
@@ -149,6 +152,7 @@ const SettingsGroups = [
|
||||
...NotificationsSettings,
|
||||
...BackupExportSettings,
|
||||
...ImporterSettings,
|
||||
...AppLockSettings,
|
||||
...VaultSettings,
|
||||
...PrivacySettings,
|
||||
...EditorSettings,
|
||||
|
||||
@@ -101,11 +101,20 @@ export const ProfileSettings: SettingsGroup[] = [
|
||||
type: "button",
|
||||
variant: "error",
|
||||
title: "Delete account",
|
||||
action: async () =>
|
||||
showPasswordDialog("delete_account", async ({ password }) => {
|
||||
if (!password) return false;
|
||||
await db.user.deleteUser(password);
|
||||
return true;
|
||||
action: () =>
|
||||
showPasswordDialog({
|
||||
title: "Delete your account",
|
||||
message: ` All your data will be permanently deleted with **no way of recovery**. Proceed with caution.`,
|
||||
inputs: {
|
||||
password: {
|
||||
label: "Password",
|
||||
autoComplete: "current-password"
|
||||
}
|
||||
},
|
||||
validate: async ({ password }) => {
|
||||
await db.user.deleteUser(password);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
}
|
||||
]
|
||||
|
||||
@@ -33,6 +33,7 @@ export type SectionKeys =
|
||||
| "export"
|
||||
| "importer"
|
||||
| "vault"
|
||||
| "app-lock"
|
||||
| "privacy"
|
||||
| "support"
|
||||
| "legal"
|
||||
|
||||
25
apps/web/src/global.d.ts
vendored
25
apps/web/src/global.d.ts
vendored
@@ -36,6 +36,31 @@ declare global {
|
||||
os?: () => NodeJS.Platform | "mas";
|
||||
NativeNNCrypto?: new () => import("@notesnook/crypto").NNCrypto;
|
||||
}
|
||||
|
||||
interface AuthenticationExtensionsClientInputs {
|
||||
prf?: {
|
||||
eval: {
|
||||
first: BufferSource;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
interface AuthenticationExtensionsClientOutputs {
|
||||
prf?: {
|
||||
enabled?: boolean;
|
||||
results?: {
|
||||
first: ArrayBuffer;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
interface PublicKeyCredentialRequestOptions {
|
||||
hints?: ("security-key" | "client-device" | "hybrid")[];
|
||||
}
|
||||
interface PublicKeyCredentialCreationOptions {
|
||||
hints?: ("security-key" | "client-device" | "hybrid")[];
|
||||
}
|
||||
|
||||
interface FileSystemFileHandle {
|
||||
createSyncAccessHandle(options?: {
|
||||
mode: "read-only" | "readwrite" | "readwrite-unsafe";
|
||||
|
||||
@@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { Routes, init } from "./bootstrap";
|
||||
import { logger } from "./utils/logger";
|
||||
import { loadDatabase } from "./hooks/use-database";
|
||||
import { AppEventManager, AppEvents } from "./common/app-events";
|
||||
import { BaseThemeProvider } from "./components/theme-provider";
|
||||
import { register } from "./utils/stream-saver/mitm";
|
||||
@@ -32,12 +31,16 @@ async function renderApp() {
|
||||
const { component, props, path } = await init();
|
||||
|
||||
if (serviceWorkerWhitelist.includes(path)) await initializeServiceWorker();
|
||||
if (IS_DESKTOP_APP) await loadDatabase("db");
|
||||
if (IS_DESKTOP_APP) {
|
||||
const { loadDatabase } = await import("./hooks/use-database");
|
||||
await loadDatabase("db");
|
||||
}
|
||||
|
||||
const { default: Component } = await component();
|
||||
const rootElement = document.getElementById("root");
|
||||
if (!rootElement) return;
|
||||
|
||||
const { default: AppLock } = await import("./views/app-lock");
|
||||
const root = createRoot(rootElement);
|
||||
root.render(
|
||||
<BaseThemeProvider
|
||||
@@ -45,7 +48,9 @@ async function renderApp() {
|
||||
addGlobalStyles
|
||||
sx={{ height: "100%" }}
|
||||
>
|
||||
<Component route={props?.route || "login:email"} />
|
||||
<AppLock>
|
||||
<Component route={props?.route || "login:email"} />
|
||||
</AppLock>
|
||||
</BaseThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
355
apps/web/src/interfaces/key-store.ts
Normal file
355
apps/web/src/interfaces/key-store.ts
Normal file
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Cipher } from "@notesnook/crypto";
|
||||
import { IKVStore, IndexedDBKVStore, MemoryKVStore } from "./key-value";
|
||||
import { NNCrypto } from "./nncrypto";
|
||||
import { isFeatureSupported } from "../utils/feature-check";
|
||||
import { isCipher } from "@notesnook/core/dist/database/crypto";
|
||||
|
||||
type BaseCredential = { id: string };
|
||||
type PasswordCredential = BaseCredential & {
|
||||
type: "password";
|
||||
password: string;
|
||||
};
|
||||
|
||||
type KeyCredential = BaseCredential & {
|
||||
type: "key";
|
||||
key: CryptoKey;
|
||||
};
|
||||
|
||||
type Credential = PasswordCredential | KeyCredential;
|
||||
export type SerializableCredential = Omit<Credential, "key" | "password">;
|
||||
|
||||
type EncryptedData = {
|
||||
iv: Uint8Array;
|
||||
cipher: ArrayBuffer;
|
||||
};
|
||||
|
||||
function isEncryptedData(data: any): data is EncryptedData {
|
||||
return data.iv instanceof Uint8Array && typeof data.cipher !== "string";
|
||||
}
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
const decoder = new TextDecoder();
|
||||
|
||||
/**
|
||||
* This is not "super" secure but there's nothing better on Web.
|
||||
* Ideally, the key store should be encrypted with user's password
|
||||
* or user's biometric. Since we don't have any of that, we have to
|
||||
* resort to using CryptoKeys which are "non-exportable" when stored
|
||||
* in IndexedDB. That doesn't mean they are "secure" - just that no
|
||||
* one can run off with them. They can still be used by scripts for
|
||||
* encryption/decryption in the browser.
|
||||
*
|
||||
* There's 4 problems with this:
|
||||
* 1. Anyone can use the CryptoKeys to encrypt/decrypt values in the
|
||||
* keystore
|
||||
* 2. Anyone can delete the CryptoKeys causing data corruption since
|
||||
* without the CryptoKeys, there's no way to decrypt the values in
|
||||
* the keystore.
|
||||
* 3. Anyone can modify the values.
|
||||
* 4. Anyone can add new values.
|
||||
*
|
||||
* In short, there's no way to guarantee data integrity i.e., a keystore
|
||||
* cannot sustain 99% of attack vectors inside the browser.
|
||||
*
|
||||
* What if we use user's password/pin?
|
||||
*
|
||||
* 1. This will only work if the pin/password is not stored in any way and
|
||||
* requested everytime.
|
||||
* 2. No one can decrypt values in the keystore without the pin/password
|
||||
* 3. Anyone can add new values & modify old ones (there's no write lock).
|
||||
* However, modification is pointless since changing a single byte would
|
||||
* trigger HMAC authentication error. Adding new values is also pointless
|
||||
* because the app won't ever read them.
|
||||
* 4. The values can be deleted in which case we will have a sabotaged database
|
||||
* but the attacker still won't have any access to the actual data.
|
||||
* 5. In conclusion, this is the most secure way for devices where there's no
|
||||
* system level keystore. The compromise here is that the database won't be
|
||||
* encrypted if the user doesn't turn on app lock.
|
||||
*/
|
||||
class KeyStore {
|
||||
private secretStore: IKVStore;
|
||||
private metadataStore: IKVStore;
|
||||
private keyId = "key";
|
||||
private key?: CryptoKey;
|
||||
|
||||
constructor(dbName: string) {
|
||||
console.log("key store", dbName);
|
||||
this.metadataStore = isFeatureSupported("indexedDB")
|
||||
? new IndexedDBKVStore(dbName, "metadata")
|
||||
: new MemoryKVStore();
|
||||
this.secretStore = isFeatureSupported("indexedDB")
|
||||
? new IndexedDBKVStore(dbName, "secrets")
|
||||
: new MemoryKVStore();
|
||||
}
|
||||
|
||||
public async lock(credential: Credential) {
|
||||
const originalKey = await this.getKey();
|
||||
const key = new Uint8Array(
|
||||
await window.crypto.subtle.exportKey("raw", originalKey)
|
||||
);
|
||||
|
||||
await this.metadataStore.set(
|
||||
this.getCredentialKey(credential),
|
||||
await this.encryptKey(credential, key)
|
||||
);
|
||||
|
||||
await this.metadataStore.delete(this.keyId);
|
||||
await this.metadataStore.set<SerializableCredential[]>("credentials", [
|
||||
...(await this.getCredentials()),
|
||||
{ id: credential.id, type: credential.type }
|
||||
]);
|
||||
|
||||
this.key = originalKey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public async unlock(
|
||||
credential: Credential,
|
||||
options?: {
|
||||
permanent?: boolean;
|
||||
}
|
||||
) {
|
||||
if (!(await this.isLocked())) return this;
|
||||
|
||||
const encryptedKey = await this.metadataStore.get<
|
||||
Cipher<"base64"> | EncryptedData
|
||||
>(this.getCredentialKey(credential));
|
||||
if (!encryptedKey) return this;
|
||||
|
||||
const decryptedKey = await this.decryptKey(encryptedKey, credential);
|
||||
if (!decryptedKey) throw new Error("Could not decrypt key.");
|
||||
|
||||
const key = await window.crypto.subtle.importKey(
|
||||
"raw",
|
||||
decryptedKey,
|
||||
{ name: "AES-GCM", length: 256 },
|
||||
true,
|
||||
["encrypt", "decrypt"]
|
||||
);
|
||||
|
||||
if (options?.permanent) {
|
||||
for (const credential of await this.getCredentials()) {
|
||||
await this.metadataStore.delete(this.getCredentialKey(credential));
|
||||
}
|
||||
await this.metadataStore.set(this.keyId, key);
|
||||
this.key = undefined;
|
||||
} else this.key = key;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public relock() {
|
||||
this.key = undefined;
|
||||
}
|
||||
|
||||
public async changeCredential(
|
||||
oldCredential: Credential,
|
||||
newCredential: Credential
|
||||
) {
|
||||
const encryptedKey = await this.metadataStore.get<Cipher<"base64">>(
|
||||
this.getCredentialKey(oldCredential)
|
||||
);
|
||||
if (!encryptedKey) return this;
|
||||
|
||||
const decryptedKey = await this.decryptKey(encryptedKey, oldCredential);
|
||||
if (!decryptedKey) throw new Error("Could not decrypt key.");
|
||||
|
||||
const reencryptedKey = await this.encryptKey(newCredential, decryptedKey);
|
||||
if (!reencryptedKey) throw new Error("Could not reencrypt key.");
|
||||
|
||||
await this.metadataStore.set(
|
||||
this.getCredentialKey(newCredential),
|
||||
reencryptedKey
|
||||
);
|
||||
}
|
||||
|
||||
public async verifyCredential(credential: Credential) {
|
||||
try {
|
||||
const encryptedKey = await this.metadataStore.get<Cipher<"base64">>(
|
||||
this.getCredentialKey(credential)
|
||||
);
|
||||
if (!encryptedKey) return false;
|
||||
|
||||
const decryptedKey = await this.decryptKey(encryptedKey, credential);
|
||||
return !!decryptedKey;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async removeCredential(credential: SerializableCredential) {
|
||||
await this.metadataStore.delete(this.getCredentialKey(credential));
|
||||
const credentials = await this.getCredentials();
|
||||
const index = credentials.findIndex(
|
||||
(c) => c.type === credential.type && c.id === credential.id
|
||||
);
|
||||
credentials.splice(index, 1);
|
||||
this.metadataStore.set("credentials", credentials);
|
||||
}
|
||||
|
||||
public async extractKey() {
|
||||
if (await this.isLocked())
|
||||
throw new Error("Please unlock the key store to extract its key.");
|
||||
|
||||
const key = await window.crypto.subtle.exportKey(
|
||||
"raw",
|
||||
await this.getKey()
|
||||
);
|
||||
return Buffer.from(key).toString("base64");
|
||||
}
|
||||
|
||||
async isLocked() {
|
||||
return (await this.getCredentials()).length > 0 && !this.key;
|
||||
}
|
||||
|
||||
public async getCredentials() {
|
||||
return (
|
||||
(await this.metadataStore.get<SerializableCredential[]>("credentials")) ||
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
public async set(name: string, value: string) {
|
||||
if (await this.isLocked())
|
||||
throw new Error("Please unlock the key store to set values.");
|
||||
|
||||
return this.secretStore.set(
|
||||
name,
|
||||
await this.encrypt(value, await this.getKey())
|
||||
);
|
||||
}
|
||||
|
||||
public async get(name: string): Promise<string | undefined> {
|
||||
if (await this.isLocked())
|
||||
throw new Error("Please unlock the key store to get values.");
|
||||
|
||||
const blob = await this.secretStore.get<EncryptedData>(name);
|
||||
if (!blob) return;
|
||||
return this.decrypt(blob, await this.getKey());
|
||||
}
|
||||
|
||||
public async clear(): Promise<void> {
|
||||
await this.secretStore.clear();
|
||||
await this.metadataStore.clear();
|
||||
this.key = undefined;
|
||||
}
|
||||
|
||||
private async decryptKey(
|
||||
encryptedKey: Cipher<"base64"> | EncryptedData,
|
||||
credential: PasswordCredential | KeyCredential
|
||||
): Promise<Uint8Array | undefined> {
|
||||
if (credential.type === "password" && isCipher(encryptedKey)) {
|
||||
return await NNCrypto.decrypt(
|
||||
{ password: credential.password },
|
||||
encryptedKey,
|
||||
"uint8array"
|
||||
);
|
||||
} else if (credential.type === "key" && isEncryptedData(encryptedKey)) {
|
||||
return new Uint8Array(
|
||||
await window.crypto.subtle.decrypt(
|
||||
{
|
||||
name: "AES-GCM",
|
||||
iv: encryptedKey.iv
|
||||
},
|
||||
credential.key,
|
||||
encryptedKey.cipher
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async encryptKey(
|
||||
credential: PasswordCredential | KeyCredential,
|
||||
key: Uint8Array
|
||||
) {
|
||||
if (credential.type === "password") {
|
||||
return await NNCrypto.encrypt(
|
||||
{ password: credential.password },
|
||||
key,
|
||||
"uint8array",
|
||||
"base64"
|
||||
);
|
||||
} else if (credential.type === "key") {
|
||||
if (!credential.key?.usages.includes("encrypt"))
|
||||
throw new Error("Cannot use this key to encrypt.");
|
||||
|
||||
return await this.encrypt(key, credential.key);
|
||||
}
|
||||
}
|
||||
|
||||
private async getKey() {
|
||||
if (this.key) return this.key;
|
||||
if ((await this.getCredentials()).length > 0)
|
||||
throw new Error("Key store is locked.");
|
||||
|
||||
let key = await this.metadataStore.get<CryptoKey>(this.keyId);
|
||||
if (!key) {
|
||||
key = await window.crypto.subtle.generateKey(
|
||||
{
|
||||
name: "AES-GCM",
|
||||
length: 256
|
||||
},
|
||||
true,
|
||||
["encrypt", "decrypt"]
|
||||
);
|
||||
await this.metadataStore.set(this.keyId, key);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
private async encrypt(data: string | ArrayBuffer, key: CryptoKey) {
|
||||
const iv = window.crypto.getRandomValues(new Uint8Array(12));
|
||||
const cipher = await window.crypto.subtle.encrypt(
|
||||
{
|
||||
name: "AES-GCM",
|
||||
iv: iv
|
||||
},
|
||||
key,
|
||||
typeof data === "string" ? encoder.encode(data) : data
|
||||
);
|
||||
|
||||
return <EncryptedData>{
|
||||
iv,
|
||||
cipher
|
||||
};
|
||||
}
|
||||
|
||||
private async decrypt(data: EncryptedData, key: CryptoKey) {
|
||||
const plainText = await window.crypto.subtle.decrypt(
|
||||
{
|
||||
name: "AES-GCM",
|
||||
iv: data.iv
|
||||
},
|
||||
key,
|
||||
data.cipher
|
||||
);
|
||||
return decoder.decode(plainText);
|
||||
}
|
||||
|
||||
private getCredentialKey(credential: SerializableCredential) {
|
||||
return `${this.keyId}-${credential.type}-${credential.id}`;
|
||||
}
|
||||
}
|
||||
|
||||
console.trace("key store!");
|
||||
export const KeyChain = new KeyStore("KeyChain");
|
||||
export type IKeyStore = typeof KeyStore.prototype;
|
||||
@@ -174,17 +174,6 @@ export type UseStore = <T>(
|
||||
export class IndexedDBKVStore implements IKVStore {
|
||||
store: UseStore;
|
||||
|
||||
static async isIndexedDBSupported(): Promise<boolean> {
|
||||
if (!("indexedDB" in window)) return false;
|
||||
try {
|
||||
await promisifyIDBRequest(indexedDB.open("checkIDBSupport"));
|
||||
return true;
|
||||
} catch {
|
||||
console.error("IndexedDB is not supported in this browser.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
constructor(databaseName: string, storeName: string) {
|
||||
this.store = this.createStore(databaseName, storeName);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ import {
|
||||
} from "./key-value";
|
||||
import { NNCrypto } from "./nncrypto";
|
||||
import type { Cipher, SerializedKey } from "@notesnook/crypto/dist/src/types";
|
||||
import { isFeatureSupported } from "../utils/feature-check";
|
||||
import { IKeyStore } from "./key-store";
|
||||
import { User } from "@notesnook/core/dist/api/user-manager";
|
||||
|
||||
type EncryptedKey = { iv: Uint8Array; cipher: BufferSource };
|
||||
export type DatabasePersistence = "memory" | "db";
|
||||
@@ -33,20 +36,34 @@ export type DatabasePersistence = "memory" | "db";
|
||||
const APP_SALT = "oVzKtazBo7d8sb7TBvY9jw";
|
||||
|
||||
export class NNStorage implements IStorage {
|
||||
database!: IKVStore;
|
||||
database: IKVStore;
|
||||
|
||||
static async createInstance(
|
||||
constructor(
|
||||
name: string,
|
||||
private readonly keyStore: IKeyStore | null,
|
||||
persistence: DatabasePersistence = "db"
|
||||
) {
|
||||
const storage = new NNStorage();
|
||||
storage.database =
|
||||
this.database =
|
||||
persistence === "memory"
|
||||
? new MemoryKVStore()
|
||||
: (await IndexedDBKVStore.isIndexedDBSupported())
|
||||
: isFeatureSupported("indexedDB")
|
||||
? new IndexedDBKVStore(name, "keyvaluepairs")
|
||||
: new LocalStorageKVStore();
|
||||
return storage;
|
||||
}
|
||||
|
||||
async migrate() {
|
||||
if (!this.keyStore) return;
|
||||
const user = await this.read<User>("user");
|
||||
if (!user) return;
|
||||
|
||||
const key = await this._getCryptoKey(user.email);
|
||||
if (!key) return;
|
||||
|
||||
await this.database.deleteMany([
|
||||
`_uk_@${user.email}`,
|
||||
`_uk_@${user.email}@_k`
|
||||
]);
|
||||
await this.keyStore.set("userEncryptionKey", key);
|
||||
}
|
||||
|
||||
read<T>(key: string): Promise<T | undefined> {
|
||||
@@ -83,43 +100,22 @@ export class NNStorage implements IStorage {
|
||||
return this.database.keys();
|
||||
}
|
||||
|
||||
async deriveCryptoKey(name: string, credentials: SerializedKey) {
|
||||
async deriveCryptoKey(credentials: SerializedKey) {
|
||||
if (!this.keyStore) throw new Error("No key store found!");
|
||||
|
||||
const { password, salt } = credentials;
|
||||
if (!password) throw new Error("Invalid data provided to deriveCryptoKey.");
|
||||
|
||||
const keyData = await NNCrypto.exportKey(password, salt);
|
||||
if (!keyData.key) throw new Error("Invalid key.");
|
||||
|
||||
if (
|
||||
(await IndexedDBKVStore.isIndexedDBSupported()) &&
|
||||
window?.crypto?.subtle &&
|
||||
keyData.key
|
||||
) {
|
||||
const pbkdfKey = await derivePBKDF2Key(password);
|
||||
await this.write(name, pbkdfKey);
|
||||
const cipheredKey = await aesEncrypt(pbkdfKey, keyData.key);
|
||||
await this.write(`${name}@_k`, cipheredKey);
|
||||
} else if (keyData.key) {
|
||||
await this.write(`${name}@_k`, keyData.key);
|
||||
} else {
|
||||
throw new Error(`Invalid key.`);
|
||||
}
|
||||
await this.keyStore.set("userEncryptionKey", keyData.key);
|
||||
}
|
||||
|
||||
async getCryptoKey(name: string): Promise<string | undefined> {
|
||||
if (
|
||||
(await IndexedDBKVStore.isIndexedDBSupported()) &&
|
||||
window?.crypto?.subtle
|
||||
) {
|
||||
const pbkdfKey = await this.read<CryptoKey>(name);
|
||||
const cipheredKey = await this.read<EncryptedKey | string>(`${name}@_k`);
|
||||
if (typeof cipheredKey === "string") return cipheredKey;
|
||||
if (!pbkdfKey || !cipheredKey) return;
|
||||
return await aesDecrypt(pbkdfKey, cipheredKey);
|
||||
} else {
|
||||
const key = await this.read<string>(`${name}@_k`);
|
||||
if (!key) return;
|
||||
return key;
|
||||
}
|
||||
async getCryptoKey(): Promise<string | undefined> {
|
||||
if (!this.keyStore) throw new Error("No key store found!");
|
||||
|
||||
return this.keyStore.get("userEncryptionKey");
|
||||
}
|
||||
|
||||
async generateCryptoKey(
|
||||
@@ -159,56 +155,26 @@ export class NNStorage implements IStorage {
|
||||
items.forEach((c) => (c.format = "base64"));
|
||||
return NNCrypto.decryptMulti(key, items, "text");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
private async _getCryptoKey(name: string) {
|
||||
if (isFeatureSupported("indexedDB") && window?.crypto?.subtle) {
|
||||
const pbkdfKey = await this.read<CryptoKey>(name);
|
||||
const cipheredKey = await this.read<EncryptedKey | string>(`${name}@_k`);
|
||||
if (typeof cipheredKey === "string") return cipheredKey;
|
||||
if (!pbkdfKey || !cipheredKey) return;
|
||||
return await aesDecrypt(pbkdfKey, cipheredKey);
|
||||
} else {
|
||||
const key = await this.read<string>(`${name}@_k`);
|
||||
if (!key) return;
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const enc = new TextEncoder();
|
||||
const dec = new TextDecoder();
|
||||
|
||||
async function derivePBKDF2Key(password: string): Promise<CryptoKey> {
|
||||
const key = await window.crypto.subtle.importKey(
|
||||
"raw",
|
||||
enc.encode(password),
|
||||
"PBKDF2",
|
||||
false,
|
||||
["deriveKey"]
|
||||
);
|
||||
|
||||
const salt = window.crypto.getRandomValues(new Uint8Array(16));
|
||||
return await window.crypto.subtle.deriveKey(
|
||||
{
|
||||
name: "PBKDF2",
|
||||
salt,
|
||||
iterations: 100000,
|
||||
hash: "SHA-256"
|
||||
},
|
||||
key,
|
||||
{ name: "AES-GCM", length: 256 },
|
||||
true,
|
||||
["encrypt", "decrypt"]
|
||||
);
|
||||
}
|
||||
|
||||
async function aesEncrypt(
|
||||
cryptoKey: CryptoKey,
|
||||
data: string
|
||||
): Promise<EncryptedKey> {
|
||||
const iv = window.crypto.getRandomValues(new Uint8Array(12));
|
||||
|
||||
const cipher = await window.crypto.subtle.encrypt(
|
||||
{
|
||||
name: "AES-GCM",
|
||||
iv: iv
|
||||
},
|
||||
cryptoKey,
|
||||
enc.encode(data)
|
||||
);
|
||||
|
||||
return {
|
||||
iv,
|
||||
cipher
|
||||
};
|
||||
}
|
||||
|
||||
async function aesDecrypt(
|
||||
cryptoKey: CryptoKey,
|
||||
data: EncryptedKey
|
||||
|
||||
@@ -35,7 +35,10 @@ import { Notice, resetNotices } from "../common/notices";
|
||||
import { EV, EVENTS, SYNC_CHECK_IDS } from "@notesnook/core/dist/common";
|
||||
import { logger } from "../utils/logger";
|
||||
import Config from "../utils/config";
|
||||
import { onPageVisibilityChanged } from "../utils/page-visibility";
|
||||
import {
|
||||
onNetworkStatusChanged,
|
||||
onPageVisibilityChanged
|
||||
} from "../utils/page-visibility";
|
||||
import { NetworkCheck } from "../utils/network-check";
|
||||
import { Color, Notebook, Tag } from "@notesnook/core";
|
||||
|
||||
@@ -122,19 +125,23 @@ class AppStore extends BaseStore<AppStore> {
|
||||
this.updateSyncStatus("failed");
|
||||
});
|
||||
|
||||
onPageVisibilityChanged(async (type, documentHidden) => {
|
||||
if (!documentHidden && type !== "offline") {
|
||||
logger.info("Page visibility changed. Reconnecting SSE...");
|
||||
if (type === "online") {
|
||||
// a slight delay to make sure sockets are open and can be connected
|
||||
// to. Otherwise, this fails miserably.
|
||||
await networkCheck.waitForInternet();
|
||||
}
|
||||
await db.connectSSE({ force: type === "online" }).catch(logger.error);
|
||||
} else if (type === "offline") {
|
||||
onNetworkStatusChanged(async (status) => {
|
||||
if (status === "offline") {
|
||||
await this.abortSync("offline");
|
||||
} else {
|
||||
// a slight delay to make sure sockets are open and can be connected
|
||||
// to. Otherwise, this fails miserably.
|
||||
await networkCheck.waitForInternet();
|
||||
await db.connectSSE({ force: true }).catch(logger.error);
|
||||
}
|
||||
});
|
||||
|
||||
onPageVisibilityChanged(async (_, documentHidden) => {
|
||||
if (!documentHidden) return;
|
||||
|
||||
logger.info("Page visibility changed. Reconnecting SSE...");
|
||||
await db.connectSSE({ force: false }).catch(logger.error);
|
||||
});
|
||||
};
|
||||
|
||||
refresh = async () => {
|
||||
|
||||
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { PATHS } from "@notesnook/desktop";
|
||||
import { DesktopIntegration, PATHS } from "@notesnook/desktop";
|
||||
import { db } from "../common/db";
|
||||
import { desktop } from "../common/desktop-bridge";
|
||||
import createStore from "../common/store";
|
||||
@@ -26,11 +26,17 @@ import BaseStore from "./index";
|
||||
import { store as editorStore } from "./editor-store";
|
||||
import { isTelemetryEnabled, setTelemetry } from "../utils/telemetry";
|
||||
import { setDocumentTitle } from "../utils/dom";
|
||||
import { TimeFormat } from "@notesnook/core/dist/utils/date";
|
||||
import { TrashCleanupInterval } from "@notesnook/core";
|
||||
import { SecurityKeyConfig } from "../utils/webauthn";
|
||||
|
||||
/**
|
||||
* @extends {BaseStore<SettingStore>}
|
||||
*/
|
||||
class SettingStore extends BaseStore {
|
||||
type AppLockSettings = {
|
||||
enabled: boolean;
|
||||
lockAfter: number;
|
||||
securityKey?: SecurityKeyConfig;
|
||||
};
|
||||
|
||||
class SettingStore extends BaseStore<SettingStore> {
|
||||
encryptBackups = Config.get("encryptBackups", false);
|
||||
backupReminderOffset = Config.get("backupReminderOffset", 0);
|
||||
backupStorageLocation = Config.get(
|
||||
@@ -45,24 +51,21 @@ class SettingStore extends BaseStore {
|
||||
privacyMode = false;
|
||||
hideNoteTitle = Config.get("hideNoteTitle", false);
|
||||
telemetry = isTelemetryEnabled();
|
||||
/** @type {string} */
|
||||
dateFormat = null;
|
||||
/** @type {"12-hour" | "24-hour"} */
|
||||
timeFormat = null;
|
||||
titleFormat = null;
|
||||
/** @type {number} */
|
||||
trashCleanupInterval = 7;
|
||||
dateFormat = "DD-MM-YYYY";
|
||||
timeFormat: TimeFormat = "12-hour";
|
||||
titleFormat = "Note $date$ $time$";
|
||||
|
||||
trashCleanupInterval: TrashCleanupInterval = 7;
|
||||
homepage = Config.get("homepage", 0);
|
||||
/**
|
||||
* @type {DesktopIntegrationSettings | undefined}
|
||||
*/
|
||||
desktopIntegrationSettings = undefined;
|
||||
desktopIntegrationSettings?: DesktopIntegration;
|
||||
autoUpdates = true;
|
||||
isFlatpak = false;
|
||||
/**
|
||||
* @type {string|undefined}
|
||||
*/
|
||||
proxyRules = undefined;
|
||||
proxyRules?: string;
|
||||
|
||||
appLockSettings: AppLockSettings = Config.get("appLockSettings", {
|
||||
enabled: false,
|
||||
lockAfter: 0
|
||||
});
|
||||
|
||||
refresh = async () => {
|
||||
this.set({
|
||||
@@ -80,54 +83,52 @@ class SettingStore extends BaseStore {
|
||||
});
|
||||
};
|
||||
|
||||
setDateFormat = async (dateFormat) => {
|
||||
setDateFormat = async (dateFormat: string) => {
|
||||
await db.settings.setDateFormat(dateFormat);
|
||||
this.set({ dateFormat });
|
||||
};
|
||||
|
||||
setTimeFormat = async (timeFormat) => {
|
||||
setTimeFormat = async (timeFormat: TimeFormat) => {
|
||||
await db.settings.setTimeFormat(timeFormat);
|
||||
this.set({ timeFormat });
|
||||
};
|
||||
|
||||
setTitleFormat = async (titleFormat) => {
|
||||
setTitleFormat = async (titleFormat: string) => {
|
||||
await db.settings.setTitleFormat(titleFormat);
|
||||
this.set({ titleFormat });
|
||||
};
|
||||
|
||||
setTrashCleanupInterval = async (trashCleanupInterval) => {
|
||||
setTrashCleanupInterval = async (
|
||||
trashCleanupInterval: TrashCleanupInterval
|
||||
) => {
|
||||
await db.settings.setTrashCleanupInterval(trashCleanupInterval);
|
||||
this.set({ trashCleanupInterval });
|
||||
};
|
||||
|
||||
setZoomFactor = async (zoomFactor) => {
|
||||
setZoomFactor = async (zoomFactor: number) => {
|
||||
await desktop?.integration.setZoomFactor.mutate(zoomFactor);
|
||||
this.set({ zoomFactor });
|
||||
};
|
||||
|
||||
setProxyRules = async (proxyRules) => {
|
||||
setProxyRules = async (proxyRules: string) => {
|
||||
await desktop?.integration.setProxyRules.mutate(proxyRules);
|
||||
this.set({ proxyRules });
|
||||
};
|
||||
|
||||
setEncryptBackups = (encryptBackups) => {
|
||||
setEncryptBackups = (encryptBackups: boolean) => {
|
||||
this.set({ encryptBackups });
|
||||
Config.set("encryptBackups", encryptBackups);
|
||||
};
|
||||
|
||||
setHomepage = (homepage) => {
|
||||
setHomepage = (homepage: number) => {
|
||||
this.set({ homepage });
|
||||
Config.set("homepage", homepage);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Partial<DesktopIntegrationSettings>} settings
|
||||
*/
|
||||
setDesktopIntegration = async (settings) => {
|
||||
setDesktopIntegration = async (settings: DesktopIntegration) => {
|
||||
const { desktopIntegrationSettings } = this.get();
|
||||
|
||||
await desktop.integration.setDesktopIntegration.mutate({
|
||||
await desktop?.integration.setDesktopIntegration.mutate({
|
||||
...desktopIntegrationSettings,
|
||||
...settings
|
||||
});
|
||||
@@ -137,24 +138,30 @@ class SettingStore extends BaseStore {
|
||||
});
|
||||
};
|
||||
|
||||
setNotificationSettings = (settings) => {
|
||||
setNotificationSettings = (settings: { reminder: boolean }) => {
|
||||
const { notificationsSettings } = this.get();
|
||||
Config.set("notifications", { ...notificationsSettings, ...settings });
|
||||
|
||||
this.set({ notificationsSettings: Config.get("notifications") });
|
||||
};
|
||||
|
||||
setAppLockSettings = (settings: Partial<AppLockSettings>) => {
|
||||
const { appLockSettings } = this.get();
|
||||
Config.set("appLockSettings", { ...appLockSettings, ...settings });
|
||||
this.set({ appLockSettings: Config.get("appLockSettings") });
|
||||
};
|
||||
|
||||
toggleEncryptBackups = () => {
|
||||
const encryptBackups = this.get().encryptBackups;
|
||||
this.setEncryptBackups(!encryptBackups);
|
||||
};
|
||||
|
||||
setBackupReminderOffset = (offset) => {
|
||||
setBackupReminderOffset = (offset: number) => {
|
||||
Config.set("backupReminderOffset", offset);
|
||||
this.set({ backupReminderOffset: offset });
|
||||
};
|
||||
|
||||
setBackupStorageLocation = (location) => {
|
||||
setBackupStorageLocation = (location: string) => {
|
||||
Config.set("backupStorageLocation", location);
|
||||
this.set({ backupStorageLocation: location });
|
||||
};
|
||||
@@ -31,18 +31,14 @@ import { hashNavigate } from "../navigation";
|
||||
import { isUserPremium } from "../hooks/use-is-user-premium";
|
||||
import { SUBSCRIPTION_STATUS } from "../common/constants";
|
||||
import { ANALYTICS_EVENTS, trackEvent } from "../utils/analytics";
|
||||
import { User } from "@notesnook/core/dist/api/user-manager";
|
||||
|
||||
/**
|
||||
* @extends {BaseStore<UserStore>}
|
||||
*/
|
||||
class UserStore extends BaseStore {
|
||||
isLoggedIn = undefined;
|
||||
class UserStore extends BaseStore<UserStore> {
|
||||
isLoggedIn?: boolean;
|
||||
isLoggingIn = false;
|
||||
isSigningIn = false;
|
||||
/**
|
||||
* @type {import("@notesnook/core/dist/api/user-manager").User | undefined}
|
||||
*/
|
||||
user = undefined;
|
||||
|
||||
user?: User = undefined;
|
||||
counter = 0;
|
||||
|
||||
init = () => {
|
||||
@@ -79,7 +75,10 @@ class UserStore extends BaseStore {
|
||||
|
||||
EV.subscribe(EVENTS.userSubscriptionUpdated, (subscription) => {
|
||||
const wasUserPremium = isUserPremium();
|
||||
this.set((state) => (state.user.subscription = subscription));
|
||||
this.set((state) => {
|
||||
if (!state.user) return;
|
||||
state.user.subscription = subscription;
|
||||
});
|
||||
if (!wasUserPremium && isUserPremium())
|
||||
showOnboardingDialog(
|
||||
subscription.type === SUBSCRIPTION_STATUS.TRIAL ? "trial" : "pro"
|
||||
@@ -92,7 +91,7 @@ class UserStore extends BaseStore {
|
||||
|
||||
EV.subscribe(EVENTS.userLoggedOut, async (reason) => {
|
||||
this.set((state) => {
|
||||
state.user = {};
|
||||
state.user = undefined;
|
||||
state.isLoggedIn = false;
|
||||
});
|
||||
config.clear();
|
||||
@@ -19,7 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
const FEATURE_CHECKS = {
|
||||
opfs: false,
|
||||
cache: false
|
||||
cache: false,
|
||||
indexedDB: false
|
||||
};
|
||||
|
||||
async function isOPFSSupported() {
|
||||
@@ -28,10 +29,10 @@ async function isOPFSSupported() {
|
||||
typeof window.navigator.storage.getDirectory === "function";
|
||||
return (
|
||||
hasGetDirectory &&
|
||||
window.navigator.storage
|
||||
(await window.navigator.storage
|
||||
.getDirectory()
|
||||
.then(() => (FEATURE_CHECKS.opfs = true))
|
||||
.catch(() => (FEATURE_CHECKS.opfs = false))
|
||||
.catch(() => (FEATURE_CHECKS.opfs = false)))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,15 +43,34 @@ async function isCacheSupported() {
|
||||
window.caches instanceof CacheStorage;
|
||||
return (
|
||||
hasCacheStorage &&
|
||||
window.caches
|
||||
(await window.caches
|
||||
.has("something")
|
||||
.then((f) => (FEATURE_CHECKS.cache = true))
|
||||
.catch((a) => (FEATURE_CHECKS.cache = false))
|
||||
.then(() => (FEATURE_CHECKS.cache = true))
|
||||
.catch(() => (FEATURE_CHECKS.cache = false)))
|
||||
);
|
||||
}
|
||||
|
||||
async function isIndexedDBSupported() {
|
||||
console.log("IS indexed db supported");
|
||||
const hasIndexedDB = "indexedDB" in window;
|
||||
return (
|
||||
hasIndexedDB &&
|
||||
(await new Promise((resolve, reject) => {
|
||||
const request = indexedDB.open("checkIDBSupport");
|
||||
request.onsuccess = resolve;
|
||||
request.onerror = reject;
|
||||
})
|
||||
.then(() => (FEATURE_CHECKS.indexedDB = true))
|
||||
.catch(() => (FEATURE_CHECKS.indexedDB = false)))
|
||||
);
|
||||
}
|
||||
|
||||
export async function initializeFeatureChecks() {
|
||||
await Promise.allSettled([isOPFSSupported(), isCacheSupported()]);
|
||||
await Promise.allSettled([
|
||||
isOPFSSupported(),
|
||||
isCacheSupported(),
|
||||
isIndexedDBSupported()
|
||||
]);
|
||||
}
|
||||
|
||||
function isFeatureSupported(key: keyof typeof FEATURE_CHECKS) {
|
||||
|
||||
52
apps/web/src/utils/idle-detection.ts
Normal file
52
apps/web/src/utils/idle-detection.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export function startIdleDetection(ms: number, onTrigger: () => void) {
|
||||
console.log("starting idle detection", ms);
|
||||
let timeout = 0;
|
||||
function onEvent() {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(onTrigger, ms) as unknown as number;
|
||||
}
|
||||
|
||||
window.addEventListener("mousemove", onEvent);
|
||||
window.addEventListener("wheel", onEvent);
|
||||
window.addEventListener("keydown", onEvent);
|
||||
window.addEventListener("keydown", onEvent);
|
||||
window.addEventListener("scroll", onEvent);
|
||||
window.addEventListener("touchmove", onEvent);
|
||||
window.addEventListener("touchstart", onEvent);
|
||||
window.addEventListener("click", onEvent);
|
||||
window.addEventListener("focus", onEvent);
|
||||
window.addEventListener("blur", onEvent);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
window.removeEventListener("mousemove", onEvent);
|
||||
window.removeEventListener("wheel", onEvent);
|
||||
window.removeEventListener("keydown", onEvent);
|
||||
window.removeEventListener("keydown", onEvent);
|
||||
window.removeEventListener("scroll", onEvent);
|
||||
window.removeEventListener("touchmove", onEvent);
|
||||
window.removeEventListener("touchstart", onEvent);
|
||||
window.removeEventListener("click", onEvent);
|
||||
window.removeEventListener("focus", onEvent);
|
||||
window.removeEventListener("blur", onEvent);
|
||||
};
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import { sanitizeFilename } from "@notesnook/common";
|
||||
|
||||
let logger: typeof _logger;
|
||||
async function initializeLogger(persistence: DatabasePersistence = "db") {
|
||||
initialize(await NNStorage.createInstance("Logs", persistence), false);
|
||||
initialize(new NNStorage("Logs", null, persistence), false);
|
||||
logger = _logger.scope("notesnook-web");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,46 +36,61 @@ function isDocumentHidden() {
|
||||
: document.hidden;
|
||||
}
|
||||
|
||||
export function onNetworkStatusChanged(
|
||||
handler: (status: "online" | "offline") => void
|
||||
) {
|
||||
const onlineListener = debounce((_) => handler("online"), 1000);
|
||||
const offlineListener = debounce((_) => handler("online"), 1000);
|
||||
window.addEventListener("online", onlineListener);
|
||||
window.addEventListener("offline", offlineListener);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("online", onlineListener);
|
||||
window.removeEventListener("offline", offlineListener);
|
||||
};
|
||||
}
|
||||
|
||||
export function onPageVisibilityChanged(
|
||||
handler: (
|
||||
status: "online" | "offline" | "visibilitychange" | "focus",
|
||||
bool: boolean
|
||||
status: "visibilitychange" | "focus" | "blur",
|
||||
isDocumentHidden: boolean
|
||||
) => void
|
||||
) {
|
||||
window.addEventListener(
|
||||
"online",
|
||||
debounce((_) => {
|
||||
handler("online", false);
|
||||
}, 1000)
|
||||
);
|
||||
window.addEventListener(
|
||||
"offline",
|
||||
debounce((_) => {
|
||||
handler("offline", false);
|
||||
}, 1000)
|
||||
);
|
||||
const onVisibilityChanged = debounce((_) => {
|
||||
if (isEventIgnored()) return;
|
||||
|
||||
// Handle page visibility change
|
||||
document.addEventListener(
|
||||
visibilityChange(),
|
||||
debounce((_) => {
|
||||
if (PAGE_VISIBILITY_CHANGE.ignore) {
|
||||
PAGE_VISIBILITY_CHANGE.ignore = false;
|
||||
return;
|
||||
}
|
||||
handler("visibilitychange", isDocumentHidden());
|
||||
}, 1000)
|
||||
);
|
||||
handler("visibilitychange", isDocumentHidden());
|
||||
}, 1000);
|
||||
|
||||
window.addEventListener(
|
||||
"focus",
|
||||
debounce((_) => {
|
||||
if (!window.document.hasFocus()) return;
|
||||
if (PAGE_VISIBILITY_CHANGE.ignore) {
|
||||
PAGE_VISIBILITY_CHANGE.ignore = false;
|
||||
return;
|
||||
}
|
||||
handler("focus", false);
|
||||
}, 1000)
|
||||
);
|
||||
const onFocus = debounce((_) => {
|
||||
if (isEventIgnored()) return;
|
||||
|
||||
if (!window.document.hasFocus()) return;
|
||||
handler("focus", isDocumentHidden());
|
||||
}, 1000);
|
||||
|
||||
const onBlur = debounce((_) => {
|
||||
if (isEventIgnored()) return;
|
||||
|
||||
if (window.document.hasFocus()) return;
|
||||
handler("blur", isDocumentHidden());
|
||||
}, 1000);
|
||||
|
||||
document.addEventListener(visibilityChange(), onVisibilityChanged);
|
||||
window.addEventListener("focus", onFocus);
|
||||
window.addEventListener("blur", onBlur);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener(visibilityChange(), onVisibilityChanged);
|
||||
window.removeEventListener("focus", onFocus);
|
||||
window.removeEventListener("blur", onBlur);
|
||||
};
|
||||
}
|
||||
|
||||
function isEventIgnored() {
|
||||
if (PAGE_VISIBILITY_CHANGE.ignore) {
|
||||
PAGE_VISIBILITY_CHANGE.ignore = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
31
apps/web/src/utils/password-generator.ts
Normal file
31
apps/web/src/utils/password-generator.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export function generatePassword() {
|
||||
return window.crypto
|
||||
.getRandomValues(new BigUint64Array(4))
|
||||
.reduce((prev, curr, index) => {
|
||||
const char =
|
||||
index % 2 ? curr.toString(36).toUpperCase() : curr.toString(36);
|
||||
return prev + char;
|
||||
}, "")
|
||||
.split("")
|
||||
.sort(() => 128 - window.crypto.getRandomValues(new Uint8Array(1))[0])
|
||||
.join("");
|
||||
}
|
||||
148
apps/web/src/utils/webauthn.ts
Normal file
148
apps/web/src/utils/webauthn.ts
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getFormattedDate } from "@notesnook/common";
|
||||
|
||||
export type SecurityKeyConfig = {
|
||||
firstSalt: string;
|
||||
label: string;
|
||||
rawId: string;
|
||||
transports: AuthenticatorTransport[];
|
||||
};
|
||||
|
||||
async function registerSecurityKey(userId: BufferSource, username: string) {
|
||||
const challenge = window.crypto.getRandomValues(new Uint32Array(1));
|
||||
const firstSalt = window.crypto.getRandomValues(new Uint8Array(32));
|
||||
const result = await navigator.credentials.create({
|
||||
publicKey: {
|
||||
challenge: challenge,
|
||||
rp: {
|
||||
name: "Notesnook"
|
||||
},
|
||||
user: {
|
||||
id: userId,
|
||||
name: `${username} (${getFormattedDate(new Date(), "date-time")})`,
|
||||
displayName: username
|
||||
},
|
||||
pubKeyCredParams: [
|
||||
{ alg: -7, type: "public-key" }, // ES256
|
||||
{ alg: -257, type: "public-key" } // RS256
|
||||
],
|
||||
authenticatorSelection: {
|
||||
userVerification: "required",
|
||||
residentKey: "required",
|
||||
requireResidentKey: true,
|
||||
authenticatorAttachment: "cross-platform"
|
||||
},
|
||||
extensions: {
|
||||
prf: {
|
||||
eval: {
|
||||
first: firstSalt
|
||||
}
|
||||
}
|
||||
},
|
||||
hints: ["security-key"]
|
||||
}
|
||||
});
|
||||
|
||||
if (
|
||||
!result ||
|
||||
!(result instanceof PublicKeyCredential) ||
|
||||
!result.getClientExtensionResults().prf?.enabled
|
||||
)
|
||||
throw new Error(
|
||||
"Could not register security key: your browser or security key does not support the PRF WebAuthn extension."
|
||||
);
|
||||
|
||||
return {
|
||||
firstSalt,
|
||||
transports: (
|
||||
result.response as AuthenticatorAttestationResponse
|
||||
).getTransports() as AuthenticatorTransport[],
|
||||
rawId: result.rawId
|
||||
};
|
||||
}
|
||||
|
||||
async function getEncryptionKey(config: {
|
||||
rawId: BufferSource;
|
||||
firstSalt: BufferSource;
|
||||
label: string;
|
||||
transports: AuthenticatorTransport[];
|
||||
}) {
|
||||
const { firstSalt, label, rawId, transports } = config;
|
||||
const challenge = window.crypto.getRandomValues(new Uint32Array(1));
|
||||
const result = await navigator.credentials.get({
|
||||
publicKey: {
|
||||
challenge: challenge,
|
||||
userVerification: "required",
|
||||
allowCredentials: [
|
||||
{
|
||||
id: rawId,
|
||||
type: "public-key",
|
||||
transports
|
||||
}
|
||||
],
|
||||
extensions: {
|
||||
prf: {
|
||||
eval: {
|
||||
first: firstSalt
|
||||
}
|
||||
}
|
||||
},
|
||||
hints: ["security-key"]
|
||||
}
|
||||
});
|
||||
|
||||
if (!result || !(result instanceof PublicKeyCredential))
|
||||
throw new Error("Invalid response.");
|
||||
|
||||
const extensionResult = result.getClientExtensionResults();
|
||||
|
||||
if (!extensionResult.prf?.results?.first)
|
||||
throw new Error(
|
||||
"Could not create encryption key: the WebAuthn PRF response did not include salt bytes."
|
||||
);
|
||||
|
||||
const key = extensionResult.prf.results.first;
|
||||
const keyDerivationKey = await window.crypto.subtle.importKey(
|
||||
"raw",
|
||||
new Uint8Array(key),
|
||||
"HKDF",
|
||||
false,
|
||||
["deriveKey"]
|
||||
);
|
||||
|
||||
// Never forget what you set this value to or the key
|
||||
// can't be derived later
|
||||
const info = new TextEncoder().encode(label);
|
||||
// `salt` is a required argument for `deriveKey()`, but
|
||||
// should be empty
|
||||
const salt = new Uint8Array();
|
||||
const encryptionKey = await crypto.subtle.deriveKey(
|
||||
{ name: "HKDF", info, salt, hash: "SHA-256" },
|
||||
keyDerivationKey,
|
||||
{ name: "AES-GCM", length: 256 },
|
||||
false,
|
||||
["encrypt", "decrypt"]
|
||||
);
|
||||
|
||||
return { encryptionKey };
|
||||
}
|
||||
|
||||
export const WebAuthn = { registerSecurityKey, getEncryptionKey };
|
||||
245
apps/web/src/views/app-lock.tsx
Normal file
245
apps/web/src/views/app-lock.tsx
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2023 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { PropsWithChildren, useEffect, useState } from "react";
|
||||
import { useStore as useSettingStore } from "../stores/setting-store";
|
||||
import usePromise from "../hooks/use-promise";
|
||||
import { KeyChain } from "../interfaces/key-store";
|
||||
import { Button, Flex, Text } from "@theme-ui/components";
|
||||
import { Loading, Lock } from "../components/icons";
|
||||
import { ErrorText } from "../components/error-text";
|
||||
import Field from "../components/field";
|
||||
import { startIdleDetection } from "../utils/idle-detection";
|
||||
import { onPageVisibilityChanged } from "../utils/page-visibility";
|
||||
import { closeOpenedDialog } from "../common/dialog-controller";
|
||||
import { WebAuthn } from "../utils/webauthn";
|
||||
|
||||
export default function AppLock(props: PropsWithChildren<unknown>) {
|
||||
const keychain = usePromise(async () => ({
|
||||
isLocked: await KeyChain.isLocked(),
|
||||
credentials: await KeyChain.getCredentials()
|
||||
}));
|
||||
const [error, setError] = useState<string>();
|
||||
const [isUnlocking, setIsUnlocking] = useState(false);
|
||||
const appLockSettings = useSettingStore((store) => store.appLockSettings);
|
||||
|
||||
useEffect(() => {
|
||||
const { lockAfter, enabled } = appLockSettings;
|
||||
if (
|
||||
!enabled ||
|
||||
lockAfter === -1 ||
|
||||
keychain.status !== "fulfilled" ||
|
||||
keychain.value.isLocked
|
||||
)
|
||||
return;
|
||||
|
||||
if (lockAfter > 0) {
|
||||
const stop = startIdleDetection(
|
||||
appLockSettings.lockAfter * 60 * 1000,
|
||||
() => {
|
||||
KeyChain.relock();
|
||||
closeOpenedDialog();
|
||||
keychain.refresh();
|
||||
}
|
||||
);
|
||||
return () => stop();
|
||||
} else if (lockAfter === 0) {
|
||||
const stop = onPageVisibilityChanged((_, hidden) => {
|
||||
if (hidden) {
|
||||
KeyChain.relock();
|
||||
closeOpenedDialog();
|
||||
keychain.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
return () => stop();
|
||||
}
|
||||
}, [appLockSettings, keychain]);
|
||||
|
||||
if (keychain.status === "fulfilled" && !keychain.value.isLocked)
|
||||
return <>{props.children}</>;
|
||||
|
||||
if (keychain.status === "fulfilled" && keychain.value.isLocked)
|
||||
return (
|
||||
<Flex
|
||||
as="form"
|
||||
sx={{
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
height: "100%",
|
||||
flexDirection: "column"
|
||||
}}
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
setError(undefined);
|
||||
setIsUnlocking(true);
|
||||
|
||||
const data = new FormData(e.target as HTMLFormElement);
|
||||
const password = data.get("password");
|
||||
if (!password || typeof password !== "string") {
|
||||
setIsUnlocking(false);
|
||||
setError("Password is required.");
|
||||
return;
|
||||
}
|
||||
|
||||
await KeyChain.unlock({ type: "password", id: "primary", password })
|
||||
.then(() => keychain.refresh())
|
||||
.catch((e) => {
|
||||
setError(
|
||||
typeof e === "string"
|
||||
? e
|
||||
: "message" in e && typeof e.message === "string"
|
||||
? e.message ===
|
||||
"ciphertext cannot be decrypted using that key"
|
||||
? "Wrong password."
|
||||
: e.message
|
||||
: JSON.stringify(e)
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
setIsUnlocking(false);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Flex
|
||||
sx={{
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center"
|
||||
}}
|
||||
>
|
||||
<Lock size={100} sx={{ opacity: 0.2 }} />
|
||||
<Text
|
||||
data-test-id="unlock-note-title"
|
||||
variant="heading"
|
||||
mx={100}
|
||||
mt={25}
|
||||
sx={{ fontSize: 36, textAlign: "center" }}
|
||||
>
|
||||
Unlock your notes
|
||||
</Text>
|
||||
</Flex>
|
||||
<Text
|
||||
variant="body"
|
||||
mt={1}
|
||||
mb={4}
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
fontSize: "title",
|
||||
color: "var(--paragraph-secondary)"
|
||||
}}
|
||||
>
|
||||
Please verify it's you.
|
||||
</Text>
|
||||
|
||||
{isUnlocking ? (
|
||||
<Loading />
|
||||
) : (
|
||||
<Flex
|
||||
sx={{
|
||||
alignSelf: "stretch",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
gap: 2
|
||||
}}
|
||||
>
|
||||
{keychain.value.credentials.map((credential) => {
|
||||
switch (credential.type) {
|
||||
case "password":
|
||||
return (
|
||||
<>
|
||||
<Field
|
||||
id="password"
|
||||
name="password"
|
||||
data-test-id="app-lock-password"
|
||||
autoFocus
|
||||
required
|
||||
sx={{ width: ["95%", "95%", "25%"] }}
|
||||
placeholder="Enter password"
|
||||
type="password"
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="accent"
|
||||
data-test-id="unlock-note-submit"
|
||||
disabled={isUnlocking}
|
||||
sx={{ borderRadius: 100, px: 30 }}
|
||||
>
|
||||
Continue
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
case "key":
|
||||
return (
|
||||
<Button
|
||||
key={credential.id}
|
||||
variant="secondary"
|
||||
type="button"
|
||||
onClick={async () => {
|
||||
const { securityKey } =
|
||||
useSettingStore.getState().appLockSettings;
|
||||
if (!securityKey) return;
|
||||
|
||||
setError(undefined);
|
||||
setIsUnlocking(true);
|
||||
|
||||
try {
|
||||
const { encryptionKey } =
|
||||
await WebAuthn.getEncryptionKey({
|
||||
firstSalt: Buffer.from(
|
||||
securityKey.firstSalt,
|
||||
"base64"
|
||||
),
|
||||
label: securityKey.label,
|
||||
rawId: Buffer.from(securityKey.rawId, "base64"),
|
||||
transports: securityKey.transports
|
||||
});
|
||||
|
||||
await KeyChain.unlock({
|
||||
type: "key",
|
||||
id: credential.id,
|
||||
key: encryptionKey
|
||||
});
|
||||
keychain.refresh();
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
} finally {
|
||||
setIsUnlocking(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Unlock with{" "}
|
||||
{credential.type === "key" &&
|
||||
credential.id === "securityKey"
|
||||
? "security key"
|
||||
: "key"}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</Flex>
|
||||
)}
|
||||
{error && <ErrorText error={error} />}
|
||||
</Flex>
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ class UserManager {
|
||||
await this.db.syncer.devices.register();
|
||||
}
|
||||
|
||||
await this.db.storage().deriveCryptoKey(`_uk_@${user.email}`, {
|
||||
await this.db.storage().deriveCryptoKey({
|
||||
password,
|
||||
salt: user.salt
|
||||
});
|
||||
@@ -224,7 +224,7 @@ class UserManager {
|
||||
const user = await this.fetchUser();
|
||||
if (!user) return;
|
||||
|
||||
await this.db.storage().deriveCryptoKey(`_uk_@${user.email}`, {
|
||||
await this.db.storage().deriveCryptoKey({
|
||||
password,
|
||||
salt: user.salt
|
||||
});
|
||||
@@ -370,7 +370,7 @@ class UserManager {
|
||||
async getEncryptionKey(): Promise<SerializedKey | undefined> {
|
||||
const user = await this.getUser();
|
||||
if (!user) return;
|
||||
const key = await this.db.storage().getCryptoKey(`_uk_@${user.email}`);
|
||||
const key = await this.db.storage().getCryptoKey();
|
||||
if (!key) return;
|
||||
return { key, salt: user.salt };
|
||||
}
|
||||
@@ -443,7 +443,7 @@ class UserManager {
|
||||
token
|
||||
);
|
||||
|
||||
await this.db.storage().deriveCryptoKey(`_uk_@${newEmail}`, {
|
||||
await this.db.storage().deriveCryptoKey({
|
||||
password,
|
||||
salt: user.salt
|
||||
});
|
||||
@@ -497,7 +497,7 @@ class UserManager {
|
||||
|
||||
if (data.encryptionKey) await this.db.sync({ type: "fetch", force: true });
|
||||
|
||||
await this.db.storage().deriveCryptoKey(`_uk_@${email}`, {
|
||||
await this.db.storage().deriveCryptoKey({
|
||||
password: new_password,
|
||||
salt
|
||||
});
|
||||
|
||||
@@ -56,9 +56,9 @@ export interface IStorage {
|
||||
key: SerializedKey,
|
||||
items: Cipher<"base64">[]
|
||||
): Promise<string[]>;
|
||||
deriveCryptoKey(name: string, credentials: SerializedKey): Promise<void>;
|
||||
deriveCryptoKey(credentials: SerializedKey): Promise<void>;
|
||||
hash(password: string, email: string): Promise<string>;
|
||||
getCryptoKey(name: string): Promise<string | undefined>;
|
||||
getCryptoKey(): Promise<string | undefined>;
|
||||
generateCryptoKey(password: string, salt?: string): Promise<SerializedKey>;
|
||||
|
||||
// async generateRandomKey() {
|
||||
|
||||
Reference in New Issue
Block a user