@galaxyproject/olit 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ async function At(We={}){var Se,f=We,Re=!!globalThis.window,Ve=!!globalThis.WorkerGlobalScope;globalThis.process?.versions?.node&&globalThis.process?.type,(function(e){const t=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:function(){console.warn("globalThis.sqlite3InitModuleState is missing",arguments)}});delete globalThis.sqlite3InitModuleState,t.debugModule("pre-js.js sqlite3InitModuleState =",t),e.locateFile=(function(o,i){return this.emscriptenLocateFile instanceof Function?this.emscriptenLocateFile(o,i):new URL(o,import.meta.url).href}).bind(t),e.instantiateWasm=(function(i,n){if(this.emscriptenInstantiateWasm instanceof Function)return this.emscriptenInstantiateWasm(i,n);const r=this,s=e.locateFile(r.wasmFilename,typeof nt>"u"?"":nt);r.debugModule("instantiateWasm() uri =",s,"sIMS =",this);const u=()=>fetch(s,{credentials:"same-origin"}),c=b=>{b.imports=i,r.instantiateWasm=b,n(b.instance,b.module)};return(WebAssembly.instantiateStreaming?async()=>WebAssembly.instantiateStreaming(u(),i).then(c):async()=>u().then(b=>b.arrayBuffer()).then(b=>WebAssembly.instantiate(b,i)).then(c))()}).bind(t)})(f);var je="./this.program",ut=import.meta.url,nt="";function Yt(e){return f.locateFile?f.locateFile(e,nt):nt+e}var bt,_t;if(Re||Ve){try{nt=new URL(".",ut).href}catch{}Ve&&(_t=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),bt=async e=>{var t=await fetch(e,{credentials:"same-origin"});if(t.ok)return t.arrayBuffer();throw new Error(t.status+" : "+t.url)}}var ft=console.log.bind(console),Ue=console.error.bind(console),rt,It=!1,Tt,kt,Ot=!1;function xt(){var e=ze.buffer;Ne=new Int8Array(e),it=new Int16Array(e),He=new Uint8Array(e),ye=new Int32Array(e),ve=new Uint32Array(e),xe=new BigInt64Array(e),new BigUint64Array(e)}function Zt(){if(f.wasmMemory)ze=f.wasmMemory;else{var e=f.INITIAL_MEMORY||8388608;ze=new WebAssembly.Memory({initial:e/65536,maximum:32768})}xt()}function en(){if(f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)fn(f.preRun.shift());Ft(Lt)}function tn(){Ot=!0,!f.noFSInit&&!a.initialized&&a.init(),et.__wasm_call_ctors(),a.ignorePermissions=!1}function nn(){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)_n(f.postRun.shift());Ft(Pt)}function Me(e){f.onAbort?.(e),e=`Aborted(${e})`,Ue(e),It=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw kt?.(t),t}var yt;function rn(){return f.locateFile?Yt("sqlite3.wasm"):new URL(""+new URL("sqlite3-Con_VOcu.wasm",import.meta.url).href,import.meta.url).href}function sn(e){if(e==yt&&rt)return new Uint8Array(rt);if(_t)return _t(e);throw"both async and sync fetching of the wasm failed"}async function on(e){if(!rt)try{var t=await bt(e);return new Uint8Array(t)}catch{}return sn(e)}async function ln(e,t){try{var o=await on(e);return await WebAssembly.instantiate(o,t)}catch(i){Ue(`failed to asynchronously prepare wasm: ${i}`),Me(i)}}async function an(e,t,o){if(!e)try{var i=fetch(t,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(i,o)}catch(n){Ue(`wasm streaming compile failed: ${n}`),Ue("falling back to ArrayBuffer instantiation")}return ln(t,o)}function cn(){return{env:$t,wasi_snapshot_preview1:$t}}async function un(){function e(i,n){return et=i.exports,pr(et),et}function t(i){return e(i.instance)}var o=cn();return f.instantiateWasm?new Promise((i,n)=>{f.instantiateWasm(o,(r,s)=>{i(e(r))})}):(yt??=rn(),t(await an(rt,yt,o)))}var it,ye,xe,Ne,ve,He,Ft=e=>{for(;e.length>0;)e.shift()(f)},Pt=[],_n=e=>Pt.push(e),Lt=[],fn=e=>Lt.push(e),ze,qe={isAbs:e=>e.charAt(0)==="/",splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var o=0,i=e.length-1;i>=0;i--){var n=e[i];n==="."?e.splice(i,1):n===".."?(e.splice(i,1),o++):o&&(e.splice(i,1),o--)}if(t)for(;o;o--)e.unshift("..");return e},normalize:e=>{var t=qe.isAbs(e),o=e.slice(-1)==="/";return e=qe.normalizeArray(e.split("/").filter(i=>!!i),!t).join("/"),!e&&!t&&(e="."),e&&o&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=qe.splitPath(e),o=t[0],i=t[1];return!o&&!i?".":(i&&(i=i.slice(0,-1)),o+i)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>qe.normalize(e.join("/")),join2:(e,t)=>qe.normalize(e+"/"+t)},dn=()=>e=>(crypto.getRandomValues(e),0),Ct=e=>(Ct=dn())(e),Ye={resolve:(...e)=>{for(var t="",o=!1,i=e.length-1;i>=-1&&!o;i--){var n=i>=0?e[i]:a.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";t=n+"/"+t,o=qe.isAbs(n)}return t=qe.normalizeArray(t.split("/").filter(r=>!!r),!o).join("/"),(o?"/":"")+t||"."},relative:(e,t)=>{e=Ye.resolve(e).slice(1),t=Ye.resolve(t).slice(1);function o(b){for(var z=0;z<b.length&&b[z]==="";z++);for(var O=b.length-1;O>=0&&b[O]==="";O--);return z>O?[]:b.slice(z,O-z+1)}for(var i=o(e.split("/")),n=o(t.split("/")),r=Math.min(i.length,n.length),s=r,u=0;u<r;u++)if(i[u]!==n[u]){s=u;break}for(var c=[],u=s;u<i.length;u++)c.push("..");return c=c.concat(n.slice(s)),c.join("/")}},Nt=new TextDecoder,Rt=(e,t,o,i)=>{for(var n=t+o;e[t]&&!(t>=n);)++t;return t},st=(e,t=0,o,i)=>{var n=Rt(e,t,o);return Nt.decode(e.buffer?e.subarray(t,n):new Uint8Array(e.slice(t,n)))},qt=[],dt=e=>{for(var t=0,o=0;o<e.length;++o){var i=e.charCodeAt(o);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++o):t+=3}return t},Dt=(e,t,o,i)=>{if(!(i>0))return 0;for(var n=o,r=o+i-1,s=0;s<e.length;++s){var u=e.codePointAt(s);if(u<=127){if(o>=r)break;t[o++]=u}else if(u<=2047){if(o+1>=r)break;t[o++]=192|u>>6,t[o++]=128|u&63}else if(u<=65535){if(o+2>=r)break;t[o++]=224|u>>12,t[o++]=128|u>>6&63,t[o++]=128|u&63}else{if(o+3>=r)break;t[o++]=240|u>>18,t[o++]=128|u>>12&63,t[o++]=128|u>>6&63,t[o++]=128|u&63,s++}}return t[o]=0,o-n},vt=(e,t,o)=>{var i=dt(e)+1,n=new Array(i),r=Dt(e,n,0,n.length);return n.length=r,n},pn=()=>{if(!qt.length){var e=null;if(globalThis.window?.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=`
2
+ `)),!e)return null;qt=vt(e)}return qt.shift()},Ge={ttys:[],init(){},shutdown(){},register(e,t){Ge.ttys[e]={input:[],output:[],ops:t},a.registerDevice(e,Ge.stream_ops)},stream_ops:{open(e){var t=Ge.ttys[e.node.rdev];if(!t)throw new a.ErrnoError(43);e.tty=t,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,t,o,i,n){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var r=0,s=0;s<i;s++){var u;try{u=e.tty.ops.get_char(e.tty)}catch{throw new a.ErrnoError(29)}if(u===void 0&&r===0)throw new a.ErrnoError(6);if(u==null)break;r++,t[o+s]=u}return r&&(e.node.atime=Date.now()),r},write(e,t,o,i,n){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var r=0;r<i;r++)e.tty.ops.put_char(e.tty,t[o+r])}catch{throw new a.ErrnoError(29)}return i&&(e.node.mtime=e.node.ctime=Date.now()),r}},default_tty_ops:{get_char(e){return pn()},put_char(e,t){t===null||t===10?(ft(st(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output?.length>0&&(ft(st(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[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]}},ioctl_tcsets(e,t,o){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,t){t===null||t===10?(Ue(st(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output?.length>0&&(Ue(st(e.output)),e.output=[])}}},hn=(e,t)=>He.fill(0,e,e+t),jt=(e,t)=>Math.ceil(e/t)*t,Mt=e=>{e=jt(e,65536);var t=Gt(65536,e);return t&&hn(t,e),t},_e={ops_table:null,mount(e){return _e.createNode(null,"/",16895,0)},createNode(e,t,o,i){if(a.isBlkdev(o)||a.isFIFO(o))throw new a.ErrnoError(63);_e.ops_table||={dir:{node:{getattr:_e.node_ops.getattr,setattr:_e.node_ops.setattr,lookup:_e.node_ops.lookup,mknod:_e.node_ops.mknod,rename:_e.node_ops.rename,unlink:_e.node_ops.unlink,rmdir:_e.node_ops.rmdir,readdir:_e.node_ops.readdir,symlink:_e.node_ops.symlink},stream:{llseek:_e.stream_ops.llseek}},file:{node:{getattr:_e.node_ops.getattr,setattr:_e.node_ops.setattr},stream:{llseek:_e.stream_ops.llseek,read:_e.stream_ops.read,write:_e.stream_ops.write,mmap:_e.stream_ops.mmap,msync:_e.stream_ops.msync}},link:{node:{getattr:_e.node_ops.getattr,setattr:_e.node_ops.setattr,readlink:_e.node_ops.readlink},stream:{}},chrdev:{node:{getattr:_e.node_ops.getattr,setattr:_e.node_ops.setattr},stream:a.chrdev_stream_ops}};var n=a.createNode(e,t,o,i);return a.isDir(n.mode)?(n.node_ops=_e.ops_table.dir.node,n.stream_ops=_e.ops_table.dir.stream,n.contents={}):a.isFile(n.mode)?(n.node_ops=_e.ops_table.file.node,n.stream_ops=_e.ops_table.file.stream,n.usedBytes=0,n.contents=_e.emptyFileContents??=new Uint8Array(0)):a.isLink(n.mode)?(n.node_ops=_e.ops_table.link.node,n.stream_ops=_e.ops_table.link.stream):a.isChrdev(n.mode)&&(n.node_ops=_e.ops_table.chrdev.node,n.stream_ops=_e.ops_table.chrdev.stream),n.atime=n.mtime=n.ctime=Date.now(),e&&(e.contents[t]=n,e.atime=e.mtime=e.ctime=n.atime),n},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,t){var o=e.contents.length;if(!(o>=t)){t=Math.max(t,o*(o<1048576?2:1.125)>>>0),o&&(t=Math.max(t,256));var i=_e.getFileDataAsTypedArray(e);e.contents=new Uint8Array(t),e.contents.set(i)}},resizeFileStorage(e,t){if(e.usedBytes!=t){var o=e.contents;e.contents=new Uint8Array(t),e.contents.set(o.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=a.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,a.isDir(e.mode)?t.size=4096:a.isFile(e.mode)?t.size=e.usedBytes:a.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.atime),t.mtime=new Date(e.mtime),t.ctime=new Date(e.ctime),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){for(const o of["mode","atime","mtime","ctime"])t[o]!=null&&(e[o]=t[o]);t.size!==void 0&&_e.resizeFileStorage(e,t.size)},lookup(e,t){throw _e.doesNotExistError||(_e.doesNotExistError=new a.ErrnoError(44),_e.doesNotExistError.stack="<generic error, no stack>"),_e.doesNotExistError},mknod(e,t,o,i){return _e.createNode(e,t,o,i)},rename(e,t,o){var i;try{i=a.lookupNode(t,o)}catch{}if(i){if(a.isDir(e.mode))for(var n in i.contents)throw new a.ErrnoError(55);a.hashRemoveNode(i)}delete e.parent.contents[e.name],t.contents[o]=e,e.name=o,t.ctime=t.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,t){delete e.contents[t],e.ctime=e.mtime=Date.now()},rmdir(e,t){for(var o in a.lookupNode(e,t).contents)throw new a.ErrnoError(55);delete e.contents[t],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,t,o){var i=_e.createNode(e,t,41471,0);return i.link=o,i},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,t,o,i,n){var r=e.node.contents;if(n>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-n,i);return t.set(r.subarray(n,n+s),o),s},write(e,t,o,i,n,r){if(t.buffer===Ne.buffer&&(r=!1),!i)return 0;var s=e.node;return s.mtime=s.ctime=Date.now(),r?(s.contents=t.subarray(o,o+i),s.usedBytes=i):s.usedBytes===0&&n===0?(s.contents=t.slice(o,o+i),s.usedBytes=i):(_e.expandFileStorage(s,n+i),s.contents.set(t.subarray(o,o+i),n),s.usedBytes=Math.max(s.usedBytes,n+i)),i},llseek(e,t,o){var i=t;if(o===1?i+=e.position:o===2&&a.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new a.ErrnoError(28);return i},mmap(e,t,o,i,n){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var r,s,u=e.node.contents;if(!(n&2)&&u.buffer===Ne.buffer)s=!1,r=u.byteOffset;else{if(s=!0,r=Mt(t),!r)throw new a.ErrnoError(48);u&&((o>0||o+t<u.length)&&(u.subarray?u=u.subarray(o,o+t):u=Array.prototype.slice.call(u,o,o+t)),Ne.set(u,r))}return{ptr:r,allocated:s}},msync(e,t,o,i,n){return _e.stream_ops.write(e,t,0,i,o,!1),0}}},mn=e=>{if(typeof e!="string")return e;var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},zt=e=>(typeof e=="string"&&(e=vt(e)),e.subarray||(e=new Uint8Array(e)),e),St=(e,t)=>{var o=0;return e&&(o|=365),t&&(o|=146),o},gn=async e=>{var t=await bt(e);return new Uint8Array(t)},bn=(...e)=>a.createDataFile(...e),$e=0,ot=null,yn=e=>{if($e--,f.monitorRunDependencies?.($e),$e==0&&ot){var t=ot;ot=null,t()}},qn=e=>{$e++,f.monitorRunDependencies?.($e)},Bt=[],vn=async(e,t)=>{typeof Browser<"u"&&Browser.init();for(var o of Bt)if(o.canHandle(t))return o.handle(e,t);return e},Ut=async(e,t,o,i,n,r,s,u)=>{var c=t?Ye.resolve(qe.join2(e,t)):e;qn();try{var b=o;typeof o=="string"&&(b=await gn(o)),b=await vn(b,c),u?.(),r||bn(e,t,b,i,n,s)}finally{yn()}},Sn=(e,t,o,i,n,r,s,u,c,b)=>{Ut(e,t,o,i,n,u,c,b).then(r).catch(s)},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class{name="ErrnoError";constructor(e){this.errno=e}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,t,o,i){e||(e=this),this.parent=e,this.mount=e.mount,this.id=a.nextInode++,this.name=t,this.mode=o,this.rdev=i,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return a.isDir(this.mode)}get isDevice(){return a.isChrdev(this.mode)}},lookupPath(e,t={}){if(!e)throw new a.ErrnoError(44);t.follow_mount??=!0,qe.isAbs(e)||(e=a.cwd()+"/"+e);e:for(var o=0;o<40;o++){for(var i=e.split("/").filter(b=>!!b),n=a.root,r="/",s=0;s<i.length;s++){var u=s===i.length-1;if(u&&t.parent)break;if(i[s]!=="."){if(i[s]===".."){if(r=qe.dirname(r),a.isRoot(n)){e=r+"/"+i.slice(s+1).join("/"),o--;continue e}else n=n.parent;continue}r=qe.join2(r,i[s]);try{n=a.lookupNode(n,i[s])}catch(b){if(b?.errno===44&&u&&t.noent_okay)return{path:r};throw b}if(a.isMountpoint(n)&&(!u||t.follow_mount)&&(n=n.mounted.root),a.isLink(n.mode)&&(!u||t.follow)){if(!n.node_ops.readlink)throw new a.ErrnoError(52);var c=n.node_ops.readlink(n);qe.isAbs(c)||(c=qe.dirname(r)+"/"+c),e=c+"/"+i.slice(s+1).join("/");continue e}}}return{path:r,node:n}}throw new a.ErrnoError(32)},getPath(e){for(var t;;){if(a.isRoot(e)){var o=e.mount.mountpoint;return t?o[o.length-1]!=="/"?`${o}/${t}`:o+t:o}t=t?`${e.name}/${t}`:e.name,e=e.parent}},hashName(e,t){for(var o=0,i=0;i<t.length;i++)o=(o<<5)-o+t.charCodeAt(i)|0;return(e+o>>>0)%a.nameTable.length},hashAddNode(e){var t=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[t],a.nameTable[t]=e},hashRemoveNode(e){var t=a.hashName(e.parent.id,e.name);if(a.nameTable[t]===e)a.nameTable[t]=e.name_next;else for(var o=a.nameTable[t];o;){if(o.name_next===e){o.name_next=e.name_next;break}o=o.name_next}},lookupNode(e,t){var o=a.mayLookup(e);if(o)throw new a.ErrnoError(o);for(var i=a.hashName(e.id,t),n=a.nameTable[i];n;n=n.name_next){var r=n.name;if(n.parent.id===e.id&&r===t)return n}return a.lookup(e,t)},createNode(e,t,o,i){var n=new a.FSNode(e,t,o,i);return a.hashAddNode(n),n},destroyNode(e){a.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var t=["r","w","rw"][e&3];return e&512&&(t+="w"),t},nodePermissions(e,t){return a.ignorePermissions?0:t.includes("r")&&!(e.mode&292)||t.includes("w")&&!(e.mode&146)||t.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!a.isDir(e.mode))return 54;var t=a.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate(e,t){if(!a.isDir(e.mode))return 54;try{return a.lookupNode(e,t),20}catch{}return a.nodePermissions(e,"wx")},mayDelete(e,t,o){var i;try{i=a.lookupNode(e,t)}catch(r){return r.errno}var n=a.nodePermissions(e,"wx");if(n)return n;if(o){if(!a.isDir(i.mode))return 54;if(a.isRoot(i)||a.getPath(i)===a.cwd())return 10}else if(a.isDir(i.mode))return 31;return 0},mayOpen(e,t){if(!e)return 44;if(a.isLink(e.mode))return 32;var o=a.flagsToPermissionString(t);return a.isDir(e.mode)&&(o!=="r"||t&576)?31:a.nodePermissions(e,o)},checkOpExists(e,t){if(!e)throw new a.ErrnoError(t);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked(e){var t=a.getStream(e);if(!t)throw new a.ErrnoError(8);return t},getStream:e=>a.streams[e],createStream(e,t=-1){return e=Object.assign(new a.FSStream,e),t==-1&&(t=a.nextfd()),e.fd=t,a.streams[t]=e,e},closeStream(e){a.streams[e]=null},dupStream(e,t=-1){var o=a.createStream(e,t);return o.stream_ops?.dup?.(o),o},doSetAttr(e,t,o){var i=e?.stream_ops.setattr,n=i?e:t;i??=t.node_ops.setattr,a.checkOpExists(i,63),i(n,o)},chrdev_stream_ops:{open(e){e.stream_ops=a.getDevice(e.node.rdev).stream_ops,e.stream_ops.open?.(e)},llseek(){throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,t)=>e<<8|t,registerDevice(e,t){a.devices[e]={stream_ops:t}},getDevice:e=>a.devices[e],getMounts(e){for(var t=[],o=[e];o.length;){var i=o.pop();t.push(i),o.push(...i.mounts)}return t},syncfs(e,t){typeof e=="function"&&(t=e,e=!1),a.syncFSRequests++,a.syncFSRequests>1&&Ue(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var o=a.getMounts(a.root.mount),i=0;function n(u){return a.syncFSRequests--,t(u)}function r(u){if(u)return r.errored?void 0:(r.errored=!0,n(u));++i>=o.length&&n(null)}for(var s of o)s.type.syncfs?s.type.syncfs(s,e,r):r(null)},mount(e,t,o){var i=o==="/",n=!o,r;if(i&&a.root)throw new a.ErrnoError(10);if(!i&&!n){var s=a.lookupPath(o,{follow_mount:!1});if(o=s.path,r=s.node,a.isMountpoint(r))throw new a.ErrnoError(10);if(!a.isDir(r.mode))throw new a.ErrnoError(54)}var u={type:e,opts:t,mountpoint:o,mounts:[]},c=e.mount(u);return c.mount=u,u.root=c,i?a.root=c:r&&(r.mounted=u,r.mount&&r.mount.mounts.push(u)),c},unmount(e){var t=a.lookupPath(e,{follow_mount:!1});if(!a.isMountpoint(t.node))throw new a.ErrnoError(28);var o=t.node,i=o.mounted,n=a.getMounts(i);for(var[r,s]of Object.entries(a.nameTable))for(;s;){var u=s.name_next;n.includes(s.mount)&&a.destroyNode(s),s=u}o.mounted=null;var c=o.mount.mounts.indexOf(i);o.mount.mounts.splice(c,1)},lookup(e,t){return e.node_ops.lookup(e,t)},mknod(e,t,o){var i=a.lookupPath(e,{parent:!0}).node,n=qe.basename(e);if(!n)throw new a.ErrnoError(28);if(n==="."||n==="..")throw new a.ErrnoError(20);var r=a.mayCreate(i,n);if(r)throw new a.ErrnoError(r);if(!i.node_ops.mknod)throw new a.ErrnoError(63);return i.node_ops.mknod(i,n,t,o)},statfs(e){return a.statfsNode(a.lookupPath(e,{follow:!0}).node)},statfsStream(e){return a.statfsNode(e.node)},statfsNode(e){var t={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:a.nextInode,ffree:a.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(t,e.node_ops.statfs(e.mount.opts.root)),t},create(e,t=438){return t&=4095,t|=32768,a.mknod(e,t,0)},mkdir(e,t=511){return t&=1023,t|=16384,a.mknod(e,t,0)},mkdirTree(e,t){var o=e.split("/"),i="";for(var n of o)if(n){(i||qe.isAbs(e))&&(i+="/"),i+=n;try{a.mkdir(i,t)}catch(r){if(r.errno!=20)throw r}}},mkdev(e,t,o){return typeof o>"u"&&(o=t,t=438),t|=8192,a.mknod(e,t,o)},symlink(e,t){if(!Ye.resolve(e))throw new a.ErrnoError(44);var o=a.lookupPath(t,{parent:!0}).node;if(!o)throw new a.ErrnoError(44);var i=qe.basename(t),n=a.mayCreate(o,i);if(n)throw new a.ErrnoError(n);if(!o.node_ops.symlink)throw new a.ErrnoError(63);return o.node_ops.symlink(o,i,e)},rename(e,t){var o=qe.dirname(e),i=qe.dirname(t),n=qe.basename(e),r=qe.basename(t),s=a.lookupPath(e,{parent:!0}),u=s.node,c;if(s=a.lookupPath(t,{parent:!0}),c=s.node,!u||!c)throw new a.ErrnoError(44);if(u.mount!==c.mount)throw new a.ErrnoError(75);var b=a.lookupNode(u,n),z=Ye.relative(e,i);if(z.charAt(0)!==".")throw new a.ErrnoError(28);if(z=Ye.relative(t,o),z.charAt(0)!==".")throw new a.ErrnoError(55);var O;try{O=a.lookupNode(c,r)}catch{}if(b!==O){var S=a.isDir(b.mode),w=a.mayDelete(u,n,S);if(w)throw new a.ErrnoError(w);if(w=O?a.mayDelete(c,r,S):a.mayCreate(c,r),w)throw new a.ErrnoError(w);if(!u.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(b)||O&&a.isMountpoint(O))throw new a.ErrnoError(10);if(c!==u&&(w=a.nodePermissions(u,"w"),w))throw new a.ErrnoError(w);a.hashRemoveNode(b);try{u.node_ops.rename(b,c,r),b.parent=c}catch(P){throw P}finally{a.hashAddNode(b)}}},rmdir(e){var t=a.lookupPath(e,{parent:!0}).node,o=qe.basename(e),i=a.lookupNode(t,o),n=a.mayDelete(t,o,!0);if(n)throw new a.ErrnoError(n);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(i))throw new a.ErrnoError(10);t.node_ops.rmdir(t,o),a.destroyNode(i)},readdir(e){var t=a.lookupPath(e,{follow:!0}).node;return a.checkOpExists(t.node_ops.readdir,54)(t)},unlink(e){var t=a.lookupPath(e,{parent:!0}).node;if(!t)throw new a.ErrnoError(44);var o=qe.basename(e),i=a.lookupNode(t,o),n=a.mayDelete(t,o,!1);if(n)throw new a.ErrnoError(n);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(i))throw new a.ErrnoError(10);t.node_ops.unlink(t,o),a.destroyNode(i)},readlink(e){var t=a.lookupPath(e).node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,t){var o=a.lookupPath(e,{follow:!t}).node;return a.checkOpExists(o.node_ops.getattr,63)(o)},fstat(e){var t=a.getStreamChecked(e),o=t.node,i=t.stream_ops.getattr,n=i?t:o;return i??=o.node_ops.getattr,a.checkOpExists(i,63),i(n)},lstat(e){return a.stat(e,!0)},doChmod(e,t,o,i){a.doSetAttr(e,t,{mode:o&4095|t.mode&-4096,ctime:Date.now(),dontFollow:i})},chmod(e,t,o){var i;typeof e=="string"?i=a.lookupPath(e,{follow:!o}).node:i=e,a.doChmod(null,i,t,o)},lchmod(e,t){a.chmod(e,t,!0)},fchmod(e,t){var o=a.getStreamChecked(e);a.doChmod(o,o.node,t,!1)},doChown(e,t,o){a.doSetAttr(e,t,{timestamp:Date.now(),dontFollow:o})},chown(e,t,o,i){var n;typeof e=="string"?n=a.lookupPath(e,{follow:!i}).node:n=e,a.doChown(null,n,i)},lchown(e,t,o){a.chown(e,t,o,!0)},fchown(e,t,o){var i=a.getStreamChecked(e);a.doChown(i,i.node,!1)},doTruncate(e,t,o){if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var i=a.nodePermissions(t,"w");if(i)throw new a.ErrnoError(i);a.doSetAttr(e,t,{size:o,timestamp:Date.now()})},truncate(e,t){if(t<0)throw new a.ErrnoError(28);var o;typeof e=="string"?o=a.lookupPath(e,{follow:!0}).node:o=e,a.doTruncate(null,o,t)},ftruncate(e,t){var o=a.getStreamChecked(e);if(t<0||(o.flags&2097155)===0)throw new a.ErrnoError(28);a.doTruncate(o,o.node,t)},utime(e,t,o){var i=a.lookupPath(e,{follow:!0}).node;a.checkOpExists(i.node_ops.setattr,63)(i,{atime:t,mtime:o})},open(e,t,o=438){if(e==="")throw new a.ErrnoError(44);t=mn(t),t&64?o=o&4095|32768:o=0;var i,n;if(typeof e=="object")i=e;else{n=e.endsWith("/");var r=a.lookupPath(e,{follow:!(t&131072),noent_okay:!0});i=r.node,e=r.path}var s=!1;if(t&64)if(i){if(t&128)throw new a.ErrnoError(20)}else{if(n)throw new a.ErrnoError(31);i=a.mknod(e,o|511,0),s=!0}if(!i)throw new a.ErrnoError(44);if(a.isChrdev(i.mode)&&(t&=-513),t&65536&&!a.isDir(i.mode))throw new a.ErrnoError(54);if(!s){var u=a.mayOpen(i,t);if(u)throw new a.ErrnoError(u)}t&512&&!s&&a.truncate(i,0),t&=-131713;var c=a.createStream({node:i,path:a.getPath(i),flags:t,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),s&&a.chmod(i,o&511),c},close(e){if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(t){throw t}finally{a.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,t,o){if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(o!=0&&o!=1&&o!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,o),e.ungotten=[],e.position},read(e,t,o,i,n){if(i<0||n<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var r=typeof n<"u";if(!r)n=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,t,o,i,n);return r||(e.position+=s),s},write(e,t,o,i,n,r){if(i<0||n<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var s=typeof n<"u";if(!s)n=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var u=e.stream_ops.write(e,t,o,i,n,r);return s||(e.position+=u),u},mmap(e,t,o,i,n){if((i&2)!==0&&(n&2)===0&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);if(!t)throw new a.ErrnoError(28);return e.stream_ops.mmap(e,t,o,i,n)},msync(e,t,o,i,n){return e.stream_ops.msync?e.stream_ops.msync(e,t,o,i,n):0},ioctl(e,t,o){if(!e.stream_ops.ioctl)throw new a.ErrnoError(59);return e.stream_ops.ioctl(e,t,o)},readFile(e,t={}){t.flags=t.flags||0,t.encoding=t.encoding||"binary",t.encoding!=="utf8"&&t.encoding!=="binary"&&Me(`Invalid encoding type "${t.encoding}"`);var o=a.open(e,t.flags),i=a.stat(e).size,n=new Uint8Array(i);return a.read(o,n,0,i,0),t.encoding==="utf8"&&(n=st(n)),a.close(o),n},writeFile(e,t,o={}){o.flags=o.flags||577;var i=a.open(e,o.flags,o.mode);t=zt(t),a.write(i,t,0,t.byteLength,void 0,o.canOwn),a.close(i)},cwd:()=>a.currentPath,chdir(e){var t=a.lookupPath(e,{follow:!0});if(t.node===null)throw new a.ErrnoError(44);if(!a.isDir(t.node.mode))throw new a.ErrnoError(54);var o=a.nodePermissions(t.node,"x");if(o)throw new a.ErrnoError(o);a.currentPath=t.path},createDefaultDirectories(){a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user")},createDefaultDevices(){a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(i,n,r,s,u)=>s,llseek:()=>0}),a.mkdev("/dev/null",a.makedev(1,3)),Ge.register(a.makedev(5,0),Ge.default_tty_ops),Ge.register(a.makedev(6,0),Ge.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),t=0,o=()=>(t===0&&(Ct(e),t=e.byteLength),e[--t]);a.createDevice("/dev","random",o),a.createDevice("/dev","urandom",o),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp")},createSpecialDirectories(){a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount(){var t=a.createNode(e,"fd",16895,73);return t.stream_ops={llseek:_e.stream_ops.llseek},t.node_ops={lookup(o,i){var n=+i,r=a.getStreamChecked(n),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path},id:n+1};return s.parent=s,s},readdir(){return Array.from(a.streams.entries()).filter(([o,i])=>i).map(([o,i])=>o.toString())}},t}},{},"/proc/self/fd")},createStandardStreams(e,t,o){e?a.createDevice("/dev","stdin",e):a.symlink("/dev/tty","/dev/stdin"),t?a.createDevice("/dev","stdout",null,t):a.symlink("/dev/tty","/dev/stdout"),o?a.createDevice("/dev","stderr",null,o):a.symlink("/dev/tty1","/dev/stderr"),a.open("/dev/stdin",0),a.open("/dev/stdout",1),a.open("/dev/stderr",1)},staticInit(){a.nameTable=new Array(4096),a.mount(_e,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:_e}},init(e,t,o){a.initialized=!0,e??=f.stdin,t??=f.stdout,o??=f.stderr,a.createStandardStreams(e,t,o)},quit(){a.initialized=!1;for(var e of a.streams)e&&a.close(e)},findObject(e,t){var o=a.analyzePath(e,t);return o.exists?o.object:null},analyzePath(e,t){try{var o=a.lookupPath(e,{follow:!t});e=o.path}catch{}var i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var o=a.lookupPath(e,{parent:!0});i.parentExists=!0,i.parentPath=o.path,i.parentObject=o.node,i.name=qe.basename(e),o=a.lookupPath(e,{follow:!t}),i.exists=!0,i.path=o.path,i.object=o.node,i.name=o.node.name,i.isRoot=o.path==="/"}catch(n){i.error=n.errno}return i},createPath(e,t,o,i){e=typeof e=="string"?e:a.getPath(e);for(var n=t.split("/").reverse();n.length;){var r=n.pop();if(r){var s=qe.join2(e,r);try{a.mkdir(s)}catch(u){if(u.errno!=20)throw u}e=s}}return s},createFile(e,t,o,i,n){var r=qe.join2(typeof e=="string"?e:a.getPath(e),t),s=St(i,n);return a.create(r,s)},createDataFile(e,t,o,i,n,r){var s=t;e&&(e=typeof e=="string"?e:a.getPath(e),s=t?qe.join2(e,t):e);var u=St(i,n),c=a.create(s,u);if(o){o=zt(o),a.chmod(c,u|146);var b=a.open(c,577);a.write(b,o,0,o.length,0,r),a.close(b),a.chmod(c,u)}},createDevice(e,t,o,i){var n=qe.join2(typeof e=="string"?e:a.getPath(e),t),r=St(!!o,!!i);a.createDevice.major??=64;var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(u){u.seekable=!1},close(u){i?.buffer?.length&&i(10)},read(u,c,b,z,O){for(var S=0,w=0;w<z;w++){var P;try{P=o()}catch{throw new a.ErrnoError(29)}if(P===void 0&&S===0)throw new a.ErrnoError(6);if(P==null)break;S++,c[b+w]=P}return S&&(u.node.atime=Date.now()),S},write(u,c,b,z,O){for(var S=0;S<z;S++)try{i(c[b+S])}catch{throw new a.ErrnoError(29)}return z&&(u.node.mtime=u.node.ctime=Date.now()),S}}),a.mkdev(n,r,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)Me("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=_t(e.url)}catch{throw new a.ErrnoError(29)}},createLazyFile(e,t,o,i,n){class r{lengthKnown=!1;chunks=[];get(O){if(!(O>this.length-1||O<0)){var S=O%this.chunkSize,w=O/this.chunkSize|0;return this.getter(w)[S]}}setDataGetter(O){this.getter=O}cacheLength(){var O=new XMLHttpRequest;O.open("HEAD",o,!1),O.send(null),O.status>=200&&O.status<300||O.status===304||Me("Couldn't load "+o+". Status: "+O.status);var S=Number(O.getResponseHeader("Content-length")),w,P=(w=O.getResponseHeader("Accept-Ranges"))&&w==="bytes",N=(w=O.getResponseHeader("Content-Encoding"))&&w==="gzip",U=1048576;P||(U=S);var y=(j,W)=>{j>W&&Me("invalid range ("+j+", "+W+") or no bytes requested!"),W>S-1&&Me("only "+S+" bytes available! programmer error!");var A=new XMLHttpRequest;return A.open("GET",o,!1),S!==U&&A.setRequestHeader("Range","bytes="+j+"-"+W),A.responseType="arraybuffer",A.overrideMimeType&&A.overrideMimeType("text/plain; charset=x-user-defined"),A.send(null),A.status>=200&&A.status<300||A.status===304||Me("Couldn't load "+o+". Status: "+A.status),A.response!==void 0?new Uint8Array(A.response||[]):vt(A.responseText||"")},m=this;m.setDataGetter(j=>{var W=j*U,A=(j+1)*U-1;return A=Math.min(A,S-1),typeof m.chunks[j]>"u"&&(m.chunks[j]=y(W,A)),typeof m.chunks[j]>"u"&&Me("doXHR failed!"),m.chunks[j]}),(N||!S)&&(U=S=1,S=this.getter(0).length,U=S,ft("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=S,this._chunkSize=U,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){Ve||Me("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s={isDevice:!1,contents:new r}}else var s={isDevice:!1,url:o};var u=a.createFile(e,t,s,i,n);s.contents?u.contents=s.contents:s.url&&(u.contents=null,u.url=s.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var c={};for(const[z,O]of Object.entries(u.stream_ops))c[z]=(...S)=>(a.forceLoadFile(u),O(...S));function b(z,O,S,w,P){var N=z.node.contents;if(P>=N.length)return 0;var U=Math.min(N.length-P,w);if(N.slice)for(var y=0;y<U;y++)O[S+y]=N[P+y];else for(var y=0;y<U;y++)O[S+y]=N.get(P+y);return U}return c.read=(z,O,S,w,P)=>(a.forceLoadFile(u),b(z,O,S,w,P)),c.mmap=(z,O,S,w,P)=>{a.forceLoadFile(u);var N=Mt(O);if(!N)throw new a.ErrnoError(48);return b(z,Ne,N,O,S),{ptr:N,allocated:!0}},u.stream_ops=c,u}},wn=(e,t,o)=>{if(!e)return"";var i=Rt(He,e,t);return Nt.decode(He.subarray(e,i))},fe={calculateAt(e,t,o){if(qe.isAbs(t))return t;var i;if(e===-100?i=a.cwd():i=fe.getStreamFromFD(e).path,t.length==0){if(!o)throw new a.ErrnoError(44);return i}return i+"/"+t},writeStat(e,t){ve[e>>2]=t.dev,ve[e+4>>2]=t.mode,ve[e+8>>2]=t.nlink,ve[e+12>>2]=t.uid,ve[e+16>>2]=t.gid,ve[e+20>>2]=t.rdev,xe[e+24>>3]=BigInt(t.size),ye[e+32>>2]=4096,ye[e+36>>2]=t.blocks;var o=t.atime.getTime(),i=t.mtime.getTime(),n=t.ctime.getTime();return xe[e+40>>3]=BigInt(Math.floor(o/1e3)),ve[e+48>>2]=o%1e3*1e3*1e3,xe[e+56>>3]=BigInt(Math.floor(i/1e3)),ve[e+64>>2]=i%1e3*1e3*1e3,xe[e+72>>3]=BigInt(Math.floor(n/1e3)),ve[e+80>>2]=n%1e3*1e3*1e3,xe[e+88>>3]=BigInt(t.ino),0},writeStatFs(e,t){ve[e+4>>2]=t.bsize,ve[e+60>>2]=t.bsize,xe[e+8>>3]=BigInt(t.blocks),xe[e+16>>3]=BigInt(t.bfree),xe[e+24>>3]=BigInt(t.bavail),xe[e+32>>3]=BigInt(t.files),xe[e+40>>3]=BigInt(t.ffree),ve[e+48>>2]=t.fsid,ve[e+64>>2]=t.flags,ve[e+56>>2]=t.namelen},doMsync(e,t,o,i,n){if(!a.isFile(t.node.mode))throw new a.ErrnoError(43);if(i&2)return 0;var r=He.slice(e,e+o);a.msync(t,r,n,o,i)},getStreamFromFD(e){return a.getStreamChecked(e)},varargs:void 0,getStr(e){return wn(e)}};function En(e,t){try{return e=fe.getStr(e),a.chmod(e,t),0}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function An(e,t,o,i){try{if(t=fe.getStr(t),t=fe.calculateAt(e,t),o&-8)return-28;var n=a.lookupPath(t,{follow:!0}).node;if(!n)return-44;var r="";return o&4&&(r+="r"),o&2&&(r+="w"),o&1&&(r+="x"),r&&a.nodePermissions(n,r)?-2:0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function In(e,t){try{return a.fchmod(e,t),0}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Tn(e,t,o){try{return a.fchown(e,t,o),0}catch(i){if(typeof a>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var pt=()=>{var e=ye[+fe.varargs>>2];return fe.varargs+=4,e},Ze=pt;function kn(e,t,o){fe.varargs=o;try{var i=fe.getStreamFromFD(e);switch(t){case 0:var n=pt();if(n<0)return-28;for(;a.streams[n];)n++;return a.dupStream(i,n).fd;case 1:case 2:return 0;case 3:return i.flags;case 4:var n=pt();return i.flags|=n,0;case 12:var n=Ze(),r=0;return it[n+r>>1]=2,0;case 13:case 14:return 0}return-28}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function On(e,t){try{return fe.writeStat(t,a.fstat(e))}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var xn=9007199254740992,Fn=-9007199254740992,lt=e=>e<Fn||e>xn?NaN:Number(e);function Pn(e,t){t=lt(t);try{return isNaN(t)?-61:(a.ftruncate(e,t),0)}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var Ke=(e,t,o)=>Dt(e,He,t,o);function Ln(e,t){try{if(t===0)return-28;var o=a.cwd(),i=dt(o)+1;return t<i?-68:(Ke(o,e,t),i)}catch(n){if(typeof a>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function Cn(e,t,o){fe.varargs=o;try{var i=fe.getStreamFromFD(e);switch(t){case 21509:return i.tty?0:-59;case 21505:if(!i.tty)return-59;if(i.tty.ops.ioctl_tcgets){var n=i.tty.ops.ioctl_tcgets(i),O=Ze();ye[O>>2]=n.c_iflag||0,ye[O+4>>2]=n.c_oflag||0,ye[O+8>>2]=n.c_cflag||0,ye[O+12>>2]=n.c_lflag||0;for(var r=0;r<32;r++)Ne[O+r+17]=n.c_cc[r]||0;return 0}return 0;case 21510:case 21511:case 21512:return i.tty?0:-59;case 21506:case 21507:case 21508:if(!i.tty)return-59;if(i.tty.ops.ioctl_tcsets){for(var O=Ze(),s=ye[O>>2],u=ye[O+4>>2],c=ye[O+8>>2],b=ye[O+12>>2],z=[],r=0;r<32;r++)z.push(Ne[O+r+17]);return i.tty.ops.ioctl_tcsets(i.tty,t,{c_iflag:s,c_oflag:u,c_cflag:c,c_lflag:b,c_cc:z})}return 0;case 21519:if(!i.tty)return-59;var O=Ze();return ye[O>>2]=0,0;case 21520:return i.tty?-28:-59;case 21537:case 21531:var O=Ze();return a.ioctl(i,t,O);case 21523:if(!i.tty)return-59;if(i.tty.ops.ioctl_tiocgwinsz){var S=i.tty.ops.ioctl_tiocgwinsz(i.tty),O=Ze();it[O>>1]=S[0],it[O+2>>1]=S[1]}return 0;case 21524:return i.tty?0:-59;case 21515:return i.tty?0:-59;default:return-28}}catch(w){if(typeof a>"u"||w.name!=="ErrnoError")throw w;return-w.errno}}function Nn(e,t){try{return e=fe.getStr(e),fe.writeStat(t,a.lstat(e))}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Rn(e,t,o){try{return t=fe.getStr(t),t=fe.calculateAt(e,t),a.mkdir(t,o,0),0}catch(i){if(typeof a>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Dn(e,t,o,i){try{t=fe.getStr(t);var n=i&256,r=i&4096;return i=i&-6401,t=fe.calculateAt(e,t,r),fe.writeStat(o,n?a.lstat(t):a.stat(t))}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function jn(e,t,o,i){fe.varargs=i;try{t=fe.getStr(t),t=fe.calculateAt(e,t);var n=i?pt():0;return a.open(t,o,n).fd}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function Mn(e,t,o,i){try{if(t=fe.getStr(t),t=fe.calculateAt(e,t),i<=0)return-28;var n=a.readlink(t),r=Math.min(i,dt(n)),s=Ne[o+r];return Ke(n,o,i+1),Ne[o+r]=s,r}catch(u){if(typeof a>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function zn(e){try{return e=fe.getStr(e),a.rmdir(e),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function Bn(e,t){try{return e=fe.getStr(e),fe.writeStat(t,a.stat(e))}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Un(e,t,o){try{if(t=fe.getStr(t),t=fe.calculateAt(e,t),!o)a.unlink(t);else if(o===512)a.rmdir(t);else return-28;return 0}catch(i){if(typeof a>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var Qt=e=>ve[e>>2]+ye[e+4>>2]*4294967296;function Qn(e,t,o,i){try{t=fe.getStr(t),t=fe.calculateAt(e,t,!0);var n=Date.now(),r,s;if(!o)r=n,s=n;else{var u=Qt(o),c=ye[o+8>>2];c==1073741823?r=n:c==1073741822?r=null:r=u*1e3+c/1e6,o+=16,u=Qt(o),c=ye[o+8>>2],c==1073741823?s=n:c==1073741822?s=null:s=u*1e3+c/1e6}return(s??r)!==null&&a.utime(t,r,s),0}catch(b){if(typeof a>"u"||b.name!=="ErrnoError")throw b;return-b.errno}}var Wn=e=>e%4===0&&(e%100!==0||e%400===0),Vn=[0,31,60,91,121,152,182,213,244,274,305,335],Hn=[0,31,59,90,120,151,181,212,243,273,304,334],Gn=e=>(Wn(e.getFullYear())?Vn:Hn)[e.getMonth()]+e.getDate()-1;function $n(e,t){e=lt(e);var o=new Date(e*1e3);ye[t>>2]=o.getSeconds(),ye[t+4>>2]=o.getMinutes(),ye[t+8>>2]=o.getHours(),ye[t+12>>2]=o.getDate(),ye[t+16>>2]=o.getMonth(),ye[t+20>>2]=o.getFullYear()-1900,ye[t+24>>2]=o.getDay();var i=Gn(o)|0;ye[t+28>>2]=i,ye[t+36>>2]=-(o.getTimezoneOffset()*60);var n=new Date(o.getFullYear(),0,1),r=new Date(o.getFullYear(),6,1).getTimezoneOffset(),s=n.getTimezoneOffset(),u=(r!=s&&o.getTimezoneOffset()==Math.min(s,r))|0;ye[t+32>>2]=u}function Kn(e,t,o,i,n,r,s){n=lt(n);try{var u=fe.getStreamFromFD(i),c=a.mmap(u,e,n,t,o),b=c.ptr;return ye[r>>2]=c.allocated,ve[s>>2]=b,0}catch(z){if(typeof a>"u"||z.name!=="ErrnoError")throw z;return-z.errno}}function Jn(e,t,o,i,n,r){r=lt(r);try{var s=fe.getStreamFromFD(n);o&2&&fe.doMsync(e,s,t,i,r)}catch(u){if(typeof a>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}var Xn=(e,t,o,i)=>{var n=new Date().getFullYear(),r=new Date(n,0,1),s=new Date(n,6,1),u=r.getTimezoneOffset(),c=s.getTimezoneOffset(),b=Math.max(u,c);ve[e>>2]=b*60,ye[t>>2]=+(u!=c);var z=w=>{var P=w>=0?"-":"+",N=Math.abs(w);return`UTC${P}${String(Math.floor(N/60)).padStart(2,"0")}${String(N%60).padStart(2,"0")}`},O=z(u),S=z(c);c<u?(Ke(O,o,17),Ke(S,i,17)):(Ke(O,i,17),Ke(S,o,17))},Wt=()=>performance.now(),Vt=()=>Date.now(),Yn=e=>e>=0&&e<=3;function Zn(e,t,o){if(!Yn(e))return 28;var i;e===0?i=Vt():i=Wt();var n=Math.round(i*1e3*1e3);return xe[o>>3]=BigInt(n),0}var Ht=()=>2147483648,er=()=>Ht(),tr=e=>{var t=(e-ze.buffer.byteLength+65535)/65536|0;try{return ze.grow(t),xt(),1}catch{}},nr=e=>{var t=He.length;e>>>=0;var o=Ht();if(e>o)return!1;for(var i=1;i<=4;i*=2){var n=t*(1+.2/i);if(n=Math.min(n,e+100663296),tr(Math.min(o,jt(Math.max(e,n),65536))))return!0}return!1},wt={},rr=()=>je||"./this.program",at=()=>{if(!at.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:rr()};for(var t in wt)wt[t]===void 0?delete e[t]:e[t]=wt[t];var o=[];for(var t in e)o.push(`${t}=${e[t]}`);at.strings=o}return at.strings},ir=(e,t)=>{var o=0,i=0;for(var n of at()){var r=t+o;ve[e+i>>2]=r,o+=Ke(n,r,1/0)+1,i+=4}return 0},sr=(e,t)=>{var o=at();ve[e>>2]=o.length;var i=0;for(var n of o)i+=dt(n)+1;return ve[t>>2]=i,0};function or(e){try{var t=fe.getStreamFromFD(e);return a.close(t),0}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return o.errno}}function lr(e,t){try{var o=0,i=0,n=0,r=fe.getStreamFromFD(e),s=r.tty?2:a.isDir(r.mode)?3:a.isLink(r.mode)?7:4;return Ne[t]=s,it[t+2>>1]=n,xe[t+8>>3]=BigInt(o),xe[t+16>>3]=BigInt(i),0}catch(u){if(typeof a>"u"||u.name!=="ErrnoError")throw u;return u.errno}}var ar=(e,t,o,i)=>{for(var n=0,r=0;r<o;r++){var s=ve[t>>2],u=ve[t+4>>2];t+=8;var c=a.read(e,Ne,s,u,i);if(c<0)return-1;if(n+=c,c<u)break}return n};function cr(e,t,o,i){try{var n=ar(fe.getStreamFromFD(e),t,o);return ve[i>>2]=n,0}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return r.errno}}function ur(e,t,o,i){t=lt(t);try{if(isNaN(t))return 61;var n=fe.getStreamFromFD(e);return a.llseek(n,t,o),xe[i>>3]=BigInt(n.position),n.getdents&&t===0&&o===0&&(n.getdents=null),0}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return r.errno}}function _r(e){try{var t=fe.getStreamFromFD(e);return t.stream_ops?.fsync?.(t)}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return o.errno}}var fr=(e,t,o,i)=>{for(var n=0,r=0;r<o;r++){var s=ve[t>>2],u=ve[t+4>>2];t+=8;var c=a.write(e,Ne,s,u,i);if(c<0)return-1;if(n+=c,c<u)break}return n};function dr(e,t,o,i){try{var n=fr(fe.getStreamFromFD(e),t,o);return ve[i>>2]=n,0}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return r.errno}}if(a.createPreloadedFile=Sn,a.preloadFile=Ut,a.staticInit(),Zt(),f.noExitRuntime&&f.noExitRuntime,f.preloadPlugins&&(Bt=f.preloadPlugins),f.print&&(ft=f.print),f.printErr&&(Ue=f.printErr),f.wasmBinary&&(rt=f.wasmBinary),f.arguments&&f.arguments,f.thisProgram&&(je=f.thisProgram),f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.shift()();f.wasmMemory=ze;var Gt;function pr(e){f._sqlite3_status64=e.sqlite3_status64,f._sqlite3_status=e.sqlite3_status,f._sqlite3_db_status64=e.sqlite3_db_status64,f._sqlite3_msize=e.sqlite3_msize,f._sqlite3_db_status=e.sqlite3_db_status,f._sqlite3_vfs_find=e.sqlite3_vfs_find,f._sqlite3_initialize=e.sqlite3_initialize,f._sqlite3_malloc=e.sqlite3_malloc,f._sqlite3_free=e.sqlite3_free,f._sqlite3_vfs_register=e.sqlite3_vfs_register,f._sqlite3_vfs_unregister=e.sqlite3_vfs_unregister,f._sqlite3_malloc64=e.sqlite3_malloc64,f._sqlite3_realloc=e.sqlite3_realloc,f._sqlite3_realloc64=e.sqlite3_realloc64,f._sqlite3_value_text=e.sqlite3_value_text,f._sqlite3_randomness=e.sqlite3_randomness,f._sqlite3_stricmp=e.sqlite3_stricmp,f._sqlite3_strnicmp=e.sqlite3_strnicmp,f._sqlite3_uri_parameter=e.sqlite3_uri_parameter,f._sqlite3_uri_boolean=e.sqlite3_uri_boolean,f._sqlite3_serialize=e.sqlite3_serialize,f._sqlite3_prepare_v2=e.sqlite3_prepare_v2,f._sqlite3_step=e.sqlite3_step,f._sqlite3_column_int64=e.sqlite3_column_int64,f._sqlite3_reset=e.sqlite3_reset,f._sqlite3_exec=e.sqlite3_exec,f._sqlite3_column_int=e.sqlite3_column_int,f._sqlite3_finalize=e.sqlite3_finalize,f._sqlite3_file_control=e.sqlite3_file_control,f._sqlite3_column_name=e.sqlite3_column_name,f._sqlite3_column_text=e.sqlite3_column_text,f._sqlite3_column_type=e.sqlite3_column_type,f._sqlite3_errmsg=e.sqlite3_errmsg,f._sqlite3_deserialize=e.sqlite3_deserialize,f._sqlite3_clear_bindings=e.sqlite3_clear_bindings,f._sqlite3_value_blob=e.sqlite3_value_blob,f._sqlite3_value_bytes=e.sqlite3_value_bytes,f._sqlite3_value_double=e.sqlite3_value_double,f._sqlite3_value_int=e.sqlite3_value_int,f._sqlite3_value_int64=e.sqlite3_value_int64,f._sqlite3_value_subtype=e.sqlite3_value_subtype,f._sqlite3_value_pointer=e.sqlite3_value_pointer,f._sqlite3_value_type=e.sqlite3_value_type,f._sqlite3_value_nochange=e.sqlite3_value_nochange,f._sqlite3_value_frombind=e.sqlite3_value_frombind,f._sqlite3_value_dup=e.sqlite3_value_dup,f._sqlite3_value_free=e.sqlite3_value_free,f._sqlite3_result_blob=e.sqlite3_result_blob,f._sqlite3_result_error_toobig=e.sqlite3_result_error_toobig,f._sqlite3_result_error_nomem=e.sqlite3_result_error_nomem,f._sqlite3_result_double=e.sqlite3_result_double,f._sqlite3_result_error=e.sqlite3_result_error,f._sqlite3_result_int=e.sqlite3_result_int,f._sqlite3_result_int64=e.sqlite3_result_int64,f._sqlite3_result_null=e.sqlite3_result_null,f._sqlite3_result_pointer=e.sqlite3_result_pointer,f._sqlite3_result_subtype=e.sqlite3_result_subtype,f._sqlite3_result_text=e.sqlite3_result_text,f._sqlite3_result_zeroblob=e.sqlite3_result_zeroblob,f._sqlite3_result_zeroblob64=e.sqlite3_result_zeroblob64,f._sqlite3_result_error_code=e.sqlite3_result_error_code,f._sqlite3_user_data=e.sqlite3_user_data,f._sqlite3_context_db_handle=e.sqlite3_context_db_handle,f._sqlite3_vtab_nochange=e.sqlite3_vtab_nochange,f._sqlite3_vtab_in_first=e.sqlite3_vtab_in_first,f._sqlite3_vtab_in_next=e.sqlite3_vtab_in_next,f._sqlite3_aggregate_context=e.sqlite3_aggregate_context,f._sqlite3_get_auxdata=e.sqlite3_get_auxdata,f._sqlite3_set_auxdata=e.sqlite3_set_auxdata,f._sqlite3_column_count=e.sqlite3_column_count,f._sqlite3_data_count=e.sqlite3_data_count,f._sqlite3_column_blob=e.sqlite3_column_blob,f._sqlite3_column_bytes=e.sqlite3_column_bytes,f._sqlite3_column_double=e.sqlite3_column_double,f._sqlite3_column_value=e.sqlite3_column_value,f._sqlite3_column_decltype=e.sqlite3_column_decltype,f._sqlite3_column_database_name=e.sqlite3_column_database_name,f._sqlite3_column_table_name=e.sqlite3_column_table_name,f._sqlite3_column_origin_name=e.sqlite3_column_origin_name,f._sqlite3_bind_blob=e.sqlite3_bind_blob,f._sqlite3_bind_double=e.sqlite3_bind_double,f._sqlite3_bind_int=e.sqlite3_bind_int,f._sqlite3_bind_int64=e.sqlite3_bind_int64,f._sqlite3_bind_null=e.sqlite3_bind_null,f._sqlite3_bind_pointer=e.sqlite3_bind_pointer,f._sqlite3_bind_text=e.sqlite3_bind_text,f._sqlite3_bind_zeroblob=e.sqlite3_bind_zeroblob,f._sqlite3_bind_parameter_count=e.sqlite3_bind_parameter_count,f._sqlite3_bind_parameter_name=e.sqlite3_bind_parameter_name,f._sqlite3_bind_parameter_index=e.sqlite3_bind_parameter_index,f._sqlite3_db_handle=e.sqlite3_db_handle,f._sqlite3_stmt_readonly=e.sqlite3_stmt_readonly,f._sqlite3_stmt_isexplain=e.sqlite3_stmt_isexplain,f._sqlite3_stmt_explain=e.sqlite3_stmt_explain,f._sqlite3_stmt_busy=e.sqlite3_stmt_busy,f._sqlite3_next_stmt=e.sqlite3_next_stmt,f._sqlite3_stmt_status=e.sqlite3_stmt_status,f._sqlite3_sql=e.sqlite3_sql,f._sqlite3_expanded_sql=e.sqlite3_expanded_sql,f._sqlite3_preupdate_old=e.sqlite3_preupdate_old,f._sqlite3_preupdate_count=e.sqlite3_preupdate_count,f._sqlite3_preupdate_depth=e.sqlite3_preupdate_depth,f._sqlite3_preupdate_blobwrite=e.sqlite3_preupdate_blobwrite,f._sqlite3_preupdate_new=e.sqlite3_preupdate_new,f._sqlite3_value_numeric_type=e.sqlite3_value_numeric_type,f._sqlite3_set_authorizer=e.sqlite3_set_authorizer,f._sqlite3_strglob=e.sqlite3_strglob,f._sqlite3_strlike=e.sqlite3_strlike,f._sqlite3_auto_extension=e.sqlite3_auto_extension,f._sqlite3_cancel_auto_extension=e.sqlite3_cancel_auto_extension,f._sqlite3_reset_auto_extension=e.sqlite3_reset_auto_extension,f._sqlite3_prepare_v3=e.sqlite3_prepare_v3,f._sqlite3_create_module=e.sqlite3_create_module,f._sqlite3_create_module_v2=e.sqlite3_create_module_v2,f._sqlite3_drop_modules=e.sqlite3_drop_modules,f._sqlite3_declare_vtab=e.sqlite3_declare_vtab,f._sqlite3_vtab_on_conflict=e.sqlite3_vtab_on_conflict,f._sqlite3_vtab_collation=e.sqlite3_vtab_collation,f._sqlite3_vtab_in=e.sqlite3_vtab_in,f._sqlite3_vtab_rhs_value=e.sqlite3_vtab_rhs_value,f._sqlite3_vtab_distinct=e.sqlite3_vtab_distinct,f._sqlite3_keyword_name=e.sqlite3_keyword_name,f._sqlite3_keyword_count=e.sqlite3_keyword_count,f._sqlite3_keyword_check=e.sqlite3_keyword_check,f._sqlite3_complete=e.sqlite3_complete,f._sqlite3_libversion=e.sqlite3_libversion,f._sqlite3_libversion_number=e.sqlite3_libversion_number,f._sqlite3_shutdown=e.sqlite3_shutdown,f._sqlite3_last_insert_rowid=e.sqlite3_last_insert_rowid,f._sqlite3_set_last_insert_rowid=e.sqlite3_set_last_insert_rowid,f._sqlite3_changes64=e.sqlite3_changes64,f._sqlite3_changes=e.sqlite3_changes,f._sqlite3_total_changes64=e.sqlite3_total_changes64,f._sqlite3_total_changes=e.sqlite3_total_changes,f._sqlite3_txn_state=e.sqlite3_txn_state,f._sqlite3_close_v2=e.sqlite3_close_v2,f._sqlite3_busy_handler=e.sqlite3_busy_handler,f._sqlite3_progress_handler=e.sqlite3_progress_handler,f._sqlite3_busy_timeout=e.sqlite3_busy_timeout,f._sqlite3_interrupt=e.sqlite3_interrupt,f._sqlite3_is_interrupted=e.sqlite3_is_interrupted,f._sqlite3_create_function=e.sqlite3_create_function,f._sqlite3_create_function_v2=e.sqlite3_create_function_v2,f._sqlite3_create_window_function=e.sqlite3_create_window_function,f._sqlite3_overload_function=e.sqlite3_overload_function,f._sqlite3_trace_v2=e.sqlite3_trace_v2,f._sqlite3_commit_hook=e.sqlite3_commit_hook,f._sqlite3_update_hook=e.sqlite3_update_hook,f._sqlite3_rollback_hook=e.sqlite3_rollback_hook,f._sqlite3_preupdate_hook=e.sqlite3_preupdate_hook,f._sqlite3_set_errmsg=e.sqlite3_set_errmsg,f._sqlite3_error_offset=e.sqlite3_error_offset,f._sqlite3_errcode=e.sqlite3_errcode,f._sqlite3_extended_errcode=e.sqlite3_extended_errcode,f._sqlite3_errstr=e.sqlite3_errstr,f._sqlite3_limit=e.sqlite3_limit,f._sqlite3_open=e.sqlite3_open,f._sqlite3_open_v2=e.sqlite3_open_v2,f._sqlite3_create_collation=e.sqlite3_create_collation,f._sqlite3_create_collation_v2=e.sqlite3_create_collation_v2,f._sqlite3_collation_needed=e.sqlite3_collation_needed,f._sqlite3_get_autocommit=e.sqlite3_get_autocommit,f._sqlite3_table_column_metadata=e.sqlite3_table_column_metadata,f._sqlite3_extended_result_codes=e.sqlite3_extended_result_codes,f._sqlite3_uri_key=e.sqlite3_uri_key,f._sqlite3_uri_int64=e.sqlite3_uri_int64,f._sqlite3_db_name=e.sqlite3_db_name,f._sqlite3_db_filename=e.sqlite3_db_filename,f._sqlite3_db_readonly=e.sqlite3_db_readonly,f._sqlite3_compileoption_used=e.sqlite3_compileoption_used,f._sqlite3_compileoption_get=e.sqlite3_compileoption_get,f._sqlite3session_diff=e.sqlite3session_diff,f._sqlite3session_attach=e.sqlite3session_attach,f._sqlite3session_create=e.sqlite3session_create,f._sqlite3session_delete=e.sqlite3session_delete,f._sqlite3session_table_filter=e.sqlite3session_table_filter,f._sqlite3session_changeset=e.sqlite3session_changeset,f._sqlite3session_changeset_strm=e.sqlite3session_changeset_strm,f._sqlite3session_patchset_strm=e.sqlite3session_patchset_strm,f._sqlite3session_patchset=e.sqlite3session_patchset,f._sqlite3session_enable=e.sqlite3session_enable,f._sqlite3session_indirect=e.sqlite3session_indirect,f._sqlite3session_isempty=e.sqlite3session_isempty,f._sqlite3session_memory_used=e.sqlite3session_memory_used,f._sqlite3session_object_config=e.sqlite3session_object_config,f._sqlite3session_changeset_size=e.sqlite3session_changeset_size,f._sqlite3changeset_start=e.sqlite3changeset_start,f._sqlite3changeset_start_v2=e.sqlite3changeset_start_v2,f._sqlite3changeset_start_strm=e.sqlite3changeset_start_strm,f._sqlite3changeset_start_v2_strm=e.sqlite3changeset_start_v2_strm,f._sqlite3changeset_next=e.sqlite3changeset_next,f._sqlite3changeset_op=e.sqlite3changeset_op,f._sqlite3changeset_pk=e.sqlite3changeset_pk,f._sqlite3changeset_old=e.sqlite3changeset_old,f._sqlite3changeset_new=e.sqlite3changeset_new,f._sqlite3changeset_conflict=e.sqlite3changeset_conflict,f._sqlite3changeset_fk_conflicts=e.sqlite3changeset_fk_conflicts,f._sqlite3changeset_finalize=e.sqlite3changeset_finalize,f._sqlite3changeset_invert=e.sqlite3changeset_invert,f._sqlite3changeset_invert_strm=e.sqlite3changeset_invert_strm,f._sqlite3changeset_apply_v2=e.sqlite3changeset_apply_v2,f._sqlite3changeset_apply_v3=e.sqlite3changeset_apply_v3,f._sqlite3changeset_apply=e.sqlite3changeset_apply,f._sqlite3changeset_apply_v3_strm=e.sqlite3changeset_apply_v3_strm,f._sqlite3changeset_apply_v2_strm=e.sqlite3changeset_apply_v2_strm,f._sqlite3changeset_apply_strm=e.sqlite3changeset_apply_strm,f._sqlite3changegroup_new=e.sqlite3changegroup_new,f._sqlite3changegroup_add=e.sqlite3changegroup_add,f._sqlite3changegroup_output=e.sqlite3changegroup_output,f._sqlite3changegroup_add_strm=e.sqlite3changegroup_add_strm,f._sqlite3changegroup_output_strm=e.sqlite3changegroup_output_strm,f._sqlite3changegroup_delete=e.sqlite3changegroup_delete,f._sqlite3changeset_concat=e.sqlite3changeset_concat,f._sqlite3changeset_concat_strm=e.sqlite3changeset_concat_strm,f._sqlite3session_config=e.sqlite3session_config,f._sqlite3_sourceid=e.sqlite3_sourceid,f._sqlite3__wasm_pstack_ptr=e.sqlite3__wasm_pstack_ptr,f._sqlite3__wasm_pstack_restore=e.sqlite3__wasm_pstack_restore,f._sqlite3__wasm_pstack_alloc=e.sqlite3__wasm_pstack_alloc,f._sqlite3__wasm_pstack_remaining=e.sqlite3__wasm_pstack_remaining,f._sqlite3__wasm_pstack_quota=e.sqlite3__wasm_pstack_quota,f._sqlite3__wasm_test_struct=e.sqlite3__wasm_test_struct,f._sqlite3__wasm_enum_json=e.sqlite3__wasm_enum_json,f._sqlite3__wasm_vfs_unlink=e.sqlite3__wasm_vfs_unlink,f._sqlite3__wasm_db_vfs=e.sqlite3__wasm_db_vfs,f._sqlite3__wasm_db_reset=e.sqlite3__wasm_db_reset,f._sqlite3__wasm_db_export_chunked=e.sqlite3__wasm_db_export_chunked,f._sqlite3__wasm_db_serialize=e.sqlite3__wasm_db_serialize,f._sqlite3__wasm_vfs_create_file=e.sqlite3__wasm_vfs_create_file,f._sqlite3__wasm_posix_create_file=e.sqlite3__wasm_posix_create_file,f._sqlite3__wasm_kvvfsMakeKey=e.sqlite3__wasm_kvvfsMakeKey,f._sqlite3__wasm_kvvfs_methods=e.sqlite3__wasm_kvvfs_methods,f._sqlite3__wasm_vtab_config=e.sqlite3__wasm_vtab_config,f._sqlite3__wasm_db_config_ip=e.sqlite3__wasm_db_config_ip,f._sqlite3__wasm_db_config_pii=e.sqlite3__wasm_db_config_pii,f._sqlite3__wasm_db_config_s=e.sqlite3__wasm_db_config_s,f._sqlite3__wasm_config_i=e.sqlite3__wasm_config_i,f._sqlite3__wasm_config_ii=e.sqlite3__wasm_config_ii,f._sqlite3__wasm_config_j=e.sqlite3__wasm_config_j,f._sqlite3__wasm_qfmt_token=e.sqlite3__wasm_qfmt_token,f._sqlite3__wasm_kvvfs_decode=e.sqlite3__wasm_kvvfs_decode,f._sqlite3__wasm_kvvfs_encode=e.sqlite3__wasm_kvvfs_encode,f._sqlite3__wasm_init_wasmfs=e.sqlite3__wasm_init_wasmfs,f._sqlite3__wasm_test_intptr=e.sqlite3__wasm_test_intptr,f._sqlite3__wasm_test_voidptr=e.sqlite3__wasm_test_voidptr,f._sqlite3__wasm_test_int64_max=e.sqlite3__wasm_test_int64_max,f._sqlite3__wasm_test_int64_min=e.sqlite3__wasm_test_int64_min,f._sqlite3__wasm_test_int64_times2=e.sqlite3__wasm_test_int64_times2,f._sqlite3__wasm_test_int64_minmax=e.sqlite3__wasm_test_int64_minmax,f._sqlite3__wasm_test_int64ptr=e.sqlite3__wasm_test_int64ptr,f._sqlite3__wasm_test_stack_overflow=e.sqlite3__wasm_test_stack_overflow,f._sqlite3__wasm_test_str_hello=e.sqlite3__wasm_test_str_hello,f._sqlite3__wasm_SQLTester_strglob=e.sqlite3__wasm_SQLTester_strglob,f._malloc=e.malloc,f._free=e.free,f._realloc=e.realloc,Gt=e.emscripten_builtin_memalign,e._emscripten_stack_restore,e._emscripten_stack_alloc,e.emscripten_stack_get_current,e.__indirect_function_table}var $t={__syscall_chmod:En,__syscall_faccessat:An,__syscall_fchmod:In,__syscall_fchown32:Tn,__syscall_fcntl64:kn,__syscall_fstat64:On,__syscall_ftruncate64:Pn,__syscall_getcwd:Ln,__syscall_ioctl:Cn,__syscall_lstat64:Nn,__syscall_mkdirat:Rn,__syscall_newfstatat:Dn,__syscall_openat:jn,__syscall_readlinkat:Mn,__syscall_rmdir:zn,__syscall_stat64:Bn,__syscall_unlinkat:Un,__syscall_utimensat:Qn,_localtime_js:$n,_mmap_js:Kn,_munmap_js:Jn,_tzset_js:Xn,clock_time_get:Zn,emscripten_date_now:Vt,emscripten_get_heap_max:er,emscripten_get_now:Wt,emscripten_resize_heap:nr,environ_get:ir,environ_sizes_get:sr,fd_close:or,fd_fdstat_get:lr,fd_read:cr,fd_seek:ur,fd_sync:_r,fd_write:dr,memory:ze};function Et(){if($e>0){ot=Et;return}if(en(),$e>0){ot=Et;return}function e(){f.calledRun=!0,!It&&(tn(),Tt?.(f),f.onRuntimeInitialized?.(),nn())}f.setStatus?(f.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>f.setStatus(""),1),e()},1)):e()}var et=await un();return Et(),f.runSQLite3PostLoadInit=async function(e,t,o){delete t.runSQLite3PostLoadInit;globalThis.sqlite3ApiBootstrap=async function i(n=globalThis.sqlite3ApiConfig||i.defaultConfig){if(i.sqlite3)return(i.sqlite3.config||console).warn("sqlite3ApiBootstrap() called multiple times.","Config and external initializers are ignored on calls after the first."),i.sqlite3;const r=(...d)=>Object.assign(Object.create(null),...d),s=r({exports:void 0,memory:void 0,bigIntEnabled:!!globalThis.BigInt64Array,debug:console.debug.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),log:console.log.bind(console),wasmfsOpfsDir:"/opfs",useStdAlloc:!1},n);Object.assign(s,{allocExportName:s.useStdAlloc?"malloc":"sqlite3_malloc",deallocExportName:s.useStdAlloc?"free":"sqlite3_free",reallocExportName:s.useStdAlloc?"realloc":"sqlite3_realloc"}),["exports","memory","functionTable","wasmfsOpfsDir"].forEach(d=>{typeof s[d]=="function"&&(s[d]=s[d]())});const u=r(),c=r(),b=d=>u.sqlite3_js_rc_str&&u.sqlite3_js_rc_str(d)||"Unknown result code #"+d,z=d=>typeof d=="number"&&d===(d|0)&&d<=2147483647&&d>=-2147483648;class O extends Error{constructor(...q){let L;if(q.length)if(z(q[0]))if(L=q[0],q.length===1)super(b(q[0]));else{const Q=b(L);typeof q[1]=="object"?super(Q,q[1]):(q[0]=Q+":",super(q.join(" ")))}else q.length===2&&typeof q[1]=="object"?super(...q):super(q.join(" "));this.resultCode=L||u.SQLITE_ERROR,this.name="SQLite3Error"}}O.toss=(...d)=>{throw new O(...d)};const S=O.toss;s.wasmfsOpfsDir&&!/^\/[^/]+$/.test(s.wasmfsOpfsDir)&&S("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");const w=function d(q){return d._max||(d._max=BigInt("0x7fffffffffffffff"),d._min=~d._max),q>=d._min&&q<=d._max},P=d=>d>=-2147483647n-1n&&d<=2147483647n,N=function d(q){return d._min||(d._min=Number.MIN_SAFE_INTEGER,d._max=Number.MAX_SAFE_INTEGER),q>=d._min&&q<=d._max},U=d=>d&&d.constructor&&z(d.constructor.BYTES_PER_ELEMENT)?d:!1,y=d=>d&&(d instanceof Uint8Array||d instanceof Int8Array||d instanceof ArrayBuffer),m=d=>d&&(d instanceof Uint8Array||d instanceof Int8Array||d instanceof ArrayBuffer),j=d=>y(d)||S("Value is not of a supported TypedArray type."),W=function(d){return m(d)?c.typedArrayToString(d instanceof ArrayBuffer?new Uint8Array(d):d,0,d.length):Array.isArray(d)?d.join(""):(c.isPtr(d)&&(d=c.cstrToJs(d)),d)};class A extends Error{constructor(...q){q.length===2&&typeof q[1]=="object"?super(...q):q.length?super(q.join(" ")):super("Allocation failed."),this.resultCode=u.SQLITE_NOMEM,this.name="WasmAllocError"}}A.toss=(...d)=>{throw new A(...d)},Object.assign(u,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(d,q,L,Q,F,Y,Z,ee,g)=>{},sqlite3_create_function:(d,q,L,Q,F,Y,Z,ee)=>{},sqlite3_create_window_function:(d,q,L,Q,F,Y,Z,ee,g,T)=>{},sqlite3_prepare_v3:(d,q,L,Q,F,Y)=>{},sqlite3_prepare_v2:(d,q,L,Q,F)=>{},sqlite3_exec:(d,q,L,Q,F)=>{},sqlite3_randomness:(d,q)=>{}});const R={affirmBindableTypedArray:j,flexibleString:W,bigIntFits32:P,bigIntFits64:w,bigIntFitsDouble:N,isBindableTypedArray:y,isInt32:z,isSQLableTypedArray:m,isTypedArray:U,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,toss:function(...d){throw new Error(d.join(" "))},toss3:S,typedArrayPart:c.typedArrayPart,nu:r,assert:function(d,q){d||R.toss("Assertion failed:",q)},affirmDbHeader:function(d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));const q="SQLite format 3";15>d.byteLength&&S("Input does not contain an SQLite3 database header.");for(let L=0;L<15;++L)q.charCodeAt(L)!==d[L]&&S("Input does not contain an SQLite3 database header.")},affirmIsDb:function(d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));const q=d.byteLength;(q<512||q%512!==0)&&S("Byte array size",q,"is invalid for an SQLite3 db."),R.affirmDbHeader(d)}};Object.assign(c,{exports:s.exports||S("Missing API config.exports (WASM module exports)."),memory:s.memory||s.exports.memory||S("API config object requires a WebAssembly.Memory object","in either config.exports.memory (exported)","or config.memory (imported)."),pointerSize:typeof s.exports.sqlite3_libversion()=="number"?4:8,bigIntEnabled:!!s.bigIntEnabled,functionTable:s.functionTable,alloc:void 0,realloc:void 0,dealloc:void 0}),c.allocFromTypedArray=function(d){d instanceof ArrayBuffer&&(d=new Uint8Array(d)),j(d);const q=c.alloc(d.byteLength||1);return c.heapForSize(d.constructor).set(d.byteLength?d:[0],Number(q)),q};{const d=s.allocExportName,q=s.deallocExportName,L=s.reallocExportName;for(const Q of[d,q,L])c.exports[Q]instanceof Function||S("Missing required exports[",Q,"] function.");c.alloc=function Q(F){return Q.impl(F)||A.toss("Failed to allocate",F," bytes.")},c.alloc.impl=c.exports[d],c.realloc=function Q(F,Y){const Z=Q.impl(c.ptr.coerce(F),Y);return Y?Z||A.toss("Failed to reallocate",Y," bytes."):c.ptr.null},c.realloc.impl=c.exports[L],c.dealloc=function Q(F){Q.impl(c.ptr.coerce(F))},c.dealloc.impl=c.exports[q]}c.compileOptionUsed=function d(q){if(arguments.length){if(Array.isArray(q)){const L=r();return q.forEach(Q=>{L[Q]=u.sqlite3_compileoption_used(Q)}),L}else if(typeof q=="object")return Object.keys(q).forEach(L=>{q[L]=u.sqlite3_compileoption_used(L)}),q}else{if(d._result)return d._result;d._opt||(d._rx=/^([^=]+)=(.+)/,d._rxInt=/^-?\d+$/,d._opt=function(Z,ee){const g=d._rx.exec(Z);ee[0]=g?g[1]:Z,ee[1]=g?d._rxInt.test(g[2])?+g[2]:g[2]:!0});const L=r(),Q=[0,0];let F=0,Y;for(;Y=u.sqlite3_compileoption_get(F++);)d._opt(Y,Q),L[Q[0]]=Q[1];return d._result=L}return typeof q=="string"?!!u.sqlite3_compileoption_used(q):!1},c.pstack=r({restore:c.exports.sqlite3__wasm_pstack_restore,alloc:function(d){return typeof d=="string"&&!(d=c.sizeofIR(d))&&A.toss("Invalid value for pstack.alloc(",arguments[0],")"),c.exports.sqlite3__wasm_pstack_alloc(d)||A.toss("Could not allocate",d,"bytes from the pstack.")},allocChunks:function(d,q){typeof q=="string"&&!(q=c.sizeofIR(q))&&A.toss("Invalid size value for allocChunks(",arguments[1],")");const L=c.pstack.alloc(d*q),Q=[L];let F=1,Y=q;for(;F<d;++F,Y+=q)Q.push(c.ptr.add(L,Y));return Q},allocPtr:(d=1,q=!0)=>d===1?c.pstack.alloc(q?8:c.ptr.size):c.pstack.allocChunks(d,q?8:c.ptr.size),call:function(d){const q=c.pstack.pointer;try{return d(J)}finally{c.pstack.restore(q)}}}),Object.defineProperties(c.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:c.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:c.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:c.exports.sqlite3__wasm_pstack_remaining}}),u.sqlite3_randomness=(...d)=>{if(d.length===1&&R.isTypedArray(d[0])&&d[0].BYTES_PER_ELEMENT===1){const q=d[0];if(q.byteLength===0)return c.exports.sqlite3_randomness(0,c.ptr.null),q;const L=c.pstack.pointer;try{let Q=q.byteLength,F=0;const Y=c.exports.sqlite3_randomness,Z=c.heap8u(),ee=Q<512?Q:512,g=c.pstack.alloc(ee);do{const T=Q>ee?ee:Q;Y(T,g),q.set(c.typedArrayPart(Z,g,c.ptr.add(g,T)),F),Q-=T,F+=T}while(Q>0)}catch(Q){s.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",Q)}finally{c.pstack.restore(L)}return q}c.exports.sqlite3_randomness(...d)},u.sqlite3_wasmfs_opfs_dir=(function(){if(this.dir!==void 0)return this.dir;const d=s.wasmfsOpfsDir;if(!d||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!c.exports.sqlite3__wasm_init_wasmfs)return this.dir="";try{return d&&c.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],d)===0?this.dir=d:this.dir=""}catch{return this.dir=""}}).bind(r()),u.sqlite3_wasmfs_filename_is_persistent=function(d){const q=u.sqlite3_wasmfs_opfs_dir();return q&&d?d.startsWith(q+"/"):!1},u.sqlite3_js_db_uses_vfs=function(d,q,L=0){try{const Q=u.sqlite3_vfs_find(q);return Q?d?Q===u.sqlite3_js_db_vfs(d,L)?Q:!1:Q===u.sqlite3_vfs_find(0)?Q:!1:!1}catch{return!1}},u.sqlite3_js_vfs_list=function(){const d=[];let q=u.sqlite3_vfs_find(c.ptr.null);for(;q;){const L=new u.sqlite3_vfs(q);d.push(c.cstrToJs(L.$zName)),q=L.$pNext,L.dispose()}return d},u.sqlite3_js_db_export=function(d,q=0){d=c.xWrap.testConvertArg("sqlite3*",d),d||S("Invalid sqlite3* argument."),c.bigIntEnabled||S("BigInt support is not enabled.");const L=c.scopedAllocPush();let Q;try{const F=c.scopedAlloc(8+c.ptr.size),Y=c.ptr.add(F,8),Z=q?c.isPtr(q)?q:c.scopedAllocCString(""+q):c.ptr.null;let ee=c.exports.sqlite3__wasm_db_serialize(d,Z,Y,F,0);ee&&S("Database serialization failed with code",J.capi.sqlite3_js_rc_str(ee)),Q=c.peekPtr(Y);const g=c.peek(F,"i64");return ee=g?c.heap8u().slice(Number(Q),Number(Q)+Number(g)):new Uint8Array,ee}finally{Q&&c.exports.sqlite3_free(Q),c.scopedAllocPop(L)}},u.sqlite3_js_db_vfs=(d,q=c.ptr.null)=>R.sqlite3__wasm_db_vfs(d,q),u.sqlite3_js_aggregate_context=(d,q)=>u.sqlite3_aggregate_context(d,q)||(q?A.toss("Cannot allocate",q,"bytes for sqlite3_aggregate_context()"):0),u.sqlite3_js_posix_create_file=function(d,q,L){let Q;q&&c.isPtr(q)?Q=q:q instanceof ArrayBuffer||q instanceof Uint8Array?(Q=c.allocFromTypedArray(q),(arguments.length<3||!R.isInt32(L)||L<0)&&(L=q.byteLength)):O.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{(!R.isInt32(L)||L<0)&&O.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");const F=R.sqlite3__wasm_posix_create_file(d,Q,L);F&&O.toss("Creation of file failed with sqlite3 result code",u.sqlite3_js_rc_str(F))}finally{Q&&Q!==q&&c.dealloc(Q)}},u.sqlite3_js_vfs_create_file=function(d,q,L,Q){s.warn("sqlite3_js_vfs_create_file() is deprecated and","should be avoided because it can lead to C-level crashes.","See its documentation for alternatives.");let F;L?c.isPtr(L)?F=L:(L instanceof ArrayBuffer&&(L=new Uint8Array(L)),L instanceof Uint8Array?(F=c.allocFromTypedArray(L),(arguments.length<4||!R.isInt32(Q)||Q<0)&&(Q=L.byteLength)):O.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")):F=0,(!R.isInt32(Q)||Q<0)&&(F&&F!==L&&c.dealloc(F),O.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."));try{const Y=R.sqlite3__wasm_vfs_create_file(d,q,F,Q);Y&&O.toss("Creation of file failed with sqlite3 result code",u.sqlite3_js_rc_str(Y))}finally{F&&F!==L&&c.dealloc(F)}},u.sqlite3_js_sql_to_string=d=>{if(typeof d=="string")return d;const q=W(v);return q===v?void 0:q},u.sqlite3_db_config=(function(d,q,...L){switch(q){case u.SQLITE_DBCONFIG_ENABLE_FKEY:case u.SQLITE_DBCONFIG_ENABLE_TRIGGER:case u.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER:case u.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION:case u.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE:case u.SQLITE_DBCONFIG_ENABLE_QPSG:case u.SQLITE_DBCONFIG_TRIGGER_EQP:case u.SQLITE_DBCONFIG_RESET_DATABASE:case u.SQLITE_DBCONFIG_DEFENSIVE:case u.SQLITE_DBCONFIG_WRITABLE_SCHEMA:case u.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE:case u.SQLITE_DBCONFIG_DQS_DML:case u.SQLITE_DBCONFIG_DQS_DDL:case u.SQLITE_DBCONFIG_ENABLE_VIEW:case u.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT:case u.SQLITE_DBCONFIG_TRUSTED_SCHEMA:case u.SQLITE_DBCONFIG_STMT_SCANSTATUS:case u.SQLITE_DBCONFIG_REVERSE_SCANORDER:case u.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE:case u.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE:case u.SQLITE_DBCONFIG_ENABLE_COMMENTS:case u.SQLITE_DBCONFIG_FP_DIGITS:return this.ip||(this.ip=c.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"])),this.ip(d,q,L[0],L[1]||0);case u.SQLITE_DBCONFIG_LOOKASIDE:return this.pii||(this.pii=c.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"])),this.pii(d,q,L[0],L[1],L[2]);case u.SQLITE_DBCONFIG_MAINDBNAME:return this.s||(this.s=c.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"])),this.s(d,q,L[0]);default:return u.SQLITE_MISUSE}}).bind(r()),u.sqlite3_value_to_js=function(d,q=!0){let L;const Q=u.sqlite3_value_type(d);switch(Q){case u.SQLITE_INTEGER:c.bigIntEnabled?(L=u.sqlite3_value_int64(d),R.bigIntFitsDouble(L)&&(L=Number(L))):L=u.sqlite3_value_double(d);break;case u.SQLITE_FLOAT:L=u.sqlite3_value_double(d);break;case u.SQLITE_TEXT:L=u.sqlite3_value_text(d);break;case u.SQLITE_BLOB:{const F=u.sqlite3_value_bytes(d),Y=u.sqlite3_value_blob(d);F&&!Y&&J.WasmAllocError.toss("Cannot allocate memory for blob argument of",F,"byte(s)"),L=F?c.heap8u().slice(Number(Y),Number(Y)+Number(F)):null;break}case u.SQLITE_NULL:L=null;break;default:q&&S(u.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",Q),L=void 0}return L},u.sqlite3_values_to_js=function(d,q,L=!0){let Q;const F=[];for(Q=0;Q<d;++Q)F.push(u.sqlite3_value_to_js(c.peekPtr(c.ptr.add(q,c.ptr.size*Q)),L));return F},u.sqlite3_result_error_js=function(d,q){q instanceof A?u.sqlite3_result_error_nomem(d):u.sqlite3_result_error(d,""+q,-1)},u.sqlite3_result_js=function(d,q){if(q instanceof Error){u.sqlite3_result_error_js(d,q);return}try{switch(typeof q){case"undefined":break;case"boolean":u.sqlite3_result_int(d,q?1:0);break;case"bigint":R.bigIntFits32(q)?u.sqlite3_result_int(d,Number(q)):R.bigIntFitsDouble(q)?u.sqlite3_result_double(d,Number(q)):c.bigIntEnabled?R.bigIntFits64(q)?u.sqlite3_result_int64(d,q):S("BigInt value",q.toString(),"is too BigInt for int64."):S("BigInt value",q.toString(),"is too BigInt.");break;case"number":{let L;R.isInt32(q)?L=u.sqlite3_result_int:c.bigIntEnabled&&Number.isInteger(q)&&R.bigIntFits64(BigInt(q))?L=u.sqlite3_result_int64:L=u.sqlite3_result_double,L(d,q);break}case"string":{const[L,Q]=c.allocCString(q,!0);u.sqlite3_result_text(d,L,Q,u.SQLITE_WASM_DEALLOC);break}case"object":if(q===null){u.sqlite3_result_null(d);break}else if(R.isBindableTypedArray(q)){const L=c.allocFromTypedArray(q);u.sqlite3_result_blob(d,L,q.byteLength,u.SQLITE_WASM_DEALLOC);break}default:S("Don't not how to handle this UDF result value:",typeof q,q)}}catch(L){u.sqlite3_result_error_js(d,L)}},u.sqlite3_column_js=function(d,q,L=!0){const Q=u.sqlite3_column_value(d,q);return Q===0?void 0:u.sqlite3_value_to_js(Q,L)};{const d=(function(q,L,Q){Q=u[Q],this.ptr?c.pokePtr(this.ptr,0):this.ptr=c.allocPtr();const F=Q(q,L,this.ptr);if(F)return O.toss(F,arguments[2]+"() failed with code "+F);const Y=c.peekPtr(this.ptr);return Y?u.sqlite3_value_to_js(Y,!0):void 0}).bind(r());u.sqlite3_preupdate_new_js=(q,L)=>d(q,L,"sqlite3_preupdate_new"),u.sqlite3_preupdate_old_js=(q,L)=>d(q,L,"sqlite3_preupdate_old"),u.sqlite3changeset_new_js=(q,L)=>d(q,L,"sqlite3changeset_new"),u.sqlite3changeset_old_js=(q,L)=>d(q,L,"sqlite3changeset_old")}u.sqlite3_js_retry_busy=function(d,q,L){for(let Q=1;Q<=d;++Q)try{L&&Q>1&&L(Q);const F=q();if(u.SQLITE_BUSY===F){if(Q===d)throw new O(F,["sqlite3_js_retry_busy() max retry attempts (",d,") reached."].join(""));continue}return F}catch(F){if(Q<d&&F instanceof O&&F.resultCode===u.SQLITE_BUSY)continue;throw F}};const J={WasmAllocError:A,SQLite3Error:O,capi:u,util:R,wasm:c,config:s,version:r(),client:void 0,asyncPostInit:(async function d(){if(d.isReady instanceof Promise)return d.isReady;let q=this.initializersAsync;delete this.initializersAsync;const L=async()=>(J.__isUnderTest||(delete J.util,delete J.StructBinder,delete J.opfs),J),Q=Y=>{throw s.error("an async sqlite3 initializer failed:",Y),Y};if(!q||!q.length)return d.isReady=L().catch(Q);q=q.map(Y=>Y instanceof Function?async Z=>Y(J):Y),q.push(L);let F=Promise.resolve(J);for(;q.length;)F=F.then(q.shift());return d.isReady=F.catch(Q)}).bind(i),scriptInfo:void 0};typeof o<"u"&&(J.__isUnderTest=!!o);try{i.initializers.forEach(d=>{d(J)})}catch(d){throw console.error("sqlite3 bootstrap initializer threw:",d),d}if(delete i.initializers,i.sqlite3=J,typeof e<"u"&&(e.debugModule("sqlite3ApiBootstrap() complete",J),J.scriptInfo=e),J.__isUnderTest){typeof t<"u"&&(J.config.emscripten=t);const d=J.scriptInfo?.instantiateWasm;d&&(J.wasm.module=d.module,J.wasm.instance=d.instance,J.wasm.imports=d.imports)}return delete globalThis.sqlite3ApiConfig,delete globalThis.sqlite3ApiBootstrap,delete i.defaultConfig,J.asyncPostInit().then(d=>(typeof e<"u"&&e.debugModule("sqlite3.asyncPostInit() complete",d),delete d.asyncPostInit,delete d.scriptInfo,delete d.emscripten,d))},globalThis.sqlite3ApiBootstrap.initializers=[],globalThis.sqlite3ApiBootstrap.initializersAsync=[],globalThis.sqlite3ApiBootstrap.defaultConfig=Object.create(null),globalThis.sqlite3ApiBootstrap.sqlite3=void 0,globalThis.sqlite3ApiBootstrap.initializers.push(function(i){i.version={libVersion:"3.53.4",libVersionNumber:3053004,sourceId:"2026-07-24 19:02:57 bf7c7f30031888f4e796e429ab3978879485813aaca6f641c7b33e4e09459bcc",downloadVersion:3530400,scm:{"sha3-256":"bf7c7f30031888f4e796e429ab3978879485813aaca6f641c7b33e4e09459bcc",branch:"branch-3.53",tags:"release version-3.53.4",datetime:"2026-07-24T19:02:57.525Z"}}}),globalThis.WhWasmUtilInstaller=function(n){n.bigIntEnabled===void 0&&(n.bigIntEnabled=!!globalThis.BigInt64Array);const r=(...l)=>{throw new Error(l.join(" "))};if(!n.pointerSize&&!n.pointerIR&&n.alloc&&n.dealloc){const l=n.alloc(1);n.pointerSize=typeof l=="bigint"?8:4,n.dealloc(l)}n.pointerSize&&!n.pointerIR&&(n.pointerIR=n.pointerSize===4?"i32":"i64");const s=n.pointerIR??="i32",u=n.pointerSize??=s==="i32"?4:s==="i64"?8:0;delete n.pointerSize,delete n.pointerIR,s!=="i32"&&s!=="i64"?r("Invalid pointerIR:",s):u!==8&&u!==4&&r("Invalid pointerSize:",u);const c=n.bigIntEnabled?l=>BigInt(l||0):l=>r("BigInt support is disabled in this build."),z=u===4?l=>Number(l||0):c,O=z(0),S=function(...l){let _=z(0);for(const p of l)_+=z(p);return _};{const l=Object.create(null);Object.defineProperty(n,"ptr",{enumerable:!0,get:()=>l,set:()=>r("The ptr property is read-only.")}),(function _(p,D){return Object.defineProperty(l,p,{enumerable:!0,get:()=>D,set:()=>r("ptr["+p+"] is read-only.")}),_})("null",O)("size",u)("ir",s)("coerce",z)("add",S)("addn",s===4?S:(..._)=>Number(S(..._)))}n.exports||Object.defineProperty(n,"exports",{enumerable:!0,configurable:!0,get:()=>n.instance?.exports});const w=Object.create(null);w.heapSize=0,w.memory=null,w.freeFuncIndexes=[],w.scopedAlloc=[],w.scopedAlloc.pushPtr=l=>(w.scopedAlloc[w.scopedAlloc.length-1].push(l),l),w.utf8Decoder=new TextDecoder,w.utf8Encoder=new TextEncoder("utf-8"),n.sizeofIR=l=>{switch(l){case"i8":return 1;case"i16":return 2;case"i32":case"f32":case"float":return 4;case"i64":case"f64":case"double":return 8;case"*":return u;default:return(""+l).endsWith("*")?u:void 0}};const P=function(){if(!w.memory)w.memory=n.memory instanceof WebAssembly.Memory?n.memory:n.exports.memory;else if(w.heapSize===w.memory.buffer.byteLength)return w;const l=w.memory.buffer;return w.HEAP8=new Int8Array(l),w.HEAP8U=new Uint8Array(l),w.HEAP16=new Int16Array(l),w.HEAP16U=new Uint16Array(l),w.HEAP32=new Int32Array(l),w.HEAP32U=new Uint32Array(l),w.HEAP32F=new Float32Array(l),w.HEAP64F=new Float64Array(l),n.bigIntEnabled&&(typeof BigInt64Array<"u"?(w.HEAP64=new BigInt64Array(l),w.HEAP64U=new BigUint64Array(l)):r("BigInt support is enabled, but the BigInt64Array type is missing.")),w.heapSize=l.byteLength,w};n.heap8=()=>P().HEAP8,n.heap8u=()=>P().HEAP8U,n.heap16=()=>P().HEAP16,n.heap16u=()=>P().HEAP16U,n.heap32=()=>P().HEAP32,n.heap32u=()=>P().HEAP32U,n.heapForSize=function(l,_=!0){const p=w.memory&&w.heapSize===w.memory.buffer.byteLength?w:P();switch(l){case Int8Array:return p.HEAP8;case Uint8Array:return p.HEAP8U;case Int16Array:return p.HEAP16;case Uint16Array:return p.HEAP16U;case Int32Array:return p.HEAP32;case Uint32Array:return p.HEAP32U;case 8:return _?p.HEAP8U:p.HEAP8;case 16:return _?p.HEAP16U:p.HEAP16;case 32:return _?p.HEAP32U:p.HEAP32;case 64:if(p.HEAP64)return _?p.HEAP64U:p.HEAP64;break;default:if(n.bigIntEnabled){if(l===globalThis.BigUint64Array)return p.HEAP64U;if(l===globalThis.BigInt64Array)return p.HEAP64;break}}r("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")};const N=n.functionTable;delete n.functionTable,n.functionTable=N?()=>N:()=>n.exports.__indirect_function_table,n.functionEntry=function(l){const _=n.functionTable();return l<_.length?_.get(z(l)):void 0},n.jsFuncToWasm=function l(_,p){if(l._||(l._={sigTypes:Object.assign(Object.create(null),{i:"i32",p:s,P:s,s,j:"i64",f:"f32",d:"f64"}),typeCodes:Object.assign(Object.create(null),{f64:124,f32:125,i64:126,i32:127}),uleb128Encode:(h,E,V)=>{V<128?h[E](V):h[E](V%128|128,V>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:h=>{const E=l._.rxJSig.exec(h);return E?E[2]:h.substr(1)},letterType:h=>l._.sigTypes[h]||r("Invalid signature letter:",h),pushSigType:(h,E)=>h.push(l._.typeCodes[l._.letterType(E)])}),typeof _=="string"){const h=p;p=_,_=h}const D=l._,B=D.sigParams(p),C=[1,96];D.uleb128Encode(C,"push",B.length);for(const h of B)D.pushSigType(C,h);return p[0]==="v"?C.push(0):(C.push(1),D.pushSigType(C,p[0])),D.uleb128Encode(C,"unshift",C.length),C.unshift(0,97,115,109,1,0,0,0,1),C.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array(C)),{e:{f:_}}).exports.f};const U=function(_,p,D){if(D&&!w.scopedAlloc.length&&r("No scopedAllocPush() scope is active."),typeof _=="string"){const E=p;p=_,_=E}(typeof p!="string"||!(_ instanceof Function))&&r("Invalid arguments: expecting (function,signature) or (signature,function).");const B=n.functionTable(),C=z(B.length);let h;for(;(h=w.freeFuncIndexes.pop())&&B.get(h);){h=null;continue}h||(h=z(C),B.grow(z(1)));try{return B.set(h,_),D&&w.scopedAlloc.pushPtr(h),h}catch(E){if(!(E instanceof TypeError))throw h===C&&w.freeFuncIndexes.push(C),E}try{const E=n.jsFuncToWasm(_,p);B.set(h,E),D&&w.scopedAlloc.pushPtr(h)}catch(E){throw h===C&&w.freeFuncIndexes.push(C),E}return h};n.installFunction=(l,_)=>U(l,_,!1),n.scopedInstallFunction=(l,_)=>U(l,_,!0),n.uninstallFunction=function(l){if(!l&&O!==l)return;const _=n.functionTable();w.freeFuncIndexes.push(l);const p=_.get(l);return _.set(l,null),p},n.peek=function(_,p="i8"){p.endsWith("*")&&(p=s);const D=w.memory&&w.heapSize===w.memory.buffer.byteLength?w:P(),B=Array.isArray(_)?[]:void 0;let C;do{switch(B&&(_=arguments[0].shift()),p){case"i1":case"i8":C=D.HEAP8[Number(_)>>0];break;case"i16":C=D.HEAP16[Number(_)>>1];break;case"i32":C=D.HEAP32[Number(_)>>2];break;case"float":case"f32":C=D.HEAP32F[Number(_)>>2];break;case"double":case"f64":C=Number(D.HEAP64F[Number(_)>>3]);break;case"i64":if(D.HEAP64){C=c(D.HEAP64[Number(_)>>3]);break}default:r("Invalid type for peek():",p)}B&&B.push(C)}while(B&&arguments[0].length);return B||C},n.poke=function(l,_,p="i8"){p.endsWith("*")&&(p=s);const D=w.memory&&w.heapSize===w.memory.buffer.byteLength?w:P();for(const B of Array.isArray(l)?l:[l])switch(p){case"i1":case"i8":D.HEAP8[Number(B)>>0]=_;continue;case"i16":D.HEAP16[Number(B)>>1]=_;continue;case"i32":D.HEAP32[Number(B)>>2]=_;continue;case"float":case"f32":D.HEAP32F[Number(B)>>2]=_;continue;case"double":case"f64":D.HEAP64F[Number(B)>>3]=_;continue;case"i64":if(D.HEAP64){D.HEAP64[Number(B)>>3]=c(_);continue}default:r("Invalid type for poke(): "+p)}return this},n.peekPtr=(...l)=>n.peek(l.length===1?l[0]:l,s),n.pokePtr=(l,_=0)=>n.poke(l,_,s),n.peek8=(...l)=>n.peek(l.length===1?l[0]:l,"i8"),n.poke8=(l,_)=>n.poke(l,_,"i8"),n.peek16=(...l)=>n.peek(l.length===1?l[0]:l,"i16"),n.poke16=(l,_)=>n.poke(l,_,"i16"),n.peek32=(...l)=>n.peek(l.length===1?l[0]:l,"i32"),n.poke32=(l,_)=>n.poke(l,_,"i32"),n.peek64=(...l)=>n.peek(l.length===1?l[0]:l,"i64"),n.poke64=(l,_)=>n.poke(l,_,"i64"),n.peek32f=(...l)=>n.peek(l.length===1?l[0]:l,"f32"),n.poke32f=(l,_)=>n.poke(l,_,"f32"),n.peek64f=(...l)=>n.peek(l.length===1?l[0]:l,"f64"),n.poke64f=(l,_)=>n.poke(l,_,"f64"),n.getMemValue=n.peek,n.getPtrValue=n.peekPtr,n.setMemValue=n.poke,n.setPtrValue=n.pokePtr,n.isPtr32=l=>typeof l=="number"&&l>=0&&l===(l|0),n.isPtr64=l=>typeof l=="bigint"?l>=0:n.isPtr32(l),n.isPtr=u===4?n.isPtr32:n.isPtr64,n.cstrlen=function(l){if(!l||!n.isPtr(l))return null;l=Number(l);const _=P().HEAP8U;let p=l;for(;_[p]!==0;++p);return p-l};const y=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,m=l=>l.buffer instanceof y;n.isSharedTypedArray=m;const j=(l,_,p)=>(u===8&&(typeof _=="bigint"&&(_=Number(_)),typeof p=="bigint"&&(p=Number(p))),m(l)?l.slice(_,p):l.subarray(_,p));n.typedArrayPart=j;const W=(l,_,p)=>w.utf8Decoder.decode(j(l,_,p));n.typedArrayToString=W,n.cstrToJs=function(l){const _=n.cstrlen(l);return _?W(P().HEAP8U,Number(l),Number(l)+_):_===null?_:""},n.jstrlen=function(l){if(typeof l!="string")return null;const _=l.length;let p=0;for(let D=0;D<_;++D){let B=l.charCodeAt(D);B>=55296&&B<=57343&&(B=65536+((B&1023)<<10)|l.charCodeAt(++D)&1023),B<=127?++p:B<=2047?p+=2:B<=65535?p+=3:p+=4}return p},n.jstrcpy=function(l,_,p=0,D=-1,B=!0){if((!_||!(_ instanceof Int8Array)&&!(_ instanceof Uint8Array))&&r("jstrcpy() target must be an Int8Array or Uint8Array."),D=Number(D),p=Number(p),D<0&&(D=_.length-p),!(D>0)||!(p>=0))return 0;let C=0,h=l.length;const E=p,V=p+D-(B?1:0);for(;C<h&&p<V;++C){let G=l.charCodeAt(C);if(G>=55296&&G<=57343&&(G=65536+((G&1023)<<10)|l.charCodeAt(++C)&1023),G<=127){if(p>=V)break;_[p++]=G}else if(G<=2047){if(p+1>=V)break;_[p++]=192|G>>6,_[p++]=128|G&63}else if(G<=65535){if(p+2>=V)break;_[p++]=224|G>>12,_[p++]=128|G>>6&63,_[p++]=128|G&63}else{if(p+3>=V)break;_[p++]=240|G>>18,_[p++]=128|G>>12&63,_[p++]=128|G>>6&63,_[p++]=128|G&63}}return B&&(_[p++]=0),p-E},n.cstrncpy=function(l,_,p){if((!l||!_)&&r("cstrncpy() does not accept NULL strings."),p<0)p=n.cstrlen(strPtr)+1;else if(!(p>0))return 0;const D=n.heap8u();let B=0,C;const h=Number(l),E=Number(_);for(;B<p&&(C=D[E+B]);++B)D[h+B]=C;return B<p&&(D[h+B++]=0),B},n.jstrToUintArray=(l,_=!1)=>w.utf8Encoder.encode(_?l+"\0":l);const A=(l,_)=>{(!(l.alloc instanceof Function)||!(l.dealloc instanceof Function))&&r("Object is missing alloc() and/or dealloc() function(s)","required by",_+"().")},R=function(l,_,p,D){if(A(n,D),typeof l!="string")return null;const B=w.utf8Encoder.encode(l),C=p(B.length+1);let h=C;try{const E=P().HEAP8U;return E.set(B,Number(C)),E[S(C,B.length)]=0,h=O,_?[C,B.length]:C}finally{h&&n.dealloc(h)}};n.allocCString=(l,_=!1)=>R(l,_,n.alloc,"allocCString()"),n.scopedAllocPush=function(){A(n,"scopedAllocPush");const l=[];return w.scopedAlloc.push(l),l},n.scopedAllocPop=function(l){A(n,"scopedAllocPop");const _=arguments.length?w.scopedAlloc.indexOf(l):w.scopedAlloc.length-1;_<0&&r("Invalid state object for scopedAllocPop()."),arguments.length===0&&(l=w.scopedAlloc[_]),w.scopedAlloc.splice(_,1);for(let p;p=l.pop();)n.functionEntry(p)?n.uninstallFunction(p):n.dealloc(p)},n.scopedAlloc=function(l){w.scopedAlloc.length||r("No scopedAllocPush() scope is active.");const _=z(n.alloc(l));return w.scopedAlloc.pushPtr(_)},Object.defineProperty(n.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>w.scopedAlloc.length,set:()=>r("The 'active' property is read-only.")}),n.scopedAllocCString=(l,_=!1)=>R(l,_,n.scopedAlloc,"scopedAllocCString()");const J=function(l,_){const p=n[l?"scopedAlloc":"alloc"]((_.length+1)*n.ptr.size);let D=0;return _.forEach(B=>{n.pokePtr(S(p,n.ptr.size*D++),n[l?"scopedAllocCString":"allocCString"](""+B))}),n.pokePtr(S(p,n.ptr.size*D),0),p};n.scopedAllocMainArgv=l=>J(!0,l),n.allocMainArgv=l=>J(!1,l),n.cArgvToJs=(l,_)=>{const p=[];for(let D=0;D<l;++D){const B=n.peekPtr(S(_,n.ptr.size*D));p.push(B?n.cstrToJs(B):null)}return p},n.scopedAllocCall=function(l){n.scopedAllocPush();try{return l()}finally{n.scopedAllocPop()}};const d=function(l,_,p){A(n,p);const D=_?"i64":s;let B=n[p](l*(_?8:u));if(n.poke(B,0,D),l===1)return B;const C=[B];for(let h=1;h<l;++h)B=S(B,_?8:u),C[h]=B,n.poke(B,0,D);return C};n.allocPtr=(l=1,_=!0)=>d(l,_,"alloc"),n.scopedAllocPtr=(l=1,_=!0)=>d(l,_,"scopedAlloc"),n.xGet=function(l){return n.exports[l]||r("Cannot find exported symbol:",l)};const q=(l,_)=>r(l+"() requires",_,"argument(s).");n.xCall=function(l,..._){const p=l instanceof Function?l:n.xGet(l);return p instanceof Function||r("Exported symbol",l,"is not a function."),p.length!==_.length&&q(p===l?p.name:l,p.length),arguments.length===2&&Array.isArray(arguments[1])?p.apply(null,arguments[1]):p.apply(null,_)},w.xWrap=Object.create(null),w.xWrap.convert=Object.create(null),w.xWrap.convert.arg=new Map,w.xWrap.convert.result=new Map;const L=w.xWrap.convert.arg,Q=w.xWrap.convert.result,F=z;L.set("i64",c).set("i32",l=>l|0).set("i16",l=>(l|0)&65535).set("i8",l=>(l|0)&255).set("f32",l=>Number(l).valueOf()).set("float",L.get("f32")).set("f64",L.get("f32")).set("double",L.get("f64")).set("int",L.get("i32")).set("null",l=>l).set(null,L.get("null")).set("**",F).set("*",F),Q.set("*",F).set("pointer",F).set("number",l=>Number(l)).set("void",l=>{}).set(void 0,Q.get("void")).set("null",l=>l).set(null,Q.get("null"));for(const l of["i8","i16","i32","i64","int","f32","float","f64","double"])L.set(l+"*",F),Q.set(l+"*",F),Q.set(l,L.get(l)||r("Maintenance required: missing arg converter for",l));const Y=l=>typeof l=="string"?n.scopedAllocCString(l):z(l);L.set("string",Y).set("utf8",Y),Q.set("string",l=>n.cstrToJs(l)).set("utf8",Q.get("string")).set("string:dealloc",l=>{try{return l?n.cstrToJs(l):null}finally{n.dealloc(l)}}).set("utf8:dealloc",Q.get("string:dealloc")).set("json",l=>JSON.parse(n.cstrToJs(l))).set("json:dealloc",l=>{try{return l?JSON.parse(n.cstrToJs(l)):null}finally{n.dealloc(l)}});const Z=class{constructor(l){this.name=l.name||"unnamed adapter"}convertArg(l,_,p){r("AbstractArgAdapter must be subclassed.")}};L.FuncPtrAdapter=class Be extends Z{constructor(_){super(_),L.FuncPtrAdapter.warnOnUse&&console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",_),this.name=_.name||"unnamed",this.signature=_.signature,_.contextKey instanceof Function&&(this.contextKey=_.contextKey,_.bindScope||(_.bindScope="context")),this.bindScope=_.bindScope||r("FuncPtrAdapter options requires a bindScope (explicit or implied)."),Be.bindScopes.indexOf(_.bindScope)<0&&r("Invalid options.bindScope ("+_.bindMod+") for FuncPtrAdapter. Expecting one of: ("+Be.bindScopes.join(", ")+")"),this.isTransient=this.bindScope==="transient",this.isContext=this.bindScope==="context",this.isPermanent=this.bindScope==="permanent",this.singleton=this.bindScope==="singleton"?[]:void 0,this.callProxy=_.callProxy instanceof Function?_.callProxy:void 0}contextKey(_,p){return this}contextMap(_){const p=this.__cmap||(this.__cmap=new Map);let D=p.get(_);return D===void 0&&p.set(_,D=[]),D}convertArg(_,p,D){let B=this.singleton;if(!B&&this.isContext&&(B=this.contextMap(this.contextKey(p,D))),B&&B.length===2&&B[0]===_)return B[1];if(_ instanceof Function){this.callProxy&&(_=this.callProxy(_));const C=U(_,this.signature,this.isTransient);if(Be.debugFuncInstall&&Be.debugOut("FuncPtrAdapter installed",this,this.contextKey(p,D),"@"+C,_),B){if(B[1]){Be.debugFuncInstall&&Be.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(p,D),"@"+B[1],_);try{w.scopedAlloc.pushPtr(B[1])}catch{}}B[0]=arguments[0]||O,B[1]=C}return C}else if(n.isPtr(_)||_===null||_===void 0){if(B&&B[1]&&B[1]!==_){Be.debugFuncInstall&&Be.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(p,D),"@"+B[1],_);try{w.scopedAlloc.pushPtr(B[1])}catch{}B[0]=B[1]=_||O}return _||O}else throw new TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},L.FuncPtrAdapter.warnOnUse=!1,L.FuncPtrAdapter.debugFuncInstall=!1,L.FuncPtrAdapter.debugOut=console.debug.bind(console),L.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];const ee=l=>L.get(l)||r("Argument adapter not found:",l),g=l=>Q.get(l)||r("Result adapter not found:",l);w.xWrap.convertArg=(l,..._)=>ee(l)(..._),w.xWrap.convertArgNoCheck=(l,..._)=>L.get(l)(..._),w.xWrap.convertResult=(l,_)=>l===null?_:l?g(l)(_):void 0,w.xWrap.convertResultNoCheck=(l,_)=>l===null?_:l?Q.get(l)(_):void 0,n.xWrap=function l(_,p,...D){arguments.length===3&&Array.isArray(arguments[2])&&(D=arguments[2]),n.isPtr(_)&&(_=n.functionEntry(_)||r("Function pointer not found in WASM function table."));const B=_ instanceof Function,C=B?_:n.xGet(_);if(B&&(_=C.name||"unnamed function"),D.length!==C.length&&q(_,C.length),C.length===0&&(p===null||p==="null"))return C;g(p);for(const E of D)E instanceof Z?L.set(E,(...V)=>E.convertArg(...V)):ee(E);const h=w.xWrap;return C.length===0?(...E)=>E.length?q(_,C.length):h.convertResult(p,C.call(null)):function(...E){E.length!==C.length&&q(_,C.length);const V=n.scopedAllocPush();try{let G=0;for(l.debug&&console.debug("xWrap() preparing: resultType ",p,"xf",C,"argTypes",D,"args",E);G<E.length;++G)E[G]=h.convertArgNoCheck(D[G],E[G],E,G);return l.debug&&console.debug("xWrap() calling: resultType ",p,"xf",C,"argTypes",D,"args",E),h.convertResultNoCheck(p,C.apply(null,E))}finally{n.scopedAllocPop(V)}}};const T=function(l,_,p,D,B,C){if(typeof p=="string"){if(_===1)return C.get(p);if(_===2){if(D)D instanceof Function||r(B,"requires a function argument.");else return C.delete(p),l;return C.set(p,D),l}}r("Invalid arguments to",B)};return n.xWrap.resultAdapter=function l(_,p){return T(l,arguments.length,_,p,"resultAdapter()",Q)},n.xWrap.argAdapter=function l(_,p){return T(l,arguments.length,_,p,"argAdapter()",L)},n.xWrap.FuncPtrAdapter=L.FuncPtrAdapter,n.xCallWrapped=function(l,_,p,...D){return Array.isArray(arguments[3])&&(D=arguments[3]),n.xWrap(l,_,p||[]).apply(null,D||[])},n.xWrap.testConvertArg=w.xWrap.convertArg,n.xWrap.testConvertResult=w.xWrap.convertResult,n},globalThis.WhWasmUtilInstaller.yawl=(function(n){const r=()=>fetch(n.uri,{credentials:"same-origin"}),s=this,u=function(c){if(n.wasmUtilTarget){const b=(...O)=>{throw new Error(O.join(" "))},z=n.wasmUtilTarget;if(z.module=c.module,z.instance=c.instance,z.instance.exports.memory||(z.memory=n?.imports?.env?.memory||b("Missing 'memory' object!")),!z.alloc&&c.instance.exports.malloc){const O=c.instance.exports;z.alloc=function(S){return O.malloc(S)||b("Allocation of",S,"bytes failed.")},z.dealloc=function(S){S&&O.free(S)}}s(z)}return c.config=n,n.onload&&n.onload(c),c};return WebAssembly.instantiateStreaming?()=>WebAssembly.instantiateStreaming(r(),n.imports||{}).then(u):()=>r().then(c=>c.arrayBuffer()).then(c=>WebAssembly.instantiate(c,n.imports||{})).then(u)}).bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function i(n){const r=(...I)=>{throw new Error(I.join(" "))};{let I=n.heap;I instanceof WebAssembly.Memory?I=(function(){return new Uint8Array(this.buffer)}).bind(I):I instanceof Function||r("config.heap must be WebAssembly.Memory instance or","a function which returns one."),n.heap=I}["alloc","dealloc"].forEach(function(I){n[I]instanceof Function||r("Config option '"+I+"' must be a function.")});const s=i,u=n.heap,c=n.alloc,b=n.dealloc;n.realloc;const z=n.log||console.debug.bind(console),O=n.memberPrefix||"",S=n.memberSuffix||"",w=globalThis.BigInt,P=globalThis.BigInt64Array,N=n.bigIntEnabled??!!P;let U;const y=n.pointerSize||n.ptrSize||(typeof(U=c(1))=="bigint"?8:4),m=n.pointerIR||n.ptrIR||(y===4?"i32":"i64");U&&(b(U),U=void 0),y!==4&&y!==8&&r("Invalid pointer size:",y),m!=="i32"&&m!=="i64"&&r("Invalid pointer representation:",m);const j=N&&w?I=>w(I||0):I=>r("BigInt support is disabled in this build."),W=m=="i32"?Number:j,A=W(0),R=function(...I){let H=A;for(let X=0;X<I.length;++X)H+=W(I[X]);return H},J=function(...I){return R(this.pointer,...I)};s.debugFlags||(s.__makeDebugFlags=function(I=null){I&&I.__flags&&(I=I.__flags);const H=function X(te){return arguments.length===0?X.__flags:(te<0?(delete X.__flags.getter,delete X.__flags.setter,delete X.__flags.alloc,delete X.__flags.dealloc):(X.__flags.getter=(1&te)!==0,X.__flags.setter=(2&te)!==0,X.__flags.alloc=(4&te)!==0,X.__flags.dealloc=(8&te)!==0),X._flags)};return Object.defineProperty(H,"__flags",{iterable:!1,writable:!1,value:Object.create(I)}),I||H(0),H},s.debugFlags=s.__makeDebugFlags());const d=!0,q=I=>I[1]==="(",L=I=>I==="p"||I==="P"||I==="s",Q=I=>I==="P",F=I=>I?q(I)?"p":I[0]:void 0,Y=function(I){switch(F(I)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return m;case"j":return"i64";case"f":return"float";case"d":return"double"}r("Unhandled signature IR:",I)},Z=function(I){switch(F(I)){case"c":case"C":return 1;case"i":return 4;case"p":case"P":case"s":return y;case"j":return 8;case"f":return 4;case"d":return 8}r("Unhandled signature sizeof:",I)},ee=P?()=>!0:()=>r("BigInt64Array is not available."),g=function(I){switch(F(I)){case"p":case"P":case"s":switch(y){case 4:return"getInt32";case 8:return ee()&&"getBigInt64"}break;case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return ee()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}r("Unhandled DataView getter for signature:",I)},T=function(I){switch(F(I)){case"p":case"P":case"s":switch(y){case 4:return"setInt32";case 8:return ee()&&"setBigInt64"}break;case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return ee()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}r("Unhandled DataView setter for signature:",I)},l=function(I){switch(F(I)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return j;case"p":case"P":case"s":switch(y){case 4:return Number;case 8:return j}}r("Unhandled DataView set wrapper for signature:",I)},_=(I,H)=>I+"::"+H,p=function(I,H){return()=>r(_(I,H),"is read-only.")},D=function I(H,X=!0){let te=I.map.get(H);return!te&&X&&I.map.set(H,te=I.create(H)),te};D.map=new WeakMap,D.create=I=>Object.assign(Object.create(null),{o:I,p:void 0,ownsPointer:!1,zod:!1,xb:0});const B=I=>D.map.delete(I),C=I=>typeof I=="number"&&I===(I|0)&&I>=0,E=y===4?C:I=>typeof I=="bigint"&&I>=0||C(I),V=I=>E(I)&&I>0,G=function(I,H,X){const te=D(H,!1);if(te){if(B(H),!X&&!(X=te.p)){console.warn("Cannot(?) happen: __freeStruct() found no instanceInfo");return}if(Array.isArray(H.ondispose)){let ae;for(;ae=H.ondispose.pop();)try{ae instanceof Function?ae.call(H):ae instanceof Pe?ae.dispose():E(ae)&&b(ae)}catch(be){console.warn("ondispose() for",I.structName,"@",X,"threw. NOT propagating it.",be)}}else if(H.ondispose instanceof Function)try{H.ondispose()}catch(ae){console.warn("ondispose() for",I.structName,"@",X,"threw. NOT propagating it.",ae)}delete H.ondispose,I.debugFlags.__flags.dealloc&&z("debug.dealloc:",te.ownsPointer?"":"EXTERNAL",I.structName,"instance:",I.structInfo.sizeof,"bytes @"+X),te.ownsPointer&&((te.zod||I.structInfo.zeroOnDispose)&&u().fill(0,Number(X),Number(X)+I.structInfo.sizeof+te.xb),b(X))}},re=()=>({configurable:!1,writable:!1,iterable:!1}),ne=I=>({...re(),value:I}),de=function(H,X,te){let ae;const be=ge=>{V(ge)||r("Invalid pointer value",arguments[0],"for",H.structName,"constructor.")};arguments.length>=3?te&&typeof te=="object"?(ae=te,te=ae?.wrap):(be(te),ae={wrap:te}):ae={};const Te=!te;let Fe=0,Le=!1;if(te)be(te),Le=!!ae?.takeOwnership;else{const ge=ae?.extraBytes??0;(ge<0||ge!==(ge|0))&&r("Invalid extraBytes value:",ae?.extraBytes),Fe=H.structInfo.sizeof+ge,te=c(Fe)||r("Allocation of",H.structName,"structure failed."),Le=!0}try{ae?.debugFlags&&X.debugFlags(ae.debugFlags),H.debugFlags.__flags.alloc&&z("debug.alloc:",Te?"":"EXTERNAL",H.structName,"instance:",H.structInfo.sizeof,"bytes @"+te),Te&&u().fill(0,Number(te),Number(te)+Fe);const ge=D(X);ge.p=te,ge.ownsPointer=Le,ge.xb=Fe?Fe-H.structInfo.sizeof:0,ge.zod=!!ae?.zeroOnDispose,ae?.ondispose&&ae.ondispose!==te&&X.addOnDispose(ae.ondispose)}catch(ge){throw G(H,X,te),ge}},ue=function I(H){return I.rxSig1??=/^[ipPsjfdcC]$/,I.rxSig2??=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/,I.rxSig1.test(H)||I.rxSig2.test(H)},Ae=(function(I){let H=this.get(I);return H||(H=[Object.create(null),Object.create(null),Object.create(null)],this.set(I,H)),H}).bind(new WeakMap),Oe=function(I,H,X,te){const ae=Ae(I)[H];return arguments.length===3?ae[X]:te?ae[X]=te:delete ae[X]},Je=function(I,...H){return Oe(this,0,I,...H)},ht=function(I,H){ue(H)&&r(I,"(",H,") collides with a data type signature.")},x=function(I,...H){return ht("Setter adaptor",I),Oe(this,1,I,...H)},M=function(I,...H){return ht("Struct adaptor",I),Oe(this,2,I,...H)},$=function(I,H){const X=typeof H=="string"?Oe(I,2,H):H;return typeof X!="object"&&r("Invalid struct mapping object. Arg =",H,JSON.stringify(X)),X},ie=ne(I=>O+I+S),se=function(I,H,X=!0){let te=I.members[H];if(!te&&(O||S)){for(const ae of Object.values(I.members))if(ae.key===H){te=ae;break}!te&&X&&r(_(I.name||I.structName,H),"is not a mapped struct member.")}return te},oe=function I(H,X,te=!1){I._||(I._=be=>be.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));const ae=se(H.structInfo,X,!0);return te?I._(ae.signature):ae.signature},le=ne(function(){const I=[];for(const H of Object.keys(this.structInfo.members))I.push(this.memberKey(H));return I}),pe=new TextDecoder("utf-8"),we=new TextEncoder,he=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,me=function(I,H,X){return y===8&&(H=Number(H),X=Number(X)),pe.decode(I.buffer instanceof he?I.slice(H,X):I.subarray(H,X))},Ie=function(I,H,X=!1){const te=se(I.structInfo,H,X);return te&&te.signature.length===1&&te.signature[0]==="s"?te:!1},De=function(I){I.signature!=="s"&&r("Invalid member type signature for C-string value:",JSON.stringify(I))},Qe=function(H,X){const te=se(H.structInfo,X,!0);De(te);const ae=H[te.key];if(!ae)return null;let be=ae;const Te=u();for(;Te[be]!==0;++be);return ae===be?"":me(Te,ae,be)},tt=function(I,...H){I.ondispose?Array.isArray(I.ondispose)||(I.ondispose=[I.ondispose]):I.ondispose=[],I.ondispose.push(...H)},Xe=function(I){const H=we.encode(I),X=c(H.length+1);X||r("Allocation error while duplicating string:",I);const te=u();return te.set(H,Number(X)),te[R(X,H.length)]=0,X},ct=function(I,H,X){const te=se(I.structInfo,H,!0);De(te);const ae=Xe(X);return I[te.key]=ae,tt(I,ae),I},Pe=function(H,X){arguments[2]!==ne&&r("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:ne(H),structInfo:ne(X)})};Pe.prototype=Object.create(null,{dispose:ne(function(){G(this.constructor,this)}),lookupMember:ne(function(I,H=!0){return se(this.structInfo,I,H)}),memberToJsString:ne(function(I){return Qe(this,I)}),memberIsString:ne(function(I,H=!0){return Ie(this,I,H)}),memberKey:ie,memberKeys:le,memberSignature:ne(function(I,H=!1){return oe(this,I,H)}),memoryDump:ne(function(){const I=this.pointer;return I?new Uint8Array(u().slice(Number(I),Number(I)+this.structInfo.sizeof)):null}),extraBytes:{configurable:!1,enumerable:!1,get:function(){return D(this,!1)?.xb??0}},zeroOnDispose:{configurable:!1,enumerable:!1,get:function(){return D(this,!1)?.zod??!!this.structInfo.zeroOnDispose}},pointer:{configurable:!1,enumerable:!1,get:function(){return D(this,!1)?.p},set:()=>r("Cannot assign the 'pointer' property of a struct.")},setMemberCString:ne(function(I,H){return ct(this,I,H)})}),Object.assign(Pe.prototype,{addOnDispose:function(...I){return tt(this,...I),this}}),Object.defineProperties(Pe,{allocCString:ne(Xe),isA:ne(I=>I instanceof Pe),hasExternalPointer:ne(I=>{const H=D(I,!1);return!!(H?.p&&!H?.ownsPointer)}),memberKey:ie});const mt=function(I){return I.get||(I.adaptGet?Ce.adaptGet(I.adaptGet):void 0)},Kt=function(I){return I.set||(I.adaptSet?Ce.adaptSet(I.adaptSet):void 0)},hr=function I(H,X,te){const ae=I.innerStructs??=new Map,be=H.memberKey(X);te.signature!==void 0&&r("'signature' cannot be used on an embedded struct (",H.structName,".",be,")."),Kt(te)&&r("'set' and 'adaptSet' are not permitted for nested struct members."),te.structName??=H.structName+"::"+X,te.key=be,te.name=X,te.constructor=this.call(this,te.structName,te);const Te=mt(te),Fe=Object.assign(Object.create(null),{configurable:!1,enumerable:!1,set:p(H.structName,be),get:function(){const Le=this.debugFlags.__flags,ge=this.pointer,ke=ge+"."+be;let ce=ae.get(ke);return Le.getter&&z("debug.getter: k =",ke),ce||(ce=new te.constructor(R(ge,te.offset)),ae.set(ke,ce),this.addOnDispose(()=>ce.dispose()),ce.addOnDispose(()=>ae.delete(ke))),Te&&(ce=Te.apply(this,[ce,be])),Le.getter&&z("debug.getter: result =",ce),ce}});Object.defineProperty(H.prototype,be,Fe)},mr=function I(H,X,te){if(te=$(this,te),te.members)return hr.call(this,H,X,te);if(!I.cache){I.cache={getters:{},setters:{},sw:{}};const ke=["i","c","C","p","P","s","f","d","v()"];N&&ke.push("j"),ke.forEach(function(ce){I.cache.getters[ce]=g(ce),I.cache.setters[ce]=T(ce),I.cache.sw[ce]=l(ce)}),I.sigCheck=function(ce,Ee,gt,Xt){Object.prototype.hasOwnProperty.call(ce,gt)&&r(ce.structName,"already has a property named",gt+"."),ue(Xt)||r("Malformed signature for",_(ce.structName,Ee)+":",Xt)}}const ae=H.memberKey(X);I.sigCheck(H.prototype,X,ae,te.signature),te.key=ae,te.name=X;const be=F(te.signature),Te=_(H.structName,ae),Fe=H.debugFlags.__flags,Le=mt(te),ge=Object.create(null);if(ge.configurable=!1,ge.enumerable=!1,ge.get=function(){Fe.getter&&z("debug.getter:",I.cache.getters[be],"for",Y(be),Te,"@",this.pointer,"+",te.offset,"sz",te.sizeof);let ke=new DataView(u().buffer,Number(this.pointer)+te.offset,te.sizeof)[I.cache.getters[be]](0,d);return Le&&(ke=Le.apply(this,[ae,ke])),Fe.getter&&z("debug.getter:",Te,"result =",ke),ke},te.readOnly)ge.set=p(H.prototype.structName,ae);else{const ke=Kt(te);ge.set=function(ce){Fe.setter&&z("debug.setter:",I.cache.setters[be],"for",Y(be),Te,"@",this.pointer,"+",te.offset,"sz",te.sizeof,ce),this.pointer||r("Cannot set native property on a disposed",this.structName,"instance."),ke&&(ce=ke.apply(this,[ae,ce])),ce==null?ce=A:L(te.signature)&&!E(ce)&&(Q(te.signature)&&ce instanceof Pe?(ce=ce.pointer||A,Fe.setter&&z("debug.setter:",Te,"resolved to",ce)):r("Invalid value for pointer-type",Te+".")),new DataView(u().buffer,Number(this.pointer)+te.offset,te.sizeof)[I.cache.setters[be]](0,I.cache.sw[be](ce),d)}}Object.defineProperty(H.prototype,ae,ge)},Jt=function I(H,X,te=Object.create(null)){const ae=function ce(Ee){this instanceof ce||r("The",H,"constructor may only be called via 'new'."),de(ce,this,...arguments)},be=this,Te=ce=>typeof ce=="string"&&ue(ce)?{signature:ce}:$(be,ce);arguments.length===1?(X=Te(H),H=X.structName||X.name):arguments.length===2?(X=Te(X),X.name??=H):X=Te(X),H??=X.structName,H??=te.structName,H||r("One of 'name' or 'structName' are required."),X.adapt&&(Object.keys(X.adapt.struct||{}).forEach(ce=>{M.call(I,ce,X.adapt.struct[ce])}),Object.keys(X.adapt.set||{}).forEach(ce=>{x.call(I,ce,X.adapt.set[ce])}),Object.keys(X.adapt.get||{}).forEach(ce=>{Je.call(I,ce,X.adapt.get[ce])})),!X.members&&!X.sizeof&&(X.sizeof=Z(X.signature));const Fe=ne(s.__makeDebugFlags(Ce.debugFlags));Object.defineProperties(ae,{debugFlags:Fe,isA:ne(ce=>ce instanceof ae),memberKey:ie,memberKeys:le,structInfo:ne(X),structName:ne(H),ptrAdd:ne(R)}),ae.prototype=new Pe(H,X,ne),Object.defineProperties(ae.prototype,{debugFlags:Fe,constructor:ne(ae),ptrAdd:ne(J)});let Le=!1,ge=0;const ke=!!X.autoCalcSizeOffset;return ke||X.sizeof||r(H,"description is missing its sizeof property."),X.offset??=0,Object.keys(X.members||{}).forEach(ce=>{let Ee=Te(X.members[ce]);!Ee.members&&!Ee.sizeof&&(Ee.sizeof=Z(Ee.signature),Ee.sizeof||r(_(H,ce),"is missing a sizeof property.",Ee)),Ee.offset===void 0&&(ke?Ee.offset=ge:r(_(H,ce),"is missing its offset.",JSON.stringify(Ee))),X.members[ce]=Ee,(!Le||Le.offset<Ee.offset)&&(Le=Ee);const gt=!!Ee.autoCalc;ke&&(Ee.autoCalcSizeOffset=!0),mr.call(be,ae,ce,Ee),gt?Ee.autoCalcSizeOffset=!0:delete Ee.autoCalcSizeOffset,ge+=Ee.sizeof}),Le||r("No member property descriptions found."),X.sizeof||(X.sizeof=ge),X.sizeof===1?X.signature==="c"||X.signature==="C"||r("Unexpected sizeof==1 member",_(H,k),"with signature",X.signature):(X.sizeof%4!==0&&(console.warn("Invalid struct member description",X),r(H,"sizeof is not aligned. sizeof="+X.sizeof)),X.offset%4!==0&&(console.warn("Invalid struct member description",X),r(H,"offset is not aligned. offset="+X.offset))),X.sizeof<ge&&(console.warn("Suspect struct description:",X,"offset =",ge),r("Mismatch in the calculated vs. the provided sizeof/offset info.","Expected sizeof",ge,"but got",X.sizeof,"for",X)),delete X.autoCalcSizeOffset,ae},Ce=function I(H,X){return arguments.length==1?Jt.call(I,H):Jt.call(I,H,X)};return Ce.StructType=Pe,Ce.config=n,Ce.allocCString=Xe,Ce.adaptGet=Je,Ce.adaptSet=x,Ce.adaptStruct=M,Ce.ptrAdd=R,Ce.debugFlags||(Ce.debugFlags=s.__makeDebugFlags(s.debugFlags)),Ce},globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const n=(...y)=>{throw new Error(y.join(" "))},r=i.capi,s=i.wasm,u=i.util;globalThis.WhWasmUtilInstaller(s),delete globalThis.WhWasmUtilInstaller;const c={core:[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_bind_double","int","sqlite3_stmt*","int","f64"],["sqlite3_bind_int","int","sqlite3_stmt*","int","int"],["sqlite3_bind_null",void 0,"sqlite3_stmt*","int"],["sqlite3_bind_parameter_count","int","sqlite3_stmt*"],["sqlite3_bind_parameter_index","int","sqlite3_stmt*","string"],["sqlite3_bind_parameter_name","string","sqlite3_stmt*","int"],["sqlite3_bind_pointer","int","sqlite3_stmt*","int","*","string:static","*"],["sqlite3_bind_zeroblob","int","sqlite3_stmt*","int","int"],["sqlite3_busy_handler","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(y,m)=>y[0]}),"*"]],["sqlite3_busy_timeout","int","sqlite3*","int"],["sqlite3_changes","int","sqlite3*"],["sqlite3_clear_bindings","int","sqlite3_stmt*"],["sqlite3_collation_needed","int","sqlite3*","*","*"],["sqlite3_column_blob","*","sqlite3_stmt*","int"],["sqlite3_column_bytes","int","sqlite3_stmt*","int"],["sqlite3_column_count","int","sqlite3_stmt*"],["sqlite3_column_decltype","string","sqlite3_stmt*","int"],["sqlite3_column_double","f64","sqlite3_stmt*","int"],["sqlite3_column_int","int","sqlite3_stmt*","int"],["sqlite3_column_name","string","sqlite3_stmt*","int"],["sqlite3_column_type","int","sqlite3_stmt*","int"],["sqlite3_column_value","sqlite3_value*","sqlite3_stmt*","int"],["sqlite3_commit_hook","void*",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"sqlite3_commit_hook",signature:"i(p)",contextKey:y=>y[0]}),"*"]],["sqlite3_compileoption_get","string","int"],["sqlite3_compileoption_used","int","string"],["sqlite3_complete","int","string:flexible"],["sqlite3_context_db_handle","sqlite3*","sqlite3_context*"],["sqlite3_data_count","int","sqlite3_stmt*"],["sqlite3_db_filename","string","sqlite3*","string"],["sqlite3_db_handle","sqlite3*","sqlite3_stmt*"],["sqlite3_db_name","string","sqlite3*","int"],["sqlite3_db_readonly","int","sqlite3*","string"],["sqlite3_db_status","int","sqlite3*","int","*","*","int"],["sqlite3_errcode","int","sqlite3*"],["sqlite3_errmsg","string","sqlite3*"],["sqlite3_error_offset","int","sqlite3*"],["sqlite3_errstr","string","int"],["sqlite3_exec","int",["sqlite3*","string:flexible",new s.xWrap.FuncPtrAdapter({signature:"i(pipp)",bindScope:"transient",callProxy:y=>{let m;return(j,W,A,R)=>{try{const J=s.cArgvToJs(W,A);return m||(m=s.cArgvToJs(W,R)),y(J,m)|0}catch(J){return J.resultCode||r.SQLITE_ERROR}}}}),"*","**"]],["sqlite3_expanded_sql","string","sqlite3_stmt*"],["sqlite3_extended_errcode","int","sqlite3*"],["sqlite3_extended_result_codes","int","sqlite3*","int"],["sqlite3_file_control","int","sqlite3*","string","int","*"],["sqlite3_finalize","int","sqlite3_stmt*"],["sqlite3_free",void 0,"*"],["sqlite3_get_autocommit","int","sqlite3*"],["sqlite3_get_auxdata","*","sqlite3_context*","int"],["sqlite3_initialize",void 0],["sqlite3_interrupt",void 0,"sqlite3*"],["sqlite3_is_interrupted","int","sqlite3*"],["sqlite3_keyword_count","int"],["sqlite3_keyword_name","int",["int","**","*"]],["sqlite3_keyword_check","int",["string","int"]],["sqlite3_libversion","string"],["sqlite3_libversion_number","int"],["sqlite3_limit","int",["sqlite3*","int","int"]],["sqlite3_malloc","*","int"],["sqlite3_next_stmt","sqlite3_stmt*",["sqlite3*","sqlite3_stmt*"]],["sqlite3_open","int","string","*"],["sqlite3_open_v2","int","string","*","int","string"],["sqlite3_realloc","*","*","int"],["sqlite3_reset","int","sqlite3_stmt*"],["sqlite3_result_blob",void 0,"sqlite3_context*","*","int","*"],["sqlite3_result_double",void 0,"sqlite3_context*","f64"],["sqlite3_result_error",void 0,"sqlite3_context*","string","int"],["sqlite3_result_error_code",void 0,"sqlite3_context*","int"],["sqlite3_result_error_nomem",void 0,"sqlite3_context*"],["sqlite3_result_error_toobig",void 0,"sqlite3_context*"],["sqlite3_result_int",void 0,"sqlite3_context*","int"],["sqlite3_result_null",void 0,"sqlite3_context*"],["sqlite3_result_pointer",void 0,"sqlite3_context*","*","string:static","*"],["sqlite3_result_subtype",void 0,"sqlite3_value*","int"],["sqlite3_result_text",void 0,"sqlite3_context*","string","int","*"],["sqlite3_result_zeroblob",void 0,"sqlite3_context*","int"],["sqlite3_rollback_hook","void*",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"sqlite3_rollback_hook",signature:"v(p)",contextKey:y=>y[0]}),"*"]],["sqlite3_set_auxdata",void 0,["sqlite3_context*","int","*","*"]],["sqlite3_set_errmsg","int","sqlite3*","int","string"],["sqlite3_shutdown",void 0],["sqlite3_sourceid","string"],["sqlite3_sql","string","sqlite3_stmt*"],["sqlite3_status","int","int","*","*","int"],["sqlite3_step","int","sqlite3_stmt*"],["sqlite3_stmt_busy","int","sqlite3_stmt*"],["sqlite3_stmt_readonly","int","sqlite3_stmt*"],["sqlite3_stmt_status","int","sqlite3_stmt*","int","int"],["sqlite3_strglob","int","string","string"],["sqlite3_stricmp","int","string","string"],["sqlite3_strlike","int","string","string","int"],["sqlite3_strnicmp","int","string","string","int"],["sqlite3_table_column_metadata","int","sqlite3*","string","string","string","**","**","*","*","*"],["sqlite3_total_changes","int","sqlite3*"],["sqlite3_trace_v2","int",["sqlite3*","int",new s.xWrap.FuncPtrAdapter({name:"sqlite3_trace_v2::callback",signature:"i(ippp)",contextKey:(y,m)=>y[0]}),"*"]],["sqlite3_txn_state","int",["sqlite3*","string"]],["sqlite3_uri_boolean","int","sqlite3_filename","string","int"],["sqlite3_uri_key","string","sqlite3_filename","int"],["sqlite3_uri_parameter","string","sqlite3_filename","string"],["sqlite3_user_data","void*","sqlite3_context*"],["sqlite3_value_blob","*","sqlite3_value*"],["sqlite3_value_bytes","int","sqlite3_value*"],["sqlite3_value_double","f64","sqlite3_value*"],["sqlite3_value_dup","sqlite3_value*","sqlite3_value*"],["sqlite3_value_free",void 0,"sqlite3_value*"],["sqlite3_value_frombind","int","sqlite3_value*"],["sqlite3_value_int","int","sqlite3_value*"],["sqlite3_value_nochange","int","sqlite3_value*"],["sqlite3_value_numeric_type","int","sqlite3_value*"],["sqlite3_value_pointer","*","sqlite3_value*","string:static"],["sqlite3_value_subtype","int","sqlite3_value*"],["sqlite3_value_type","int","sqlite3_value*"],["sqlite3_vfs_find","*","string"],["sqlite3_vfs_register","int","sqlite3_vfs*","int"],["sqlite3_vfs_unregister","int","sqlite3_vfs*"]],int64:[["sqlite3_bind_int64","int",["sqlite3_stmt*","int","i64"]],["sqlite3_changes64","i64",["sqlite3*"]],["sqlite3_column_int64","i64",["sqlite3_stmt*","int"]],["sqlite3_deserialize","int","sqlite3*","string","*","i64","i64","int"],["sqlite3_last_insert_rowid","i64",["sqlite3*"]],["sqlite3_malloc64","*","i64"],["sqlite3_msize","i64","*"],["sqlite3_overload_function","int",["sqlite3*","string","int"]],["sqlite3_realloc64","*","*","i64"],["sqlite3_result_int64",void 0,"*","i64"],["sqlite3_result_zeroblob64","int","*","i64"],["sqlite3_serialize","*","sqlite3*","string","*","int"],["sqlite3_set_last_insert_rowid",void 0,["sqlite3*","i64"]],["sqlite3_status64","int","int","*","*","int"],["sqlite3_db_status64","int","sqlite3*","int","*","*","int"],["sqlite3_total_changes64","i64",["sqlite3*"]],["sqlite3_update_hook","*",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"sqlite3_update_hook::callback",signature:"v(pippj)",contextKey:y=>y[0],callProxy:y=>(m,j,W,A,R)=>{y(m,j,s.cstrToJs(W),s.cstrToJs(A),R)}}),"*"]],["sqlite3_uri_int64","i64",["sqlite3_filename","string","i64"]],["sqlite3_value_int64","i64","sqlite3_value*"]],wasmInternal:[["sqlite3__wasm_db_reset","int","sqlite3*"],["sqlite3__wasm_db_vfs","sqlite3_vfs*","sqlite3*","string"],["sqlite3__wasm_vfs_create_file","int","sqlite3_vfs*","string","*","int"],["sqlite3__wasm_posix_create_file","int","string","*","int"],["sqlite3__wasm_vfs_unlink","int","sqlite3_vfs*","string"],["sqlite3__wasm_qfmt_token","string:dealloc","string","int"]]};if(s.exports.sqlite3_progress_handler&&c.core.push(["sqlite3_progress_handler",void 0,["sqlite3*","int",new s.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(y,m)=>y[0]}),"*"]]),s.exports.sqlite3_stmt_explain&&c.core.push(["sqlite3_stmt_explain","int","sqlite3_stmt*","int"],["sqlite3_stmt_isexplain","int","sqlite3_stmt*"]),s.exports.sqlite3_set_authorizer&&c.core.push(["sqlite3_set_authorizer","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(y,m)=>y[0],callProxy:y=>(m,j,W,A,R,J)=>{try{return W=W&&s.cstrToJs(W),A=A&&s.cstrToJs(A),R=R&&s.cstrToJs(R),J=J&&s.cstrToJs(J),y(m,j,W,A,R,J)|0}catch(d){return d.resultCode||r.SQLITE_ERROR}}}),"*"]]),s.exports.sqlite3_column_origin_name&&c.core.push(["sqlite3_column_database_name","string","sqlite3_stmt*","int"],["sqlite3_column_origin_name","string","sqlite3_stmt*","int"],["sqlite3_column_table_name","string","sqlite3_stmt*","int"]),s.bigIntEnabled&&s.exports.sqlite3_declare_vtab&&c.int64.push(["sqlite3_create_module","int",["sqlite3*","string","sqlite3_module*","*"]],["sqlite3_create_module_v2","int",["sqlite3*","string","sqlite3_module*","*","*"]],["sqlite3_declare_vtab","int",["sqlite3*","string:flexible"]],["sqlite3_drop_modules","int",["sqlite3*","**"]],["sqlite3_vtab_collation","string","sqlite3_index_info*","int"],["sqlite3_vtab_distinct","int","sqlite3_index_info*"],["sqlite3_vtab_in","int","sqlite3_index_info*","int","int"],["sqlite3_vtab_in_first","int","sqlite3_value*","**"],["sqlite3_vtab_in_next","int","sqlite3_value*","**"],["sqlite3_vtab_nochange","int","sqlite3_context*"],["sqlite3_vtab_on_conflict","int","sqlite3*"],["sqlite3_vtab_rhs_value","int","sqlite3_index_info*","int","**"]),s.bigIntEnabled&&s.exports.sqlite3_preupdate_hook&&c.int64.push(["sqlite3_preupdate_blobwrite","int","sqlite3*"],["sqlite3_preupdate_count","int","sqlite3*"],["sqlite3_preupdate_depth","int","sqlite3*"],["sqlite3_preupdate_hook","*",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"sqlite3_preupdate_hook",signature:"v(ppippjj)",contextKey:y=>y[0],callProxy:y=>(m,j,W,A,R,J,d)=>{y(m,j,W,s.cstrToJs(A),s.cstrToJs(R),J,d)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]]),s.bigIntEnabled&&s.exports.sqlite3changegroup_add&&s.exports.sqlite3session_create&&s.exports.sqlite3_preupdate_hook){const y={signature:"i(ps)",callProxy:m=>(j,W)=>{try{return m(j,s.cstrToJs(W))|0}catch(A){return A.resultCode||r.SQLITE_ERROR}}};c.int64.push(["sqlite3changegroup_add","int",["sqlite3_changegroup*","int","void*"]],["sqlite3changegroup_add_strm","int",["sqlite3_changegroup*",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changegroup_delete",void 0,["sqlite3_changegroup*"]],["sqlite3changegroup_new","int",["**"]],["sqlite3changegroup_output","int",["sqlite3_changegroup*","int*","**"]],["sqlite3changegroup_output_strm","int",["sqlite3_changegroup*",new s.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply","int",["sqlite3*","int","void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...y}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_strm","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...y}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_v2","int",["sqlite3*","int","void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...y}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v2_strm","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...y}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3","int",["sqlite3*","int","void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3_strm","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_concat","int",["int","void*","int","void*","int*","**"]],["sqlite3changeset_concat_strm","int",[new s.xWrap.FuncPtrAdapter({name:"xInputA",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xInputB",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_conflict","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_finalize","int",["sqlite3_changeset_iter*"]],["sqlite3changeset_fk_conflicts","int",["sqlite3_changeset_iter*","int*"]],["sqlite3changeset_invert","int",["int","void*","int*","**"]],["sqlite3changeset_invert_strm","int",[new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_new","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_next","int",["sqlite3_changeset_iter*"]],["sqlite3changeset_old","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_op","int",["sqlite3_changeset_iter*","**","int*","int*","int*"]],["sqlite3changeset_pk","int",["sqlite3_changeset_iter*","**","int*"]],["sqlite3changeset_start","int",["**","int","*"]],["sqlite3changeset_start_strm","int",["**",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changeset_start_v2","int",["**","int","*","int"]],["sqlite3changeset_start_v2_strm","int",["**",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*","int"]],["sqlite3session_attach","int",["sqlite3_session*","string"]],["sqlite3session_changeset","int",["sqlite3_session*","int*","**"]],["sqlite3session_changeset_size","i64",["sqlite3_session*"]],["sqlite3session_changeset_strm","int",["sqlite3_session*",new s.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_config","int",["int","void*"]],["sqlite3session_create","int",["sqlite3*","string","**"]],["sqlite3session_diff","int",["sqlite3_session*","string","string","**"]],["sqlite3session_enable","int",["sqlite3_session*","int"]],["sqlite3session_indirect","int",["sqlite3_session*","int"]],["sqlite3session_isempty","int",["sqlite3_session*"]],["sqlite3session_memory_used","i64",["sqlite3_session*"]],["sqlite3session_object_config","int",["sqlite3_session*","int","void*"]],["sqlite3session_patchset","int",["sqlite3_session*","*","**"]],["sqlite3session_patchset_strm","int",["sqlite3_session*",new s.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_table_filter",void 0,["sqlite3_session*",new s.xWrap.FuncPtrAdapter({name:"xFilter",...y,contextKey:(m,j)=>m[0]}),"*"]])}i.StructBinder=globalThis.Jaccwabyt({heap:s.heap8u,alloc:s.alloc,dealloc:s.dealloc,bigIntEnabled:s.bigIntEnabled,pointerIR:s.ptr.ir,memberPrefix:"$"}),delete globalThis.Jaccwabyt;{const y=s.xWrap.argAdapter("string");s.xWrap.argAdapter("string:flexible",A=>y(u.flexibleString(A))),s.xWrap.argAdapter("string:static",(function(A){return s.isPtr(A)?A:(A=""+A,this[A]||(this[A]=s.allocCString(A)))}).bind(Object.create(null)));const m=s.xWrap.argAdapter("*"),j=function(){};s.xWrap.argAdapter("sqlite3_filename",m)("sqlite3_context*",m)("sqlite3_value*",m)("void*",m)("sqlite3_changegroup*",m)("sqlite3_changeset_iter*",m)("sqlite3_session*",m)("sqlite3_stmt*",A=>m(A instanceof(i?.oo1?.Stmt||j)?A.pointer:A))("sqlite3*",A=>m(A instanceof(i?.oo1?.DB||j)?A.pointer:A))("sqlite3_vfs*",A=>typeof A=="string"?r.sqlite3_vfs_find(A)||i.SQLite3Error.toss(r.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",A):m(A instanceof(r.sqlite3_vfs||j)?A.pointer:A)),s.exports.sqlite3_declare_vtab&&s.xWrap.argAdapter("sqlite3_index_info*",A=>m(A instanceof(r.sqlite3_index_info||j)?A.pointer:A))("sqlite3_module*",A=>m(A instanceof(r.sqlite3_module||j)?A.pointer:A));const W=s.xWrap.resultAdapter("*");s.xWrap.resultAdapter("sqlite3*",W)("sqlite3_context*",W)("sqlite3_stmt*",W)("sqlite3_value*",W)("sqlite3_vfs*",W)("void*",W);for(const A of c.core)r[A[0]]=s.xWrap.apply(null,A);for(const A of c.wasmInternal)u[A[0]]=s.xWrap.apply(null,A);for(const A of c.int64)r[A[0]]=s.bigIntEnabled?s.xWrap.apply(null,A):()=>n(A[0]+"() is unavailable due to lack","of BigInt support in this build.");delete c.core,delete c.int64,delete c.wasmInternal,u.sqlite3__wasm_db_error=function(A,R,J){return A?(R instanceof i.WasmAllocError?(R=r.SQLITE_NOMEM,J=0):R instanceof Error&&(J=J||""+R,R=R.resultCode||r.SQLITE_ERROR),r.sqlite3_set_errmsg(A,R,J)||R):r.SQLITE_MISUSE}}{const y=s.xCall("sqlite3__wasm_enum_json");y||n("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!"),s.ctype=JSON.parse(s.cstrToJs(y));const m=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];s.bigIntEnabled&&m.push("serialize","session","vtab");for(const A of m)for(const R of Object.entries(s.ctype[A]))r[R[0]]=R[1];s.functionEntry(r.SQLITE_WASM_DEALLOC)||n("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+r.SQLITE_WASM_DEALLOC+").");const j=Object.create(null);for(const A of Object.entries(s.ctype.resultCodes))j[A[1]]=A[0];r.sqlite3_js_rc_str=A=>j[A];const W=Object.assign(Object.create(null),{WasmTestStruct:!0,sqlite3_index_info:!s.bigIntEnabled,sqlite3_index_constraint:!s.bigIntEnabled,sqlite3_index_orderby:!s.bigIntEnabled,sqlite3_index_constraint_usage:!s.bigIntEnabled});for(const A of s.ctype.structs)W[A.name]||(r[A.name]=i.StructBinder(A));if(r.sqlite3_index_info){for(const A of["sqlite3_index_constraint","sqlite3_index_orderby","sqlite3_index_constraint_usage"])r.sqlite3_index_info[A]=r[A],delete r[A];r.sqlite3_vtab_config=s.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}const b=(y,m,j)=>u.sqlite3__wasm_db_error(y,r.SQLITE_MISUSE,m+"() requires "+j+" argument"+(j===1?"":"s")+"."),z=y=>u.sqlite3__wasm_db_error(y,r.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),O=y=>s.xWrap.argAdapter("sqlite3*")(y),S=y=>s.isPtr(y)?s.cstrToJs(y):y,w=(function(y,m){y=O(y);let j=this.dbMap.get(y);if(m)!j&&m>0&&this.dbMap.set(y,j=Object.create(null));else return this.dbMap.delete(y),j;return j}).bind(Object.assign(Object.create(null),{dbMap:new Map}));w.addCollation=function(y,m){const j=w(y,1);j.collation||(j.collation=new Set),j.collation.add(S(m).toLowerCase())},w._addUDF=function(y,m,j,W){m=S(m).toLowerCase();let A=W.get(m);A||W.set(m,A=new Set),A.add(j<0?-1:j)},w.addFunction=function(y,m,j){const W=w(y,1);W.udf||(W.udf=new Map),this._addUDF(y,m,j,W.udf)},s.exports.sqlite3_create_window_function&&(w.addWindowFunc=function(y,m,j){const W=w(y,1);W.wudf||(W.wudf=new Map),this._addUDF(y,m,j,W.wudf)}),w.cleanup=function(y){y=O(y);for(const W of[["sqlite3_busy_handler",3],["sqlite3_commit_hook",3],["sqlite3_preupdate_hook",3],["sqlite3_progress_handler",4],["sqlite3_rollback_hook",3],["sqlite3_set_authorizer",3],["sqlite3_trace_v2",4],["sqlite3_update_hook",3]]){const[A,R]=W;if(!s.exports[A])continue;const J=[y];J.length=R;try{r[A](...J)}catch(d){i.config.warn("close-time call of",A+"(",J,") threw:",d)}}const m=w(y,0);if(!m)return;if(m.collation){for(const W of m.collation)try{r.sqlite3_create_collation_v2(y,W,r.SQLITE_UTF8,0,0,0)}catch{}delete m.collation}let j=0;for(;j<2;++j){const W=j?m.wudf:m.udf;if(!W)continue;const A=j?r.sqlite3_create_window_function:r.sqlite3_create_function_v2;for(const R of W){const J=R[0],d=R[1],q=[y,J,0,r.SQLITE_UTF8,0,0,0,0,0];j&&q.push(0);for(const L of d)try{q[2]=L,A.apply(null,q)}catch{}d.clear()}W.clear()}delete m.udf,delete m.wudf};{const y=s.xWrap("sqlite3_close_v2","int","sqlite3*");r.sqlite3_close_v2=function(m){if(arguments.length!==1)return b(m,"sqlite3_close_v2",1);if(m)try{w.cleanup(m)}catch{}return y(m)}}if(r.sqlite3session_create){const y=s.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);r.sqlite3session_delete=function(m){if(arguments.length!==1)return b(pDb,"sqlite3session_delete",1);m&&r.sqlite3session_table_filter(m,0,0),y(m)}}{const y=(j,W)=>"argv["+W+"]:"+j[0]+":"+s.cstrToJs(j[1]).toLowerCase(),m=s.xWrap("sqlite3_create_collation_v2","int",["sqlite3*","string","int","*",new s.xWrap.FuncPtrAdapter({name:"xCompare",signature:"i(pipip)",contextKey:y}),new s.xWrap.FuncPtrAdapter({name:"xDestroy",signature:"v(p)",contextKey:y})]);r.sqlite3_create_collation_v2=function(j,W,A,R,J,d){if(arguments.length!==6)return b(j,"sqlite3_create_collation_v2",6);if((A&15)===0)A|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(A&15))return z(j);try{const q=m(j,W,A,R,J,d);return q===0&&J instanceof Function&&w.addCollation(j,W),q}catch(q){return u.sqlite3__wasm_db_error(j,q)}},r.sqlite3_create_collation=(j,W,A,R,J)=>arguments.length===5?r.sqlite3_create_collation_v2(j,W,A,R,J,0):b(j,"sqlite3_create_collation",5)}{const y=function(A,R){return A[0]+":"+(A[2]<0?-1:A[2])+":"+R+":"+s.cstrToJs(A[1]).toLowerCase()},m=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:y,callProxy:A=>(R,J,d)=>{try{A(R,...r.sqlite3_values_to_js(J,d))}catch(q){r.sqlite3_result_error_js(R,q)}}},xFinalAndValue:{signature:"v(p)",contextKey:y,callProxy:A=>R=>{try{r.sqlite3_result_js(R,A(R))}catch(J){r.sqlite3_result_error_js(R,J)}}},xFunc:{signature:"v(pip)",contextKey:y,callProxy:A=>(R,J,d)=>{try{r.sqlite3_result_js(R,A(R,...r.sqlite3_values_to_js(J,d)))}catch(q){r.sqlite3_result_error_js(R,q)}}},xDestroy:{signature:"v(p)",contextKey:y,callProxy:A=>R=>{try{A(R)}catch(J){console.error("UDF xDestroy method threw:",J)}}}}),j=s.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new s.xWrap.FuncPtrAdapter({name:"xFunc",...m.xFunc}),new s.xWrap.FuncPtrAdapter({name:"xStep",...m.xInverseAndStep}),new s.xWrap.FuncPtrAdapter({name:"xFinal",...m.xFinalAndValue}),new s.xWrap.FuncPtrAdapter({name:"xDestroy",...m.xDestroy})]),W=s.exports.sqlite3_create_window_function?s.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new s.xWrap.FuncPtrAdapter({name:"xStep",...m.xInverseAndStep}),new s.xWrap.FuncPtrAdapter({name:"xFinal",...m.xFinalAndValue}),new s.xWrap.FuncPtrAdapter({name:"xValue",...m.xFinalAndValue}),new s.xWrap.FuncPtrAdapter({name:"xInverse",...m.xInverseAndStep}),new s.xWrap.FuncPtrAdapter({name:"xDestroy",...m.xDestroy})]):void 0;r.sqlite3_create_function_v2=function A(R,J,d,q,L,Q,F,Y,Z){if(A.length!==arguments.length)return b(R,"sqlite3_create_function_v2",A.length);if((q&15)===0)q|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(q&15))return z(R);try{const ee=j(R,J,d,q,L,Q,F,Y,Z);return ee===0&&(Q instanceof Function||F instanceof Function||Y instanceof Function||Z instanceof Function)&&w.addFunction(R,J,d),ee}catch(ee){return console.error("sqlite3_create_function_v2() setup threw:",ee),u.sqlite3__wasm_db_error(R,ee,"Creation of UDF threw: "+ee)}},r.sqlite3_create_function=function A(R,J,d,q,L,Q,F,Y){return A.length===arguments.length?r.sqlite3_create_function_v2(R,J,d,q,L,Q,F,Y,0):b(R,"sqlite3_create_function",A.length)},W?r.sqlite3_create_window_function=function A(R,J,d,q,L,Q,F,Y,Z,ee){if(A.length!==arguments.length)return b(R,"sqlite3_create_window_function",A.length);if((q&15)===0)q|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(q&15))return z(R);try{const g=W(R,J,d,q,L,Q,F,Y,Z,ee);return g===0&&(Q instanceof Function||F instanceof Function||Y instanceof Function||Z instanceof Function||ee instanceof Function)&&w.addWindowFunc(R,J,d),g}catch(g){return console.error("sqlite3_create_window_function() setup threw:",g),u.sqlite3__wasm_db_error(R,g,"Creation of UDF threw: "+g)}}:delete r.sqlite3_create_window_function,r.sqlite3_create_function_v2.udfSetResult=r.sqlite3_create_function.udfSetResult=r.sqlite3_result_js,r.sqlite3_create_window_function&&(r.sqlite3_create_window_function.udfSetResult=r.sqlite3_result_js),r.sqlite3_create_function_v2.udfConvertArgs=r.sqlite3_create_function.udfConvertArgs=r.sqlite3_values_to_js,r.sqlite3_create_window_function&&(r.sqlite3_create_window_function.udfConvertArgs=r.sqlite3_values_to_js),r.sqlite3_create_function_v2.udfSetError=r.sqlite3_create_function.udfSetError=r.sqlite3_result_error_js,r.sqlite3_create_window_function&&(r.sqlite3_create_window_function.udfSetError=r.sqlite3_result_error_js)}{const y=(j,W)=>(typeof j=="string"?W=-1:u.isSQLableTypedArray(j)?(W=j.byteLength,j=s.typedArrayToString(j instanceof ArrayBuffer?new Uint8Array(j):j)):Array.isArray(j)&&(j=j.join(""),W=-1),[j,W]),m={basic:s.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:s.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};r.sqlite3_prepare_v3=function j(W,A,R,J,d,q){if(j.length!==arguments.length)return b(W,"sqlite3_prepare_v3",j.length);const[L,Q]=y(A,Number(R));switch(typeof L){case"string":return m.basic(W,L,Q,J,d,null);case typeof s.ptr.null:return m.full(W,s.ptr.coerce(L),Q,J,d,q);default:return u.sqlite3__wasm_db_error(W,r.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3(). typeof="+typeof L)}},r.sqlite3_prepare_v2=function j(W,A,R,J,d){return j.length===arguments.length?r.sqlite3_prepare_v3(W,A,R,0,J,d):b(W,"sqlite3_prepare_v2",j.length)}}{const y=s.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),m=s.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);r.sqlite3_bind_text=function j(W,A,R,J,d){if(j.length!==arguments.length)return b(r.sqlite3_db_handle(W),"sqlite3_bind_text",j.length);if(s.isPtr(R)||R===null)return y(W,A,R,J,d);R instanceof ArrayBuffer?R=new Uint8Array(R):Array.isArray(pMem)&&(R=pMem.join(""));let q,L;try{if(u.isSQLableTypedArray(R))q=s.allocFromTypedArray(R),L=R.byteLength;else if(typeof R=="string")[q,L]=s.allocCString(R);else return u.sqlite3__wasm_db_error(r.sqlite3_db_handle(W),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return y(W,A,q,L,r.SQLITE_WASM_DEALLOC)}catch(Q){return s.dealloc(q),u.sqlite3__wasm_db_error(r.sqlite3_db_handle(W),Q)}},r.sqlite3_bind_blob=function j(W,A,R,J,d){if(j.length!==arguments.length)return b(r.sqlite3_db_handle(W),"sqlite3_bind_blob",j.length);if(s.isPtr(R)||R===null)return m(W,A,R,J,d);R instanceof ArrayBuffer?R=new Uint8Array(R):Array.isArray(R)&&(R=R.join(""));let q,L;try{if(u.isBindableTypedArray(R))q=s.allocFromTypedArray(R),L=J>=0?J:R.byteLength;else if(typeof R=="string")[q,L]=s.allocCString(R);else return u.sqlite3__wasm_db_error(r.sqlite3_db_handle(W),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return m(W,A,q,L,r.SQLITE_WASM_DEALLOC)}catch(Q){return s.dealloc(q),u.sqlite3__wasm_db_error(r.sqlite3_db_handle(W),Q)}}}if(!r.sqlite3_column_text){const y=s.xWrap.argAdapter("sqlite3_stmt*"),m=s.xWrap.argAdapter("int"),j=s.xWrap.argAdapter("sqlite3_value*"),W=(A,R)=>s.typedArrayToString(s.heap8u(),Number(A),Number(A)+R);r.sqlite3_column_text=function(A,R){const J=y(A),d=m(R),q=s.exports.sqlite3_column_text(J,d);return q?W(q,s.exports.sqlite3_column_bytes(J,d)):null},r.sqlite3_value_text=function(A){const R=j(A),J=s.exports.sqlite3_value_text(R);return J?W(J,s.exports.sqlite3_value_bytes(R)):null}}r.sqlite3_config=function(y,...m){if(arguments.length<2)return r.SQLITE_MISUSE;switch(y){case r.SQLITE_CONFIG_COVERING_INDEX_SCAN:case r.SQLITE_CONFIG_MEMSTATUS:case r.SQLITE_CONFIG_SMALL_MALLOC:case r.SQLITE_CONFIG_SORTERREF_SIZE:case r.SQLITE_CONFIG_STMTJRNL_SPILL:case r.SQLITE_CONFIG_URI:return s.exports.sqlite3__wasm_config_i(y,m[0]);case r.SQLITE_CONFIG_LOOKASIDE:return s.exports.sqlite3__wasm_config_ii(y,m[0],m[1]);case r.SQLITE_CONFIG_MEMDB_MAXSIZE:return s.exports.sqlite3__wasm_config_j(y,m[0]);case r.SQLITE_CONFIG_GETMALLOC:case r.SQLITE_CONFIG_GETMUTEX:case r.SQLITE_CONFIG_GETPCACHE2:case r.SQLITE_CONFIG_GETPCACHE:case r.SQLITE_CONFIG_HEAP:case r.SQLITE_CONFIG_LOG:case r.SQLITE_CONFIG_MALLOC:case r.SQLITE_CONFIG_MMAP_SIZE:case r.SQLITE_CONFIG_MULTITHREAD:case r.SQLITE_CONFIG_MUTEX:case r.SQLITE_CONFIG_PAGECACHE:case r.SQLITE_CONFIG_PCACHE2:case r.SQLITE_CONFIG_PCACHE:case r.SQLITE_CONFIG_PCACHE_HDRSZ:case r.SQLITE_CONFIG_PMASZ:case r.SQLITE_CONFIG_SERIALIZED:case r.SQLITE_CONFIG_SINGLETHREAD:case r.SQLITE_CONFIG_SQLLOG:case r.SQLITE_CONFIG_WIN32_HEAPSIZE:default:return r.SQLITE_NOTFOUND}};{const y=new Set;r.sqlite3_auto_extension=function(m){if(m instanceof Function)m=s.installFunction("i(ppp)",m);else if(arguments.length!==1||!s.isPtr(m))return r.SQLITE_MISUSE;const j=s.exports.sqlite3_auto_extension(m);return m!==arguments[0]&&(j===0?y.add(m):s.uninstallFunction(m)),j},r.sqlite3_cancel_auto_extension=function(m){return!m||arguments.length!==1||!s.isPtr(m)?0:s.exports.sqlite3_cancel_auto_extension(m)},r.sqlite3_reset_auto_extension=function(){s.exports.sqlite3_reset_auto_extension();for(const m of y)s.uninstallFunction(m);y.clear()}}s.xWrap.FuncPtrAdapter.warnOnUse=!0;const P=i.StructBinder,N=function y(m,j,W,A=y.installMethodArgcCheck){if(m instanceof P.StructType?!(W instanceof Function)&&!s.isPtr(W)&&n("Usage error: expecting a Function or WASM pointer to one."):n("Usage error: target object is-not-a StructType."),arguments.length===1)return(q,L)=>y(m,q,L,A);y.argcProxy||(y.argcProxy=function(q,L,Q,F){return function(...Y){return Q.length!==arguments.length&&n("Argument mismatch for",q.structInfo.name+"::"+L+": Native signature is:",F),Q.apply(this,Y)}},y.removeFuncList=function(){this.ondispose.__removeFuncList&&(this.ondispose.__removeFuncList.forEach((q,L)=>{if(s.isPtr(q))try{s.uninstallFunction(q)}catch{}}),delete this.ondispose.__removeFuncList)});const R=m.memberSignature(j);R.length<2&&n("Member",j,"does not have a function pointer signature:",R);const J=m.memberKey(j),d=A&&!s.isPtr(W)?y.argcProxy(m,J,W,R):W;if(s.isPtr(d))d&&!s.functionEntry(d)&&n("Pointer",d,"is not a WASM function table entry."),m[J]=d;else{const q=s.installFunction(d,R);m[J]=q,(!m.ondispose||!m.ondispose.__removeFuncList)&&(m.addOnDispose("ondispose.__removeFuncList handler",y.removeFuncList),m.ondispose.__removeFuncList=[]),m.ondispose.__removeFuncList.push(J,q)}return(q,L)=>y(m,q,L,A)};N.installMethodArgcCheck=!1;const U=function(y,m,j=N.installMethodArgcCheck){const W=new Map;for(const A of Object.keys(m)){const R=m[A],J=W.get(R);if(J){const d=y.memberKey(A);y[d]=y[y.memberKey(J)]}else N(y,A,R,j),W.set(R,A)}return y};P.StructType.prototype.installMethod=function(m,j,W=N.installMethodArgcCheck){return arguments.length<3&&m&&typeof m=="object"?U(this,...arguments):N(this,...arguments)},P.StructType.prototype.installMethods=function(y,m=N.installMethodArgcCheck){return U(this,y,m)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const n=(...g)=>{throw new i.SQLite3Error(...g)},r=i.capi,s=i.wasm,u=i.util;i.__isUnderTest?console.debug.bind(console):i.config.debug,i.__isUnderTest?console.warn.bind(console):i.config.warn,i.__isUnderTest?console.error.bind(console):i.config.error;const c=new WeakMap,b=new Set,z=new WeakMap,O=(g,T,l)=>{const _=Object.getOwnPropertyDescriptor(g,T);return _?_.value:l},S=function(g,T){return T&&(g instanceof U&&(g=g.pointer),n(T,"sqlite3 result code",T+":",g?r.sqlite3_errmsg(g):r.sqlite3_errstr(T))),arguments[0]},w=s.installFunction("i(ippp)",(function(g,T,l,_){r.SQLITE_TRACE_STMT===g&&console.log("SQL TRACE #"+ ++this.counter,"via sqlite3@"+T+"["+r.sqlite3_db_filename(T,null)+"]",s.cstrToJs(_))}).bind({counter:0})),P=Object.create(null),N=function g(...T){const l=g.normalizeArgs(...T);let _;if(_=l["sqlite3*"])l["sqlite3*:takeOwnership"]||b.add(this),this.filename=r.sqlite3_db_filename(_,"main");else{let p=l.filename,D=l.vfs,B=l.flags;(typeof p!="string"&&!s.isPtr(p)||typeof B!="string"||D&&typeof D!="string"&&!s.isPtr(D))&&(i.config.error("Invalid DB ctor args",l,arguments),n("Invalid arguments for DB constructor:",arguments,"opts:",l));let C=0;B.indexOf("c")>=0&&(C|=r.SQLITE_OPEN_CREATE|r.SQLITE_OPEN_READWRITE),B.indexOf("w")>=0&&(C|=r.SQLITE_OPEN_READWRITE),C===0&&(C|=r.SQLITE_OPEN_READONLY),C|=r.SQLITE_OPEN_EXRESCODE;const h=s.pstack.pointer;try{const E=s.pstack.allocPtr();let V=r.sqlite3_open_v2(p,E,C,D||s.ptr.null);_=s.peekPtr(E),S(_,V),r.sqlite3_extended_result_codes(_,1),B.indexOf("t")>=0&&r.sqlite3_trace_v2(_,r.SQLITE_TRACE_STMT,w,_)}catch(E){throw _&&r.sqlite3_close_v2(_),E}finally{s.pstack.restore(h)}this.filename=s.isPtr(p)?s.cstrToJs(p):p}if(c.set(this,_),z.set(this,Object.create(null)),!l["sqlite3*"])try{const p=r.sqlite3_js_db_vfs(_)||n("Internal error: cannot get VFS for new db handle."),D=P[p];D&&(D instanceof Function?D(this,i):S(_,r.sqlite3_exec(_,D,0,0,0)))}catch(p){throw this.close(),p}};N.setVfsPostOpenCallback=function(g,T){T instanceof Function||n("dbCtorHelper.setVfsPostOpenCallback() should not be used with a non-function argument.",arguments),P[g]=T},N.normalizeArgs=function(g=":memory:",T="c",l=null){const _={};return arguments.length===1&&arguments[0]&&typeof arguments[0]=="object"?(Object.assign(_,arguments[0]),_.flags===void 0&&(_.flags="c"),_.vfs===void 0&&(_.vfs=null),_.filename===void 0&&(_.filename=":memory:")):(_.filename=g,_.flags=T,_.vfs=l),_};const U=function(...g){N.apply(this,g)};U.dbCtorHelper=N;const y={null:1,number:2,string:3,boolean:4,blob:5};s.bigIntEnabled&&(y.bigint=y.number);const m=function(){y!==arguments[2]&&n(r.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare()."),this.db=arguments[0],c.set(this,arguments[1]),arguments.length>3&&!arguments[3]&&b.add(this)},j=function(g){return g.pointer||n("DB has been closed."),g},W=function(g,T){return(T!==(T|0)||T<0||T>=g.columnCount)&&n("Column index",T,"is out of range."),g},A=function(g,T){const l=Object.create(null);switch(l.opt=Object.create(null),T.length){case 1:typeof T[0]=="string"||u.isSQLableTypedArray(T[0])||Array.isArray(T[0])?l.sql=T[0]:T[0]&&typeof T[0]=="object"&&(l.opt=T[0],l.sql=l.opt.sql);break;case 2:l.sql=T[0],l.opt=T[1];break;default:n("Invalid argument count for exec().")}l.sql=u.flexibleString(l.sql),typeof l.sql!="string"&&n("Missing SQL argument or unsupported SQL value type.");const _=l.opt;switch(_.returnValue){case"resultRows":_.resultRows||(_.resultRows=[]),l.returnVal=()=>_.resultRows;break;case"saveSql":_.saveSql||(_.saveSql=[]),l.returnVal=()=>_.saveSql;break;case void 0:case"this":l.returnVal=()=>g;break;default:n("Invalid returnValue value:",_.returnValue)}if(!_.callback&&!_.returnValue&&_.rowMode!==void 0&&(_.resultRows||(_.resultRows=[]),l.returnVal=()=>_.resultRows),_.callback||_.resultRows)switch(_.rowMode===void 0?"array":_.rowMode){case"object":l.cbArg=(p,D)=>{D.columnNames||(D.columnNames=p.getColumnNames([]));const B=p.get([]),C=Object.create(null);for(const h in D.columnNames)C[D.columnNames[h]]=B[h];return C};break;case"array":l.cbArg=p=>p.get([]);break;case"stmt":Array.isArray(_.resultRows)&&n("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference."),l.cbArg=p=>p;break;default:if(u.isInt32(_.rowMode)){l.cbArg=p=>p.get(_.rowMode);break}else if(typeof _.rowMode=="string"&&_.rowMode.length>1&&_.rowMode[0]==="$"){const p=_.rowMode.substr(1);l.cbArg=D=>{const B=D.get(Object.create(null))[p];return B===void 0?n(r.SQLITE_NOTFOUND,"exec(): unknown result column:",p):B};break}n("Invalid rowMode:",_.rowMode)}return l},R=(g,T,l,..._)=>{const p=g.prepare(T);try{const D=p.bind(l).step()?p.get(..._):void 0;return p.reset(),D}finally{p.finalize()}},J=(g,T,l,_)=>g.exec({sql:T,bind:l,rowMode:_,returnValue:"resultRows"});U.checkRc=(g,T)=>S(g,T),U.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return j(this)},close:function(){const g=this.pointer;if(g){if(this.onclose&&this.onclose.before instanceof Function)try{this.onclose.before(this)}catch{}if(Object.keys(z.get(this)).forEach((T,l)=>{if(l&&l.pointer)try{l.finalize()}catch{}}),c.delete(this),z.delete(this),b.delete(this)||r.sqlite3_close_v2(g),this.onclose&&this.onclose.after instanceof Function)try{this.onclose.after(this)}catch{}delete this.filename}},changes:function(g=!1,T=!1){const l=j(this).pointer;return g?T?r.sqlite3_total_changes64(l):r.sqlite3_total_changes(l):T?r.sqlite3_changes64(l):r.sqlite3_changes(l)},dbFilename:function(g="main"){return r.sqlite3_db_filename(j(this).pointer,g)},dbName:function(g=0){return r.sqlite3_db_name(j(this).pointer,g)},dbVfsName:function(g=0){let T;const l=r.sqlite3_js_db_vfs(j(this).pointer,g);if(l){const _=new r.sqlite3_vfs(l);try{T=s.cstrToJs(_.$zName)}finally{_.dispose()}}return T},prepare:function(g){j(this);const T=s.pstack.pointer;let l,_;try{l=s.pstack.alloc(8),U.checkRc(this,r.sqlite3_prepare_v2(this.pointer,g,-1,l,null)),_=s.peekPtr(l)}finally{s.pstack.restore(T)}_||n("Cannot prepare empty SQL.");const p=new m(this,_,y);return z.get(this)[_]=p,p},exec:function(){j(this);const g=A(this,arguments);if(!g.sql)return n("exec() requires an SQL string.");const T=g.opt,l=T.callback,_=Array.isArray(T.resultRows)?T.resultRows:void 0;let p,D=T.bind,B=!!(g.cbArg||T.columnNames||_);const C=s.scopedAllocPush(),h=Array.isArray(T.saveSql)?T.saveSql:void 0;try{const E=u.isSQLableTypedArray(g.sql);let V=E?g.sql.byteLength:s.jstrlen(g.sql);const G=s.scopedAlloc(2*s.ptr.size+(V+1)),re=s.ptr.add(G,s.ptr.size);let ne=s.ptr.add(re,s.ptr.size);const de=s.ptr.add(ne,V);for(E?s.heap8().set(g.sql,ne):s.jstrcpy(g.sql,s.heap8(),ne,V,!1),s.poke8(s.ptr.add(ne,V),0);ne&&s.peek8(ne);){s.pokePtr([G,re],0),U.checkRc(this,r.sqlite3_prepare_v3(this.pointer,ne,V,0,G,re));const ue=s.peekPtr(G);if(ne=s.peekPtr(re),V=Number(s.ptr.add(de,-ne)),!!ue){if(h&&h.push(r.sqlite3_sql(ue).trim()),p=new m(this,ue,y),D&&p.parameterCount&&(p.bind(D),D=null),B&&p.columnCount){let Ae=Array.isArray(T.columnNames)?0:1;if(B=!1,g.cbArg||_){const Oe=Object.create(null);for(;p.step();F.delete(p)){Ae++===0&&p.getColumnNames(Oe.columnNames=T.columnNames||[]),F.add(p);const Je=g.cbArg(p,Oe);if(_&&_.push(Je),l&&l.call(T,Je,p)===!1)break}F.delete(p)}Ae===0&&p.getColumnNames(T.columnNames)}else p.step();p.reset().finalize(),p=null}}}finally{p&&(F.delete(p),p.finalize()),s.scopedAllocPop(C)}return g.returnVal()},createFunction:function(T,l,_){const p=Oe=>Oe instanceof Function;switch(arguments.length){case 1:_=T,T=_.name,l=_.xFunc||0;break;case 2:p(l)||(_=l,l=_.xFunc||0)}_||(_={}),typeof T!="string"&&n("Invalid arguments: missing function name.");let D=_.xStep||0,B=_.xFinal||0;const C=_.xValue||0,h=_.xInverse||0;let E;p(l)?(E=!1,(p(D)||p(B))&&n("Ambiguous arguments: scalar or aggregate?"),D=B=null):p(D)?(p(B)||n("Missing xFinal() callback for aggregate or window UDF."),l=null):p(B)?n("Missing xStep() callback for aggregate or window UDF."):n("Missing function-type properties."),E===!1?(p(C)||p(h))&&n("xValue and xInverse are not permitted for non-window UDFs."):p(C)?(p(h)||n("xInverse must be provided if xValue is."),E=!0):p(h)&&n("xValue must be provided if xInverse is.");const V=_.pApp;V!=null&&!s.isPtr(V)&&n("Invalid value for pApp property. Must be a legal WASM pointer value.");const G=_.xDestroy||0;G&&!p(G)&&n("xDestroy property must be a function.");let re=0;O(_,"deterministic")&&(re|=r.SQLITE_DETERMINISTIC),O(_,"directOnly")&&(re|=r.SQLITE_DIRECTONLY),O(_,"innocuous")&&(re|=r.SQLITE_INNOCUOUS),T=T.toLowerCase();const ne=l||D,de=O(_,"arity"),ue=typeof de=="number"?de:ne.length?ne.length-1:0;let Ae;return E?Ae=r.sqlite3_create_window_function(this.pointer,T,ue,r.SQLITE_UTF8|re,V||0,D,B,C,h,G):Ae=r.sqlite3_create_function_v2(this.pointer,T,ue,r.SQLITE_UTF8|re,V||0,l,D,B,G),U.checkRc(this,Ae),this},selectValue:function(g,T,l){return R(this,g,T,0,l)},selectValues:function(g,T,l){const _=this.prepare(g),p=[];try{for(_.bind(T);_.step();)p.push(_.get(0,l));_.reset()}finally{_.finalize()}return p},selectArray:function(g,T){return R(this,g,T,[])},selectObject:function(g,T){return R(this,g,T,{})},selectArrays:function(g,T){return J(this,g,T,"array")},selectObjects:function(g,T){return J(this,g,T,"object")},openStatementCount:function(){return this.pointer?Object.keys(z.get(this)).length:0},transaction:function(g){let T="BEGIN";arguments.length>1&&(/[^a-zA-Z]/.test(arguments[0])&&n(r.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier."),T+=" "+arguments[0],g=arguments[1]),j(this).exec(T);try{const l=g(this);return this.exec("COMMIT"),l}catch(l){throw this.exec("ROLLBACK"),l}},savepoint:function(g){j(this).exec("SAVEPOINT oo1");try{const T=g(this);return this.exec("RELEASE oo1"),T}catch(T){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),T}},checkRc:function(g){return S(this,g)}},U.wrapHandle=function(g,T=!1){if(!g||!s.isPtr(g))throw new i.SQLite3Error(r.SQLITE_MISUSE,"Argument must be a WASM sqlite3 pointer");return new U({"sqlite3*":g,"sqlite3*:takeOwnership":!!T})};const d=function(g){return g.pointer||n("Stmt has been closed."),g},q=function(g){let T=y[g==null?"null":typeof g];switch(T){case y.boolean:case y.null:case y.number:case y.string:return T;case y.bigint:return s.bigIntEnabled?T:void 0;default:return u.isBindableTypedArray(g)?y.blob:void 0}},L=function(g){return q(g)||n("Unsupported bind() argument type:",typeof g)},Q=function(g,T){const l=typeof T=="number"?T:r.sqlite3_bind_parameter_index(g.pointer,T);return l===0||!u.isInt32(l)?n("Invalid bind() parameter name: "+T):(l<1||l>g.parameterCount)&&n("Bind index",T,"is out of range."),l},F=new Set,Y=new Set,Z=function(g,T){return F.has(g)&&n("Operation is illegal when statement is locked:",T),g},ee=function g(T,l,_,p){Z(d(T),"bind()"),g._||(g._tooBigInt=B=>n("BigInt value is too big to store without precision loss:",B),g._={string:function(B,C,h,E){const[V,G]=s.allocCString(h,!0);return(E?r.sqlite3_bind_blob:r.sqlite3_bind_text)(B.pointer,C,V,G,r.SQLITE_WASM_DEALLOC)}}),L(p),l=Q(T,l);let D=0;switch(p==null?y.null:_){case y.null:D=r.sqlite3_bind_null(T.pointer,l);break;case y.string:D=g._.string(T,l,p,!1);break;case y.number:{let B;u.isInt32(p)?B=r.sqlite3_bind_int:typeof p=="bigint"?u.bigIntFits64(p)?s.bigIntEnabled?B=r.sqlite3_bind_int64:u.bigIntFitsDouble(p)?(p=Number(p),B=r.sqlite3_bind_double):g._tooBigInt(p):g._tooBigInt(p):(p=Number(p),s.bigIntEnabled&&Number.isInteger(p)?B=r.sqlite3_bind_int64:B=r.sqlite3_bind_double),D=B(T.pointer,l,p);break}case y.boolean:D=r.sqlite3_bind_int(T.pointer,l,p?1:0);break;case y.blob:{if(typeof p=="string"){D=g._.string(T,l,p,!0);break}else p instanceof ArrayBuffer?p=new Uint8Array(p):u.isBindableTypedArray(p)||n("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");const B=s.alloc(p.byteLength||1);s.heap8().set(p.byteLength?p:[0],Number(B)),D=r.sqlite3_bind_blob(T.pointer,l,B,p.byteLength,r.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",p),n("Unsupported bind() argument type: "+typeof p)}return D&&U.checkRc(T.db.pointer,D),T};m.prototype={finalize:function(){const g=this.pointer;if(g){Z(this,"finalize()");const T=b.delete(this)?0:r.sqlite3_finalize(g);return delete z.get(this.db)[g],c.delete(this),F.delete(this),Y.delete(this),delete this.parameterCount,delete this.db,T}},clearBindings:function(){return Z(d(this),"clearBindings()"),r.sqlite3_clear_bindings(this.pointer),Y.delete(this),this},reset:function(g){Z(this,"reset()"),g&&this.clearBindings();const T=r.sqlite3_reset(d(this).pointer);return Y.delete(this),S(this.db,T),this},bind:function(){d(this);let g,T;switch(arguments.length){case 1:g=1,T=arguments[0];break;case 2:g=arguments[0],T=arguments[1];break;default:n("Invalid bind() arguments.")}return T===void 0?this:(this.parameterCount||n("This statement has no bindable parameters."),Y.delete(this),T===null?ee(this,g,y.null,T):Array.isArray(T)?(arguments.length!==1&&n("When binding an array, an index argument is not permitted."),T.forEach((l,_)=>ee(this,_+1,L(l),l)),this):(T instanceof ArrayBuffer&&(T=new Uint8Array(T)),typeof T=="object"&&!u.isBindableTypedArray(T)?(arguments.length!==1&&n("When binding an object, an index argument is not permitted."),Object.keys(T).forEach(l=>ee(this,l,L(T[l]),T[l])),this):ee(this,g,L(T),T)))},bindAsBlob:function(g,T){d(this),arguments.length===1&&(T=g,g=1);const l=L(T);return y.string!==l&&y.blob!==l&&y.null!==l&&n("Invalid value type for bindAsBlob()"),ee(this,g,y.blob,T)},step:function(){Z(this,"step()");const g=r.sqlite3_step(d(this).pointer);switch(g){case r.SQLITE_DONE:return Y.delete(this),!1;case r.SQLITE_ROW:return Y.add(this),!0;default:Y.delete(this),i.config.warn("sqlite3_step() rc=",g,r.sqlite3_js_rc_str(g),"SQL =",r.sqlite3_sql(this.pointer)),U.checkRc(this.db.pointer,g)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{const g=this.step();return this.reset(),g}finally{try{this.finalize()}catch{}}},get:function(g,T){if(Y.has(d(this))||n("Stmt.step() has not (recently) returned true."),Array.isArray(g)){let l=0;const _=this.columnCount;for(;l<_;)g[l]=this.get(l++);return g}else if(g&&typeof g=="object"){let l=0;const _=this.columnCount;for(;l<_;)g[r.sqlite3_column_name(this.pointer,l)]=this.get(l++);return g}switch(W(this,g),T===void 0?r.sqlite3_column_type(this.pointer,g):T){case r.SQLITE_NULL:return null;case r.SQLITE_INTEGER:if(s.bigIntEnabled){const l=r.sqlite3_column_int64(this.pointer,g);return l>=Number.MIN_SAFE_INTEGER&&l<=Number.MAX_SAFE_INTEGER?Number(l).valueOf():l}else{const l=r.sqlite3_column_double(this.pointer,g);return(l>Number.MAX_SAFE_INTEGER||l<Number.MIN_SAFE_INTEGER)&&n("Integer is out of range for JS integer range: "+l),u.isInt32(l)?l|0:l}case r.SQLITE_FLOAT:return r.sqlite3_column_double(this.pointer,g);case r.SQLITE_TEXT:return r.sqlite3_column_text(this.pointer,g);case r.SQLITE_BLOB:{const l=r.sqlite3_column_bytes(this.pointer,g),_=r.sqlite3_column_blob(this.pointer,g),p=new Uint8Array(l);return l&&(p.set(s.heap8u().slice(Number(_),Number(_)+l),0),this.db._blobXfer instanceof Array&&this.db._blobXfer.push(p.buffer)),p}default:n("Don't know how to translate","type of result column #"+g+".")}n("Not reached.")},getInt:function(g){return this.get(g,r.SQLITE_INTEGER)},getFloat:function(g){return this.get(g,r.SQLITE_FLOAT)},getString:function(g){return this.get(g,r.SQLITE_TEXT)},getBlob:function(g){return this.get(g,r.SQLITE_BLOB)},getJSON:function(g){const T=this.get(g,r.SQLITE_STRING);return T===null?T:JSON.parse(T)},getColumnName:function(g){return r.sqlite3_column_name(W(d(this),g).pointer,g)},getColumnNames:function(g=[]){W(d(this),0);const T=this.columnCount;for(let l=0;l<T;++l)g.push(r.sqlite3_column_name(this.pointer,l));return g},getParamIndex:function(g){return d(this).parameterCount?r.sqlite3_bind_parameter_index(this.pointer,g):void 0},getParamName:function(g){return d(this).parameterCount?r.sqlite3_bind_parameter_name(this.pointer,g):void 0},isBusy:function(){return r.sqlite3_stmt_busy(d(this))!==0},isReadOnly:function(){return r.sqlite3_stmt_readonly(d(this))!==0}};{const g={enumerable:!0,get:function(){return c.get(this)},set:()=>n("The pointer property is read-only.")};Object.defineProperty(m.prototype,"pointer",g),Object.defineProperty(U.prototype,"pointer",g)}Object.defineProperty(m.prototype,"columnCount",{enumerable:!1,get:function(){return r.sqlite3_column_count(this.pointer)},set:()=>n("The columnCount property is read-only.")}),Object.defineProperty(m.prototype,"parameterCount",{enumerable:!1,get:function(){return r.sqlite3_bind_parameter_count(this.pointer)},set:()=>n("The parameterCount property is read-only.")}),m.wrapHandle=function(g,T,l=!1){if(!(g instanceof U)||!g.pointer)throw new i.SQLite3Error(i.SQLITE_MISUSE,"First argument must be an opened sqlite3.oo1.DB instance");if(!T||!s.isPtr(T))throw new i.SQLite3Error(i.SQLITE_MISUSE,"Second argument must be a WASM sqlite3_stmt pointer");return new m(g,T,y,!!l)},i.oo1={DB:U,Stmt:m}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const n=i.util;i.initWorker1API=(function(){const r=(...P)=>{throw new Error(P.join(" "))};globalThis.WorkerGlobalScope instanceof Function||r("initWorker1API() must be run from a Worker thread.");const s=this.sqlite3||r("Missing this.sqlite3 object."),u=s.oo1.DB,c=function(P){let N=b.idMap.get(P);return N||(N="db#"+ ++b.idSeq+":"+Math.floor(Math.random()*1e8)+":"+Math.floor(Math.random()*1e8),b.idMap.set(P,N),N)},b={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function(P){const N=new u(P);return this.dbs[c(N)]=N,this.dbList.indexOf(N)<0&&this.dbList.push(N),N},close:function(P,N){if(P){delete this.dbs[c(P)];const U=P.filename,y=n.sqlite3__wasm_db_vfs(P.pointer,0);P.close();const m=this.dbList.indexOf(P);m>=0&&this.dbList.splice(m,1),N&&U&&y&&n.sqlite3__wasm_vfs_unlink(y,U)}},post:function(P,N){N&&N.length?(globalThis.postMessage(P,Array.from(N)),N.length=0):globalThis.postMessage(P)},dbs:Object.create(null),getDb:function(P,N=!0){return this.dbs[P]||(N?r("Unknown (or closed) DB ID:",P):void 0)}},z=function(P=b.dbList[0]){return P&&P.pointer?P:r("DB is not opened.")},O=function(P,N=!0){const U=b.getDb(P.dbId,!1)||b.dbList[0];return N?z(U):U},S=function(){return b.dbList[0]&&c(b.dbList[0])},w={open:function(P){const N=Object.create(null),U=P.args||Object.create(null);U.simulateError&&r("Throwing because of simulateError flag.");const y=Object.create(null);N.vfs=U.vfs,N.filename=U.filename||"";const m=b.open(N);return y.filename=m.filename,y.persistent=!!s.capi.sqlite3_js_db_uses_vfs(m.pointer,"opfs"),y.dbId=c(m),y.vfs=m.dbVfsName(),y},close:function(P){const N=O(P,!1),U={filename:N&&N.filename};if(N){const y=P.args&&typeof P.args=="object"?!!P.args.unlink:!1;b.close(N,y)}return U},exec:function(P){const N=typeof P.args=="string"?{sql:P.args}:P.args||Object.create(null);N.rowMode==="stmt"?r("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API."):N.sql||r("'exec' requires input SQL.");const U=O(P);(N.callback||Array.isArray(N.resultRows))&&(U._blobXfer=b.xfer);const y=N.callback;let m=0;const j=!!N.columnNames;typeof y=="string"&&(j||(N.columnNames=[]),N.callback=function(W,A){b.post({type:y,columnNames:N.columnNames,rowNumber:++m,row:W},b.xfer)});try{const W=N.countChanges?U.changes(!0,N.countChanges===64):void 0;U.exec(N),W!==void 0&&(N.changeCount=U.changes(!0,N.countChanges===64)-W);const A=N.lastInsertRowId?s.capi.sqlite3_last_insert_rowid(U):void 0;A!==void 0&&(N.lastInsertRowId=A),N.callback instanceof Function&&(N.callback=y,b.post({type:y,columnNames:N.columnNames,rowNumber:null,row:void 0}))}finally{delete U._blobXfer,N.callback&&(N.callback=y)}return N},"config-get":function(){const P=Object.create(null),N=s.config;return["bigIntEnabled"].forEach(function(U){Object.getOwnPropertyDescriptor(N,U)&&(P[U]=N[U])}),P.version=s.version,P.vfsList=s.capi.sqlite3_js_vfs_list(),P},export:function(P){const N=O(P),U={byteArray:s.capi.sqlite3_js_db_export(N.pointer),filename:N.filename,mimetype:"application/x-sqlite3"};return b.xfer.push(U.byteArray.buffer),U},toss:function(P){r("Testing worker exception")}};globalThis.onmessage=async function(P){P=P.data;let N,U=P.dbId,y=P.type;const m=performance.now();try{w.hasOwnProperty(y)&&w[y]instanceof Function?N=await w[y](P):r("Unknown db worker message type:",P.type)}catch(j){y="error",N={operation:P.type,message:j.message,errorClass:j.name,input:P},j.stack&&(N.stack=typeof j.stack=="string"?j.stack.split(/\n\s*/):j.stack)}U||(U=N.dbId||S()),b.post({type:y,dbId:U,messageId:P.messageId,workerReceivedTime:m,workerRespondTime:performance.now(),departureTime:P.departureTime,result:N},b.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}).bind({sqlite3:i})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const n=i.wasm,r=i.capi,s=i.util.toss3,u=Object.create(null);i.vfs=u,r.sqlite3_vfs.prototype.registerVfs=function(c=!1){this instanceof i.capi.sqlite3_vfs||s("Expecting a sqlite3_vfs-type argument.");const b=r.sqlite3_vfs_register(this,c?1:0);return b&&s("sqlite3_vfs_register(",this,") failed with rc",b),this.pointer!==r.sqlite3_vfs_find(this.$zName)&&s("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this),this},u.installVfs=function(c){let b=0;const z=["io","vfs"];for(const O of z){const S=c[O];S&&(++b,S.struct.installMethods(S.methods,!!S.applyArgcCheck),O==="vfs"&&(!S.struct.$zName&&typeof S.name=="string"&&S.struct.addOnDispose(S.struct.$zName=n.allocCString(S.name)),S.struct.registerVfs(!!S.asDefault)))}return b||s("Misuse: installVfs() options object requires at least","one of:",z),this}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.wasm.exports.sqlite3_declare_vtab)return;const n=i.wasm,r=i.capi,s=i.util.toss3,u=Object.create(null);i.vtab=u;const c=r.sqlite3_index_info;c.prototype.nthConstraint=function(O,S=!1){if(O<0||O>=this.$nConstraint)return!1;const w=n.ptr.add(this.$aConstraint,c.sqlite3_index_constraint.structInfo.sizeof*O);return S?w:new c.sqlite3_index_constraint(w)},c.prototype.nthConstraintUsage=function(O,S=!1){if(O<0||O>=this.$nConstraint)return!1;const w=n.ptr.add(this.$aConstraintUsage,c.sqlite3_index_constraint_usage.structInfo.sizeof*O);return S?w:new c.sqlite3_index_constraint_usage(w)},c.prototype.nthOrderBy=function(O,S=!1){if(O<0||O>=this.$nOrderBy)return!1;const w=n.ptr.add(this.$aOrderBy,c.sqlite3_index_orderby.structInfo.sizeof*O);return S?w:new c.sqlite3_index_orderby(w)};const b=function(O,S){return(function(w,P=!1){if(arguments.length===0&&(w=new S),w instanceof S)return this.set(w.pointer,w),w;n.isPtr(w)||i.SQLite3Error.toss("Invalid argument to",O+"()");let N=this.get(w);return P&&this.delete(w),N}).bind(new Map)},z=function(O,S){const w=b(O,S);return Object.assign(Object.create(null),{StructType:S,create:P=>{const N=w();return n.pokePtr(P,N.pointer),N},get:P=>w(P),unget:P=>w(P,!0),dispose:P=>w(P,!0)?.dispose?.()})};u.xVtab=z("xVtab",r.sqlite3_vtab),u.xCursor=z("xCursor",r.sqlite3_vtab_cursor),u.xIndexInfo=O=>new r.sqlite3_index_info(O),u.xError=function O(S,w,P){if(O.errorReporter instanceof Function)try{O.errorReporter("sqlite3_module::"+S+"(): "+w.message)}catch{}let N;return w instanceof i.WasmAllocError?N=r.SQLITE_NOMEM:arguments.length>2?N=P:w instanceof i.SQLite3Error&&(N=w.resultCode),N||r.SQLITE_ERROR},u.xError.errorReporter=i.config.error.bind(i.config),u.xRowid=(O,S)=>n.poke(O,S,"i64"),u.setupModule=function(O){let S=!1;const w=this instanceof r.sqlite3_module?this:O.struct||(S=new r.sqlite3_module);try{const P=O.methods||s("Missing 'methods' object.");for(const N of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){const U=N[0],y=N[1];P[U]===!0?P[U]=P[y]:P[y]===!0&&(P[y]=P[U])}if(O.catchExceptions){const N=function(m,j){return["xConnect","xCreate"].indexOf(m)>=0?function(W,A,R,J,d,q){try{return j(...arguments)||0}catch(L){return L instanceof i.WasmAllocError||(n.dealloc(n.peekPtr(q)),n.pokePtr(q,n.allocCString(L.message))),u.xError(m,L)}}:function(...W){try{return j(...W)||0}catch(A){return u.xError(m,A)}}},U=["xCreate","xConnect","xBestIndex","xDisconnect","xDestroy","xOpen","xClose","xFilter","xNext","xEof","xColumn","xRowid","xUpdate","xBegin","xSync","xCommit","xRollback","xFindFunction","xRename","xSavepoint","xRelease","xRollbackTo","xShadowName"],y=Object.create(null);for(const m of U){const j=P[m];if(j instanceof Function)m==="xConnect"&&P.xCreate===j?y[m]=P.xCreate:m==="xCreate"&&P.xConnect===j?y[m]=P.xConnect:y[m]=N(m,j);else continue}w.installMethods(y,!1)}else w.installMethods(P,!!O.applyArgcCheck);if(w.$iVersion===0){let N;typeof O.iVersion=="number"?N=O.iVersion:w.$xIntegrity?N=4:w.$xShadowName?N=3:w.$xSavePoint||w.$xRelease||w.$xRollbackTo?N=2:N=1,w.$iVersion=N}}catch(P){throw S&&S.dispose(),P}return w},r.sqlite3_module.prototype.setupModule=function(O){return u.setupModule.call(this,O)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.kvvfs)return;const n=i.capi,r=n.sqlite3_kvvfs_methods,s=n.KVVfsFile,u=i.capi.sqlite3_vfs_find("kvvfs");if(delete n.sqlite3_kvvfs_methods,delete n.KVVfsFile,!u)return;const c=i.util,b=i.wasm,z=c.toss3,O=new r(b.exports.sqlite3__wasm_kvvfs_methods());c.assert(32<=O.$nKeySize,"unexpected kvvfsMethods.$nKeySize: "+O.$nKeySize);const S=Object.assign(Object.create(null),{rxJournalSuffix:/-journal$/,zKeyJrnl:b.allocCString("jrnl"),zKeySz:b.allocCString("sz"),keySize:O.$nKeySize,buffer:Object.assign(Object.create(null),{n:O.$nBufferSize,pool:Object.create(null)})});S.memBuffer=(x=0)=>S.buffer.pool[x]??=b.alloc(S.buffer.n),S.memBufferFree=x=>{const M=S.buffer.pool[x];M&&(b.dealloc(M),delete S.buffer.pool[x])};const w=()=>{},P=i.__isUnderTest?(...x)=>i.config.debug?.("kvvfs:",...x):w,N=(...x)=>i.config.warn?.("kvvfs:",...x),U=(...x)=>i.config.error?.("kvvfs:",...x);class y{#e=Object.create(null);#i=null;#s=0;constructor(){this.clear()}#t(){return this.#i??=Object.keys(this.#e)}key(M){return M<0||M>=this.#s?null:this.#t()[M]}getItem(M){return this.#e[M]??null}setItem(M,$){M in this.#e||(++this.#s,this.#i=null),this.#e[M]=""+$}removeItem(M){M in this.#e&&(delete this.#e[M],--this.#s,this.#i=null)}clear(){this.#e=Object.create(null),this.#i=null,this.#s=0}get length(){return this.#s}}const m=x=>x==="local"||x==="session",j=x=>m(x)?"kvvfs-"+x+"-":"",W=function(x,M=!1){if(m(x))return;const $=new Blob([x]).size;$||z(n.SQLITE_MISUSE,"Empty name is not permitted.");let K=S.keySize-1;S.rxJournalSuffix.test(x)?M||z(n.SQLITE_MISUSE,"Storage names may not have a '-journal' suffix."):["-wal","-shm"].filter(se=>x.endsWith(se)).length?z(n.SQLITE_MISUSE,"Storage names may not have a -wal or -shm suffix."):K-=8,$>K&&z(n.SQLITE_RANGE,"Storage name is too long. Limit =",K);let ie=0;for(;ie<$;++ie){const se=x.codePointAt(ie);se<32&&z(n.SQLITE_RANGE,"Illegal character ("+se+"d) in storage name:",x)}},A=(x,M=void 0)=>Object.assign(Object.create(null),{jzClass:x,refc:1,deleteAtRefc0:!1,storage:M||new y,keyPrefix:j(x),files:[],listeners:void 0}),R=i.kvvfs=Object.create(null);i.__isUnderTest&&(R.log=Object.assign(Object.create(null),{xOpen:!1,xClose:!1,xWrite:!1,xRead:!1,xSync:!1,xAccess:!1,xFileControl:!1,xRcrdRead:!1,xRcrdWrite:!1,xRcrdDelete:!1}));const J=function(x){const M=S.rxJournalSuffix.test(x.jzClass)?x.jzClass.replace(S.rxJournalSuffix,""):x.jzClass+"-journal";R?.log?.xClose&&P("cleaning up storage handles [",x.jzClass,M,"]",x),delete S.storagePool[x.jzClass],delete S.storagePool[M],i.__isUnderTest||(delete x.storage,delete x.refc)},d=x=>S.storagePool[x.jzClass]=S.storagePool[x.jzClass+"-journal"]=x,q=".";S.storagePool=Object.assign(Object.create(null),{[q]:A(q)}),globalThis.Storage&&(globalThis.localStorage instanceof globalThis.Storage&&(S.storagePool.local=A("local",globalThis.localStorage)),globalThis.sessionStorage instanceof globalThis.Storage&&(S.storagePool.session=A("session",globalThis.sessionStorage))),S.builtinStorageNames=Object.keys(S.storagePool);const L=x=>S.builtinStorageNames.indexOf(x)>-1;for(const x of Object.keys(S.storagePool)){const M=S.storagePool[x];S.storagePool[x+"-journal"]=M}S.setError=(x=void 0,M=n.SQLITE_ERROR)=>x?(S.lastError=x,x.resultCode|0||M):(delete S.lastError,0),S.popError=()=>{const x=S.lastError;return delete S.lastError,x};const Q=x=>{N("kvvfs.listener handler threw:",x)},F=b.exports.sqlite3__wasm_kvvfs_decode,Y=b.exports.sqlite3__wasm_kvvfs_encode,Z=async function(x,M,...$){try{M.keyPrefix&&$[0]&&($[0]=$[0].replace(M.keyPrefix,""));let K,ie,se,oe;for(const le of M.listeners){const pe=Object.create(null);pe.storageName=M.jzClass,pe.type=x,le.decodePages;const we=le.events[x];if(we){if(!le.includeJournal&&$[0]==="jrnl")continue;if(x==="write"&&le.decodePages&&+$[0]>0){if(pe.data=[$[0]],oe?.[$[0]]){pe.data[1]=oe[$[0]];continue}K??=new TextEncoder("utf-8"),ie??=S.memBuffer(10),se??=S.memBuffer(11);const he=K.encode($[1]),me=b.heap8u();me.set(he,Number(ie)),me[b.ptr.addn(ie,he.length)]=0;const Ie=F(ie,se,S.buffer.n);if(Ie>0)oe??=Object.create(null),oe[$[0]]=pe.data[1]=me.slice(Number(se),b.ptr.addn(se,Ie));else continue}else pe.data=$.length?$.length===1?$[0]:$:void 0;try{we(pe)?.catch?.(Q)}catch(he){N("notifyListeners [",M.jzClass,"]",x,he)}}}}catch(K){Q(K)}},ee=x=>typeof x=="string"?S.storagePool[x]:S.storagePool[b.cstrToJs(x)],g=b.exports.sqlite3__wasm_kvvfsMakeKey,T=(x,M,$)=>M&&x.keyPrefix?g(M,$):$,l=(x,M,$)=>b.cstrToJs(T(x,M,$)),_=x=>+x.storage.getItem(x.keyPrefix+"sz"),p=new Map,D={vfs:Object.create(null),ioDb:Object.create(null),ioJrnl:Object.create(null)},B=new n.sqlite3_vfs(O.$pVfs),C=new n.sqlite3_io_methods(O.$pIoDb),h=new n.sqlite3_io_methods(O.$pIoJrnl),E=Object.create(null),V=Object.assign(Object.create(null),{pFileHandles:p,cache:S,storageForZClass:ee,KVVfsStorage:y,disablePageSizeChange:!0});R.log&&(R.internal=V);const G={recordHandler:{xRcrdRead:(x,M,$,K)=>{try{const ie=b.cstrToJs(x),se=ee(ie);if(!se)return-1;const oe=l(se,x,M);R?.log?.xRcrdRead&&N("xRcrdRead",ie,oe,K,se);const le=se.storage.getItem(oe);if(le===null)return-1;const pe=le.length;if(K<=0)return pe;if(K===1)return b.poke($,0),pe;K+1<pe&&z(n.SQLITE_RANGE,"xRcrdRead()",ie,oe,"input buffer is too small: need",pe,"but have",K);const we=S.memBuffer(0),he=b.heap8();let me=0;for(;me<pe;++me)he[b.ptr.add(we,me)]=le.codePointAt(me)&255;return he.copyWithin(Number($),Number(we),b.ptr.addn(we,me)),he[b.ptr.add($,pe)]=0,K}catch(ie){return U("kvrecordRead()",ie),S.setError(ie),-2}},xRcrdWrite:(x,M,$)=>{try{const K=ee(x),ie=l(K,x,M),se=b.cstrToJs($);return R?.log?.xRcrdWrite&&N("xRcrdWrite",ie,K),K.storage.setItem(ie,se),K.listeners&&Z("write",K,ie,se),0}catch(K){return U("kvrecordWrite()",K),S.setError(K,n.SQLITE_IOERR)}},xRcrdDelete:(x,M)=>{try{const $=ee(x),K=l($,x,M);return R?.log?.xRcrdDelete&&N("xRcrdDelete",K,$),$.storage.removeItem(K),$.listeners&&Z("delete",$,K),0}catch($){return U("kvrecordDelete()",$),S.setError($,n.SQLITE_IOERR)}}},vfs:{xOpen:function(x,M,$,K,ie){S.popError();let se;try{M||(se=b.allocCString(""+$+"."+(Math.random()*1e5|0)),M=se);const oe=b.cstrToJs(M);R?.log?.xOpen&&P("xOpen",oe,"flags =",K),W(oe,!0),K&(n.SQLITE_OPEN_MAIN_DB|n.SQLITE_OPEN_TEMP_DB|n.SQLITE_OPEN_TRANSIENT_DB)&&S.rxJournalSuffix.test(oe)&&z(n.SQLITE_ERROR,"DB files may not have a '-journal' suffix.");let le=ee(oe);!le&&!(K&n.SQLITE_OPEN_CREATE)&&z(n.SQLITE_ERROR,"Storage not found:",oe);const pe=D.vfs.xOpen(x,M,$,K,ie);if(pe)return pe;let we=!!(n.SQLITE_OPEN_DELETEONCLOSE&K);b.isPtr(arguments[1])&&n.sqlite3_uri_boolean(M,"delete-on-close",0)&&(we=!0);const he=new s($);if(c.assert(he.$zClass,"Missing f.$zClass"),he.addOnDispose(se),se=void 0,le)++le.refc,le.files.push(he),b.poke32(ie,K);else{b.poke32(ie,K|n.SQLITE_OPEN_CREATE),c.assert(!he.$isJournal,"Opening a journal before its db? "+oe);const me=oe.replace(S.rxJournalSuffix,"");le=A(me),d(le),le.files.push(he),le.deleteAtRefc0=we,R?.log?.xOpen&&P("xOpen installed storage handle [",me,me+"-journal","]",le)}return p.set($,{store:le,file:he,jzClass:oe}),le.listeners&&Z("open",le,le.files.length),0}catch(oe){return N("xOpen:",oe),S.setError(oe)}finally{se&&b.dealloc(se)}},xDelete:function(x,M,$){S.popError();try{const K=b.cstrToJs(M);return S.rxJournalSuffix.test(K)&&E.xRcrdDelete(M,S.zKeyJrnl),0}catch(K){return N("xDelete",K),S.setError(K)}},xAccess:function(x,M,$,K){S.popError();try{const ie=ee(M),se=ie?.jzClass||b.cstrToJs(M);if(R?.log?.xAccess&&P("xAccess",se,"flags =",$,"*pResOut =",b.peek32(K),"store =",ie),!ie)try{W(se)}catch{return b.poke32(K,0),0}if(ie){const oe=ie.keyPrefix+(S.rxJournalSuffix.test(se)?"jrnl":"1"),le=ie.storage.getItem(oe)?0:1;b.poke32(K,le)}else b.poke32(K,0);return 0}catch(ie){return U("xAccess",ie),S.setError(ie)}},xRandomness:function(x,M,$){const K=b.heap8u();let ie=0;const se=Number($);for(;ie<M;++ie)K[se+ie]=Math.random()*255e3&255;return M},xGetLastError:function(x,M,$){const K=S.popError();if(P("xGetLastError",K),K){const ie=b.scopedAllocPush();try{const[se,oe]=b.scopedAllocCString(K.message,!0);return b.cstrncpy($,se,M),oe>M&&b.poke8(b.ptr.add($,M,-1),0),P("set xGetLastError",K.message),K.resultCode|0||n.SQLITE_IOERR}catch{return n.SQLITE_NOMEM}finally{b.scopedAllocPop(ie)}}return 0}},ioDb:{xClose:function(x){S.popError();try{const M=p.get(x);if(R?.log?.xClose&&P("xClose",x,M),M){p.delete(x);const $=M.store;$.files=$.files.filter(K=>K!==M.file),--$.refc<=0&&$.deleteAtRefc0&&J($),D.ioDb.xClose(x),M.file.dispose(),$.listeners&&Z("close",$,$.files.length)}return 0}catch(M){return U("xClose",M),S.setError(M)}},xFileControl:function(x,M,$){S.popError();try{const K=p.get(x);if(c.assert(K,"Missing KVVfsFile handle"),R?.log?.xFileControl&&P("xFileControl",K,"op =",M),M===n.SQLITE_FCNTL_PRAGMA&&V.disablePageSizeChange){const se=b.peekPtr(b.ptr.add($,b.ptr.size));if(b.cstrToJs(se)==="page_size"){R?.log?.xFileControl&&P("xFileControl pragma",b.cstrToJs(se));const oe=b.peekPtr(b.ptr.add($,2*b.ptr.size));if(oe)return R?.log?.xFileControl&&N("xFileControl pragma",K,"NOT setting page size to",b.cstrToJs(oe)),K.file.$szPage=-1,0;if(K.file.$szPage>0)return R?.log?.xFileControl&&N("xFileControl",K,"getting page size",K.file.$szPage),b.pokePtr($,b.allocCString(""+K.file.$szPage)),0}}const ie=D.ioDb.xFileControl(x,M,$);return ie==0&&n.SQLITE_FCNTL_SYNC===M&&K.store.listeners&&Z("sync",K.store,!1),ie}catch(K){return U("xFileControl",K),S.setError(K)}},xSync:function(x,M){S.popError();try{const $=p.get(x);R?.log?.xSync&&P("xSync",$),c.assert($,"Missing KVVfsFile handle");const K=D.ioDb.xSync(x,M);return K==0&&$.store.listeners&&Z("sync",$.store,!0),K}catch($){return U("xSync",$),S.setError($)}}},ioJrnl:{xClose:!0}};try{c.assert(S.buffer.n>132096,"Heap buffer is not large enough");for(const x of Object.entries(G.recordHandler)){const M=x[0],$=x[1];E[M]=$,O[O.memberKey(M)]=b.installFunction(O.memberSignature(M),$)}for(const x of Object.entries(G.vfs)){const M=x[0],$=x[1],K=B.memberKey(M),ie=B.structInfo.members[M]||c.toss("Missing pVfs.structInfo[",M,"]");D.vfs[M]=b.functionEntry(B[K]),B[K]=b.installFunction(ie.signature,$)}for(const x of Object.entries(G.ioDb)){const M=x[0],$=x[1],K=C.memberKey(M);D.ioDb[M]=b.functionEntry(C[K])||c.toss("Missing native pIoDb[",K,"]"),C[K]=b.installFunction(C.memberSignature(M),$)}for(const x of Object.entries(G.ioJrnl)){const M=x[0],$=x[1],K=h.memberKey(M);D.ioJrnl[M]=b.functionEntry(h[K])||c.toss("Missing native pIoJrnl[",K,"]"),$===!0?h[K]=C[K]||c.toss("Missing copied pIoDb[",K,"]"):h[K]=b.installFunction(h.memberSignature(M),$)}}finally{O.dispose(),B.dispose(),C.dispose(),h.dispose()}const re=function x(M){if(M==="")return x("local")+x("session");const $=ee(M);if(!$)return 0;$.files.length&&(globalThis.localStorage===$.storage||globalThis.sessionStorage===$.storage||z(n.SQLITE_ACCESS,"Cannot clear in-use database storage."));const K=$.storage,ie=[];let se,oe=K.length;for(se=0;se<oe;++se){const le=K.key(se);(!$.keyPrefix||le.startsWith($.keyPrefix))&&ie.push(le)}return ie.forEach(le=>K.removeItem(le)),ie.length},ne=function x(M){if(M==="")return x("local")+x("session");const $=ee(M);if(!$)return 0;const K=$.storage;let ie,se=0;for(ie=0;ie<K.length;++ie){const oe=K.key(ie);(!$.keyPrefix||oe.startsWith($.keyPrefix))&&(se+=oe.length,se+=K.getItem(oe).length)}return se*2},de=function(...M){let $;M.length===1&&typeof M[0]=="object"?$=M[0]:M.length&&($=Object.assign(Object.create(null),{name:M[0]}));const K=$?ee($.name):null;K||z(n.SQLITE_NOTFOUND,"There is no kvvfs storage named",$?.name);const ie=K.storage,se=Object.assign(Object.create(null),{name:K.jzClass,timestamp:Date.now(),pages:[]}),oe=Object.create(null),le=K.keyPrefix,pe=le?/^kvvfs-[^-]+-(\w+)/:void 0;let we=0,he=ie.length;for(;we<he;++we){const me=ie.key(we);if(!le||me.startsWith(le)){let Ie=(le?pe.exec(me):void 0)?.[1]??me;switch(Ie){case"jrnl":$.includeJournal&&(se.journal=ie.getItem(me));break;case"sz":se.size=+ie.getItem(me);break;default:if(Ie=+Ie,(!c.isInt32(Ie)||Ie<=0)&&z(n.SQLITE_RANGE,"Malformed kvvfs key: "+me),$.decodePages){const De=ie.getItem(me),Qe=De.length,tt=S.memBuffer(0),Xe=S.memBuffer(1),ct=b.heap8u();let Pe=0;for(;Pe<Qe;++Pe)ct[b.ptr.add(tt,Pe)]=De.codePointAt(Pe)&255;ct[b.ptr.add(tt,Pe)]=0;const mt=F(tt,Xe,S.buffer.n);oe[Ie]=ct.slice(Number(Xe),b.ptr.addn(Xe,mt))}else oe[Ie]=ie.getItem(me)}}}return $.decodePages&&S.memBufferFree(1),Object.keys(oe).map(me=>+me).sort().forEach(me=>se.pages.push(oe[me])),se},ue=function(x,M=!1){!x?.timestamp||!x.name||x.size===void 0||!Array.isArray(x.pages)?z(n.SQLITE_MISUSE,"Malformed export object."):(!x.size||x.size!==(x.size|0)||x.size>=2147483647)&&z(n.SQLITE_RANGE,"Invalid db size: "+x.size),W(x.name);let $=ee(x.name);const K=!$;$?(M?!$.files||!$.jzClass?z(n.SQLITE_ERROR,"Internal storage object",x.name,"seems to be malformed."):$.files.length&&z(n.SQLITE_IOERR_ACCESS,"Cannot import db storage while it is in use."):z(n.SQLITE_ACCESS,"Storage '"+x.name+"' already exists and","overwrite was not specified."),re(x.name)):$=A(x.name);const ie=j(x.name);let se;try{const oe=$.storage;oe.setItem(ie+"sz",x.size),x.journal&&oe.setItem(ie+"jrnl",x.journal),x.pages[0]instanceof Uint8Array?x.pages.forEach((le,pe)=>{const we=le.length;se??=S.memBuffer(1);const he=S.memBuffer(0),me=b.heap8u();me.set(le,Number(he)),me[b.ptr.addn(he,we)]=0;const Ie=Y(he,we,se);c.assert(Ie<S.buffer.n,"Impossibly long output - possibly smashed the heap"),c.assert(b.peek8(b.ptr.add(se,Ie))===0,"Expecting NUL-terminated encoded output");const De=b.cstrToJs(se);oe.setItem(ie+(pe+1),De)}):x.pages[0]&&x.pages.forEach((le,pe)=>oe.setItem(ie+(pe+1),le)),K&&d($)}catch{if(!K)try{re(x.name)}catch{}}finally{se&&S.memBufferFree(1)}return this},Ae=function(x){let M=ee(x);if(M){++M.refc;return}W(x),d(A(x))},Oe=function(x){const M=ee(x);return!M||m(M.jzClass)||L(M.jzClass)||S.rxJournalSuffix.test(x)?!1:M.refc>M.files.length||M.files.length===0?(--M.refc<=0&&J(M),!0):!1},Je=function(x){(!x||typeof x!="object")&&z(n.SQLITE_MISUSE,"Expecting a listener object.");let M=ee(x.storage);M||(x.storage&&x.reserve?(Ae(x.storage),M=ee(x.storage),c.assert(M,"Unexpectedly cannot fetch reserved storage "+x.storage)):z(n.SQLITE_NOTFOUND,"No such storage:",x.storage)),x.events&&(M.listeners??=[]).push(x)},ht=function(x){const M=ee(x?.storage);if(M?.listeners&&x.events){const $=M.listeners.length;M.listeners=M.listeners.filter(ie=>ie!==x);const K=$>M.listeners.length;return M.listeners.length||(M.listeners=void 0),K}return!1};if(i.kvvfs.reserve=Ae,i.kvvfs.import=ue,i.kvvfs.export=de,i.kvvfs.unlink=Oe,i.kvvfs.listen=Je,i.kvvfs.unlisten=ht,i.kvvfs.exists=x=>!!ee(x),i.kvvfs.estimateSize=ne,i.kvvfs.clear=re,globalThis.Storage&&(n.sqlite3_js_kvvfs_size=(x="")=>ne(x),n.sqlite3_js_kvvfs_clear=(x="")=>re(x)),i.oo1?.DB){const x=i.oo1.DB;i.oo1.JsStorageDb=function($=i.oo1.JsStorageDb.defaultStorageName){const K=x.dbCtorHelper.normalizeArgs(...arguments);switch(K.vfs="kvvfs",K.filename){case":sessionStorage:":K.filename="session";break;case":localStorage:":K.filename="local"}const ie=/(file:(\/\/)?)([^?]+)/.exec(K.filename);W(ie?ie[3]:K.filename),x.dbCtorHelper.call(this,K)},i.oo1.JsStorageDb.defaultStorageName=S.storagePool.session?"session":q;const M=i.oo1.JsStorageDb;M.prototype=Object.create(x.prototype),M.clearStorage=re,M.prototype.clearStorage=function(){return M.clearStorage(this.affirmOpen().dbFilename(),!0)},M.storageSize=ne,M.prototype.storageSize=function(){return M.storageSize(this.affirmOpen().dbFilename(),!0)}}if(i.__isUnderTest&&i.vtab){const x=Object.assign(Object.create(null),{rowid:{type:"INTEGER"},name:{type:"TEXT"},nRef:{type:"INTEGER"},nOpen:{type:"INTEGER"},isTransient:{type:"INTEGER"},dbSize:{type:"INTEGER"}});Object.keys(x).forEach((se,oe)=>x[se].colId=oe);const M=i.vtab,$=Object.assign(Object.create(null),{row:function(){return S.storagePool[this.names[this.rowid]]}});Object.assign(Object.create($),{rowid:0,names:Object.keys(S.storagePool).filter(se=>!S.rxJournalSuffix.test(se))});const K=function(se,oe){const le=se instanceof n.sqlite3_vtab_cursor?se:M.xCursor.get(se);return(oe||!le.vTabState)&&(le.vTabState=Object.assign(Object.create($),{rowid:0,names:Object.keys(S.storagePool).filter(pe=>!S.rxJournalSuffix.test(pe))})),le.vTabState},ie=function se(){return se.mod??=new i.capi.sqlite3_module().setupModule({catchExceptions:!0,methods:{xConnect:function(oe,le,pe,we,he,me){try{const Ie=[];Object.keys(x).forEach(Qe=>{Ie.push(Qe+" "+x[Qe].type)});const De=n.sqlite3_declare_vtab(oe,"CREATE TABLE ignored("+Ie.join(",")+")");if(De===0){const Qe=M.xVtab.create(he);c.assert(Qe===M.xVtab.get(b.peekPtr(he)),"output pointer check failed")}return De}catch(Ie){return M.xError("xConnect",Ie,n.SQLITE_ERROR)}},xCreate:b.ptr.null,xDisconnect:function(oe){return M.xVtab.dispose(oe),0},xOpen:function(oe,le){return M.xCursor.create(le),0},xClose:function(oe){const le=M.xCursor.unget(oe);return delete le.vTabState,le.dispose(),0},xNext:function(oe){const le=M.xCursor.get(oe);return++K(le).rowid,0},xColumn:function(oe,le,pe){const we=K(oe),he=we.row();switch(c.assert(he,"Unexpected xColumn call"),pe){case x.rowid.colId:n.sqlite3_result_int(le,we.rowid);break;case x.name.colId:n.sqlite3_result_text(le,he.jzClass,-1,n.SQLITE_TRANSIENT);break;case x.nRef.colId:n.sqlite3_result_int(le,he.refc);break;case x.nOpen.colId:n.sqlite3_result_int(le,he.files.length);break;case x.isTransient.colId:n.sqlite3_result_int(le,!!he.deleteAtRefc0);break;case x.dbSize.colId:n.sqlite3_result_int(le,_(he));break;default:return n.sqlite3_result_error(le,"Invalid column id: "+pe),n.SQLITE_RANGE}return 0},xRowid:function(oe,le){const pe=K(oe);return M.xRowid(le,pe.rowid),0},xEof:function(oe){const le=K(oe);return""+!le.row(),!le.row()},xFilter:function(oe,le,pe,we,he){return K(oe,!0),0},xBestIndex:function(oe,le){const pe=new n.sqlite3_index_info(le);return pe.$estimatedRows=S.storagePool.size,pe.$estimatedCost=1,pe.dispose(),0}}})};i.kvvfs.create_module=function(se,oe="sqlite_kvvfs"){return n.sqlite3_create_module(se,oe,ie(),b.ptr.null)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.opfs&&i.config.disable.vfs["opfs-vfs"])return;const n=i.util.toss;i.capi;const r=i.util;i.wasm;const s=i.opfs=Object.create(null);s.thisThreadHasOPFS=()=>globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory,s.getRootDir=async function c(){return c.promise??=navigator.storage.getDirectory().then(b=>(s.rootDirectory=b,b)).catch(b=>{throw delete c.promise,b})},s.getResolvedPath=function(c,b){const z=new URL(c,"file://irrelevant").pathname;return b?z.split("/").filter(O=>!!O):z},s.getDirForFilename=async function(b,z=!1){const O=s.getResolvedPath(b,!0),S=O.pop();let w=await s.getRootDir();for(const P of O)P&&(w=await w.getDirectoryHandle(P,{create:!!z}));return[w,S]},s.mkdir=async function(c){try{return await s.getDirForFilename(c+"/filepart",!0),!0}catch{return!1}},s.entryExists=async function(c){try{const[b,z]=await s.getDirForFilename(c);return await b.getFileHandle(z),!0}catch{return!1}},s.randomFilename=function c(b=16){c._chars||(c._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789",c._n=c._chars.length);const z=[];let O=0;for(;O<b;++O){const S=Math.random()*(c._n*64)%c._n|0;z[O]=c._chars[S]}return z.join("")},s.treeList=async function(){const c=async function z(O,S){S.name=O.name,S.dirs=[],S.files=[];for await(const w of O.values())if(w.kind==="directory"){const P=Object.create(null);S.dirs.push(P),await z(w,P)}else S.files.push(w.name)},b=Object.create(null);return await c(await s.getRootDir(),b),b},s.rmfr=async function(){const c=await s.getRootDir(),b={recurse:!0};for await(const z of c.values())c.removeEntry(z.name,b)},s.unlink=async function(c,b=!1,z=!1){try{const[O,S]=await s.getDirForFilename(c,!1);return await O.removeEntry(S,{recursive:b}),!0}catch(O){if(z)throw new Error("unlink(",arguments[0],") failed: "+O.message,{cause:O});return!1}},s.traverse=async function(c){const b={recursive:!0,directory:await s.getRootDir()};typeof c=="function"&&(c={callback:c}),c=Object.assign(b,c||{}),(async function z(O,S){for await(const w of O.values()){if(c.callback(w,O,S)===!1)return!1;if(c.recursive&&w.kind==="directory"&&await z(w,S+1)===!1)break}})(c.directory,0)};const u=async function(c,b){const[z,O]=await s.getDirForFilename(c,!0);let S=await(await z.getFileHandle(O,{create:!0})).createSyncAccessHandle(),w=0,P,N=!1;try{for(S.truncate(0);(P=await b())!==void 0;)P instanceof ArrayBuffer&&(P=new Uint8Array(P)),!N&&w===0&&P.byteLength>=15&&(r.affirmDbHeader(P),N=!0),S.write(P,{at:w}),w+=P.byteLength;if((w<512||w%512!==0)&&n("Input size",w,"is not correct for an SQLite database."),!N){const U=new Uint8Array(20);S.read(U,{at:0}),r.affirmDbHeader(U)}return S.write(new Uint8Array([1,1]),{at:18}),w}catch(U){throw await S.close(),S=void 0,await z.removeEntry(O).catch(()=>{}),U}finally{S&&await S.close()}};s.importDb=async function(c,b){if(b instanceof Function)return u(c,b);b instanceof ArrayBuffer&&(b=new Uint8Array(b)),r.affirmIsDb(b);const z=b.byteLength,[O,S]=await s.getDirForFilename(c,!0);let w,P=0;try{return w=await(await O.getFileHandle(S,{create:!0})).createSyncAccessHandle(),w.truncate(0),P=w.write(b,{at:0}),P!=z&&n("Expected to write "+z+" bytes but wrote "+P+"."),w.write(new Uint8Array([1,1]),{at:18}),P}catch(N){throw w&&(await w.close(),w=void 0),await O.removeEntry(S).catch(()=>{}),N}finally{w&&await w.close()}},s.vfsInstallationFeatureCheck=function(c){!globalThis.SharedArrayBuffer||!globalThis.Atomics?n("Cannot install OPFS: Missing SharedArrayBuffer and/or Atomics.","The server must emit the COOP/COEP response headers to enable those.","See https://sqlite.org/wasm/doc/trunk/persistence.md#coop-coep"):typeof WorkerGlobalScope>"u"?n("The OPFS sqlite3_vfs cannot run in the main thread","because it requires Atomics.wait()."):!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle?.prototype?.createSyncAccessHandle||!navigator?.storage?.getDirectory?n("Missing required OPFS APIs."):c==="opfs-wl"&&!globalThis.Atomics.waitAsync&&n("The",c,"VFS requires Atomics.waitAsync(), which is not available.")},s.initOptions=function(b,z){const O=new URL(globalThis.location.href).searchParams;if(!O.has(b+"-disable")){try{s.vfsInstallationFeatureCheck(b)}catch{return}return z=r.nu(z),z.vfsName=b,z.verbose??=O.has("opfs-verbose")?+O.get("opfs-verbose"):1,z.sanityChecks??=O.has("opfs-sanity-check"),s.proxyUri||(s.proxyUri="sqlite3-opfs-async-proxy.js",i.scriptInfo?.sqlite3Dir&&(s.proxyUri=i.scriptInfo.sqlite3Dir+s.proxyUri)),z.proxyUri??=s.proxyUri,typeof z.proxyUri=="function"&&(z.proxyUri=z.proxyUri()),s.options=z}},s.createVfsState=function(){const c=r.nu(),b=s.options;c.verbose=b.verbose;const z=[i.config.error,i.config.warn,i.config.log],O=b.vfsName||n("Maintenance required: missing VFS name"),S=(F,...Y)=>{c.verbose>F&&z[F](O+":",...Y)},w=(...F)=>S(2,...F),P=(...F)=>S(1,...F),N=(...F)=>S(0,...F),U=i.capi,y=i.wasm,m=c.vfs=new U.sqlite3_vfs,j=m.ioMethods=new U.sqlite3_io_methods;j.$iVersion=1,m.$iVersion=2,m.$szOsFile=U.sqlite3_file.structInfo.sizeof,m.$mxPathname=1024,m.$zName=y.allocCString(O),m.addOnDispose("$zName",m.$zName,j),m.metrics=r.nu({counters:r.nu(),dump:function(){let F,Y=0,Z=0,ee=0;for(F in c.opIds){const g=W[F];Y+=g.count,Z+=g.time,ee+=g.wait,g.avgTime=g.count&&g.time?g.time/g.count:0,g.avgWait=g.count&&g.wait?g.wait/g.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",W,`
3
+ Total of`,Y,"op(s) for",Z,"ms (incl. "+ee+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",m.metrics.counters.s11n),m.worker?.postMessage?.({type:"opfs-async-metrics"})},reset:function(){let F;const Y=g=>g.count=g.time=g.wait=0,Z=m.metrics.counters;for(F in c.opIds)Y(Z[F]=Object.create(null));let ee=Z.s11n=Object.create(null);ee=ee.serialize=Object.create(null),ee.count=ee.time=0,ee=Z.s11n.deserialize=Object.create(null),ee.count=ee.time=0}}),c.asyncIdleWaitTime=150,c.asyncS11nExceptions=1,c.fileBufferSize=65536,c.sabS11nOffset=c.fileBufferSize,c.sabS11nSize=m.$mxPathname*2,c.sabIO=new SharedArrayBuffer(c.fileBufferSize+c.sabS11nSize),c.opIds=Object.create(null);{let F=0;c.opIds.whichOp=F++,c.opIds.rc=F++,c.opIds.xAccess=F++,c.opIds.xClose=F++,c.opIds.xDelete=F++,c.opIds.xDeleteNoWait=F++,c.opIds.xFileSize=F++,c.opIds.xLock=F++,c.opIds.xOpen=F++,c.opIds.xRead=F++,c.opIds.xSleep=F++,c.opIds.xSync=F++,c.opIds.xTruncate=F++,c.opIds.xUnlock=F++,c.opIds.xWrite=F++,c.opIds.mkdir=F++,c.opIds["opfs-async-metrics"]=F++,c.opIds["opfs-async-shutdown"]=F++,c.opIds.retry=F++,c.sabOP=new SharedArrayBuffer(F*4)}c.sq3Codes=Object.create(null);for(const F of["SQLITE_ACCESS_EXISTS","SQLITE_ACCESS_READWRITE","SQLITE_BUSY","SQLITE_CANTOPEN","SQLITE_ERROR","SQLITE_IOERR","SQLITE_IOERR_ACCESS","SQLITE_IOERR_CLOSE","SQLITE_IOERR_DELETE","SQLITE_IOERR_FSYNC","SQLITE_IOERR_LOCK","SQLITE_IOERR_READ","SQLITE_IOERR_SHORT_READ","SQLITE_IOERR_TRUNCATE","SQLITE_IOERR_UNLOCK","SQLITE_IOERR_WRITE","SQLITE_LOCK_EXCLUSIVE","SQLITE_LOCK_NONE","SQLITE_LOCK_PENDING","SQLITE_LOCK_RESERVED","SQLITE_LOCK_SHARED","SQLITE_LOCKED","SQLITE_MISUSE","SQLITE_NOTFOUND","SQLITE_OPEN_CREATE","SQLITE_OPEN_DELETEONCLOSE","SQLITE_OPEN_MAIN_DB","SQLITE_OPEN_READONLY","SQLITE_LOCK_NONE","SQLITE_LOCK_SHARED","SQLITE_LOCK_RESERVED","SQLITE_LOCK_PENDING","SQLITE_LOCK_EXCLUSIVE"])c.sq3Codes[F]=U[F]??n("Maintenance required: not found:",F);c.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1}),m.metrics.reset();const W=m.metrics.counters,A=m.opRun=(F,...Y)=>{const Z=c.opIds[F]||n(m.vfsName+": Invalid op ID:",F);c.s11n.serialize(...Y),Atomics.store(c.sabOPView,c.opIds.rc,-1),Atomics.store(c.sabOPView,c.opIds.whichOp,Z),Atomics.notify(c.sabOPView,c.opIds.whichOp);const ee=performance.now();for(;Atomics.wait(c.sabOPView,c.opIds.rc,-1)!=="not-equal";);const g=Atomics.load(c.sabOPView,c.opIds.rc);if(W[F].wait+=performance.now()-ee,g&&c.asyncS11nExceptions){const T=c.s11n.deserialize();T&&N(F+"() async error:",...T)}return g},R=Object.create(null);R.op=void 0,R.start=void 0;const J=m.mTimeStart=F=>{R.start=performance.now(),R.op=F,++W[F].count},d=m.mTimeEnd=()=>W[R.op].time+=performance.now()-R.start,q=m.__openFiles=Object.create(null);m.ioSyncWrappers=r.nu({xCheckReservedLock:function(F,Y){return y.poke(Y,0,"i32"),0},xClose:function(F){J("xClose");let Y=0;const Z=q[F];return Z&&(delete q[F],Y=A("xClose",F),Z.sq3File&&Z.sq3File.dispose()),d(),Y},xDeviceCharacteristics:function(F){return U.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(F,Y,Z){return U.SQLITE_NOTFOUND},xFileSize:function(F,Y){J("xFileSize");let Z=A("xFileSize",F);if(Z==0)try{const ee=c.s11n.deserialize()[0];y.poke(Y,ee,"i64")}catch(ee){N("Unexpected error reading xFileSize() result:",ee),Z=c.sq3Codes.SQLITE_IOERR}return d(),Z},xRead:function(F,Y,Z,ee){J("xRead");const g=q[F];let T;try{T=A("xRead",F,Z,Number(ee)),(T===0||U.SQLITE_IOERR_SHORT_READ===T)&&y.heap8u().set(g.sabView.subarray(0,Z),Number(Y))}catch(l){N("xRead(",arguments,") failed:",l,g),T=U.SQLITE_IOERR_READ}return d(),T},xSync:function(F,Y){J("xSync");const Z=A("xSync",F,Y);return d(),Z},xTruncate:function(F,Y){J("xTruncate");const Z=A("xTruncate",F,Number(Y));return d(),Z},xWrite:function(F,Y,Z,ee){J("xWrite");const g=q[F];let T;try{g.sabView.set(y.heap8u().subarray(Number(Y),Number(Y)+Z)),T=A("xWrite",F,Z,Number(ee))}catch(l){N("xWrite(",arguments,") failed:",l,g),T=U.SQLITE_IOERR_WRITE}return d(),T}}),m.vfsSyncWrappers={xAccess:function(F,Y,Z,ee){J("xAccess");const g=A("xAccess",y.cstrToJs(Y));return y.poke(ee,g?0:1,"i32"),d(),0},xCurrentTime:function(F,Y){return y.poke(Y,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(F,Y){return y.poke(Y,21086676e7+new Date().getTime(),"i64"),0},xDelete:function(F,Y,Z){J("xDelete");const ee=A("xDelete",y.cstrToJs(Y),Z,!1);return d(),ee},xFullPathname:function(F,Y,Z,ee){return y.cstrncpy(ee,Y,Z)<Z?0:U.SQLITE_CANTOPEN},xGetLastError:function(F,Y,Z){return i.config.warn("OPFS xGetLastError() has nothing sensible to return."),0},xOpen:function(Y,Z,ee,g,T){J("xOpen");let l=0,_,p;if(!Z)_=s.randomFilename(),Z=p=y.allocCString(_);else if(y.isPtr(Z))U.sqlite3_uri_boolean(Z,"opfs-unlock-asap",0)&&(l|=c.opfsFlags.OPFS_UNLOCK_ASAP),U.sqlite3_uri_boolean(Z,"delete-before-open",0)&&(l|=c.opfsFlags.OPFS_UNLINK_BEFORE_OPEN),_=y.cstrToJs(Z);else return i.config.error("Impossible zName value in xOpen?",Z),U.SQLITE_CANTOPEN;const D=r.nu({fid:ee,filename:_,sab:new SharedArrayBuffer(c.fileBufferSize),flags:g,readOnly:!(U.SQLITE_OPEN_CREATE&g)&&!!(g&U.SQLITE_OPEN_READONLY)}),B=A("xOpen",ee,_,g,l);return B?p&&y.dealloc(p):(D.readOnly&&y.poke(T,U.SQLITE_OPEN_READONLY,"i32"),q[ee]=D,D.sabView=c.sabFileBufView,D.sq3File=new U.sqlite3_file(ee),p&&D.sq3File.addOnDispose(p),D.sq3File.$pMethods=j.pointer,D.lockType=U.SQLITE_LOCK_NONE),d(),B}};const L=U.sqlite3_vfs_find(null);if(L){const F=new U.sqlite3_vfs(L);m.$xRandomness=F.$xRandomness,m.$xSleep=F.$xSleep,F.dispose()}m.$xRandomness||(m.vfsSyncWrappers.xRandomness=function(F,Y,Z){const ee=y.heap8u();let g=0;const T=Number(Z);for(;g<Y;++g)ee[T+g]=Math.random()*255e3&255;return g}),m.$xSleep||(m.vfsSyncWrappers.xSleep=function(F,Y){return J("xSleep"),Atomics.wait(c.sabOPView,c.opIds.xSleep,0,Y),d(),0});const Q=function(){if(c.s11n)return c.s11n;const F=new TextDecoder,Y=new TextEncoder("utf-8"),Z=new Uint8Array(c.sabIO,c.sabS11nOffset,c.sabS11nSize),ee=new DataView(c.sabIO,c.sabS11nOffset,c.sabS11nSize);c.s11n=Object.create(null);const g=Object.create(null);g.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},g.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},g.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},g.string={id:4};const T=_=>g[typeof _]||n("Maintenance required: this value type cannot be serialized.",_),l=_=>{switch(_){case g.number.id:return g.number;case g.bigint.id:return g.bigint;case g.boolean.id:return g.boolean;case g.string.id:return g.string;default:n("Invalid type ID:",_)}};return c.s11n.deserialize=function(_=!1){performance.now();const p=Z[0],D=p?[]:null;if(p){const B=[];let C=1,h,E,V;for(h=0;h<p;++h,++C)B.push(l(Z[C]));for(h=0;h<p;++h){const G=B[h];G.getter?(V=ee[G.getter](C,c.littleEndian),C+=G.size):(E=ee.getInt32(C,c.littleEndian),C+=4,V=F.decode(Z.slice(C,C+E)),C+=E),D.push(V)}}return _&&(Z[0]=0),D},c.s11n.serialize=function(..._){if(performance.now(),_.length){const p=[];let D=0,B=1;for(Z[0]=_.length&255;D<_.length;++D,++B)p.push(T(_[D])),Z[B]=p[D].id;for(D=0;D<_.length;++D){const C=p[D];if(C.setter)ee[C.setter](B,_[D],c.littleEndian),B+=C.size;else{const h=Y.encode(_[D]);ee.setInt32(B,h.byteLength,c.littleEndian),B+=4,Z.set(h,B),B+=h.byteLength}}}else Z[0]=0},c.s11n};return m.initS11n=Q,m.bindVfs=function(F,Y){return Object.assign(m.ioSyncWrappers,F),new Promise(function(Z,ee){let g;const T=h=>(g=!0,m.dispose(),ee(h)),l=()=>{try{Y(i,m)}catch(h){return T(h)}return g=!1,Z(i)},_=s.options,p=_.proxyUri+(_.proxyUri.indexOf("?")<0?"?":"&")+"vfs="+O,D=m.worker=new Worker(new URL(p,import.meta.url));let B=setTimeout(()=>{g===void 0&&T(new Error("Timeout while waiting for OPFS async proxy worker."))},4e3);D._originalOnError=D.onerror,D.onerror=function(h){N("Error initializing OPFS asyncer:",h),T(new Error("Loading OPFS async Worker failed for unknown reasons."))},m.opRun;const C=function(){const h=y.scopedAllocPush(),E=new U.sqlite3_file;try{const V=E.pointer,G=U.SQLITE_OPEN_CREATE|U.SQLITE_OPEN_READWRITE|U.SQLITE_OPEN_MAIN_DB,re=y.scopedAlloc(8),ne="/sanity/check/file"+randomFilename(8),de=y.scopedAllocCString(ne);let ue;if(c.s11n.serialize("This is ä string."),ue=c.s11n.deserialize(),w("deserialize() says:",ue),ue[0]!=="This is ä string."&&n("String d13n error."),m.vfsSyncWrappers.xAccess(m.pointer,de,0,re),ue=y.peek(re,"i32"),w("xAccess(",ne,") exists ?=",ue),ue=m.vfsSyncWrappers.xOpen(m.pointer,de,V,G,re),w("open rc =",ue,"state.sabOPView[xOpen] =",c.sabOPView[c.opIds.xOpen]),ue!==0){N("open failed with code",ue);return}m.vfsSyncWrappers.xAccess(m.pointer,de,0,re),ue=y.peek(re,"i32"),ue||n("xAccess() failed to detect file."),ue=m.ioSyncWrappers.xSync(E.pointer,0),ue&&n("sync failed w/ rc",ue),ue=m.ioSyncWrappers.xTruncate(E.pointer,1024),ue&&n("truncate failed w/ rc",ue),y.poke(re,0,"i64"),ue=m.ioSyncWrappers.xFileSize(E.pointer,re),ue&&n("xFileSize failed w/ rc",ue),w("xFileSize says:",y.peek(re,"i64")),ue=m.ioSyncWrappers.xWrite(E.pointer,de,10,1),ue&&n("xWrite() failed!");const Ae=y.scopedAlloc(16);ue=m.ioSyncWrappers.xRead(E.pointer,Ae,6,2),y.poke(Ae+6,0);let Oe=y.cstrToJs(Ae);w("xRead() got:",Oe),Oe!=="sanity"&&n("Unexpected xRead() value."),m.vfsSyncWrappers.xSleep&&(w("xSleep()ing before close()ing..."),m.vfsSyncWrappers.xSleep(m.pointer,2e3),w("waking up from xSleep()")),ue=m.ioSyncWrappers.xClose(V),w("xClose rc =",ue,"sabOPView =",c.sabOPView),w("Deleting file:",ne),m.vfsSyncWrappers.xDelete(m.pointer,de,4660),m.vfsSyncWrappers.xAccess(m.pointer,de,0,re),ue=y.peek(re,"i32"),ue&&n("Expecting 0 from xAccess(",ne,") after xDelete()."),P("End of OPFS sanity checks.")}finally{E.dispose(),y.scopedAllocPop(h)}};D.onmessage=function({data:h}){switch(h.type){case"opfs-unavailable":T(new Error(h.payload.join(" ")));break;case"opfs-async-loaded":delete c.vfs,D.postMessage({type:"opfs-async-init",args:r.nu(c)});break;case"opfs-async-inited":if(g===!0)break;clearTimeout(B),B=null;try{i.vfs.installVfs({io:{struct:m.ioMethods,methods:m.ioSyncWrappers},vfs:{struct:m,methods:m.vfsSyncWrappers}}),c.sabOPView=new Int32Array(c.sabOP),c.sabFileBufView=new Uint8Array(c.sabIO,0,c.fileBufferSize),c.sabS11nView=new Uint8Array(c.sabIO,c.sabS11nOffset,c.sabS11nSize),m.initS11n(),delete m.initS11n,_.sanityChecks&&(P("Running sanity checks because of opfs-sanity-check URL arg..."),C()),s.thisThreadHasOPFS()?s.getRootDir().then(E=>{D.onerror=D._originalOnError,delete D._originalOnError,w("End of OPFS sqlite3_vfs setup.",m),l()}).catch(T):l()}catch(E){N(E),T(E)}break;case"debug":P("debug message from worker:",h);break;default:{const E="Unexpected message from the OPFS async worker: "+JSON.stringify(h);N(E),T(new Error(E));break}}}})},c}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.opfs)return;const n=i.util,r=i.opfs||i.util.toss("Missing sqlite3.opfs"),s=async function(u){if(u=r.initOptions("opfs",u),!u)return i;const c=i.capi,b=r.createVfsState().vfs,z=b.metrics.counters,O=b.mTimeStart,S=b.mTimeEnd,w=b.opRun,P=b.__openFiles;return b.bindVfs(n.nu({xLock:function(N,U){O("xLock"),++z.xLock.count;const y=P[N];let m=0;return y.lockType?y.lockType=U:(m=w("xLock",N,U),m===0&&(y.lockType=U)),S(),m},xUnlock:function(N,U){O("xUnlock"),++z.xUnlock.count;const y=P[N];let m=0;return c.SQLITE_LOCK_NONE===U&&y.lockType&&(m=w("xUnlock",N,U)),m===0&&(y.lockType=U),S(),m}}),function(N,U){if(N.oo1){const y=function(...m){const j=N.oo1.DB.dbCtorHelper.normalizeArgs(...m);j.vfs=U.$zName,N.oo1.DB.dbCtorHelper.call(this,j)};y.prototype=Object.create(N.oo1.DB.prototype),N.oo1.OpfsDb=y,y.importDb=r.importDb,N.oo1.DB.dbCtorHelper.setVfsPostOpenCallback(b.pointer,function(m,j){j.capi.sqlite3_busy_timeout(m,1e4)})}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async u=>s().catch(c=>{u.config.warn("Ignoring inability to install 'opfs' sqlite3_vfs:",c)}))}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.["opfs-sahpool"])return;const n=i.util.toss,r=i.util.toss3,s=Object.create(null),u=i.capi,c=i.util,b=i.wasm,z=4096,O=512,S=8,w=516,P=O,N=w,U=z,y=u.SQLITE_OPEN_MAIN_DB|u.SQLITE_OPEN_MAIN_JOURNAL|u.SQLITE_OPEN_SUPER_JOURNAL|u.SQLITE_OPEN_WAL,m=u.SQLITE_OPEN_MEMORY,j=".opaque",W=()=>Math.random().toString(36).slice(2),A=new TextDecoder,R=new TextEncoder,J=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2,forceReinitIfPreviouslyFailed:!1}),d=[i.config.error,i.config.warn,i.config.log];i.config.log;const q=i.config.warn;i.config.error;const L=new Map,Q=C=>L.get(C),F=(C,h)=>{h?L.set(C,h):L.delete(C)},Y=new Map,Z=C=>Y.get(C),ee=(C,h)=>{h?Y.set(C,h):Y.delete(C)},g={xCheckReservedLock:function(C,h){const E=Z(C);return E.log("xCheckReservedLock"),E.storeErr(),b.poke32(h,1),0},xClose:function(C){const h=Z(C);h.storeErr();const E=h.getOFileForS3File(C);if(E)try{h.log(`xClose ${E.path}`),h.mapS3FileToOFile(C,!1),E.sah.flush(),E.flags&u.SQLITE_OPEN_DELETEONCLOSE&&h.deletePath(E.path)}catch(V){return h.storeErr(V,u.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(C){return u.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(C,h,E){return u.SQLITE_NOTFOUND},xFileSize:function(C,h){const E=Z(C);E.log("xFileSize");const V=E.getOFileForS3File(C).sah.getSize()-U;return b.poke64(h,BigInt(V)),0},xLock:function(C,h){const E=Z(C);E.log(`xLock ${h}`),E.storeErr();const V=E.getOFileForS3File(C);return V.lockType=h,0},xRead:function(C,h,E,V){const G=Z(C);G.storeErr();const re=G.getOFileForS3File(C);G.log(`xRead ${re.path} ${E} @ ${V}`);try{const ne=re.sah.read(b.heap8u().subarray(Number(h),Number(h)+E),{at:U+Number(V)});return ne<E?(b.heap8u().fill(0,Number(h)+ne,Number(h)+E),u.SQLITE_IOERR_SHORT_READ):0}catch(ne){return G.storeErr(ne,u.SQLITE_IOERR)}},xSectorSize:function(C){return z},xSync:function(C,h){const E=Z(C);E.log(`xSync ${h}`),E.storeErr();const V=E.getOFileForS3File(C);try{return V.sah.flush(),0}catch(G){return E.storeErr(G,u.SQLITE_IOERR)}},xTruncate:function(C,h){const E=Z(C);E.log(`xTruncate ${h}`),E.storeErr();const V=E.getOFileForS3File(C);try{return V.sah.truncate(U+Number(h)),0}catch(G){return E.storeErr(G,u.SQLITE_IOERR)}},xUnlock:function(C,h){const E=Z(C);E.log("xUnlock");const V=E.getOFileForS3File(C);return V.lockType=h,0},xWrite:function(C,h,E,V){const G=Z(C);G.storeErr();const re=G.getOFileForS3File(C);G.log(`xWrite ${re.path} ${E} ${V}`);try{return E===re.sah.write(b.heap8u().subarray(Number(h),Number(h)+E),{at:U+Number(V)})?0:n("Unknown write() failure.")}catch(ne){return G.storeErr(ne,u.SQLITE_IOERR)}}},T=new u.sqlite3_io_methods;T.$iVersion=1,i.vfs.installVfs({io:{struct:T,methods:g}});const l={xAccess:function(C,h,E,V){const G=Q(C);G.storeErr();try{const re=G.getPath(h);b.poke32(V,G.hasFilename(re)?1:0)}catch{b.poke32(V,0)}return 0},xCurrentTime:function(C,h){return b.poke(h,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(C,h){return b.poke(h,21086676e7+new Date().getTime(),"i64"),0},xDelete:function(C,h,E){const V=Q(C);V.log(`xDelete ${b.cstrToJs(h)}`),V.storeErr();try{return V.deletePath(V.getPath(h)),0}catch(G){return V.storeErr(G),u.SQLITE_IOERR_DELETE}},xFullPathname:function(C,h,E,V){return b.cstrncpy(V,h,E)<E?0:u.SQLITE_CANTOPEN},xGetLastError:function(C,h,E){const V=Q(C),G=V.popErr();if(V.log(`xGetLastError ${h} e =`,G),G){const re=b.scopedAllocPush();try{const[ne,de]=b.scopedAllocCString(G.message,!0);b.cstrncpy(E,ne,h),de>h&&b.poke8(b.ptr.add(E,h,-1),0)}catch{return u.SQLITE_NOMEM}finally{b.scopedAllocPop(re)}}return G?G.sqlite3Rc||u.SQLITE_IOERR:0},xOpen:function(h,E,V,G,re){const ne=Q(h);try{G&=~m,ne.log(`xOpen ${b.cstrToJs(E)} ${G}`);const de=E&&b.peek8(E)?ne.getPath(E):W();let ue=ne.getSAHForPath(de);!ue&&G&u.SQLITE_OPEN_CREATE&&(ne.getFileCount()<ne.getCapacity()?(ue=ne.nextAvailableSAH(),ne.setAssociatedPath(ue,de,G)):n("SAH pool is full. Cannot create file",de)),ue||n("file not found:",de);const Ae={path:de,flags:G,sah:ue};ne.mapS3FileToOFile(V,Ae),Ae.lockType=u.SQLITE_LOCK_NONE;const Oe=new u.sqlite3_file(V);return Oe.$pMethods=T.pointer,Oe.dispose(),b.poke32(re,G),0}catch(de){return ne.storeErr(de),u.SQLITE_CANTOPEN}}},_=function(C){i.capi.sqlite3_vfs_find(C)&&r("VFS name is already registered:",C);const h=new u.sqlite3_vfs,E=u.sqlite3_vfs_find(null),V=E?new u.sqlite3_vfs(E):null;return h.$iVersion=2,h.$szOsFile=u.sqlite3_file.structInfo.sizeof,h.$mxPathname=O,h.addOnDispose(h.$zName=b.allocCString(C),()=>F(h.pointer,0)),V&&(h.$xRandomness=V.$xRandomness,h.$xSleep=V.$xSleep,V.dispose()),!h.$xRandomness&&!l.xRandomness&&(l.xRandomness=function(G,re,ne){const de=b.heap8u();let ue=0;const Ae=Number(ne);for(;ue<re;++ue)de[Ae+ue]=Math.random()*255e3&255;return ue}),!h.$xSleep&&!l.xSleep&&(l.xSleep=(G,re)=>0),i.vfs.installVfs({vfs:{struct:h,methods:l}}),h};class p{vfsDir;#e;#i;#s;#t=new Map;#n=new Map;#o=new Set;#a=new Map;#r=new Uint8Array(w);#c;#l;#_;constructor(h=Object.create(null)){this.#_=h.verbosity??J.verbosity,this.vfsName=h.name||J.name,this.#l=_(this.vfsName),F(this.#l.pointer,this),this.vfsDir=h.directory||"."+this.vfsName,this.#c=new DataView(this.#r.buffer,this.#r.byteOffset),this.isReady=this.reset(!!(h.clearOnInit??J.clearOnInit)).then(()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(h.initialCapacity||J.initialCapacity)})}#u(h,...E){this.#_>h&&d[h](this.vfsName+":",...E)}log(...h){this.#u(2,...h)}warn(...h){this.#u(1,...h)}error(...h){this.#u(0,...h)}getVfs(){return this.#l}getCapacity(){return this.#t.size}getFileCount(){return this.#n.size}getFileNames(){const h=[];for(const E of this.#n.keys())h.push(E);return h}async addCapacity(h){for(let E=0;E<h;++E){const V=W(),G=await(await this.#i.getFileHandle(V,{create:!0})).createSyncAccessHandle();this.#t.set(G,V),this.setAssociatedPath(G,"",0)}return this.getCapacity()}async reduceCapacity(h){let E=0;for(const V of Array.from(this.#o)){if(E===h||this.getFileCount()===this.getCapacity())break;const G=this.#t.get(V);V.close(),await this.#i.removeEntry(G),this.#t.delete(V),this.#o.delete(V),++E}return E}releaseAccessHandles(){for(const h of this.#t.keys())h.close();this.#t.clear(),this.#n.clear(),this.#o.clear()}async acquireAccessHandles(h=!1){const E=[];for await(const[V,G]of this.#i)G.kind==="file"&&E.push([V,G]);return Promise.all(E.map(async([V,G])=>{try{const re=await G.createSyncAccessHandle();if(this.#t.set(re,V),h)re.truncate(U),this.setAssociatedPath(re,"",0);else{const ne=this.getAssociatedPath(re);ne?this.#n.set(ne,re):this.#o.add(re)}}catch(re){throw this.storeErr(re),this.releaseAccessHandles(),re}}))}getAssociatedPath(h){h.read(this.#r,{at:0});const E=this.#c.getUint32(P);if(this.#r[0]&&(E&u.SQLITE_OPEN_DELETEONCLOSE||(E&y)===0))return q(`Removing file with unexpected flags ${E.toString(16)}`,this.#r),this.setAssociatedPath(h,"",0),"";const V=new Uint32Array(S/4);h.read(V,{at:N});const G=this.computeDigest(this.#r,E);if(V.every((re,ne)=>re===G[ne])){const re=this.#r.findIndex(ne=>ne===0);return re===0&&h.truncate(U),re?A.decode(this.#r.subarray(0,re)):""}else return q("Disassociating file with bad digest."),this.setAssociatedPath(h,"",0),""}setAssociatedPath(h,E,V){const G=R.encodeInto(E,this.#r);O<=G.written+1&&n("Path too long:",E),E&&V&&(V|=m),this.#r.fill(0,G.written,O),this.#c.setUint32(P,V);const re=this.computeDigest(this.#r,V);h.write(this.#r,{at:0}),h.write(re,{at:N}),h.flush(),E?(this.#n.set(E,h),this.#o.delete(h)):(h.truncate(U),this.#o.add(h))}computeDigest(h,E){if(E&m){let V=3735928559,G=1103547991;for(const re of h)V=Math.imul(V^re,2654435761),G=Math.imul(G^re,104729);return new Uint32Array([V>>>0,G>>>0])}else return new Uint32Array([0,0])}async reset(h){await this.isReady;let E=await navigator.storage.getDirectory(),V;for(const G of this.vfsDir.split("/"))G&&(V=E,E=await E.getDirectoryHandle(G,{create:!0}));return this.#e=E,this.#s=V,this.#i=await this.#e.getDirectoryHandle(j,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(h)}getPath(h){return b.isPtr(h)&&(h=b.cstrToJs(h)),(h instanceof URL?h:new URL(h,"file://localhost/")).pathname}deletePath(h){const E=this.#n.get(h);return E&&(this.#n.delete(h),this.setAssociatedPath(E,"",0)),!!E}storeErr(h,E){return h&&(h.sqlite3Rc=E||u.SQLITE_IOERR,this.error(h)),this.$error=h,E}popErr(){const h=this.$error;return this.$error=void 0,h}nextAvailableSAH(){const[h]=this.#o.keys();return h}getOFileForS3File(h){return this.#a.get(h)}mapS3FileToOFile(h,E){E?(this.#a.set(h,E),ee(h,this)):(this.#a.delete(h),ee(h,!1))}hasFilename(h){return this.#n.has(h)}getSAHForPath(h){return this.#n.get(h)}async removeVfs(){if(!this.#l.pointer||!this.#i)return!1;u.sqlite3_vfs_unregister(this.#l.pointer),this.#l.dispose(),delete s[this.vfsName];try{this.releaseAccessHandles(),await this.#e.removeEntry(j,{recursive:!0}),this.#i=void 0,await this.#s.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#s=void 0}catch(h){i.config.error(this.vfsName,"removeVfs() failed with no recovery strategy:",h)}return!0}pauseVfs(){return this.#a.size>0&&i.SQLite3Error.toss(u.SQLITE_MISUSE,"Cannot pause VFS",this.vfsName,"because it has opened files."),this.#t.size>0&&(u.sqlite3_vfs_unregister(this.vfsName),this.releaseAccessHandles()),this}isPaused(){return this.#t.size===0}async unpauseVfs(){return this.#t.size===0?this.acquireAccessHandles(!1).then(()=>u.sqlite3_vfs_register(this.#l,0),this):this}exportFile(h){const E=this.#n.get(h)||n("File not found:",h),V=E.getSize()-U,G=new Uint8Array(V>0?V:0);if(V>0){const re=E.read(G,{at:U});re!=V&&n("Expected to read "+V+" bytes but read "+re+".")}return G}async importDbChunked(h,E){const V=this.#n.get(h)||this.nextAvailableSAH()||n("No available handles to import to.");V.truncate(0);let G=0,re,ne=!1;try{for(;(re=await E())!==void 0;)re instanceof ArrayBuffer&&(re=new Uint8Array(re)),!ne&&G===0&&re.byteLength>=15&&(c.affirmDbHeader(re),ne=!0),V.write(re,{at:U+G}),G+=re.byteLength;if((G<512||G%512!==0)&&n("Input size",G,"is not correct for an SQLite database."),!ne){const de=new Uint8Array(20);V.read(de,{at:0}),c.affirmDbHeader(de)}V.write(new Uint8Array([1,1]),{at:4114})}catch(de){throw this.setAssociatedPath(V,"",0),de}return this.setAssociatedPath(V,h,u.SQLITE_OPEN_MAIN_DB),G}importDb(h,E){if(E instanceof ArrayBuffer)E=new Uint8Array(E);else if(E instanceof Function)return this.importDbChunked(h,E);const V=this.#n.get(h)||this.nextAvailableSAH()||n("No available handles to import to."),G=E.byteLength;(G<512||G%512!=0)&&n("Byte array size is invalid for an SQLite db.");const re="SQLite format 3";for(let de=0;de<15;++de)re.charCodeAt(de)!==E[de]&&n("Input does not contain an SQLite database header.");const ne=V.write(E,{at:U});return ne!=G?(this.setAssociatedPath(V,"",0),n("Expected to write "+G+" bytes but wrote "+ne+".")):(V.write(new Uint8Array([1,1]),{at:4114}),this.setAssociatedPath(V,h,u.SQLITE_OPEN_MAIN_DB)),ne}}class D{#e;constructor(h){this.#e=h,this.vfsName=h.vfsName}async addCapacity(h){return this.#e.addCapacity(h)}async reduceCapacity(h){return this.#e.reduceCapacity(h)}getCapacity(){return this.#e.getCapacity(this.#e)}getFileCount(){return this.#e.getFileCount()}getFileNames(){return this.#e.getFileNames()}async reserveMinimumCapacity(h){const E=this.#e.getCapacity();return E<h?this.#e.addCapacity(h-E):E}exportFile(h){return this.#e.exportFile(h)}importDb(h,E){return this.#e.importDb(h,E)}async wipeFiles(){return this.#e.reset(!0)}unlink(h){return this.#e.deletePath(h)}async removeVfs(){return this.#e.removeVfs()}pauseVfs(){return this.#e.pauseVfs(),this}async unpauseVfs(){return this.#e.unpauseVfs().then(()=>this)}isPaused(){return this.#e.isPaused()}}const B=async()=>{const C=await navigator.storage.getDirectory(),h=".opfs-sahpool-sync-check-"+W(),E=(await(await C.getFileHandle(h,{create:!0})).createSyncAccessHandle()).close();return await E,await C.removeEntry(h),E?.then&&n("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method."),!0};i.installOpfsSAHPoolVfs=async function(C=Object.create(null)){C=Object.assign(Object.create(null),J,C||{});const h=C.name;if(C.$testThrowPhase1)throw C.$testThrowPhase1;if(s[h])try{return await s[h]}catch(E){if(C.forceReinitIfPreviouslyFailed)delete s[h];else throw E}return!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!navigator?.storage?.getDirectory?s[h]=Promise.reject(new Error("Missing required OPFS APIs.")):s[h]=B().then(async function(){if(C.$testThrowPhase2)throw C.$testThrowPhase2;const E=new p(C);return E.isReady.then(async()=>{const V=new D(E);if(i.oo1){const G=i.oo1,re=E.getVfs(),ne=function(...de){const ue=G.DB.dbCtorHelper.normalizeArgs(...de);ue.vfs=re.$zName,G.DB.dbCtorHelper.call(this,ue)};ne.prototype=Object.create(G.DB.prototype),V.OpfsSAHPoolDb=ne}return E.log("VFS initialized."),V}).catch(async V=>{throw await E.removeVfs().catch(()=>{}),V})}).catch(E=>s[h]=Promise.reject(E))}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.["opfs-wl"])return;const n=i.util;i.util.toss;const r=i.opfs,s="opfs-wl",u=async function(c){if(c=r.initOptions(s,c),!c)return i;i.capi;const b=r.createVfsState().vfs;b.metrics.counters;const z=b.mTimeStart,O=b.mTimeEnd,S=b.opRun,w=b.__openFiles;return b.bindVfs(n.nu({xLock:function(P,N){z("xLock");const U=w[P],y=S("xLock",P,N);return y||(U.lockType=N),O(),y},xUnlock:function(P,N){z("xUnlock");const U=w[P],y=S("xUnlock",P,N);return y||(U.lockType=N),O(),y}}),function(P,N){if(P.oo1){const U=function(...y){const m=P.oo1.DB.dbCtorHelper.normalizeArgs(...y);m.vfs=N.$zName,P.oo1.DB.dbCtorHelper.call(this,m)};U.prototype=Object.create(P.oo1.DB.prototype),P.oo1.OpfsWlDb=U,U.importDb=r.importDb}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async c=>u().catch(b=>{c.config.warn("Ignoring inability to install the",s,"sqlite3_vfs:",b)}))});try{const i=Object.assign(Object.create(null),{memory:typeof ze<"u"?ze:t.wasmMemory,exports:typeof et<"u"?et:Object.prototype.hasOwnProperty.call(t,"wasmExports")?t.wasmExports:t.asm},globalThis.sqlite3ApiBootstrap.defaultConfig,globalThis.sqlite3ApiConfig||{});e.debugModule("Bootstrapping lib config",i);const n=globalThis.sqlite3ApiBootstrap(i);return delete globalThis.sqlite3ApiBootstrap,n}catch(i){throw console.error("sqlite3ApiBootstrap() error:",i),i}},Ot?Se=f:Se=new Promise((e,t)=>{Tt=e,kt=t}),Se}At=(function(){const We=At;if(!We)throw new Error("Expecting sqlite3InitModule to be defined by the Emscripten build.");const Se=globalThis.sqlite3InitModuleState=Object.assign(Object.create(null),{moduleScript:globalThis?.document?.currentScript,isWorker:typeof WorkerGlobalScope<"u",location:globalThis.location,urlParams:globalThis?.location?.href?new URL(globalThis.location.href).searchParams:new URLSearchParams,wasmFilename:"sqlite3.wasm"});if(Se.debugModule=Se.urlParams.has("sqlite3.debugModule")?(...Re)=>console.warn("sqlite3.debugModule:",...Re):()=>{},Se.urlParams.has("sqlite3.dir"))Se.sqlite3Dir=Se.urlParams.get("sqlite3.dir")+"/";else if(Se.moduleScript){const Re=Se.moduleScript.src.split("/");Re.pop(),Se.sqlite3Dir=Re.join("/")+"/"}const f=globalThis.sqlite3InitModule=function Re(...Ve){return Se.emscriptenLocateFile=Ve[0]?.locateFile,Se.emscriptenInstantiateWasm=Ve[0]?.instantiateWasm,We(...Ve).then(je=>{Se.debugModule("sqlite3InitModule() sIMS =",Se),Se.debugModule("sqlite3InitModule() EmscriptenModule =",je);const ut=je.runSQLite3PostLoadInit(Se,je,!!Re.__isUnderTest);return Se.debugModule("sqlite3InitModule() sqlite3 =",ut),ut}).catch(je=>{throw console.error("Exception loading sqlite3 module:",je),je})};if(f.ready=We.ready,Se.moduleScript){let Re=Se.moduleScript.src.split("/");Re.pop(),Se.scriptDir=Re.join("/")+"/"}return Se.debugModule("extern-post-js.c-pp.js sqlite3InitModuleState =",Se),f})();At().then(We=>We.initWorker1API());