@tearleads/client-sdk 0.1.109 → 0.1.111
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.
- package/data/blobs/attachments/events.js +2 -3
- package/data/blobs/attachments/events.js.map +1 -1
- package/data/containers/shared/events.js +3 -4
- package/data/containers/shared/events.js.map +1 -1
- package/data/documents/shared/containerKek/containerKekPathHistory.js +3 -3
- package/data/documents/shared/containerKek/containerKekPathHistory.js.map +1 -1
- package/data/documents/shared/events.js +4 -4
- package/data/documents/shared/events.js.map +1 -1
- package/data/keying/canonicalJson.js +3 -65
- package/data/keying/canonicalJson.js.map +1 -1
- package/data/keyingProjectionVerification/checkpoints/bundleVerification.js +3 -3
- package/data/keyingProjectionVerification/checkpoints/bundleVerification.js.map +1 -1
- package/data/keyingProjectionVerification/checkpoints/verifiedBundleBytes.js +2 -3
- package/data/keyingProjectionVerification/checkpoints/verifiedBundleBytes.js.map +1 -1
- package/data/keyingProjectionVerification/container/containerManifestVerification.js +3 -3
- package/data/keyingProjectionVerification/container/containerManifestVerification.js.map +1 -1
- package/data/keyingProjectionVerification/document/documentManifestVerification.js +2 -3
- package/data/keyingProjectionVerification/document/documentManifestVerification.js.map +1 -1
- package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js +2 -3
- package/data/keyingProjectionVerification/documentPurge/documentPurgeDocumentChainVerification.js.map +1 -1
- package/data/keyingProjectionVerification/readers.js +3 -3
- package/data/keyingProjectionVerification/readers.js.map +1 -1
- package/internal/crypto/index.d.ts +1 -1
- package/internal/crypto/index.js +1 -1
- package/internal/crypto/index.js.map +1 -1
- package/internal/crypto/keying/canonicalJsonGuard.d.ts +3 -0
- package/internal/crypto/keying/canonicalJsonGuard.js +60 -0
- package/internal/crypto/keying/canonicalJsonGuard.js.map +1 -0
- package/internal/crypto/keying/index.d.ts +1 -0
- package/internal/crypto/keying/index.js +1 -0
- package/internal/crypto/keying/index.js.map +1 -1
- package/package.json +1 -1
- package/sqlite/worker.js +4 -4
- package/workflows/blobs/verification/attachmentBindingVerification.js +3 -3
- package/workflows/blobs/verification/attachmentBindingVerification.js.map +1 -1
- package/workflows/containers/root/create.js +3 -3
- package/workflows/containers/root/create.js.map +1 -1
- package/workflows/documents/linkSet/linkSetBlobRewraps.js +2 -3
- package/workflows/documents/linkSet/linkSetBlobRewraps.js.map +1 -1
- package/workflows/documents/purge/index.js +3 -3
- package/workflows/documents/purge/index.js.map +1 -1
package/sqlite/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Rc=(w,s,
|
|
2
|
-
`}if(!e)return null;Ct=Nt(e,!0)}return Ct.shift()},it={ttys:[],init(){},shutdown(){},register(e,n){it.ttys[e]={input:[],output:[],ops:n},l.registerDevice(e,it.stream_ops)},stream_ops:{open(e){var n=it.ttys[e.node.rdev];if(!n)throw new l.ErrnoError(43);e.tty=n,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,n,o,i,t){if(!e.tty||!e.tty.ops.get_char)throw new l.ErrnoError(60);var r=0;for(var a=0;a<i;a++){var _;try{_=e.tty.ops.get_char(e.tty)}catch(h){throw new l.ErrnoError(29)}if(_===void 0&&r===0)throw new l.ErrnoError(6);if(_===null||_===void 0)break;r++,n[o+a]=_}if(r)e.node.atime=Date.now();return r},write(e,n,o,i,t){if(!e.tty||!e.tty.ops.put_char)throw new l.ErrnoError(60);try{for(var r=0;r<i;r++)e.tty.ops.put_char(e.tty,n[o+r])}catch(a){throw new l.ErrnoError(29)}if(i)e.node.mtime=e.node.ctime=Date.now();return r}},default_tty_ops:{get_char(e){return pr()},put_char(e,n){if(n===null||n===10)wt(bt(e.output)),e.output=[];else if(n!=0)e.output.push(n)},fsync(e){if(e.output?.length>0)wt(bt(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,n,o){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,n){if(n===null||n===10)rt(bt(e.output)),e.output=[];else if(n!=0)e.output.push(n)},fsync(e){if(e.output?.length>0)rt(bt(e.output)),e.output=[]}}},hr=(e,n)=>Ze.fill(0,e,e+n),an=(e,n)=>Math.ceil(e/n)*n,ln=(e)=>{e=an(e,65536);var n=gn(65536,e);if(n)hr(n,e);return n},ye={ops_table:null,mount(e){return ye.createNode(null,"/",16895,0)},createNode(e,n,o,i){if(l.isBlkdev(o)||l.isFIFO(o))throw new l.ErrnoError(63);ye.ops_table||={dir:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr,lookup:ye.node_ops.lookup,mknod:ye.node_ops.mknod,rename:ye.node_ops.rename,unlink:ye.node_ops.unlink,rmdir:ye.node_ops.rmdir,readdir:ye.node_ops.readdir,symlink:ye.node_ops.symlink},stream:{llseek:ye.stream_ops.llseek}},file:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr},stream:{llseek:ye.stream_ops.llseek,read:ye.stream_ops.read,write:ye.stream_ops.write,mmap:ye.stream_ops.mmap,msync:ye.stream_ops.msync}},link:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr,readlink:ye.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr},stream:l.chrdev_stream_ops}};var t=l.createNode(e,n,o,i);if(l.isDir(t.mode))t.node_ops=ye.ops_table.dir.node,t.stream_ops=ye.ops_table.dir.stream,t.contents={};else if(l.isFile(t.mode))t.node_ops=ye.ops_table.file.node,t.stream_ops=ye.ops_table.file.stream,t.usedBytes=0,t.contents=ye.emptyFileContents??=new Uint8Array(0);else if(l.isLink(t.mode))t.node_ops=ye.ops_table.link.node,t.stream_ops=ye.ops_table.link.stream;else if(l.isChrdev(t.mode))t.node_ops=ye.ops_table.chrdev.node,t.stream_ops=ye.ops_table.chrdev.stream;if(t.atime=t.mtime=t.ctime=Date.now(),e)e.contents[n]=t,e.atime=e.mtime=e.ctime=t.atime;return t},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,n){var o=e.contents.length;if(o>=n)return;var i=1048576;if(n=Math.max(n,o*(o<i?2:1.125)>>>0),o)n=Math.max(n,256);var t=ye.getFileDataAsTypedArray(e);e.contents=new Uint8Array(n),e.contents.set(t)},resizeFileStorage(e,n){if(e.usedBytes==n)return;var o=e.contents;e.contents=new Uint8Array(n),e.contents.set(o.subarray(0,Math.min(n,e.usedBytes))),e.usedBytes=n},node_ops:{getattr(e){var n={};if(n.dev=l.isChrdev(e.mode)?e.id:1,n.ino=e.id,n.mode=e.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=e.rdev,l.isDir(e.mode))n.size=4096;else if(l.isFile(e.mode))n.size=e.usedBytes;else if(l.isLink(e.mode))n.size=e.link.length;else n.size=0;return n.atime=new Date(e.atime),n.mtime=new Date(e.mtime),n.ctime=new Date(e.ctime),n.blksize=4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr(e,n){for(let o of["mode","atime","mtime","ctime"])if(n[o]!=null)e[o]=n[o];if(n.size!==void 0)ye.resizeFileStorage(e,n.size)},lookup(e,n){if(!ye.doesNotExistError)ye.doesNotExistError=new l.ErrnoError(44),ye.doesNotExistError.stack="<generic error, no stack>";throw ye.doesNotExistError},mknod(e,n,o,i){return ye.createNode(e,n,o,i)},rename(e,n,o){var i;try{i=l.lookupNode(n,o)}catch(r){}if(i){if(l.isDir(e.mode))for(var t in i.contents)throw new l.ErrnoError(55);l.hashRemoveNode(i)}delete e.parent.contents[e.name],n.contents[o]=e,e.name=o,n.ctime=n.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,n){delete e.contents[n],e.ctime=e.mtime=Date.now()},rmdir(e,n){var o=l.lookupNode(e,n);for(var i in o.contents)throw new l.ErrnoError(55);delete e.contents[n],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,n,o){var i=ye.createNode(e,n,41471,0);return i.link=o,i},readlink(e){if(!l.isLink(e.mode))throw new l.ErrnoError(28);return e.link}},stream_ops:{read(e,n,o,i,t){var r=e.node.contents;if(t>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-t,i);return n.set(r.subarray(t,t+a),o),a},write(e,n,o,i,t,r){if(n.buffer===Be.buffer)r=!1;if(!i)return 0;var a=e.node;if(a.mtime=a.ctime=Date.now(),r)a.contents=n.subarray(o,o+i),a.usedBytes=i;else if(a.usedBytes===0&&t===0)a.contents=n.slice(o,o+i),a.usedBytes=i;else ye.expandFileStorage(a,t+i),a.contents.set(n.subarray(o,o+i),t),a.usedBytes=Math.max(a.usedBytes,t+i);return i},llseek(e,n,o){var i=n;if(o===1)i+=e.position;else if(o===2){if(l.isFile(e.node.mode))i+=e.node.usedBytes}if(i<0)throw new l.ErrnoError(28);return i},mmap(e,n,o,i,t){if(!l.isFile(e.node.mode))throw new l.ErrnoError(43);var r,a,_=e.node.contents;if(!(t&2)&&_.buffer===Be.buffer)a=!1,r=_.byteOffset;else{if(a=!0,r=ln(n),!r)throw new l.ErrnoError(48);if(_){if(o>0||o+n<_.length)if(_.subarray)_=_.subarray(o,o+n);else _=Array.prototype.slice.call(_,o,o+n);Be.set(_,r)}}return{ptr:r,allocated:a}},msync(e,n,o,i,t){return ye.stream_ops.write(e,n,0,i,o,!1),0}}},mr=(e)=>{if(typeof e!="string")return e;var n={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},o=n[e];if(typeof o>"u")throw Error(`Unknown file open mode: ${e}`);return o},cn=(e)=>{if(typeof e=="string")e=Nt(e,!0);if(!e.subarray)e=new Uint8Array(e);return e},Dt=(e,n)=>{var o=0;if(e)o|=365;if(n)o|=146;return o},gr=async(e)=>{var n=await xt(e);return new Uint8Array(n)},br=(...e)=>l.createDataFile(...e),yr=(e)=>e,_n=null,qr=async()=>_n,lt=0,un=null,vr=(e)=>{if(lt--,s.monitorRunDependencies?.(lt),!lt)un()},Sr=(e)=>{if(!lt)_n=new Promise((n)=>un=n);lt++,s.monitorRunDependencies?.(lt)},wr=[],Er=async(e,n)=>{if(typeof Browser<"u")Browser.init();for(var o of wr)if(o.canHandle(n))return o.handle(e,n);return e},fn=async(e,n,o,i,t,r,a,_)=>{var h=n?ut.resolve(Te.join2(e,n)):e,I=yr(`cp ${h}`);Sr(I);try{var q=o;if(typeof o=="string")q=await gr(o);if(q=await Er(q,h),_?.(),!r)br(e,n,q,i,t,a)}finally{vr(I)}},kr=(e,n,o,i,t,r,a,_,h,I)=>{fn(e,n,o,i,t,_,h,I).then(r).catch(a)},l={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,n,o,i){if(!e)e=this;this.parent=e,this.mount=e.mount,this.id=l.nextInode++,this.name=n,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 l.isDir(this.mode)}get isDevice(){return l.isChrdev(this.mode)}addListener(e,n=!1){var o={cb:e,exclusive:n},i=this.listeners??=new Set;return i.add(o),{listeners:i,entry:o}}notifyListeners(e){if(!this.listeners)return;var n;for(var o of this.listeners)if(o.exclusive)(n||=[]).push(o);else o.cb(e);if(n){var i=(this.exclTurn||0)%n.length;this.exclTurn=i+1,n[i].cb(e)}}},lookupPath(e,n={}){if(!e)throw new l.ErrnoError(44);if(n.follow_mount??=!0,!Te.isAbs(e))e=l.cwd()+"/"+e;e:for(var o=0;o<40;o++){var i=e.split("/").filter((I)=>!!I),t=l.root,r="/";for(var a=0;a<i.length;a++){var _=a===i.length-1;if(_&&n.parent)break;if(i[a]===".")continue;if(i[a]===".."){if(r=Te.dirname(r),l.isRoot(t)){e=r+"/"+i.slice(a+1).join("/"),o--;continue e}else t=t.parent;continue}r=Te.join2(r,i[a]);try{t=l.lookupNode(t,i[a])}catch(I){if(I?.errno===44&&_&&n.noent_okay)return{path:r};throw I}if(l.isMountpoint(t)&&(!_||n.follow_mount))t=t.mounted.root;if(l.isLink(t.mode)&&(!_||n.follow)){if(!t.node_ops.readlink)throw new l.ErrnoError(52);var h=t.node_ops.readlink(t);if(!Te.isAbs(h))h=Te.dirname(r)+"/"+h;e=h+"/"+i.slice(a+1).join("/");continue e}}return{path:r,node:t}}throw new l.ErrnoError(32)},getPath(e){var n;while(!0){if(l.isRoot(e)){var o=e.mount.mountpoint;if(!n)return o;return o[o.length-1]!=="/"?`${o}/${n}`:o+n}n=n?`${e.name}/${n}`:e.name,e=e.parent}},hashName(e,n){var o=0;for(var i=0;i<n.length;i++)o=(o<<5)-o+n.charCodeAt(i)|0;return(e+o>>>0)%l.nameTable.length},hashAddNode(e){var n=l.hashName(e.parent.id,e.name);e.name_next=l.nameTable[n],l.nameTable[n]=e},hashRemoveNode(e){var n=l.hashName(e.parent.id,e.name);if(l.nameTable[n]===e)l.nameTable[n]=e.name_next;else{var o=l.nameTable[n];while(o){if(o.name_next===e){o.name_next=e.name_next;break}o=o.name_next}}},lookupNode(e,n){var o=l.mayLookup(e);if(o)throw new l.ErrnoError(o);var i=l.hashName(e.id,n);for(var t=l.nameTable[i];t;t=t.name_next){var r=t.name;if(t.parent.id===e.id&&r===n)return t}return l.lookup(e,n)},createNode(e,n,o,i){var t=new l.FSNode(e,n,o,i);return l.hashAddNode(t),t},destroyNode(e){l.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 n=["r","w","rw"][e&3];if(e&512)n+="w";return n},nodePermissions(e,n){if(l.ignorePermissions)return 0;if(n.includes("r")&&!(e.mode&292))return 2;if(n.includes("w")&&!(e.mode&146))return 2;if(n.includes("x")&&!(e.mode&73))return 2;return 0},mayLookup(e){if(!l.isDir(e.mode))return 54;var n=l.nodePermissions(e,"x");if(n)return n;if(!e.node_ops.lookup)return 2;return 0},mayCreate(e,n){if(!l.isDir(e.mode))return 54;try{var o=l.lookupNode(e,n);return 20}catch(i){}return l.nodePermissions(e,"wx")},mayDelete(e,n,o){var i;try{i=l.lookupNode(e,n)}catch(r){return r.errno}var t=l.nodePermissions(e,"wx");if(t)return t;if(o){if(!l.isDir(i.mode))return 54;if(l.isRoot(i)||l.getPath(i)===l.cwd())return 10}else if(l.isDir(i.mode))return 31;return 0},mayOpen(e,n){if(!e)return 44;if(l.isLink(e.mode))return 32;var o=l.flagsToPermissionString(n);if(l.isDir(e.mode)){if(o!=="r"||n&576)return 31}return l.nodePermissions(e,o)},checkOpExists(e,n){if(!e)throw new l.ErrnoError(n);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=l.MAX_OPEN_FDS;e++)if(!l.streams[e])return e;throw new l.ErrnoError(33)},getStreamChecked(e){var n=l.getStream(e);if(!n)throw new l.ErrnoError(8);return n},getStream:(e)=>l.streams[e],createStream(e,n=-1){if(e=Object.assign(new l.FSStream,e),n==-1)n=l.nextfd();return e.fd=n,l.streams[n]=e,e},closeStream(e){l.streams[e]=null},dupStream(e,n=-1){var o=l.createStream(e,n);return o.stream_ops?.dup?.(o),o},doSetAttr(e,n,o){var i=e?.stream_ops.setattr,t=i?e:n;i??=n.node_ops.setattr,l.checkOpExists(i,63);try{i(t,o)}catch(r){if(r instanceof RangeError)throw new l.ErrnoError(22);throw r}},chrdev_stream_ops:{open(e){var n=l.getDevice(e.node.rdev);e.stream_ops=n.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new l.ErrnoError(70)}},major:(e)=>e>>8,minor:(e)=>e&255,makedev:(e,n)=>e<<8|n,registerDevice(e,n){l.devices[e]={stream_ops:n}},getDevice:(e)=>l.devices[e],getMounts(e){var n=[],o=[e];while(o.length){var i=o.pop();n.push(i),o.push(...i.mounts)}return n},syncfs(e,n){if(typeof e=="function")n=e,e=!1;if(l.syncFSRequests++,l.syncFSRequests>1)rt(`warning: ${l.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var o=l.getMounts(l.root.mount),i=0;function t(_){return l.syncFSRequests--,n(_)}function r(_){if(_){if(!r.errored)return r.errored=!0,t(_);return}if(++i>=o.length)t(null)}for(var a of o)if(a.type.syncfs)a.type.syncfs(a,e,r);else r(null)},mount(e,n,o){var i=o==="/",t=!o,r;if(i&&l.root)throw new l.ErrnoError(10);else if(!i&&!t){var a=l.lookupPath(o,{follow_mount:!1});if(o=a.path,r=a.node,l.isMountpoint(r))throw new l.ErrnoError(10);if(!l.isDir(r.mode))throw new l.ErrnoError(54)}var _={type:e,opts:n,mountpoint:o,mounts:[]},h=e.mount(_);if(h.mount=_,_.root=h,i)l.root=h;else if(r){if(r.mounted=_,r.mount)r.mount.mounts.push(_)}return h},unmount(e){var n=l.lookupPath(e,{follow_mount:!1});if(!l.isMountpoint(n.node))throw new l.ErrnoError(28);var o=n.node,i=o.mounted,t=l.getMounts(i);for(var[r,a]of Object.entries(l.nameTable))while(a){var _=a.name_next;if(t.includes(a.mount))l.destroyNode(a);a=_}o.mounted=null;var h=o.mount.mounts.indexOf(i);o.mount.mounts.splice(h,1)},lookup(e,n){return e.node_ops.lookup(e,n)},mknod(e,n,o){var i=l.lookupPath(e,{parent:!0}),t=i.node,r=Te.basename(e);if(!r)throw new l.ErrnoError(28);if(r==="."||r==="..")throw new l.ErrnoError(20);var a=l.mayCreate(t,r);if(a)throw new l.ErrnoError(a);if(!t.node_ops.mknod)throw new l.ErrnoError(63);return t.node_ops.mknod(t,r,n,o)},statfs(e){return l.statfsNode(l.lookupPath(e,{follow:!0}).node)},statfsStream(e){return l.statfsNode(e.node)},statfsNode(e){var n={bsize:4096,frsize:4096,blocks:1e6,bfree:500000,bavail:500000,files:l.nextInode,ffree:l.nextInode-1,fsid:42,flags:2,namelen:255};if(e.node_ops.statfs)Object.assign(n,e.node_ops.statfs(e.mount.opts.root));return n},create(e,n=438){return n&=4095,n|=32768,l.mknod(e,n,0)},mkdir(e,n=511){return n&=1023,n|=16384,l.mknod(e,n,0)},mkdirTree(e,n){var o=e.split("/"),i="";for(var t of o){if(!t)continue;if(i||Te.isAbs(e))i+="/";i+=t;try{l.mkdir(i,n)}catch(r){if(r.errno!=20)throw r}}},mkdev(e,n,o){if(typeof o>"u")o=n,n=438;return n|=8192,l.mknod(e,n,o)},symlink(e,n){if(!ut.resolve(e))throw new l.ErrnoError(44);var o=l.lookupPath(n,{parent:!0}),i=o.node;if(!i)throw new l.ErrnoError(44);var t=Te.basename(n),r=l.mayCreate(i,t);if(r)throw new l.ErrnoError(r);if(!i.node_ops.symlink)throw new l.ErrnoError(63);return i.node_ops.symlink(i,t,e)},link(e,n,o){var i=l.lookupPath(n,{parent:!0}),t=i.node;if(!t)throw new l.ErrnoError(44);var r=Te.basename(n),a=l.mayCreate(t,r);if(a)throw new l.ErrnoError(a);if(!t.node_ops.link)throw new l.ErrnoError(34);return t.node_ops.link(t,r,e,o)},rename(e,n){var o=Te.dirname(e),i=Te.dirname(n),t=Te.basename(e),r=Te.basename(n),a,_,h;if(a=l.lookupPath(e,{parent:!0}),_=a.node,a=l.lookupPath(n,{parent:!0}),h=a.node,!_||!h)throw new l.ErrnoError(44);if(_.mount!==h.mount)throw new l.ErrnoError(75);var I=l.lookupNode(_,t),q=ut.relative(e,i);if(q.charAt(0)!==".")throw new l.ErrnoError(28);if(q=ut.relative(n,o),q.charAt(0)!==".")throw new l.ErrnoError(55);var R;try{R=l.lookupNode(h,r)}catch(te){}if(I===R)return;var M=l.isDir(I.mode),p=l.mayDelete(_,t,M);if(p)throw new l.ErrnoError(p);if(p=R?l.mayDelete(h,r,M):l.mayCreate(h,r),p)throw new l.ErrnoError(p);if(!_.node_ops.rename)throw new l.ErrnoError(63);if(l.isMountpoint(I)||R&&l.isMountpoint(R))throw new l.ErrnoError(10);if(h!==_){if(p=l.nodePermissions(_,"w"),p)throw new l.ErrnoError(p)}l.hashRemoveNode(I);try{_.node_ops.rename(I,h,r),I.parent=h}catch(te){throw te}finally{l.hashAddNode(I)}},rmdir(e){var n=l.lookupPath(e,{parent:!0}),o=n.node,i=Te.basename(e),t=l.lookupNode(o,i),r=l.mayDelete(o,i,!0);if(r)throw new l.ErrnoError(r);if(!o.node_ops.rmdir)throw new l.ErrnoError(63);if(l.isMountpoint(t))throw new l.ErrnoError(10);o.node_ops.rmdir(o,i),l.destroyNode(t)},readdir(e){var n=l.lookupPath(e,{follow:!0}),o=n.node,i=l.checkOpExists(o.node_ops.readdir,54);return i(o)},unlink(e){var n=l.lookupPath(e,{parent:!0}),o=n.node;if(!o)throw new l.ErrnoError(44);var i=Te.basename(e),t=l.lookupNode(o,i),r=l.mayDelete(o,i,!1);if(r)throw new l.ErrnoError(r);if(!o.node_ops.unlink)throw new l.ErrnoError(63);if(l.isMountpoint(t))throw new l.ErrnoError(10);o.node_ops.unlink(o,i),l.destroyNode(t)},readlink(e){var n=l.lookupPath(e),o=n.node;if(!o)throw new l.ErrnoError(44);if(!o.node_ops.readlink)throw new l.ErrnoError(28);return o.node_ops.readlink(o)},stat(e,n){var o=l.lookupPath(e,{follow:!n}),i=o.node,t=l.checkOpExists(i.node_ops.getattr,63);return t(i)},fstat(e){var n=l.getStreamChecked(e),o=n.node,i=n.stream_ops.getattr,t=i?n:o;return i??=o.node_ops.getattr,l.checkOpExists(i,63),i(t)},lstat(e){return l.stat(e,!0)},doChmod(e,n,o,i){l.doSetAttr(e,n,{mode:o&4095|n.mode&-4096,ctime:Date.now(),dontFollow:i})},chmod(e,n,o){var i;if(typeof e=="string"){var t=l.lookupPath(e,{follow:!o});i=t.node}else i=e;l.doChmod(null,i,n,o)},lchmod(e,n){l.chmod(e,n,!0)},fchmod(e,n){var o=l.getStreamChecked(e);l.doChmod(o,o.node,n,!1)},doChown(e,n,o){l.doSetAttr(e,n,{timestamp:Date.now(),dontFollow:o})},chown(e,n,o,i){var t;if(typeof e=="string"){var r=l.lookupPath(e,{follow:!i});t=r.node}else t=e;l.doChown(null,t,i)},lchown(e,n,o){l.chown(e,n,o,!0)},fchown(e,n,o){var i=l.getStreamChecked(e);l.doChown(i,i.node,!1)},doTruncate(e,n,o){if(l.isDir(n.mode))throw new l.ErrnoError(31);if(!l.isFile(n.mode))throw new l.ErrnoError(28);var i=l.nodePermissions(n,"w");if(i)throw new l.ErrnoError(i);l.doSetAttr(e,n,{size:o,timestamp:Date.now()})},truncate(e,n){if(n<0)throw new l.ErrnoError(28);var o;if(typeof e=="string"){var i=l.lookupPath(e,{follow:!0});o=i.node}else o=e;l.doTruncate(null,o,n)},ftruncate(e,n){var o=l.getStreamChecked(e);if(n<0||(o.flags&2097155)===0)throw new l.ErrnoError(28);l.doTruncate(o,o.node,n)},utime(e,n,o,i){var t=l.lookupPath(e,{follow:!i});l.doSetAttr(null,t.node,{atime:n,mtime:o,dontFollow:i})},open(e,n,o=438){if(e==="")throw new l.ErrnoError(44);if(n=mr(n),n&64)o=o&4095|32768;else o=0;var i,t;if(typeof e=="object")i=e;else{t=e.endsWith("/");var r=l.lookupPath(e,{follow:!(n&131072),noent_okay:!0});i=r.node,e=r.path}var a=!1;if(n&64)if(i){if(n&128)throw new l.ErrnoError(20)}else if(t)throw new l.ErrnoError(31);else i=l.mknod(e,o|511,0),a=!0;if(!i)throw new l.ErrnoError(44);if(l.isChrdev(i.mode))n&=-513;if(n&65536&&!l.isDir(i.mode))throw new l.ErrnoError(54);if(!a){var _=l.mayOpen(i,n);if(_)throw new l.ErrnoError(_)}if(n&512&&!a)l.truncate(i,0);n&=-131713;var h=l.createStream({node:i,path:l.getPath(i),flags:n,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});if(h.stream_ops.open)h.stream_ops.open(h);if(a)l.chmod(i,o&511);return h},close(e){if(l.isClosed(e))throw new l.ErrnoError(8);if(e.getdents)e.getdents=null;e.node?.notifyListeners(32);try{if(e.stream_ops.close)e.stream_ops.close(e)}catch(n){throw n}finally{l.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,n,o){if(l.isClosed(e))throw new l.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new l.ErrnoError(70);if(o!=0&&o!=1&&o!=2)throw new l.ErrnoError(28);return e.position=e.stream_ops.llseek(e,n,o),e.ungotten=[],e.position},read(e,n,o,i,t){if(i<0||t<0)throw new l.ErrnoError(28);if(l.isClosed(e))throw new l.ErrnoError(8);if((e.flags&2097155)===1)throw new l.ErrnoError(8);if(l.isDir(e.node.mode))throw new l.ErrnoError(31);if(!e.stream_ops.read)throw new l.ErrnoError(28);var r=typeof t<"u";if(!r)t=e.position;else if(!e.seekable)throw new l.ErrnoError(70);var a=e.stream_ops.read(e,n,o,i,t);if(!r)e.position+=a;return a},write(e,n,o,i,t,r){if(i<0||t<0)throw new l.ErrnoError(28);if(l.isClosed(e))throw new l.ErrnoError(8);if((e.flags&2097155)===0)throw new l.ErrnoError(8);if(l.isDir(e.node.mode))throw new l.ErrnoError(31);if(!e.stream_ops.write)throw new l.ErrnoError(28);if(e.seekable&&e.flags&1024)l.llseek(e,0,2);var a=typeof t<"u";if(!a)t=e.position;else if(!e.seekable)throw new l.ErrnoError(70);var _=e.stream_ops.write(e,n,o,i,t,r);if(!a)e.position+=_;return _},mmap(e,n,o,i,t){if((i&2)!==0&&(t&2)===0&&(e.flags&2097155)!==2)throw new l.ErrnoError(2);if((e.flags&2097155)===1)throw new l.ErrnoError(2);if(!e.stream_ops.mmap)throw new l.ErrnoError(43);if(!n)throw new l.ErrnoError(28);return e.stream_ops.mmap(e,n,o,i,t)},msync(e,n,o,i,t){if(!e.stream_ops.msync)return 0;return e.stream_ops.msync(e,n,o,i,t)},ioctl(e,n,o){if(!e.stream_ops.ioctl)throw new l.ErrnoError(59);return e.stream_ops.ioctl(e,n,o)},readFile(e,n={}){if(n.flags=n.flags??0,n.encoding=n.encoding??"binary",n.encoding!=="utf8"&&n.encoding!=="binary")Ke(`Invalid encoding type "${n.encoding}"`);var o=l.open(e,n.flags),i=l.stat(e),t=i.size,r=new Uint8Array(t);if(l.read(o,r,0,t,0),n.encoding==="utf8")r=bt(r);return l.close(o),r},writeFile(e,n,o={}){o.flags=o.flags??577;var i=l.open(e,o.flags,o.mode);n=cn(n),l.write(i,n,0,n.byteLength,void 0,o.canOwn),l.close(i)},cwd:()=>l.currentPath,chdir(e){var n=l.lookupPath(e,{follow:!0});if(n.node===null)throw new l.ErrnoError(44);if(!l.isDir(n.node.mode))throw new l.ErrnoError(54);var o=l.nodePermissions(n.node,"x");if(o)throw new l.ErrnoError(o);l.currentPath=n.path},createDefaultDirectories(){l.mkdir("/tmp"),l.mkdir("/home"),l.mkdir("/home/web_user")},createDefaultDevices(){l.mkdir("/dev"),l.registerDevice(l.makedev(1,3),{read:()=>0,write:(i,t,r,a,_)=>a,llseek:()=>0}),l.mkdev("/dev/null",l.makedev(1,3)),it.register(l.makedev(5,0),it.default_tty_ops),it.register(l.makedev(6,0),it.default_tty1_ops),l.mkdev("/dev/tty",l.makedev(5,0)),l.mkdev("/dev/tty1",l.makedev(6,0));var e=new Uint8Array(1024),n=0,o=()=>{if(n===0)nn(e),n=e.byteLength;return e[--n]};l.createDevice("/dev","random",o),l.createDevice("/dev","urandom",o),l.mkdir("/dev/shm"),l.mkdir("/dev/shm/tmp")},createSpecialDirectories(){l.mkdir("/proc");var e=l.mkdir("/proc/self");l.mkdir("/proc/self/fd"),l.mount({mount(){var n=l.createNode(e,"fd",16895,73);return n.stream_ops={llseek:ye.stream_ops.llseek},n.node_ops={lookup(o,i){var t=+i,r=l.getStreamChecked(t),a={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path},id:t+1};return a.parent=a,a},readdir(){return Array.from(l.streams.entries()).filter(([o,i])=>i).map(([o,i])=>o.toString())}},n}},{},"/proc/self/fd")},createStandardStreams(e,n,o){if(e)l.createDevice("/dev","stdin",e);else l.symlink("/dev/tty","/dev/stdin");if(n)l.createDevice("/dev","stdout",null,n);else l.symlink("/dev/tty","/dev/stdout");if(o)l.createDevice("/dev","stderr",null,o);else l.symlink("/dev/tty1","/dev/stderr");var i=l.open("/dev/stdin",0),t=l.open("/dev/stdout",1),r=l.open("/dev/stderr",1)},staticInit(){l.nameTable=Array(4096),l.mount(ye,{},"/"),l.createDefaultDirectories(),l.createDefaultDevices(),l.createSpecialDirectories(),l.filesystems={MEMFS:ye}},init(e,n,o){l.initialized=!0,e??=s.stdin,n??=s.stdout,o??=s.stderr,l.createStandardStreams(e,n,o)},quit(){l.initialized=!1;for(var e of l.streams)if(e)l.close(e)},findObject(e,n){var o=l.analyzePath(e,n);if(!o.exists)return null;return o.object},analyzePath(e,n){try{var o=l.lookupPath(e,{follow:!n});e=o.path}catch(t){}var i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var o=l.lookupPath(e,{parent:!0});i.parentExists=!0,i.parentPath=o.path,i.parentObject=o.node,i.name=Te.basename(e),o=l.lookupPath(e,{follow:!n}),i.exists=!0,i.path=o.path,i.object=o.node,i.name=o.node.name,i.isRoot=o.path==="/"}catch(t){i.error=t.errno}return i},createPath(e,n,o,i){e=typeof e=="string"?e:l.getPath(e);var t=n.split("/").reverse();while(t.length){var r=t.pop();if(!r)continue;var a=Te.join2(e,r);try{l.mkdir(a)}catch(_){if(_.errno!=20)throw _}e=a}return a},createFile(e,n,o,i,t){var r=Te.join2(typeof e=="string"?e:l.getPath(e),n),a=Dt(i,t);return l.create(r,a)},createDataFile(e,n,o,i,t,r){var a=n;if(e)e=typeof e=="string"?e:l.getPath(e),a=n?Te.join2(e,n):e;var _=Dt(i,t),h=l.create(a,_);if(o){o=cn(o),l.chmod(h,_|146);var I=l.open(h,577);l.write(I,o,0,o.length,0,r),l.close(I),l.chmod(h,_)}},createDevice(e,n,o,i){var t=Te.join2(typeof e=="string"?e:l.getPath(e),n),r=Dt(!!o,!!i);l.createDevice.major??=64;var a=l.makedev(l.createDevice.major++,0);return l.registerDevice(a,{open(_){_.seekable=!1},close(_){if(i?.buffer?.length)i(10)},read(_,h,I,q,R){var M=0;for(var p=0;p<q;p++){var te;try{te=o()}catch(j){throw new l.ErrnoError(29)}if(te===void 0&&M===0)throw new l.ErrnoError(6);if(te===null||te===void 0)break;M++,h[I+p]=te}if(M)_.node.atime=Date.now();return M},write(_,h,I,q,R){for(var M=0;M<q;M++)try{i(h[I+M])}catch(p){throw new l.ErrnoError(29)}if(q)_.node.mtime=_.node.ctime=Date.now();return M}}),l.mkdev(t,r,a)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)Ke("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=St(e.url)}catch(n){throw new l.ErrnoError(29)}},createLazyFile(e,n,o,i,t){class r{lengthKnown=!1;chunks=[];get(R){if(R>this.length-1||R<0)return;var M=R%this.chunkSize,p=R/this.chunkSize|0;return this.getter(p)[M]}setDataGetter(R){this.getter=R}cacheLength(){var R=new XMLHttpRequest;if(R.open("HEAD",o,!1),R.send(null),!(R.status>=200&&R.status<300||R.status===304))Ke("Couldn't load "+o+". Status: "+R.status);var M=Number(R.getResponseHeader("Content-length")),p,te=(p=R.getResponseHeader("Accept-Ranges"))&&p==="bytes",j=(p=R.getResponseHeader("Content-Encoding"))&&p==="gzip",U=1048576;if(!te)U=M;var E=(F,x)=>{if(F>x)Ke(`invalid range (${F}, ${x}) or no bytes requested!`);if(x>M-1)Ke(`only ${M} bytes available! programmer error!`);var A=new XMLHttpRequest;if(A.open("GET",o,!1),M!==U)A.setRequestHeader("Range","bytes="+F+"-"+x);if(A.responseType="arraybuffer",A.overrideMimeType)A.overrideMimeType("text/plain; charset=x-user-defined");if(A.send(null),!(A.status>=200&&A.status<300||A.status===304))Ke("Couldn't load "+o+". Status: "+A.status);if(A.response!==void 0)return new Uint8Array(A.response||[]);return Nt(A.responseText??"",!0)},g=this;if(g.setDataGetter((F)=>{var x=F*U,A=(F+1)*U-1;if(A=Math.min(A,M-1),typeof g.chunks[F]>"u")g.chunks[F]=E(x,A);if(typeof g.chunks[F]>"u")Ke("doXHR failed!");return g.chunks[F]}),j||!M)U=M=1,M=this.getter(0).length,U=M,wt("LazyFiles on gzip forces download of the whole file when length is accessed");this._length=M,this._chunkSize=U,this.lengthKnown=!0}get length(){if(!this.lengthKnown)this.cacheLength();return this._length}get chunkSize(){if(!this.lengthKnown)this.cacheLength();return this._chunkSize}}if(globalThis.XMLHttpRequest){if(!ne)Ke("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var a=new r,_={isDevice:!1,contents:a}}else var _={isDevice:!1,url:o};var h=l.createFile(e,n,_,i,t);if(_.contents)h.contents=_.contents;else if(_.url)h.contents=null,h.url=_.url;Object.defineProperties(h,{usedBytes:{get:function(){return this.contents.length}}});var I={};for(let[R,M]of Object.entries(h.stream_ops))I[R]=(...p)=>(l.forceLoadFile(h),M(...p));function q(R,M,p,te,j){var U=R.node.contents;if(j>=U.length)return 0;var E=Math.min(U.length-j,te);if(U.slice)for(var g=0;g<E;g++)M[p+g]=U[j+g];else for(var g=0;g<E;g++)M[p+g]=U.get(j+g);return E}return I.read=(R,M,p,te,j)=>(l.forceLoadFile(h),q(R,M,p,te,j)),I.mmap=(R,M,p,te,j)=>{l.forceLoadFile(h);var U=ln(M);if(!U)throw new l.ErrnoError(48);return q(R,Be,U,M,p),{ptr:U,allocated:!0}},h.stream_ops=I,h}},Ar=(e,n,o)=>{if(!e)return"";var i=sn(Ze,e,n,o);return rn.decode(Ze.subarray(e,i))},ve={currentUmask:18,calculateAt(e,n,o){if(Te.isAbs(n))return n;var i;if(e===-100)i=l.cwd();else{var t=ve.getStreamFromFD(e);i=t.path}if(n.length==0){if(!o)throw new l.ErrnoError(44);return i}return i+"/"+n},writeStat(e,n){ke[e>>2]=n.dev,ke[e+4>>2]=n.mode,ke[e+8>>2]=n.nlink,ke[e+12>>2]=n.uid,ke[e+16>>2]=n.gid,ke[e+20>>2]=n.rdev,ze[e+24>>3]=BigInt(n.size),Ie[e+32>>2]=4096,Ie[e+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),t=n.ctime.getTime();return ze[e+40>>3]=BigInt(Math.floor(o/1000)),ke[e+48>>2]=o%1000*1000*1000,ze[e+56>>3]=BigInt(Math.floor(i/1000)),ke[e+64>>2]=i%1000*1000*1000,ze[e+72>>3]=BigInt(Math.floor(t/1000)),ke[e+80>>2]=t%1000*1000*1000,ze[e+88>>3]=BigInt(n.ino),0},writeStatFs(e,n){ke[e+4>>2]=n.bsize,ke[e+60>>2]=n.bsize,ze[e+8>>3]=BigInt(n.blocks),ze[e+16>>3]=BigInt(n.bfree),ze[e+24>>3]=BigInt(n.bavail),ze[e+32>>3]=BigInt(n.files),ze[e+40>>3]=BigInt(n.ffree),ke[e+48>>2]=n.fsid,ke[e+64>>2]=n.flags,ke[e+56>>2]=n.namelen},doMsync(e,n,o,i,t){if(!l.isFile(n.node.mode))throw new l.ErrnoError(43);if(i&2)return 0;var r=Ze.subarray(e,e+o);l.msync(n,r,t,o,i)},getStreamFromFD(e){var n=l.getStreamChecked(e);return n},varargs:void 0,getStr(e){var n=Ar(e);return n}};function Ir(e,n){try{return e=ve.getStr(e),l.chmod(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function xr(e,n,o,i){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),o&-8)return-28;var t=l.lookupPath(n,{follow:!0}),r=t.node;if(!r)return-44;var a="";if(o&4)a+="r";if(o&2)a+="w";if(o&1)a+="x";if(a&&l.nodePermissions(r,a))return-2;return 0}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function Tr(e,n){try{return l.fchmod(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Or(e,n,o){try{return l.fchown(e,n,o),0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var kt=()=>{var e=Ie[+ve.varargs>>2];return ve.varargs+=4,e},ft=kt;function Pr(e,n,o){ve.varargs=o;try{var i=ve.getStreamFromFD(e);switch(n){case 0:{var t=kt();if(t<0)return-28;while(l.streams[t])t++;var r=l.dupStream(i,t);return r.fd}case 1:case 2:return 0;case 3:return i.flags;case 4:{var t=kt(),a=289792;return i.flags=i.flags&~a|t&a,0}case 12:{var t=ft(),_=0;return at[t+_>>1]=2,0}case 13:case 14:return 0}return-28}catch(h){if(typeof l>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function Fr(e,n){try{return ve.writeStat(n,l.fstat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var Lr=9007199254740992,Cr=-9007199254740992,dt=(e)=>e<Cr||e>Lr?NaN:Number(e);function Nr(e,n){n=dt(n);try{if(isNaN(n))return-22;return l.ftruncate(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var ct=(e,n,o)=>on(e,Ze,n,o);function Dr(e,n){try{if(n===0)return-28;var o=l.cwd(),i=Et(o)+1;if(n<i)return-68;return ct(o,e,n),i}catch(t){if(typeof l>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function Rr(e,n,o){ve.varargs=o;try{var i=ve.getStreamFromFD(e);switch(n){case 21509:{if(!i.tty)return-59;return 0}case 21505:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcgets){var t=i.tty.ops.ioctl_tcgets(i),r=ft();Ie[r>>2]=t.c_iflag||0,Ie[r+4>>2]=t.c_oflag||0,Ie[r+8>>2]=t.c_cflag||0,Ie[r+12>>2]=t.c_lflag||0;for(var a=0;a<32;a++)Be[r+a+17]=t.c_cc[a]||0;return 0}return 0}case 21510:case 21511:case 21512:{if(!i.tty)return-59;return 0}case 21506:case 21507:case 21508:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcsets){var r=ft(),_=Ie[r>>2],h=Ie[r+4>>2],I=Ie[r+8>>2],q=Ie[r+12>>2],R=[];for(var a=0;a<32;a++)R.push(Be[r+a+17]);return i.tty.ops.ioctl_tcsets(i.tty,n,{c_iflag:_,c_oflag:h,c_cflag:I,c_lflag:q,c_cc:R})}return 0}case 21519:{if(!i.tty)return-59;var r=ft();return Ie[r>>2]=0,0}case 21520:{if(!i.tty)return-59;return-28}case 21537:case 21531:{var r=ft();return l.ioctl(i,n,r)}case 21523:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tiocgwinsz){var M=i.tty.ops.ioctl_tiocgwinsz(i.tty),r=ft();at[r>>1]=M[0],at[r+2>>1]=M[1]}return 0}case 21524:{if(!i.tty)return-59;return 0}case 21515:{if(!i.tty)return-59;return 0}default:return-28}}catch(p){if(typeof l>"u"||p.name!=="ErrnoError")throw p;return-p.errno}}function Mr(e,n){try{return e=ve.getStr(e),ve.writeStat(n,l.lstat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function jr(e,n,o){try{return n=ve.getStr(n),n=ve.calculateAt(e,n),o&=~ve.currentUmask,l.mkdir(n,o,0),0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Wr(e,n,o,i){try{n=ve.getStr(n);var t=i&256,r=i&4096;return i=i&-6401,n=ve.calculateAt(e,n,r),ve.writeStat(o,t?l.lstat(n):l.stat(n))}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function zr(e,n,o,i){ve.varargs=i;try{n=ve.getStr(n),n=ve.calculateAt(e,n);var t=i?kt():0;if(o&64)t&=~ve.currentUmask;return l.open(n,o,t).fd}catch(r){if(typeof l>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function Br(e,n,o,i){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),i<=0)return-28;var t=l.readlink(n),r=Math.min(i,Et(t)),a=Be[o+r];return ct(t,o,i+1),Be[o+r]=a,r}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function Ur(e){try{return e=ve.getStr(e),l.rmdir(e),0}catch(n){if(typeof l>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function Qr(e,n){try{return e=ve.getStr(e),ve.writeStat(n,l.stat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Vr(e,n,o){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),!o)l.unlink(n);else if(o===512)l.rmdir(n);else return-28;return 0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var dn=(e)=>ke[e>>2]+Ie[e+4>>2]*4294967296;function Hr(e,n,o,i){try{var t=i&256;n=ve.getStr(n),n=ve.calculateAt(e,n,!0);var r=Date.now(),a,_;if(!o)a=r,_=r;else{var h=dn(o),I=Ie[o+8>>2];if(I==1073741823)a=r;else if(I==1073741822)a=null;else a=h*1000+I/1e6;if(o+=16,h=dn(o),I=Ie[o+8>>2],I==1073741823)_=r;else if(I==1073741822)_=null;else _=h*1000+I/1e6}if((_??a)!==null)l.utime(n,a,_,t);return 0}catch(q){if(typeof l>"u"||q.name!=="ErrnoError")throw q;return-q.errno}}var Gr=()=>Ke(""),Kr=(e)=>e%4===0&&(e%100!==0||e%400===0),$r=[0,31,60,91,121,152,182,213,244,274,305,335],Jr=[0,31,59,90,120,151,181,212,243,273,304,334],Xr=(e)=>{var n=Kr(e.getFullYear()),o=n?$r:Jr,i=o[e.getMonth()]+e.getDate()-1;return i};function Yr(e,n){e=dt(e);var o=new Date(e*1000);if(isNaN(o.getTime()))return 1;Ie[n>>2]=o.getSeconds(),Ie[n+4>>2]=o.getMinutes(),Ie[n+8>>2]=o.getHours(),Ie[n+12>>2]=o.getDate(),Ie[n+16>>2]=o.getMonth(),Ie[n+20>>2]=o.getFullYear()-1900,Ie[n+24>>2]=o.getDay();var i=Xr(o)|0;Ie[n+28>>2]=i,Ie[n+36>>2]=-(o.getTimezoneOffset()*60);var t=new Date(o.getFullYear(),0,1),r=new Date(o.getFullYear(),6,1).getTimezoneOffset(),a=t.getTimezoneOffset(),_=(r!=a&&o.getTimezoneOffset()==Math.min(a,r))|0;return Ie[n+32>>2]=_,0}function Zr(e,n,o,i,t,r,a){t=dt(t);try{var _=ve.getStreamFromFD(i),h=l.mmap(_,e,t,n,o),I=h.ptr;return Ie[r>>2]=h.allocated,ke[a>>2]=I,0}catch(q){if(typeof l>"u"||q.name!=="ErrnoError")throw q;return-q.errno}}function ei(e,n,o,i,t,r){r=dt(r);try{var a=ve.getStreamFromFD(t);if(o&2)ve.doMsync(e,a,n,i,r)}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}var ti=(e,n,o,i)=>{var t=new Date().getFullYear(),r=new Date(t,0,1),a=new Date(t,6,1),_=r.getTimezoneOffset(),h=a.getTimezoneOffset(),I=Math.max(_,h);ke[e>>2]=I*60,Ie[n>>2]=Number(_!=h);var q=(p)=>{var te=p>=0?"-":"+",j=Math.abs(p),U=String(Math.floor(j/60)).padStart(2,"0"),E=String(j%60).padStart(2,"0");return`UTC${te}${U}${E}`},R=q(_),M=q(h);if(h<_)ct(R,o,17),ct(M,i,17);else ct(R,i,17),ct(M,o,17)},pn=()=>performance.now(),hn=()=>Date.now(),ni=1,ri=(e)=>e>=0&&e<=3;function ii(e,n,o){if(n=dt(n),!ri(e))return 28;var i;if(e===0)i=hn();else if(ni)i=pn();else return 52;var t=Math.round(i*1000*1000);return ze[o>>3]=BigInt(t),0}var mn=()=>2147483648,si=()=>mn(),oi=(e)=>{var n=et.buffer.byteLength,o=(e-n+65535)/65536|0;try{return et.grow(o),Xt(),1}catch(i){}},ai=(e)=>{var n=Ze.length;e>>>=0;var o=mn();if(e>o)return!1;for(var i=1;i<=4;i*=2){var t=n*(1+0.2/i);t=Math.min(t,e+100663296);var r=Math.min(o,an(Math.max(e,t),65536)),a=oi(r);if(a)return!0}return!1},Rt={},li=()=>Ve,yt=()=>{if(!yt.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",n={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:li()};for(var o in Rt)if(Rt[o]===void 0)delete n[o];else n[o]=Rt[o];var i=[];for(var o in n)i.push(`${o}=${n[o]}`);yt.strings=i}return yt.strings},ci=(e,n)=>{var o=0,i=0;for(var t of yt()){var r=n+o;ke[e+i>>2]=r,o+=ct(t,r,1/0)+1,i+=4}return 0},_i=(e,n)=>{var o=yt();ke[e>>2]=o.length;var i=0;for(var t of o)i+=Et(t)+1;return ke[n>>2]=i,0},ui=0,fi=()=>tn||ui>0,di=(e)=>{if($t=e,!fi())s.onExit?.(e),Tt=!0;nt(e,new Zt(e))},pi=(e,n)=>{$t=e,di(e)},hi=pi;function mi(e){try{var n=ve.getStreamFromFD(e);return l.close(n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return o.errno}}function gi(e,n){try{var o=0,i=0,t=0,r=ve.getStreamFromFD(e),a=r.tty?2:l.isDir(r.mode)?3:l.isLink(r.mode)?7:4;return Be[n]=a,at[n+2>>1]=t,ze[n+8>>3]=BigInt(o),ze[n+16>>3]=BigInt(i),0}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return _.errno}}var bi=(e,n,o,i)=>{var t=0;for(var r=0;r<o;r++){var a=ke[n>>2],_=ke[n+4>>2];n+=8;try{var h=l.read(e,Be,a,_,i)}catch(I){if(t>0&&I instanceof l.ErrnoError&&(I.errno==6||I.errno==6))break;throw I}if(h<0)return-1;if(t+=h,h<_)break;if(typeof i<"u")i+=h}return t};function yi(e,n,o,i){try{var t=ve.getStreamFromFD(e),r=bi(t,n,o);return ke[i>>2]=r,0}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return a.errno}}function qi(e,n,o,i){n=dt(n);try{if(isNaN(n))return 22;var t=ve.getStreamFromFD(e);if(l.llseek(t,n,o),ze[i>>3]=BigInt(t.position),t.getdents&&n===0&&o===0)t.getdents=null;return 0}catch(r){if(typeof l>"u"||r.name!=="ErrnoError")throw r;return r.errno}}function vi(e){try{var n=ve.getStreamFromFD(e),o=n.stream_ops?.fsync?.(n);return o}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return i.errno}}var Si=(e,n,o,i)=>{if(o==1)return l.write(e,Be,ke[n>>2],ke[n+4>>2],i);var t=0;for(var r=0,a=n;r<o;r++,a+=8)t+=ke[a+4>>2];var _=new Uint8Array(t),h=0;for(var r=0;r<o;r++,n+=8){var I=ke[n>>2],q=ke[n+4>>2];_.set(Ze.subarray(I,I+q),h),h+=q}return l.write(e,_,0,t,i)};function wi(e,n,o,i){try{var t=ve.getStreamFromFD(e),r=Si(t,n,o);return ke[i>>2]=r,0}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return a.errno}}l.createPreloadedFile=kr,l.preloadFile=fn,l.staticInit();{if(er(),s.noExitRuntime)tn=s.noExitRuntime;if(s.print)wt=s.print;if(s.printErr)rt=s.printErr;if(s.arguments)We=s.arguments;if(s.thisProgram)Ve=s.thisProgram;var pt=s.preInit;if(pt){if(typeof pt=="function")s.preInit=pt=[pt];while(pt.length>0)pt.shift()()}}s.wasmMemory=et;function Ei(e,n){if(typeof crypto>"u"||!crypto.getRandomValues)return-1;try{var o=new Uint8Array(Ze.buffer,e,n),i=65536;for(var t=0;t<n;t+=i)crypto.getRandomValues(o.subarray(t,Math.min(t+i,n)));return 0}catch(r){return-1}}var ki,Ai,Ii,xi,Ti,Oi,Pi,Fi,Li,Ci,Ni,Di,Ri,Mi,ji,Wi,zi,Bi,Ui,Qi,Vi,Hi,Gi,Ki,$i,Ji,Xi,Yi,Zi,es,ts,ns,rs,is,ss,os,as,ls,cs,_s,us,fs,ds,ps,hs,ms,gs,bs,ys,qs,vs,Ss,ws,Es,ks,As,Is,xs,Ts,Os,Ps,Fs,Ls,Cs,Ns,Ds,Rs,Ms,js,Ws,zs,Bs,Us,Qs,Vs,Hs,Gs,Ks,$s,Js,Xs,Ys,Zs,eo,to,no,ro,io,so,oo,ao,lo,co,_o,uo,fo,po,ho,mo,go,bo,yo,qo,vo,So,wo,Eo,ko,Ao,Io,xo,To,Oo,Po,Fo,Lo,Co,No,Do,Ro,Mo,jo,Wo,zo,Bo,Uo,Qo,Vo,Ho,Go,Ko,$o,Jo,Xo,Yo,Zo,ea,ta,na,ra,ia,sa,oa,aa,la,ca,_a,ua,fa,da,pa,ha,ma,ga,ba,ya,qa,va,Sa,wa,Ea,ka,Aa,Ia,xa,Ta,Oa,Pa,Fa,La,Ca,Na,Da,Ra,Ma,ja,Wa,za,Ba,Ua,Qa,Va,Ha,Ga,Ka,$a,Ja,Xa,Ya,Za,el,tl,nl,rl,il,sl,ol,al,ll,cl,_l,ul,fl,dl,pl,hl,ml,gl,bl,yl,ql,vl,Sl,wl,El,kl,Al,Il,xl,Tl,Ol,Pl,Fl,Ll,Cl,Nl,Dl,Rl,Ml,jl,Wl,zl,Bl,Ul,Ql,Vl,Hl,Gl,Kl,$l,Jl,Xl,Yl,Zl,ec,tc,nc,rc,ic,sc,oc,ac,lc,cc,_c,uc,fc,dc,pc,hc,mc,gc,bc,yc,qc,vc,Sc,wc,Ec,kc,Ac,Ic,xc,Tc,Oc,Pc,Fc,gn,bn,Lc,yn,Cc;function Nc(e){ki=s._sqlite3_status64=e.sqlite3_status64,Ai=s._sqlite3_status=e.sqlite3_status,Ii=s._sqlite3_db_status64=e.sqlite3_db_status64,xi=s._sqlite3_msize=e.sqlite3_msize,Ti=s._sqlite3_db_status=e.sqlite3_db_status,Oi=s._sqlite3_vfs_find=e.sqlite3_vfs_find,Pi=s._sqlite3_initialize=e.sqlite3_initialize,Fi=s._sqlite3_vfs_register=e.sqlite3_vfs_register,Li=s._sqlite3_vfs_unregister=e.sqlite3_vfs_unregister,Ci=s._sqlite3_malloc=e.sqlite3_malloc,Ni=s._sqlite3_malloc64=e.sqlite3_malloc64,Di=s._sqlite3_free=e.sqlite3_free,Ri=s._sqlite3_realloc=e.sqlite3_realloc,Mi=s._sqlite3_realloc64=e.sqlite3_realloc64,ji=s._sqlite3_value_text=e.sqlite3_value_text,Wi=s._sqlite3_randomness=e.sqlite3_randomness,zi=s._sqlite3_stricmp=e.sqlite3_stricmp,Bi=s._sqlite3_strnicmp=e.sqlite3_strnicmp,Ui=s._sqlite3_uri_parameter=e.sqlite3_uri_parameter,Qi=s._sqlite3_uri_boolean=e.sqlite3_uri_boolean,Vi=s._sqlite3_serialize=e.sqlite3_serialize,Hi=s._sqlite3_prepare_v2=e.sqlite3_prepare_v2,Gi=s._sqlite3_step=e.sqlite3_step,Ki=s._sqlite3_column_int64=e.sqlite3_column_int64,$i=s._sqlite3_reset=e.sqlite3_reset,Ji=s._sqlite3_exec=e.sqlite3_exec,Xi=s._sqlite3_column_int=e.sqlite3_column_int,Yi=s._sqlite3_finalize=e.sqlite3_finalize,Zi=s._sqlite3_file_control=e.sqlite3_file_control,es=s._sqlite3_column_name=e.sqlite3_column_name,ts=s._sqlite3_column_text=e.sqlite3_column_text,ns=s._sqlite3_column_type=e.sqlite3_column_type,rs=s._sqlite3_errmsg=e.sqlite3_errmsg,is=s._sqlite3_deserialize=e.sqlite3_deserialize,ss=s._sqlite3_backup_init=e.sqlite3_backup_init,os=s._sqlite3_backup_step=e.sqlite3_backup_step,as=s._sqlite3_backup_finish=e.sqlite3_backup_finish,ls=s._sqlite3_backup_remaining=e.sqlite3_backup_remaining,cs=s._sqlite3_backup_pagecount=e.sqlite3_backup_pagecount,_s=s._sqlite3_clear_bindings=e.sqlite3_clear_bindings,us=s._sqlite3_value_blob=e.sqlite3_value_blob,fs=s._sqlite3_value_bytes=e.sqlite3_value_bytes,ds=s._sqlite3_value_double=e.sqlite3_value_double,ps=s._sqlite3_value_int=e.sqlite3_value_int,hs=s._sqlite3_value_int64=e.sqlite3_value_int64,ms=s._sqlite3_value_subtype=e.sqlite3_value_subtype,gs=s._sqlite3_value_pointer=e.sqlite3_value_pointer,bs=s._sqlite3_value_type=e.sqlite3_value_type,ys=s._sqlite3_value_nochange=e.sqlite3_value_nochange,qs=s._sqlite3_value_frombind=e.sqlite3_value_frombind,vs=s._sqlite3_value_dup=e.sqlite3_value_dup,Ss=s._sqlite3_value_free=e.sqlite3_value_free,ws=s._sqlite3_result_blob=e.sqlite3_result_blob,Es=s._sqlite3_result_error_toobig=e.sqlite3_result_error_toobig,ks=s._sqlite3_result_error_nomem=e.sqlite3_result_error_nomem,As=s._sqlite3_result_double=e.sqlite3_result_double,Is=s._sqlite3_result_error=e.sqlite3_result_error,xs=s._sqlite3_result_int=e.sqlite3_result_int,Ts=s._sqlite3_result_int64=e.sqlite3_result_int64,Os=s._sqlite3_result_null=e.sqlite3_result_null,Ps=s._sqlite3_result_pointer=e.sqlite3_result_pointer,Fs=s._sqlite3_result_subtype=e.sqlite3_result_subtype,Ls=s._sqlite3_result_text=e.sqlite3_result_text,Cs=s._sqlite3_result_zeroblob=e.sqlite3_result_zeroblob,Ns=s._sqlite3_result_zeroblob64=e.sqlite3_result_zeroblob64,Ds=s._sqlite3_result_error_code=e.sqlite3_result_error_code,Rs=s._sqlite3_user_data=e.sqlite3_user_data,Ms=s._sqlite3_context_db_handle=e.sqlite3_context_db_handle,js=s._sqlite3_vtab_nochange=e.sqlite3_vtab_nochange,Ws=s._sqlite3_vtab_in_first=e.sqlite3_vtab_in_first,zs=s._sqlite3_vtab_in_next=e.sqlite3_vtab_in_next,Bs=s._sqlite3_aggregate_context=e.sqlite3_aggregate_context,Us=s._sqlite3_get_auxdata=e.sqlite3_get_auxdata,Qs=s._sqlite3_set_auxdata=e.sqlite3_set_auxdata,Vs=s._sqlite3_column_count=e.sqlite3_column_count,Hs=s._sqlite3_data_count=e.sqlite3_data_count,Gs=s._sqlite3_column_blob=e.sqlite3_column_blob,Ks=s._sqlite3_column_bytes=e.sqlite3_column_bytes,$s=s._sqlite3_column_double=e.sqlite3_column_double,Js=s._sqlite3_column_value=e.sqlite3_column_value,Xs=s._sqlite3_column_decltype=e.sqlite3_column_decltype,Ys=s._sqlite3_column_database_name=e.sqlite3_column_database_name,Zs=s._sqlite3_column_table_name=e.sqlite3_column_table_name,eo=s._sqlite3_column_origin_name=e.sqlite3_column_origin_name,to=s._sqlite3_bind_blob=e.sqlite3_bind_blob,no=s._sqlite3_bind_double=e.sqlite3_bind_double,ro=s._sqlite3_bind_int=e.sqlite3_bind_int,io=s._sqlite3_bind_int64=e.sqlite3_bind_int64,so=s._sqlite3_bind_null=e.sqlite3_bind_null,oo=s._sqlite3_bind_pointer=e.sqlite3_bind_pointer,ao=s._sqlite3_bind_text=e.sqlite3_bind_text,lo=s._sqlite3_bind_zeroblob=e.sqlite3_bind_zeroblob,co=s._sqlite3_bind_parameter_count=e.sqlite3_bind_parameter_count,_o=s._sqlite3_bind_parameter_name=e.sqlite3_bind_parameter_name,uo=s._sqlite3_bind_parameter_index=e.sqlite3_bind_parameter_index,fo=s._sqlite3_db_handle=e.sqlite3_db_handle,po=s._sqlite3_stmt_readonly=e.sqlite3_stmt_readonly,ho=s._sqlite3_stmt_isexplain=e.sqlite3_stmt_isexplain,mo=s._sqlite3_stmt_explain=e.sqlite3_stmt_explain,go=s._sqlite3_stmt_busy=e.sqlite3_stmt_busy,bo=s._sqlite3_next_stmt=e.sqlite3_next_stmt,yo=s._sqlite3_stmt_status=e.sqlite3_stmt_status,qo=s._sqlite3_sql=e.sqlite3_sql,vo=s._sqlite3_expanded_sql=e.sqlite3_expanded_sql,So=s._sqlite3_preupdate_old=e.sqlite3_preupdate_old,wo=s._sqlite3_preupdate_count=e.sqlite3_preupdate_count,Eo=s._sqlite3_preupdate_depth=e.sqlite3_preupdate_depth,ko=s._sqlite3_preupdate_blobwrite=e.sqlite3_preupdate_blobwrite,Ao=s._sqlite3_preupdate_new=e.sqlite3_preupdate_new,Io=s._sqlite3_value_numeric_type=e.sqlite3_value_numeric_type,xo=s._sqlite3_set_authorizer=e.sqlite3_set_authorizer,To=s._sqlite3_strglob=e.sqlite3_strglob,Oo=s._sqlite3_strlike=e.sqlite3_strlike,Po=s._sqlite3_auto_extension=e.sqlite3_auto_extension,Fo=s._sqlite3_cancel_auto_extension=e.sqlite3_cancel_auto_extension,Lo=s._sqlite3_reset_auto_extension=e.sqlite3_reset_auto_extension,Co=s._sqlite3_prepare_v3=e.sqlite3_prepare_v3,No=s._sqlite3_create_module=e.sqlite3_create_module,Do=s._sqlite3_create_module_v2=e.sqlite3_create_module_v2,Ro=s._sqlite3_drop_modules=e.sqlite3_drop_modules,Mo=s._sqlite3_declare_vtab=e.sqlite3_declare_vtab,jo=s._sqlite3_vtab_on_conflict=e.sqlite3_vtab_on_conflict,Wo=s._sqlite3_vtab_collation=e.sqlite3_vtab_collation,zo=s._sqlite3_vtab_in=e.sqlite3_vtab_in,Bo=s._sqlite3_vtab_rhs_value=e.sqlite3_vtab_rhs_value,Uo=s._sqlite3_vtab_distinct=e.sqlite3_vtab_distinct,Qo=s._sqlite3_keyword_name=e.sqlite3_keyword_name,Vo=s._sqlite3_keyword_count=e.sqlite3_keyword_count,Ho=s._sqlite3_keyword_check=e.sqlite3_keyword_check,Go=s._sqlite3_complete=e.sqlite3_complete,Ko=s._sqlite3_libversion=e.sqlite3_libversion,$o=s._sqlite3_libversion_number=e.sqlite3_libversion_number,Jo=s._sqlite3mc_vfs_create=e.sqlite3mc_vfs_create,Xo=s._sqlite3_shutdown=e.sqlite3_shutdown,Yo=s._sqlite3mc_vfs_shutdown=e.sqlite3mc_vfs_shutdown,Zo=s._sqlite3_last_insert_rowid=e.sqlite3_last_insert_rowid,ea=s._sqlite3_set_last_insert_rowid=e.sqlite3_set_last_insert_rowid,ta=s._sqlite3_changes64=e.sqlite3_changes64,na=s._sqlite3_changes=e.sqlite3_changes,ra=s._sqlite3_total_changes64=e.sqlite3_total_changes64,ia=s._sqlite3_total_changes=e.sqlite3_total_changes,sa=s._sqlite3_txn_state=e.sqlite3_txn_state,oa=s._sqlite3_close_v2=e.sqlite3_close_v2,aa=s._sqlite3_busy_handler=e.sqlite3_busy_handler,la=s._sqlite3_progress_handler=e.sqlite3_progress_handler,ca=s._sqlite3_busy_timeout=e.sqlite3_busy_timeout,_a=s._sqlite3_interrupt=e.sqlite3_interrupt,ua=s._sqlite3_is_interrupted=e.sqlite3_is_interrupted,fa=s._sqlite3_create_function=e.sqlite3_create_function,da=s._sqlite3_create_function_v2=e.sqlite3_create_function_v2,pa=s._sqlite3_create_window_function=e.sqlite3_create_window_function,ha=s._sqlite3_overload_function=e.sqlite3_overload_function,ma=s._sqlite3_trace_v2=e.sqlite3_trace_v2,ga=s._sqlite3_commit_hook=e.sqlite3_commit_hook,ba=s._sqlite3_update_hook=e.sqlite3_update_hook,ya=s._sqlite3_rollback_hook=e.sqlite3_rollback_hook,qa=s._sqlite3_preupdate_hook=e.sqlite3_preupdate_hook,va=s._sqlite3_set_errmsg=e.sqlite3_set_errmsg,Sa=s._sqlite3_error_offset=e.sqlite3_error_offset,wa=s._sqlite3_errcode=e.sqlite3_errcode,Ea=s._sqlite3_extended_errcode=e.sqlite3_extended_errcode,ka=s._sqlite3_errstr=e.sqlite3_errstr,Aa=s._sqlite3_limit=e.sqlite3_limit,Ia=s._sqlite3_open=e.sqlite3_open,xa=s._sqlite3_open_v2=e.sqlite3_open_v2,Ta=s._sqlite3_create_collation=e.sqlite3_create_collation,Oa=s._sqlite3_create_collation_v2=e.sqlite3_create_collation_v2,Pa=s._sqlite3_collation_needed=e.sqlite3_collation_needed,Fa=s._sqlite3_get_autocommit=e.sqlite3_get_autocommit,La=s._sqlite3_table_column_metadata=e.sqlite3_table_column_metadata,Ca=s._sqlite3_extended_result_codes=e.sqlite3_extended_result_codes,Na=s._sqlite3_uri_key=e.sqlite3_uri_key,Da=s._sqlite3_uri_int64=e.sqlite3_uri_int64,Ra=s._sqlite3_db_name=e.sqlite3_db_name,Ma=s._sqlite3_db_filename=e.sqlite3_db_filename,ja=s._sqlite3_db_readonly=e.sqlite3_db_readonly,Wa=s._sqlite3_compileoption_used=e.sqlite3_compileoption_used,za=s._sqlite3_compileoption_get=e.sqlite3_compileoption_get,Ba=s._sqlite3session_diff=e.sqlite3session_diff,Ua=s._sqlite3session_attach=e.sqlite3session_attach,Qa=s._sqlite3session_create=e.sqlite3session_create,Va=s._sqlite3session_delete=e.sqlite3session_delete,Ha=s._sqlite3session_table_filter=e.sqlite3session_table_filter,Ga=s._sqlite3session_changeset=e.sqlite3session_changeset,Ka=s._sqlite3session_changeset_strm=e.sqlite3session_changeset_strm,$a=s._sqlite3session_patchset_strm=e.sqlite3session_patchset_strm,Ja=s._sqlite3session_patchset=e.sqlite3session_patchset,Xa=s._sqlite3session_enable=e.sqlite3session_enable,Ya=s._sqlite3session_indirect=e.sqlite3session_indirect,Za=s._sqlite3session_isempty=e.sqlite3session_isempty,el=s._sqlite3session_memory_used=e.sqlite3session_memory_used,tl=s._sqlite3session_object_config=e.sqlite3session_object_config,nl=s._sqlite3session_changeset_size=e.sqlite3session_changeset_size,rl=s._sqlite3changeset_start=e.sqlite3changeset_start,il=s._sqlite3changeset_start_v2=e.sqlite3changeset_start_v2,sl=s._sqlite3changeset_start_strm=e.sqlite3changeset_start_strm,ol=s._sqlite3changeset_start_v2_strm=e.sqlite3changeset_start_v2_strm,al=s._sqlite3changeset_next=e.sqlite3changeset_next,ll=s._sqlite3changeset_op=e.sqlite3changeset_op,cl=s._sqlite3changeset_pk=e.sqlite3changeset_pk,_l=s._sqlite3changeset_old=e.sqlite3changeset_old,ul=s._sqlite3changeset_new=e.sqlite3changeset_new,fl=s._sqlite3changeset_conflict=e.sqlite3changeset_conflict,dl=s._sqlite3changeset_fk_conflicts=e.sqlite3changeset_fk_conflicts,pl=s._sqlite3changeset_finalize=e.sqlite3changeset_finalize,hl=s._sqlite3changeset_invert=e.sqlite3changeset_invert,ml=s._sqlite3changeset_invert_strm=e.sqlite3changeset_invert_strm,gl=s._sqlite3changeset_apply_v2=e.sqlite3changeset_apply_v2,bl=s._sqlite3changeset_apply_v3=e.sqlite3changeset_apply_v3,yl=s._sqlite3changeset_apply=e.sqlite3changeset_apply,ql=s._sqlite3changeset_apply_v3_strm=e.sqlite3changeset_apply_v3_strm,vl=s._sqlite3changeset_apply_v2_strm=e.sqlite3changeset_apply_v2_strm,Sl=s._sqlite3changeset_apply_strm=e.sqlite3changeset_apply_strm,wl=s._sqlite3changegroup_new=e.sqlite3changegroup_new,El=s._sqlite3changegroup_add=e.sqlite3changegroup_add,kl=s._sqlite3changegroup_output=e.sqlite3changegroup_output,Al=s._sqlite3changegroup_add_strm=e.sqlite3changegroup_add_strm,Il=s._sqlite3changegroup_output_strm=e.sqlite3changegroup_output_strm,xl=s._sqlite3changegroup_delete=e.sqlite3changegroup_delete,Tl=s._sqlite3changeset_concat=e.sqlite3changeset_concat,Ol=s._sqlite3changeset_concat_strm=e.sqlite3changeset_concat_strm,Pl=s._sqlite3session_config=e.sqlite3session_config,Fl=s._sqlite3_sourceid=e.sqlite3_sourceid,Ll=s._sqlite3mc_version=e.sqlite3mc_version,Cl=s._sqlite3mc_config=e.sqlite3mc_config,Nl=s._sqlite3mc_cipher_count=e.sqlite3mc_cipher_count,Dl=s._sqlite3mc_cipher_index=e.sqlite3mc_cipher_index,Rl=s._sqlite3mc_cipher_name=e.sqlite3mc_cipher_name,Ml=s._sqlite3mc_cipher_name_copy=e.sqlite3mc_cipher_name_copy,jl=s._sqlite3mc_config_cipher=e.sqlite3mc_config_cipher,Wl=s._sqlite3mc_codec_data=e.sqlite3mc_codec_data,zl=s._sqlite3_activate_see=e.sqlite3_activate_see,Bl=s._sqlite3_key=e.sqlite3_key,Ul=s._sqlite3_key_v2=e.sqlite3_key_v2,Ql=s._sqlite3_rekey_v2=e.sqlite3_rekey_v2,Vl=s._sqlite3_rekey=e.sqlite3_rekey,Hl=s._sqlite3mc_vfs_destroy=e.sqlite3mc_vfs_destroy,Gl=s._sqlite3__wasm_pstack_ptr=e.sqlite3__wasm_pstack_ptr,Kl=s._sqlite3__wasm_pstack_restore=e.sqlite3__wasm_pstack_restore,$l=s._sqlite3__wasm_pstack_alloc=e.sqlite3__wasm_pstack_alloc,Jl=s._sqlite3__wasm_pstack_remaining=e.sqlite3__wasm_pstack_remaining,Xl=s._sqlite3__wasm_pstack_quota=e.sqlite3__wasm_pstack_quota,Yl=s._sqlite3__wasm_test_struct=e.sqlite3__wasm_test_struct,Zl=s._sqlite3__wasm_enum_json=e.sqlite3__wasm_enum_json,ec=s._sqlite3__wasm_vfs_unlink=e.sqlite3__wasm_vfs_unlink,tc=s._sqlite3__wasm_db_vfs=e.sqlite3__wasm_db_vfs,nc=s._sqlite3__wasm_db_reset=e.sqlite3__wasm_db_reset,rc=s._sqlite3__wasm_db_export_chunked=e.sqlite3__wasm_db_export_chunked,ic=s._sqlite3__wasm_db_serialize=e.sqlite3__wasm_db_serialize,sc=s._sqlite3__wasm_vfs_create_file=e.sqlite3__wasm_vfs_create_file,oc=s._sqlite3__wasm_posix_create_file=e.sqlite3__wasm_posix_create_file,ac=s._sqlite3__wasm_kvvfsMakeKey=e.sqlite3__wasm_kvvfsMakeKey,lc=s._sqlite3__wasm_kvvfs_methods=e.sqlite3__wasm_kvvfs_methods,cc=s._sqlite3__wasm_vtab_config=e.sqlite3__wasm_vtab_config,_c=s._sqlite3__wasm_db_config_ip=e.sqlite3__wasm_db_config_ip,uc=s._sqlite3__wasm_db_config_pii=e.sqlite3__wasm_db_config_pii,fc=s._sqlite3__wasm_db_config_s=e.sqlite3__wasm_db_config_s,dc=s._sqlite3__wasm_config_i=e.sqlite3__wasm_config_i,pc=s._sqlite3__wasm_config_ii=e.sqlite3__wasm_config_ii,hc=s._sqlite3__wasm_config_j=e.sqlite3__wasm_config_j,mc=s._sqlite3__wasm_qfmt_token=e.sqlite3__wasm_qfmt_token,gc=s._sqlite3__wasm_kvvfs_decode=e.sqlite3__wasm_kvvfs_decode,bc=s._sqlite3__wasm_kvvfs_encode=e.sqlite3__wasm_kvvfs_encode,yc=s._sqlite3__wasm_init_wasmfs=e.sqlite3__wasm_init_wasmfs,qc=s._sqlite3__wasm_test_intptr=e.sqlite3__wasm_test_intptr,vc=s._sqlite3__wasm_test_voidptr=e.sqlite3__wasm_test_voidptr,Sc=s._sqlite3__wasm_test_int64_max=e.sqlite3__wasm_test_int64_max,wc=s._sqlite3__wasm_test_int64_min=e.sqlite3__wasm_test_int64_min,Ec=s._sqlite3__wasm_test_int64_times2=e.sqlite3__wasm_test_int64_times2,kc=s._sqlite3__wasm_test_int64_minmax=e.sqlite3__wasm_test_int64_minmax,Ac=s._sqlite3__wasm_test_int64ptr=e.sqlite3__wasm_test_int64ptr,Ic=s._sqlite3__wasm_test_stack_overflow=e.sqlite3__wasm_test_stack_overflow,xc=s._sqlite3__wasm_test_str_hello=e.sqlite3__wasm_test_str_hello,Tc=s._sqlite3__wasm_SQLTester_strglob=e.sqlite3__wasm_SQLTester_strglob,Oc=s._malloc=e.malloc,Pc=s._free=e.free,Fc=s._realloc=e.realloc,gn=e.emscripten_builtin_memalign,bn=e._emscripten_stack_restore,Lc=e._emscripten_stack_alloc,yn=e.emscripten_stack_get_current,Cc=e.__indirect_function_table}var qn={__syscall_chmod:Ir,__syscall_faccessat:xr,__syscall_fchmod:Tr,__syscall_fchown32:Or,__syscall_fcntl64:Pr,__syscall_fstat64:Fr,__syscall_ftruncate64:Nr,__syscall_getcwd:Dr,__syscall_ioctl:Rr,__syscall_lstat64:Mr,__syscall_mkdirat:jr,__syscall_newfstatat:Wr,__syscall_openat:zr,__syscall_readlinkat:Br,__syscall_rmdir:Ur,__syscall_stat64:Qr,__syscall_unlinkat:Vr,__syscall_utimensat:Hr,_abort_js:Gr,_localtime_js:Yr,_mmap_js:Zr,_munmap_js:ei,_tzset_js:ti,clock_time_get:ii,emscripten_date_now:hn,emscripten_get_heap_max:si,emscripten_get_now:pn,emscripten_resize_heap:ai,environ_get:ci,environ_sizes_get:_i,exit:hi,fd_close:mi,fd_fdstat_get:gi,fd_read:yi,fd_seek:qi,fd_sync:vi,fd_write:wi,memory:et,wasm_crypto_getrandom:Ei};async function Dc(){if(tr(),lt)await qr();var e=s.setStatus;if(e)e("Running..."),await new Promise((n)=>setTimeout(n,1)),setTimeout(e,1,"");if(Tt)return;nr(),s.onRuntimeInitialized?.(),rr()}var ht=await _r();return await Dc(),s.runSQLite3PostLoadInit=async function(e,n,o){delete n.runSQLite3PostLoadInit,globalThis.sqlite3ApiBootstrap=async function i(t=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;let r=(...f)=>Object.assign(Object.create(null),...f),a=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},t);Object.assign(a,{allocExportName:a.useStdAlloc?"malloc":"sqlite3_malloc",deallocExportName:a.useStdAlloc?"free":"sqlite3_free",reallocExportName:a.useStdAlloc?"realloc":"sqlite3_realloc"}),["exports","memory","functionTable","wasmfsOpfsDir"].forEach((f)=>{if(typeof a[f]==="function")a[f]=a[f]()});let _=r(),h=r(),I=(f)=>_.sqlite3_js_rc_str&&_.sqlite3_js_rc_str(f)||"Unknown result code #"+f,q=(f)=>typeof f==="number"&&f===(f|0)&&f<=2147483647&&f>=-2147483648;class R extends Error{constructor(...f){let S;if(f.length)if(q(f[0]))if(S=f[0],f.length===1)super(I(f[0]));else{let D=I(S);if(typeof f[1]==="object")super(D,f[1]);else{f[0]=D+":";super(f.join(" "))}}else if(f.length===2&&typeof f[1]==="object")super(...f);else super(f.join(" "));this.resultCode=S||_.SQLITE_ERROR,this.name="SQLite3Error"}}R.toss=(...f)=>{throw new R(...f)};let M=R.toss;if(a.wasmfsOpfsDir&&!/^\/[^/]+$/.test(a.wasmfsOpfsDir))M("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");let p=function f(S){if(!f._max)f._max=BigInt("0x7fffffffffffffff"),f._min=~f._max;return S>=f._min&&S<=f._max},te=(f)=>f>=-0x7fffffffn-1n&&f<=0x7fffffffn,j=function f(S){if(!f._min)f._min=Number.MIN_SAFE_INTEGER,f._max=Number.MAX_SAFE_INTEGER;return S>=f._min&&S<=f._max},U=(f)=>f&&f.constructor&&q(f.constructor.BYTES_PER_ELEMENT)?f:!1,E=(f)=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),g=(f)=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),F=(f)=>E(f)||M("Value is not of a supported TypedArray type."),x=function(f){if(g(f))return h.typedArrayToString(f instanceof ArrayBuffer?new Uint8Array(f):f,0,f.length);else if(Array.isArray(f))return f.join("");else if(h.isPtr(f))f=h.cstrToJs(f);return f};class A extends Error{constructor(...f){if(f.length===2&&typeof f[1]==="object")super(...f);else if(f.length)super(f.join(" "));else super("Allocation failed.");this.resultCode=_.SQLITE_NOMEM,this.name="WasmAllocError"}}A.toss=(...f)=>{throw new A(...f)},Object.assign(_,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(f,S,D,J,ie,le,Se,me,K)=>{},sqlite3_create_function:(f,S,D,J,ie,le,Se,me)=>{},sqlite3_create_window_function:(f,S,D,J,ie,le,Se,me,K,oe)=>{},sqlite3_prepare_v3:(f,S,D,J,ie,le)=>{},sqlite3_prepare_v2:(f,S,D,J,ie)=>{},sqlite3_exec:(f,S,D,J,ie)=>{},sqlite3_randomness:(f,S)=>{}});let N={affirmBindableTypedArray:F,flexibleString:x,bigIntFits32:te,bigIntFits64:p,bigIntFitsDouble:j,isBindableTypedArray:E,isInt32:q,isSQLableTypedArray:g,isTypedArray:U,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,toss:function(...f){throw Error(f.join(" "))},toss3:M,typedArrayPart:h.typedArrayPart,nu:r,assert:function(f,S){if(!f)N.toss("Assertion failed:",S)},affirmDbHeader:function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);let S="SQLite format 3";if(S.length>f.byteLength)M("Input does not contain an SQLite3 database header.");for(let D=0;D<S.length;++D)if(S.charCodeAt(D)!==f[D])break},affirmIsDb:function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);let S=f.byteLength;if(S<512||S%512!==0)M("Byte array size",S,"is invalid for an SQLite3 db.");N.affirmDbHeader(f)}};Object.assign(h,{exports:a.exports||M("Missing API config.exports (WASM module exports)."),memory:a.memory||a.exports.memory||M("API config object requires a WebAssembly.Memory object","in either config.exports.memory (exported)","or config.memory (imported)."),pointerSize:typeof a.exports.sqlite3_libversion()==="number"?4:8,bigIntEnabled:!!a.bigIntEnabled,functionTable:a.functionTable,alloc:void 0,realloc:void 0,dealloc:void 0}),h.allocFromTypedArray=function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);F(f);let S=h.alloc(f.byteLength||1);return h.heapForSize(f.constructor).set(f.byteLength?f:[0],Number(S)),S};{let{allocExportName:f,deallocExportName:S,reallocExportName:D}=a;for(let J of[f,S,D])if(!(h.exports[J]instanceof Function))M("Missing required exports[",J,"] function.");h.alloc=function J(ie){return J.impl(ie)||A.toss("Failed to allocate",ie," bytes.")},h.alloc.impl=h.exports[f],h.realloc=function J(ie,le){let Se=J.impl(h.ptr.coerce(ie),le);return le?Se||A.toss("Failed to reallocate",le," bytes."):h.ptr.null},h.realloc.impl=h.exports[D],h.dealloc=function J(ie){J.impl(h.ptr.coerce(ie))},h.dealloc.impl=h.exports[S]}h.compileOptionUsed=function f(S){if(!arguments.length){if(f._result)return f._result;else if(!f._opt)f._rx=/^([^=]+)=(.+)/,f._rxInt=/^-?\d+$/,f._opt=function(Se,me){let K=f._rx.exec(Se);me[0]=K?K[1]:Se,me[1]=K?f._rxInt.test(K[2])?+K[2]:K[2]:!0};let D=r(),J=[0,0],ie=0,le;while(le=_.sqlite3_compileoption_get(ie++))f._opt(le,J),D[J[0]]=J[1];return f._result=D}else if(Array.isArray(S)){let D=r();return S.forEach((J)=>{D[J]=_.sqlite3_compileoption_used(J)}),D}else if(typeof S==="object")return Object.keys(S).forEach((D)=>{S[D]=_.sqlite3_compileoption_used(D)}),S;return typeof S==="string"?!!_.sqlite3_compileoption_used(S):!1},h.pstack=r({restore:h.exports.sqlite3__wasm_pstack_restore,alloc:function(f){if(typeof f==="string"&&!(f=h.sizeofIR(f)))A.toss("Invalid value for pstack.alloc(",arguments[0],")");return h.exports.sqlite3__wasm_pstack_alloc(f)||A.toss("Could not allocate",f,"bytes from the pstack.")},allocChunks:function(f,S){if(typeof S==="string"&&!(S=h.sizeofIR(S)))A.toss("Invalid size value for allocChunks(",arguments[1],")");let D=h.pstack.alloc(f*S),J=[D],ie=1,le=S;for(;ie<f;++ie,le+=S)J.push(h.ptr.add(D,le));return J},allocPtr:(f=1,S=!0)=>f===1?h.pstack.alloc(S?8:h.ptr.size):h.pstack.allocChunks(f,S?8:h.ptr.size),call:function(f){let S=h.pstack.pointer;try{return f(z)}finally{h.pstack.restore(S)}}}),Object.defineProperties(h.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_remaining}}),_.sqlite3_randomness=(...f)=>{if(f.length===1&&N.isTypedArray(f[0])&&f[0].BYTES_PER_ELEMENT===1){let S=f[0];if(S.byteLength===0)return h.exports.sqlite3_randomness(0,h.ptr.null),S;let D=h.pstack.pointer;try{let J=S.byteLength,ie=0,le=h.exports.sqlite3_randomness,Se=h.heap8u(),me=J<512?J:512,K=h.pstack.alloc(me);do{let oe=J>me?me:J;le(oe,K),S.set(h.typedArrayPart(Se,K,h.ptr.add(K,oe)),ie),J-=oe,ie+=oe}while(J>0)}catch(J){a.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",J)}finally{h.pstack.restore(D)}return S}h.exports.sqlite3_randomness(...f)},_.sqlite3_wasmfs_opfs_dir=function(){if(this.dir!==void 0)return this.dir;let f=a.wasmfsOpfsDir;if(!f||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!h.exports.sqlite3__wasm_init_wasmfs)return this.dir="";try{if(f&&h.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],f)===0)return this.dir=f;else return this.dir=""}catch(S){return this.dir=""}}.bind(r()),_.sqlite3_wasmfs_filename_is_persistent=function(f){let S=_.sqlite3_wasmfs_opfs_dir();return S&&f?f.startsWith(S+"/"):!1},_.sqlite3_js_db_uses_vfs=function(f,S,D=0){try{let J=_.sqlite3_vfs_find(S);if(!J)return!1;else if(!f)return J===_.sqlite3_vfs_find(0)?J:!1;else return J===_.sqlite3_js_db_vfs(f,D)?J:!1}catch(J){return!1}},_.sqlite3_js_vfs_list=function(){let f=[],S=_.sqlite3_vfs_find(h.ptr.null);while(S){let D=new _.sqlite3_vfs(S);f.push(h.cstrToJs(D.$zName)),S=D.$pNext,D.dispose()}return f},_.sqlite3_js_db_export=function(f,S=0){if(f=h.xWrap.testConvertArg("sqlite3*",f),!f)M("Invalid sqlite3* argument.");if(!h.bigIntEnabled)M("BigInt support is not enabled.");let D=h.scopedAllocPush(),J;try{let ie=h.scopedAlloc(8+h.ptr.size),le=h.ptr.add(ie,8),Se=S?h.isPtr(S)?S:h.scopedAllocCString(""+S):h.ptr.null,me=h.exports.sqlite3__wasm_db_serialize(f,Se,le,ie,0);if(me)M("Database serialization failed with code",z.capi.sqlite3_js_rc_str(me));J=h.peekPtr(le);let K=h.peek(ie,"i64");return me=K?h.heap8u().slice(Number(J),Number(J)+Number(K)):new Uint8Array,me}finally{if(J)h.exports.sqlite3_free(J);h.scopedAllocPop(D)}},_.sqlite3_js_db_vfs=(f,S=h.ptr.null)=>N.sqlite3__wasm_db_vfs(f,S),_.sqlite3_js_aggregate_context=(f,S)=>_.sqlite3_aggregate_context(f,S)||(S?A.toss("Cannot allocate",S,"bytes for sqlite3_aggregate_context()"):0),_.sqlite3_js_posix_create_file=function(f,S,D){let J;if(S&&h.isPtr(S))J=S;else if(S instanceof ArrayBuffer||S instanceof Uint8Array){if(J=h.allocFromTypedArray(S),arguments.length<3||!N.isInt32(D)||D<0)D=S.byteLength}else R.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{if(!N.isInt32(D)||D<0)R.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");let ie=N.sqlite3__wasm_posix_create_file(f,J,D);if(ie)R.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(ie))}finally{if(J&&J!==S)h.dealloc(J)}},_.sqlite3_js_vfs_create_file=function(f,S,D,J){a.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 ie;if(D)if(h.isPtr(D))ie=D;else{if(D instanceof ArrayBuffer)D=new Uint8Array(D);if(D instanceof Uint8Array){if(ie=h.allocFromTypedArray(D),arguments.length<4||!N.isInt32(J)||J<0)J=D.byteLength}else R.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")}else ie=0;if(!N.isInt32(J)||J<0){if(ie&&ie!==D)h.dealloc(ie);R.toss("Invalid 4th argument for sqlite3_js_vfs_create_file().")}try{let le=N.sqlite3__wasm_vfs_create_file(f,S,ie,J);if(le)R.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(le))}finally{if(ie&&ie!==D)h.dealloc(ie)}},_.sqlite3_js_sql_to_string=(f)=>{if(typeof f==="string")return f;let S=x(v);return S===v?void 0:S},_.sqlite3_db_config=function(f,S,...D){switch(S){case _.SQLITE_DBCONFIG_ENABLE_FKEY:case _.SQLITE_DBCONFIG_ENABLE_TRIGGER:case _.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER:case _.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION:case _.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE:case _.SQLITE_DBCONFIG_ENABLE_QPSG:case _.SQLITE_DBCONFIG_TRIGGER_EQP:case _.SQLITE_DBCONFIG_RESET_DATABASE:case _.SQLITE_DBCONFIG_DEFENSIVE:case _.SQLITE_DBCONFIG_WRITABLE_SCHEMA:case _.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE:case _.SQLITE_DBCONFIG_DQS_DML:case _.SQLITE_DBCONFIG_DQS_DDL:case _.SQLITE_DBCONFIG_ENABLE_VIEW:case _.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT:case _.SQLITE_DBCONFIG_TRUSTED_SCHEMA:case _.SQLITE_DBCONFIG_STMT_SCANSTATUS:case _.SQLITE_DBCONFIG_REVERSE_SCANORDER:case _.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE:case _.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE:case _.SQLITE_DBCONFIG_ENABLE_COMMENTS:case _.SQLITE_DBCONFIG_FP_DIGITS:if(!this.ip)this.ip=h.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"]);return this.ip(f,S,D[0],D[1]||0);case _.SQLITE_DBCONFIG_LOOKASIDE:if(!this.pii)this.pii=h.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"]);return this.pii(f,S,D[0],D[1],D[2]);case _.SQLITE_DBCONFIG_MAINDBNAME:if(!this.s)this.s=h.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"]);return this.s(f,S,D[0]);default:return _.SQLITE_MISUSE}}.bind(r()),_.sqlite3_value_to_js=function(f,S=!0){let D,J=_.sqlite3_value_type(f);switch(J){case _.SQLITE_INTEGER:if(h.bigIntEnabled){if(D=_.sqlite3_value_int64(f),N.bigIntFitsDouble(D))D=Number(D)}else D=_.sqlite3_value_double(f);break;case _.SQLITE_FLOAT:D=_.sqlite3_value_double(f);break;case _.SQLITE_TEXT:D=_.sqlite3_value_text(f);break;case _.SQLITE_BLOB:{let ie=_.sqlite3_value_bytes(f),le=_.sqlite3_value_blob(f);if(ie&&!le)z.WasmAllocError.toss("Cannot allocate memory for blob argument of",ie,"byte(s)");D=ie?h.heap8u().slice(Number(le),Number(le)+Number(ie)):null;break}case _.SQLITE_NULL:D=null;break;default:if(S)M(_.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",J);D=void 0}return D},_.sqlite3_values_to_js=function(f,S,D=!0){let J,ie=[];for(J=0;J<f;++J)ie.push(_.sqlite3_value_to_js(h.peekPtr(h.ptr.add(S,h.ptr.size*J)),D));return ie},_.sqlite3_result_error_js=function(f,S){if(S instanceof A)_.sqlite3_result_error_nomem(f);else _.sqlite3_result_error(f,""+S,-1)},_.sqlite3_result_js=function(f,S){if(S instanceof Error){_.sqlite3_result_error_js(f,S);return}try{switch(typeof S){case"undefined":break;case"boolean":_.sqlite3_result_int(f,S?1:0);break;case"bigint":if(N.bigIntFits32(S))_.sqlite3_result_int(f,Number(S));else if(N.bigIntFitsDouble(S))_.sqlite3_result_double(f,Number(S));else if(h.bigIntEnabled)if(N.bigIntFits64(S))_.sqlite3_result_int64(f,S);else M("BigInt value",S.toString(),"is too BigInt for int64.");else M("BigInt value",S.toString(),"is too BigInt.");break;case"number":{let D;if(N.isInt32(S))D=_.sqlite3_result_int;else if(h.bigIntEnabled&&Number.isInteger(S)&&N.bigIntFits64(BigInt(S)))D=_.sqlite3_result_int64;else D=_.sqlite3_result_double;D(f,S);break}case"string":{let[D,J]=h.allocCString(S,!0);_.sqlite3_result_text(f,D,J,_.SQLITE_WASM_DEALLOC);break}case"object":if(S===null){_.sqlite3_result_null(f);break}else if(N.isBindableTypedArray(S)){let D=h.allocFromTypedArray(S);_.sqlite3_result_blob(f,D,S.byteLength,_.SQLITE_WASM_DEALLOC);break}default:M("Don't not how to handle this UDF result value:",typeof S,S)}}catch(D){_.sqlite3_result_error_js(f,D)}},_.sqlite3_column_js=function(f,S,D=!0){let J=_.sqlite3_column_value(f,S);return J===0?void 0:_.sqlite3_value_to_js(J,D)};{let f=function(S,D,J){if(J=_[J],!this.ptr)this.ptr=h.allocPtr();else h.pokePtr(this.ptr,0);let ie=J(S,D,this.ptr);if(ie)return R.toss(ie,arguments[2]+"() failed with code "+ie);let le=h.peekPtr(this.ptr);return le?_.sqlite3_value_to_js(le,!0):void 0}.bind(r());_.sqlite3_preupdate_new_js=(S,D)=>f(S,D,"sqlite3_preupdate_new"),_.sqlite3_preupdate_old_js=(S,D)=>f(S,D,"sqlite3_preupdate_old"),_.sqlite3changeset_new_js=(S,D)=>f(S,D,"sqlite3changeset_new"),_.sqlite3changeset_old_js=(S,D)=>f(S,D,"sqlite3changeset_old")}_.sqlite3_js_retry_busy=function(f,S,D){for(let J=1;J<=f;++J)try{if(D&&J>1)D(J);let ie=S();if(_.SQLITE_BUSY===ie){if(J===f)throw new R(ie,["sqlite3_js_retry_busy() max retry attempts (",f,") reached."].join(""));continue}return ie}catch(ie){if(J<f&&ie instanceof R&&ie.resultCode===_.SQLITE_BUSY)continue;throw ie}};let z={WasmAllocError:A,SQLite3Error:R,capi:_,util:N,wasm:h,config:a,version:r(),client:void 0,asyncPostInit:async function f(){if(f.isReady instanceof Promise)return f.isReady;let S=this.initializersAsync;delete this.initializersAsync;let D=async()=>{if(!z.__isUnderTest)delete z.util,delete z.StructBinder,delete z.opfs;return z},J=(le)=>{throw a.error("an async sqlite3 initializer failed:",le),le};if(!S||!S.length)return f.isReady=D().catch(J);S=S.map((le)=>le instanceof Function?async(Se)=>le(z):le),S.push(D);let ie=Promise.resolve(z);while(S.length)ie=ie.then(S.shift());return f.isReady=ie.catch(J)}.bind(i),scriptInfo:void 0};if(typeof o<"u")z.__isUnderTest=!!o;try{i.initializers.forEach((f)=>{f(z)})}catch(f){throw console.error("sqlite3 bootstrap initializer threw:",f),f}if(delete i.initializers,i.sqlite3=z,typeof e<"u")e.debugModule("sqlite3ApiBootstrap() complete",z),z.scriptInfo=e;if(z.__isUnderTest){if(typeof n<"u")z.config.emscripten=n;let f=z.scriptInfo?.instantiateWasm;if(f)z.wasm.module=f.module,z.wasm.instance=f.instance,z.wasm.imports=f.imports}return delete globalThis.sqlite3ApiConfig,delete globalThis.sqlite3ApiBootstrap,delete i.defaultConfig,z.asyncPostInit().then((f)=>{if(typeof e<"u")e.debugModule("sqlite3.asyncPostInit() complete",f);return delete f.asyncPostInit,delete f.scriptInfo,delete f.emscripten,f})},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.54.0",libVersionNumber:3054000,sourceId:"2026-10-09 15:46:58 be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3",downloadVersion:3540000,scm:{"sha3-256":"be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3",branch:"trunk",tags:"release major-release version-3.54.0",datetime:"2026-10-09T15:46:58.543Z"}}}),globalThis.WhWasmUtilInstaller=function(t){if(t.bigIntEnabled===void 0)t.bigIntEnabled=!!globalThis.BigInt64Array;let r=(...u)=>{throw Error(u.join(" "))};if(!t.pointerSize&&!t.pointerIR&&t.alloc&&t.dealloc){let u=t.alloc(1);t.pointerSize=typeof u==="bigint"?8:4,t.dealloc(u)}if(t.pointerSize&&!t.pointerIR)t.pointerIR=t.pointerSize===4?"i32":"i64";let a=t.pointerIR??="i32",_=t.pointerSize??=a==="i32"?4:a==="i64"?8:0;if(delete t.pointerSize,delete t.pointerIR,a!=="i32"&&a!=="i64")r("Invalid pointerIR:",a);else if(_!==8&&_!==4)r("Invalid pointerSize:",_);let h=t.bigIntEnabled?(u)=>BigInt(u||0):(u)=>r("BigInt support is disabled in this build."),q=_===4?(u)=>Number(u||0):h,R=q(0),M=function(...u){let y=q(0);for(let O of u)y+=q(O);return y};{let u=Object.create(null);Object.defineProperty(t,"ptr",{enumerable:!0,get:()=>u,set:()=>r("The ptr property is read-only.")}),function y(O,V){return Object.defineProperty(u,O,{enumerable:!0,get:()=>V,set:()=>r("ptr["+O+"] is read-only.")}),y}("null",R)("size",_)("ir",a)("coerce",q)("add",M)("addn",a===4?M:(...y)=>Number(M(...y)))}if(!t.exports)Object.defineProperty(t,"exports",{enumerable:!0,configurable:!0,get:()=>t.instance?.exports});let p=Object.create(null);p.heapSize=0,p.memory=null,p.freeFuncIndexes=[],p.scopedAlloc=[],p.scopedAlloc.pushPtr=(u)=>(p.scopedAlloc[p.scopedAlloc.length-1].push(u),u),p.utf8Decoder=new TextDecoder,p.utf8Encoder=new TextEncoder("utf-8"),t.sizeofIR=(u)=>{switch(u){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 _;default:return(""+u).endsWith("*")?_:void 0}};let te=function(){if(!p.memory)p.memory=t.memory instanceof WebAssembly.Memory?t.memory:t.exports.memory;else if(p.heapSize===p.memory.buffer.byteLength)return p;let u=p.memory.buffer;if(p.HEAP8=new Int8Array(u),p.HEAP8U=new Uint8Array(u),p.HEAP16=new Int16Array(u),p.HEAP16U=new Uint16Array(u),p.HEAP32=new Int32Array(u),p.HEAP32U=new Uint32Array(u),p.HEAP32F=new Float32Array(u),p.HEAP64F=new Float64Array(u),t.bigIntEnabled)if(typeof BigInt64Array<"u")p.HEAP64=new BigInt64Array(u),p.HEAP64U=new BigUint64Array(u);else r("BigInt support is enabled, but the BigInt64Array type is missing.");return p.heapSize=u.byteLength,p};t.heap8=()=>te().HEAP8,t.heap8u=()=>te().HEAP8U,t.heap16=()=>te().HEAP16,t.heap16u=()=>te().HEAP16U,t.heap32=()=>te().HEAP32,t.heap32u=()=>te().HEAP32U,t.heapForSize=function(u,y=!0){let O,V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te();switch(u){case Int8Array:return V.HEAP8;case Uint8Array:return V.HEAP8U;case Int16Array:return V.HEAP16;case Uint16Array:return V.HEAP16U;case Int32Array:return V.HEAP32;case Uint32Array:return V.HEAP32U;case 8:return y?V.HEAP8U:V.HEAP8;case 16:return y?V.HEAP16U:V.HEAP16;case 32:return y?V.HEAP32U:V.HEAP32;case 64:if(V.HEAP64)return y?V.HEAP64U:V.HEAP64;break;default:if(t.bigIntEnabled){if(u===globalThis.BigUint64Array)return V.HEAP64U;else if(u===globalThis.BigInt64Array)return V.HEAP64;break}}r("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")};let j=t.functionTable;delete t.functionTable,t.functionTable=j?()=>j:()=>t.exports.__indirect_function_table,t.functionEntry=function(u){let y=t.functionTable();return u<y.length?y.get(q(u)):void 0},t.jsFuncToWasm=function u(y,O){if(!u._)u._={sigTypes:Object.assign(Object.create(null),{i:"i32",p:a,P:a,s:a,j:"i64",f:"f32",d:"f64"}),typeCodes:Object.assign(Object.create(null),{f64:124,f32:125,i64:126,i32:127}),uleb128Encode:(b,C,c)=>{if(c<128)b[C](c);else b[C](c%128|128,c>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:(b)=>{let C=u._.rxJSig.exec(b);return C?C[2]:b.substr(1)},letterType:(b)=>u._.sigTypes[b]||r("Invalid signature letter:",b),pushSigType:(b,C)=>b.push(u._.typeCodes[u._.letterType(C)])};if(typeof y==="string"){let b=O;O=y,y=b}let V=u._,Y=V.sigParams(O),m=[1,96];V.uleb128Encode(m,"push",Y.length);for(let b of Y)V.pushSigType(m,b);if(O[0]==="v")m.push(0);else m.push(1),V.pushSigType(m,O[0]);return V.uleb128Encode(m,"unshift",m.length),m.unshift(0,97,115,109,1,0,0,0,1),m.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(m)),{e:{f:y}}).exports.f};let U=function(y,O,V){if(V&&!p.scopedAlloc.length)r("No scopedAllocPush() scope is active.");if(typeof y==="string"){let C=O;O=y,y=C}if(typeof O!=="string"||!(y instanceof Function))r("Invalid arguments: expecting (function,signature) or (signature,function).");let Y=t.functionTable(),m=q(Y.length),b;while(b=p.freeFuncIndexes.pop())if(Y.get(b)){b=null;continue}else break;if(!b)b=q(m),Y.grow(q(1));try{if(Y.set(b,y),V)p.scopedAlloc.pushPtr(b);return b}catch(C){if(!(C instanceof TypeError)){if(b===m)p.freeFuncIndexes.push(m);throw C}}try{let C=t.jsFuncToWasm(y,O);if(Y.set(b,C),V)p.scopedAlloc.pushPtr(b)}catch(C){if(b===m)p.freeFuncIndexes.push(m);throw C}return b};t.installFunction=(u,y)=>U(u,y,!1),t.scopedInstallFunction=(u,y)=>U(u,y,!0),t.uninstallFunction=function(u){if(!u&&R!==u)return;let y=t.functionTable();p.freeFuncIndexes.push(u);let O=y.get(u);return y.set(u,null),O},t.peek=function(y,O="i8"){if(O.endsWith("*"))O=a;let V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te(),Y=Array.isArray(y)?[]:void 0,m;do{if(Y)y=arguments[0].shift();switch(O){case"i1":case"i8":m=V.HEAP8[Number(y)>>0];break;case"i16":m=V.HEAP16[Number(y)>>1];break;case"i32":m=V.HEAP32[Number(y)>>2];break;case"float":case"f32":m=V.HEAP32F[Number(y)>>2];break;case"double":case"f64":m=Number(V.HEAP64F[Number(y)>>3]);break;case"i64":if(V.HEAP64){m=h(V.HEAP64[Number(y)>>3]);break}default:r("Invalid type for peek():",O)}if(Y)Y.push(m)}while(Y&&arguments[0].length);return Y||m},t.poke=function(u,y,O="i8"){if(O.endsWith("*"))O=a;let V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te();for(let Y of Array.isArray(u)?u:[u])switch(O){case"i1":case"i8":V.HEAP8[Number(Y)>>0]=y;continue;case"i16":V.HEAP16[Number(Y)>>1]=y;continue;case"i32":V.HEAP32[Number(Y)>>2]=y;continue;case"float":case"f32":V.HEAP32F[Number(Y)>>2]=y;continue;case"double":case"f64":V.HEAP64F[Number(Y)>>3]=y;continue;case"i64":if(V.HEAP64){V.HEAP64[Number(Y)>>3]=h(y);continue}default:r("Invalid type for poke(): "+O)}return this},t.peekPtr=(...u)=>t.peek(u.length===1?u[0]:u,a),t.pokePtr=(u,y=0)=>t.poke(u,y,a),t.peek8=(...u)=>t.peek(u.length===1?u[0]:u,"i8"),t.poke8=(u,y)=>t.poke(u,y,"i8"),t.peek16=(...u)=>t.peek(u.length===1?u[0]:u,"i16"),t.poke16=(u,y)=>t.poke(u,y,"i16"),t.peek32=(...u)=>t.peek(u.length===1?u[0]:u,"i32"),t.poke32=(u,y)=>t.poke(u,y,"i32"),t.peek64=(...u)=>t.peek(u.length===1?u[0]:u,"i64"),t.poke64=(u,y)=>t.poke(u,y,"i64"),t.peek32f=(...u)=>t.peek(u.length===1?u[0]:u,"f32"),t.poke32f=(u,y)=>t.poke(u,y,"f32"),t.peek64f=(...u)=>t.peek(u.length===1?u[0]:u,"f64"),t.poke64f=(u,y)=>t.poke(u,y,"f64"),t.getMemValue=t.peek,t.getPtrValue=t.peekPtr,t.setMemValue=t.poke,t.setPtrValue=t.pokePtr,t.isPtr32=(u)=>typeof u==="number"&&u>=0&&u===(u|0),t.isPtr64=(u)=>typeof u==="bigint"?u>=0:t.isPtr32(u),t.isPtr=_===4?t.isPtr32:t.isPtr64,t.cstrlen=function(u){if(!u||!t.isPtr(u))return null;u=Number(u);let y=te().HEAP8U,O=u;for(;y[O]!==0;++O);return O-u};let E=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,g=(u)=>u.buffer instanceof E;t.isSharedTypedArray=g;let F=(u,y,O)=>{if(_===8){if(typeof y==="bigint")y=Number(y);if(typeof O==="bigint")O=Number(O)}return g(u)?u.slice(y,O):u.subarray(y,O)};t.typedArrayPart=F;let x=(u,y,O)=>p.utf8Decoder.decode(F(u,y,O));t.typedArrayToString=x,t.cstrToJs=function(u){let y=t.cstrlen(u);return y?x(te().HEAP8U,Number(u),Number(u)+y):y===null?y:""},t.jstrlen=function(u){if(typeof u!=="string")return null;let y=u.length,O=0;for(let V=0;V<y;++V){let Y=u.charCodeAt(V);if(Y>=55296&&Y<=57343)Y=65536+((Y&1023)<<10)|u.charCodeAt(++V)&1023;if(Y<=127)++O;else if(Y<=2047)O+=2;else if(Y<=65535)O+=3;else O+=4}return O},t.jstrcpy=function(u,y,O=0,V=-1,Y=!0){if(!y||!(y instanceof Int8Array)&&!(y instanceof Uint8Array))r("jstrcpy() target must be an Int8Array or Uint8Array.");if(V=Number(V),O=Number(O),V<0)V=y.length-O;if(!(V>0)||!(O>=0))return 0;let m=0,b=u.length,C=O,c=O+V-(Y?1:0);for(;m<b&&O<c;++m){let d=u.charCodeAt(m);if(d>=55296&&d<=57343)d=65536+((d&1023)<<10)|u.charCodeAt(++m)&1023;if(d<=127){if(O>=c)break;y[O++]=d}else if(d<=2047){if(O+1>=c)break;y[O++]=192|d>>6,y[O++]=128|d&63}else if(d<=65535){if(O+2>=c)break;y[O++]=224|d>>12,y[O++]=128|d>>6&63,y[O++]=128|d&63}else{if(O+3>=c)break;y[O++]=240|d>>18,y[O++]=128|d>>12&63,y[O++]=128|d>>6&63,y[O++]=128|d&63}}if(Y)y[O++]=0;return O-C},t.cstrncpy=function(u,y,O){if(!u||!y)r("cstrncpy() does not accept NULL strings.");if(O<0)O=t.cstrlen(strPtr)+1;else if(!(O>0))return 0;let V=t.heap8u(),Y=0,m,b=Number(u),C=Number(y);for(;Y<O&&(m=V[C+Y]);++Y)V[b+Y]=m;if(Y<O)V[b+Y++]=0;return Y},t.jstrToUintArray=(u,y=!1)=>p.utf8Encoder.encode(y?u+"\x00":u);let A=(u,y)=>{if(!(u.alloc instanceof Function)||!(u.dealloc instanceof Function))r("Object is missing alloc() and/or dealloc() function(s)","required by",y+"().")},N=function(u,y,O,V){if(A(t,V),typeof u!=="string")return null;let Y=p.utf8Encoder.encode(u),m=O(Y.length+1),b=m;try{let C=te().HEAP8U;return C.set(Y,Number(m)),C[M(m,Y.length)]=0,b=R,y?[m,Y.length]:m}finally{if(b)t.dealloc(b)}};t.allocCString=(u,y=!1)=>N(u,y,t.alloc,"allocCString()"),t.scopedAllocPush=function(){A(t,"scopedAllocPush");let u=[];return p.scopedAlloc.push(u),u},t.scopedAllocPop=function(u){A(t,"scopedAllocPop");let y=arguments.length?p.scopedAlloc.indexOf(u):p.scopedAlloc.length-1;if(y<0)r("Invalid state object for scopedAllocPop().");if(arguments.length===0)u=p.scopedAlloc[y];p.scopedAlloc.splice(y,1);for(let O;O=u.pop();)if(t.functionEntry(O))t.uninstallFunction(O);else t.dealloc(O)},t.scopedAlloc=function(u){if(!p.scopedAlloc.length)r("No scopedAllocPush() scope is active.");let y=q(t.alloc(u));return p.scopedAlloc.pushPtr(y)},Object.defineProperty(t.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>p.scopedAlloc.length,set:()=>r("The 'active' property is read-only.")}),t.scopedAllocCString=(u,y=!1)=>N(u,y,t.scopedAlloc,"scopedAllocCString()");let z=function(u,y){let O=t[u?"scopedAlloc":"alloc"]((y.length+1)*t.ptr.size),V=0;return y.forEach((Y)=>{t.pokePtr(M(O,t.ptr.size*V++),t[u?"scopedAllocCString":"allocCString"](""+Y))}),t.pokePtr(M(O,t.ptr.size*V),0),O};t.scopedAllocMainArgv=(u)=>z(!0,u),t.allocMainArgv=(u)=>z(!1,u),t.cArgvToJs=(u,y)=>{let O=[];for(let V=0;V<u;++V){let Y=t.peekPtr(M(y,t.ptr.size*V));O.push(Y?t.cstrToJs(Y):null)}return O},t.scopedAllocCall=function(u){t.scopedAllocPush();try{return u()}finally{t.scopedAllocPop()}};let f=function(u,y,O){A(t,O);let V=y?"i64":a,Y=t[O](u*(y?8:_));if(t.poke(Y,0,V),u===1)return Y;let m=[Y];for(let b=1;b<u;++b)Y=M(Y,y?8:_),m[b]=Y,t.poke(Y,0,V);return m};t.allocPtr=(u=1,y=!0)=>f(u,y,"alloc"),t.scopedAllocPtr=(u=1,y=!0)=>f(u,y,"scopedAlloc"),t.xGet=function(u){return t.exports[u]||r("Cannot find exported symbol:",u)};let S=(u,y)=>r(u+"() requires",y,"argument(s).");t.xCall=function(u,...y){let O=u instanceof Function?u:t.xGet(u);if(!(O instanceof Function))r("Exported symbol",u,"is not a function.");if(O.length!==y.length)S(O===u?O.name:u,O.length);return arguments.length===2&&Array.isArray(arguments[1])?O.apply(null,arguments[1]):O.apply(null,y)},p.xWrap=Object.create(null),p.xWrap.convert=Object.create(null),p.xWrap.convert.arg=new Map,p.xWrap.convert.result=new Map;let D=p.xWrap.convert.arg,J=p.xWrap.convert.result,ie=q;D.set("i64",h).set("i32",(u)=>u|0).set("i16",(u)=>(u|0)&65535).set("i8",(u)=>(u|0)&255).set("f32",(u)=>Number(u).valueOf()).set("float",D.get("f32")).set("f64",D.get("f32")).set("double",D.get("f64")).set("int",D.get("i32")).set("null",(u)=>u).set(null,D.get("null")).set("**",ie).set("*",ie),J.set("*",ie).set("pointer",ie).set("number",(u)=>Number(u)).set("void",(u)=>{return}).set(void 0,J.get("void")).set("null",(u)=>u).set(null,J.get("null"));for(let u of["i8","i16","i32","i64","int","f32","float","f64","double"])D.set(u+"*",ie),J.set(u+"*",ie),J.set(u,D.get(u)||r("Maintenance required: missing arg converter for",u));let le=(u)=>typeof u==="string"?t.scopedAllocCString(u):q(u);D.set("string",le).set("utf8",le),J.set("string",(u)=>t.cstrToJs(u)).set("utf8",J.get("string")).set("string:dealloc",(u)=>{try{return u?t.cstrToJs(u):null}finally{t.dealloc(u)}}).set("utf8:dealloc",J.get("string:dealloc")).set("json",(u)=>JSON.parse(t.cstrToJs(u))).set("json:dealloc",(u)=>{try{return u?JSON.parse(t.cstrToJs(u)):null}finally{t.dealloc(u)}});let Se=class{constructor(u){this.name=u.name||"unnamed adapter"}convertArg(u,y,O){r("AbstractArgAdapter must be subclassed.")}};D.FuncPtrAdapter=class u extends Se{constructor(y){super(y);if(D.FuncPtrAdapter.warnOnUse)console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",y);if(this.name=y.name||"unnamed",this.signature=y.signature,y.contextKey instanceof Function){if(this.contextKey=y.contextKey,!y.bindScope)y.bindScope="context"}if(this.bindScope=y.bindScope||r("FuncPtrAdapter options requires a bindScope (explicit or implied)."),u.bindScopes.indexOf(y.bindScope)<0)r("Invalid options.bindScope ("+y.bindMod+") for FuncPtrAdapter. Expecting one of: ("+u.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=y.callProxy instanceof Function?y.callProxy:void 0}contextKey(y,O){return this}contextMap(y){let O=this.__cmap||(this.__cmap=new Map),V=O.get(y);if(V===void 0)O.set(y,V=[]);return V}convertArg(y,O,V){let Y=this.singleton;if(!Y&&this.isContext)Y=this.contextMap(this.contextKey(O,V));if(Y&&Y.length===2&&Y[0]===y)return Y[1];if(y instanceof Function){if(this.callProxy)y=this.callProxy(y);let m=U(y,this.signature,this.isTransient);if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter installed",this,this.contextKey(O,V),"@"+m,y);if(Y){if(Y[1]){if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,V),"@"+Y[1],y);try{p.scopedAlloc.pushPtr(Y[1])}catch(b){}}Y[0]=arguments[0]||R,Y[1]=m}return m}else if(t.isPtr(y)||y===null||y===void 0){if(Y&&Y[1]&&Y[1]!==y){if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,V),"@"+Y[1],y);try{p.scopedAlloc.pushPtr(Y[1])}catch(m){}Y[0]=Y[1]=y||R}return y||R}else throw TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},D.FuncPtrAdapter.warnOnUse=!1,D.FuncPtrAdapter.debugFuncInstall=!1,D.FuncPtrAdapter.debugOut=console.debug.bind(console),D.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];let me=(u)=>D.get(u)||r("Argument adapter not found:",u),K=(u)=>J.get(u)||r("Result adapter not found:",u);p.xWrap.convertArg=(u,...y)=>me(u)(...y),p.xWrap.convertArgNoCheck=(u,...y)=>D.get(u)(...y),p.xWrap.convertResult=(u,y)=>u===null?y:u?K(u)(y):void 0,p.xWrap.convertResultNoCheck=(u,y)=>u===null?y:u?J.get(u)(y):void 0,t.xWrap=function u(y,O,...V){if(arguments.length===3&&Array.isArray(arguments[2]))V=arguments[2];if(t.isPtr(y))y=t.functionEntry(y)||r("Function pointer not found in WASM function table.");let Y=y instanceof Function,m=Y?y:t.xGet(y);if(Y)y=m.name||"unnamed function";if(V.length!==m.length)S(y,m.length);if(m.length===0&&(O===null||O==="null"))return m;K(O);for(let C of V)if(C instanceof Se)D.set(C,(...c)=>C.convertArg(...c));else me(C);let b=p.xWrap;if(m.length===0)return(...C)=>C.length?S(y,m.length):b.convertResult(O,m.call(null));return function(...C){if(C.length!==m.length)S(y,m.length);let c=t.scopedAllocPush();try{let d=0;if(u.debug)console.debug("xWrap() preparing: resultType ",O,"xf",m,"argTypes",V,"args",C);for(;d<C.length;++d)C[d]=b.convertArgNoCheck(V[d],C[d],C,d);if(u.debug)console.debug("xWrap() calling: resultType ",O,"xf",m,"argTypes",V,"args",C);return b.convertResultNoCheck(O,m.apply(null,C))}finally{t.scopedAllocPop(c)}}};let oe=function(u,y,O,V,Y,m){if(typeof O==="string"){if(y===1)return m.get(O);else if(y===2){if(!V)return m.delete(O),u;else if(!(V instanceof Function))r(Y,"requires a function argument.");return m.set(O,V),u}}r("Invalid arguments to",Y)};return t.xWrap.resultAdapter=function u(y,O){return oe(u,arguments.length,y,O,"resultAdapter()",J)},t.xWrap.argAdapter=function u(y,O){return oe(u,arguments.length,y,O,"argAdapter()",D)},t.xWrap.FuncPtrAdapter=D.FuncPtrAdapter,t.xCallWrapped=function(u,y,O,...V){if(Array.isArray(arguments[3]))V=arguments[3];return t.xWrap(u,y,O||[]).apply(null,V||[])},t.xWrap.testConvertArg=p.xWrap.convertArg,t.xWrap.testConvertResult=p.xWrap.convertResult,t},globalThis.WhWasmUtilInstaller.yawl=function(t){let r=()=>fetch(t.uri,{credentials:"same-origin"}),a=this,_=function(I){if(t.wasmUtilTarget){let q=(...M)=>{throw Error(M.join(" "))},R=t.wasmUtilTarget;if(R.module=I.module,R.instance=I.instance,!R.instance.exports.memory)R.memory=t?.imports?.env?.memory||q("Missing 'memory' object!");if(!R.alloc&&I.instance.exports.malloc){let M=I.instance.exports;R.alloc=function(p){return M.malloc(p)||q("Allocation of",p,"bytes failed.")},R.dealloc=function(p){p&&M.free(p)}}a(R)}if(I.config=t,t.onload)t.onload(I);return I};return WebAssembly.instantiateStreaming?()=>WebAssembly.instantiateStreaming(r(),t.imports||{}).then(_):()=>r().then((I)=>I.arrayBuffer()).then((I)=>WebAssembly.instantiate(I,t.imports||{})).then(_)}.bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function i(t){let r=(...P)=>{throw Error(P.join(" "))};{let P=t.heap;if(P instanceof WebAssembly.Memory)P=function(){return new Uint8Array(this.buffer)}.bind(P);else if(!(P instanceof Function))r("config.heap must be WebAssembly.Memory instance or","a function which returns one.");t.heap=P}["alloc","dealloc"].forEach(function(P){t[P]instanceof Function||r("Config option '"+P+"' must be a function.")});let a=i,{heap:_,alloc:h,dealloc:I}=t,q=t.realloc||function(){r("This StructBinderFactory was configured without realloc()")},R=t.log||console.debug.bind(console),M=t.memberPrefix||"",p=t.memberSuffix||"",{BigInt:te,BigInt64Array:j}=globalThis,U=t.bigIntEnabled??!!j,E,g=t.pointerSize||t.ptrSize||(typeof(E=h(1))==="bigint"?8:4),F=t.pointerIR||t.ptrIR||(g===4?"i32":"i64");if(E)I(E),E=void 0;if(g!==4&&g!==8)r("Invalid pointer size:",g);if(F!=="i32"&&F!=="i64")r("Invalid pointer representation:",F);let x=U&&te?(P)=>te(P||0):(P)=>r("BigInt support is disabled in this build."),A=F=="i32"?Number:x,N=A(0),z=function(...P){let X=N;for(let Z=0;Z<P.length;++Z)X+=A(P[Z]);return X},f=function(...P){return z(this.pointer,...P)};if(!a.debugFlags)a.__makeDebugFlags=function(P=null){if(P&&P.__flags)P=P.__flags;let X=function Z(re){if(arguments.length===0)return Z.__flags;if(re<0)delete Z.__flags.getter,delete Z.__flags.setter,delete Z.__flags.alloc,delete Z.__flags.dealloc;else Z.__flags.getter=(1&re)!==0,Z.__flags.setter=(2&re)!==0,Z.__flags.alloc=(4&re)!==0,Z.__flags.dealloc=(8&re)!==0;return Z._flags};if(Object.defineProperty(X,"__flags",{iterable:!1,writable:!1,value:Object.create(P)}),!P)X(0);return X},a.debugFlags=a.__makeDebugFlags();let S=!0,D=(P)=>P[1]==="(",J=(P)=>P==="p"||P==="P"||P==="s",ie=(P)=>P==="P",le=(P)=>P?D(P)?"p":P[0]:void 0,Se=function(P){switch(le(P)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return F;case"j":return"i64";case"f":return"float";case"d":return"double"}r("Unhandled signature IR:",P)},me=function(P){switch(le(P)){case"c":case"C":return 1;case"i":return 4;case"p":case"P":case"s":return g;case"j":return 8;case"f":return 4;case"d":return 8}r("Unhandled signature sizeof:",P)},K=j?()=>!0:()=>r("BigInt64Array is not available."),oe=function(P){switch(le(P)){case"p":case"P":case"s":{switch(g){case 4:return"getInt32";case 8:return K()&&"getBigInt64"}break}case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return K()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}r("Unhandled DataView getter for signature:",P)},u=function(P){switch(le(P)){case"p":case"P":case"s":{switch(g){case 4:return"setInt32";case 8:return K()&&"setBigInt64"}break}case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return K()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}r("Unhandled DataView setter for signature:",P)},y=function(P){switch(le(P)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return x;case"p":case"P":case"s":switch(g){case 4:return Number;case 8:return x}break}r("Unhandled DataView set wrapper for signature:",P)},O=(P,X)=>P+"::"+X,V=function(P,X){return()=>r(O(P,X),"is read-only.")},Y=function P(X,Z=!0){let re=P.map.get(X);if(!re&&Z)P.map.set(X,re=P.create(X));return re};Y.map=new WeakMap,Y.create=(P)=>Object.assign(Object.create(null),{o:P,p:void 0,ownsPointer:!1,zod:!1,xb:0});let m=(P)=>Y.map.delete(P),b=(P)=>typeof P==="number"&&P===(P|0)&&P>=0,c=g===4?b:(P)=>typeof P==="bigint"&&P>=0||b(P),d=(P)=>c(P)&&P>0,L=function(P,X,Z){let re=Y(X,!1);if(!re||re.isDisposing)return;if(re.isDisposing=!0,!Z&&!(Z=re.p)){console.warn("Cannot(?) happen: __freeStruct() found no instanceInfo");return}if(Array.isArray(X.ondispose)){let fe;while(fe=X.ondispose.pop())try{if(fe instanceof Function)fe.call(X);else if(fe instanceof Je)fe.dispose();else if(c(fe))I(fe)}catch(Oe){console.warn("ondispose() for",P.structName,"@",Z,"threw. NOT propagating it.",Oe)}}else if(X.ondispose instanceof Function)try{X.ondispose()}catch(fe){console.warn("ondispose() for",P.structName,"@",Z,"threw. NOT propagating it.",fe)}if(m(X),delete X.ondispose,P.debugFlags.__flags.dealloc)R("debug.dealloc:",re.ownsPointer?"":"EXTERNAL",P.structName,"instance:",P.structInfo.sizeof,"bytes @"+Z);if(re.ownsPointer){if(re.zod||P.structInfo.zeroOnDispose)_().fill(0,Number(Z),Number(Z)+P.structInfo.sizeof+re.xb);I(Z)}},G=()=>({configurable:!1,writable:!1,iterable:!1}),B=(P)=>({...G(),value:P}),ae=function(X,Z,re){let fe,Oe=(xe)=>{d(xe)||r("Invalid pointer value",arguments[0],"for",X.structName,"constructor.")};if(arguments.length>=3)if(re&&typeof re==="object")fe=re,re=fe?.wrap;else Oe(re),fe={wrap:re};else fe={};let Me=!re,Qe=0,Ge=!1;if(re)Oe(re),Ge=!!fe?.takeOwnership;else{let xe=fe?.extraBytes??0;if(xe<0||xe!==(xe|0))r("Invalid extraBytes value:",fe?.extraBytes);Qe=X.structInfo.sizeof+xe,re=h(Qe)||r("Allocation of",X.structName,"structure failed."),Ge=!0}try{if(fe?.debugFlags)Z.debugFlags(fe.debugFlags);if(X.debugFlags.__flags.alloc)R("debug.alloc:",Me?"":"EXTERNAL",X.structName,"instance:",X.structInfo.sizeof,"bytes @"+re);if(Me)_().fill(0,Number(re),Number(re)+Qe);let xe=Y(Z);if(xe.p=re,xe.ownsPointer=Ge,xe.xb=Qe?Qe-X.structInfo.sizeof:0,xe.zod=!!fe?.zeroOnDispose,fe?.ondispose&&fe.ondispose!==re)Z.addOnDispose(fe.ondispose)}catch(xe){throw L(X,Z,re),xe}},ce=function P(X){return P.rxSig1??=/^[ipPsjfdcC]$/,P.rxSig2??=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/,P.rxSig1.test(X)||P.rxSig2.test(X)},ge=function(P){let X=this.get(P);if(!X)X=[Object.create(null),Object.create(null),Object.create(null)],this.set(P,X);return X}.bind(new WeakMap),qe=function(P,X,Z,re){let fe=ge(P)[X];if(arguments.length===3)return fe[Z];if(re)return fe[Z]=re;return delete fe[Z]},Fe=(P)=>P,Pe=function(P,...X){return qe(this,0,P,...X)},Ee=function(P,X){ce(X)&&r(P,"(",X,") collides with a data type signature.")},Ue=function(P,...X){return Ee("Setter adaptor",P),qe(this,1,P,...X)},He=function(P,...X){return Ee("Struct adaptor",P),qe(this,2,P,...X)},T=function(P,X){let Z=typeof X==="string"?qe(P,2,X):X;if(typeof Z!=="object")r("Invalid struct mapping object. Arg =",X,JSON.stringify(Z));return Z},Q=B((P)=>M+P+p),H=function(P,X,Z=!0){let re=P.members[X];if(!re&&(M||p)){for(let fe of Object.values(P.members))if(fe.key===X){re=fe;break}if(!re&&Z)r(O(P.name||P.structName,X),"is not a mapped struct member.")}return re},se=function P(X,Z,re=!1){if(!P._)P._=(Oe)=>Oe.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i");let fe=H(X.structInfo,Z,!0);return re?P._(fe.signature):fe.signature},_e=B(function(){let P=[];for(let X of Object.keys(this.structInfo.members))P.push(this.memberKey(X));return P}),de=new TextDecoder("utf-8"),ue=new TextEncoder,pe=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,Le=function(P,X,Z){if(g===8)X=Number(X),Z=Number(Z);return de.decode(P.buffer instanceof pe?P.slice(X,Z):P.subarray(X,Z))},Ce=function(P,X,Z=!1){let re=H(P.structInfo,X,Z);return re&&re.signature.length===1&&re.signature[0]==="s"?re:!1},Ae=function(P){if(P.signature==="s")return;r("Invalid member type signature for C-string value:",JSON.stringify(P))},Ne=function(X,Z){let re=H(X.structInfo,Z,!0);Ae(re);let fe=X[re.key];if(!fe)return null;let Oe=fe,Me=_();for(;Me[Oe]!==0;++Oe);return fe===Oe?"":Le(Me,fe,Oe)},Re=function(P,...X){if(P.ondispose){if(!Array.isArray(P.ondispose))P.ondispose=[P.ondispose]}else P.ondispose=[];P.ondispose.push(...X)},tt=function(P){let X=ue.encode(P),Z=h(X.length+1);if(!Z)r("Allocation error while duplicating string:",P);let re=_();return re.set(X,Number(Z)),re[z(Z,X.length)]=0,Z},st=function(P,X,Z){let re=H(P.structInfo,X,!0);Ae(re);let fe=tt(Z);return P[re.key]=fe,Re(P,fe),P},Je=function(X,Z){if(arguments[2]!==B)r("Do not call the StructType constructor","from client-level code.");Object.defineProperties(this,{structName:B(X),structInfo:B(Z)})};Je.prototype=Object.create(null,{dispose:B(function(){L(this.constructor,this)}),lookupMember:B(function(P,X=!0){return H(this.structInfo,P,X)}),memberToJsString:B(function(P){return Ne(this,P)}),memberIsString:B(function(P,X=!0){return Ce(this,P,X)}),memberKey:Q,memberKeys:_e,memberSignature:B(function(P,X=!1){return se(this,P,X)}),memoryDump:B(function(){let P=this.pointer;return P?new Uint8Array(_().slice(Number(P),Number(P)+this.structInfo.sizeof)):null}),extraBytes:{configurable:!1,enumerable:!1,get:function(){return Y(this,!1)?.xb??0}},zeroOnDispose:{configurable:!1,enumerable:!1,get:function(){return Y(this,!1)?.zod??!!this.structInfo.zeroOnDispose}},pointer:{configurable:!1,enumerable:!1,get:function(){return Y(this,!1)?.p},set:()=>r("Cannot assign the 'pointer' property of a struct.")},setMemberCString:B(function(P,X){return st(this,P,X)})}),Object.assign(Je.prototype,{addOnDispose:function(...P){return Re(this,...P),this}}),Object.defineProperties(Je,{allocCString:B(tt),isA:B((P)=>P instanceof Je),hasExternalPointer:B((P)=>{let X=Y(P,!1);return!!(X?.p&&!X?.ownsPointer)}),memberKey:Q});let mt=function(P){return P.get||(P.adaptGet?$e.adaptGet(P.adaptGet):void 0)},gt=function(P){return P.set||(P.adaptSet?$e.adaptSet(P.adaptSet):void 0)},_t=function P(X,Z,re){let fe=P.innerStructs??=new Map,Oe=X.memberKey(Z);if(re.signature!==void 0)r("'signature' cannot be used on an embedded struct (",X.structName,".",Oe,").");if(gt(re))r("'set' and 'adaptSet' are not permitted for nested struct members.");re.structName??=X.structName+"::"+Z,re.key=Oe,re.name=Z,re.constructor=this.call(this,re.structName,re);let Me=mt(re),Qe=Object.assign(Object.create(null),{configurable:!1,enumerable:!1,set:V(X.structName,Oe),get:function(){let Ge=this.debugFlags.__flags,xe=this.pointer,je=xe+"."+Oe,he=fe.get(je);if(Ge.getter)R("debug.getter: k =",je);if(!he)he=new re.constructor(z(xe,re.offset)),fe.set(je,he),this.addOnDispose(()=>he.dispose()),he.addOnDispose(()=>fe.delete(je));if(Me)he=Me.apply(this,[he,Oe]);if(Ge.getter)R("debug.getter: result =",he);return he}});Object.defineProperty(X.prototype,Oe,Qe)},Mt=function P(X,Z,re){if(re=T(this,re),re.members)return _t.call(this,X,Z,re);if(!P.cache){P.cache={getters:{},setters:{},sw:{}};let je=["i","c","C","p","P","s","f","d","v()"];if(U)je.push("j");je.forEach(function(he){P.cache.getters[he]=oe(he),P.cache.setters[he]=u(he),P.cache.sw[he]=y(he)}),P.sigCheck=function(he,De,At,Sn){if(Object.prototype.hasOwnProperty.call(he,At))r(he.structName,"already has a property named",At+".");ce(Sn)||r("Malformed signature for",O(he.structName,De)+":",Sn)}}let fe=X.memberKey(Z);P.sigCheck(X.prototype,Z,fe,re.signature),re.key=fe,re.name=Z;let Oe=le(re.signature),Me=O(X.structName,fe),Qe=X.debugFlags.__flags,Ge=mt(re),xe=Object.create(null);if(xe.configurable=!1,xe.enumerable=!1,xe.get=function(){if(Qe.getter)R("debug.getter:",P.cache.getters[Oe],"for",Se(Oe),Me,"@",this.pointer,"+",re.offset,"sz",re.sizeof);let je=new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[P.cache.getters[Oe]](0,S);if(Ge)je=Ge.apply(this,[fe,je]);if(Qe.getter)R("debug.getter:",Me,"result =",je);return je},re.readOnly)xe.set=V(X.prototype.structName,fe);else{let je=gt(re);xe.set=function(he){if(Qe.setter)R("debug.setter:",P.cache.setters[Oe],"for",Se(Oe),Me,"@",this.pointer,"+",re.offset,"sz",re.sizeof,he);if(!this.pointer)r("Cannot set native property on a disposed",this.structName,"instance.");if(je)he=je.apply(this,[fe,he]);if(he===null||he===void 0)he=N;else if(J(re.signature)&&!c(he))if(ie(re.signature)&&he instanceof Je){if(he=he.pointer||N,Qe.setter)R("debug.setter:",Me,"resolved to",he)}else r("Invalid value for pointer-type",Me+".");new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[P.cache.setters[Oe]](0,P.cache.sw[Oe](he),S)}}Object.defineProperty(X.prototype,fe,xe)},vn=function P(X,Z,re=Object.create(null)){let fe=function he(De){if(!(this instanceof he))r("The",X,"constructor may only be called via 'new'.");ae(he,this,...arguments)},Oe=this,Me=(he)=>typeof he==="string"&&ce(he)?{signature:he}:T(Oe,he);if(arguments.length===1)Z=Me(X),X=Z.structName||Z.name;else if(arguments.length===2)Z=Me(Z),Z.name??=X;else Z=Me(Z);if(X??=Z.structName,X??=re.structName,!X)r("One of 'name' or 'structName' are required.");if(Z.adapt)Object.keys(Z.adapt.struct||{}).forEach((he)=>{He.call(P,he,Z.adapt.struct[he])}),Object.keys(Z.adapt.set||{}).forEach((he)=>{Ue.call(P,he,Z.adapt.set[he])}),Object.keys(Z.adapt.get||{}).forEach((he)=>{Pe.call(P,he,Z.adapt.get[he])});if(!Z.members&&!Z.sizeof)Z.sizeof=me(Z.signature);let Qe=B(a.__makeDebugFlags($e.debugFlags));Object.defineProperties(fe,{debugFlags:Qe,isA:B((he)=>he instanceof fe),memberKey:Q,memberKeys:_e,structInfo:B(Z),structName:B(X),ptrAdd:B(z)}),fe.prototype=new Je(X,Z,B),Object.defineProperties(fe.prototype,{debugFlags:Qe,constructor:B(fe),ptrAdd:B(f)});let Ge=!1,xe=0,je=!!Z.autoCalcSizeOffset;if(!je){if(!Z.sizeof)r(X,"description is missing its sizeof property.");Z.offset??=0}else Z.offset??=0;if(Object.keys(Z.members||{}).forEach((he)=>{let De=Me(Z.members[he]);if(!De.members&&!De.sizeof){if(De.sizeof=me(De.signature),!De.sizeof)r(O(X,he),"is missing a sizeof property.",De)}if(De.offset===void 0)if(je)De.offset=xe;else r(O(X,he),"is missing its offset.",JSON.stringify(De));if(Z.members[he]=De,!Ge||Ge.offset<De.offset)Ge=De;let At=!!De.autoCalc;if(je)De.autoCalcSizeOffset=!0;if(Mt.call(Oe,fe,he,De),At)De.autoCalcSizeOffset=!0;else delete De.autoCalcSizeOffset;xe+=De.sizeof}),!Ge)r("No member property descriptions found.");if(!Z.sizeof)Z.sizeof=xe;if(Z.sizeof===1)Z.signature==="c"||Z.signature==="C"||r("Unexpected sizeof==1 member",O(X,k),"with signature",Z.signature);else{if(Z.sizeof%4!==0)console.warn("Invalid struct member description",Z),r(X,"sizeof is not aligned. sizeof="+Z.sizeof);if(Z.offset%4!==0)console.warn("Invalid struct member description",Z),r(X,"offset is not aligned. offset="+Z.offset)}if(Z.sizeof<xe)console.warn("Suspect struct description:",Z,"offset =",xe),r("Mismatch in the calculated vs. the provided sizeof/offset info.","Expected sizeof",xe,"but got",Z.sizeof,"for",Z);return delete Z.autoCalcSizeOffset,fe},$e=function P(X,Z){return arguments.length==1?vn.call(P,X):vn.call(P,X,Z)};if($e.StructType=Je,$e.config=t,$e.allocCString=tt,$e.adaptGet=Pe,$e.adaptSet=Ue,$e.adaptStruct=He,$e.ptrAdd=z,!$e.debugFlags)$e.debugFlags=a.__makeDebugFlags(a.debugFlags);return $e},globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=(...E)=>{throw Error(E.join(" "))},{capi:r,wasm:a,util:_}=i;globalThis.WhWasmUtilInstaller(a),delete globalThis.WhWasmUtilInstaller;let h={core:[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_backup_init","sqlite3_backup*","sqlite3*","string","sqlite3*","string"],["sqlite3_backup_step","int","sqlite3_backup*","int"],["sqlite3_backup_finish","int","sqlite3_backup*"],["sqlite3_backup_remaining","int","sqlite3_backup*"],["sqlite3_backup_pagecount","int","sqlite3_backup*"],["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 a.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(E,g)=>E[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 a.xWrap.FuncPtrAdapter({name:"sqlite3_commit_hook",signature:"i(p)",contextKey:(E)=>E[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 a.xWrap.FuncPtrAdapter({signature:"i(pipp)",bindScope:"transient",callProxy:(E)=>{let g;return(F,x,A,N)=>{try{let z=a.cArgvToJs(x,A);if(!g)g=a.cArgvToJs(x,N);return E(z,g)|0}catch(z){return z.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 a.xWrap.FuncPtrAdapter({name:"sqlite3_rollback_hook",signature:"v(p)",contextKey:(E)=>E[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 a.xWrap.FuncPtrAdapter({name:"sqlite3_trace_v2::callback",signature:"i(ippp)",contextKey:(E,g)=>E[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 a.xWrap.FuncPtrAdapter({name:"sqlite3_update_hook::callback",signature:"v(pippj)",contextKey:(E)=>E[0],callProxy:(E)=>(g,F,x,A,N)=>{E(g,F,a.cstrToJs(x),a.cstrToJs(A),N)}}),"*"]],["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(a.exports.sqlite3_progress_handler)h.core.push(["sqlite3_progress_handler",void 0,["sqlite3*","int",new a.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(E,g)=>E[0]}),"*"]]);if(a.exports.sqlite3_stmt_explain)h.core.push(["sqlite3_stmt_explain","int","sqlite3_stmt*","int"],["sqlite3_stmt_isexplain","int","sqlite3_stmt*"]);if(a.exports.sqlite3_set_authorizer)h.core.push(["sqlite3_set_authorizer","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(E,g)=>E[0],callProxy:(E)=>(g,F,x,A,N,z)=>{try{return x=x&&a.cstrToJs(x),A=A&&a.cstrToJs(A),N=N&&a.cstrToJs(N),z=z&&a.cstrToJs(z),E(g,F,x,A,N,z)|0}catch(f){return f.resultCode||r.SQLITE_ERROR}}}),"*"]]);if(a.exports.sqlite3_column_origin_name)h.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"]);if(a.exports.sqlite3_key_v2)h.core.push(["sqlite3_key","int","sqlite3*","string","int"],["sqlite3_key_v2","int","sqlite3*","string","*","int"],["sqlite3_rekey","int","sqlite3*","string","int"],["sqlite3_rekey_v2","int","sqlite3*","string","*","int"],["sqlite3_activate_see",void 0,"string"],["sqlite3mc_cipher_count","int"],["sqlite3mc_cipher_index","int","string"],["sqlite3mc_cipher_name","string","int"],["sqlite3mc_cipher_name_copy","int","int","string","int"],["sqlite3mc_config","int","sqlite3*","string","int"],["sqlite3mc_config_cipher","int","sqlite3*","string","string","int"],["sqlite3mc_codec_data","string","sqlite3*","string","string"],["sqlite3mc_version","string"],["sqlite3mc_vfs_create","int","string","int"],["sqlite3mc_vfs_destroy",void 0,"string"],["sqlite3mc_vfs_shutdown",void 0]);if(a.bigIntEnabled&&!!a.exports.sqlite3_declare_vtab)h.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","**"]);if(a.bigIntEnabled&&!!a.exports.sqlite3_preupdate_hook)h.int64.push(["sqlite3_preupdate_blobwrite","int","sqlite3*"],["sqlite3_preupdate_count","int","sqlite3*"],["sqlite3_preupdate_depth","int","sqlite3*"],["sqlite3_preupdate_hook","*",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_preupdate_hook",signature:"v(ppippjj)",contextKey:(E)=>E[0],callProxy:(E)=>(g,F,x,A,N,z,f)=>{E(g,F,x,a.cstrToJs(A),a.cstrToJs(N),z,f)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]]);if(a.bigIntEnabled&&!!a.exports.sqlite3changegroup_add&&!!a.exports.sqlite3session_create&&!!a.exports.sqlite3_preupdate_hook){let E={signature:"i(ps)",callProxy:(g)=>(F,x)=>{try{return g(F,a.cstrToJs(x))|0}catch(A){return A.resultCode||r.SQLITE_ERROR}}};h.int64.push(["sqlite3changegroup_add","int",["sqlite3_changegroup*","int","void*"]],["sqlite3changegroup_add_strm","int",["sqlite3_changegroup*",new a.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 a.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_v2","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v2_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new a.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 a.xWrap.FuncPtrAdapter({name:"xInputA",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xInputB",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.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 a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.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 a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changeset_start_v2","int",["**","int","*","int"]],["sqlite3changeset_start_v2_strm","int",["**",new a.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 a.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 a.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_table_filter",void 0,["sqlite3_session*",new a.xWrap.FuncPtrAdapter({name:"xFilter",...E,contextKey:(g,F)=>g[0]}),"*"]])}i.StructBinder=globalThis.Jaccwabyt({heap:a.heap8u,alloc:a.alloc,dealloc:a.dealloc,bigIntEnabled:a.bigIntEnabled,pointerIR:a.ptr.ir,memberPrefix:"$"}),delete globalThis.Jaccwabyt;{let E=a.xWrap.argAdapter("string");a.xWrap.argAdapter("string:flexible",(A)=>E(_.flexibleString(A))),a.xWrap.argAdapter("string:static",function(A){if(a.isPtr(A))return A;return A=""+A,this[A]||(this[A]=a.allocCString(A))}.bind(Object.create(null)));let g=a.xWrap.argAdapter("*"),F=function(){};if(a.xWrap.argAdapter("sqlite3_filename",g)("sqlite3_backup*",g)("sqlite3_context*",g)("sqlite3_value*",g)("void*",g)("sqlite3_changegroup*",g)("sqlite3_changeset_iter*",g)("sqlite3_session*",g)("sqlite3_stmt*",(A)=>g(A instanceof(i?.oo1?.Stmt||F)?A.pointer:A))("sqlite3*",(A)=>g(A instanceof(i?.oo1?.DB||F)?A.pointer:A))("sqlite3_vfs*",(A)=>{if(typeof A==="string")return r.sqlite3_vfs_find(A)||i.SQLite3Error.toss(r.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",A);return g(A instanceof(r.sqlite3_vfs||F)?A.pointer:A)}),a.exports.sqlite3_declare_vtab)a.xWrap.argAdapter("sqlite3_index_info*",(A)=>g(A instanceof(r.sqlite3_index_info||F)?A.pointer:A))("sqlite3_module*",(A)=>g(A instanceof(r.sqlite3_module||F)?A.pointer:A));let x=a.xWrap.resultAdapter("*");a.xWrap.resultAdapter("sqlite3*",x)("sqlite3_backup*",x)("sqlite3_context*",x)("sqlite3_stmt*",x)("sqlite3_value*",x)("sqlite3_vfs*",x)("void*",x);for(let A of h.core)r[A[0]]=a.xWrap.apply(null,A);for(let A of h.wasmInternal)_[A[0]]=a.xWrap.apply(null,A);for(let A of h.int64)r[A[0]]=a.bigIntEnabled?a.xWrap.apply(null,A):()=>t(A[0]+"() is unavailable due to lack","of BigInt support in this build.");delete h.core,delete h.int64,delete h.wasmInternal,_.sqlite3__wasm_db_error=function(A,N,z){if(!A)return r.SQLITE_MISUSE;if(N instanceof i.WasmAllocError)N=r.SQLITE_NOMEM,z=0;else if(N instanceof Error)z=z||""+N,N=N.resultCode||r.SQLITE_ERROR;return r.sqlite3_set_errmsg(A,N,z)||N}}{let E=a.xCall("sqlite3__wasm_enum_json");if(!E)t("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!");a.ctype=JSON.parse(a.cstrToJs(E));let g=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];if(a.bigIntEnabled)g.push("serialize","session","vtab");for(let A of g)for(let N of Object.entries(a.ctype[A]))r[N[0]]=N[1];if(!a.functionEntry(r.SQLITE_WASM_DEALLOC))t("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+r.SQLITE_WASM_DEALLOC+").");let F=Object.create(null);for(let A of Object.entries(a.ctype.resultCodes))F[A[1]]=A[0];r.sqlite3_js_rc_str=(A)=>F[A];let x=Object.assign(Object.create(null),{WasmTestStruct:!0,sqlite3_index_info:!a.bigIntEnabled,sqlite3_index_constraint:!a.bigIntEnabled,sqlite3_index_orderby:!a.bigIntEnabled,sqlite3_index_constraint_usage:!a.bigIntEnabled});for(let A of a.ctype.structs)if(!x[A.name])r[A.name]=i.StructBinder(A);if(r.sqlite3_index_info){for(let 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=a.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}let I=(E,g,F)=>_.sqlite3__wasm_db_error(E,r.SQLITE_MISUSE,g+"() requires "+F+" argument"+(F===1?"":"s")+"."),q=(E)=>_.sqlite3__wasm_db_error(E,r.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),R=(E)=>a.xWrap.argAdapter("sqlite3*")(E),M=(E)=>a.isPtr(E)?a.cstrToJs(E):E,p=function(E,g){E=R(E);let F=this.dbMap.get(E);if(!g)return this.dbMap.delete(E),F;else if(!F&&g>0)this.dbMap.set(E,F=Object.create(null));return F}.bind(Object.assign(Object.create(null),{dbMap:new Map}));if(p.addCollation=function(E,g){let F=p(E,1);if(!F.collation)F.collation=new Set;F.collation.add(M(g).toLowerCase())},p._addUDF=function(E,g,F,x){g=M(g).toLowerCase();let A=x.get(g);if(!A)x.set(g,A=new Set);A.add(F<0?-1:F)},p.addFunction=function(E,g,F){let x=p(E,1);if(!x.udf)x.udf=new Map;this._addUDF(E,g,F,x.udf)},a.exports.sqlite3_create_window_function)p.addWindowFunc=function(E,g,F){let x=p(E,1);if(!x.wudf)x.wudf=new Map;this._addUDF(E,g,F,x.wudf)};p.cleanup=function(E){E=R(E);for(let x 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]]){let[A,N]=x;if(!a.exports[A])continue;let f=[E];f.length=N;try{r[A](...f)}catch(S){i.config.warn("close-time call of",A+"(",f,") threw:",S)}}let g=p(E,0);if(!g)return;if(g.collation){for(let x of g.collation)try{r.sqlite3_create_collation_v2(E,x,r.SQLITE_UTF8,0,0,0)}catch(A){}delete g.collation}let F;for(F=0;F<2;++F){let x=F?g.wudf:g.udf;if(!x)continue;let A=F?r.sqlite3_create_window_function:r.sqlite3_create_function_v2;for(let N of x){let z=N[0],f=N[1],S=[E,z,0,r.SQLITE_UTF8,0,0,0,0,0];if(F)S.push(0);for(let D of f)try{S[2]=D,A.apply(null,S)}catch(J){}f.clear()}x.clear()}delete g.udf,delete g.wudf};{let E=a.xWrap("sqlite3_close_v2","int","sqlite3*");r.sqlite3_close_v2=function(g){if(arguments.length!==1)return I(g,"sqlite3_close_v2",1);if(g)try{p.cleanup(g)}catch(F){}return E(g)}}if(r.sqlite3session_create){let E=a.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);r.sqlite3session_delete=function(g){if(arguments.length!==1)return I(pDb,"sqlite3session_delete",1);else if(g)r.sqlite3session_table_filter(g,0,0);E(g)}}{let E=(F,x)=>"argv["+x+"]:"+F[0]+":"+a.cstrToJs(F[1]).toLowerCase(),g=a.xWrap("sqlite3_create_collation_v2","int",["sqlite3*","string","int","*",new a.xWrap.FuncPtrAdapter({name:"xCompare",signature:"i(pipip)",contextKey:E}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",signature:"v(p)",contextKey:E})]);r.sqlite3_create_collation_v2=function(F,x,A,N,z,f){if(arguments.length!==6)return I(F,"sqlite3_create_collation_v2",6);else if((A&15)===0)A|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(A&15))return q(F);try{let S=g(F,x,A,N,z,f);if(S===0&&z instanceof Function)p.addCollation(F,x);return S}catch(S){return _.sqlite3__wasm_db_error(F,S)}},r.sqlite3_create_collation=(F,x,A,N,z)=>arguments.length===5?r.sqlite3_create_collation_v2(F,x,A,N,z,0):I(F,"sqlite3_create_collation",5)}{let E=function(A,N){return A[0]+":"+(A[2]<0?-1:A[2])+":"+N+":"+a.cstrToJs(A[1]).toLowerCase()},g=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:E,callProxy:(A)=>(N,z,f)=>{try{A(N,...r.sqlite3_values_to_js(z,f))}catch(S){r.sqlite3_result_error_js(N,S)}}},xFinalAndValue:{signature:"v(p)",contextKey:E,callProxy:(A)=>(N)=>{try{r.sqlite3_result_js(N,A(N))}catch(z){r.sqlite3_result_error_js(N,z)}}},xFunc:{signature:"v(pip)",contextKey:E,callProxy:(A)=>(N,z,f)=>{try{r.sqlite3_result_js(N,A(N,...r.sqlite3_values_to_js(z,f)))}catch(S){r.sqlite3_result_error_js(N,S)}}},xDestroy:{signature:"v(p)",contextKey:E,callProxy:(A)=>(N)=>{try{A(N)}catch(z){console.error("UDF xDestroy method threw:",z)}}}}),F=a.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xFunc",...g.xFunc}),new a.xWrap.FuncPtrAdapter({name:"xStep",...g.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...g.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...g.xDestroy})]),x=a.exports.sqlite3_create_window_function?a.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xStep",...g.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...g.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xValue",...g.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xInverse",...g.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...g.xDestroy})]):void 0;if(r.sqlite3_create_function_v2=function A(N,z,f,S,D,J,ie,le,Se){if(A.length!==arguments.length)return I(N,"sqlite3_create_function_v2",A.length);else if((S&15)===0)S|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(S&15))return q(N);try{let me=F(N,z,f,S,D,J,ie,le,Se);if(me===0&&(J instanceof Function||ie instanceof Function||le instanceof Function||Se instanceof Function))p.addFunction(N,z,f);return me}catch(me){return console.error("sqlite3_create_function_v2() setup threw:",me),_.sqlite3__wasm_db_error(N,me,"Creation of UDF threw: "+me)}},r.sqlite3_create_function=function A(N,z,f,S,D,J,ie,le){return A.length===arguments.length?r.sqlite3_create_function_v2(N,z,f,S,D,J,ie,le,0):I(N,"sqlite3_create_function",A.length)},x)r.sqlite3_create_window_function=function A(N,z,f,S,D,J,ie,le,Se,me){if(A.length!==arguments.length)return I(N,"sqlite3_create_window_function",A.length);else if((S&15)===0)S|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(S&15))return q(N);try{let K=x(N,z,f,S,D,J,ie,le,Se,me);if(K===0&&(J instanceof Function||ie instanceof Function||le instanceof Function||Se instanceof Function||me instanceof Function))p.addWindowFunc(N,z,f);return K}catch(K){return console.error("sqlite3_create_window_function() setup threw:",K),_.sqlite3__wasm_db_error(N,K,"Creation of UDF threw: "+K)}};else delete r.sqlite3_create_window_function;if(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;if(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;if(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}{let E=(F,x)=>{if(typeof F==="string")x=-1;else if(_.isSQLableTypedArray(F))x=F.byteLength,F=a.typedArrayToString(F instanceof ArrayBuffer?new Uint8Array(F):F);else if(Array.isArray(F))F=F.join(""),x=-1;return[F,x]},g={basic:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};r.sqlite3_prepare_v3=function F(x,A,N,z,f,S){if(F.length!==arguments.length)return I(x,"sqlite3_prepare_v3",F.length);let[D,J]=E(A,Number(N));switch(typeof D){case"string":return g.basic(x,D,J,z,f,null);case typeof a.ptr.null:return g.full(x,a.ptr.coerce(D),J,z,f,S);default:return _.sqlite3__wasm_db_error(x,r.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3(). typeof="+typeof D)}},r.sqlite3_prepare_v2=function F(x,A,N,z,f){return F.length===arguments.length?r.sqlite3_prepare_v3(x,A,N,0,z,f):I(x,"sqlite3_prepare_v2",F.length)}}{let E=a.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),g=a.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);r.sqlite3_bind_text=function F(x,A,N,z,f){if(F.length!==arguments.length)return I(r.sqlite3_db_handle(x),"sqlite3_bind_text",F.length);else if(a.isPtr(N)||N===null)return E(x,A,N,z,f);else if(N instanceof ArrayBuffer)N=new Uint8Array(N);else if(Array.isArray(pMem))N=pMem.join("");let S,D;try{if(_.isSQLableTypedArray(N))S=a.allocFromTypedArray(N),D=N.byteLength;else if(typeof N==="string")[S,D]=a.allocCString(N);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return E(x,A,S,D,r.SQLITE_WASM_DEALLOC)}catch(J){return a.dealloc(S),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),J)}},r.sqlite3_bind_blob=function F(x,A,N,z,f){if(F.length!==arguments.length)return I(r.sqlite3_db_handle(x),"sqlite3_bind_blob",F.length);else if(a.isPtr(N)||N===null)return g(x,A,N,z,f);else if(N instanceof ArrayBuffer)N=new Uint8Array(N);else if(Array.isArray(N))N=N.join("");let S,D;try{if(_.isBindableTypedArray(N))S=a.allocFromTypedArray(N),D=z>=0?z:N.byteLength;else if(typeof N==="string")[S,D]=a.allocCString(N);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return g(x,A,S,D,r.SQLITE_WASM_DEALLOC)}catch(J){return a.dealloc(S),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),J)}}}if(!r.sqlite3_column_text){let E=a.xWrap.argAdapter("sqlite3_stmt*"),g=a.xWrap.argAdapter("int"),F=a.xWrap.argAdapter("sqlite3_value*"),x=(A,N)=>a.typedArrayToString(a.heap8u(),Number(A),Number(A)+N);r.sqlite3_column_text=function(A,N){let z=E(A),f=g(N),S=a.exports.sqlite3_column_text(z,f);return S?x(S,a.exports.sqlite3_column_bytes(z,f)):null},r.sqlite3_value_text=function(A){let N=F(A),z=a.exports.sqlite3_value_text(N);return z?x(z,a.exports.sqlite3_value_bytes(N)):null}}r.sqlite3_config=function(E,...g){if(arguments.length<2)return r.SQLITE_MISUSE;switch(E){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 a.exports.sqlite3__wasm_config_i(E,g[0]);case r.SQLITE_CONFIG_LOOKASIDE:return a.exports.sqlite3__wasm_config_ii(E,g[0],g[1]);case r.SQLITE_CONFIG_MEMDB_MAXSIZE:return a.exports.sqlite3__wasm_config_j(E,g[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}};{let E=new Set;r.sqlite3_auto_extension=function(g){if(g instanceof Function)g=a.installFunction("i(ppp)",g);else if(arguments.length!==1||!a.isPtr(g))return r.SQLITE_MISUSE;let F=a.exports.sqlite3_auto_extension(g);if(g!==arguments[0])if(F===0)E.add(g);else a.uninstallFunction(g);return F},r.sqlite3_cancel_auto_extension=function(g){if(!g||arguments.length!==1||!a.isPtr(g))return 0;return a.exports.sqlite3_cancel_auto_extension(g)},r.sqlite3_reset_auto_extension=function(){a.exports.sqlite3_reset_auto_extension();for(let g of E)a.uninstallFunction(g);E.clear()}}a.xWrap.FuncPtrAdapter.warnOnUse=!0;let te=i.StructBinder,j=function E(g,F,x,A=E.installMethodArgcCheck){if(!(g instanceof te.StructType))t("Usage error: target object is-not-a StructType.");else if(!(x instanceof Function)&&!a.isPtr(x))t("Usage error: expecting a Function or WASM pointer to one.");if(arguments.length===1)return(S,D)=>E(g,S,D,A);if(!E.argcProxy)E.argcProxy=function(S,D,J,ie){return function(...le){if(J.length!==arguments.length)t("Argument mismatch for",S.structInfo.name+"::"+D+": Native signature is:",ie);return J.apply(this,le)}},E.removeFuncList=function(){if(this.ondispose.__removeFuncList)this.ondispose.__removeFuncList.forEach((S,D)=>{if(a.isPtr(S))try{a.uninstallFunction(S)}catch(J){}}),delete this.ondispose.__removeFuncList};let N=g.memberSignature(F);if(N.length<2)t("Member",F,"does not have a function pointer signature:",N);let z=g.memberKey(F),f=A&&!a.isPtr(x)?E.argcProxy(g,z,x,N):x;if(a.isPtr(f)){if(f&&!a.functionEntry(f))t("Pointer",f,"is not a WASM function table entry.");g[z]=f}else{let S=a.installFunction(f,N);if(g[z]=S,!g.ondispose||!g.ondispose.__removeFuncList)g.addOnDispose("ondispose.__removeFuncList handler",E.removeFuncList),g.ondispose.__removeFuncList=[];g.ondispose.__removeFuncList.push(z,S)}return(S,D)=>E(g,S,D,A)};j.installMethodArgcCheck=!1;let U=function(E,g,F=j.installMethodArgcCheck){let x=new Map;for(let A of Object.keys(g)){let N=g[A],z=x.get(N);if(z){let f=E.memberKey(A);E[f]=E[E.memberKey(z)]}else j(E,A,N,F),x.set(N,A)}return E};te.StructType.prototype.installMethod=function(g,F,x=j.installMethodArgcCheck){return arguments.length<3&&g&&typeof g==="object"?U(this,...arguments):j(this,...arguments)},te.StructType.prototype.installMethods=function(E,g=j.installMethodArgcCheck){return U(this,E,g)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=(...m)=>{throw new i.SQLite3Error(...m)},{capi:r,wasm:a,util:_}=i,h=function(m){return(...b)=>m("sqlite3.oo1:",...b)},I=i.__isUnderTest?h(console.debug.bind(console)):h(i.config.debug),q=i.__isUnderTest?h(console.warn.bind(console)):h(i.config.warn),R=i.__isUnderTest?h(console.error.bind(console)):h(i.config.error),M=new WeakMap,p=new Set,te=new WeakMap,j=(m,b,C)=>{let c=Object.getOwnPropertyDescriptor(m,b);return c?c.value:C},U=function(m,b){if(b){if(m instanceof N)m=m.pointer;t(b,"sqlite3 result code",b+":",m?r.sqlite3_errmsg(m):r.sqlite3_errstr(b))}return arguments[0]},E=a.installFunction("i(ippp)",function(m,b,C,c){if(r.SQLITE_TRACE_STMT===m)console.log("SQL TRACE #"+ ++this.counter,"via sqlite3@"+b+"["+r.sqlite3_db_filename(b,null)+"]",a.cstrToJs(c))}.bind({counter:0})),g=Object.create(null),F=function(m){if(m instanceof ArrayBuffer)m=new Uint8Array(m);let b=[],C="0123456789abcdef";for(let c of m)b.push(C[(c&240)>>4],C[c&15]);return b.join("")},x=function(m,b){if(!r.sqlite3_key_v2)return;let C,c,d=(b.key?1:0)+(b.hexkey?1:0)+(b.textkey?1:0);if(!d)return;else if(d>1)t(r.SQLITE_MISUSE,"Only ONE of (key, hexkey, textkey) may be provided.");if(b.key){if(C="key",c=b.key,typeof c==="string")c=new TextEncoder("utf-8").encode(c);if(c instanceof ArrayBuffer||c instanceof Uint8Array)c=F(c),C="hexkey";else{t(r.SQLITE_MISUSE,"Invalid value for the 'key' option. Expecting a string,","ArrayBuffer, or Uint8Array.");return}}else if(b.textkey){if(C="textkey",c=b.textkey,c instanceof ArrayBuffer)c=new Uint8Array(c);if(c instanceof Uint8Array)c=new TextDecoder("utf-8").decode(c);else if(typeof c!=="string")t(r.SQLITE_MISUSE,"Invalid value for the 'textkey' option. Expecting a string,","ArrayBuffer, or Uint8Array.")}else if(b.hexkey){if(C="hexkey",c=b.hexkey,c instanceof ArrayBuffer||c instanceof Uint8Array)c=F(c);else if(typeof c!=="string")t(r.SQLITE_MISUSE,"Invalid value for the 'hexkey' option. Expecting a string,","ArrayBuffer, or Uint8Array.")}else return;let L;try{return L=m.prepare("PRAGMA "+C+"="+_.sqlite3__wasm_qfmt_token(c,1)),L.step(),!0}finally{if(L)L.finalize()}},A=function m(...b){let C=m.normalizeArgs(...b),c;if(c=C["sqlite3*"]){if(!C["sqlite3*:takeOwnership"])p.add(this);this.filename=r.sqlite3_db_filename(c,"main")}else{let{filename:d,vfs:L,flags:G}=C;if(typeof d!=="string"&&!a.isPtr(d)||typeof G!=="string"||L&&(typeof L!=="string"&&!a.isPtr(L)))i.config.error("Invalid DB ctor args",C,arguments),t("Invalid arguments for DB constructor:",arguments,"opts:",C);let B=0;if(G.indexOf("c")>=0)B|=r.SQLITE_OPEN_CREATE|r.SQLITE_OPEN_READWRITE;if(G.indexOf("w")>=0)B|=r.SQLITE_OPEN_READWRITE;if(B===0)B|=r.SQLITE_OPEN_READONLY;B|=r.SQLITE_OPEN_EXRESCODE;let ae=a.pstack.pointer;try{let ce=a.pstack.allocPtr(),ge=r.sqlite3_open_v2(d,ce,B,L||a.ptr.null);if(c=a.peekPtr(ce),U(c,ge),r.sqlite3_extended_result_codes(c,1),G.indexOf("t")>=0)r.sqlite3_trace_v2(c,r.SQLITE_TRACE_STMT,E,c)}catch(ce){if(c)r.sqlite3_close_v2(c);throw ce}finally{a.pstack.restore(ae)}this.filename=a.isPtr(d)?a.cstrToJs(d):d}if(M.set(this,c),te.set(this,Object.create(null)),!C["sqlite3*"])try{x(this,C);let d=r.sqlite3_js_db_vfs(c)||t("Internal error: cannot get VFS for new db handle."),L=g[d];if(L)if(L instanceof Function)L(this,i);else U(c,r.sqlite3_exec(c,L,0,0,0))}catch(d){throw this.close(),d}};A.setVfsPostOpenCallback=function(m,b){if(!(b instanceof Function))t("dbCtorHelper.setVfsPostOpenCallback() should not be used with a non-function argument.",arguments);g[m]=b},A.normalizeArgs=function(m=":memory:",b="c",C=null){let c={};if(arguments.length===1&&arguments[0]&&typeof arguments[0]==="object"){if(Object.assign(c,arguments[0]),c.flags===void 0)c.flags="c";if(c.vfs===void 0)c.vfs=null;if(c.filename===void 0)c.filename=":memory:"}else c.filename=m,c.flags=b,c.vfs=C;return c};let N=function(...m){A.apply(this,m)};N.dbCtorHelper=A;let z={null:1,number:2,string:3,boolean:4,blob:5};if(a.bigIntEnabled)z.bigint=z.number;let f=function(){if(z!==arguments[2])t(r.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare().");if(this.db=arguments[0],M.set(this,arguments[1]),arguments.length>3&&!arguments[3])p.add(this)},S=function(m){if(!m.pointer)t("DB has been closed.");return m},D=function(m,b){if(b!==(b|0)||b<0||b>=m.columnCount)t("Column index",b,"is out of range.");return m},J=function(m,b){let C=Object.create(null);switch(C.opt=Object.create(null),b.length){case 1:if(typeof b[0]==="string"||_.isSQLableTypedArray(b[0]))C.sql=b[0];else if(Array.isArray(b[0]))C.sql=b[0];else if(b[0]&&typeof b[0]==="object")C.opt=b[0],C.sql=C.opt.sql;break;case 2:C.sql=b[0],C.opt=b[1];break;default:t("Invalid argument count for exec().")}if(C.sql=_.flexibleString(C.sql),typeof C.sql!=="string")t("Missing SQL argument or unsupported SQL value type.");let c=C.opt;switch(c.returnValue){case"resultRows":if(!c.resultRows)c.resultRows=[];C.returnVal=()=>c.resultRows;break;case"saveSql":if(!c.saveSql)c.saveSql=[];C.returnVal=()=>c.saveSql;break;case void 0:case"this":C.returnVal=()=>m;break;default:t("Invalid returnValue value:",c.returnValue)}if(!c.callback&&!c.returnValue&&c.rowMode!==void 0){if(!c.resultRows)c.resultRows=[];C.returnVal=()=>c.resultRows}if(c.callback||c.resultRows)switch(c.rowMode===void 0?"array":c.rowMode){case"object":C.cbArg=(d,L)=>{if(!L.columnNames)L.columnNames=d.getColumnNames([]);let G=d.get([]),B=Object.create(null);for(let ae in L.columnNames)B[L.columnNames[ae]]=G[ae];return B};break;case"array":C.cbArg=(d)=>d.get([]);break;case"stmt":if(Array.isArray(c.resultRows))t("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference.");C.cbArg=(d)=>d;break;default:if(_.isInt32(c.rowMode)){C.cbArg=(d)=>d.get(c.rowMode);break}else if(typeof c.rowMode==="string"&&c.rowMode.length>1&&c.rowMode[0]==="$"){let d=c.rowMode.substr(1);C.cbArg=(L)=>{let G=L.get(Object.create(null))[d];return G===void 0?t(r.SQLITE_NOTFOUND,"exec(): unknown result column:",d):G};break}t("Invalid rowMode:",c.rowMode)}return C},ie=(m,b,C,...c)=>{let d=m.prepare(b);try{let L=d.bind(C).step()?d.get(...c):void 0;return d.reset(),L}finally{d.finalize()}},le=(m,b,C,c)=>m.exec({sql:b,bind:C,rowMode:c,returnValue:"resultRows"}),Se=(m,b,C)=>{switch(C===void 0?r.sqlite3_column_type(m.pointer,b):C){case r.SQLITE_NULL:return null;case r.SQLITE_INTEGER:if(a.bigIntEnabled){let c=r.sqlite3_column_int64(m.pointer,b);if(c>=Number.MIN_SAFE_INTEGER&&c<=Number.MAX_SAFE_INTEGER)return Number(c).valueOf();return c}else{let c=r.sqlite3_column_double(m.pointer,b);if(c>Number.MAX_SAFE_INTEGER||c<Number.MIN_SAFE_INTEGER)t("Integer is out of range for JS integer range: "+c);return _.isInt32(c)?c|0:c}case r.SQLITE_FLOAT:return r.sqlite3_column_double(m.pointer,b);case r.SQLITE_TEXT:return r.sqlite3_column_text(m.pointer,b);case r.SQLITE_BLOB:{let c=r.sqlite3_column_bytes(m.pointer,b),d=r.sqlite3_column_blob(m.pointer,b),L=new Uint8Array(c);if(c){if(L.set(a.heap8u().slice(Number(d),Number(d)+c),0),m.db._blobXfer instanceof Array)m.db._blobXfer.push(L.buffer)}return L}default:t("Don't know how to translate","type of result column #"+b+".")}t("Not reached.")};N.checkRc=(m,b)=>U(m,b),N.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return S(this)},close:function(){let m=this.pointer;if(m){if(this.onclose?.before instanceof Function)try{this.onclose.before(this)}catch(b){}for(let b of Object.values(te.get(this)))if(b?.pointer)try{b.finalize()}catch(C){}if(M.delete(this),te.delete(this),!p.delete(this))r.sqlite3_close_v2(m);if(this.onclose?.after instanceof Function)try{this.onclose.after(this)}catch(b){}delete this.filename}},changes:function(m=!1,b=!1){let C=S(this).pointer;if(m)return b?r.sqlite3_total_changes64(C):r.sqlite3_total_changes(C);else return b?r.sqlite3_changes64(C):r.sqlite3_changes(C)},dbFilename:function(m="main"){return r.sqlite3_db_filename(S(this).pointer,m)},dbName:function(m=0){return r.sqlite3_db_name(S(this).pointer,m)},dbVfsName:function(m=0){let b,C=r.sqlite3_js_db_vfs(S(this).pointer,m);if(C){let c=new r.sqlite3_vfs(C);try{b=a.cstrToJs(c.$zName)}finally{c.dispose()}}return b},prepare:function(m){S(this);let b=a.pstack.pointer,C,c;try{C=a.pstack.alloc(8),N.checkRc(this,r.sqlite3_prepare_v2(this.pointer,m,-1,C,null)),c=a.peekPtr(C)}finally{a.pstack.restore(b)}if(!c)t("Cannot prepare empty SQL.");let d=new f(this,c,z);return te.get(this)[c]=d,d},exec:function(){S(this);let m=J(this,arguments);if(!m.sql)return t("exec() requires an SQL string.");let b=m.opt,C=b.callback,c=Array.isArray(b.resultRows)?b.resultRows:void 0,d,L=b.bind,G=!!(m.cbArg||b.columnNames||c),B=a.scopedAllocPush(),ae=Array.isArray(b.saveSql)?b.saveSql:void 0;try{let ce=_.isSQLableTypedArray(m.sql),ge=ce?m.sql.byteLength:a.jstrlen(m.sql),qe=a.scopedAlloc(2*a.ptr.size+(ge+1)),Fe=a.ptr.add(qe,a.ptr.size),Pe=a.ptr.add(Fe,a.ptr.size),Ee=a.ptr.add(Pe,ge);if(ce)a.heap8().set(m.sql,Pe);else a.jstrcpy(m.sql,a.heap8(),Pe,ge,!1);a.poke8(a.ptr.add(Pe,ge),0);while(Pe&&a.peek8(Pe)){a.pokePtr([qe,Fe],0),N.checkRc(this,r.sqlite3_prepare_v3(this.pointer,Pe,ge,0,qe,Fe));let Ue=a.peekPtr(qe);if(Pe=a.peekPtr(Fe),ge=Number(a.ptr.add(Ee,-Pe)),!Ue)continue;if(ae)ae.push(r.sqlite3_sql(Ue).trim());if(d=new f(this,Ue,z),L&&d.parameterCount)d.bind(L),L=null;if(G&&d.columnCount){let He=Array.isArray(b.columnNames)?0:1;if(G=!1,m.cbArg||c){let T=Object.create(null);for(;d.step();y.delete(d)){if(He++===0)d.getColumnNames(T.columnNames=b.columnNames||[]);y.add(d);let W=m.cbArg(d,T);if(c)c.push(W);if(C&&C.call(b,W,d)===!1)break}y.delete(d)}if(He===0)d.getColumnNames(b.columnNames)}else d.step();d.reset().finalize(),d=null}}finally{if(d)y.delete(d),d.finalize();a.scopedAllocPop(B)}return m.returnVal()},createFunction:function(b,C,c){let d=(T)=>T instanceof Function;switch(arguments.length){case 1:c=b,b=c.name,C=c.xFunc||0;break;case 2:if(!d(C))c=C,C=c.xFunc||0;break;case 3:break;default:break}if(!c)c={};if(typeof b!=="string")t("Invalid arguments: missing function name.");let L=c.xStep||0,G=c.xFinal||0,B=c.xValue||0,ae=c.xInverse||0,ce=void 0;if(d(C)){if(ce=!1,d(L)||d(G))t("Ambiguous arguments: scalar or aggregate?");L=G=null}else if(d(L)){if(!d(G))t("Missing xFinal() callback for aggregate or window UDF.");C=null}else if(d(G))t("Missing xStep() callback for aggregate or window UDF.");else t("Missing function-type properties.");if(ce===!1){if(d(B)||d(ae))t("xValue and xInverse are not permitted for non-window UDFs.")}else if(d(B)){if(!d(ae))t("xInverse must be provided if xValue is.");ce=!0}else if(d(ae))t("xValue must be provided if xInverse is.");let ge=c.pApp;if(ge!==void 0&&ge!==null&&!a.isPtr(ge))t("Invalid value for pApp property. Must be a legal WASM pointer value.");let qe=c.xDestroy||0;if(qe&&!d(qe))t("xDestroy property must be a function.");let Fe=0;if(j(c,"deterministic"))Fe|=r.SQLITE_DETERMINISTIC;if(j(c,"directOnly"))Fe|=r.SQLITE_DIRECTONLY;if(j(c,"innocuous"))Fe|=r.SQLITE_INNOCUOUS;b=b.toLowerCase();let Pe=C||L,Ee=j(c,"arity"),Ue=typeof Ee==="number"?Ee:Pe.length?Pe.length-1:0,He;if(ce)He=r.sqlite3_create_window_function(this.pointer,b,Ue,r.SQLITE_UTF8|Fe,ge||0,L,G,B,ae,qe);else He=r.sqlite3_create_function_v2(this.pointer,b,Ue,r.SQLITE_UTF8|Fe,ge||0,C,L,G,qe);return N.checkRc(this,He),this},selectValue:function(m,b,C){return ie(this,m,b,0,C)},selectValues:function(m,b,C){let c=this.prepare(m),d=[];try{D(c,0),c.bind(b);while(c.step())d.push(Se(c,0,C));c.reset()}finally{c.finalize()}return d},selectArray:function(m,b){return ie(this,m,b,[])},selectObject:function(m,b){return ie(this,m,b,{})},selectArrays:function(m,b){return le(this,m,b,"array")},selectObjects:function(m,b){return le(this,m,b,"object")},openStatementCount:function(){return this.pointer?Object.keys(te.get(this)).length:0},transaction:function(m){let b="BEGIN";if(arguments.length>1){if(/[^a-zA-Z]/.test(arguments[0]))t(r.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier.");b+=" "+arguments[0],m=arguments[1]}S(this).exec(b);try{let C=m(this);return this.exec("COMMIT"),C}catch(C){throw this.exec("ROLLBACK"),C}},savepoint:function(m){S(this).exec("SAVEPOINT oo1");try{let b=m(this);return this.exec("RELEASE oo1"),b}catch(b){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),b}},checkRc:function(m){return U(this,m)}},N.wrapHandle=function(m,b=!1){if(!m||!a.isPtr(m))throw new i.SQLite3Error(r.SQLITE_MISUSE,"Argument must be a WASM sqlite3 pointer");return new N({"sqlite3*":m,"sqlite3*:takeOwnership":!!b})};let me=function(m){if(!m.pointer)t("Stmt has been closed.");return m},K=function(m){let b=z[m===null||m===void 0?"null":typeof m];switch(b){case z.boolean:case z.null:case z.number:case z.string:return b;case z.bigint:return a.bigIntEnabled?b:void 0;default:return _.isBindableTypedArray(m)?z.blob:void 0}},oe=function(m){return K(m)||t("Unsupported bind() argument type:",typeof m)},u=function(m,b){let C=typeof b==="number"?b:r.sqlite3_bind_parameter_index(m.pointer,b);if(C===0||!_.isInt32(C))t("Invalid bind() parameter name: "+b);else if(C<1||C>m.parameterCount)t("Bind index",b,"is out of range.");return C},y=new Set,O=new Set,V=function(m,b){if(y.has(m))t("Operation is illegal when statement is locked:",b);return m},Y=function m(b,C,c,d){if(V(me(b),"bind()"),!m._)m._tooBigInt=(G)=>t("BigInt value is too big to store without precision loss:",G),m._={string:function(G,B,ae,ce){let[ge,qe]=a.allocCString(ae,!0);return(ce?r.sqlite3_bind_blob:r.sqlite3_bind_text)(G.pointer,B,ge,qe,r.SQLITE_WASM_DEALLOC)}};oe(d),C=u(b,C);let L=0;switch(d===null||d===void 0?z.null:c){case z.null:L=r.sqlite3_bind_null(b.pointer,C);break;case z.string:L=m._.string(b,C,d,!1);break;case z.number:{let G;if(_.isInt32(d))G=r.sqlite3_bind_int;else if(typeof d==="bigint")if(!_.bigIntFits64(d))m._tooBigInt(d);else if(a.bigIntEnabled)G=r.sqlite3_bind_int64;else if(_.bigIntFitsDouble(d))d=Number(d),G=r.sqlite3_bind_double;else m._tooBigInt(d);else if(d=Number(d),a.bigIntEnabled&&Number.isInteger(d))G=r.sqlite3_bind_int64;else G=r.sqlite3_bind_double;L=G(b.pointer,C,d);break}case z.boolean:L=r.sqlite3_bind_int(b.pointer,C,d?1:0);break;case z.blob:{if(typeof d==="string"){L=m._.string(b,C,d,!0);break}else if(d instanceof ArrayBuffer)d=new Uint8Array(d);else if(!_.isBindableTypedArray(d))t("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");let G=a.alloc(d.byteLength||1);a.heap8().set(d.byteLength?d:[0],Number(G)),L=r.sqlite3_bind_blob(b.pointer,C,G,d.byteLength,r.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",d),t("Unsupported bind() argument type: "+typeof d)}if(L)N.checkRc(b.db.pointer,L);return b};f.prototype={finalize:function(){let m=this.pointer;if(m){V(this,"finalize()");let b=p.delete(this)?0:r.sqlite3_finalize(m);return delete te.get(this.db)[m],M.delete(this),y.delete(this),O.delete(this),delete this.parameterCount,delete this.db,b}},clearBindings:function(){return V(me(this),"clearBindings()"),r.sqlite3_clear_bindings(this.pointer),O.delete(this),this},reset:function(m){if(V(this,"reset()"),m)this.clearBindings();let b=r.sqlite3_reset(me(this).pointer);return O.delete(this),U(this.db,b),this},resetNoThrow:function(m){if(V(this,"reset()"),m)this.clearBindings();let b=r.sqlite3_reset(me(this).pointer);return O.delete(this),b},bind:function(){me(this);let m,b;switch(arguments.length){case 1:m=1,b=arguments[0];break;case 2:m=arguments[0],b=arguments[1];break;default:t("Invalid bind() arguments.")}if(b===void 0)return this;else if(!this.parameterCount)t("This statement has no bindable parameters.");if(O.delete(this),b===null)return Y(this,m,z.null,b);else if(Array.isArray(b)){if(arguments.length!==1)t("When binding an array, an index argument is not permitted.");return b.forEach((C,c)=>Y(this,c+1,oe(C),C)),this}else if(b instanceof ArrayBuffer)b=new Uint8Array(b);if(typeof b==="object"&&!_.isBindableTypedArray(b)){if(arguments.length!==1)t("When binding an object, an index argument is not permitted.");return Object.keys(b).forEach((C)=>Y(this,C,oe(b[C]),b[C])),this}else return Y(this,m,oe(b),b);t("Should not reach this point.")},bindAsBlob:function(m,b){if(me(this),arguments.length===1)b=m,m=1;let C=oe(b);if(z.string!==C&&z.blob!==C&&z.null!==C)t("Invalid value type for bindAsBlob()");return Y(this,m,z.blob,b)},step:function(){V(this,"step()");let m=r.sqlite3_step(me(this).pointer);switch(m){case r.SQLITE_DONE:return O.delete(this),!1;case r.SQLITE_ROW:return O.add(this),!0;default:O.delete(this),i.config.warn("sqlite3_step() rc=",m,r.sqlite3_js_rc_str(m),"SQL =",r.sqlite3_sql(this.pointer)),N.checkRc(this.db.pointer,m)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{let m=this.step();return this.reset(),m}finally{try{this.finalize()}catch(m){}}},get:function(m,b){if(!O.has(me(this)))t("Stmt.step() has not (recently) returned true.");if(Array.isArray(m)){let C=0,c=this.columnCount;while(C<c)m[C]=Se(this,C,b),++C;return m}else if(m&&typeof m==="object"){let C=0,c=this.columnCount;while(C<c)m[r.sqlite3_column_name(this.pointer,C)]=Se(this,C,b),++C;return m}return D(this,m),Se(this,m,b)},getInt:function(m){return this.get(m,r.SQLITE_INTEGER)},getFloat:function(m){return this.get(m,r.SQLITE_FLOAT)},getString:function(m){return this.get(m,r.SQLITE_TEXT)},getBlob:function(m){return this.get(m,r.SQLITE_BLOB)},getJSON:function(m){let b=this.get(m,r.SQLITE_STRING);return b===null?b:JSON.parse(b)},getColumnName:function(m){return r.sqlite3_column_name(D(me(this),m).pointer,m)},getColumnNames:function(m=[]){D(me(this),0);let b=this.columnCount;for(let C=0;C<b;++C)m.push(r.sqlite3_column_name(this.pointer,C));return m},getParamIndex:function(m){return me(this).parameterCount?r.sqlite3_bind_parameter_index(this.pointer,m):void 0},getParamName:function(m){return me(this).parameterCount?r.sqlite3_bind_parameter_name(this.pointer,m):void 0},isBusy:function(){return r.sqlite3_stmt_busy(me(this))!==0},isReadOnly:function(){return r.sqlite3_stmt_readonly(me(this))!==0}};{let m={enumerable:!0,get:function(){return M.get(this)},set:()=>t("The pointer property is read-only.")};Object.defineProperty(f.prototype,"pointer",m),Object.defineProperty(N.prototype,"pointer",m)}Object.defineProperty(f.prototype,"columnCount",{enumerable:!1,get:function(){return r.sqlite3_column_count(this.pointer)},set:()=>t("The columnCount property is read-only.")}),Object.defineProperty(f.prototype,"parameterCount",{enumerable:!1,get:function(){return r.sqlite3_bind_parameter_count(this.pointer)},set:()=>t("The parameterCount property is read-only.")}),f.wrapHandle=function(m,b,C=!1){let c=f;if(!(m instanceof N)||!m.pointer)throw new i.SQLite3Error(i.SQLITE_MISUSE,"First argument must be an opened sqlite3.oo1.DB instance");if(!b||!a.isPtr(b))throw new i.SQLite3Error(i.SQLITE_MISUSE,"Second argument must be a WASM sqlite3_stmt pointer");return new f(m,b,z,!!C)},i.oo1={DB:N,Stmt:f}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=i.util;i.initWorker1API=function(){let r=(...j)=>{throw Error(j.join(" "))};if(!(globalThis.WorkerGlobalScope instanceof Function))r("initWorker1API() must be run from a Worker thread.");let a=this.sqlite3||r("Missing this.sqlite3 object."),_=a.oo1.DB,h=function(j){let U=I.idMap.get(j);if(U)return U;return U="db#"+ ++I.idSeq+":"+Math.floor(Math.random()*1e8)+":"+Math.floor(Math.random()*1e8),I.idMap.set(j,U),U},I={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function(j){let U=new _(j);if(this.dbs[h(U)]=U,this.dbList.indexOf(U)<0)this.dbList.push(U);return U},close:function(j,U){if(j){delete this.dbs[h(j)];let E=j.filename,g=t.sqlite3__wasm_db_vfs(j.pointer,0);j.close();let F=this.dbList.indexOf(j);if(F>=0)this.dbList.splice(F,1);if(U&&E&&g)t.sqlite3__wasm_vfs_unlink(g,E)}},post:function(j,U){if(U&&U.length)globalThis.postMessage(j,Array.from(U)),U.length=0;else globalThis.postMessage(j)},dbs:Object.create(null),getDb:function(j,U=!0){return this.dbs[j]||(U?r("Unknown (or closed) DB ID:",j):void 0)}},q=function(j=I.dbList[0]){return j&&j.pointer?j:r("DB is not opened.")},R=function(j,U=!0){let E=I.getDb(j.dbId,!1)||I.dbList[0];return U?q(E):E},M=function(){return I.dbList[0]&&h(I.dbList[0])},p=(j)=>j===""||j[0]===":",te={open:function(j){let U=Object.create(null),E=j.args||Object.create(null);if(E.simulateError)r("Throwing because of simulateError flag.");let g=Object.create(null);U.vfs=E.vfs,U.filename=E.filename||"";let F=I.open(U);return g.filename=F.filename,g.persistent=!!a.capi.sqlite3_js_db_uses_vfs(F.pointer,"opfs"),g.dbId=h(F),g.vfs=F.dbVfsName(),g},close:function(j){let U=R(j,!1),E={filename:U&&U.filename};if(U){let g=j.args&&typeof j.args==="object"?!!j.args.unlink:!1;I.close(U,g)}return E},exec:function(j){let U=typeof j.args==="string"?{sql:j.args}:j.args||Object.create(null);if(U.rowMode==="stmt")r("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API.");else if(!U.sql)r("'exec' requires input SQL.");let E=R(j);if(U.callback||Array.isArray(U.resultRows))E._blobXfer=I.xfer;let g=U.callback,F=0,x=!!U.columnNames;if(typeof g==="string"){if(!x)U.columnNames=[];U.callback=function(A,N){I.post({type:g,columnNames:U.columnNames,rowNumber:++F,row:A},I.xfer)}}try{let A=U.countChanges?E.changes(!0,U.countChanges===64):void 0;if(E.exec(U),A!==void 0)U.changeCount=E.changes(!0,U.countChanges===64)-A;let N=U.lastInsertRowId?a.capi.sqlite3_last_insert_rowid(E):void 0;if(N!==void 0)U.lastInsertRowId=N;if(U.callback instanceof Function)U.callback=g,I.post({type:g,columnNames:U.columnNames,rowNumber:null,row:void 0})}finally{if(delete E._blobXfer,U.callback)U.callback=g}return U},"config-get":function(){let j=Object.create(null),U=a.config;return["bigIntEnabled"].forEach(function(E){if(Object.getOwnPropertyDescriptor(U,E))j[E]=U[E]}),j.version=a.version,j.vfsList=a.capi.sqlite3_js_vfs_list(),j},export:function(j){let U=R(j),E={byteArray:a.capi.sqlite3_js_db_export(U.pointer),filename:U.filename,mimetype:"application/x-sqlite3"};return I.xfer.push(E.byteArray.buffer),E},toss:function(j){r("Testing worker exception")}};globalThis.onmessage=async function(j){j=j.data;let U,E=j.dbId,g=j.type,F=performance.now();try{if(te.hasOwnProperty(g)&&te[g]instanceof Function)U=await te[g](j);else r("Unknown db worker message type:",j.type)}catch(x){if(g="error",U={operation:j.type,message:x.message,errorClass:x.name,input:j},x.stack)U.stack=typeof x.stack==="string"?x.stack.split(/\n\s*/):x.stack}if(!E)E=U.dbId||M();I.post({type:g,dbId:E,messageId:j.messageId,workerReceivedTime:F,workerRespondTime:performance.now(),departureTime:j.departureTime,result:U},I.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}.bind({sqlite3:i})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let{wasm:t,capi:r}=i,a=i.util.toss3,_=Object.create(null);i.vfs=_,r.sqlite3_vfs.prototype.registerVfs=function(h=!1){if(!(this instanceof i.capi.sqlite3_vfs))a("Expecting a sqlite3_vfs-type argument.");let I=r.sqlite3_vfs_register(this,h?1:0);if(I)a("sqlite3_vfs_register(",this,") failed with rc",I);if(this.pointer!==r.sqlite3_vfs_find(this.$zName))a("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this);return this},_.installVfs=function(h){let I=0,q=["io","vfs"];for(let R of q){let M=h[R];if(M){if(++I,M.struct.installMethods(M.methods,!!M.applyArgcCheck),R==="vfs"){if(!M.struct.$zName&&typeof M.name==="string")M.struct.addOnDispose(M.struct.$zName=t.allocCString(M.name));M.struct.registerVfs(!!M.asDefault)}}}if(!I)a("Misuse: installVfs() options object requires at least","one of:",q);return this}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.wasm.exports.sqlite3_declare_vtab)return;let{wasm:t,capi:r}=i,a=i.util.toss3,_=Object.create(null);i.vtab=_;let h=r.sqlite3_index_info;h.prototype.nthConstraint=function(R,M=!1){if(R<0||R>=this.$nConstraint)return!1;let p=t.ptr.add(this.$aConstraint,h.sqlite3_index_constraint.structInfo.sizeof*R);return M?p:new h.sqlite3_index_constraint(p)},h.prototype.nthConstraintUsage=function(R,M=!1){if(R<0||R>=this.$nConstraint)return!1;let p=t.ptr.add(this.$aConstraintUsage,h.sqlite3_index_constraint_usage.structInfo.sizeof*R);return M?p:new h.sqlite3_index_constraint_usage(p)},h.prototype.nthOrderBy=function(R,M=!1){if(R<0||R>=this.$nOrderBy)return!1;let p=t.ptr.add(this.$aOrderBy,h.sqlite3_index_orderby.structInfo.sizeof*R);return M?p:new h.sqlite3_index_orderby(p)};let I=function(R,M){return function(p,te=!1){if(arguments.length===0)p=new M;if(p instanceof M)return this.set(p.pointer,p),p;else if(!t.isPtr(p))i.SQLite3Error.toss("Invalid argument to",R+"()");let j=this.get(p);if(te)this.delete(p);return j}.bind(new Map)},q=function(R,M){let p=I(R,M);return Object.assign(Object.create(null),{StructType:M,create:(te)=>{let j=p();return t.pokePtr(te,j.pointer),j},get:(te)=>p(te),unget:(te)=>p(te,!0),dispose:(te)=>p(te,!0)?.dispose?.()})};_.xVtab=q("xVtab",r.sqlite3_vtab),_.xCursor=q("xCursor",r.sqlite3_vtab_cursor),_.xIndexInfo=(R)=>new r.sqlite3_index_info(R),_.xError=function R(M,p,te){if(R.errorReporter instanceof Function)try{R.errorReporter("sqlite3_module::"+M+"(): "+p.message)}catch(U){}let j;if(p instanceof i.WasmAllocError)j=r.SQLITE_NOMEM;else if(arguments.length>2)j=te;else if(p instanceof i.SQLite3Error)j=p.resultCode;return j||r.SQLITE_ERROR},_.xError.errorReporter=i.config.error.bind(i.config),_.xRowid=(R,M)=>t.poke(R,M,"i64"),_.setupModule=function(R){let M=!1,p=this instanceof r.sqlite3_module?this:R.struct||(M=new r.sqlite3_module);try{let te=R.methods||a("Missing 'methods' object.");for(let j of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){let U=j[0],E=j[1];if(te[U]===!0)te[U]=te[E];else if(te[E]===!0)te[E]=te[U]}if(R.catchExceptions){let j=function(g,F){if(["xConnect","xCreate"].indexOf(g)>=0)return function(x,A,N,z,f,S){try{return F(...arguments)||0}catch(D){if(!(D instanceof i.WasmAllocError))t.dealloc(t.peekPtr(S)),t.pokePtr(S,t.allocCString(D.message));return _.xError(g,D)}};else return function(...x){try{return F(...x)||0}catch(A){return _.xError(g,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"],E=Object.create(null);for(let g of U){let F=te[g];if(!(F instanceof Function))continue;else if(g==="xConnect"&&te.xCreate===F)E[g]=te.xCreate;else if(g==="xCreate"&&te.xConnect===F)E[g]=te.xConnect;else E[g]=j(g,F)}p.installMethods(E,!1)}else p.installMethods(te,!!R.applyArgcCheck);if(p.$iVersion===0){let j;if(typeof R.iVersion==="number")j=R.iVersion;else if(p.$xIntegrity)j=4;else if(p.$xShadowName)j=3;else if(p.$xSavePoint||p.$xRelease||p.$xRollbackTo)j=2;else j=1;p.$iVersion=j}}catch(te){if(M)M.dispose();throw te}return p},r.sqlite3_module.prototype.setupModule=function(R){return _.setupModule.call(this,R)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.kvvfs)return;let t=i.capi,{sqlite3_kvvfs_methods:r,KVVfsFile:a}=t,_=i.capi.sqlite3_vfs_find("kvvfs");if(delete t.sqlite3_kvvfs_methods,delete t.KVVfsFile,!_)return;let{util:h,wasm:I}=i,q=h.toss3,R=(T,W)=>Object.prototype.hasOwnProperty.call(T,W),M=new r(I.exports.sqlite3__wasm_kvvfs_methods());h.assert(32<=M.$nKeySize,"unexpected kvvfsMethods.$nKeySize: "+M.$nKeySize);let p=Object.assign(Object.create(null),{rxJournalSuffix:/-journal$/,zKeyJrnl:I.allocCString("jrnl"),zKeySz:I.allocCString("sz"),keySize:M.$nKeySize,buffer:Object.assign(Object.create(null),{n:M.$nBufferSize,pool:Object.create(null)})});p.memBuffer=(T=0)=>p.buffer.pool[T]??=I.alloc(p.buffer.n),p.memBufferFree=(T)=>{let W=p.buffer.pool[T];if(W)I.dealloc(W),delete p.buffer.pool[T]};let te=()=>{},j=i.__isUnderTest?(...T)=>i.config.debug?.("kvvfs:",...T):te,U=(...T)=>i.config.warn?.("kvvfs:",...T),E=(...T)=>i.config.error?.("kvvfs:",...T);class g{#e=Object.create(null);#i=null;#s=0;constructor(){this.clear()}#t(){return this.#i??=Object.keys(this.#e)}key(T){if(T<0||T>=this.#s)return null;return this.#t()[T]}getItem(T){return this.#e[T]??null}setItem(T,W){if(!(T in this.#e))++this.#s,this.#i=null;this.#e[T]=""+W}removeItem(T){if(T in this.#e)delete this.#e[T],--this.#s,this.#i=null}clear(){this.#e=Object.create(null),this.#i=null,this.#s=0}get length(){return this.#s}}let F=(T)=>T==="local"||T==="session",x=(T)=>F(T)?"kvvfs-"+T+"-":"",A=function(T,W=!1){if(F(T))return;let Q=new Blob([T]).size;if(!Q)q(t.SQLITE_MISUSE,"Empty name is not permitted.");let H=p.keySize-1;if(p.rxJournalSuffix.test(T)){if(!W)q(t.SQLITE_MISUSE,"Storage names may not have a '-journal' suffix.")}else if(["-wal","-shm"].filter((_e)=>T.endsWith(_e)).length)q(t.SQLITE_MISUSE,"Storage names may not have a -wal or -shm suffix.");else H-=8;if(Q>H)q(t.SQLITE_RANGE,"Storage name is too long. Limit =",H);let se;for(se=0;se<Q;++se){let _e=T.codePointAt(se);if(_e<32)q(t.SQLITE_RANGE,"Illegal character ("+_e+"d) in storage name:",T)}},N=(T,W=void 0)=>Object.assign(Object.create(null),{jzClass:T,refc:1,deleteAtRefc0:!1,storage:W||new g,keyPrefix:x(T),files:[],listeners:void 0}),z=i.kvvfs=Object.create(null);if(i.__isUnderTest)z.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});let f=function(T){let W=p.rxJournalSuffix.test(T.jzClass)?T.jzClass.replace(p.rxJournalSuffix,""):T.jzClass+"-journal";if(z?.log?.xClose&&j("cleaning up storage handles [",T.jzClass,W,"]",T),delete p.storagePool[T.jzClass],delete p.storagePool[W],!i.__isUnderTest)delete T.storage,delete T.refc},S=(T)=>p.storagePool[T.jzClass]=p.storagePool[T.jzClass+"-journal"]=T,D=".";if(p.storagePool=Object.assign(Object.create(null),{[D]:N(D)}),globalThis.Storage){if(globalThis.localStorage instanceof globalThis.Storage)p.storagePool.local=N("local",globalThis.localStorage);if(globalThis.sessionStorage instanceof globalThis.Storage)p.storagePool.session=N("session",globalThis.sessionStorage)}p.builtinStorageNames=Object.keys(p.storagePool);let J=(T)=>p.builtinStorageNames.indexOf(T)>-1;for(let T of Object.keys(p.storagePool)){let W=p.storagePool[T];p.storagePool[T+"-journal"]=W}p.setError=(T=void 0,W=t.SQLITE_ERROR)=>{if(T)return p.lastError=T,T.resultCode|0||W;return delete p.lastError,0},p.popError=()=>{let T=p.lastError;return delete p.lastError,T};let ie=(T)=>{U("kvvfs.listener handler threw:",T)},le=I.exports.sqlite3__wasm_kvvfs_decode,Se=I.exports.sqlite3__wasm_kvvfs_encode,me=async function(T,W,...Q){try{if(W.keyPrefix&&Q[0])Q[0]=Q[0].replace(W.keyPrefix,"");let H,se,_e,de;for(let ue of W.listeners){let pe=Object.create(null);pe.storageName=W.jzClass,pe.type=T;let Le=ue.decodePages,Ce=ue.events[T];if(Ce){if(!ue.includeJournal&&Q[0]==="jrnl")continue;if(T==="write"&&ue.decodePages&&+Q[0]>0){if(pe.data=[Q[0]],de?.[Q[0]]){pe.data[1]=de[Q[0]];continue}H??=new TextEncoder("utf-8"),se??=p.memBuffer(10),_e??=p.memBuffer(11);let Ae=H.encode(Q[1]),Ne=I.heap8u();Ne.set(Ae,Number(se)),Ne[I.ptr.addn(se,Ae.length)]=0;let Re=le(se,_e,p.buffer.n);if(Re>0)de??=Object.create(null),de[Q[0]]=pe.data[1]=Ne.slice(Number(_e),I.ptr.addn(_e,Re));else continue}else pe.data=Q.length?Q.length===1?Q[0]:Q:void 0;try{Ce(pe)?.catch?.(ie)}catch(Ae){U("notifyListeners [",W.jzClass,"]",T,Ae)}}}}catch(H){ie(H)}},K=(T)=>typeof T==="string"?p.storagePool[T]:p.storagePool[I.cstrToJs(T)],oe=I.exports.sqlite3__wasm_kvvfsMakeKey,u=(T,W,Q)=>W&&T.keyPrefix?oe(W,Q):Q,y=(T,W,Q)=>I.cstrToJs(u(T,W,Q)),O=(T)=>+T.storage.getItem(T.keyPrefix+"sz"),V=new Map,Y=new Map,m=function(T,W){if(T.lockType<=W)return;let Q=Y.get(T.jzClass);if(T.lockType>t.SQLITE_LOCK_SHARED)Q.lockType=t.SQLITE_LOCK_SHARED;if(W===t.SQLITE_LOCK_NONE&&--Q.nShared===0)Y.delete(T.jzClass);T.lockType=W},b={vfs:Object.create(null),ioDb:Object.create(null),ioJrnl:Object.create(null)},C=(T)=>b[T.$isJournal?"ioJrnl":"ioDb"],c=new t.sqlite3_vfs(M.$pVfs),d=new t.sqlite3_io_methods(M.$pIoDb),L=new t.sqlite3_io_methods(M.$pIoJrnl),G=Object.create(null),B=Object.assign(Object.create(null),{pFileHandles:V,cache:p,storageForZClass:K,KVVfsStorage:g,disablePageSizeChange:!0});if(z.log)z.internal=B;let ae={recordHandler:{xRcrdRead:(T,W,Q,H)=>{try{let se=I.cstrToJs(T),_e=K(se);if(!_e)return-1;let de=y(_e,T,W);z?.log?.xRcrdRead&&U("xRcrdRead",se,de,H,_e);let ue=_e.storage.getItem(de);if(ue===null)return-1;let pe=ue.length;if(H<=0)return pe;else if(H===1)return I.poke(Q,0),pe;else if(H<pe)q(t.SQLITE_RANGE,"xRcrdRead()",se,de,"input buffer is too small: need",pe,"but have",H);else if(H>pe+1)H=pe+1;let Le=pe<H?pe:H-1,Ce=I.heap8();for(let Ae=0;Ae<Le;++Ae)Ce[I.ptr.add(Q,Ae)]=ue.codePointAt(Ae)&255;return Ce[I.ptr.add(Q,Le)]=0,Le}catch(se){return E("kvrecordRead()",se),p.setError(se),-2}},xRcrdWrite:(T,W,Q)=>{try{let H=K(T),se=y(H,T,W),_e=I.cstrToJs(Q);return z?.log?.xRcrdWrite&&U("xRcrdWrite",se,H),H.storage.setItem(se,_e),H.listeners&&me("write",H,se,_e),0}catch(H){return E("kvrecordWrite()",H),p.setError(H,t.SQLITE_IOERR)}},xRcrdDelete:(T,W)=>{try{let Q=K(T),H=y(Q,T,W);return z?.log?.xRcrdDelete&&U("xRcrdDelete",H,Q),Q.storage.removeItem(H),Q.listeners&&me("delete",Q,H),0}catch(Q){return E("kvrecordDelete()",Q),p.setError(Q,t.SQLITE_IOERR)}}},vfs:{xOpen:function(T,W,Q,H,se){p.popError();let _e;try{if(!W)_e=I.allocCString(""+Q+"."+(Math.random()*1e5|0)),W=_e;let de=I.cstrToJs(W);if(z?.log?.xOpen&&j("xOpen",de,"flags =",H),A(de,!0),H&(t.SQLITE_OPEN_MAIN_DB|t.SQLITE_OPEN_TEMP_DB|t.SQLITE_OPEN_TRANSIENT_DB)&&p.rxJournalSuffix.test(de))q(t.SQLITE_ERROR,"DB files may not have a '-journal' suffix.");let ue=K(de);if(!ue&&!(H&t.SQLITE_OPEN_CREATE))q(t.SQLITE_ERROR,"Storage not found:",de);let pe=b.vfs.xOpen(T,W,Q,H,se);if(pe)return pe;let Le=!!(t.SQLITE_OPEN_DELETEONCLOSE&H);if(I.isPtr(arguments[1])){if(t.sqlite3_uri_boolean(W,"delete-on-close",0))Le=!0}let Ce=new a(Q);if(h.assert(Ce.$zClass,"Missing f.$zClass"),Ce.addOnDispose(_e),_e=void 0,ue)++ue.refc,ue.files.push(Ce),I.poke32(se,H);else{I.poke32(se,H|t.SQLITE_OPEN_CREATE),h.assert(!Ce.$isJournal,"Opening a journal before its db? "+de);let Ae=de.replace(p.rxJournalSuffix,"");ue=N(Ae),S(ue),ue.files.push(Ce),ue.deleteAtRefc0=Le,z?.log?.xOpen&&j("xOpen installed storage handle [",Ae,Ae+"-journal","]",ue)}return V.set(Q,Object.assign(Object.create(null),{store:ue,file:Ce,jzClass:de,lockType:0})),ue.listeners&&me("open",ue,ue.files.length),0}catch(de){return U("xOpen:",de),p.setError(de)}finally{_e&&I.dealloc(_e)}},xDelete:function(T,W,Q){p.popError();try{let H=I.cstrToJs(W);if(p.rxJournalSuffix.test(H))G.xRcrdDelete(W,p.zKeyJrnl);return 0}catch(H){return U("xDelete",H),p.setError(H)}},xAccess:function(T,W,Q,H){p.popError();try{let se=K(W),_e=se?.jzClass||I.cstrToJs(W);if(z?.log?.xAccess)j("xAccess",_e,"flags =",Q,"*pResOut =",I.peek32(H),"store =",se);if(!se)try{A(_e)}catch(de){return I.poke32(H,0),0}if(se){let de=se.keyPrefix+(p.rxJournalSuffix.test(_e)?"jrnl":"1"),ue=se.storage.getItem(de)?0:1;I.poke32(H,ue)}else I.poke32(H,0);return 0}catch(se){return E("xAccess",se),p.setError(se)}},xRandomness:function(T,W,Q){let H=I.heap8u(),se=0,_e=Number(Q);for(;se<W;++se)H[_e+se]=Math.random()*255000&255;return W},xGetLastError:function(T,W,Q){let H=p.popError();if(j("xGetLastError",H),H){let se=I.scopedAllocPush();try{let[_e,de]=I.scopedAllocCString(H.message,!0);if(I.cstrncpy(Q,_e,W),de>W)I.poke8(I.ptr.add(Q,W,-1),0);return j("set xGetLastError",H.message),H.resultCode|0||t.SQLITE_IOERR}catch(_e){return t.SQLITE_NOMEM}finally{I.scopedAllocPop(se)}}return 0},xSleep:(T,W)=>0},ioDb:{xClose:function(T){p.popError();try{let W=V.get(T);if(z?.log?.xClose&&j("xClose",T,W),W){V.delete(T),m(W,t.SQLITE_LOCK_NONE);let Q=W.store;if(Q.files=Q.files.filter((H)=>H!==W.file),--Q.refc<=0&&Q.deleteAtRefc0)f(Q);b.ioDb.xClose(T),W.file.dispose(),Q.listeners&&me("close",Q,Q.files.length)}return 0}catch(W){return E("xClose",W),p.setError(W)}},xFileControl:function(T,W,Q){p.popError();try{let H=V.get(T);if(h.assert(H,"Missing KVVfsFile handle"),z?.log?.xFileControl&&j("xFileControl",H,"op =",W),W===t.SQLITE_FCNTL_PRAGMA&&B.disablePageSizeChange){let _e=I.peekPtr(I.ptr.add(Q,I.ptr.size));if(I.cstrToJs(_e)==="page_size"){z?.log?.xFileControl&&j("xFileControl pragma",I.cstrToJs(_e));let de=I.peekPtr(I.ptr.add(Q,2*I.ptr.size));if(de)return z?.log?.xFileControl&&U("xFileControl pragma",H,"NOT setting page size to",I.cstrToJs(de)),H.file.$szPage=-1,0;else if(H.file.$szPage>0)return z?.log?.xFileControl&&U("xFileControl",H,"getting page size",H.file.$szPage),I.pokePtr(Q,I.allocCString(""+H.file.$szPage)),0}}let se=b.ioDb.xFileControl(T,W,Q);if(se==0&&t.SQLITE_FCNTL_SYNC===W)H.store.listeners&&me("sync",H.store,!1);return se}catch(H){return E("xFileControl",H),p.setError(H)}},xSync:function(T,W){p.popError();try{let Q=V.get(T);z?.log?.xSync&&j("xSync",Q),h.assert(Q,"Missing KVVfsFile handle");let H=b.ioDb.xSync(T,W);if(H==0&&Q.store.listeners)me("sync",Q.store,!0);return H}catch(Q){return E("xSync",Q),p.setError(Q)}},xLock:function(T,W){p.popError();try{let Q=V.get(T);if(t.SQLITE_LOCK_NONE!==W)b.ioDb.xLock(T,W);if(Q.lockType>=W)return 0;let H=Y.get(Q.jzClass);if(!H)H=Object.assign(Object.create(null),{nShared:0,lockType:t.SQLITE_LOCK_NONE}),Y.set(Q.jzClass,H);if(Q.lockType!==H.lockType&&(H.lockType>=t.SQLITE_LOCK_PENDING||W>t.SQLITE_LOCK_SHARED))return t.SQLITE_BUSY;if(W===t.SQLITE_LOCK_SHARED){if(++H.nShared,H.lockType===t.SQLITE_LOCK_NONE)H.lockType=W}else if(W===t.SQLITE_LOCK_EXCLUSIVE&&H.nShared>1){if(Q.lockType===t.SQLITE_LOCK_RESERVED)Q.lockType=H.lockType=t.SQLITE_LOCK_PENDING;return t.SQLITE_BUSY}else H.lockType=W;return Q.lockType=W,0}catch(Q){return E("xLock",Q),p.setError(Q)}},xUnlock:function(T,W){p.popError();try{if(t.SQLITE_LOCK_NONE===W)b.ioDb.xUnlock(T,W);let Q=V.get(T);return m(Q,W),0}catch(Q){return E("xUnlock",Q),p.setError(Q)}},xCheckReservedLock:function(T,W){p.popError();try{let Q=V.get(T),H=Y.get(Q.jzClass);return I.poke32(W,!!H&&H.lockType>t.SQLITE_LOCK_SHARED?1:0),0}catch(Q){return E("xCheckReservedLock",Q),p.setError(Q)}}},ioJrnl:{xClose:!0,xLock:!0,xUnlock:!0,xCheckReservedLock:!0}};try{h.assert(p.buffer.n>132096,"Heap buffer is not large enough");for(let T of Object.entries(ae.recordHandler)){let W=T[0],Q=T[1];G[W]=Q,M[M.memberKey(W)]=I.installFunction(M.memberSignature(W),Q)}for(let T of Object.entries(ae.vfs)){let W=T[0],Q=T[1],H=c.memberKey(W),se=c.structInfo.members[W]||h.toss("Missing pVfs.structInfo[",W,"]");b.vfs[W]=I.functionEntry(c[H]),c[H]=I.installFunction(se.signature,Q)}for(let T of Object.entries(ae.ioDb)){let W=T[0],Q=T[1],H=d.memberKey(W);b.ioDb[W]=I.functionEntry(d[H])||h.toss("Missing native pIoDb[",H,"]"),d[H]=I.installFunction(d.memberSignature(W),Q)}for(let T of Object.entries(ae.ioJrnl)){let W=T[0],Q=T[1],H=L.memberKey(W);if(b.ioJrnl[W]=I.functionEntry(L[H])||h.toss("Missing native pIoJrnl[",H,"]"),Q===!0)L[H]=d[H]||h.toss("Missing copied pIoDb[",H,"]");else L[H]=I.installFunction(L.memberSignature(W),Q)}}finally{M.dispose(),c.dispose(),d.dispose(),L.dispose()}let ce=function T(W){if(W==="")return T("local")+T("session");let Q=K(W);if(!Q)return 0;if(Q.files.length)if(globalThis.localStorage===Q.storage||globalThis.sessionStorage===Q.storage);else q(t.SQLITE_ACCESS,"Cannot clear in-use database storage.");let H=Q.storage,se=[],_e,de=H.length;for(_e=0;_e<de;++_e){let ue=H.key(_e);if(!Q.keyPrefix||ue.startsWith(Q.keyPrefix))se.push(ue)}return se.forEach((ue)=>H.removeItem(ue)),se.length},ge=function T(W){if(W==="")return T("local")+T("session");let Q=K(W);if(!Q)return 0;let H=Q.storage,se,_e=0;for(se=0;se<H.length;++se){let de=H.key(se);if(!Q.keyPrefix||de.startsWith(Q.keyPrefix))_e+=de.length,_e+=H.getItem(de).length}return _e*2},qe=function(...W){let Q;if(W.length===1&&typeof W[0]==="object")Q=W[0];else if(W.length)Q=Object.assign(Object.create(null),{name:W[0]});let H=Q?K(Q.name):null;if(!H)q(t.SQLITE_NOTFOUND,"There is no kvvfs storage named",Q?.name);let se=H.storage,_e=Object.assign(Object.create(null),{name:H.jzClass,timestamp:Date.now(),pages:[]}),de=Object.create(null),ue,pe=H.keyPrefix,Le=pe?/^kvvfs-[^-]+-(\w+)/:void 0,Ce=0,Ae=se.length;for(;Ce<Ae;++Ce){let Ne=se.key(Ce);if(!pe||Ne.startsWith(pe)){let Re=(pe?Le.exec(Ne):void 0)?.[1]??Ne;switch(Re){case"jrnl":if(Q.includeJournal)_e.journal=se.getItem(Ne);break;case"sz":_e.size=+se.getItem(Ne);break;default:if(Re=+Re,!h.isInt32(Re)||Re<=0)q(t.SQLITE_RANGE,"Malformed kvvfs key: "+Ne);if(Q.decodePages){let tt=se.getItem(Ne),st=tt.length,Je=p.memBuffer(0),mt=p.memBuffer(1),gt=I.heap8u(),_t=0;for(;_t<st;++_t)gt[I.ptr.add(Je,_t)]=tt.codePointAt(_t)&255;gt[I.ptr.add(Je,_t)]=0;let Mt=le(Je,mt,p.buffer.n);de[Re]=gt.slice(Number(mt),I.ptr.addn(mt,Mt))}else de[Re]=se.getItem(Ne);break}}}if(Q.decodePages)p.memBufferFree(1);return Object.keys(de).map((Ne)=>+Ne).sort().forEach((Ne)=>_e.pages.push(de[Ne])),_e},Fe=function(T,W=!1){if(!T?.timestamp||!T.name||T.size===void 0||!Array.isArray(T.pages))q(t.SQLITE_MISUSE,"Malformed export object.");else if(!T.size||T.size!==(T.size|0)||T.size>=2147483647)q(t.SQLITE_RANGE,"Invalid db size: "+T.size);A(T.name);let Q=K(T.name),H=!Q;if(Q){if(!W)q(t.SQLITE_ACCESS,"Storage '"+T.name+"' already exists and","overwrite was not specified.");else if(!Q.files||!Q.jzClass)q(t.SQLITE_ERROR,"Internal storage object",T.name,"seems to be malformed.");else if(Q.files.length)q(t.SQLITE_IOERR_ACCESS,"Cannot import db storage while it is in use.");ce(T.name)}else Q=N(T.name);let se=x(T.name),_e;try{let de=Q.storage;if(de.setItem(se+"sz",T.size),T.journal)de.setItem(se+"jrnl",T.journal);if(T.pages[0]instanceof Uint8Array)T.pages.forEach((ue,pe)=>{let Le=ue.length;_e??=p.memBuffer(1);let Ce=p.memBuffer(0),Ae=I.heap8u();Ae.set(ue,Number(Ce)),Ae[I.ptr.addn(Ce,Le)]=0;let Ne=Se(Ce,Le,_e);h.assert(Ne<p.buffer.n,"Impossibly long output - possibly smashed the heap"),h.assert(I.peek8(I.ptr.add(_e,Ne))===0,"Expecting NUL-terminated encoded output");let Re=I.cstrToJs(_e);de.setItem(se+(pe+1),Re)});else if(T.pages[0])T.pages.forEach((ue,pe)=>de.setItem(se+(pe+1),ue));if(H)S(Q)}catch{if(!H)try{ce(T.name)}catch(de){}}finally{if(_e)p.memBufferFree(1)}return this},Pe=function(T){let W=K(T);if(W){++W.refc;return}A(T),S(N(T))},Ee=function(T){let W=K(T);if(!W||F(W.jzClass)||J(W.jzClass)||p.rxJournalSuffix.test(T))return!1;if(W.refc>W.files.length||W.files.length===0){if(--W.refc<=0)f(W);return!0}return!1},Ue=function(T){if(!T||typeof T!=="object")q(t.SQLITE_MISUSE,"Expecting a listener object.");let W=K(T.storage);if(!W)if(T.storage&&T.reserve)Pe(T.storage),W=K(T.storage),h.assert(W,"Unexpectedly cannot fetch reserved storage "+T.storage);else q(t.SQLITE_NOTFOUND,"No such storage:",T.storage);if(T.events)(W.listeners??=[]).push(T)},He=function(T){let W=K(T?.storage);if(W?.listeners&&T.events){let Q=W.listeners.length;W.listeners=W.listeners.filter((se)=>se!==T);let H=Q>W.listeners.length;if(!W.listeners.length)W.listeners=void 0;return H}return!1};if(i.kvvfs.reserve=Pe,i.kvvfs.import=Fe,i.kvvfs.export=qe,i.kvvfs.unlink=Ee,i.kvvfs.listen=Ue,i.kvvfs.unlisten=He,i.kvvfs.exists=(T)=>!!K(T),i.kvvfs.estimateSize=ge,i.kvvfs.clear=ce,globalThis.Storage)t.sqlite3_js_kvvfs_size=(T="")=>ge(T),t.sqlite3_js_kvvfs_clear=(T="")=>ce(T);if(i.oo1?.DB){let T=i.oo1.DB;i.oo1.JsStorageDb=function(Q=i.oo1.JsStorageDb.defaultStorageName){let H=T.dbCtorHelper.normalizeArgs(...arguments);switch(H.vfs="kvvfs",H.filename){case":sessionStorage:":H.filename="session";break;case":localStorage:":H.filename="local";break}let se=/(file:(\/\/)?)([^?]+)/.exec(H.filename);A(se?se[3]:H.filename),T.dbCtorHelper.call(this,H)},i.oo1.JsStorageDb.defaultStorageName=p.storagePool.session?"session":D;let W=i.oo1.JsStorageDb;W.prototype=Object.create(T.prototype),W.clearStorage=ce,W.prototype.clearStorage=function(){return W.clearStorage(this.affirmOpen().dbFilename(),!0)},W.storageSize=ge,W.prototype.storageSize=function(){return W.storageSize(this.affirmOpen().dbFilename(),!0)}}if(i.__isUnderTest&&i.vtab){let T=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(T).forEach((de,ue)=>T[de].colId=ue);let W=i.vtab,Q=Object.assign(Object.create(null),{row:function(){return p.storagePool[this.names[this.rowid]]}});Object.assign(Object.create(Q),{rowid:0,names:Object.keys(p.storagePool).filter((de)=>!p.rxJournalSuffix.test(de))});let H=function(de,ue){let pe=de instanceof t.sqlite3_vtab_cursor?de:W.xCursor.get(de);if(ue||!pe.vTabState)pe.vTabState=Object.assign(Object.create(Q),{rowid:0,names:Object.keys(p.storagePool).filter((Le)=>!p.rxJournalSuffix.test(Le))});return pe.vTabState},se=()=>{},_e=function de(){return de.mod??=new i.capi.sqlite3_module().setupModule({catchExceptions:!0,methods:{xConnect:function(ue,pe,Le,Ce,Ae,Ne){se("xConnect");try{let Re=[];Object.keys(T).forEach((st)=>{Re.push(st+" "+T[st].type)});let tt=t.sqlite3_declare_vtab(ue,"CREATE TABLE ignored("+Re.join(",")+")");if(tt===0){let st=W.xVtab.create(Ae);h.assert(st===W.xVtab.get(I.peekPtr(Ae)),"output pointer check failed")}return tt}catch(Re){return W.xError("xConnect",Re,t.SQLITE_ERROR)}},xCreate:I.ptr.null,xDisconnect:function(ue){return se("xDisconnect",...arguments),W.xVtab.dispose(ue),0},xOpen:function(ue,pe){return se("xOpen",...arguments),W.xCursor.create(pe),0},xClose:function(ue){se("xClose",...arguments);let pe=W.xCursor.unget(ue);return delete pe.vTabState,pe.dispose(),0},xNext:function(ue){se("xNext",...arguments);let pe=W.xCursor.get(ue);return++H(pe).rowid,0},xColumn:function(ue,pe,Le){se("xColumn",...arguments);let Ce=H(ue),Ae=Ce.row();switch(h.assert(Ae,"Unexpected xColumn call"),Le){case T.rowid.colId:t.sqlite3_result_int(pe,Ce.rowid);break;case T.name.colId:t.sqlite3_result_text(pe,Ae.jzClass,-1,t.SQLITE_TRANSIENT);break;case T.nRef.colId:t.sqlite3_result_int(pe,Ae.refc);break;case T.nOpen.colId:t.sqlite3_result_int(pe,Ae.files.length);break;case T.isTransient.colId:t.sqlite3_result_int(pe,!!Ae.deleteAtRefc0);break;case T.dbSize.colId:t.sqlite3_result_int(pe,O(Ae));break;default:return t.sqlite3_result_error(pe,"Invalid column id: "+Le),t.SQLITE_RANGE}return 0},xRowid:function(ue,pe){se("xRowid",...arguments);let Le=H(ue);return W.xRowid(pe,Le.rowid),0},xEof:function(ue){let pe=H(ue);return se("xEof?="+!pe.row(),...arguments),!pe.row()},xFilter:function(ue,pe,Le,Ce,Ae){se("xFilter",...arguments);let Ne=H(ue,!0);return 0},xBestIndex:function(ue,pe){se("xBestIndex",...arguments);let Le=new t.sqlite3_index_info(pe);return Le.$estimatedRows=p.storagePool.size,Le.$estimatedCost=1,Le.dispose(),0}}})};i.kvvfs.create_module=function(de,ue="sqlite_kvvfs"){return t.sqlite3_create_module(de,ue,_e(),I.ptr.null)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.opfs&&i.config.disable.vfs["opfs-vfs"])return;let t=i.util.toss,{capi:r,util:a,wasm:_}=i,h=i.opfs=Object.create(null);h.thisThreadHasOPFS=()=>globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory,h.getRootDir=async function q(){return q.promise??=navigator.storage.getDirectory().then((R)=>(h.rootDirectory=R,R)).catch((R)=>{throw delete q.promise,R})},h.getResolvedPath=function(q,R){let M=new URL(q,"file://irrelevant").pathname;return R?M.split("/").filter((p)=>!!p):M},h.getDirForFilename=async function(R,M=!1){let p=h.getResolvedPath(R,!0),te=p.pop(),j=await h.getRootDir();for(let U of p)if(U)j=await j.getDirectoryHandle(U,{create:!!M});return[j,te]},h.mkdir=async function(q){try{return await h.getDirForFilename(q+"/filepart",!0),!0}catch(R){return!1}},h.entryExists=async function(q){try{let[R,M]=await h.getDirForFilename(q);return await R.getFileHandle(M),!0}catch(R){return!1}},h.randomFilename=function q(R=16){if(!q._chars)q._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789",q._n=q._chars.length;let M=[],p=0;for(;p<R;++p){let te=Math.random()*(q._n*64)%q._n|0;M[p]=q._chars[te]}return M.join("")},h.treeList=async function(){let q=async function p(te,j){j.name=te.name,j.dirs=[],j.files=[];for await(let U of te.values())if(U.kind==="directory"){let E=Object.create(null);j.dirs.push(E),await p(U,E)}else j.files.push(U.name)},R=Object.create(null),M=await h.getRootDir();return await q(M,R),R},h.rmfr=async function(){let R=await h.getRootDir(),M={recurse:!0};for await(let p of R.values())R.removeEntry(p.name,M)},h.unlink=async function(q,R=!1,M=!1){try{let[p,te]=await h.getDirForFilename(q,!1);return await p.removeEntry(te,{recursive:R}),!0}catch(p){if(M)throw Error("unlink(",arguments[0],") failed: "+p.message,{cause:p});return!1}},h.traverse=async function(q){let R={recursive:!0,directory:await h.getRootDir()};if(typeof q==="function")q={callback:q};q=Object.assign(R,q||{}),async function p(te,j){for await(let U of te.values())if(q.callback(U,te,j)===!1)return!1;else if(q.recursive&&U.kind==="directory"){if(await p(U,j+1)===!1)break}}(q.directory,0)};let I=async function(q,R){let[M,p]=await h.getDirForFilename(q,!0),j=await(await M.getFileHandle(p,{create:!0})).createSyncAccessHandle(),U=0,E,g=!1,F=!1;try{j.truncate(0);while((E=await R())!==void 0){if(E instanceof ArrayBuffer)E=new Uint8Array(E);if(!g&&U===0&&E.byteLength>=15)a.affirmDbHeader(E),g=!0;j.write(E,{at:U}),U+=E.byteLength}if(U<512||U%512!==0)t("Input size",U,"is not correct for an SQLite database.");if(!g){let x=new Uint8Array(20);j.read(x,{at:0}),a.affirmDbHeader(x)}return j.write(new Uint8Array([1,1]),{at:18}),U}catch(x){throw await j.close(),j=void 0,await M.removeEntry(p).catch(()=>{}),x}finally{if(j)await j.close()}};h.importDb=async function(q,R){if(R instanceof Function)return I(q,R);if(R instanceof ArrayBuffer)R=new Uint8Array(R);a.affirmIsDb(R);let M=R.byteLength,[p,te]=await h.getDirForFilename(q,!0),j,U,E=0;try{if(j=await(await p.getFileHandle(te,{create:!0})).createSyncAccessHandle(),j.truncate(0),E=j.write(R,{at:0}),E!=M)t("Expected to write "+M+" bytes but wrote "+E+".");return j.write(new Uint8Array([1,1]),{at:18}),E}catch(g){if(j)await j.close(),j=void 0;throw await p.removeEntry(te).catch(()=>{}),g}finally{if(j)await j.close()}},h.vfsInstallationFeatureCheck=function(q){if(!globalThis.SharedArrayBuffer||!globalThis.Atomics)t("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");else if(typeof WorkerGlobalScope>"u")t("The OPFS sqlite3_vfs cannot run in the main thread","because it requires Atomics.wait().");else if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle?.prototype?.createSyncAccessHandle||!navigator?.storage?.getDirectory)t("Missing required OPFS APIs.");else if(q==="opfs-wl"&&!globalThis.Atomics.waitAsync)t("The",q,"VFS requires Atomics.waitAsync(), which is not available.")},h.initOptions=function(R,M){let p=new URL(globalThis.location.href).searchParams;if(p.has(R+"-disable"))return;try{h.vfsInstallationFeatureCheck(R)}catch(te){return}if(M=a.nu(M),M.vfsName=R,M.verbose??=p.has("opfs-verbose")?+p.get("opfs-verbose"):1,M.sanityChecks??=p.has("opfs-sanity-check"),!h.proxyUri){if(h.proxyUri="sqlite3-opfs-async-proxy.js",i.scriptInfo?.sqlite3Dir)h.proxyUri=i.scriptInfo.sqlite3Dir+h.proxyUri}if(M.proxyUri??=h.proxyUri,typeof M.proxyUri==="function")M.proxyUri=M.proxyUri();return h.options=M},h.createVfsState=function(){let q=a.nu(),R=h.options;q.verbose=R.verbose;let M=[i.config.error,i.config.warn,i.config.log],p=R.vfsName||t("Maintenance required: missing VFS name"),te=(K,...oe)=>{if(q.verbose>K)M[K](p+":",...oe)},j=(...K)=>te(2,...K),U=(...K)=>te(1,...K),E=(...K)=>te(0,...K),{capi:g,wasm:F}=i,x=q.vfs=new g.sqlite3_vfs,A=x.ioMethods=new g.sqlite3_io_methods;A.$iVersion=1,x.$iVersion=2,x.$szOsFile=g.sqlite3_file.structInfo.sizeof,x.$mxPathname=1024,x.$zName=F.allocCString(p),x.addOnDispose("$zName",x.$zName,A),x.metrics=a.nu({counters:a.nu(),dump:function(){let K,oe=0,u=0,y=0;for(K in q.opIds){let O=N[K];oe+=O.count,u+=O.time,y+=O.wait,O.avgTime=O.count&&O.time?O.time/O.count:0,O.avgWait=O.count&&O.wait?O.wait/O.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",N,`
|
|
3
|
-
Total of`,oe,"op(s) for",u,"ms (incl. "+y+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",x.metrics.counters.s11n),x.worker?.postMessage?.({type:"opfs-async-metrics"})},reset:function(){let K,oe=(O)=>O.count=O.time=O.wait=0,u=x.metrics.counters;for(K in q.opIds)oe(u[K]=Object.create(null));let y=u.s11n=Object.create(null);y=y.serialize=Object.create(null),y.count=y.time=0,y=u.s11n.deserialize=Object.create(null),y.count=y.time=0}}),q.asyncIdleWaitTime=150,q.asyncS11nExceptions=1,q.fileBufferSize=65536,q.sabS11nOffset=q.fileBufferSize,q.sabS11nSize=x.$mxPathname*2,q.sabIO=new SharedArrayBuffer(q.fileBufferSize+q.sabS11nSize),q.opIds=Object.create(null);{let K=0;q.opIds.whichOp=K++,q.opIds.rc=K++,q.opIds.xAccess=K++,q.opIds.xClose=K++,q.opIds.xDelete=K++,q.opIds.xDeleteNoWait=K++,q.opIds.xFileSize=K++,q.opIds.xLock=K++,q.opIds.xOpen=K++,q.opIds.xRead=K++,q.opIds.xSleep=K++,q.opIds.xSync=K++,q.opIds.xTruncate=K++,q.opIds.xUnlock=K++,q.opIds.xWrite=K++,q.opIds.mkdir=K++,q.opIds["opfs-async-metrics"]=K++,q.opIds["opfs-async-shutdown"]=K++,q.opIds.retry=K++,q.sabOP=new SharedArrayBuffer(K*4)}q.sq3Codes=Object.create(null);for(let K 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"])q.sq3Codes[K]=g[K]??t("Maintenance required: not found:",K);q.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1}),x.metrics.reset();let N=x.metrics.counters,z=x.opRun=(K,...oe)=>{let u=q.opIds[K]||t(x.vfsName+": Invalid op ID:",K);q.s11n.serialize(...oe),Atomics.store(q.sabOPView,q.opIds.rc,-1),Atomics.store(q.sabOPView,q.opIds.whichOp,u),Atomics.notify(q.sabOPView,q.opIds.whichOp);let y=performance.now();while(Atomics.wait(q.sabOPView,q.opIds.rc,-1)!=="not-equal");let O=Atomics.load(q.sabOPView,q.opIds.rc);if(N[K].wait+=performance.now()-y,O&&q.asyncS11nExceptions){let V=q.s11n.deserialize();if(V)E(K+"() async error:",...V)}return O},f=Object.create(null);f.op=void 0,f.start=void 0;let S=x.mTimeStart=(K)=>{f.start=performance.now(),f.op=K,++N[K].count},D=x.mTimeEnd=()=>N[f.op].time+=performance.now()-f.start,J=x.__openFiles=Object.create(null),ie=x.ioSyncWrappers=a.nu({xCheckReservedLock:function(K,oe){return F.poke(oe,0,"i32"),0},xClose:function(K){S("xClose");let oe=0,u=J[K];if(u){if(delete J[K],oe=z("xClose",K),u.sq3File)u.sq3File.dispose()}return D(),oe},xDeviceCharacteristics:function(K){return g.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(K,oe,u){return g.SQLITE_NOTFOUND},xFileSize:function(K,oe){S("xFileSize");let u=z("xFileSize",K);if(u==0)try{let y=q.s11n.deserialize()[0];F.poke(oe,y,"i64")}catch(y){E("Unexpected error reading xFileSize() result:",y),u=q.sq3Codes.SQLITE_IOERR}return D(),u},xRead:function(K,oe,u,y){S("xRead");let O=J[K],V;try{if(V=z("xRead",K,u,Number(y)),V===0||g.SQLITE_IOERR_SHORT_READ===V)F.heap8u().set(O.sabView.subarray(0,u),Number(oe))}catch(Y){E("xRead(",arguments,") failed:",Y,O),V=g.SQLITE_IOERR_READ}return D(),V},xSync:function(K,oe){S("xSync");let u=z("xSync",K,oe);return D(),u},xTruncate:function(K,oe){S("xTruncate");let u=z("xTruncate",K,Number(oe));return D(),u},xWrite:function(K,oe,u,y){S("xWrite");let O=J[K],V;try{O.sabView.set(F.heap8u().subarray(Number(oe),Number(oe)+u)),V=z("xWrite",K,u,Number(y))}catch(Y){E("xWrite(",arguments,") failed:",Y,O),V=g.SQLITE_IOERR_WRITE}return D(),V}}),le=x.vfsSyncWrappers={xAccess:function(K,oe,u,y){S("xAccess");let O=z("xAccess",F.cstrToJs(oe));return F.poke(y,O?0:1,"i32"),D(),0},xCurrentTime:function(K,oe){return F.poke(oe,2440587.5+new Date().getTime()/86400000,"double"),0},xCurrentTimeInt64:function(K,oe){return F.poke(oe,210866760000000+new Date().getTime(),"i64"),0},xDelete:function(K,oe,u){S("xDelete");let y=z("xDelete",F.cstrToJs(oe),u,!1);return D(),y},xFullPathname:function(K,oe,u,y){return F.cstrncpy(y,oe,u)<u?0:g.SQLITE_CANTOPEN},xGetLastError:function(K,oe,u){return i.config.warn("OPFS xGetLastError() has nothing sensible to return."),0},xOpen:function(oe,u,y,O,V){S("xOpen");let Y=0,m,b;if(!u)m=h.randomFilename(),u=b=F.allocCString(m);else if(F.isPtr(u)){if(g.sqlite3_uri_boolean(u,"opfs-unlock-asap",0))Y|=q.opfsFlags.OPFS_UNLOCK_ASAP;if(g.sqlite3_uri_boolean(u,"delete-before-open",0))Y|=q.opfsFlags.OPFS_UNLINK_BEFORE_OPEN;m=F.cstrToJs(u)}else return i.config.error("Impossible zName value in xOpen?",u),g.SQLITE_CANTOPEN;let C=a.nu({fid:y,filename:m,sab:new SharedArrayBuffer(q.fileBufferSize),flags:O,readOnly:!(g.SQLITE_OPEN_CREATE&O)&&!!(O&g.SQLITE_OPEN_READONLY)}),c=z("xOpen",y,m,O,Y);if(c){if(b)F.dealloc(b)}else{if(C.readOnly)F.poke(V,g.SQLITE_OPEN_READONLY,"i32");if(J[y]=C,C.sabView=q.sabFileBufView,C.sq3File=new g.sqlite3_file(y),b)C.sq3File.addOnDispose(b);C.sq3File.$pMethods=A.pointer,C.lockType=g.SQLITE_LOCK_NONE}return D(),c}},Se=g.sqlite3_vfs_find(null);if(Se){let K=new g.sqlite3_vfs(Se);x.$xRandomness=K.$xRandomness,x.$xSleep=K.$xSleep,K.dispose()}if(!x.$xRandomness)x.vfsSyncWrappers.xRandomness=function(K,oe,u){let y=F.heap8u(),O=0,V=Number(u);for(;O<oe;++O)y[V+O]=Math.random()*255000&255;return O};if(!x.$xSleep)x.vfsSyncWrappers.xSleep=function(K,oe){return S("xSleep"),Atomics.wait(q.sabOPView,q.opIds.xSleep,0,oe),D(),0};let me=function(){if(q.s11n)return q.s11n;let K=new TextDecoder,oe=new TextEncoder("utf-8"),u=new Uint8Array(q.sabIO,q.sabS11nOffset,q.sabS11nSize),y=new DataView(q.sabIO,q.sabS11nOffset,q.sabS11nSize);q.s11n=Object.create(null);let O=Object.create(null);O.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},O.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},O.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},O.string={id:4};let V=(m)=>O[typeof m]||t("Maintenance required: this value type cannot be serialized.",m),Y=(m)=>{switch(m){case O.number.id:return O.number;case O.bigint.id:return O.bigint;case O.boolean.id:return O.boolean;case O.string.id:return O.string;default:t("Invalid type ID:",m)}};return q.s11n.deserialize=function(m=!1){let b=performance.now(),C=u[0],c=C?[]:null;if(C){let d=[],L=1,G,B,ae;for(G=0;G<C;++G,++L)d.push(Y(u[L]));for(G=0;G<C;++G){let ce=d[G];if(ce.getter)ae=y[ce.getter](L,q.littleEndian),L+=ce.size;else B=y.getInt32(L,q.littleEndian),L+=4,ae=K.decode(u.slice(L,L+B)),L+=B;c.push(ae)}}if(m)u[0]=0;return c},q.s11n.serialize=function(...m){let b=performance.now();if(m.length){let C=[],c=0,d=1;u[0]=m.length&255;for(;c<m.length;++c,++d)C.push(V(m[c])),u[d]=C[c].id;for(c=0;c<m.length;++c){let L=C[c];if(L.setter)y[L.setter](d,m[c],q.littleEndian),d+=L.size;else{let G=oe.encode(m[c]);y.setInt32(d,G.byteLength,q.littleEndian),d+=4,u.set(G,d),d+=G.byteLength}}}else u[0]=0},q.s11n};return x.initS11n=me,x.bindVfs=function(K,oe){return Object.assign(x.ioSyncWrappers,K),new Promise(function(y,O){let V=void 0,Y=(B)=>(V=!0,x.dispose(),O(B)),m=()=>{try{oe(i,x)}catch(B){return Y(B)}return V=!1,y(i)},b=h.options,C=b.proxyUri+(b.proxyUri.indexOf("?")<0?"?":"&")+"vfs="+p,c=x.worker=new Worker(new URL(C,import.meta.url)),d=setTimeout(()=>{if(V===void 0)Y(Error("Timeout while waiting for OPFS async proxy worker."))},4000);c._originalOnError=c.onerror,c.onerror=function(B){E("Error initializing OPFS asyncer:",B),Y(Error("Loading OPFS async Worker failed for unknown reasons."))};let L=x.opRun,G=function(){let B=F.scopedAllocPush(),ae=new g.sqlite3_file;try{let ce=ae.pointer,ge=g.SQLITE_OPEN_CREATE|g.SQLITE_OPEN_READWRITE|g.SQLITE_OPEN_MAIN_DB,qe=F.scopedAlloc(8),Fe="/sanity/check/file"+h.randomFilename(8),Pe=F.scopedAllocCString(Fe),Ee;if(q.s11n.serialize("This is ä string."),Ee=q.s11n.deserialize(),j("deserialize() says:",Ee),Ee[0]!=="This is ä string.")t("String d13n error.");if(x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),j("xAccess(",Fe,") exists ?=",Ee),Ee=x.vfsSyncWrappers.xOpen(x.pointer,Pe,ce,ge,qe),j("open rc =",Ee,"state.sabOPView[xOpen] =",q.sabOPView[q.opIds.xOpen]),Ee!==0){E("open failed with code",Ee);return}if(x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),!Ee)t("xAccess() failed to detect file.");if(Ee=x.ioSyncWrappers.xSync(ae.pointer,0),Ee)t("sync failed w/ rc",Ee);if(Ee=x.ioSyncWrappers.xTruncate(ae.pointer,1024),Ee)t("truncate failed w/ rc",Ee);if(F.poke(qe,0,"i64"),Ee=x.ioSyncWrappers.xFileSize(ae.pointer,qe),Ee)t("xFileSize failed w/ rc",Ee);if(j("xFileSize says:",F.peek(qe,"i64")),Ee=x.ioSyncWrappers.xWrite(ae.pointer,Pe,10,1),Ee)t("xWrite() failed!");let Ue=F.scopedAlloc(16);Ee=x.ioSyncWrappers.xRead(ae.pointer,Ue,6,2),F.poke(Ue+6,0);let He=F.cstrToJs(Ue);if(j("xRead() got:",He),He!=="sanity")t("Unexpected xRead() value.");if(x.vfsSyncWrappers.xSleep)j("xSleep()ing before close()ing..."),x.vfsSyncWrappers.xSleep(x.pointer,2000),j("waking up from xSleep()");if(Ee=x.ioSyncWrappers.xClose(ce),j("xClose rc =",Ee,"sabOPView =",q.sabOPView),j("Deleting file:",Fe),x.vfsSyncWrappers.xDelete(x.pointer,Pe,4660),x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),Ee)t("Expecting 0 from xAccess(",Fe,") after xDelete().");U("End of OPFS sanity checks.")}finally{ae.dispose(),F.scopedAllocPop(B)}};c.onmessage=function({data:B}){switch(B.type){case"opfs-unavailable":Y(Error(B.payload.join(" ")));break;case"opfs-async-loaded":delete q.vfs,c.postMessage({type:"opfs-async-init",args:a.nu(q)});break;case"opfs-async-inited":{if(V===!0)break;clearTimeout(d),d=null;try{if(i.vfs.installVfs({io:{struct:x.ioMethods,methods:x.ioSyncWrappers},vfs:{struct:x,methods:x.vfsSyncWrappers}}),q.sabOPView=new Int32Array(q.sabOP),q.sabFileBufView=new Uint8Array(q.sabIO,0,q.fileBufferSize),q.sabS11nView=new Uint8Array(q.sabIO,q.sabS11nOffset,q.sabS11nSize),x.initS11n(),x.initS11n=null,b.sanityChecks)U("Running sanity checks because of opfs-sanity-check URL arg..."),G();if(h.thisThreadHasOPFS())h.getRootDir().then((ae)=>{c.onerror=c._originalOnError,delete c._originalOnError,j("End of OPFS sqlite3_vfs setup.",x),m()}).catch(Y);else m()}catch(ae){E(ae),Y(ae)}break}case"debug":U("debug message from worker:",B);break;default:{let ae="Unexpected message from the OPFS async worker: "+JSON.stringify(B);E(ae),Y(Error(ae));break}}}})},q}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.opfs)return;let t=i.util,r=i.opfs||i.util.toss("Missing sqlite3.opfs"),a=async function(_){if(_=r.initOptions("opfs",_),!_)return i;let h=i.capi,I=r.createVfsState(),q=I.vfs,R=q.metrics.counters,{mTimeStart:M,mTimeEnd:p,opRun:te}=q,j=(...g)=>i.config.debug("opfs:",...g),U=(...g)=>i.config.warn("opfs:",...g),E=q.__openFiles;return q.bindVfs(t.nu({xLock:function(g,F){M("xLock"),++R.xLock.count;let x=E[g],A=0;if(x.lockType)x.lockType=F;else if(A=te("xLock",g,F),A===0)x.lockType=F;return p(),A},xUnlock:function(g,F){M("xUnlock"),++R.xUnlock.count;let x=E[g],A=0;if(h.SQLITE_LOCK_NONE===F&&x.lockType)A=te("xUnlock",g,F);if(A===0)x.lockType=F;return p(),A}}),function(g,F){if(g.oo1){let x=function(...A){let N=g.oo1.DB.dbCtorHelper.normalizeArgs(...A);N.vfs=F.$zName,g.oo1.DB.dbCtorHelper.call(this,N)};x.prototype=Object.create(g.oo1.DB.prototype),g.oo1.OpfsDb=x,x.importDb=r.importDb,g.oo1.DB.dbCtorHelper.setVfsPostOpenCallback(q.pointer,function(A,N){N.capi.sqlite3_busy_timeout(A,1e4)})}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async(_)=>a().catch((h)=>{_.config.warn("Ignoring inability to install 'opfs' sqlite3_vfs:",h)}))}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.["opfs-sahpool"])return;let t=i.util.toss,r=i.util.toss3,a=Object.create(null),{capi:_,util:h,wasm:I}=i,q=4096,R=512,M=4,p=8,te=R+M,j=R,U=te,E=q,g=_.SQLITE_OPEN_MAIN_DB|_.SQLITE_OPEN_MAIN_JOURNAL|_.SQLITE_OPEN_SUPER_JOURNAL|_.SQLITE_OPEN_WAL,F=_.SQLITE_OPEN_MEMORY,x=".opaque",A=()=>Math.random().toString(36).slice(2),N=new TextDecoder,z=new TextEncoder,f=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2,forceReinitIfPreviouslyFailed:!1,preserveOnInitFailure:!1}),S=[i.config.error,i.config.warn,i.config.log],D=i.config.log,J=i.config.warn,ie=i.config.error,le=new Map,Se=(c)=>le.get(c),me=(c,d)=>{if(d)le.set(c,d);else le.delete(c)},K=new Map,oe=(c)=>K.get(c),u=(c,d)=>{if(d)K.set(c,d);else K.delete(c)},y={xCheckReservedLock:function(c,d){let L=oe(c);L.log("xCheckReservedLock"),L.storeErr();let G=L.getOFileForS3File(c);return I.poke32(d,L.hasReservedLock(G.path)?1:0),0},xClose:function(c){let d=oe(c);d.storeErr();let L=d.getOFileForS3File(c);if(L)try{if(d.log(`xClose ${L.path}`),d.unlockFile(L,_.SQLITE_LOCK_NONE),d.mapS3FileToOFile(c,!1),L.sah.flush(),L.flags&_.SQLITE_OPEN_DELETEONCLOSE)d.deletePath(L.path)}catch(G){return d.storeErr(G,_.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(c){return _.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(c,d,L){return _.SQLITE_NOTFOUND},xFileSize:function(c,d){let L=oe(c);L.log("xFileSize");let B=L.getOFileForS3File(c).sah.getSize()-E;return I.poke64(d,BigInt(B)),0},xLock:function(c,d){let L=oe(c);L.log(`xLock ${d}`),L.storeErr();let G=L.getOFileForS3File(c);return L.lockFile(G,d)},xRead:function(c,d,L,G){let B=oe(c);B.storeErr();let ae=B.getOFileForS3File(c);B.log(`xRead ${ae.path} ${L} @ ${G}`);try{let ce=ae.sah.read(I.heap8u().subarray(Number(d),Number(d)+L),{at:E+Number(G)});if(ce<L)return I.heap8u().fill(0,Number(d)+ce,Number(d)+L),_.SQLITE_IOERR_SHORT_READ;return 0}catch(ce){return B.storeErr(ce,_.SQLITE_IOERR)}},xSectorSize:function(c){return q},xSync:function(c,d){let L=oe(c);L.log(`xSync ${d}`),L.storeErr();let G=L.getOFileForS3File(c);try{return G.sah.flush(),0}catch(B){return L.storeErr(B,_.SQLITE_IOERR)}},xTruncate:function(c,d){let L=oe(c);L.log(`xTruncate ${d}`),L.storeErr();let G=L.getOFileForS3File(c);try{return G.sah.truncate(E+Number(d)),0}catch(B){return L.storeErr(B,_.SQLITE_IOERR)}},xUnlock:function(c,d){let L=oe(c);L.log("xUnlock");let G=L.getOFileForS3File(c);return L.unlockFile(G,d),0},xWrite:function(c,d,L,G){let B=oe(c);B.storeErr();let ae=B.getOFileForS3File(c);B.log(`xWrite ${ae.path} ${L} ${G}`);try{let ce=ae.sah.write(I.heap8u().subarray(Number(d),Number(d)+L),{at:E+Number(G)});return L===ce?0:t("Unknown write() failure.")}catch(ce){return B.storeErr(ce,_.SQLITE_IOERR)}}},O=new _.sqlite3_io_methods;O.$iVersion=1,i.vfs.installVfs({io:{struct:O,methods:y}});let V={xAccess:function(c,d,L,G){let B=Se(c);B.storeErr();try{let ae=B.getPath(d);I.poke32(G,B.hasFilename(ae)?1:0)}catch(ae){I.poke32(G,0)}return 0},xCurrentTime:function(c,d){return I.poke(d,2440587.5+new Date().getTime()/86400000,"double"),0},xCurrentTimeInt64:function(c,d){return I.poke(d,210866760000000+new Date().getTime(),"i64"),0},xDelete:function(c,d,L){let G=Se(c);G.log(`xDelete ${I.cstrToJs(d)}`),G.storeErr();try{return G.deletePath(G.getPath(d)),0}catch(B){return G.storeErr(B),_.SQLITE_IOERR_DELETE}},xFullPathname:function(c,d,L,G){return I.cstrncpy(G,d,L)<L?0:_.SQLITE_CANTOPEN},xGetLastError:function(c,d,L){let G=Se(c),B=G.popErr();if(G.log(`xGetLastError ${d} e =`,B),B){let ae=I.scopedAllocPush();try{let[ce,ge]=I.scopedAllocCString(B.message,!0);if(I.cstrncpy(L,ce,d),ge>d)I.poke8(I.ptr.add(L,d,-1),0)}catch(ce){return _.SQLITE_NOMEM}finally{I.scopedAllocPop(ae)}}return B?B.sqlite3Rc||_.SQLITE_IOERR:0},xOpen:function(d,L,G,B,ae){let ce=Se(d);try{B&=~F,ce.log(`xOpen ${I.cstrToJs(L)} ${B}`);let ge=L&&I.peek8(L)?ce.getPath(L):A(),qe=ce.getSAHForPath(ge);if(qe&&B&_.SQLITE_OPEN_CREATE&&B&_.SQLITE_OPEN_EXCLUSIVE)t("file already exists:",ge);if(!qe&&B&_.SQLITE_OPEN_CREATE)if(ce.getFileCount()<ce.getCapacity())qe=ce.nextAvailableSAH(),ce.setAssociatedPath(qe,ge,B);else t("SAH pool is full. Cannot create file",ge);if(!qe)t("file not found:",ge);let Fe={path:ge,flags:B,sah:qe};ce.mapS3FileToOFile(G,Fe),Fe.lockType=_.SQLITE_LOCK_NONE;let Pe=new _.sqlite3_file(G);return Pe.$pMethods=O.pointer,Pe.dispose(),I.poke32(ae,B),0}catch(ge){return ce.storeErr(ge),_.SQLITE_CANTOPEN}}},Y=function(c){if(i.capi.sqlite3_vfs_find(c))r("VFS name is already registered:",c);let d=new _.sqlite3_vfs,L=_.sqlite3_vfs_find(null),G=L?new _.sqlite3_vfs(L):null;if(d.$iVersion=2,d.$szOsFile=_.sqlite3_file.structInfo.sizeof,d.$mxPathname=R,d.addOnDispose(d.$zName=I.allocCString(c),()=>me(d.pointer,0)),G)d.$xRandomness=G.$xRandomness,G.dispose();if(!d.$xRandomness&&!V.xRandomness)V.xRandomness=function(B,ae,ce){let ge=I.heap8u(),qe=0,Fe=Number(ce);for(;qe<ae;++qe)ge[Fe+qe]=Math.random()*255000&255;return qe};return V.xSleep=(B,ae)=>0,i.vfs.installVfs({vfs:{struct:d,methods:V}}),d};class m{vfsDir;#e;#i;#s;#t=new Map;#n=new Map;#o=new Set;#c=new Map;#l=new Map;#r=new Uint8Array(te);#_;#a;#f;constructor(c=Object.create(null)){this.#f=c.verbosity??f.verbosity,this.vfsName=c.name||f.name,this.#a=Y(this.vfsName),me(this.#a.pointer,this),this.vfsDir=c.directory||"."+this.vfsName,this.#_=new DataView(this.#r.buffer,this.#r.byteOffset),this.isReady=this.reset(!!(c.clearOnInit??f.clearOnInit)).then(()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(c.initialCapacity||f.initialCapacity)})}#u(c,...d){if(this.#f>c)S[c](this.vfsName+":",...d)}log(...c){this.#u(2,...c)}warn(...c){this.#u(1,...c)}error(...c){this.#u(0,...c)}getVfs(){return this.#a}getCapacity(){return this.#t.size}getFileCount(){return this.#n.size}getFileNames(){let c=[];for(let d of this.#n.keys())c.push(d);return c}async addCapacity(c){for(let d=0;d<c;++d){let L=A(),B=await(await this.#i.getFileHandle(L,{create:!0})).createSyncAccessHandle();this.#t.set(B,L),this.setAssociatedPath(B,"",0)}return this.getCapacity()}async reduceCapacity(c){if(!Number.isSafeInteger(c)||c<0)t("Invalid capacity reduction:",c);let d=0;for(let L of Array.from(this.#o)){if(d===c||this.getFileCount()===this.getCapacity())break;let G=this.#t.get(L);L.close(),this.#t.delete(L),this.#o.delete(L),await this.#i.removeEntry(G),++d}return d}releaseAccessHandles(){for(let c of this.#t.keys())c.close();this.#t.clear(),this.#n.clear(),this.#o.clear(),this.#c.clear(),this.#l.clear()}async acquireAccessHandles(c=!1){let d=[];for await(let[B,ae]of this.#i)if(ae.kind==="file")d.push([B,ae]);let G=(await Promise.allSettled(d.map(async([B,ae])=>{let ce=await ae.createSyncAccessHandle();if(this.#t.set(ce,B),c)ce.truncate(E),this.setAssociatedPath(ce,"",0);else{let ge=this.getAssociatedPath(ce);if(ge)this.#n.set(ge,ce);else this.#o.add(ce)}}))).find((B)=>B.status==="rejected");if(G)throw this.storeErr(G.reason),this.releaseAccessHandles(),G.reason}getAssociatedPath(c){c.read(this.#r,{at:0});let d=this.#_.getUint32(j);if(this.#r[0]&&(d&_.SQLITE_OPEN_DELETEONCLOSE||(d&g)===0))return J(`Removing file with unexpected flags ${d.toString(16)}`,this.#r),this.setAssociatedPath(c,"",0),"";let L=new Uint32Array(p/4);c.read(L,{at:U});let G=this.computeDigest(this.#r,d);if(L.every((B,ae)=>B===G[ae])){let B=this.#r.findIndex((ae)=>ae===0);if(B===0)c.truncate(E);return B?N.decode(this.#r.subarray(0,B)):""}else return J("Disassociating file with bad digest."),this.setAssociatedPath(c,"",0),""}setAssociatedPath(c,d,L){let G=z.encodeInto(d,this.#r);if(R<=G.written+1)t("Path too long:",d);if(d&&L)L|=F;this.#r.fill(0,G.written,R),this.#_.setUint32(j,L);let B=this.computeDigest(this.#r,L);if(c.write(this.#r,{at:0}),c.write(B,{at:U}),c.flush(),d)this.#n.set(d,c),this.#o.delete(c);else c.truncate(E),this.#o.add(c)}computeDigest(c,d){if(d&F){let L=3735928559,G=1103547991;for(let B of c)L=Math.imul(L^B,2654435761),G=Math.imul(G^B,104729);return new Uint32Array([L>>>0,G>>>0])}else return new Uint32Array([0,0])}async reset(c){await this.isReady;let d=await navigator.storage.getDirectory(),L,G;for(let B of this.vfsDir.split("/"))if(B)L=d,d=await d.getDirectoryHandle(B,{create:!0});return this.#e=d,this.#s=L,this.#i=await this.#e.getDirectoryHandle(x,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(c)}getPath(c){if(I.isPtr(c))c=I.cstrToJs(c);return(c instanceof URL?c:new URL(c,"file://localhost/")).pathname}deletePath(c){let d=this.#n.get(c);if(d)this.#n.delete(c),this.setAssociatedPath(d,"",0);return!!d}storeErr(c,d){if(c)c.sqlite3Rc=d||_.SQLITE_IOERR,this.error(c);return this.$error=c,d}popErr(){let c=this.$error;return this.$error=void 0,c}nextAvailableSAH(){let[c]=this.#o.keys();return c}getOFileForS3File(c){return this.#c.get(c)}mapS3FileToOFile(c,d){if(d)this.#c.set(c,d),u(c,this);else this.#c.delete(c),u(c,!1)}hasFilename(c){return this.#n.has(c)}getSAHForPath(c){return this.#n.get(c)}async removeVfs(){if(!this.#a.pointer||!this.#i)return!1;_.sqlite3_vfs_unregister(this.#a.pointer),this.#a.dispose(),delete a[this.vfsName];try{this.releaseAccessHandles(),await this.#e.removeEntry(x,{recursive:!0}),this.#i=void 0,await this.#s.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#s=void 0}catch(c){i.config.error(this.vfsName,"removeVfs() failed with no recovery strategy:",c)}return!0}pauseVfs(){if(this.#c.size>0)i.SQLite3Error.toss(_.SQLITE_MISUSE,"Cannot pause VFS",this.vfsName,"because it has opened files.");if(this.#t.size>0)_.sqlite3_vfs_unregister(this.vfsName),this.releaseAccessHandles();return this}isPaused(){return this.#t.size===0}async unpauseVfs(){if(this.#t.size===0)return this.acquireAccessHandles(!1).then(()=>_.sqlite3_vfs_register(this.#a,0),this);return this}exportFile(c){let d=this.#n.get(c)||t("File not found:",c),L=d.getSize()-E,G=new Uint8Array(L>0?L:0);if(L>0){let B=d.read(G,{at:E});if(B!=L)t("Expected to read "+L+" bytes but read "+B+".")}return G}async importDbChunked(c,d){let L=this.#n.get(c)||this.nextAvailableSAH()||t("No available handles to import to.");L.truncate(0);let G=0,B,ae=!1,ce=!1;try{while((B=await d())!==void 0){if(B instanceof ArrayBuffer)B=new Uint8Array(B);if(!ae&&G===0&&B.byteLength>=15)h.affirmDbHeader(B),ae=!0;let ge=L.write(B,{at:E+G});if(ge!==B.byteLength)t("Expected to write "+B.byteLength+"bytes but wrote"+ge+".");G+=B.byteLength}if(G<512||G%512!==0)t("Input size",G,"is not correct for an SQLite database.");if(!ae){let ge=new Uint8Array(20);L.read(ge,{at:E}),h.affirmDbHeader(ge)}L.write(new Uint8Array([1,1]),{at:E+18})}catch(ge){throw this.setAssociatedPath(L,"",0),ge}return this.setAssociatedPath(L,c,_.SQLITE_OPEN_MAIN_DB),G}importDb(c,d){if(d instanceof ArrayBuffer)d=new Uint8Array(d);else if(d instanceof Function)return this.importDbChunked(c,d);h.affirmIsDb(d);let L=this.#n.get(c)||this.nextAvailableSAH()||t("No available handles to import to."),G=d.byteLength,B=L.write(d,{at:E});if(B!=G)this.setAssociatedPath(L,"",0),t("Expected to write "+G+" bytes but wrote "+B+".");else L.truncate(E+G),L.write(new Uint8Array([1,1]),{at:E+18}),this.setAssociatedPath(L,c,_.SQLITE_OPEN_MAIN_DB);return B}hasReservedLock(c){let d=this.#l.get(c);return!!d&&d.lockType>_.SQLITE_LOCK_SHARED}lockFile(c,d){if(c.lockType>=d)return 0;let L=this.#l.get(c.path);if(!L)L=Object.assign(Object.create(null),{nShared:0,lockType:_.SQLITE_LOCK_NONE}),this.#l.set(c.path,L);if(c.lockType!==L.lockType&&(L.lockType>=_.SQLITE_LOCK_PENDING||d>_.SQLITE_LOCK_SHARED))return _.SQLITE_BUSY;if(d===_.SQLITE_LOCK_SHARED){if(++L.nShared,L.lockType===_.SQLITE_LOCK_NONE)L.lockType=d}else if(d===_.SQLITE_LOCK_EXCLUSIVE&&L.nShared>1){if(c.lockType===_.SQLITE_LOCK_RESERVED)c.lockType=L.lockType=_.SQLITE_LOCK_PENDING;return _.SQLITE_BUSY}else L.lockType=d;return c.lockType=d,0}unlockFile(c,d){if(c.lockType<=d)return;let L=this.#l.get(c.path);if(c.lockType>_.SQLITE_LOCK_SHARED)L.lockType=_.SQLITE_LOCK_SHARED;if(d===_.SQLITE_LOCK_NONE&&--L.nShared===0)this.#l.delete(c.path);c.lockType=d}}class b{#e;constructor(c){this.#e=c,this.vfsName=c.vfsName}async addCapacity(c){return this.#e.addCapacity(c)}async reduceCapacity(c){return this.#e.reduceCapacity(c)}getCapacity(){return this.#e.getCapacity(this.#e)}getFileCount(){return this.#e.getFileCount()}getFileNames(){return this.#e.getFileNames()}async reserveMinimumCapacity(c){let d=this.#e.getCapacity();return d<c?this.#e.addCapacity(c-d):d}exportFile(c){return this.#e.exportFile(c)}importDb(c,d){return this.#e.importDb(c,d)}async wipeFiles(){return this.#e.reset(!0)}unlink(c){return this.#e.deletePath(c)}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()}}let C=async()=>{let c=await navigator.storage.getDirectory(),d=".opfs-sahpool-sync-check-"+A(),B=(await(await c.getFileHandle(d,{create:!0})).createSyncAccessHandle()).close();if(await B,await c.removeEntry(d),B?.then)t("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method.");return!0};i.installOpfsSAHPoolVfs=async function(c=Object.create(null)){c=Object.assign(Object.create(null),f,c||{});let d=c.name;if(c.$testThrowPhase1)throw c.$testThrowPhase1;if(a[d])try{return await a[d]}catch(G){if(c.forceReinitIfPreviouslyFailed)delete a[d];else throw G}if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!navigator?.storage?.getDirectory)return a[d]=Promise.reject(Error("Missing required OPFS APIs."));let L=(G)=>{let B=G.getVfs();if(B?.pointer)_.sqlite3_vfs_unregister(B.pointer),B.dispose(),G.releaseAccessHandles()};return a[d]=C().then(async function(){if(c.$testThrowPhase2)throw c.$testThrowPhase2;let G=new m(c);return G.isReady.then(async()=>{let B=new b(G);if(i.oo1){let ae=i.oo1,ce=G.getVfs(),ge=function(...qe){let Fe=ae.DB.dbCtorHelper.normalizeArgs(...qe);Fe.vfs=ce.$zName,ae.DB.dbCtorHelper.call(this,Fe)};ge.prototype=Object.create(ae.DB.prototype),B.OpfsSAHPoolDb=ge}return G.log("VFS initialized."),B}).catch(async(B)=>{if(c.preserveOnInitFailure)L(G);else await G.removeVfs().catch(()=>{});throw B})}).catch((G)=>a[d]=Promise.reject(G))}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.["opfs-wl"])return;let t=i.util,r=i.util.toss,a=i.opfs,_="opfs-wl",h=async function(I){if(I=a.initOptions(_,I),!I)return i;let q=i.capi,R=a.createVfsState(),M=R.vfs,p=M.metrics.counters,{mTimeStart:te,mTimeEnd:j,opRun:U}=M,E=(...x)=>i.config.debug(_+":",...x),g=(...x)=>i.config.warn(_+":",...x),F=M.__openFiles;return M.bindVfs(t.nu({xLock:function(x,A){te("xLock");let N=F[x],z=U("xLock",x,A);if(!z)N.lockType=A;return j(),z},xUnlock:function(x,A){te("xUnlock");let N=F[x],z=U("xUnlock",x,A);if(!z)N.lockType=A;return j(),z}}),function(x,A){if(x.oo1){let N=function(...z){let f=x.oo1.DB.dbCtorHelper.normalizeArgs(...z);f.vfs=A.$zName,x.oo1.DB.dbCtorHelper.call(this,f)};N.prototype=Object.create(x.oo1.DB.prototype),x.oo1.OpfsWlDb=N,N.importDb=a.importDb}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async(I)=>h().catch((q)=>{I.config.warn("Ignoring inability to install the",_,"sqlite3_vfs:",q)}))});try{let i=Object.assign(Object.create(null),{memory:typeof et<"u"?et:n.wasmMemory,exports:typeof ht<"u"?ht:Object.prototype.hasOwnProperty.call(n,"wasmExports")?n.wasmExports:n.asm},globalThis.sqlite3ApiBootstrap.defaultConfig,globalThis.sqlite3ApiConfig||{});e.debugModule("Bootstrapping lib config",i);let t=globalThis.sqlite3ApiBootstrap(i);return delete globalThis.sqlite3ApiBootstrap,t}catch(i){throw console.error("sqlite3ApiBootstrap() error:",i),i}},s}var zc,xn;var Tn=Rc(()=>{zc=function(){let w=zt;if(!w)throw Error("Expecting sqlite3InitModule to be defined by the Emscripten build.");let s=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(s.debugModule=s.urlParams.has("sqlite3.debugModule")?(...ne)=>console.warn("sqlite3.debugModule:",...ne):()=>{},s.urlParams.has("sqlite3.dir"))s.sqlite3Dir=s.urlParams.get("sqlite3.dir")+"/";else if(s.moduleScript){let ne=s.moduleScript.src.split("/");ne.pop(),s.sqlite3Dir=ne.join("/")+"/"}let ee=globalThis.sqlite3InitModule=function ne(...be){return s.emscriptenLocateFile=be[0]?.locateFile,s.emscriptenInstantiateWasm=be[0]?.instantiateWasm,w(...be).then((we)=>{s.debugModule("sqlite3InitModule() sIMS =",s),s.debugModule("sqlite3InitModule() EmscriptenModule =",we);let We=we.runSQLite3PostLoadInit(s,we,!!ne.__isUnderTest);return s.debugModule("sqlite3InitModule() sqlite3 =",We),We}).catch((we)=>{throw console.error("Exception loading sqlite3 module:",we),we})};if(ee.ready=w.ready,s.moduleScript){let ne=s.moduleScript.src.split("/");ne.pop(),s.scriptDir=ne.join("/")+"/"}return s.debugModule("extern-post-js.c-pp.js sqlite3InitModuleState =",s),ee}();zt=zc;xn=zt});var wn=Promise.resolve();function Mc(){return typeof Bun>"u"?null:Bun.fetch}function jt(w){let s=Mc();if(!s)return w();let ee=wn.then(async()=>{let ne=globalThis.fetch;globalThis.fetch=s;try{return await w()}finally{globalThis.fetch=ne}});return wn=ee.then(()=>{return},()=>{return}),ee}function jc(w,s){let ee=Reflect.get(w.capi,"sqlite3mc_vfs_create");if(typeof ee!=="function")return null;let ne=Reflect.apply(ee,w.capi,[s,0]);return typeof ne==="number"?ne:null}function En(w,s){let ee=new Set(w.capi.sqlite3_js_vfs_list()),ne=jc(w,s);if(ne===null)throw Error("Persistent storage requested but the SQLite build does not provide sqlite3mc_vfs_create.");if(ne!==0)throw Error(`Failed to create the multiple-ciphers VFS over ${s} (rc=${ne}).`);let be=w.capi.sqlite3_js_vfs_list().filter((We)=>!ee.has(We)),we=be.find((We)=>We.includes(s))??be[0];if(!we)throw Error("The multiple-ciphers VFS was created but could not be located in the VFS list.");return we}function kn(w,s){let ee=Reflect.get(w.capi,"sqlite3mc_vfs_destroy");if(typeof ee!=="function")throw Error("The SQLite build does not provide sqlite3mc_vfs_destroy.");Reflect.apply(ee,w.capi,[s])}var qt=8000;class It extends Error{constructor(w){super(w);this.name="SahPoolStepTimeoutError"}}function vt(w,s){w.catch(()=>{});let ee;return Promise.race([w,new Promise((ne,be)=>{ee=setTimeout(()=>{be(new It(`SAHPool handle acquisition did not settle within ${s}ms (likely a hung createSyncAccessHandle under OPFS handle-cap contention).`))},s)})]).finally(()=>{clearTimeout(ee)})}var An="tearleads-opfs-sahpool",In="/tearleads-sqlite";function Wc(w){let s=w.trim().replace(/^\/+/u,"").replace(/[^a-zA-Z0-9_.-]+/gu,"_").replace(/^_+/u,""),ee=s.length;while(ee>0&&s[ee-1]==="_")ee-=1;let ne=s.slice(0,ee);return!ne||ne==="."||ne===".."?"default":ne}function Wt(w){let s=Wc(w);return{directory:`/tearleads-sqlite/${s}`,vfsName:`tearleads-opfs-sahpool-${s}`}}var Bc=["Missing SharedArrayBuffer and/or Atomics","The OPFS sqlite3_vfs cannot run in the main thread"],On=Symbol.for("tearleads.sqliteWorker.autoOpfsVfsWarnFilterInstalled");function Pn(w){if(typeof w==="string")return w;if(w instanceof Error)return w.message;if(typeof w==="object"&&w!==null){let s=Reflect.get(w,"message");if(typeof s==="string")return s}try{return String(w)}catch{return"[Object]"}}function Uc(w){return Bc.some((s)=>w.includes(s))}function Fn(w){if(w.length===0)return!1;let s=Pn(w[0]),ee=w.map(Pn).join(" ");return(s==="Ignoring inability to install OPFS sqlite3_vfs:"||s.includes("Ignoring inability to install OPFS sqlite3_vfs:"))&&Uc(ee)}function Ln(){if(Reflect.get(console,On)===!0||typeof console.warn!=="function")return;let w=console.warn;Reflect.set(console,"warn",(...ee)=>{if(Fn(ee))return;Reflect.apply(w,console,ee)}),Reflect.set(console,On,!0)}function Qc(w){let s=typeof w==="object"&&w!==null?w:void 0,ee=s?Reflect.get(s,"warn"):void 0,ne=(...be)=>{if(Fn(be))return;if(typeof ee==="function"){Reflect.apply(ee,s??globalThis,be);return}console.warn(...be)};return Object.assign(Object.create(null),s,{warn:ne})}function Vc(w){if(w===void 0){Reflect.deleteProperty(globalThis,"sqlite3ApiConfig");return}Reflect.set(globalThis,"sqlite3ApiConfig",w)}async function Cn(){let w=Reflect.get(globalThis,"sqlite3ApiConfig"),s=Qc(w);Reflect.set(globalThis,"sqlite3ApiConfig",s);try{await Promise.resolve().then(() => Tn());return await xn()}finally{if(Reflect.get(globalThis,"sqlite3ApiConfig")===s)Vc(w)}}function Bt(w,s){if(s.rowMode==="array"){let ne=[];return w.exec(s.sql,{...s.bind!==void 0?{bind:s.bind}:{},rowMode:"array",resultRows:ne}),ne}let ee=[];return w.exec(s.sql,{...s.bind!==void 0?{bind:s.bind}:{},rowMode:"object",resultRows:ee}),ee}var Hc=12,Gc=3000,Kc=150,$c=600;function Jc(w){return new Promise((s)=>{setTimeout(s,w)})}function Xc(w){if(typeof w!=="object"||w===null)return!1;if(Reflect.get(w,"name")==="NoModificationAllowedError")return!0;let ee=Reflect.get(w,"message");return typeof ee==="string"&&ee.includes("Access Handles cannot be created")}var Ut,Qt,ot=new Map,Vt=new WeakMap;function Nn(w){return`${w.vfsName}
|
|
4
|
-
${w.directory}`}function
|
|
1
|
+
var Rc=(w,s,Z)=>()=>{if(w)try{s=w(w=0)}catch(ne){Z=[ne]}if(Z)throw Z[0];return s};async function zt(w={}){var s=w,Z=!!globalThis.window,ne=!!globalThis.WorkerGlobalScope,be=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer",we=!Z&&!be&&!ne;(function(e){let n=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:function(){console.warn("globalThis.sqlite3InitModuleState is missing",arguments)}});delete globalThis.sqlite3InitModuleState,n.debugModule("pre-js.js sqlite3InitModuleState =",n),e.locateFile=function(o,i){if(this.emscriptenLocateFile instanceof Function)return this.emscriptenLocateFile(o,i);return new URL(o,import.meta.url).href}.bind(n),e.instantiateWasm=function(i,t){if(this.emscriptenInstantiateWasm instanceof Function)return this.emscriptenInstantiateWasm(i,t);let r=this,a=(q)=>{q.imports=i,r.instantiateWasm=q,t(q.instance,q.module)},_=e.locateFile(r.wasmFilename,typeof Xe>"u"?"":Xe);r.debugModule("instantiateWasm() uri =",_,"sIMS =",this);let h=()=>fetch(_,{credentials:"same-origin"});return(WebAssembly.instantiateStreaming?async()=>WebAssembly.instantiateStreaming(h(),i).then(a):async()=>h().then((q)=>q.arrayBuffer()).then((q)=>WebAssembly.instantiate(q,i)).then(a))()}.bind(n)})(s);var We=[],Ve="./this.program",nt=(e,n)=>{throw n},Ye=import.meta.url,Xe="";function Jn(e){if(s.locateFile)return s.locateFile(e,Xe);return Xe+e}var xt,St;if(Z||ne){try{Xe=new URL(".",Ye).href}catch{}{if(ne)St=(e)=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)};xt=async(e)=>{var n=await fetch(e,{credentials:"same-origin"});if(n.ok)return n.arrayBuffer();throw Error(n.status+" : "+n.url)}}}var wt=console.log.bind(console),rt=console.error.bind(console),Kt,Tt=!1,$t;function p_(e,n){if(!e)Ke(n)}var h_=(e)=>e.startsWith("file://");class Jt{}class Xn extends Jt{}var Yn=!1;function Zn(){return et.buffer}function Xt(){if(Be?.buffer?.resizable)return;var e=Zn();Be=new Int8Array(e),at=new Int16Array(e),Ze=new Uint8Array(e),ur=new Uint16Array(e),Ie=new Int32Array(e),ke=new Uint32Array(e),Ot=new Float32Array(e),Pt=new Float64Array(e),ze=new BigInt64Array(e),fr=new BigUint64Array(e)}function er(){if(s.wasmMemory)et=s.wasmMemory;else{var e=s.INITIAL_MEMORY||8388608;et=new WebAssembly.Memory({initial:e/65536,maximum:32768})}Xt()}function tr(){var e=s.preRun;if(e){if(typeof e=="function")e=[e];Lt.push(...e)}en(Lt)}function nr(){if(Yn=!0,!s.noFSInit&&!l.initialized)l.init();it.init(),ht.__wasm_call_ctors(),l.ignorePermissions=!1}function rr(){var e=s.postRun;if(e){if(typeof e=="function")e=[e];Ft.push(...e)}en(Ft)}function Ke(e){s.onAbort?.(e),e=`Aborted(${e})`,rt(e),Tt=!0,e+=". Build with -sASSERTIONS for more info.";var n=new WebAssembly.RuntimeError(e);throw n}var Yt;function ir(){if(s.locateFile)return Jn("sqlite3.wasm");return new URL("sqlite3.wasm",import.meta.url).href}function sr(e){if(St)return St(e);throw"both async and sync fetching of the wasm failed"}async function or(e){if(!Kt)try{var n=await xt(e);return new Uint8Array(n)}catch{}return sr(e)}async function ar(e,n){try{var o=await or(e),i=await WebAssembly.instantiate(o,n);return i}catch(t){rt(`failed to asynchronously prepare wasm: ${t}`),Ke(t)}}async function lr(e,n,o){if(!e)try{var i=fetch(n,{credentials:"same-origin"}),t=await WebAssembly.instantiateStreaming(i,o);return t}catch(r){rt(`wasm streaming compile failed: ${r}`),rt("falling back to ArrayBuffer instantiation")}return ar(n,o)}function cr(){var e={env:qn,wasi_snapshot_preview1:qn};return e}async function _r(){function e(a){return ht=a.exports,Nc(ht),ht}function n(a){return e(a.instance)}var o=cr(),i=s.instantiateWasm;if(i)return new Promise((a)=>{i(o,(_)=>a(e(_)))});Yt??=ir();var t=await lr(Kt,Yt,o),r=n(t);return r}class Zt{name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var at,Ie,ze,Be,Ot,Pt,ur,ke,fr,Ze,en=(e)=>{while(e.length>0)e.shift()(s)},Ft=[],m_=(e)=>Ft.push(e),Lt=[],g_=(e)=>Lt.push(e);function b_(e,n="i8"){if(n.endsWith("*"))n="*";switch(n){case"i1":return Be[e];case"i8":return Be[e];case"i16":return at[e>>1];case"i32":return Ie[e>>2];case"i64":return ze[e>>3];case"float":return Ot[e>>2];case"double":return Pt[e>>3];case"*":return ke[e>>2];default:Ke(`invalid type for getValue: ${n}`)}}var tn=!0;function y_(e,n,o="i8"){if(o.endsWith("*"))o="*";switch(o){case"i1":Be[e]=n;break;case"i8":Be[e]=n;break;case"i16":at[e>>1]=n;break;case"i32":Ie[e>>2]=n;break;case"i64":ze[e>>3]=BigInt(n);break;case"float":Ot[e>>2]=n;break;case"double":Pt[e>>3]=n;break;case"*":ke[e>>2]=n;break;default:Ke(`invalid type for setValue: ${o}`)}}var q_=(e)=>bn(e),v_=()=>yn(),et,Te={isAbs:(e)=>e.charAt(0)==="/",splitPath:(e)=>{var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return n.exec(e).slice(1)},normalizeArray:(e,n)=>{var o=0;for(var i=e.length-1;i>=0;i--){var t=e[i];if(t===".")e.splice(i,1);else if(t==="..")e.splice(i,1),o++;else if(o)e.splice(i,1),o--}if(n)for(;o;o--)e.unshift("..");return e},normalize:(e)=>{var n=Te.isAbs(e),o=e.slice(-1)==="/";if(e=Te.normalizeArray(e.split("/").filter((i)=>!!i),!n).join("/"),!e&&!n)e=".";if(e&&o)e+="/";return(n?"/":"")+e},dirname:(e)=>{var n=Te.splitPath(e),o=n[0],i=n[1];if(!o&&!i)return".";if(i)i=i.slice(0,-1);return o+i},basename:(e)=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>Te.normalize(e.join("/")),join2:(e,n)=>Te.normalize(e+"/"+n)},dr=()=>(e)=>(crypto.getRandomValues(e),0),nn=(e)=>(nn=dr())(e),ut={resolve:(...e)=>{var n="",o=!1;for(var i=e.length-1;i>=-1&&!o;i--){var t=i>=0?e[i]:l.cwd();if(typeof t!="string")throw TypeError("Arguments to path.resolve must be strings");else if(!t)return"";n=t+"/"+n,o=Te.isAbs(t)}return n=Te.normalizeArray(n.split("/").filter((r)=>!!r),!o).join("/"),(o?"/":"")+n||"."},relative:(e,n)=>{e=ut.resolve(e).slice(1),n=ut.resolve(n).slice(1);function o(I){var q=0;for(;q<I.length;q++)if(I[q]!=="")break;var R=I.length-1;for(;R>=0;R--)if(I[R]!=="")break;if(q>R)return[];return I.slice(q,R-q+1)}var i=o(e.split("/")),t=o(n.split("/")),r=Math.min(i.length,t.length),a=r;for(var _=0;_<r;_++)if(i[_]!==t[_]){a=_;break}var h=[];for(var _=a;_<i.length;_++)h.push("..");return h=h.concat(t.slice(a)),h.join("/")}},rn=new TextDecoder,sn=(e,n,o,i)=>{var t=n+o;if(i)return t;while(e[n]&&!(n>=t))++n;return n},bt=(e,n=0,o,i)=>{var t=sn(e,n,o,i);return rn.decode(e.buffer?e.subarray(n,t):new Uint8Array(e.slice(n,t)))},Ct=[],Et=(e)=>{var n=0;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(i<=127)n++;else if(i<=2047)n+=2;else if(i>=55296&&i<=57343)n+=4,++o;else n+=3}return n},on=(e,n,o,i)=>{if(!(i>0))return 0;var t=o,r=o+i-1;for(var a=0;a<e.length;++a){var _=e.codePointAt(a);if(_<=127){if(o>=r)break;n[o++]=_}else if(_<=2047){if(o+1>=r)break;n[o++]=192|_>>6,n[o++]=128|_&63}else if(_<=65535){if(o+2>=r)break;n[o++]=224|_>>12,n[o++]=128|_>>6&63,n[o++]=128|_&63}else{if(o+3>=r)break;n[o++]=240|_>>18,n[o++]=128|_>>12&63,n[o++]=128|_>>6&63,n[o++]=128|_&63,a++}}return n[o]=0,o-t},Nt=(e,n,o)=>{var i=o>0?o:Et(e)+1,t=Array(i),r=on(e,t,0,t.length);if(n)t.length=r;return t},pr=()=>{if(!Ct.length){var e=null;if(globalThis.window?.prompt){if(e=window.prompt("Input: "),e!==null)e+=`
|
|
2
|
+
`}if(!e)return null;Ct=Nt(e,!0)}return Ct.shift()},it={ttys:[],init(){},shutdown(){},register(e,n){it.ttys[e]={input:[],output:[],ops:n},l.registerDevice(e,it.stream_ops)},stream_ops:{open(e){var n=it.ttys[e.node.rdev];if(!n)throw new l.ErrnoError(43);e.tty=n,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,n,o,i,t){if(!e.tty||!e.tty.ops.get_char)throw new l.ErrnoError(60);var r=0;for(var a=0;a<i;a++){var _;try{_=e.tty.ops.get_char(e.tty)}catch(h){throw new l.ErrnoError(29)}if(_===void 0&&r===0)throw new l.ErrnoError(6);if(_===null||_===void 0)break;r++,n[o+a]=_}if(r)e.node.atime=Date.now();return r},write(e,n,o,i,t){if(!e.tty||!e.tty.ops.put_char)throw new l.ErrnoError(60);try{for(var r=0;r<i;r++)e.tty.ops.put_char(e.tty,n[o+r])}catch(a){throw new l.ErrnoError(29)}if(i)e.node.mtime=e.node.ctime=Date.now();return r}},default_tty_ops:{get_char(e){return pr()},put_char(e,n){if(n===null||n===10)wt(bt(e.output)),e.output=[];else if(n!=0)e.output.push(n)},fsync(e){if(e.output?.length>0)wt(bt(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,n,o){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,n){if(n===null||n===10)rt(bt(e.output)),e.output=[];else if(n!=0)e.output.push(n)},fsync(e){if(e.output?.length>0)rt(bt(e.output)),e.output=[]}}},hr=(e,n)=>Ze.fill(0,e,e+n),an=(e,n)=>Math.ceil(e/n)*n,ln=(e)=>{e=an(e,65536);var n=gn(65536,e);if(n)hr(n,e);return n},ye={ops_table:null,mount(e){return ye.createNode(null,"/",16895,0)},createNode(e,n,o,i){if(l.isBlkdev(o)||l.isFIFO(o))throw new l.ErrnoError(63);ye.ops_table||={dir:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr,lookup:ye.node_ops.lookup,mknod:ye.node_ops.mknod,rename:ye.node_ops.rename,unlink:ye.node_ops.unlink,rmdir:ye.node_ops.rmdir,readdir:ye.node_ops.readdir,symlink:ye.node_ops.symlink},stream:{llseek:ye.stream_ops.llseek}},file:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr},stream:{llseek:ye.stream_ops.llseek,read:ye.stream_ops.read,write:ye.stream_ops.write,mmap:ye.stream_ops.mmap,msync:ye.stream_ops.msync}},link:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr,readlink:ye.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr},stream:l.chrdev_stream_ops}};var t=l.createNode(e,n,o,i);if(l.isDir(t.mode))t.node_ops=ye.ops_table.dir.node,t.stream_ops=ye.ops_table.dir.stream,t.contents={};else if(l.isFile(t.mode))t.node_ops=ye.ops_table.file.node,t.stream_ops=ye.ops_table.file.stream,t.usedBytes=0,t.contents=ye.emptyFileContents??=new Uint8Array(0);else if(l.isLink(t.mode))t.node_ops=ye.ops_table.link.node,t.stream_ops=ye.ops_table.link.stream;else if(l.isChrdev(t.mode))t.node_ops=ye.ops_table.chrdev.node,t.stream_ops=ye.ops_table.chrdev.stream;if(t.atime=t.mtime=t.ctime=Date.now(),e)e.contents[n]=t,e.atime=e.mtime=e.ctime=t.atime;return t},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,n){var o=e.contents.length;if(o>=n)return;var i=1048576;if(n=Math.max(n,o*(o<i?2:1.125)>>>0),o)n=Math.max(n,256);var t=ye.getFileDataAsTypedArray(e);e.contents=new Uint8Array(n),e.contents.set(t)},resizeFileStorage(e,n){if(e.usedBytes==n)return;var o=e.contents;e.contents=new Uint8Array(n),e.contents.set(o.subarray(0,Math.min(n,e.usedBytes))),e.usedBytes=n},node_ops:{getattr(e){var n={};if(n.dev=l.isChrdev(e.mode)?e.id:1,n.ino=e.id,n.mode=e.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=e.rdev,l.isDir(e.mode))n.size=4096;else if(l.isFile(e.mode))n.size=e.usedBytes;else if(l.isLink(e.mode))n.size=e.link.length;else n.size=0;return n.atime=new Date(e.atime),n.mtime=new Date(e.mtime),n.ctime=new Date(e.ctime),n.blksize=4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr(e,n){for(let o of["mode","atime","mtime","ctime"])if(n[o]!=null)e[o]=n[o];if(n.size!==void 0)ye.resizeFileStorage(e,n.size)},lookup(e,n){if(!ye.doesNotExistError)ye.doesNotExistError=new l.ErrnoError(44),ye.doesNotExistError.stack="<generic error, no stack>";throw ye.doesNotExistError},mknod(e,n,o,i){return ye.createNode(e,n,o,i)},rename(e,n,o){var i;try{i=l.lookupNode(n,o)}catch(r){}if(i){if(l.isDir(e.mode))for(var t in i.contents)throw new l.ErrnoError(55);l.hashRemoveNode(i)}delete e.parent.contents[e.name],n.contents[o]=e,e.name=o,n.ctime=n.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,n){delete e.contents[n],e.ctime=e.mtime=Date.now()},rmdir(e,n){var o=l.lookupNode(e,n);for(var i in o.contents)throw new l.ErrnoError(55);delete e.contents[n],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,n,o){var i=ye.createNode(e,n,41471,0);return i.link=o,i},readlink(e){if(!l.isLink(e.mode))throw new l.ErrnoError(28);return e.link}},stream_ops:{read(e,n,o,i,t){var r=e.node.contents;if(t>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-t,i);return n.set(r.subarray(t,t+a),o),a},write(e,n,o,i,t,r){if(n.buffer===Be.buffer)r=!1;if(!i)return 0;var a=e.node;if(a.mtime=a.ctime=Date.now(),r)a.contents=n.subarray(o,o+i),a.usedBytes=i;else if(a.usedBytes===0&&t===0)a.contents=n.slice(o,o+i),a.usedBytes=i;else ye.expandFileStorage(a,t+i),a.contents.set(n.subarray(o,o+i),t),a.usedBytes=Math.max(a.usedBytes,t+i);return i},llseek(e,n,o){var i=n;if(o===1)i+=e.position;else if(o===2){if(l.isFile(e.node.mode))i+=e.node.usedBytes}if(i<0)throw new l.ErrnoError(28);return i},mmap(e,n,o,i,t){if(!l.isFile(e.node.mode))throw new l.ErrnoError(43);var r,a,_=e.node.contents;if(!(t&2)&&_.buffer===Be.buffer)a=!1,r=_.byteOffset;else{if(a=!0,r=ln(n),!r)throw new l.ErrnoError(48);if(_){if(o>0||o+n<_.length)if(_.subarray)_=_.subarray(o,o+n);else _=Array.prototype.slice.call(_,o,o+n);Be.set(_,r)}}return{ptr:r,allocated:a}},msync(e,n,o,i,t){return ye.stream_ops.write(e,n,0,i,o,!1),0}}},mr=(e)=>{if(typeof e!="string")return e;var n={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},o=n[e];if(typeof o>"u")throw Error(`Unknown file open mode: ${e}`);return o},cn=(e)=>{if(typeof e=="string")e=Nt(e,!0);if(!e.subarray)e=new Uint8Array(e);return e},Dt=(e,n)=>{var o=0;if(e)o|=365;if(n)o|=146;return o},gr=async(e)=>{var n=await xt(e);return new Uint8Array(n)},br=(...e)=>l.createDataFile(...e),yr=(e)=>e,_n=null,qr=async()=>_n,lt=0,un=null,vr=(e)=>{if(lt--,s.monitorRunDependencies?.(lt),!lt)un()},Sr=(e)=>{if(!lt)_n=new Promise((n)=>un=n);lt++,s.monitorRunDependencies?.(lt)},wr=[],Er=async(e,n)=>{if(typeof Browser<"u")Browser.init();for(var o of wr)if(o.canHandle(n))return o.handle(e,n);return e},fn=async(e,n,o,i,t,r,a,_)=>{var h=n?ut.resolve(Te.join2(e,n)):e,I=yr(`cp ${h}`);Sr(I);try{var q=o;if(typeof o=="string")q=await gr(o);if(q=await Er(q,h),_?.(),!r)br(e,n,q,i,t,a)}finally{vr(I)}},kr=(e,n,o,i,t,r,a,_,h,I)=>{fn(e,n,o,i,t,_,h,I).then(r).catch(a)},l={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,n,o,i){if(!e)e=this;this.parent=e,this.mount=e.mount,this.id=l.nextInode++,this.name=n,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 l.isDir(this.mode)}get isDevice(){return l.isChrdev(this.mode)}addListener(e,n=!1){var o={cb:e,exclusive:n},i=this.listeners??=new Set;return i.add(o),{listeners:i,entry:o}}notifyListeners(e){if(!this.listeners)return;var n;for(var o of this.listeners)if(o.exclusive)(n||=[]).push(o);else o.cb(e);if(n){var i=(this.exclTurn||0)%n.length;this.exclTurn=i+1,n[i].cb(e)}}},lookupPath(e,n={}){if(!e)throw new l.ErrnoError(44);if(n.follow_mount??=!0,!Te.isAbs(e))e=l.cwd()+"/"+e;e:for(var o=0;o<40;o++){var i=e.split("/").filter((I)=>!!I),t=l.root,r="/";for(var a=0;a<i.length;a++){var _=a===i.length-1;if(_&&n.parent)break;if(i[a]===".")continue;if(i[a]===".."){if(r=Te.dirname(r),l.isRoot(t)){e=r+"/"+i.slice(a+1).join("/"),o--;continue e}else t=t.parent;continue}r=Te.join2(r,i[a]);try{t=l.lookupNode(t,i[a])}catch(I){if(I?.errno===44&&_&&n.noent_okay)return{path:r};throw I}if(l.isMountpoint(t)&&(!_||n.follow_mount))t=t.mounted.root;if(l.isLink(t.mode)&&(!_||n.follow)){if(!t.node_ops.readlink)throw new l.ErrnoError(52);var h=t.node_ops.readlink(t);if(!Te.isAbs(h))h=Te.dirname(r)+"/"+h;e=h+"/"+i.slice(a+1).join("/");continue e}}return{path:r,node:t}}throw new l.ErrnoError(32)},getPath(e){var n;while(!0){if(l.isRoot(e)){var o=e.mount.mountpoint;if(!n)return o;return o[o.length-1]!=="/"?`${o}/${n}`:o+n}n=n?`${e.name}/${n}`:e.name,e=e.parent}},hashName(e,n){var o=0;for(var i=0;i<n.length;i++)o=(o<<5)-o+n.charCodeAt(i)|0;return(e+o>>>0)%l.nameTable.length},hashAddNode(e){var n=l.hashName(e.parent.id,e.name);e.name_next=l.nameTable[n],l.nameTable[n]=e},hashRemoveNode(e){var n=l.hashName(e.parent.id,e.name);if(l.nameTable[n]===e)l.nameTable[n]=e.name_next;else{var o=l.nameTable[n];while(o){if(o.name_next===e){o.name_next=e.name_next;break}o=o.name_next}}},lookupNode(e,n){var o=l.mayLookup(e);if(o)throw new l.ErrnoError(o);var i=l.hashName(e.id,n);for(var t=l.nameTable[i];t;t=t.name_next){var r=t.name;if(t.parent.id===e.id&&r===n)return t}return l.lookup(e,n)},createNode(e,n,o,i){var t=new l.FSNode(e,n,o,i);return l.hashAddNode(t),t},destroyNode(e){l.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 n=["r","w","rw"][e&3];if(e&512)n+="w";return n},nodePermissions(e,n){if(l.ignorePermissions)return 0;if(n.includes("r")&&!(e.mode&292))return 2;if(n.includes("w")&&!(e.mode&146))return 2;if(n.includes("x")&&!(e.mode&73))return 2;return 0},mayLookup(e){if(!l.isDir(e.mode))return 54;var n=l.nodePermissions(e,"x");if(n)return n;if(!e.node_ops.lookup)return 2;return 0},mayCreate(e,n){if(!l.isDir(e.mode))return 54;try{var o=l.lookupNode(e,n);return 20}catch(i){}return l.nodePermissions(e,"wx")},mayDelete(e,n,o){var i;try{i=l.lookupNode(e,n)}catch(r){return r.errno}var t=l.nodePermissions(e,"wx");if(t)return t;if(o){if(!l.isDir(i.mode))return 54;if(l.isRoot(i)||l.getPath(i)===l.cwd())return 10}else if(l.isDir(i.mode))return 31;return 0},mayOpen(e,n){if(!e)return 44;if(l.isLink(e.mode))return 32;var o=l.flagsToPermissionString(n);if(l.isDir(e.mode)){if(o!=="r"||n&576)return 31}return l.nodePermissions(e,o)},checkOpExists(e,n){if(!e)throw new l.ErrnoError(n);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=l.MAX_OPEN_FDS;e++)if(!l.streams[e])return e;throw new l.ErrnoError(33)},getStreamChecked(e){var n=l.getStream(e);if(!n)throw new l.ErrnoError(8);return n},getStream:(e)=>l.streams[e],createStream(e,n=-1){if(e=Object.assign(new l.FSStream,e),n==-1)n=l.nextfd();return e.fd=n,l.streams[n]=e,e},closeStream(e){l.streams[e]=null},dupStream(e,n=-1){var o=l.createStream(e,n);return o.stream_ops?.dup?.(o),o},doSetAttr(e,n,o){var i=e?.stream_ops.setattr,t=i?e:n;i??=n.node_ops.setattr,l.checkOpExists(i,63);try{i(t,o)}catch(r){if(r instanceof RangeError)throw new l.ErrnoError(22);throw r}},chrdev_stream_ops:{open(e){var n=l.getDevice(e.node.rdev);e.stream_ops=n.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new l.ErrnoError(70)}},major:(e)=>e>>8,minor:(e)=>e&255,makedev:(e,n)=>e<<8|n,registerDevice(e,n){l.devices[e]={stream_ops:n}},getDevice:(e)=>l.devices[e],getMounts(e){var n=[],o=[e];while(o.length){var i=o.pop();n.push(i),o.push(...i.mounts)}return n},syncfs(e,n){if(typeof e=="function")n=e,e=!1;if(l.syncFSRequests++,l.syncFSRequests>1)rt(`warning: ${l.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var o=l.getMounts(l.root.mount),i=0;function t(_){return l.syncFSRequests--,n(_)}function r(_){if(_){if(!r.errored)return r.errored=!0,t(_);return}if(++i>=o.length)t(null)}for(var a of o)if(a.type.syncfs)a.type.syncfs(a,e,r);else r(null)},mount(e,n,o){var i=o==="/",t=!o,r;if(i&&l.root)throw new l.ErrnoError(10);else if(!i&&!t){var a=l.lookupPath(o,{follow_mount:!1});if(o=a.path,r=a.node,l.isMountpoint(r))throw new l.ErrnoError(10);if(!l.isDir(r.mode))throw new l.ErrnoError(54)}var _={type:e,opts:n,mountpoint:o,mounts:[]},h=e.mount(_);if(h.mount=_,_.root=h,i)l.root=h;else if(r){if(r.mounted=_,r.mount)r.mount.mounts.push(_)}return h},unmount(e){var n=l.lookupPath(e,{follow_mount:!1});if(!l.isMountpoint(n.node))throw new l.ErrnoError(28);var o=n.node,i=o.mounted,t=l.getMounts(i);for(var[r,a]of Object.entries(l.nameTable))while(a){var _=a.name_next;if(t.includes(a.mount))l.destroyNode(a);a=_}o.mounted=null;var h=o.mount.mounts.indexOf(i);o.mount.mounts.splice(h,1)},lookup(e,n){return e.node_ops.lookup(e,n)},mknod(e,n,o){var i=l.lookupPath(e,{parent:!0}),t=i.node,r=Te.basename(e);if(!r)throw new l.ErrnoError(28);if(r==="."||r==="..")throw new l.ErrnoError(20);var a=l.mayCreate(t,r);if(a)throw new l.ErrnoError(a);if(!t.node_ops.mknod)throw new l.ErrnoError(63);return t.node_ops.mknod(t,r,n,o)},statfs(e){return l.statfsNode(l.lookupPath(e,{follow:!0}).node)},statfsStream(e){return l.statfsNode(e.node)},statfsNode(e){var n={bsize:4096,frsize:4096,blocks:1e6,bfree:500000,bavail:500000,files:l.nextInode,ffree:l.nextInode-1,fsid:42,flags:2,namelen:255};if(e.node_ops.statfs)Object.assign(n,e.node_ops.statfs(e.mount.opts.root));return n},create(e,n=438){return n&=4095,n|=32768,l.mknod(e,n,0)},mkdir(e,n=511){return n&=1023,n|=16384,l.mknod(e,n,0)},mkdirTree(e,n){var o=e.split("/"),i="";for(var t of o){if(!t)continue;if(i||Te.isAbs(e))i+="/";i+=t;try{l.mkdir(i,n)}catch(r){if(r.errno!=20)throw r}}},mkdev(e,n,o){if(typeof o>"u")o=n,n=438;return n|=8192,l.mknod(e,n,o)},symlink(e,n){if(!ut.resolve(e))throw new l.ErrnoError(44);var o=l.lookupPath(n,{parent:!0}),i=o.node;if(!i)throw new l.ErrnoError(44);var t=Te.basename(n),r=l.mayCreate(i,t);if(r)throw new l.ErrnoError(r);if(!i.node_ops.symlink)throw new l.ErrnoError(63);return i.node_ops.symlink(i,t,e)},link(e,n,o){var i=l.lookupPath(n,{parent:!0}),t=i.node;if(!t)throw new l.ErrnoError(44);var r=Te.basename(n),a=l.mayCreate(t,r);if(a)throw new l.ErrnoError(a);if(!t.node_ops.link)throw new l.ErrnoError(34);return t.node_ops.link(t,r,e,o)},rename(e,n){var o=Te.dirname(e),i=Te.dirname(n),t=Te.basename(e),r=Te.basename(n),a,_,h;if(a=l.lookupPath(e,{parent:!0}),_=a.node,a=l.lookupPath(n,{parent:!0}),h=a.node,!_||!h)throw new l.ErrnoError(44);if(_.mount!==h.mount)throw new l.ErrnoError(75);var I=l.lookupNode(_,t),q=ut.relative(e,i);if(q.charAt(0)!==".")throw new l.ErrnoError(28);if(q=ut.relative(n,o),q.charAt(0)!==".")throw new l.ErrnoError(55);var R;try{R=l.lookupNode(h,r)}catch(te){}if(I===R)return;var M=l.isDir(I.mode),p=l.mayDelete(_,t,M);if(p)throw new l.ErrnoError(p);if(p=R?l.mayDelete(h,r,M):l.mayCreate(h,r),p)throw new l.ErrnoError(p);if(!_.node_ops.rename)throw new l.ErrnoError(63);if(l.isMountpoint(I)||R&&l.isMountpoint(R))throw new l.ErrnoError(10);if(h!==_){if(p=l.nodePermissions(_,"w"),p)throw new l.ErrnoError(p)}l.hashRemoveNode(I);try{_.node_ops.rename(I,h,r),I.parent=h}catch(te){throw te}finally{l.hashAddNode(I)}},rmdir(e){var n=l.lookupPath(e,{parent:!0}),o=n.node,i=Te.basename(e),t=l.lookupNode(o,i),r=l.mayDelete(o,i,!0);if(r)throw new l.ErrnoError(r);if(!o.node_ops.rmdir)throw new l.ErrnoError(63);if(l.isMountpoint(t))throw new l.ErrnoError(10);o.node_ops.rmdir(o,i),l.destroyNode(t)},readdir(e){var n=l.lookupPath(e,{follow:!0}),o=n.node,i=l.checkOpExists(o.node_ops.readdir,54);return i(o)},unlink(e){var n=l.lookupPath(e,{parent:!0}),o=n.node;if(!o)throw new l.ErrnoError(44);var i=Te.basename(e),t=l.lookupNode(o,i),r=l.mayDelete(o,i,!1);if(r)throw new l.ErrnoError(r);if(!o.node_ops.unlink)throw new l.ErrnoError(63);if(l.isMountpoint(t))throw new l.ErrnoError(10);o.node_ops.unlink(o,i),l.destroyNode(t)},readlink(e){var n=l.lookupPath(e),o=n.node;if(!o)throw new l.ErrnoError(44);if(!o.node_ops.readlink)throw new l.ErrnoError(28);return o.node_ops.readlink(o)},stat(e,n){var o=l.lookupPath(e,{follow:!n}),i=o.node,t=l.checkOpExists(i.node_ops.getattr,63);return t(i)},fstat(e){var n=l.getStreamChecked(e),o=n.node,i=n.stream_ops.getattr,t=i?n:o;return i??=o.node_ops.getattr,l.checkOpExists(i,63),i(t)},lstat(e){return l.stat(e,!0)},doChmod(e,n,o,i){l.doSetAttr(e,n,{mode:o&4095|n.mode&-4096,ctime:Date.now(),dontFollow:i})},chmod(e,n,o){var i;if(typeof e=="string"){var t=l.lookupPath(e,{follow:!o});i=t.node}else i=e;l.doChmod(null,i,n,o)},lchmod(e,n){l.chmod(e,n,!0)},fchmod(e,n){var o=l.getStreamChecked(e);l.doChmod(o,o.node,n,!1)},doChown(e,n,o){l.doSetAttr(e,n,{timestamp:Date.now(),dontFollow:o})},chown(e,n,o,i){var t;if(typeof e=="string"){var r=l.lookupPath(e,{follow:!i});t=r.node}else t=e;l.doChown(null,t,i)},lchown(e,n,o){l.chown(e,n,o,!0)},fchown(e,n,o){var i=l.getStreamChecked(e);l.doChown(i,i.node,!1)},doTruncate(e,n,o){if(l.isDir(n.mode))throw new l.ErrnoError(31);if(!l.isFile(n.mode))throw new l.ErrnoError(28);var i=l.nodePermissions(n,"w");if(i)throw new l.ErrnoError(i);l.doSetAttr(e,n,{size:o,timestamp:Date.now()})},truncate(e,n){if(n<0)throw new l.ErrnoError(28);var o;if(typeof e=="string"){var i=l.lookupPath(e,{follow:!0});o=i.node}else o=e;l.doTruncate(null,o,n)},ftruncate(e,n){var o=l.getStreamChecked(e);if(n<0||(o.flags&2097155)===0)throw new l.ErrnoError(28);l.doTruncate(o,o.node,n)},utime(e,n,o,i){var t=l.lookupPath(e,{follow:!i});l.doSetAttr(null,t.node,{atime:n,mtime:o,dontFollow:i})},open(e,n,o=438){if(e==="")throw new l.ErrnoError(44);if(n=mr(n),n&64)o=o&4095|32768;else o=0;var i,t;if(typeof e=="object")i=e;else{t=e.endsWith("/");var r=l.lookupPath(e,{follow:!(n&131072),noent_okay:!0});i=r.node,e=r.path}var a=!1;if(n&64)if(i){if(n&128)throw new l.ErrnoError(20)}else if(t)throw new l.ErrnoError(31);else i=l.mknod(e,o|511,0),a=!0;if(!i)throw new l.ErrnoError(44);if(l.isChrdev(i.mode))n&=-513;if(n&65536&&!l.isDir(i.mode))throw new l.ErrnoError(54);if(!a){var _=l.mayOpen(i,n);if(_)throw new l.ErrnoError(_)}if(n&512&&!a)l.truncate(i,0);n&=-131713;var h=l.createStream({node:i,path:l.getPath(i),flags:n,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});if(h.stream_ops.open)h.stream_ops.open(h);if(a)l.chmod(i,o&511);return h},close(e){if(l.isClosed(e))throw new l.ErrnoError(8);if(e.getdents)e.getdents=null;e.node?.notifyListeners(32);try{if(e.stream_ops.close)e.stream_ops.close(e)}catch(n){throw n}finally{l.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,n,o){if(l.isClosed(e))throw new l.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new l.ErrnoError(70);if(o!=0&&o!=1&&o!=2)throw new l.ErrnoError(28);return e.position=e.stream_ops.llseek(e,n,o),e.ungotten=[],e.position},read(e,n,o,i,t){if(i<0||t<0)throw new l.ErrnoError(28);if(l.isClosed(e))throw new l.ErrnoError(8);if((e.flags&2097155)===1)throw new l.ErrnoError(8);if(l.isDir(e.node.mode))throw new l.ErrnoError(31);if(!e.stream_ops.read)throw new l.ErrnoError(28);var r=typeof t<"u";if(!r)t=e.position;else if(!e.seekable)throw new l.ErrnoError(70);var a=e.stream_ops.read(e,n,o,i,t);if(!r)e.position+=a;return a},write(e,n,o,i,t,r){if(i<0||t<0)throw new l.ErrnoError(28);if(l.isClosed(e))throw new l.ErrnoError(8);if((e.flags&2097155)===0)throw new l.ErrnoError(8);if(l.isDir(e.node.mode))throw new l.ErrnoError(31);if(!e.stream_ops.write)throw new l.ErrnoError(28);if(e.seekable&&e.flags&1024)l.llseek(e,0,2);var a=typeof t<"u";if(!a)t=e.position;else if(!e.seekable)throw new l.ErrnoError(70);var _=e.stream_ops.write(e,n,o,i,t,r);if(!a)e.position+=_;return _},mmap(e,n,o,i,t){if((i&2)!==0&&(t&2)===0&&(e.flags&2097155)!==2)throw new l.ErrnoError(2);if((e.flags&2097155)===1)throw new l.ErrnoError(2);if(!e.stream_ops.mmap)throw new l.ErrnoError(43);if(!n)throw new l.ErrnoError(28);return e.stream_ops.mmap(e,n,o,i,t)},msync(e,n,o,i,t){if(!e.stream_ops.msync)return 0;return e.stream_ops.msync(e,n,o,i,t)},ioctl(e,n,o){if(!e.stream_ops.ioctl)throw new l.ErrnoError(59);return e.stream_ops.ioctl(e,n,o)},readFile(e,n={}){if(n.flags=n.flags??0,n.encoding=n.encoding??"binary",n.encoding!=="utf8"&&n.encoding!=="binary")Ke(`Invalid encoding type "${n.encoding}"`);var o=l.open(e,n.flags),i=l.stat(e),t=i.size,r=new Uint8Array(t);if(l.read(o,r,0,t,0),n.encoding==="utf8")r=bt(r);return l.close(o),r},writeFile(e,n,o={}){o.flags=o.flags??577;var i=l.open(e,o.flags,o.mode);n=cn(n),l.write(i,n,0,n.byteLength,void 0,o.canOwn),l.close(i)},cwd:()=>l.currentPath,chdir(e){var n=l.lookupPath(e,{follow:!0});if(n.node===null)throw new l.ErrnoError(44);if(!l.isDir(n.node.mode))throw new l.ErrnoError(54);var o=l.nodePermissions(n.node,"x");if(o)throw new l.ErrnoError(o);l.currentPath=n.path},createDefaultDirectories(){l.mkdir("/tmp"),l.mkdir("/home"),l.mkdir("/home/web_user")},createDefaultDevices(){l.mkdir("/dev"),l.registerDevice(l.makedev(1,3),{read:()=>0,write:(i,t,r,a,_)=>a,llseek:()=>0}),l.mkdev("/dev/null",l.makedev(1,3)),it.register(l.makedev(5,0),it.default_tty_ops),it.register(l.makedev(6,0),it.default_tty1_ops),l.mkdev("/dev/tty",l.makedev(5,0)),l.mkdev("/dev/tty1",l.makedev(6,0));var e=new Uint8Array(1024),n=0,o=()=>{if(n===0)nn(e),n=e.byteLength;return e[--n]};l.createDevice("/dev","random",o),l.createDevice("/dev","urandom",o),l.mkdir("/dev/shm"),l.mkdir("/dev/shm/tmp")},createSpecialDirectories(){l.mkdir("/proc");var e=l.mkdir("/proc/self");l.mkdir("/proc/self/fd"),l.mount({mount(){var n=l.createNode(e,"fd",16895,73);return n.stream_ops={llseek:ye.stream_ops.llseek},n.node_ops={lookup(o,i){var t=+i,r=l.getStreamChecked(t),a={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path},id:t+1};return a.parent=a,a},readdir(){return Array.from(l.streams.entries()).filter(([o,i])=>i).map(([o,i])=>o.toString())}},n}},{},"/proc/self/fd")},createStandardStreams(e,n,o){if(e)l.createDevice("/dev","stdin",e);else l.symlink("/dev/tty","/dev/stdin");if(n)l.createDevice("/dev","stdout",null,n);else l.symlink("/dev/tty","/dev/stdout");if(o)l.createDevice("/dev","stderr",null,o);else l.symlink("/dev/tty1","/dev/stderr");var i=l.open("/dev/stdin",0),t=l.open("/dev/stdout",1),r=l.open("/dev/stderr",1)},staticInit(){l.nameTable=Array(4096),l.mount(ye,{},"/"),l.createDefaultDirectories(),l.createDefaultDevices(),l.createSpecialDirectories(),l.filesystems={MEMFS:ye}},init(e,n,o){l.initialized=!0,e??=s.stdin,n??=s.stdout,o??=s.stderr,l.createStandardStreams(e,n,o)},quit(){l.initialized=!1;for(var e of l.streams)if(e)l.close(e)},findObject(e,n){var o=l.analyzePath(e,n);if(!o.exists)return null;return o.object},analyzePath(e,n){try{var o=l.lookupPath(e,{follow:!n});e=o.path}catch(t){}var i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var o=l.lookupPath(e,{parent:!0});i.parentExists=!0,i.parentPath=o.path,i.parentObject=o.node,i.name=Te.basename(e),o=l.lookupPath(e,{follow:!n}),i.exists=!0,i.path=o.path,i.object=o.node,i.name=o.node.name,i.isRoot=o.path==="/"}catch(t){i.error=t.errno}return i},createPath(e,n,o,i){e=typeof e=="string"?e:l.getPath(e);var t=n.split("/").reverse();while(t.length){var r=t.pop();if(!r)continue;var a=Te.join2(e,r);try{l.mkdir(a)}catch(_){if(_.errno!=20)throw _}e=a}return a},createFile(e,n,o,i,t){var r=Te.join2(typeof e=="string"?e:l.getPath(e),n),a=Dt(i,t);return l.create(r,a)},createDataFile(e,n,o,i,t,r){var a=n;if(e)e=typeof e=="string"?e:l.getPath(e),a=n?Te.join2(e,n):e;var _=Dt(i,t),h=l.create(a,_);if(o){o=cn(o),l.chmod(h,_|146);var I=l.open(h,577);l.write(I,o,0,o.length,0,r),l.close(I),l.chmod(h,_)}},createDevice(e,n,o,i){var t=Te.join2(typeof e=="string"?e:l.getPath(e),n),r=Dt(!!o,!!i);l.createDevice.major??=64;var a=l.makedev(l.createDevice.major++,0);return l.registerDevice(a,{open(_){_.seekable=!1},close(_){if(i?.buffer?.length)i(10)},read(_,h,I,q,R){var M=0;for(var p=0;p<q;p++){var te;try{te=o()}catch(j){throw new l.ErrnoError(29)}if(te===void 0&&M===0)throw new l.ErrnoError(6);if(te===null||te===void 0)break;M++,h[I+p]=te}if(M)_.node.atime=Date.now();return M},write(_,h,I,q,R){for(var M=0;M<q;M++)try{i(h[I+M])}catch(p){throw new l.ErrnoError(29)}if(q)_.node.mtime=_.node.ctime=Date.now();return M}}),l.mkdev(t,r,a)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)Ke("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=St(e.url)}catch(n){throw new l.ErrnoError(29)}},createLazyFile(e,n,o,i,t){class r{lengthKnown=!1;chunks=[];get(R){if(R>this.length-1||R<0)return;var M=R%this.chunkSize,p=R/this.chunkSize|0;return this.getter(p)[M]}setDataGetter(R){this.getter=R}cacheLength(){var R=new XMLHttpRequest;if(R.open("HEAD",o,!1),R.send(null),!(R.status>=200&&R.status<300||R.status===304))Ke("Couldn't load "+o+". Status: "+R.status);var M=Number(R.getResponseHeader("Content-length")),p,te=(p=R.getResponseHeader("Accept-Ranges"))&&p==="bytes",j=(p=R.getResponseHeader("Content-Encoding"))&&p==="gzip",U=1048576;if(!te)U=M;var E=(F,x)=>{if(F>x)Ke(`invalid range (${F}, ${x}) or no bytes requested!`);if(x>M-1)Ke(`only ${M} bytes available! programmer error!`);var A=new XMLHttpRequest;if(A.open("GET",o,!1),M!==U)A.setRequestHeader("Range","bytes="+F+"-"+x);if(A.responseType="arraybuffer",A.overrideMimeType)A.overrideMimeType("text/plain; charset=x-user-defined");if(A.send(null),!(A.status>=200&&A.status<300||A.status===304))Ke("Couldn't load "+o+". Status: "+A.status);if(A.response!==void 0)return new Uint8Array(A.response||[]);return Nt(A.responseText??"",!0)},g=this;if(g.setDataGetter((F)=>{var x=F*U,A=(F+1)*U-1;if(A=Math.min(A,M-1),typeof g.chunks[F]>"u")g.chunks[F]=E(x,A);if(typeof g.chunks[F]>"u")Ke("doXHR failed!");return g.chunks[F]}),j||!M)U=M=1,M=this.getter(0).length,U=M,wt("LazyFiles on gzip forces download of the whole file when length is accessed");this._length=M,this._chunkSize=U,this.lengthKnown=!0}get length(){if(!this.lengthKnown)this.cacheLength();return this._length}get chunkSize(){if(!this.lengthKnown)this.cacheLength();return this._chunkSize}}if(globalThis.XMLHttpRequest){if(!ne)Ke("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var a=new r,_={isDevice:!1,contents:a}}else var _={isDevice:!1,url:o};var h=l.createFile(e,n,_,i,t);if(_.contents)h.contents=_.contents;else if(_.url)h.contents=null,h.url=_.url;Object.defineProperties(h,{usedBytes:{get:function(){return this.contents.length}}});var I={};for(let[R,M]of Object.entries(h.stream_ops))I[R]=(...p)=>(l.forceLoadFile(h),M(...p));function q(R,M,p,te,j){var U=R.node.contents;if(j>=U.length)return 0;var E=Math.min(U.length-j,te);if(U.slice)for(var g=0;g<E;g++)M[p+g]=U[j+g];else for(var g=0;g<E;g++)M[p+g]=U.get(j+g);return E}return I.read=(R,M,p,te,j)=>(l.forceLoadFile(h),q(R,M,p,te,j)),I.mmap=(R,M,p,te,j)=>{l.forceLoadFile(h);var U=ln(M);if(!U)throw new l.ErrnoError(48);return q(R,Be,U,M,p),{ptr:U,allocated:!0}},h.stream_ops=I,h}},Ar=(e,n,o)=>{if(!e)return"";var i=sn(Ze,e,n,o);return rn.decode(Ze.subarray(e,i))},ve={currentUmask:18,calculateAt(e,n,o){if(Te.isAbs(n))return n;var i;if(e===-100)i=l.cwd();else{var t=ve.getStreamFromFD(e);i=t.path}if(n.length==0){if(!o)throw new l.ErrnoError(44);return i}return i+"/"+n},writeStat(e,n){ke[e>>2]=n.dev,ke[e+4>>2]=n.mode,ke[e+8>>2]=n.nlink,ke[e+12>>2]=n.uid,ke[e+16>>2]=n.gid,ke[e+20>>2]=n.rdev,ze[e+24>>3]=BigInt(n.size),Ie[e+32>>2]=4096,Ie[e+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),t=n.ctime.getTime();return ze[e+40>>3]=BigInt(Math.floor(o/1000)),ke[e+48>>2]=o%1000*1000*1000,ze[e+56>>3]=BigInt(Math.floor(i/1000)),ke[e+64>>2]=i%1000*1000*1000,ze[e+72>>3]=BigInt(Math.floor(t/1000)),ke[e+80>>2]=t%1000*1000*1000,ze[e+88>>3]=BigInt(n.ino),0},writeStatFs(e,n){ke[e+4>>2]=n.bsize,ke[e+60>>2]=n.bsize,ze[e+8>>3]=BigInt(n.blocks),ze[e+16>>3]=BigInt(n.bfree),ze[e+24>>3]=BigInt(n.bavail),ze[e+32>>3]=BigInt(n.files),ze[e+40>>3]=BigInt(n.ffree),ke[e+48>>2]=n.fsid,ke[e+64>>2]=n.flags,ke[e+56>>2]=n.namelen},doMsync(e,n,o,i,t){if(!l.isFile(n.node.mode))throw new l.ErrnoError(43);if(i&2)return 0;var r=Ze.subarray(e,e+o);l.msync(n,r,t,o,i)},getStreamFromFD(e){var n=l.getStreamChecked(e);return n},varargs:void 0,getStr(e){var n=Ar(e);return n}};function Ir(e,n){try{return e=ve.getStr(e),l.chmod(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function xr(e,n,o,i){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),o&-8)return-28;var t=l.lookupPath(n,{follow:!0}),r=t.node;if(!r)return-44;var a="";if(o&4)a+="r";if(o&2)a+="w";if(o&1)a+="x";if(a&&l.nodePermissions(r,a))return-2;return 0}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function Tr(e,n){try{return l.fchmod(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Or(e,n,o){try{return l.fchown(e,n,o),0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var kt=()=>{var e=Ie[+ve.varargs>>2];return ve.varargs+=4,e},ft=kt;function Pr(e,n,o){ve.varargs=o;try{var i=ve.getStreamFromFD(e);switch(n){case 0:{var t=kt();if(t<0)return-28;while(l.streams[t])t++;var r=l.dupStream(i,t);return r.fd}case 1:case 2:return 0;case 3:return i.flags;case 4:{var t=kt(),a=289792;return i.flags=i.flags&~a|t&a,0}case 12:{var t=ft(),_=0;return at[t+_>>1]=2,0}case 13:case 14:return 0}return-28}catch(h){if(typeof l>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function Fr(e,n){try{return ve.writeStat(n,l.fstat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var Lr=9007199254740992,Cr=-9007199254740992,dt=(e)=>e<Cr||e>Lr?NaN:Number(e);function Nr(e,n){n=dt(n);try{if(isNaN(n))return-22;return l.ftruncate(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var ct=(e,n,o)=>on(e,Ze,n,o);function Dr(e,n){try{if(n===0)return-28;var o=l.cwd(),i=Et(o)+1;if(n<i)return-68;return ct(o,e,n),i}catch(t){if(typeof l>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function Rr(e,n,o){ve.varargs=o;try{var i=ve.getStreamFromFD(e);switch(n){case 21509:{if(!i.tty)return-59;return 0}case 21505:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcgets){var t=i.tty.ops.ioctl_tcgets(i),r=ft();Ie[r>>2]=t.c_iflag||0,Ie[r+4>>2]=t.c_oflag||0,Ie[r+8>>2]=t.c_cflag||0,Ie[r+12>>2]=t.c_lflag||0;for(var a=0;a<32;a++)Be[r+a+17]=t.c_cc[a]||0;return 0}return 0}case 21510:case 21511:case 21512:{if(!i.tty)return-59;return 0}case 21506:case 21507:case 21508:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcsets){var r=ft(),_=Ie[r>>2],h=Ie[r+4>>2],I=Ie[r+8>>2],q=Ie[r+12>>2],R=[];for(var a=0;a<32;a++)R.push(Be[r+a+17]);return i.tty.ops.ioctl_tcsets(i.tty,n,{c_iflag:_,c_oflag:h,c_cflag:I,c_lflag:q,c_cc:R})}return 0}case 21519:{if(!i.tty)return-59;var r=ft();return Ie[r>>2]=0,0}case 21520:{if(!i.tty)return-59;return-28}case 21537:case 21531:{var r=ft();return l.ioctl(i,n,r)}case 21523:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tiocgwinsz){var M=i.tty.ops.ioctl_tiocgwinsz(i.tty),r=ft();at[r>>1]=M[0],at[r+2>>1]=M[1]}return 0}case 21524:{if(!i.tty)return-59;return 0}case 21515:{if(!i.tty)return-59;return 0}default:return-28}}catch(p){if(typeof l>"u"||p.name!=="ErrnoError")throw p;return-p.errno}}function Mr(e,n){try{return e=ve.getStr(e),ve.writeStat(n,l.lstat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function jr(e,n,o){try{return n=ve.getStr(n),n=ve.calculateAt(e,n),o&=~ve.currentUmask,l.mkdir(n,o,0),0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Wr(e,n,o,i){try{n=ve.getStr(n);var t=i&256,r=i&4096;return i=i&-6401,n=ve.calculateAt(e,n,r),ve.writeStat(o,t?l.lstat(n):l.stat(n))}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function zr(e,n,o,i){ve.varargs=i;try{n=ve.getStr(n),n=ve.calculateAt(e,n);var t=i?kt():0;if(o&64)t&=~ve.currentUmask;return l.open(n,o,t).fd}catch(r){if(typeof l>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function Br(e,n,o,i){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),i<=0)return-28;var t=l.readlink(n),r=Math.min(i,Et(t)),a=Be[o+r];return ct(t,o,i+1),Be[o+r]=a,r}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function Ur(e){try{return e=ve.getStr(e),l.rmdir(e),0}catch(n){if(typeof l>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function Qr(e,n){try{return e=ve.getStr(e),ve.writeStat(n,l.stat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Vr(e,n,o){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),!o)l.unlink(n);else if(o===512)l.rmdir(n);else return-28;return 0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var dn=(e)=>ke[e>>2]+Ie[e+4>>2]*4294967296;function Hr(e,n,o,i){try{var t=i&256;n=ve.getStr(n),n=ve.calculateAt(e,n,!0);var r=Date.now(),a,_;if(!o)a=r,_=r;else{var h=dn(o),I=Ie[o+8>>2];if(I==1073741823)a=r;else if(I==1073741822)a=null;else a=h*1000+I/1e6;if(o+=16,h=dn(o),I=Ie[o+8>>2],I==1073741823)_=r;else if(I==1073741822)_=null;else _=h*1000+I/1e6}if((_??a)!==null)l.utime(n,a,_,t);return 0}catch(q){if(typeof l>"u"||q.name!=="ErrnoError")throw q;return-q.errno}}var Gr=()=>Ke(""),Kr=(e)=>e%4===0&&(e%100!==0||e%400===0),$r=[0,31,60,91,121,152,182,213,244,274,305,335],Jr=[0,31,59,90,120,151,181,212,243,273,304,334],Xr=(e)=>{var n=Kr(e.getFullYear()),o=n?$r:Jr,i=o[e.getMonth()]+e.getDate()-1;return i};function Yr(e,n){e=dt(e);var o=new Date(e*1000);if(isNaN(o.getTime()))return 1;Ie[n>>2]=o.getSeconds(),Ie[n+4>>2]=o.getMinutes(),Ie[n+8>>2]=o.getHours(),Ie[n+12>>2]=o.getDate(),Ie[n+16>>2]=o.getMonth(),Ie[n+20>>2]=o.getFullYear()-1900,Ie[n+24>>2]=o.getDay();var i=Xr(o)|0;Ie[n+28>>2]=i,Ie[n+36>>2]=-(o.getTimezoneOffset()*60);var t=new Date(o.getFullYear(),0,1),r=new Date(o.getFullYear(),6,1).getTimezoneOffset(),a=t.getTimezoneOffset(),_=(r!=a&&o.getTimezoneOffset()==Math.min(a,r))|0;return Ie[n+32>>2]=_,0}function Zr(e,n,o,i,t,r,a){t=dt(t);try{var _=ve.getStreamFromFD(i),h=l.mmap(_,e,t,n,o),I=h.ptr;return Ie[r>>2]=h.allocated,ke[a>>2]=I,0}catch(q){if(typeof l>"u"||q.name!=="ErrnoError")throw q;return-q.errno}}function ei(e,n,o,i,t,r){r=dt(r);try{var a=ve.getStreamFromFD(t);if(o&2)ve.doMsync(e,a,n,i,r)}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}var ti=(e,n,o,i)=>{var t=new Date().getFullYear(),r=new Date(t,0,1),a=new Date(t,6,1),_=r.getTimezoneOffset(),h=a.getTimezoneOffset(),I=Math.max(_,h);ke[e>>2]=I*60,Ie[n>>2]=Number(_!=h);var q=(p)=>{var te=p>=0?"-":"+",j=Math.abs(p),U=String(Math.floor(j/60)).padStart(2,"0"),E=String(j%60).padStart(2,"0");return`UTC${te}${U}${E}`},R=q(_),M=q(h);if(h<_)ct(R,o,17),ct(M,i,17);else ct(R,i,17),ct(M,o,17)},pn=()=>performance.now(),hn=()=>Date.now(),ni=1,ri=(e)=>e>=0&&e<=3;function ii(e,n,o){if(n=dt(n),!ri(e))return 28;var i;if(e===0)i=hn();else if(ni)i=pn();else return 52;var t=Math.round(i*1000*1000);return ze[o>>3]=BigInt(t),0}var mn=()=>2147483648,si=()=>mn(),oi=(e)=>{var n=et.buffer.byteLength,o=(e-n+65535)/65536|0;try{return et.grow(o),Xt(),1}catch(i){}},ai=(e)=>{var n=Ze.length;e>>>=0;var o=mn();if(e>o)return!1;for(var i=1;i<=4;i*=2){var t=n*(1+0.2/i);t=Math.min(t,e+100663296);var r=Math.min(o,an(Math.max(e,t),65536)),a=oi(r);if(a)return!0}return!1},Rt={},li=()=>Ve,yt=()=>{if(!yt.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",n={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:li()};for(var o in Rt)if(Rt[o]===void 0)delete n[o];else n[o]=Rt[o];var i=[];for(var o in n)i.push(`${o}=${n[o]}`);yt.strings=i}return yt.strings},ci=(e,n)=>{var o=0,i=0;for(var t of yt()){var r=n+o;ke[e+i>>2]=r,o+=ct(t,r,1/0)+1,i+=4}return 0},_i=(e,n)=>{var o=yt();ke[e>>2]=o.length;var i=0;for(var t of o)i+=Et(t)+1;return ke[n>>2]=i,0},ui=0,fi=()=>tn||ui>0,di=(e)=>{if($t=e,!fi())s.onExit?.(e),Tt=!0;nt(e,new Zt(e))},pi=(e,n)=>{$t=e,di(e)},hi=pi;function mi(e){try{var n=ve.getStreamFromFD(e);return l.close(n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return o.errno}}function gi(e,n){try{var o=0,i=0,t=0,r=ve.getStreamFromFD(e),a=r.tty?2:l.isDir(r.mode)?3:l.isLink(r.mode)?7:4;return Be[n]=a,at[n+2>>1]=t,ze[n+8>>3]=BigInt(o),ze[n+16>>3]=BigInt(i),0}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return _.errno}}var bi=(e,n,o,i)=>{var t=0;for(var r=0;r<o;r++){var a=ke[n>>2],_=ke[n+4>>2];n+=8;try{var h=l.read(e,Be,a,_,i)}catch(I){if(t>0&&I instanceof l.ErrnoError&&(I.errno==6||I.errno==6))break;throw I}if(h<0)return-1;if(t+=h,h<_)break;if(typeof i<"u")i+=h}return t};function yi(e,n,o,i){try{var t=ve.getStreamFromFD(e),r=bi(t,n,o);return ke[i>>2]=r,0}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return a.errno}}function qi(e,n,o,i){n=dt(n);try{if(isNaN(n))return 22;var t=ve.getStreamFromFD(e);if(l.llseek(t,n,o),ze[i>>3]=BigInt(t.position),t.getdents&&n===0&&o===0)t.getdents=null;return 0}catch(r){if(typeof l>"u"||r.name!=="ErrnoError")throw r;return r.errno}}function vi(e){try{var n=ve.getStreamFromFD(e),o=n.stream_ops?.fsync?.(n);return o}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return i.errno}}var Si=(e,n,o,i)=>{if(o==1)return l.write(e,Be,ke[n>>2],ke[n+4>>2],i);var t=0;for(var r=0,a=n;r<o;r++,a+=8)t+=ke[a+4>>2];var _=new Uint8Array(t),h=0;for(var r=0;r<o;r++,n+=8){var I=ke[n>>2],q=ke[n+4>>2];_.set(Ze.subarray(I,I+q),h),h+=q}return l.write(e,_,0,t,i)};function wi(e,n,o,i){try{var t=ve.getStreamFromFD(e),r=Si(t,n,o);return ke[i>>2]=r,0}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return a.errno}}l.createPreloadedFile=kr,l.preloadFile=fn,l.staticInit();{if(er(),s.noExitRuntime)tn=s.noExitRuntime;if(s.print)wt=s.print;if(s.printErr)rt=s.printErr;if(s.arguments)We=s.arguments;if(s.thisProgram)Ve=s.thisProgram;var pt=s.preInit;if(pt){if(typeof pt=="function")s.preInit=pt=[pt];while(pt.length>0)pt.shift()()}}s.wasmMemory=et;function Ei(e,n){if(typeof crypto>"u"||!crypto.getRandomValues)return-1;try{var o=new Uint8Array(Ze.buffer,e,n),i=65536;for(var t=0;t<n;t+=i)crypto.getRandomValues(o.subarray(t,Math.min(t+i,n)));return 0}catch(r){return-1}}var ki,Ai,Ii,xi,Ti,Oi,Pi,Fi,Li,Ci,Ni,Di,Ri,Mi,ji,Wi,zi,Bi,Ui,Qi,Vi,Hi,Gi,Ki,$i,Ji,Xi,Yi,Zi,es,ts,ns,rs,is,ss,os,as,ls,cs,_s,us,fs,ds,ps,hs,ms,gs,bs,ys,qs,vs,Ss,ws,Es,ks,As,Is,xs,Ts,Os,Ps,Fs,Ls,Cs,Ns,Ds,Rs,Ms,js,Ws,zs,Bs,Us,Qs,Vs,Hs,Gs,Ks,$s,Js,Xs,Ys,Zs,eo,to,no,ro,io,so,oo,ao,lo,co,_o,uo,fo,po,ho,mo,go,bo,yo,qo,vo,So,wo,Eo,ko,Ao,Io,xo,To,Oo,Po,Fo,Lo,Co,No,Do,Ro,Mo,jo,Wo,zo,Bo,Uo,Qo,Vo,Ho,Go,Ko,$o,Jo,Xo,Yo,Zo,ea,ta,na,ra,ia,sa,oa,aa,la,ca,_a,ua,fa,da,pa,ha,ma,ga,ba,ya,qa,va,Sa,wa,Ea,ka,Aa,Ia,xa,Ta,Oa,Pa,Fa,La,Ca,Na,Da,Ra,Ma,ja,Wa,za,Ba,Ua,Qa,Va,Ha,Ga,Ka,$a,Ja,Xa,Ya,Za,el,tl,nl,rl,il,sl,ol,al,ll,cl,_l,ul,fl,dl,pl,hl,ml,gl,bl,yl,ql,vl,Sl,wl,El,kl,Al,Il,xl,Tl,Ol,Pl,Fl,Ll,Cl,Nl,Dl,Rl,Ml,jl,Wl,zl,Bl,Ul,Ql,Vl,Hl,Gl,Kl,$l,Jl,Xl,Yl,Zl,ec,tc,nc,rc,ic,sc,oc,ac,lc,cc,_c,uc,fc,dc,pc,hc,mc,gc,bc,yc,qc,vc,Sc,wc,Ec,kc,Ac,Ic,xc,Tc,Oc,Pc,Fc,gn,bn,Lc,yn,Cc;function Nc(e){ki=s._sqlite3_status64=e.sqlite3_status64,Ai=s._sqlite3_status=e.sqlite3_status,Ii=s._sqlite3_db_status64=e.sqlite3_db_status64,xi=s._sqlite3_msize=e.sqlite3_msize,Ti=s._sqlite3_db_status=e.sqlite3_db_status,Oi=s._sqlite3_vfs_find=e.sqlite3_vfs_find,Pi=s._sqlite3_initialize=e.sqlite3_initialize,Fi=s._sqlite3_vfs_register=e.sqlite3_vfs_register,Li=s._sqlite3_vfs_unregister=e.sqlite3_vfs_unregister,Ci=s._sqlite3_malloc=e.sqlite3_malloc,Ni=s._sqlite3_malloc64=e.sqlite3_malloc64,Di=s._sqlite3_free=e.sqlite3_free,Ri=s._sqlite3_realloc=e.sqlite3_realloc,Mi=s._sqlite3_realloc64=e.sqlite3_realloc64,ji=s._sqlite3_value_text=e.sqlite3_value_text,Wi=s._sqlite3_randomness=e.sqlite3_randomness,zi=s._sqlite3_stricmp=e.sqlite3_stricmp,Bi=s._sqlite3_strnicmp=e.sqlite3_strnicmp,Ui=s._sqlite3_uri_parameter=e.sqlite3_uri_parameter,Qi=s._sqlite3_uri_boolean=e.sqlite3_uri_boolean,Vi=s._sqlite3_serialize=e.sqlite3_serialize,Hi=s._sqlite3_prepare_v2=e.sqlite3_prepare_v2,Gi=s._sqlite3_step=e.sqlite3_step,Ki=s._sqlite3_column_int64=e.sqlite3_column_int64,$i=s._sqlite3_reset=e.sqlite3_reset,Ji=s._sqlite3_exec=e.sqlite3_exec,Xi=s._sqlite3_column_int=e.sqlite3_column_int,Yi=s._sqlite3_finalize=e.sqlite3_finalize,Zi=s._sqlite3_file_control=e.sqlite3_file_control,es=s._sqlite3_column_name=e.sqlite3_column_name,ts=s._sqlite3_column_text=e.sqlite3_column_text,ns=s._sqlite3_column_type=e.sqlite3_column_type,rs=s._sqlite3_errmsg=e.sqlite3_errmsg,is=s._sqlite3_deserialize=e.sqlite3_deserialize,ss=s._sqlite3_backup_init=e.sqlite3_backup_init,os=s._sqlite3_backup_step=e.sqlite3_backup_step,as=s._sqlite3_backup_finish=e.sqlite3_backup_finish,ls=s._sqlite3_backup_remaining=e.sqlite3_backup_remaining,cs=s._sqlite3_backup_pagecount=e.sqlite3_backup_pagecount,_s=s._sqlite3_clear_bindings=e.sqlite3_clear_bindings,us=s._sqlite3_value_blob=e.sqlite3_value_blob,fs=s._sqlite3_value_bytes=e.sqlite3_value_bytes,ds=s._sqlite3_value_double=e.sqlite3_value_double,ps=s._sqlite3_value_int=e.sqlite3_value_int,hs=s._sqlite3_value_int64=e.sqlite3_value_int64,ms=s._sqlite3_value_subtype=e.sqlite3_value_subtype,gs=s._sqlite3_value_pointer=e.sqlite3_value_pointer,bs=s._sqlite3_value_type=e.sqlite3_value_type,ys=s._sqlite3_value_nochange=e.sqlite3_value_nochange,qs=s._sqlite3_value_frombind=e.sqlite3_value_frombind,vs=s._sqlite3_value_dup=e.sqlite3_value_dup,Ss=s._sqlite3_value_free=e.sqlite3_value_free,ws=s._sqlite3_result_blob=e.sqlite3_result_blob,Es=s._sqlite3_result_error_toobig=e.sqlite3_result_error_toobig,ks=s._sqlite3_result_error_nomem=e.sqlite3_result_error_nomem,As=s._sqlite3_result_double=e.sqlite3_result_double,Is=s._sqlite3_result_error=e.sqlite3_result_error,xs=s._sqlite3_result_int=e.sqlite3_result_int,Ts=s._sqlite3_result_int64=e.sqlite3_result_int64,Os=s._sqlite3_result_null=e.sqlite3_result_null,Ps=s._sqlite3_result_pointer=e.sqlite3_result_pointer,Fs=s._sqlite3_result_subtype=e.sqlite3_result_subtype,Ls=s._sqlite3_result_text=e.sqlite3_result_text,Cs=s._sqlite3_result_zeroblob=e.sqlite3_result_zeroblob,Ns=s._sqlite3_result_zeroblob64=e.sqlite3_result_zeroblob64,Ds=s._sqlite3_result_error_code=e.sqlite3_result_error_code,Rs=s._sqlite3_user_data=e.sqlite3_user_data,Ms=s._sqlite3_context_db_handle=e.sqlite3_context_db_handle,js=s._sqlite3_vtab_nochange=e.sqlite3_vtab_nochange,Ws=s._sqlite3_vtab_in_first=e.sqlite3_vtab_in_first,zs=s._sqlite3_vtab_in_next=e.sqlite3_vtab_in_next,Bs=s._sqlite3_aggregate_context=e.sqlite3_aggregate_context,Us=s._sqlite3_get_auxdata=e.sqlite3_get_auxdata,Qs=s._sqlite3_set_auxdata=e.sqlite3_set_auxdata,Vs=s._sqlite3_column_count=e.sqlite3_column_count,Hs=s._sqlite3_data_count=e.sqlite3_data_count,Gs=s._sqlite3_column_blob=e.sqlite3_column_blob,Ks=s._sqlite3_column_bytes=e.sqlite3_column_bytes,$s=s._sqlite3_column_double=e.sqlite3_column_double,Js=s._sqlite3_column_value=e.sqlite3_column_value,Xs=s._sqlite3_column_decltype=e.sqlite3_column_decltype,Ys=s._sqlite3_column_database_name=e.sqlite3_column_database_name,Zs=s._sqlite3_column_table_name=e.sqlite3_column_table_name,eo=s._sqlite3_column_origin_name=e.sqlite3_column_origin_name,to=s._sqlite3_bind_blob=e.sqlite3_bind_blob,no=s._sqlite3_bind_double=e.sqlite3_bind_double,ro=s._sqlite3_bind_int=e.sqlite3_bind_int,io=s._sqlite3_bind_int64=e.sqlite3_bind_int64,so=s._sqlite3_bind_null=e.sqlite3_bind_null,oo=s._sqlite3_bind_pointer=e.sqlite3_bind_pointer,ao=s._sqlite3_bind_text=e.sqlite3_bind_text,lo=s._sqlite3_bind_zeroblob=e.sqlite3_bind_zeroblob,co=s._sqlite3_bind_parameter_count=e.sqlite3_bind_parameter_count,_o=s._sqlite3_bind_parameter_name=e.sqlite3_bind_parameter_name,uo=s._sqlite3_bind_parameter_index=e.sqlite3_bind_parameter_index,fo=s._sqlite3_db_handle=e.sqlite3_db_handle,po=s._sqlite3_stmt_readonly=e.sqlite3_stmt_readonly,ho=s._sqlite3_stmt_isexplain=e.sqlite3_stmt_isexplain,mo=s._sqlite3_stmt_explain=e.sqlite3_stmt_explain,go=s._sqlite3_stmt_busy=e.sqlite3_stmt_busy,bo=s._sqlite3_next_stmt=e.sqlite3_next_stmt,yo=s._sqlite3_stmt_status=e.sqlite3_stmt_status,qo=s._sqlite3_sql=e.sqlite3_sql,vo=s._sqlite3_expanded_sql=e.sqlite3_expanded_sql,So=s._sqlite3_preupdate_old=e.sqlite3_preupdate_old,wo=s._sqlite3_preupdate_count=e.sqlite3_preupdate_count,Eo=s._sqlite3_preupdate_depth=e.sqlite3_preupdate_depth,ko=s._sqlite3_preupdate_blobwrite=e.sqlite3_preupdate_blobwrite,Ao=s._sqlite3_preupdate_new=e.sqlite3_preupdate_new,Io=s._sqlite3_value_numeric_type=e.sqlite3_value_numeric_type,xo=s._sqlite3_set_authorizer=e.sqlite3_set_authorizer,To=s._sqlite3_strglob=e.sqlite3_strglob,Oo=s._sqlite3_strlike=e.sqlite3_strlike,Po=s._sqlite3_auto_extension=e.sqlite3_auto_extension,Fo=s._sqlite3_cancel_auto_extension=e.sqlite3_cancel_auto_extension,Lo=s._sqlite3_reset_auto_extension=e.sqlite3_reset_auto_extension,Co=s._sqlite3_prepare_v3=e.sqlite3_prepare_v3,No=s._sqlite3_create_module=e.sqlite3_create_module,Do=s._sqlite3_create_module_v2=e.sqlite3_create_module_v2,Ro=s._sqlite3_drop_modules=e.sqlite3_drop_modules,Mo=s._sqlite3_declare_vtab=e.sqlite3_declare_vtab,jo=s._sqlite3_vtab_on_conflict=e.sqlite3_vtab_on_conflict,Wo=s._sqlite3_vtab_collation=e.sqlite3_vtab_collation,zo=s._sqlite3_vtab_in=e.sqlite3_vtab_in,Bo=s._sqlite3_vtab_rhs_value=e.sqlite3_vtab_rhs_value,Uo=s._sqlite3_vtab_distinct=e.sqlite3_vtab_distinct,Qo=s._sqlite3_keyword_name=e.sqlite3_keyword_name,Vo=s._sqlite3_keyword_count=e.sqlite3_keyword_count,Ho=s._sqlite3_keyword_check=e.sqlite3_keyword_check,Go=s._sqlite3_complete=e.sqlite3_complete,Ko=s._sqlite3_libversion=e.sqlite3_libversion,$o=s._sqlite3_libversion_number=e.sqlite3_libversion_number,Jo=s._sqlite3mc_vfs_create=e.sqlite3mc_vfs_create,Xo=s._sqlite3_shutdown=e.sqlite3_shutdown,Yo=s._sqlite3mc_vfs_shutdown=e.sqlite3mc_vfs_shutdown,Zo=s._sqlite3_last_insert_rowid=e.sqlite3_last_insert_rowid,ea=s._sqlite3_set_last_insert_rowid=e.sqlite3_set_last_insert_rowid,ta=s._sqlite3_changes64=e.sqlite3_changes64,na=s._sqlite3_changes=e.sqlite3_changes,ra=s._sqlite3_total_changes64=e.sqlite3_total_changes64,ia=s._sqlite3_total_changes=e.sqlite3_total_changes,sa=s._sqlite3_txn_state=e.sqlite3_txn_state,oa=s._sqlite3_close_v2=e.sqlite3_close_v2,aa=s._sqlite3_busy_handler=e.sqlite3_busy_handler,la=s._sqlite3_progress_handler=e.sqlite3_progress_handler,ca=s._sqlite3_busy_timeout=e.sqlite3_busy_timeout,_a=s._sqlite3_interrupt=e.sqlite3_interrupt,ua=s._sqlite3_is_interrupted=e.sqlite3_is_interrupted,fa=s._sqlite3_create_function=e.sqlite3_create_function,da=s._sqlite3_create_function_v2=e.sqlite3_create_function_v2,pa=s._sqlite3_create_window_function=e.sqlite3_create_window_function,ha=s._sqlite3_overload_function=e.sqlite3_overload_function,ma=s._sqlite3_trace_v2=e.sqlite3_trace_v2,ga=s._sqlite3_commit_hook=e.sqlite3_commit_hook,ba=s._sqlite3_update_hook=e.sqlite3_update_hook,ya=s._sqlite3_rollback_hook=e.sqlite3_rollback_hook,qa=s._sqlite3_preupdate_hook=e.sqlite3_preupdate_hook,va=s._sqlite3_set_errmsg=e.sqlite3_set_errmsg,Sa=s._sqlite3_error_offset=e.sqlite3_error_offset,wa=s._sqlite3_errcode=e.sqlite3_errcode,Ea=s._sqlite3_extended_errcode=e.sqlite3_extended_errcode,ka=s._sqlite3_errstr=e.sqlite3_errstr,Aa=s._sqlite3_limit=e.sqlite3_limit,Ia=s._sqlite3_open=e.sqlite3_open,xa=s._sqlite3_open_v2=e.sqlite3_open_v2,Ta=s._sqlite3_create_collation=e.sqlite3_create_collation,Oa=s._sqlite3_create_collation_v2=e.sqlite3_create_collation_v2,Pa=s._sqlite3_collation_needed=e.sqlite3_collation_needed,Fa=s._sqlite3_get_autocommit=e.sqlite3_get_autocommit,La=s._sqlite3_table_column_metadata=e.sqlite3_table_column_metadata,Ca=s._sqlite3_extended_result_codes=e.sqlite3_extended_result_codes,Na=s._sqlite3_uri_key=e.sqlite3_uri_key,Da=s._sqlite3_uri_int64=e.sqlite3_uri_int64,Ra=s._sqlite3_db_name=e.sqlite3_db_name,Ma=s._sqlite3_db_filename=e.sqlite3_db_filename,ja=s._sqlite3_db_readonly=e.sqlite3_db_readonly,Wa=s._sqlite3_compileoption_used=e.sqlite3_compileoption_used,za=s._sqlite3_compileoption_get=e.sqlite3_compileoption_get,Ba=s._sqlite3session_diff=e.sqlite3session_diff,Ua=s._sqlite3session_attach=e.sqlite3session_attach,Qa=s._sqlite3session_create=e.sqlite3session_create,Va=s._sqlite3session_delete=e.sqlite3session_delete,Ha=s._sqlite3session_table_filter=e.sqlite3session_table_filter,Ga=s._sqlite3session_changeset=e.sqlite3session_changeset,Ka=s._sqlite3session_changeset_strm=e.sqlite3session_changeset_strm,$a=s._sqlite3session_patchset_strm=e.sqlite3session_patchset_strm,Ja=s._sqlite3session_patchset=e.sqlite3session_patchset,Xa=s._sqlite3session_enable=e.sqlite3session_enable,Ya=s._sqlite3session_indirect=e.sqlite3session_indirect,Za=s._sqlite3session_isempty=e.sqlite3session_isempty,el=s._sqlite3session_memory_used=e.sqlite3session_memory_used,tl=s._sqlite3session_object_config=e.sqlite3session_object_config,nl=s._sqlite3session_changeset_size=e.sqlite3session_changeset_size,rl=s._sqlite3changeset_start=e.sqlite3changeset_start,il=s._sqlite3changeset_start_v2=e.sqlite3changeset_start_v2,sl=s._sqlite3changeset_start_strm=e.sqlite3changeset_start_strm,ol=s._sqlite3changeset_start_v2_strm=e.sqlite3changeset_start_v2_strm,al=s._sqlite3changeset_next=e.sqlite3changeset_next,ll=s._sqlite3changeset_op=e.sqlite3changeset_op,cl=s._sqlite3changeset_pk=e.sqlite3changeset_pk,_l=s._sqlite3changeset_old=e.sqlite3changeset_old,ul=s._sqlite3changeset_new=e.sqlite3changeset_new,fl=s._sqlite3changeset_conflict=e.sqlite3changeset_conflict,dl=s._sqlite3changeset_fk_conflicts=e.sqlite3changeset_fk_conflicts,pl=s._sqlite3changeset_finalize=e.sqlite3changeset_finalize,hl=s._sqlite3changeset_invert=e.sqlite3changeset_invert,ml=s._sqlite3changeset_invert_strm=e.sqlite3changeset_invert_strm,gl=s._sqlite3changeset_apply_v2=e.sqlite3changeset_apply_v2,bl=s._sqlite3changeset_apply_v3=e.sqlite3changeset_apply_v3,yl=s._sqlite3changeset_apply=e.sqlite3changeset_apply,ql=s._sqlite3changeset_apply_v3_strm=e.sqlite3changeset_apply_v3_strm,vl=s._sqlite3changeset_apply_v2_strm=e.sqlite3changeset_apply_v2_strm,Sl=s._sqlite3changeset_apply_strm=e.sqlite3changeset_apply_strm,wl=s._sqlite3changegroup_new=e.sqlite3changegroup_new,El=s._sqlite3changegroup_add=e.sqlite3changegroup_add,kl=s._sqlite3changegroup_output=e.sqlite3changegroup_output,Al=s._sqlite3changegroup_add_strm=e.sqlite3changegroup_add_strm,Il=s._sqlite3changegroup_output_strm=e.sqlite3changegroup_output_strm,xl=s._sqlite3changegroup_delete=e.sqlite3changegroup_delete,Tl=s._sqlite3changeset_concat=e.sqlite3changeset_concat,Ol=s._sqlite3changeset_concat_strm=e.sqlite3changeset_concat_strm,Pl=s._sqlite3session_config=e.sqlite3session_config,Fl=s._sqlite3_sourceid=e.sqlite3_sourceid,Ll=s._sqlite3mc_version=e.sqlite3mc_version,Cl=s._sqlite3mc_config=e.sqlite3mc_config,Nl=s._sqlite3mc_cipher_count=e.sqlite3mc_cipher_count,Dl=s._sqlite3mc_cipher_index=e.sqlite3mc_cipher_index,Rl=s._sqlite3mc_cipher_name=e.sqlite3mc_cipher_name,Ml=s._sqlite3mc_cipher_name_copy=e.sqlite3mc_cipher_name_copy,jl=s._sqlite3mc_config_cipher=e.sqlite3mc_config_cipher,Wl=s._sqlite3mc_codec_data=e.sqlite3mc_codec_data,zl=s._sqlite3_activate_see=e.sqlite3_activate_see,Bl=s._sqlite3_key=e.sqlite3_key,Ul=s._sqlite3_key_v2=e.sqlite3_key_v2,Ql=s._sqlite3_rekey_v2=e.sqlite3_rekey_v2,Vl=s._sqlite3_rekey=e.sqlite3_rekey,Hl=s._sqlite3mc_vfs_destroy=e.sqlite3mc_vfs_destroy,Gl=s._sqlite3__wasm_pstack_ptr=e.sqlite3__wasm_pstack_ptr,Kl=s._sqlite3__wasm_pstack_restore=e.sqlite3__wasm_pstack_restore,$l=s._sqlite3__wasm_pstack_alloc=e.sqlite3__wasm_pstack_alloc,Jl=s._sqlite3__wasm_pstack_remaining=e.sqlite3__wasm_pstack_remaining,Xl=s._sqlite3__wasm_pstack_quota=e.sqlite3__wasm_pstack_quota,Yl=s._sqlite3__wasm_test_struct=e.sqlite3__wasm_test_struct,Zl=s._sqlite3__wasm_enum_json=e.sqlite3__wasm_enum_json,ec=s._sqlite3__wasm_vfs_unlink=e.sqlite3__wasm_vfs_unlink,tc=s._sqlite3__wasm_db_vfs=e.sqlite3__wasm_db_vfs,nc=s._sqlite3__wasm_db_reset=e.sqlite3__wasm_db_reset,rc=s._sqlite3__wasm_db_export_chunked=e.sqlite3__wasm_db_export_chunked,ic=s._sqlite3__wasm_db_serialize=e.sqlite3__wasm_db_serialize,sc=s._sqlite3__wasm_vfs_create_file=e.sqlite3__wasm_vfs_create_file,oc=s._sqlite3__wasm_posix_create_file=e.sqlite3__wasm_posix_create_file,ac=s._sqlite3__wasm_kvvfsMakeKey=e.sqlite3__wasm_kvvfsMakeKey,lc=s._sqlite3__wasm_kvvfs_methods=e.sqlite3__wasm_kvvfs_methods,cc=s._sqlite3__wasm_vtab_config=e.sqlite3__wasm_vtab_config,_c=s._sqlite3__wasm_db_config_ip=e.sqlite3__wasm_db_config_ip,uc=s._sqlite3__wasm_db_config_pii=e.sqlite3__wasm_db_config_pii,fc=s._sqlite3__wasm_db_config_s=e.sqlite3__wasm_db_config_s,dc=s._sqlite3__wasm_config_i=e.sqlite3__wasm_config_i,pc=s._sqlite3__wasm_config_ii=e.sqlite3__wasm_config_ii,hc=s._sqlite3__wasm_config_j=e.sqlite3__wasm_config_j,mc=s._sqlite3__wasm_qfmt_token=e.sqlite3__wasm_qfmt_token,gc=s._sqlite3__wasm_kvvfs_decode=e.sqlite3__wasm_kvvfs_decode,bc=s._sqlite3__wasm_kvvfs_encode=e.sqlite3__wasm_kvvfs_encode,yc=s._sqlite3__wasm_init_wasmfs=e.sqlite3__wasm_init_wasmfs,qc=s._sqlite3__wasm_test_intptr=e.sqlite3__wasm_test_intptr,vc=s._sqlite3__wasm_test_voidptr=e.sqlite3__wasm_test_voidptr,Sc=s._sqlite3__wasm_test_int64_max=e.sqlite3__wasm_test_int64_max,wc=s._sqlite3__wasm_test_int64_min=e.sqlite3__wasm_test_int64_min,Ec=s._sqlite3__wasm_test_int64_times2=e.sqlite3__wasm_test_int64_times2,kc=s._sqlite3__wasm_test_int64_minmax=e.sqlite3__wasm_test_int64_minmax,Ac=s._sqlite3__wasm_test_int64ptr=e.sqlite3__wasm_test_int64ptr,Ic=s._sqlite3__wasm_test_stack_overflow=e.sqlite3__wasm_test_stack_overflow,xc=s._sqlite3__wasm_test_str_hello=e.sqlite3__wasm_test_str_hello,Tc=s._sqlite3__wasm_SQLTester_strglob=e.sqlite3__wasm_SQLTester_strglob,Oc=s._malloc=e.malloc,Pc=s._free=e.free,Fc=s._realloc=e.realloc,gn=e.emscripten_builtin_memalign,bn=e._emscripten_stack_restore,Lc=e._emscripten_stack_alloc,yn=e.emscripten_stack_get_current,Cc=e.__indirect_function_table}var qn={__syscall_chmod:Ir,__syscall_faccessat:xr,__syscall_fchmod:Tr,__syscall_fchown32:Or,__syscall_fcntl64:Pr,__syscall_fstat64:Fr,__syscall_ftruncate64:Nr,__syscall_getcwd:Dr,__syscall_ioctl:Rr,__syscall_lstat64:Mr,__syscall_mkdirat:jr,__syscall_newfstatat:Wr,__syscall_openat:zr,__syscall_readlinkat:Br,__syscall_rmdir:Ur,__syscall_stat64:Qr,__syscall_unlinkat:Vr,__syscall_utimensat:Hr,_abort_js:Gr,_localtime_js:Yr,_mmap_js:Zr,_munmap_js:ei,_tzset_js:ti,clock_time_get:ii,emscripten_date_now:hn,emscripten_get_heap_max:si,emscripten_get_now:pn,emscripten_resize_heap:ai,environ_get:ci,environ_sizes_get:_i,exit:hi,fd_close:mi,fd_fdstat_get:gi,fd_read:yi,fd_seek:qi,fd_sync:vi,fd_write:wi,memory:et,wasm_crypto_getrandom:Ei};async function Dc(){if(tr(),lt)await qr();var e=s.setStatus;if(e)e("Running..."),await new Promise((n)=>setTimeout(n,1)),setTimeout(e,1,"");if(Tt)return;nr(),s.onRuntimeInitialized?.(),rr()}var ht=await _r();return await Dc(),s.runSQLite3PostLoadInit=async function(e,n,o){delete n.runSQLite3PostLoadInit,globalThis.sqlite3ApiBootstrap=async function i(t=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;let r=(...f)=>Object.assign(Object.create(null),...f),a=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},t);Object.assign(a,{allocExportName:a.useStdAlloc?"malloc":"sqlite3_malloc",deallocExportName:a.useStdAlloc?"free":"sqlite3_free",reallocExportName:a.useStdAlloc?"realloc":"sqlite3_realloc"}),["exports","memory","functionTable","wasmfsOpfsDir"].forEach((f)=>{if(typeof a[f]==="function")a[f]=a[f]()});let _=r(),h=r(),I=(f)=>_.sqlite3_js_rc_str&&_.sqlite3_js_rc_str(f)||"Unknown result code #"+f,q=(f)=>typeof f==="number"&&f===(f|0)&&f<=2147483647&&f>=-2147483648;class R extends Error{constructor(...f){let S;if(f.length)if(q(f[0]))if(S=f[0],f.length===1)super(I(f[0]));else{let D=I(S);if(typeof f[1]==="object")super(D,f[1]);else{f[0]=D+":";super(f.join(" "))}}else if(f.length===2&&typeof f[1]==="object")super(...f);else super(f.join(" "));this.resultCode=S||_.SQLITE_ERROR,this.name="SQLite3Error"}}R.toss=(...f)=>{throw new R(...f)};let M=R.toss;if(a.wasmfsOpfsDir&&!/^\/[^/]+$/.test(a.wasmfsOpfsDir))M("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");let p=function f(S){if(!f._max)f._max=BigInt("0x7fffffffffffffff"),f._min=~f._max;return S>=f._min&&S<=f._max},te=(f)=>f>=-0x7fffffffn-1n&&f<=0x7fffffffn,j=function f(S){if(!f._min)f._min=Number.MIN_SAFE_INTEGER,f._max=Number.MAX_SAFE_INTEGER;return S>=f._min&&S<=f._max},U=(f)=>f&&f.constructor&&q(f.constructor.BYTES_PER_ELEMENT)?f:!1,E=(f)=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),g=(f)=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),F=(f)=>E(f)||M("Value is not of a supported TypedArray type."),x=function(f){if(g(f))return h.typedArrayToString(f instanceof ArrayBuffer?new Uint8Array(f):f,0,f.length);else if(Array.isArray(f))return f.join("");else if(h.isPtr(f))f=h.cstrToJs(f);return f};class A extends Error{constructor(...f){if(f.length===2&&typeof f[1]==="object")super(...f);else if(f.length)super(f.join(" "));else super("Allocation failed.");this.resultCode=_.SQLITE_NOMEM,this.name="WasmAllocError"}}A.toss=(...f)=>{throw new A(...f)},Object.assign(_,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(f,S,D,J,ie,le,Se,me,K)=>{},sqlite3_create_function:(f,S,D,J,ie,le,Se,me)=>{},sqlite3_create_window_function:(f,S,D,J,ie,le,Se,me,K,oe)=>{},sqlite3_prepare_v3:(f,S,D,J,ie,le)=>{},sqlite3_prepare_v2:(f,S,D,J,ie)=>{},sqlite3_exec:(f,S,D,J,ie)=>{},sqlite3_randomness:(f,S)=>{}});let N={affirmBindableTypedArray:F,flexibleString:x,bigIntFits32:te,bigIntFits64:p,bigIntFitsDouble:j,isBindableTypedArray:E,isInt32:q,isSQLableTypedArray:g,isTypedArray:U,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,toss:function(...f){throw Error(f.join(" "))},toss3:M,typedArrayPart:h.typedArrayPart,nu:r,assert:function(f,S){if(!f)N.toss("Assertion failed:",S)},affirmDbHeader:function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);let S="SQLite format 3";if(S.length>f.byteLength)M("Input does not contain an SQLite3 database header.");for(let D=0;D<S.length;++D)if(S.charCodeAt(D)!==f[D])break},affirmIsDb:function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);let S=f.byteLength;if(S<512||S%512!==0)M("Byte array size",S,"is invalid for an SQLite3 db.");N.affirmDbHeader(f)}};Object.assign(h,{exports:a.exports||M("Missing API config.exports (WASM module exports)."),memory:a.memory||a.exports.memory||M("API config object requires a WebAssembly.Memory object","in either config.exports.memory (exported)","or config.memory (imported)."),pointerSize:typeof a.exports.sqlite3_libversion()==="number"?4:8,bigIntEnabled:!!a.bigIntEnabled,functionTable:a.functionTable,alloc:void 0,realloc:void 0,dealloc:void 0}),h.allocFromTypedArray=function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);F(f);let S=h.alloc(f.byteLength||1);return h.heapForSize(f.constructor).set(f.byteLength?f:[0],Number(S)),S};{let{allocExportName:f,deallocExportName:S,reallocExportName:D}=a;for(let J of[f,S,D])if(!(h.exports[J]instanceof Function))M("Missing required exports[",J,"] function.");h.alloc=function J(ie){return J.impl(ie)||A.toss("Failed to allocate",ie," bytes.")},h.alloc.impl=h.exports[f],h.realloc=function J(ie,le){let Se=J.impl(h.ptr.coerce(ie),le);return le?Se||A.toss("Failed to reallocate",le," bytes."):h.ptr.null},h.realloc.impl=h.exports[D],h.dealloc=function J(ie){J.impl(h.ptr.coerce(ie))},h.dealloc.impl=h.exports[S]}h.compileOptionUsed=function f(S){if(!arguments.length){if(f._result)return f._result;else if(!f._opt)f._rx=/^([^=]+)=(.+)/,f._rxInt=/^-?\d+$/,f._opt=function(Se,me){let K=f._rx.exec(Se);me[0]=K?K[1]:Se,me[1]=K?f._rxInt.test(K[2])?+K[2]:K[2]:!0};let D=r(),J=[0,0],ie=0,le;while(le=_.sqlite3_compileoption_get(ie++))f._opt(le,J),D[J[0]]=J[1];return f._result=D}else if(Array.isArray(S)){let D=r();return S.forEach((J)=>{D[J]=_.sqlite3_compileoption_used(J)}),D}else if(typeof S==="object")return Object.keys(S).forEach((D)=>{S[D]=_.sqlite3_compileoption_used(D)}),S;return typeof S==="string"?!!_.sqlite3_compileoption_used(S):!1},h.pstack=r({restore:h.exports.sqlite3__wasm_pstack_restore,alloc:function(f){if(typeof f==="string"&&!(f=h.sizeofIR(f)))A.toss("Invalid value for pstack.alloc(",arguments[0],")");return h.exports.sqlite3__wasm_pstack_alloc(f)||A.toss("Could not allocate",f,"bytes from the pstack.")},allocChunks:function(f,S){if(typeof S==="string"&&!(S=h.sizeofIR(S)))A.toss("Invalid size value for allocChunks(",arguments[1],")");let D=h.pstack.alloc(f*S),J=[D],ie=1,le=S;for(;ie<f;++ie,le+=S)J.push(h.ptr.add(D,le));return J},allocPtr:(f=1,S=!0)=>f===1?h.pstack.alloc(S?8:h.ptr.size):h.pstack.allocChunks(f,S?8:h.ptr.size),call:function(f){let S=h.pstack.pointer;try{return f(z)}finally{h.pstack.restore(S)}}}),Object.defineProperties(h.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_remaining}}),_.sqlite3_randomness=(...f)=>{if(f.length===1&&N.isTypedArray(f[0])&&f[0].BYTES_PER_ELEMENT===1){let S=f[0];if(S.byteLength===0)return h.exports.sqlite3_randomness(0,h.ptr.null),S;let D=h.pstack.pointer;try{let J=S.byteLength,ie=0,le=h.exports.sqlite3_randomness,Se=h.heap8u(),me=J<512?J:512,K=h.pstack.alloc(me);do{let oe=J>me?me:J;le(oe,K),S.set(h.typedArrayPart(Se,K,h.ptr.add(K,oe)),ie),J-=oe,ie+=oe}while(J>0)}catch(J){a.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",J)}finally{h.pstack.restore(D)}return S}h.exports.sqlite3_randomness(...f)},_.sqlite3_wasmfs_opfs_dir=function(){if(this.dir!==void 0)return this.dir;let f=a.wasmfsOpfsDir;if(!f||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!h.exports.sqlite3__wasm_init_wasmfs)return this.dir="";try{if(f&&h.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],f)===0)return this.dir=f;else return this.dir=""}catch(S){return this.dir=""}}.bind(r()),_.sqlite3_wasmfs_filename_is_persistent=function(f){let S=_.sqlite3_wasmfs_opfs_dir();return S&&f?f.startsWith(S+"/"):!1},_.sqlite3_js_db_uses_vfs=function(f,S,D=0){try{let J=_.sqlite3_vfs_find(S);if(!J)return!1;else if(!f)return J===_.sqlite3_vfs_find(0)?J:!1;else return J===_.sqlite3_js_db_vfs(f,D)?J:!1}catch(J){return!1}},_.sqlite3_js_vfs_list=function(){let f=[],S=_.sqlite3_vfs_find(h.ptr.null);while(S){let D=new _.sqlite3_vfs(S);f.push(h.cstrToJs(D.$zName)),S=D.$pNext,D.dispose()}return f},_.sqlite3_js_db_export=function(f,S=0){if(f=h.xWrap.testConvertArg("sqlite3*",f),!f)M("Invalid sqlite3* argument.");if(!h.bigIntEnabled)M("BigInt support is not enabled.");let D=h.scopedAllocPush(),J;try{let ie=h.scopedAlloc(8+h.ptr.size),le=h.ptr.add(ie,8),Se=S?h.isPtr(S)?S:h.scopedAllocCString(""+S):h.ptr.null,me=h.exports.sqlite3__wasm_db_serialize(f,Se,le,ie,0);if(me)M("Database serialization failed with code",z.capi.sqlite3_js_rc_str(me));J=h.peekPtr(le);let K=h.peek(ie,"i64");return me=K?h.heap8u().slice(Number(J),Number(J)+Number(K)):new Uint8Array,me}finally{if(J)h.exports.sqlite3_free(J);h.scopedAllocPop(D)}},_.sqlite3_js_db_vfs=(f,S=h.ptr.null)=>N.sqlite3__wasm_db_vfs(f,S),_.sqlite3_js_aggregate_context=(f,S)=>_.sqlite3_aggregate_context(f,S)||(S?A.toss("Cannot allocate",S,"bytes for sqlite3_aggregate_context()"):0),_.sqlite3_js_posix_create_file=function(f,S,D){let J;if(S&&h.isPtr(S))J=S;else if(S instanceof ArrayBuffer||S instanceof Uint8Array){if(J=h.allocFromTypedArray(S),arguments.length<3||!N.isInt32(D)||D<0)D=S.byteLength}else R.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{if(!N.isInt32(D)||D<0)R.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");let ie=N.sqlite3__wasm_posix_create_file(f,J,D);if(ie)R.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(ie))}finally{if(J&&J!==S)h.dealloc(J)}},_.sqlite3_js_vfs_create_file=function(f,S,D,J){a.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 ie;if(D)if(h.isPtr(D))ie=D;else{if(D instanceof ArrayBuffer)D=new Uint8Array(D);if(D instanceof Uint8Array){if(ie=h.allocFromTypedArray(D),arguments.length<4||!N.isInt32(J)||J<0)J=D.byteLength}else R.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")}else ie=0;if(!N.isInt32(J)||J<0){if(ie&&ie!==D)h.dealloc(ie);R.toss("Invalid 4th argument for sqlite3_js_vfs_create_file().")}try{let le=N.sqlite3__wasm_vfs_create_file(f,S,ie,J);if(le)R.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(le))}finally{if(ie&&ie!==D)h.dealloc(ie)}},_.sqlite3_js_sql_to_string=(f)=>{if(typeof f==="string")return f;let S=x(v);return S===v?void 0:S},_.sqlite3_db_config=function(f,S,...D){switch(S){case _.SQLITE_DBCONFIG_ENABLE_FKEY:case _.SQLITE_DBCONFIG_ENABLE_TRIGGER:case _.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER:case _.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION:case _.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE:case _.SQLITE_DBCONFIG_ENABLE_QPSG:case _.SQLITE_DBCONFIG_TRIGGER_EQP:case _.SQLITE_DBCONFIG_RESET_DATABASE:case _.SQLITE_DBCONFIG_DEFENSIVE:case _.SQLITE_DBCONFIG_WRITABLE_SCHEMA:case _.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE:case _.SQLITE_DBCONFIG_DQS_DML:case _.SQLITE_DBCONFIG_DQS_DDL:case _.SQLITE_DBCONFIG_ENABLE_VIEW:case _.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT:case _.SQLITE_DBCONFIG_TRUSTED_SCHEMA:case _.SQLITE_DBCONFIG_STMT_SCANSTATUS:case _.SQLITE_DBCONFIG_REVERSE_SCANORDER:case _.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE:case _.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE:case _.SQLITE_DBCONFIG_ENABLE_COMMENTS:case _.SQLITE_DBCONFIG_FP_DIGITS:if(!this.ip)this.ip=h.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"]);return this.ip(f,S,D[0],D[1]||0);case _.SQLITE_DBCONFIG_LOOKASIDE:if(!this.pii)this.pii=h.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"]);return this.pii(f,S,D[0],D[1],D[2]);case _.SQLITE_DBCONFIG_MAINDBNAME:if(!this.s)this.s=h.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"]);return this.s(f,S,D[0]);default:return _.SQLITE_MISUSE}}.bind(r()),_.sqlite3_value_to_js=function(f,S=!0){let D,J=_.sqlite3_value_type(f);switch(J){case _.SQLITE_INTEGER:if(h.bigIntEnabled){if(D=_.sqlite3_value_int64(f),N.bigIntFitsDouble(D))D=Number(D)}else D=_.sqlite3_value_double(f);break;case _.SQLITE_FLOAT:D=_.sqlite3_value_double(f);break;case _.SQLITE_TEXT:D=_.sqlite3_value_text(f);break;case _.SQLITE_BLOB:{let ie=_.sqlite3_value_bytes(f),le=_.sqlite3_value_blob(f);if(ie&&!le)z.WasmAllocError.toss("Cannot allocate memory for blob argument of",ie,"byte(s)");D=ie?h.heap8u().slice(Number(le),Number(le)+Number(ie)):null;break}case _.SQLITE_NULL:D=null;break;default:if(S)M(_.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",J);D=void 0}return D},_.sqlite3_values_to_js=function(f,S,D=!0){let J,ie=[];for(J=0;J<f;++J)ie.push(_.sqlite3_value_to_js(h.peekPtr(h.ptr.add(S,h.ptr.size*J)),D));return ie},_.sqlite3_result_error_js=function(f,S){if(S instanceof A)_.sqlite3_result_error_nomem(f);else _.sqlite3_result_error(f,""+S,-1)},_.sqlite3_result_js=function(f,S){if(S instanceof Error){_.sqlite3_result_error_js(f,S);return}try{switch(typeof S){case"undefined":break;case"boolean":_.sqlite3_result_int(f,S?1:0);break;case"bigint":if(N.bigIntFits32(S))_.sqlite3_result_int(f,Number(S));else if(N.bigIntFitsDouble(S))_.sqlite3_result_double(f,Number(S));else if(h.bigIntEnabled)if(N.bigIntFits64(S))_.sqlite3_result_int64(f,S);else M("BigInt value",S.toString(),"is too BigInt for int64.");else M("BigInt value",S.toString(),"is too BigInt.");break;case"number":{let D;if(N.isInt32(S))D=_.sqlite3_result_int;else if(h.bigIntEnabled&&Number.isInteger(S)&&N.bigIntFits64(BigInt(S)))D=_.sqlite3_result_int64;else D=_.sqlite3_result_double;D(f,S);break}case"string":{let[D,J]=h.allocCString(S,!0);_.sqlite3_result_text(f,D,J,_.SQLITE_WASM_DEALLOC);break}case"object":if(S===null){_.sqlite3_result_null(f);break}else if(N.isBindableTypedArray(S)){let D=h.allocFromTypedArray(S);_.sqlite3_result_blob(f,D,S.byteLength,_.SQLITE_WASM_DEALLOC);break}default:M("Don't not how to handle this UDF result value:",typeof S,S)}}catch(D){_.sqlite3_result_error_js(f,D)}},_.sqlite3_column_js=function(f,S,D=!0){let J=_.sqlite3_column_value(f,S);return J===0?void 0:_.sqlite3_value_to_js(J,D)};{let f=function(S,D,J){if(J=_[J],!this.ptr)this.ptr=h.allocPtr();else h.pokePtr(this.ptr,0);let ie=J(S,D,this.ptr);if(ie)return R.toss(ie,arguments[2]+"() failed with code "+ie);let le=h.peekPtr(this.ptr);return le?_.sqlite3_value_to_js(le,!0):void 0}.bind(r());_.sqlite3_preupdate_new_js=(S,D)=>f(S,D,"sqlite3_preupdate_new"),_.sqlite3_preupdate_old_js=(S,D)=>f(S,D,"sqlite3_preupdate_old"),_.sqlite3changeset_new_js=(S,D)=>f(S,D,"sqlite3changeset_new"),_.sqlite3changeset_old_js=(S,D)=>f(S,D,"sqlite3changeset_old")}_.sqlite3_js_retry_busy=function(f,S,D){for(let J=1;J<=f;++J)try{if(D&&J>1)D(J);let ie=S();if(_.SQLITE_BUSY===ie){if(J===f)throw new R(ie,["sqlite3_js_retry_busy() max retry attempts (",f,") reached."].join(""));continue}return ie}catch(ie){if(J<f&&ie instanceof R&&ie.resultCode===_.SQLITE_BUSY)continue;throw ie}};let z={WasmAllocError:A,SQLite3Error:R,capi:_,util:N,wasm:h,config:a,version:r(),client:void 0,asyncPostInit:async function f(){if(f.isReady instanceof Promise)return f.isReady;let S=this.initializersAsync;delete this.initializersAsync;let D=async()=>{if(!z.__isUnderTest)delete z.util,delete z.StructBinder,delete z.opfs;return z},J=(le)=>{throw a.error("an async sqlite3 initializer failed:",le),le};if(!S||!S.length)return f.isReady=D().catch(J);S=S.map((le)=>le instanceof Function?async(Se)=>le(z):le),S.push(D);let ie=Promise.resolve(z);while(S.length)ie=ie.then(S.shift());return f.isReady=ie.catch(J)}.bind(i),scriptInfo:void 0};if(typeof o<"u")z.__isUnderTest=!!o;try{i.initializers.forEach((f)=>{f(z)})}catch(f){throw console.error("sqlite3 bootstrap initializer threw:",f),f}if(delete i.initializers,i.sqlite3=z,typeof e<"u")e.debugModule("sqlite3ApiBootstrap() complete",z),z.scriptInfo=e;if(z.__isUnderTest){if(typeof n<"u")z.config.emscripten=n;let f=z.scriptInfo?.instantiateWasm;if(f)z.wasm.module=f.module,z.wasm.instance=f.instance,z.wasm.imports=f.imports}return delete globalThis.sqlite3ApiConfig,delete globalThis.sqlite3ApiBootstrap,delete i.defaultConfig,z.asyncPostInit().then((f)=>{if(typeof e<"u")e.debugModule("sqlite3.asyncPostInit() complete",f);return delete f.asyncPostInit,delete f.scriptInfo,delete f.emscripten,f})},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.54.0",libVersionNumber:3054000,sourceId:"2026-10-09 15:46:58 be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3",downloadVersion:3540000,scm:{"sha3-256":"be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3",branch:"trunk",tags:"release major-release version-3.54.0",datetime:"2026-10-09T15:46:58.543Z"}}}),globalThis.WhWasmUtilInstaller=function(t){if(t.bigIntEnabled===void 0)t.bigIntEnabled=!!globalThis.BigInt64Array;let r=(...u)=>{throw Error(u.join(" "))};if(!t.pointerSize&&!t.pointerIR&&t.alloc&&t.dealloc){let u=t.alloc(1);t.pointerSize=typeof u==="bigint"?8:4,t.dealloc(u)}if(t.pointerSize&&!t.pointerIR)t.pointerIR=t.pointerSize===4?"i32":"i64";let a=t.pointerIR??="i32",_=t.pointerSize??=a==="i32"?4:a==="i64"?8:0;if(delete t.pointerSize,delete t.pointerIR,a!=="i32"&&a!=="i64")r("Invalid pointerIR:",a);else if(_!==8&&_!==4)r("Invalid pointerSize:",_);let h=t.bigIntEnabled?(u)=>BigInt(u||0):(u)=>r("BigInt support is disabled in this build."),q=_===4?(u)=>Number(u||0):h,R=q(0),M=function(...u){let y=q(0);for(let O of u)y+=q(O);return y};{let u=Object.create(null);Object.defineProperty(t,"ptr",{enumerable:!0,get:()=>u,set:()=>r("The ptr property is read-only.")}),function y(O,V){return Object.defineProperty(u,O,{enumerable:!0,get:()=>V,set:()=>r("ptr["+O+"] is read-only.")}),y}("null",R)("size",_)("ir",a)("coerce",q)("add",M)("addn",a===4?M:(...y)=>Number(M(...y)))}if(!t.exports)Object.defineProperty(t,"exports",{enumerable:!0,configurable:!0,get:()=>t.instance?.exports});let p=Object.create(null);p.heapSize=0,p.memory=null,p.freeFuncIndexes=[],p.scopedAlloc=[],p.scopedAlloc.pushPtr=(u)=>(p.scopedAlloc[p.scopedAlloc.length-1].push(u),u),p.utf8Decoder=new TextDecoder,p.utf8Encoder=new TextEncoder("utf-8"),t.sizeofIR=(u)=>{switch(u){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 _;default:return(""+u).endsWith("*")?_:void 0}};let te=function(){if(!p.memory)p.memory=t.memory instanceof WebAssembly.Memory?t.memory:t.exports.memory;else if(p.heapSize===p.memory.buffer.byteLength)return p;let u=p.memory.buffer;if(p.HEAP8=new Int8Array(u),p.HEAP8U=new Uint8Array(u),p.HEAP16=new Int16Array(u),p.HEAP16U=new Uint16Array(u),p.HEAP32=new Int32Array(u),p.HEAP32U=new Uint32Array(u),p.HEAP32F=new Float32Array(u),p.HEAP64F=new Float64Array(u),t.bigIntEnabled)if(typeof BigInt64Array<"u")p.HEAP64=new BigInt64Array(u),p.HEAP64U=new BigUint64Array(u);else r("BigInt support is enabled, but the BigInt64Array type is missing.");return p.heapSize=u.byteLength,p};t.heap8=()=>te().HEAP8,t.heap8u=()=>te().HEAP8U,t.heap16=()=>te().HEAP16,t.heap16u=()=>te().HEAP16U,t.heap32=()=>te().HEAP32,t.heap32u=()=>te().HEAP32U,t.heapForSize=function(u,y=!0){let O,V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te();switch(u){case Int8Array:return V.HEAP8;case Uint8Array:return V.HEAP8U;case Int16Array:return V.HEAP16;case Uint16Array:return V.HEAP16U;case Int32Array:return V.HEAP32;case Uint32Array:return V.HEAP32U;case 8:return y?V.HEAP8U:V.HEAP8;case 16:return y?V.HEAP16U:V.HEAP16;case 32:return y?V.HEAP32U:V.HEAP32;case 64:if(V.HEAP64)return y?V.HEAP64U:V.HEAP64;break;default:if(t.bigIntEnabled){if(u===globalThis.BigUint64Array)return V.HEAP64U;else if(u===globalThis.BigInt64Array)return V.HEAP64;break}}r("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")};let j=t.functionTable;delete t.functionTable,t.functionTable=j?()=>j:()=>t.exports.__indirect_function_table,t.functionEntry=function(u){let y=t.functionTable();return u<y.length?y.get(q(u)):void 0},t.jsFuncToWasm=function u(y,O){if(!u._)u._={sigTypes:Object.assign(Object.create(null),{i:"i32",p:a,P:a,s:a,j:"i64",f:"f32",d:"f64"}),typeCodes:Object.assign(Object.create(null),{f64:124,f32:125,i64:126,i32:127}),uleb128Encode:(b,C,c)=>{if(c<128)b[C](c);else b[C](c%128|128,c>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:(b)=>{let C=u._.rxJSig.exec(b);return C?C[2]:b.substr(1)},letterType:(b)=>u._.sigTypes[b]||r("Invalid signature letter:",b),pushSigType:(b,C)=>b.push(u._.typeCodes[u._.letterType(C)])};if(typeof y==="string"){let b=O;O=y,y=b}let V=u._,Y=V.sigParams(O),m=[1,96];V.uleb128Encode(m,"push",Y.length);for(let b of Y)V.pushSigType(m,b);if(O[0]==="v")m.push(0);else m.push(1),V.pushSigType(m,O[0]);return V.uleb128Encode(m,"unshift",m.length),m.unshift(0,97,115,109,1,0,0,0,1),m.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(m)),{e:{f:y}}).exports.f};let U=function(y,O,V){if(V&&!p.scopedAlloc.length)r("No scopedAllocPush() scope is active.");if(typeof y==="string"){let C=O;O=y,y=C}if(typeof O!=="string"||!(y instanceof Function))r("Invalid arguments: expecting (function,signature) or (signature,function).");let Y=t.functionTable(),m=q(Y.length),b;while(b=p.freeFuncIndexes.pop())if(Y.get(b)){b=null;continue}else break;if(!b)b=q(m),Y.grow(q(1));try{if(Y.set(b,y),V)p.scopedAlloc.pushPtr(b);return b}catch(C){if(!(C instanceof TypeError)){if(b===m)p.freeFuncIndexes.push(m);throw C}}try{let C=t.jsFuncToWasm(y,O);if(Y.set(b,C),V)p.scopedAlloc.pushPtr(b)}catch(C){if(b===m)p.freeFuncIndexes.push(m);throw C}return b};t.installFunction=(u,y)=>U(u,y,!1),t.scopedInstallFunction=(u,y)=>U(u,y,!0),t.uninstallFunction=function(u){if(!u&&R!==u)return;let y=t.functionTable();p.freeFuncIndexes.push(u);let O=y.get(u);return y.set(u,null),O},t.peek=function(y,O="i8"){if(O.endsWith("*"))O=a;let V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te(),Y=Array.isArray(y)?[]:void 0,m;do{if(Y)y=arguments[0].shift();switch(O){case"i1":case"i8":m=V.HEAP8[Number(y)>>0];break;case"i16":m=V.HEAP16[Number(y)>>1];break;case"i32":m=V.HEAP32[Number(y)>>2];break;case"float":case"f32":m=V.HEAP32F[Number(y)>>2];break;case"double":case"f64":m=Number(V.HEAP64F[Number(y)>>3]);break;case"i64":if(V.HEAP64){m=h(V.HEAP64[Number(y)>>3]);break}default:r("Invalid type for peek():",O)}if(Y)Y.push(m)}while(Y&&arguments[0].length);return Y||m},t.poke=function(u,y,O="i8"){if(O.endsWith("*"))O=a;let V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te();for(let Y of Array.isArray(u)?u:[u])switch(O){case"i1":case"i8":V.HEAP8[Number(Y)>>0]=y;continue;case"i16":V.HEAP16[Number(Y)>>1]=y;continue;case"i32":V.HEAP32[Number(Y)>>2]=y;continue;case"float":case"f32":V.HEAP32F[Number(Y)>>2]=y;continue;case"double":case"f64":V.HEAP64F[Number(Y)>>3]=y;continue;case"i64":if(V.HEAP64){V.HEAP64[Number(Y)>>3]=h(y);continue}default:r("Invalid type for poke(): "+O)}return this},t.peekPtr=(...u)=>t.peek(u.length===1?u[0]:u,a),t.pokePtr=(u,y=0)=>t.poke(u,y,a),t.peek8=(...u)=>t.peek(u.length===1?u[0]:u,"i8"),t.poke8=(u,y)=>t.poke(u,y,"i8"),t.peek16=(...u)=>t.peek(u.length===1?u[0]:u,"i16"),t.poke16=(u,y)=>t.poke(u,y,"i16"),t.peek32=(...u)=>t.peek(u.length===1?u[0]:u,"i32"),t.poke32=(u,y)=>t.poke(u,y,"i32"),t.peek64=(...u)=>t.peek(u.length===1?u[0]:u,"i64"),t.poke64=(u,y)=>t.poke(u,y,"i64"),t.peek32f=(...u)=>t.peek(u.length===1?u[0]:u,"f32"),t.poke32f=(u,y)=>t.poke(u,y,"f32"),t.peek64f=(...u)=>t.peek(u.length===1?u[0]:u,"f64"),t.poke64f=(u,y)=>t.poke(u,y,"f64"),t.getMemValue=t.peek,t.getPtrValue=t.peekPtr,t.setMemValue=t.poke,t.setPtrValue=t.pokePtr,t.isPtr32=(u)=>typeof u==="number"&&u>=0&&u===(u|0),t.isPtr64=(u)=>typeof u==="bigint"?u>=0:t.isPtr32(u),t.isPtr=_===4?t.isPtr32:t.isPtr64,t.cstrlen=function(u){if(!u||!t.isPtr(u))return null;u=Number(u);let y=te().HEAP8U,O=u;for(;y[O]!==0;++O);return O-u};let E=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,g=(u)=>u.buffer instanceof E;t.isSharedTypedArray=g;let F=(u,y,O)=>{if(_===8){if(typeof y==="bigint")y=Number(y);if(typeof O==="bigint")O=Number(O)}return g(u)?u.slice(y,O):u.subarray(y,O)};t.typedArrayPart=F;let x=(u,y,O)=>p.utf8Decoder.decode(F(u,y,O));t.typedArrayToString=x,t.cstrToJs=function(u){let y=t.cstrlen(u);return y?x(te().HEAP8U,Number(u),Number(u)+y):y===null?y:""},t.jstrlen=function(u){if(typeof u!=="string")return null;let y=u.length,O=0;for(let V=0;V<y;++V){let Y=u.charCodeAt(V);if(Y>=55296&&Y<=57343)Y=65536+((Y&1023)<<10)|u.charCodeAt(++V)&1023;if(Y<=127)++O;else if(Y<=2047)O+=2;else if(Y<=65535)O+=3;else O+=4}return O},t.jstrcpy=function(u,y,O=0,V=-1,Y=!0){if(!y||!(y instanceof Int8Array)&&!(y instanceof Uint8Array))r("jstrcpy() target must be an Int8Array or Uint8Array.");if(V=Number(V),O=Number(O),V<0)V=y.length-O;if(!(V>0)||!(O>=0))return 0;let m=0,b=u.length,C=O,c=O+V-(Y?1:0);for(;m<b&&O<c;++m){let d=u.charCodeAt(m);if(d>=55296&&d<=57343)d=65536+((d&1023)<<10)|u.charCodeAt(++m)&1023;if(d<=127){if(O>=c)break;y[O++]=d}else if(d<=2047){if(O+1>=c)break;y[O++]=192|d>>6,y[O++]=128|d&63}else if(d<=65535){if(O+2>=c)break;y[O++]=224|d>>12,y[O++]=128|d>>6&63,y[O++]=128|d&63}else{if(O+3>=c)break;y[O++]=240|d>>18,y[O++]=128|d>>12&63,y[O++]=128|d>>6&63,y[O++]=128|d&63}}if(Y)y[O++]=0;return O-C},t.cstrncpy=function(u,y,O){if(!u||!y)r("cstrncpy() does not accept NULL strings.");if(O<0)O=t.cstrlen(strPtr)+1;else if(!(O>0))return 0;let V=t.heap8u(),Y=0,m,b=Number(u),C=Number(y);for(;Y<O&&(m=V[C+Y]);++Y)V[b+Y]=m;if(Y<O)V[b+Y++]=0;return Y},t.jstrToUintArray=(u,y=!1)=>p.utf8Encoder.encode(y?u+"\x00":u);let A=(u,y)=>{if(!(u.alloc instanceof Function)||!(u.dealloc instanceof Function))r("Object is missing alloc() and/or dealloc() function(s)","required by",y+"().")},N=function(u,y,O,V){if(A(t,V),typeof u!=="string")return null;let Y=p.utf8Encoder.encode(u),m=O(Y.length+1),b=m;try{let C=te().HEAP8U;return C.set(Y,Number(m)),C[M(m,Y.length)]=0,b=R,y?[m,Y.length]:m}finally{if(b)t.dealloc(b)}};t.allocCString=(u,y=!1)=>N(u,y,t.alloc,"allocCString()"),t.scopedAllocPush=function(){A(t,"scopedAllocPush");let u=[];return p.scopedAlloc.push(u),u},t.scopedAllocPop=function(u){A(t,"scopedAllocPop");let y=arguments.length?p.scopedAlloc.indexOf(u):p.scopedAlloc.length-1;if(y<0)r("Invalid state object for scopedAllocPop().");if(arguments.length===0)u=p.scopedAlloc[y];p.scopedAlloc.splice(y,1);for(let O;O=u.pop();)if(t.functionEntry(O))t.uninstallFunction(O);else t.dealloc(O)},t.scopedAlloc=function(u){if(!p.scopedAlloc.length)r("No scopedAllocPush() scope is active.");let y=q(t.alloc(u));return p.scopedAlloc.pushPtr(y)},Object.defineProperty(t.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>p.scopedAlloc.length,set:()=>r("The 'active' property is read-only.")}),t.scopedAllocCString=(u,y=!1)=>N(u,y,t.scopedAlloc,"scopedAllocCString()");let z=function(u,y){let O=t[u?"scopedAlloc":"alloc"]((y.length+1)*t.ptr.size),V=0;return y.forEach((Y)=>{t.pokePtr(M(O,t.ptr.size*V++),t[u?"scopedAllocCString":"allocCString"](""+Y))}),t.pokePtr(M(O,t.ptr.size*V),0),O};t.scopedAllocMainArgv=(u)=>z(!0,u),t.allocMainArgv=(u)=>z(!1,u),t.cArgvToJs=(u,y)=>{let O=[];for(let V=0;V<u;++V){let Y=t.peekPtr(M(y,t.ptr.size*V));O.push(Y?t.cstrToJs(Y):null)}return O},t.scopedAllocCall=function(u){t.scopedAllocPush();try{return u()}finally{t.scopedAllocPop()}};let f=function(u,y,O){A(t,O);let V=y?"i64":a,Y=t[O](u*(y?8:_));if(t.poke(Y,0,V),u===1)return Y;let m=[Y];for(let b=1;b<u;++b)Y=M(Y,y?8:_),m[b]=Y,t.poke(Y,0,V);return m};t.allocPtr=(u=1,y=!0)=>f(u,y,"alloc"),t.scopedAllocPtr=(u=1,y=!0)=>f(u,y,"scopedAlloc"),t.xGet=function(u){return t.exports[u]||r("Cannot find exported symbol:",u)};let S=(u,y)=>r(u+"() requires",y,"argument(s).");t.xCall=function(u,...y){let O=u instanceof Function?u:t.xGet(u);if(!(O instanceof Function))r("Exported symbol",u,"is not a function.");if(O.length!==y.length)S(O===u?O.name:u,O.length);return arguments.length===2&&Array.isArray(arguments[1])?O.apply(null,arguments[1]):O.apply(null,y)},p.xWrap=Object.create(null),p.xWrap.convert=Object.create(null),p.xWrap.convert.arg=new Map,p.xWrap.convert.result=new Map;let D=p.xWrap.convert.arg,J=p.xWrap.convert.result,ie=q;D.set("i64",h).set("i32",(u)=>u|0).set("i16",(u)=>(u|0)&65535).set("i8",(u)=>(u|0)&255).set("f32",(u)=>Number(u).valueOf()).set("float",D.get("f32")).set("f64",D.get("f32")).set("double",D.get("f64")).set("int",D.get("i32")).set("null",(u)=>u).set(null,D.get("null")).set("**",ie).set("*",ie),J.set("*",ie).set("pointer",ie).set("number",(u)=>Number(u)).set("void",(u)=>{return}).set(void 0,J.get("void")).set("null",(u)=>u).set(null,J.get("null"));for(let u of["i8","i16","i32","i64","int","f32","float","f64","double"])D.set(u+"*",ie),J.set(u+"*",ie),J.set(u,D.get(u)||r("Maintenance required: missing arg converter for",u));let le=(u)=>typeof u==="string"?t.scopedAllocCString(u):q(u);D.set("string",le).set("utf8",le),J.set("string",(u)=>t.cstrToJs(u)).set("utf8",J.get("string")).set("string:dealloc",(u)=>{try{return u?t.cstrToJs(u):null}finally{t.dealloc(u)}}).set("utf8:dealloc",J.get("string:dealloc")).set("json",(u)=>JSON.parse(t.cstrToJs(u))).set("json:dealloc",(u)=>{try{return u?JSON.parse(t.cstrToJs(u)):null}finally{t.dealloc(u)}});let Se=class{constructor(u){this.name=u.name||"unnamed adapter"}convertArg(u,y,O){r("AbstractArgAdapter must be subclassed.")}};D.FuncPtrAdapter=class u extends Se{constructor(y){super(y);if(D.FuncPtrAdapter.warnOnUse)console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",y);if(this.name=y.name||"unnamed",this.signature=y.signature,y.contextKey instanceof Function){if(this.contextKey=y.contextKey,!y.bindScope)y.bindScope="context"}if(this.bindScope=y.bindScope||r("FuncPtrAdapter options requires a bindScope (explicit or implied)."),u.bindScopes.indexOf(y.bindScope)<0)r("Invalid options.bindScope ("+y.bindMod+") for FuncPtrAdapter. Expecting one of: ("+u.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=y.callProxy instanceof Function?y.callProxy:void 0}contextKey(y,O){return this}contextMap(y){let O=this.__cmap||(this.__cmap=new Map),V=O.get(y);if(V===void 0)O.set(y,V=[]);return V}convertArg(y,O,V){let Y=this.singleton;if(!Y&&this.isContext)Y=this.contextMap(this.contextKey(O,V));if(Y&&Y.length===2&&Y[0]===y)return Y[1];if(y instanceof Function){if(this.callProxy)y=this.callProxy(y);let m=U(y,this.signature,this.isTransient);if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter installed",this,this.contextKey(O,V),"@"+m,y);if(Y){if(Y[1]){if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,V),"@"+Y[1],y);try{p.scopedAlloc.pushPtr(Y[1])}catch(b){}}Y[0]=arguments[0]||R,Y[1]=m}return m}else if(t.isPtr(y)||y===null||y===void 0){if(Y&&Y[1]&&Y[1]!==y){if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,V),"@"+Y[1],y);try{p.scopedAlloc.pushPtr(Y[1])}catch(m){}Y[0]=Y[1]=y||R}return y||R}else throw TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},D.FuncPtrAdapter.warnOnUse=!1,D.FuncPtrAdapter.debugFuncInstall=!1,D.FuncPtrAdapter.debugOut=console.debug.bind(console),D.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];let me=(u)=>D.get(u)||r("Argument adapter not found:",u),K=(u)=>J.get(u)||r("Result adapter not found:",u);p.xWrap.convertArg=(u,...y)=>me(u)(...y),p.xWrap.convertArgNoCheck=(u,...y)=>D.get(u)(...y),p.xWrap.convertResult=(u,y)=>u===null?y:u?K(u)(y):void 0,p.xWrap.convertResultNoCheck=(u,y)=>u===null?y:u?J.get(u)(y):void 0,t.xWrap=function u(y,O,...V){if(arguments.length===3&&Array.isArray(arguments[2]))V=arguments[2];if(t.isPtr(y))y=t.functionEntry(y)||r("Function pointer not found in WASM function table.");let Y=y instanceof Function,m=Y?y:t.xGet(y);if(Y)y=m.name||"unnamed function";if(V.length!==m.length)S(y,m.length);if(m.length===0&&(O===null||O==="null"))return m;K(O);for(let C of V)if(C instanceof Se)D.set(C,(...c)=>C.convertArg(...c));else me(C);let b=p.xWrap;if(m.length===0)return(...C)=>C.length?S(y,m.length):b.convertResult(O,m.call(null));return function(...C){if(C.length!==m.length)S(y,m.length);let c=t.scopedAllocPush();try{let d=0;if(u.debug)console.debug("xWrap() preparing: resultType ",O,"xf",m,"argTypes",V,"args",C);for(;d<C.length;++d)C[d]=b.convertArgNoCheck(V[d],C[d],C,d);if(u.debug)console.debug("xWrap() calling: resultType ",O,"xf",m,"argTypes",V,"args",C);return b.convertResultNoCheck(O,m.apply(null,C))}finally{t.scopedAllocPop(c)}}};let oe=function(u,y,O,V,Y,m){if(typeof O==="string"){if(y===1)return m.get(O);else if(y===2){if(!V)return m.delete(O),u;else if(!(V instanceof Function))r(Y,"requires a function argument.");return m.set(O,V),u}}r("Invalid arguments to",Y)};return t.xWrap.resultAdapter=function u(y,O){return oe(u,arguments.length,y,O,"resultAdapter()",J)},t.xWrap.argAdapter=function u(y,O){return oe(u,arguments.length,y,O,"argAdapter()",D)},t.xWrap.FuncPtrAdapter=D.FuncPtrAdapter,t.xCallWrapped=function(u,y,O,...V){if(Array.isArray(arguments[3]))V=arguments[3];return t.xWrap(u,y,O||[]).apply(null,V||[])},t.xWrap.testConvertArg=p.xWrap.convertArg,t.xWrap.testConvertResult=p.xWrap.convertResult,t},globalThis.WhWasmUtilInstaller.yawl=function(t){let r=()=>fetch(t.uri,{credentials:"same-origin"}),a=this,_=function(I){if(t.wasmUtilTarget){let q=(...M)=>{throw Error(M.join(" "))},R=t.wasmUtilTarget;if(R.module=I.module,R.instance=I.instance,!R.instance.exports.memory)R.memory=t?.imports?.env?.memory||q("Missing 'memory' object!");if(!R.alloc&&I.instance.exports.malloc){let M=I.instance.exports;R.alloc=function(p){return M.malloc(p)||q("Allocation of",p,"bytes failed.")},R.dealloc=function(p){p&&M.free(p)}}a(R)}if(I.config=t,t.onload)t.onload(I);return I};return WebAssembly.instantiateStreaming?()=>WebAssembly.instantiateStreaming(r(),t.imports||{}).then(_):()=>r().then((I)=>I.arrayBuffer()).then((I)=>WebAssembly.instantiate(I,t.imports||{})).then(_)}.bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function i(t){let r=(...P)=>{throw Error(P.join(" "))};{let P=t.heap;if(P instanceof WebAssembly.Memory)P=function(){return new Uint8Array(this.buffer)}.bind(P);else if(!(P instanceof Function))r("config.heap must be WebAssembly.Memory instance or","a function which returns one.");t.heap=P}["alloc","dealloc"].forEach(function(P){t[P]instanceof Function||r("Config option '"+P+"' must be a function.")});let a=i,{heap:_,alloc:h,dealloc:I}=t,q=t.realloc||function(){r("This StructBinderFactory was configured without realloc()")},R=t.log||console.debug.bind(console),M=t.memberPrefix||"",p=t.memberSuffix||"",{BigInt:te,BigInt64Array:j}=globalThis,U=t.bigIntEnabled??!!j,E,g=t.pointerSize||t.ptrSize||(typeof(E=h(1))==="bigint"?8:4),F=t.pointerIR||t.ptrIR||(g===4?"i32":"i64");if(E)I(E),E=void 0;if(g!==4&&g!==8)r("Invalid pointer size:",g);if(F!=="i32"&&F!=="i64")r("Invalid pointer representation:",F);let x=U&&te?(P)=>te(P||0):(P)=>r("BigInt support is disabled in this build."),A=F=="i32"?Number:x,N=A(0),z=function(...P){let X=N;for(let ee=0;ee<P.length;++ee)X+=A(P[ee]);return X},f=function(...P){return z(this.pointer,...P)};if(!a.debugFlags)a.__makeDebugFlags=function(P=null){if(P&&P.__flags)P=P.__flags;let X=function ee(re){if(arguments.length===0)return ee.__flags;if(re<0)delete ee.__flags.getter,delete ee.__flags.setter,delete ee.__flags.alloc,delete ee.__flags.dealloc;else ee.__flags.getter=(1&re)!==0,ee.__flags.setter=(2&re)!==0,ee.__flags.alloc=(4&re)!==0,ee.__flags.dealloc=(8&re)!==0;return ee._flags};if(Object.defineProperty(X,"__flags",{iterable:!1,writable:!1,value:Object.create(P)}),!P)X(0);return X},a.debugFlags=a.__makeDebugFlags();let S=!0,D=(P)=>P[1]==="(",J=(P)=>P==="p"||P==="P"||P==="s",ie=(P)=>P==="P",le=(P)=>P?D(P)?"p":P[0]:void 0,Se=function(P){switch(le(P)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return F;case"j":return"i64";case"f":return"float";case"d":return"double"}r("Unhandled signature IR:",P)},me=function(P){switch(le(P)){case"c":case"C":return 1;case"i":return 4;case"p":case"P":case"s":return g;case"j":return 8;case"f":return 4;case"d":return 8}r("Unhandled signature sizeof:",P)},K=j?()=>!0:()=>r("BigInt64Array is not available."),oe=function(P){switch(le(P)){case"p":case"P":case"s":{switch(g){case 4:return"getInt32";case 8:return K()&&"getBigInt64"}break}case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return K()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}r("Unhandled DataView getter for signature:",P)},u=function(P){switch(le(P)){case"p":case"P":case"s":{switch(g){case 4:return"setInt32";case 8:return K()&&"setBigInt64"}break}case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return K()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}r("Unhandled DataView setter for signature:",P)},y=function(P){switch(le(P)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return x;case"p":case"P":case"s":switch(g){case 4:return Number;case 8:return x}break}r("Unhandled DataView set wrapper for signature:",P)},O=(P,X)=>P+"::"+X,V=function(P,X){return()=>r(O(P,X),"is read-only.")},Y=function P(X,ee=!0){let re=P.map.get(X);if(!re&&ee)P.map.set(X,re=P.create(X));return re};Y.map=new WeakMap,Y.create=(P)=>Object.assign(Object.create(null),{o:P,p:void 0,ownsPointer:!1,zod:!1,xb:0});let m=(P)=>Y.map.delete(P),b=(P)=>typeof P==="number"&&P===(P|0)&&P>=0,c=g===4?b:(P)=>typeof P==="bigint"&&P>=0||b(P),d=(P)=>c(P)&&P>0,L=function(P,X,ee){let re=Y(X,!1);if(!re||re.isDisposing)return;if(re.isDisposing=!0,!ee&&!(ee=re.p)){console.warn("Cannot(?) happen: __freeStruct() found no instanceInfo");return}if(Array.isArray(X.ondispose)){let fe;while(fe=X.ondispose.pop())try{if(fe instanceof Function)fe.call(X);else if(fe instanceof Je)fe.dispose();else if(c(fe))I(fe)}catch(Oe){console.warn("ondispose() for",P.structName,"@",ee,"threw. NOT propagating it.",Oe)}}else if(X.ondispose instanceof Function)try{X.ondispose()}catch(fe){console.warn("ondispose() for",P.structName,"@",ee,"threw. NOT propagating it.",fe)}if(m(X),delete X.ondispose,P.debugFlags.__flags.dealloc)R("debug.dealloc:",re.ownsPointer?"":"EXTERNAL",P.structName,"instance:",P.structInfo.sizeof,"bytes @"+ee);if(re.ownsPointer){if(re.zod||P.structInfo.zeroOnDispose)_().fill(0,Number(ee),Number(ee)+P.structInfo.sizeof+re.xb);I(ee)}},G=()=>({configurable:!1,writable:!1,iterable:!1}),B=(P)=>({...G(),value:P}),ae=function(X,ee,re){let fe,Oe=(xe)=>{d(xe)||r("Invalid pointer value",arguments[0],"for",X.structName,"constructor.")};if(arguments.length>=3)if(re&&typeof re==="object")fe=re,re=fe?.wrap;else Oe(re),fe={wrap:re};else fe={};let Me=!re,Qe=0,Ge=!1;if(re)Oe(re),Ge=!!fe?.takeOwnership;else{let xe=fe?.extraBytes??0;if(xe<0||xe!==(xe|0))r("Invalid extraBytes value:",fe?.extraBytes);Qe=X.structInfo.sizeof+xe,re=h(Qe)||r("Allocation of",X.structName,"structure failed."),Ge=!0}try{if(fe?.debugFlags)ee.debugFlags(fe.debugFlags);if(X.debugFlags.__flags.alloc)R("debug.alloc:",Me?"":"EXTERNAL",X.structName,"instance:",X.structInfo.sizeof,"bytes @"+re);if(Me)_().fill(0,Number(re),Number(re)+Qe);let xe=Y(ee);if(xe.p=re,xe.ownsPointer=Ge,xe.xb=Qe?Qe-X.structInfo.sizeof:0,xe.zod=!!fe?.zeroOnDispose,fe?.ondispose&&fe.ondispose!==re)ee.addOnDispose(fe.ondispose)}catch(xe){throw L(X,ee,re),xe}},ce=function P(X){return P.rxSig1??=/^[ipPsjfdcC]$/,P.rxSig2??=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/,P.rxSig1.test(X)||P.rxSig2.test(X)},ge=function(P){let X=this.get(P);if(!X)X=[Object.create(null),Object.create(null),Object.create(null)],this.set(P,X);return X}.bind(new WeakMap),qe=function(P,X,ee,re){let fe=ge(P)[X];if(arguments.length===3)return fe[ee];if(re)return fe[ee]=re;return delete fe[ee]},Fe=(P)=>P,Pe=function(P,...X){return qe(this,0,P,...X)},Ee=function(P,X){ce(X)&&r(P,"(",X,") collides with a data type signature.")},Ue=function(P,...X){return Ee("Setter adaptor",P),qe(this,1,P,...X)},He=function(P,...X){return Ee("Struct adaptor",P),qe(this,2,P,...X)},T=function(P,X){let ee=typeof X==="string"?qe(P,2,X):X;if(typeof ee!=="object")r("Invalid struct mapping object. Arg =",X,JSON.stringify(ee));return ee},Q=B((P)=>M+P+p),H=function(P,X,ee=!0){let re=P.members[X];if(!re&&(M||p)){for(let fe of Object.values(P.members))if(fe.key===X){re=fe;break}if(!re&&ee)r(O(P.name||P.structName,X),"is not a mapped struct member.")}return re},se=function P(X,ee,re=!1){if(!P._)P._=(Oe)=>Oe.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i");let fe=H(X.structInfo,ee,!0);return re?P._(fe.signature):fe.signature},_e=B(function(){let P=[];for(let X of Object.keys(this.structInfo.members))P.push(this.memberKey(X));return P}),de=new TextDecoder("utf-8"),ue=new TextEncoder,pe=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,Le=function(P,X,ee){if(g===8)X=Number(X),ee=Number(ee);return de.decode(P.buffer instanceof pe?P.slice(X,ee):P.subarray(X,ee))},Ce=function(P,X,ee=!1){let re=H(P.structInfo,X,ee);return re&&re.signature.length===1&&re.signature[0]==="s"?re:!1},Ae=function(P){if(P.signature==="s")return;r("Invalid member type signature for C-string value:",JSON.stringify(P))},Ne=function(X,ee){let re=H(X.structInfo,ee,!0);Ae(re);let fe=X[re.key];if(!fe)return null;let Oe=fe,Me=_();for(;Me[Oe]!==0;++Oe);return fe===Oe?"":Le(Me,fe,Oe)},Re=function(P,...X){if(P.ondispose){if(!Array.isArray(P.ondispose))P.ondispose=[P.ondispose]}else P.ondispose=[];P.ondispose.push(...X)},tt=function(P){let X=ue.encode(P),ee=h(X.length+1);if(!ee)r("Allocation error while duplicating string:",P);let re=_();return re.set(X,Number(ee)),re[z(ee,X.length)]=0,ee},st=function(P,X,ee){let re=H(P.structInfo,X,!0);Ae(re);let fe=tt(ee);return P[re.key]=fe,Re(P,fe),P},Je=function(X,ee){if(arguments[2]!==B)r("Do not call the StructType constructor","from client-level code.");Object.defineProperties(this,{structName:B(X),structInfo:B(ee)})};Je.prototype=Object.create(null,{dispose:B(function(){L(this.constructor,this)}),lookupMember:B(function(P,X=!0){return H(this.structInfo,P,X)}),memberToJsString:B(function(P){return Ne(this,P)}),memberIsString:B(function(P,X=!0){return Ce(this,P,X)}),memberKey:Q,memberKeys:_e,memberSignature:B(function(P,X=!1){return se(this,P,X)}),memoryDump:B(function(){let P=this.pointer;return P?new Uint8Array(_().slice(Number(P),Number(P)+this.structInfo.sizeof)):null}),extraBytes:{configurable:!1,enumerable:!1,get:function(){return Y(this,!1)?.xb??0}},zeroOnDispose:{configurable:!1,enumerable:!1,get:function(){return Y(this,!1)?.zod??!!this.structInfo.zeroOnDispose}},pointer:{configurable:!1,enumerable:!1,get:function(){return Y(this,!1)?.p},set:()=>r("Cannot assign the 'pointer' property of a struct.")},setMemberCString:B(function(P,X){return st(this,P,X)})}),Object.assign(Je.prototype,{addOnDispose:function(...P){return Re(this,...P),this}}),Object.defineProperties(Je,{allocCString:B(tt),isA:B((P)=>P instanceof Je),hasExternalPointer:B((P)=>{let X=Y(P,!1);return!!(X?.p&&!X?.ownsPointer)}),memberKey:Q});let mt=function(P){return P.get||(P.adaptGet?$e.adaptGet(P.adaptGet):void 0)},gt=function(P){return P.set||(P.adaptSet?$e.adaptSet(P.adaptSet):void 0)},_t=function P(X,ee,re){let fe=P.innerStructs??=new Map,Oe=X.memberKey(ee);if(re.signature!==void 0)r("'signature' cannot be used on an embedded struct (",X.structName,".",Oe,").");if(gt(re))r("'set' and 'adaptSet' are not permitted for nested struct members.");re.structName??=X.structName+"::"+ee,re.key=Oe,re.name=ee,re.constructor=this.call(this,re.structName,re);let Me=mt(re),Qe=Object.assign(Object.create(null),{configurable:!1,enumerable:!1,set:V(X.structName,Oe),get:function(){let Ge=this.debugFlags.__flags,xe=this.pointer,je=xe+"."+Oe,he=fe.get(je);if(Ge.getter)R("debug.getter: k =",je);if(!he)he=new re.constructor(z(xe,re.offset)),fe.set(je,he),this.addOnDispose(()=>he.dispose()),he.addOnDispose(()=>fe.delete(je));if(Me)he=Me.apply(this,[he,Oe]);if(Ge.getter)R("debug.getter: result =",he);return he}});Object.defineProperty(X.prototype,Oe,Qe)},Mt=function P(X,ee,re){if(re=T(this,re),re.members)return _t.call(this,X,ee,re);if(!P.cache){P.cache={getters:{},setters:{},sw:{}};let je=["i","c","C","p","P","s","f","d","v()"];if(U)je.push("j");je.forEach(function(he){P.cache.getters[he]=oe(he),P.cache.setters[he]=u(he),P.cache.sw[he]=y(he)}),P.sigCheck=function(he,De,At,Sn){if(Object.prototype.hasOwnProperty.call(he,At))r(he.structName,"already has a property named",At+".");ce(Sn)||r("Malformed signature for",O(he.structName,De)+":",Sn)}}let fe=X.memberKey(ee);P.sigCheck(X.prototype,ee,fe,re.signature),re.key=fe,re.name=ee;let Oe=le(re.signature),Me=O(X.structName,fe),Qe=X.debugFlags.__flags,Ge=mt(re),xe=Object.create(null);if(xe.configurable=!1,xe.enumerable=!1,xe.get=function(){if(Qe.getter)R("debug.getter:",P.cache.getters[Oe],"for",Se(Oe),Me,"@",this.pointer,"+",re.offset,"sz",re.sizeof);let je=new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[P.cache.getters[Oe]](0,S);if(Ge)je=Ge.apply(this,[fe,je]);if(Qe.getter)R("debug.getter:",Me,"result =",je);return je},re.readOnly)xe.set=V(X.prototype.structName,fe);else{let je=gt(re);xe.set=function(he){if(Qe.setter)R("debug.setter:",P.cache.setters[Oe],"for",Se(Oe),Me,"@",this.pointer,"+",re.offset,"sz",re.sizeof,he);if(!this.pointer)r("Cannot set native property on a disposed",this.structName,"instance.");if(je)he=je.apply(this,[fe,he]);if(he===null||he===void 0)he=N;else if(J(re.signature)&&!c(he))if(ie(re.signature)&&he instanceof Je){if(he=he.pointer||N,Qe.setter)R("debug.setter:",Me,"resolved to",he)}else r("Invalid value for pointer-type",Me+".");new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[P.cache.setters[Oe]](0,P.cache.sw[Oe](he),S)}}Object.defineProperty(X.prototype,fe,xe)},vn=function P(X,ee,re=Object.create(null)){let fe=function he(De){if(!(this instanceof he))r("The",X,"constructor may only be called via 'new'.");ae(he,this,...arguments)},Oe=this,Me=(he)=>typeof he==="string"&&ce(he)?{signature:he}:T(Oe,he);if(arguments.length===1)ee=Me(X),X=ee.structName||ee.name;else if(arguments.length===2)ee=Me(ee),ee.name??=X;else ee=Me(ee);if(X??=ee.structName,X??=re.structName,!X)r("One of 'name' or 'structName' are required.");if(ee.adapt)Object.keys(ee.adapt.struct||{}).forEach((he)=>{He.call(P,he,ee.adapt.struct[he])}),Object.keys(ee.adapt.set||{}).forEach((he)=>{Ue.call(P,he,ee.adapt.set[he])}),Object.keys(ee.adapt.get||{}).forEach((he)=>{Pe.call(P,he,ee.adapt.get[he])});if(!ee.members&&!ee.sizeof)ee.sizeof=me(ee.signature);let Qe=B(a.__makeDebugFlags($e.debugFlags));Object.defineProperties(fe,{debugFlags:Qe,isA:B((he)=>he instanceof fe),memberKey:Q,memberKeys:_e,structInfo:B(ee),structName:B(X),ptrAdd:B(z)}),fe.prototype=new Je(X,ee,B),Object.defineProperties(fe.prototype,{debugFlags:Qe,constructor:B(fe),ptrAdd:B(f)});let Ge=!1,xe=0,je=!!ee.autoCalcSizeOffset;if(!je){if(!ee.sizeof)r(X,"description is missing its sizeof property.");ee.offset??=0}else ee.offset??=0;if(Object.keys(ee.members||{}).forEach((he)=>{let De=Me(ee.members[he]);if(!De.members&&!De.sizeof){if(De.sizeof=me(De.signature),!De.sizeof)r(O(X,he),"is missing a sizeof property.",De)}if(De.offset===void 0)if(je)De.offset=xe;else r(O(X,he),"is missing its offset.",JSON.stringify(De));if(ee.members[he]=De,!Ge||Ge.offset<De.offset)Ge=De;let At=!!De.autoCalc;if(je)De.autoCalcSizeOffset=!0;if(Mt.call(Oe,fe,he,De),At)De.autoCalcSizeOffset=!0;else delete De.autoCalcSizeOffset;xe+=De.sizeof}),!Ge)r("No member property descriptions found.");if(!ee.sizeof)ee.sizeof=xe;if(ee.sizeof===1)ee.signature==="c"||ee.signature==="C"||r("Unexpected sizeof==1 member",O(X,k),"with signature",ee.signature);else{if(ee.sizeof%4!==0)console.warn("Invalid struct member description",ee),r(X,"sizeof is not aligned. sizeof="+ee.sizeof);if(ee.offset%4!==0)console.warn("Invalid struct member description",ee),r(X,"offset is not aligned. offset="+ee.offset)}if(ee.sizeof<xe)console.warn("Suspect struct description:",ee,"offset =",xe),r("Mismatch in the calculated vs. the provided sizeof/offset info.","Expected sizeof",xe,"but got",ee.sizeof,"for",ee);return delete ee.autoCalcSizeOffset,fe},$e=function P(X,ee){return arguments.length==1?vn.call(P,X):vn.call(P,X,ee)};if($e.StructType=Je,$e.config=t,$e.allocCString=tt,$e.adaptGet=Pe,$e.adaptSet=Ue,$e.adaptStruct=He,$e.ptrAdd=z,!$e.debugFlags)$e.debugFlags=a.__makeDebugFlags(a.debugFlags);return $e},globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=(...E)=>{throw Error(E.join(" "))},{capi:r,wasm:a,util:_}=i;globalThis.WhWasmUtilInstaller(a),delete globalThis.WhWasmUtilInstaller;let h={core:[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_backup_init","sqlite3_backup*","sqlite3*","string","sqlite3*","string"],["sqlite3_backup_step","int","sqlite3_backup*","int"],["sqlite3_backup_finish","int","sqlite3_backup*"],["sqlite3_backup_remaining","int","sqlite3_backup*"],["sqlite3_backup_pagecount","int","sqlite3_backup*"],["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 a.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(E,g)=>E[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 a.xWrap.FuncPtrAdapter({name:"sqlite3_commit_hook",signature:"i(p)",contextKey:(E)=>E[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 a.xWrap.FuncPtrAdapter({signature:"i(pipp)",bindScope:"transient",callProxy:(E)=>{let g;return(F,x,A,N)=>{try{let z=a.cArgvToJs(x,A);if(!g)g=a.cArgvToJs(x,N);return E(z,g)|0}catch(z){return z.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 a.xWrap.FuncPtrAdapter({name:"sqlite3_rollback_hook",signature:"v(p)",contextKey:(E)=>E[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 a.xWrap.FuncPtrAdapter({name:"sqlite3_trace_v2::callback",signature:"i(ippp)",contextKey:(E,g)=>E[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 a.xWrap.FuncPtrAdapter({name:"sqlite3_update_hook::callback",signature:"v(pippj)",contextKey:(E)=>E[0],callProxy:(E)=>(g,F,x,A,N)=>{E(g,F,a.cstrToJs(x),a.cstrToJs(A),N)}}),"*"]],["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(a.exports.sqlite3_progress_handler)h.core.push(["sqlite3_progress_handler",void 0,["sqlite3*","int",new a.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(E,g)=>E[0]}),"*"]]);if(a.exports.sqlite3_stmt_explain)h.core.push(["sqlite3_stmt_explain","int","sqlite3_stmt*","int"],["sqlite3_stmt_isexplain","int","sqlite3_stmt*"]);if(a.exports.sqlite3_set_authorizer)h.core.push(["sqlite3_set_authorizer","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(E,g)=>E[0],callProxy:(E)=>(g,F,x,A,N,z)=>{try{return x=x&&a.cstrToJs(x),A=A&&a.cstrToJs(A),N=N&&a.cstrToJs(N),z=z&&a.cstrToJs(z),E(g,F,x,A,N,z)|0}catch(f){return f.resultCode||r.SQLITE_ERROR}}}),"*"]]);if(a.exports.sqlite3_column_origin_name)h.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"]);if(a.exports.sqlite3_key_v2)h.core.push(["sqlite3_key","int","sqlite3*","string","int"],["sqlite3_key_v2","int","sqlite3*","string","*","int"],["sqlite3_rekey","int","sqlite3*","string","int"],["sqlite3_rekey_v2","int","sqlite3*","string","*","int"],["sqlite3_activate_see",void 0,"string"],["sqlite3mc_cipher_count","int"],["sqlite3mc_cipher_index","int","string"],["sqlite3mc_cipher_name","string","int"],["sqlite3mc_cipher_name_copy","int","int","string","int"],["sqlite3mc_config","int","sqlite3*","string","int"],["sqlite3mc_config_cipher","int","sqlite3*","string","string","int"],["sqlite3mc_codec_data","string","sqlite3*","string","string"],["sqlite3mc_version","string"],["sqlite3mc_vfs_create","int","string","int"],["sqlite3mc_vfs_destroy",void 0,"string"],["sqlite3mc_vfs_shutdown",void 0]);if(a.bigIntEnabled&&!!a.exports.sqlite3_declare_vtab)h.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","**"]);if(a.bigIntEnabled&&!!a.exports.sqlite3_preupdate_hook)h.int64.push(["sqlite3_preupdate_blobwrite","int","sqlite3*"],["sqlite3_preupdate_count","int","sqlite3*"],["sqlite3_preupdate_depth","int","sqlite3*"],["sqlite3_preupdate_hook","*",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_preupdate_hook",signature:"v(ppippjj)",contextKey:(E)=>E[0],callProxy:(E)=>(g,F,x,A,N,z,f)=>{E(g,F,x,a.cstrToJs(A),a.cstrToJs(N),z,f)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]]);if(a.bigIntEnabled&&!!a.exports.sqlite3changegroup_add&&!!a.exports.sqlite3session_create&&!!a.exports.sqlite3_preupdate_hook){let E={signature:"i(ps)",callProxy:(g)=>(F,x)=>{try{return g(F,a.cstrToJs(x))|0}catch(A){return A.resultCode||r.SQLITE_ERROR}}};h.int64.push(["sqlite3changegroup_add","int",["sqlite3_changegroup*","int","void*"]],["sqlite3changegroup_add_strm","int",["sqlite3_changegroup*",new a.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 a.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_v2","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v2_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new a.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 a.xWrap.FuncPtrAdapter({name:"xInputA",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xInputB",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.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 a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.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 a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changeset_start_v2","int",["**","int","*","int"]],["sqlite3changeset_start_v2_strm","int",["**",new a.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 a.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 a.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_table_filter",void 0,["sqlite3_session*",new a.xWrap.FuncPtrAdapter({name:"xFilter",...E,contextKey:(g,F)=>g[0]}),"*"]])}i.StructBinder=globalThis.Jaccwabyt({heap:a.heap8u,alloc:a.alloc,dealloc:a.dealloc,bigIntEnabled:a.bigIntEnabled,pointerIR:a.ptr.ir,memberPrefix:"$"}),delete globalThis.Jaccwabyt;{let E=a.xWrap.argAdapter("string");a.xWrap.argAdapter("string:flexible",(A)=>E(_.flexibleString(A))),a.xWrap.argAdapter("string:static",function(A){if(a.isPtr(A))return A;return A=""+A,this[A]||(this[A]=a.allocCString(A))}.bind(Object.create(null)));let g=a.xWrap.argAdapter("*"),F=function(){};if(a.xWrap.argAdapter("sqlite3_filename",g)("sqlite3_backup*",g)("sqlite3_context*",g)("sqlite3_value*",g)("void*",g)("sqlite3_changegroup*",g)("sqlite3_changeset_iter*",g)("sqlite3_session*",g)("sqlite3_stmt*",(A)=>g(A instanceof(i?.oo1?.Stmt||F)?A.pointer:A))("sqlite3*",(A)=>g(A instanceof(i?.oo1?.DB||F)?A.pointer:A))("sqlite3_vfs*",(A)=>{if(typeof A==="string")return r.sqlite3_vfs_find(A)||i.SQLite3Error.toss(r.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",A);return g(A instanceof(r.sqlite3_vfs||F)?A.pointer:A)}),a.exports.sqlite3_declare_vtab)a.xWrap.argAdapter("sqlite3_index_info*",(A)=>g(A instanceof(r.sqlite3_index_info||F)?A.pointer:A))("sqlite3_module*",(A)=>g(A instanceof(r.sqlite3_module||F)?A.pointer:A));let x=a.xWrap.resultAdapter("*");a.xWrap.resultAdapter("sqlite3*",x)("sqlite3_backup*",x)("sqlite3_context*",x)("sqlite3_stmt*",x)("sqlite3_value*",x)("sqlite3_vfs*",x)("void*",x);for(let A of h.core)r[A[0]]=a.xWrap.apply(null,A);for(let A of h.wasmInternal)_[A[0]]=a.xWrap.apply(null,A);for(let A of h.int64)r[A[0]]=a.bigIntEnabled?a.xWrap.apply(null,A):()=>t(A[0]+"() is unavailable due to lack","of BigInt support in this build.");delete h.core,delete h.int64,delete h.wasmInternal,_.sqlite3__wasm_db_error=function(A,N,z){if(!A)return r.SQLITE_MISUSE;if(N instanceof i.WasmAllocError)N=r.SQLITE_NOMEM,z=0;else if(N instanceof Error)z=z||""+N,N=N.resultCode||r.SQLITE_ERROR;return r.sqlite3_set_errmsg(A,N,z)||N}}{let E=a.xCall("sqlite3__wasm_enum_json");if(!E)t("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!");a.ctype=JSON.parse(a.cstrToJs(E));let g=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];if(a.bigIntEnabled)g.push("serialize","session","vtab");for(let A of g)for(let N of Object.entries(a.ctype[A]))r[N[0]]=N[1];if(!a.functionEntry(r.SQLITE_WASM_DEALLOC))t("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+r.SQLITE_WASM_DEALLOC+").");let F=Object.create(null);for(let A of Object.entries(a.ctype.resultCodes))F[A[1]]=A[0];r.sqlite3_js_rc_str=(A)=>F[A];let x=Object.assign(Object.create(null),{WasmTestStruct:!0,sqlite3_index_info:!a.bigIntEnabled,sqlite3_index_constraint:!a.bigIntEnabled,sqlite3_index_orderby:!a.bigIntEnabled,sqlite3_index_constraint_usage:!a.bigIntEnabled});for(let A of a.ctype.structs)if(!x[A.name])r[A.name]=i.StructBinder(A);if(r.sqlite3_index_info){for(let 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=a.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}let I=(E,g,F)=>_.sqlite3__wasm_db_error(E,r.SQLITE_MISUSE,g+"() requires "+F+" argument"+(F===1?"":"s")+"."),q=(E)=>_.sqlite3__wasm_db_error(E,r.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),R=(E)=>a.xWrap.argAdapter("sqlite3*")(E),M=(E)=>a.isPtr(E)?a.cstrToJs(E):E,p=function(E,g){E=R(E);let F=this.dbMap.get(E);if(!g)return this.dbMap.delete(E),F;else if(!F&&g>0)this.dbMap.set(E,F=Object.create(null));return F}.bind(Object.assign(Object.create(null),{dbMap:new Map}));if(p.addCollation=function(E,g){let F=p(E,1);if(!F.collation)F.collation=new Set;F.collation.add(M(g).toLowerCase())},p._addUDF=function(E,g,F,x){g=M(g).toLowerCase();let A=x.get(g);if(!A)x.set(g,A=new Set);A.add(F<0?-1:F)},p.addFunction=function(E,g,F){let x=p(E,1);if(!x.udf)x.udf=new Map;this._addUDF(E,g,F,x.udf)},a.exports.sqlite3_create_window_function)p.addWindowFunc=function(E,g,F){let x=p(E,1);if(!x.wudf)x.wudf=new Map;this._addUDF(E,g,F,x.wudf)};p.cleanup=function(E){E=R(E);for(let x 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]]){let[A,N]=x;if(!a.exports[A])continue;let f=[E];f.length=N;try{r[A](...f)}catch(S){i.config.warn("close-time call of",A+"(",f,") threw:",S)}}let g=p(E,0);if(!g)return;if(g.collation){for(let x of g.collation)try{r.sqlite3_create_collation_v2(E,x,r.SQLITE_UTF8,0,0,0)}catch(A){}delete g.collation}let F;for(F=0;F<2;++F){let x=F?g.wudf:g.udf;if(!x)continue;let A=F?r.sqlite3_create_window_function:r.sqlite3_create_function_v2;for(let N of x){let z=N[0],f=N[1],S=[E,z,0,r.SQLITE_UTF8,0,0,0,0,0];if(F)S.push(0);for(let D of f)try{S[2]=D,A.apply(null,S)}catch(J){}f.clear()}x.clear()}delete g.udf,delete g.wudf};{let E=a.xWrap("sqlite3_close_v2","int","sqlite3*");r.sqlite3_close_v2=function(g){if(arguments.length!==1)return I(g,"sqlite3_close_v2",1);if(g)try{p.cleanup(g)}catch(F){}return E(g)}}if(r.sqlite3session_create){let E=a.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);r.sqlite3session_delete=function(g){if(arguments.length!==1)return I(pDb,"sqlite3session_delete",1);else if(g)r.sqlite3session_table_filter(g,0,0);E(g)}}{let E=(F,x)=>"argv["+x+"]:"+F[0]+":"+a.cstrToJs(F[1]).toLowerCase(),g=a.xWrap("sqlite3_create_collation_v2","int",["sqlite3*","string","int","*",new a.xWrap.FuncPtrAdapter({name:"xCompare",signature:"i(pipip)",contextKey:E}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",signature:"v(p)",contextKey:E})]);r.sqlite3_create_collation_v2=function(F,x,A,N,z,f){if(arguments.length!==6)return I(F,"sqlite3_create_collation_v2",6);else if((A&15)===0)A|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(A&15))return q(F);try{let S=g(F,x,A,N,z,f);if(S===0&&z instanceof Function)p.addCollation(F,x);return S}catch(S){return _.sqlite3__wasm_db_error(F,S)}},r.sqlite3_create_collation=(F,x,A,N,z)=>arguments.length===5?r.sqlite3_create_collation_v2(F,x,A,N,z,0):I(F,"sqlite3_create_collation",5)}{let E=function(A,N){return A[0]+":"+(A[2]<0?-1:A[2])+":"+N+":"+a.cstrToJs(A[1]).toLowerCase()},g=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:E,callProxy:(A)=>(N,z,f)=>{try{A(N,...r.sqlite3_values_to_js(z,f))}catch(S){r.sqlite3_result_error_js(N,S)}}},xFinalAndValue:{signature:"v(p)",contextKey:E,callProxy:(A)=>(N)=>{try{r.sqlite3_result_js(N,A(N))}catch(z){r.sqlite3_result_error_js(N,z)}}},xFunc:{signature:"v(pip)",contextKey:E,callProxy:(A)=>(N,z,f)=>{try{r.sqlite3_result_js(N,A(N,...r.sqlite3_values_to_js(z,f)))}catch(S){r.sqlite3_result_error_js(N,S)}}},xDestroy:{signature:"v(p)",contextKey:E,callProxy:(A)=>(N)=>{try{A(N)}catch(z){console.error("UDF xDestroy method threw:",z)}}}}),F=a.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xFunc",...g.xFunc}),new a.xWrap.FuncPtrAdapter({name:"xStep",...g.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...g.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...g.xDestroy})]),x=a.exports.sqlite3_create_window_function?a.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xStep",...g.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...g.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xValue",...g.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xInverse",...g.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...g.xDestroy})]):void 0;if(r.sqlite3_create_function_v2=function A(N,z,f,S,D,J,ie,le,Se){if(A.length!==arguments.length)return I(N,"sqlite3_create_function_v2",A.length);else if((S&15)===0)S|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(S&15))return q(N);try{let me=F(N,z,f,S,D,J,ie,le,Se);if(me===0&&(J instanceof Function||ie instanceof Function||le instanceof Function||Se instanceof Function))p.addFunction(N,z,f);return me}catch(me){return console.error("sqlite3_create_function_v2() setup threw:",me),_.sqlite3__wasm_db_error(N,me,"Creation of UDF threw: "+me)}},r.sqlite3_create_function=function A(N,z,f,S,D,J,ie,le){return A.length===arguments.length?r.sqlite3_create_function_v2(N,z,f,S,D,J,ie,le,0):I(N,"sqlite3_create_function",A.length)},x)r.sqlite3_create_window_function=function A(N,z,f,S,D,J,ie,le,Se,me){if(A.length!==arguments.length)return I(N,"sqlite3_create_window_function",A.length);else if((S&15)===0)S|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(S&15))return q(N);try{let K=x(N,z,f,S,D,J,ie,le,Se,me);if(K===0&&(J instanceof Function||ie instanceof Function||le instanceof Function||Se instanceof Function||me instanceof Function))p.addWindowFunc(N,z,f);return K}catch(K){return console.error("sqlite3_create_window_function() setup threw:",K),_.sqlite3__wasm_db_error(N,K,"Creation of UDF threw: "+K)}};else delete r.sqlite3_create_window_function;if(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;if(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;if(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}{let E=(F,x)=>{if(typeof F==="string")x=-1;else if(_.isSQLableTypedArray(F))x=F.byteLength,F=a.typedArrayToString(F instanceof ArrayBuffer?new Uint8Array(F):F);else if(Array.isArray(F))F=F.join(""),x=-1;return[F,x]},g={basic:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};r.sqlite3_prepare_v3=function F(x,A,N,z,f,S){if(F.length!==arguments.length)return I(x,"sqlite3_prepare_v3",F.length);let[D,J]=E(A,Number(N));switch(typeof D){case"string":return g.basic(x,D,J,z,f,null);case typeof a.ptr.null:return g.full(x,a.ptr.coerce(D),J,z,f,S);default:return _.sqlite3__wasm_db_error(x,r.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3(). typeof="+typeof D)}},r.sqlite3_prepare_v2=function F(x,A,N,z,f){return F.length===arguments.length?r.sqlite3_prepare_v3(x,A,N,0,z,f):I(x,"sqlite3_prepare_v2",F.length)}}{let E=a.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),g=a.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);r.sqlite3_bind_text=function F(x,A,N,z,f){if(F.length!==arguments.length)return I(r.sqlite3_db_handle(x),"sqlite3_bind_text",F.length);else if(a.isPtr(N)||N===null)return E(x,A,N,z,f);else if(N instanceof ArrayBuffer)N=new Uint8Array(N);else if(Array.isArray(pMem))N=pMem.join("");let S,D;try{if(_.isSQLableTypedArray(N))S=a.allocFromTypedArray(N),D=N.byteLength;else if(typeof N==="string")[S,D]=a.allocCString(N);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return E(x,A,S,D,r.SQLITE_WASM_DEALLOC)}catch(J){return a.dealloc(S),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),J)}},r.sqlite3_bind_blob=function F(x,A,N,z,f){if(F.length!==arguments.length)return I(r.sqlite3_db_handle(x),"sqlite3_bind_blob",F.length);else if(a.isPtr(N)||N===null)return g(x,A,N,z,f);else if(N instanceof ArrayBuffer)N=new Uint8Array(N);else if(Array.isArray(N))N=N.join("");let S,D;try{if(_.isBindableTypedArray(N))S=a.allocFromTypedArray(N),D=z>=0?z:N.byteLength;else if(typeof N==="string")[S,D]=a.allocCString(N);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return g(x,A,S,D,r.SQLITE_WASM_DEALLOC)}catch(J){return a.dealloc(S),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),J)}}}if(!r.sqlite3_column_text){let E=a.xWrap.argAdapter("sqlite3_stmt*"),g=a.xWrap.argAdapter("int"),F=a.xWrap.argAdapter("sqlite3_value*"),x=(A,N)=>a.typedArrayToString(a.heap8u(),Number(A),Number(A)+N);r.sqlite3_column_text=function(A,N){let z=E(A),f=g(N),S=a.exports.sqlite3_column_text(z,f);return S?x(S,a.exports.sqlite3_column_bytes(z,f)):null},r.sqlite3_value_text=function(A){let N=F(A),z=a.exports.sqlite3_value_text(N);return z?x(z,a.exports.sqlite3_value_bytes(N)):null}}r.sqlite3_config=function(E,...g){if(arguments.length<2)return r.SQLITE_MISUSE;switch(E){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 a.exports.sqlite3__wasm_config_i(E,g[0]);case r.SQLITE_CONFIG_LOOKASIDE:return a.exports.sqlite3__wasm_config_ii(E,g[0],g[1]);case r.SQLITE_CONFIG_MEMDB_MAXSIZE:return a.exports.sqlite3__wasm_config_j(E,g[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}};{let E=new Set;r.sqlite3_auto_extension=function(g){if(g instanceof Function)g=a.installFunction("i(ppp)",g);else if(arguments.length!==1||!a.isPtr(g))return r.SQLITE_MISUSE;let F=a.exports.sqlite3_auto_extension(g);if(g!==arguments[0])if(F===0)E.add(g);else a.uninstallFunction(g);return F},r.sqlite3_cancel_auto_extension=function(g){if(!g||arguments.length!==1||!a.isPtr(g))return 0;return a.exports.sqlite3_cancel_auto_extension(g)},r.sqlite3_reset_auto_extension=function(){a.exports.sqlite3_reset_auto_extension();for(let g of E)a.uninstallFunction(g);E.clear()}}a.xWrap.FuncPtrAdapter.warnOnUse=!0;let te=i.StructBinder,j=function E(g,F,x,A=E.installMethodArgcCheck){if(!(g instanceof te.StructType))t("Usage error: target object is-not-a StructType.");else if(!(x instanceof Function)&&!a.isPtr(x))t("Usage error: expecting a Function or WASM pointer to one.");if(arguments.length===1)return(S,D)=>E(g,S,D,A);if(!E.argcProxy)E.argcProxy=function(S,D,J,ie){return function(...le){if(J.length!==arguments.length)t("Argument mismatch for",S.structInfo.name+"::"+D+": Native signature is:",ie);return J.apply(this,le)}},E.removeFuncList=function(){if(this.ondispose.__removeFuncList)this.ondispose.__removeFuncList.forEach((S,D)=>{if(a.isPtr(S))try{a.uninstallFunction(S)}catch(J){}}),delete this.ondispose.__removeFuncList};let N=g.memberSignature(F);if(N.length<2)t("Member",F,"does not have a function pointer signature:",N);let z=g.memberKey(F),f=A&&!a.isPtr(x)?E.argcProxy(g,z,x,N):x;if(a.isPtr(f)){if(f&&!a.functionEntry(f))t("Pointer",f,"is not a WASM function table entry.");g[z]=f}else{let S=a.installFunction(f,N);if(g[z]=S,!g.ondispose||!g.ondispose.__removeFuncList)g.addOnDispose("ondispose.__removeFuncList handler",E.removeFuncList),g.ondispose.__removeFuncList=[];g.ondispose.__removeFuncList.push(z,S)}return(S,D)=>E(g,S,D,A)};j.installMethodArgcCheck=!1;let U=function(E,g,F=j.installMethodArgcCheck){let x=new Map;for(let A of Object.keys(g)){let N=g[A],z=x.get(N);if(z){let f=E.memberKey(A);E[f]=E[E.memberKey(z)]}else j(E,A,N,F),x.set(N,A)}return E};te.StructType.prototype.installMethod=function(g,F,x=j.installMethodArgcCheck){return arguments.length<3&&g&&typeof g==="object"?U(this,...arguments):j(this,...arguments)},te.StructType.prototype.installMethods=function(E,g=j.installMethodArgcCheck){return U(this,E,g)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=(...m)=>{throw new i.SQLite3Error(...m)},{capi:r,wasm:a,util:_}=i,h=function(m){return(...b)=>m("sqlite3.oo1:",...b)},I=i.__isUnderTest?h(console.debug.bind(console)):h(i.config.debug),q=i.__isUnderTest?h(console.warn.bind(console)):h(i.config.warn),R=i.__isUnderTest?h(console.error.bind(console)):h(i.config.error),M=new WeakMap,p=new Set,te=new WeakMap,j=(m,b,C)=>{let c=Object.getOwnPropertyDescriptor(m,b);return c?c.value:C},U=function(m,b){if(b){if(m instanceof N)m=m.pointer;t(b,"sqlite3 result code",b+":",m?r.sqlite3_errmsg(m):r.sqlite3_errstr(b))}return arguments[0]},E=a.installFunction("i(ippp)",function(m,b,C,c){if(r.SQLITE_TRACE_STMT===m)console.log("SQL TRACE #"+ ++this.counter,"via sqlite3@"+b+"["+r.sqlite3_db_filename(b,null)+"]",a.cstrToJs(c))}.bind({counter:0})),g=Object.create(null),F=function(m){if(m instanceof ArrayBuffer)m=new Uint8Array(m);let b=[],C="0123456789abcdef";for(let c of m)b.push(C[(c&240)>>4],C[c&15]);return b.join("")},x=function(m,b){if(!r.sqlite3_key_v2)return;let C,c,d=(b.key?1:0)+(b.hexkey?1:0)+(b.textkey?1:0);if(!d)return;else if(d>1)t(r.SQLITE_MISUSE,"Only ONE of (key, hexkey, textkey) may be provided.");if(b.key){if(C="key",c=b.key,typeof c==="string")c=new TextEncoder("utf-8").encode(c);if(c instanceof ArrayBuffer||c instanceof Uint8Array)c=F(c),C="hexkey";else{t(r.SQLITE_MISUSE,"Invalid value for the 'key' option. Expecting a string,","ArrayBuffer, or Uint8Array.");return}}else if(b.textkey){if(C="textkey",c=b.textkey,c instanceof ArrayBuffer)c=new Uint8Array(c);if(c instanceof Uint8Array)c=new TextDecoder("utf-8").decode(c);else if(typeof c!=="string")t(r.SQLITE_MISUSE,"Invalid value for the 'textkey' option. Expecting a string,","ArrayBuffer, or Uint8Array.")}else if(b.hexkey){if(C="hexkey",c=b.hexkey,c instanceof ArrayBuffer||c instanceof Uint8Array)c=F(c);else if(typeof c!=="string")t(r.SQLITE_MISUSE,"Invalid value for the 'hexkey' option. Expecting a string,","ArrayBuffer, or Uint8Array.")}else return;let L;try{return L=m.prepare("PRAGMA "+C+"="+_.sqlite3__wasm_qfmt_token(c,1)),L.step(),!0}finally{if(L)L.finalize()}},A=function m(...b){let C=m.normalizeArgs(...b),c;if(c=C["sqlite3*"]){if(!C["sqlite3*:takeOwnership"])p.add(this);this.filename=r.sqlite3_db_filename(c,"main")}else{let{filename:d,vfs:L,flags:G}=C;if(typeof d!=="string"&&!a.isPtr(d)||typeof G!=="string"||L&&(typeof L!=="string"&&!a.isPtr(L)))i.config.error("Invalid DB ctor args",C,arguments),t("Invalid arguments for DB constructor:",arguments,"opts:",C);let B=0;if(G.indexOf("c")>=0)B|=r.SQLITE_OPEN_CREATE|r.SQLITE_OPEN_READWRITE;if(G.indexOf("w")>=0)B|=r.SQLITE_OPEN_READWRITE;if(B===0)B|=r.SQLITE_OPEN_READONLY;B|=r.SQLITE_OPEN_EXRESCODE;let ae=a.pstack.pointer;try{let ce=a.pstack.allocPtr(),ge=r.sqlite3_open_v2(d,ce,B,L||a.ptr.null);if(c=a.peekPtr(ce),U(c,ge),r.sqlite3_extended_result_codes(c,1),G.indexOf("t")>=0)r.sqlite3_trace_v2(c,r.SQLITE_TRACE_STMT,E,c)}catch(ce){if(c)r.sqlite3_close_v2(c);throw ce}finally{a.pstack.restore(ae)}this.filename=a.isPtr(d)?a.cstrToJs(d):d}if(M.set(this,c),te.set(this,Object.create(null)),!C["sqlite3*"])try{x(this,C);let d=r.sqlite3_js_db_vfs(c)||t("Internal error: cannot get VFS for new db handle."),L=g[d];if(L)if(L instanceof Function)L(this,i);else U(c,r.sqlite3_exec(c,L,0,0,0))}catch(d){throw this.close(),d}};A.setVfsPostOpenCallback=function(m,b){if(!(b instanceof Function))t("dbCtorHelper.setVfsPostOpenCallback() should not be used with a non-function argument.",arguments);g[m]=b},A.normalizeArgs=function(m=":memory:",b="c",C=null){let c={};if(arguments.length===1&&arguments[0]&&typeof arguments[0]==="object"){if(Object.assign(c,arguments[0]),c.flags===void 0)c.flags="c";if(c.vfs===void 0)c.vfs=null;if(c.filename===void 0)c.filename=":memory:"}else c.filename=m,c.flags=b,c.vfs=C;return c};let N=function(...m){A.apply(this,m)};N.dbCtorHelper=A;let z={null:1,number:2,string:3,boolean:4,blob:5};if(a.bigIntEnabled)z.bigint=z.number;let f=function(){if(z!==arguments[2])t(r.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare().");if(this.db=arguments[0],M.set(this,arguments[1]),arguments.length>3&&!arguments[3])p.add(this)},S=function(m){if(!m.pointer)t("DB has been closed.");return m},D=function(m,b){if(b!==(b|0)||b<0||b>=m.columnCount)t("Column index",b,"is out of range.");return m},J=function(m,b){let C=Object.create(null);switch(C.opt=Object.create(null),b.length){case 1:if(typeof b[0]==="string"||_.isSQLableTypedArray(b[0]))C.sql=b[0];else if(Array.isArray(b[0]))C.sql=b[0];else if(b[0]&&typeof b[0]==="object")C.opt=b[0],C.sql=C.opt.sql;break;case 2:C.sql=b[0],C.opt=b[1];break;default:t("Invalid argument count for exec().")}if(C.sql=_.flexibleString(C.sql),typeof C.sql!=="string")t("Missing SQL argument or unsupported SQL value type.");let c=C.opt;switch(c.returnValue){case"resultRows":if(!c.resultRows)c.resultRows=[];C.returnVal=()=>c.resultRows;break;case"saveSql":if(!c.saveSql)c.saveSql=[];C.returnVal=()=>c.saveSql;break;case void 0:case"this":C.returnVal=()=>m;break;default:t("Invalid returnValue value:",c.returnValue)}if(!c.callback&&!c.returnValue&&c.rowMode!==void 0){if(!c.resultRows)c.resultRows=[];C.returnVal=()=>c.resultRows}if(c.callback||c.resultRows)switch(c.rowMode===void 0?"array":c.rowMode){case"object":C.cbArg=(d,L)=>{if(!L.columnNames)L.columnNames=d.getColumnNames([]);let G=d.get([]),B=Object.create(null);for(let ae in L.columnNames)B[L.columnNames[ae]]=G[ae];return B};break;case"array":C.cbArg=(d)=>d.get([]);break;case"stmt":if(Array.isArray(c.resultRows))t("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference.");C.cbArg=(d)=>d;break;default:if(_.isInt32(c.rowMode)){C.cbArg=(d)=>d.get(c.rowMode);break}else if(typeof c.rowMode==="string"&&c.rowMode.length>1&&c.rowMode[0]==="$"){let d=c.rowMode.substr(1);C.cbArg=(L)=>{let G=L.get(Object.create(null))[d];return G===void 0?t(r.SQLITE_NOTFOUND,"exec(): unknown result column:",d):G};break}t("Invalid rowMode:",c.rowMode)}return C},ie=(m,b,C,...c)=>{let d=m.prepare(b);try{let L=d.bind(C).step()?d.get(...c):void 0;return d.reset(),L}finally{d.finalize()}},le=(m,b,C,c)=>m.exec({sql:b,bind:C,rowMode:c,returnValue:"resultRows"}),Se=(m,b,C)=>{switch(C===void 0?r.sqlite3_column_type(m.pointer,b):C){case r.SQLITE_NULL:return null;case r.SQLITE_INTEGER:if(a.bigIntEnabled){let c=r.sqlite3_column_int64(m.pointer,b);if(c>=Number.MIN_SAFE_INTEGER&&c<=Number.MAX_SAFE_INTEGER)return Number(c).valueOf();return c}else{let c=r.sqlite3_column_double(m.pointer,b);if(c>Number.MAX_SAFE_INTEGER||c<Number.MIN_SAFE_INTEGER)t("Integer is out of range for JS integer range: "+c);return _.isInt32(c)?c|0:c}case r.SQLITE_FLOAT:return r.sqlite3_column_double(m.pointer,b);case r.SQLITE_TEXT:return r.sqlite3_column_text(m.pointer,b);case r.SQLITE_BLOB:{let c=r.sqlite3_column_bytes(m.pointer,b),d=r.sqlite3_column_blob(m.pointer,b),L=new Uint8Array(c);if(c){if(L.set(a.heap8u().slice(Number(d),Number(d)+c),0),m.db._blobXfer instanceof Array)m.db._blobXfer.push(L.buffer)}return L}default:t("Don't know how to translate","type of result column #"+b+".")}t("Not reached.")};N.checkRc=(m,b)=>U(m,b),N.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return S(this)},close:function(){let m=this.pointer;if(m){if(this.onclose?.before instanceof Function)try{this.onclose.before(this)}catch(b){}for(let b of Object.values(te.get(this)))if(b?.pointer)try{b.finalize()}catch(C){}if(M.delete(this),te.delete(this),!p.delete(this))r.sqlite3_close_v2(m);if(this.onclose?.after instanceof Function)try{this.onclose.after(this)}catch(b){}delete this.filename}},changes:function(m=!1,b=!1){let C=S(this).pointer;if(m)return b?r.sqlite3_total_changes64(C):r.sqlite3_total_changes(C);else return b?r.sqlite3_changes64(C):r.sqlite3_changes(C)},dbFilename:function(m="main"){return r.sqlite3_db_filename(S(this).pointer,m)},dbName:function(m=0){return r.sqlite3_db_name(S(this).pointer,m)},dbVfsName:function(m=0){let b,C=r.sqlite3_js_db_vfs(S(this).pointer,m);if(C){let c=new r.sqlite3_vfs(C);try{b=a.cstrToJs(c.$zName)}finally{c.dispose()}}return b},prepare:function(m){S(this);let b=a.pstack.pointer,C,c;try{C=a.pstack.alloc(8),N.checkRc(this,r.sqlite3_prepare_v2(this.pointer,m,-1,C,null)),c=a.peekPtr(C)}finally{a.pstack.restore(b)}if(!c)t("Cannot prepare empty SQL.");let d=new f(this,c,z);return te.get(this)[c]=d,d},exec:function(){S(this);let m=J(this,arguments);if(!m.sql)return t("exec() requires an SQL string.");let b=m.opt,C=b.callback,c=Array.isArray(b.resultRows)?b.resultRows:void 0,d,L=b.bind,G=!!(m.cbArg||b.columnNames||c),B=a.scopedAllocPush(),ae=Array.isArray(b.saveSql)?b.saveSql:void 0;try{let ce=_.isSQLableTypedArray(m.sql),ge=ce?m.sql.byteLength:a.jstrlen(m.sql),qe=a.scopedAlloc(2*a.ptr.size+(ge+1)),Fe=a.ptr.add(qe,a.ptr.size),Pe=a.ptr.add(Fe,a.ptr.size),Ee=a.ptr.add(Pe,ge);if(ce)a.heap8().set(m.sql,Pe);else a.jstrcpy(m.sql,a.heap8(),Pe,ge,!1);a.poke8(a.ptr.add(Pe,ge),0);while(Pe&&a.peek8(Pe)){a.pokePtr([qe,Fe],0),N.checkRc(this,r.sqlite3_prepare_v3(this.pointer,Pe,ge,0,qe,Fe));let Ue=a.peekPtr(qe);if(Pe=a.peekPtr(Fe),ge=Number(a.ptr.add(Ee,-Pe)),!Ue)continue;if(ae)ae.push(r.sqlite3_sql(Ue).trim());if(d=new f(this,Ue,z),L&&d.parameterCount)d.bind(L),L=null;if(G&&d.columnCount){let He=Array.isArray(b.columnNames)?0:1;if(G=!1,m.cbArg||c){let T=Object.create(null);for(;d.step();y.delete(d)){if(He++===0)d.getColumnNames(T.columnNames=b.columnNames||[]);y.add(d);let W=m.cbArg(d,T);if(c)c.push(W);if(C&&C.call(b,W,d)===!1)break}y.delete(d)}if(He===0)d.getColumnNames(b.columnNames)}else d.step();d.reset().finalize(),d=null}}finally{if(d)y.delete(d),d.finalize();a.scopedAllocPop(B)}return m.returnVal()},createFunction:function(b,C,c){let d=(T)=>T instanceof Function;switch(arguments.length){case 1:c=b,b=c.name,C=c.xFunc||0;break;case 2:if(!d(C))c=C,C=c.xFunc||0;break;case 3:break;default:break}if(!c)c={};if(typeof b!=="string")t("Invalid arguments: missing function name.");let L=c.xStep||0,G=c.xFinal||0,B=c.xValue||0,ae=c.xInverse||0,ce=void 0;if(d(C)){if(ce=!1,d(L)||d(G))t("Ambiguous arguments: scalar or aggregate?");L=G=null}else if(d(L)){if(!d(G))t("Missing xFinal() callback for aggregate or window UDF.");C=null}else if(d(G))t("Missing xStep() callback for aggregate or window UDF.");else t("Missing function-type properties.");if(ce===!1){if(d(B)||d(ae))t("xValue and xInverse are not permitted for non-window UDFs.")}else if(d(B)){if(!d(ae))t("xInverse must be provided if xValue is.");ce=!0}else if(d(ae))t("xValue must be provided if xInverse is.");let ge=c.pApp;if(ge!==void 0&&ge!==null&&!a.isPtr(ge))t("Invalid value for pApp property. Must be a legal WASM pointer value.");let qe=c.xDestroy||0;if(qe&&!d(qe))t("xDestroy property must be a function.");let Fe=0;if(j(c,"deterministic"))Fe|=r.SQLITE_DETERMINISTIC;if(j(c,"directOnly"))Fe|=r.SQLITE_DIRECTONLY;if(j(c,"innocuous"))Fe|=r.SQLITE_INNOCUOUS;b=b.toLowerCase();let Pe=C||L,Ee=j(c,"arity"),Ue=typeof Ee==="number"?Ee:Pe.length?Pe.length-1:0,He;if(ce)He=r.sqlite3_create_window_function(this.pointer,b,Ue,r.SQLITE_UTF8|Fe,ge||0,L,G,B,ae,qe);else He=r.sqlite3_create_function_v2(this.pointer,b,Ue,r.SQLITE_UTF8|Fe,ge||0,C,L,G,qe);return N.checkRc(this,He),this},selectValue:function(m,b,C){return ie(this,m,b,0,C)},selectValues:function(m,b,C){let c=this.prepare(m),d=[];try{D(c,0),c.bind(b);while(c.step())d.push(Se(c,0,C));c.reset()}finally{c.finalize()}return d},selectArray:function(m,b){return ie(this,m,b,[])},selectObject:function(m,b){return ie(this,m,b,{})},selectArrays:function(m,b){return le(this,m,b,"array")},selectObjects:function(m,b){return le(this,m,b,"object")},openStatementCount:function(){return this.pointer?Object.keys(te.get(this)).length:0},transaction:function(m){let b="BEGIN";if(arguments.length>1){if(/[^a-zA-Z]/.test(arguments[0]))t(r.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier.");b+=" "+arguments[0],m=arguments[1]}S(this).exec(b);try{let C=m(this);return this.exec("COMMIT"),C}catch(C){throw this.exec("ROLLBACK"),C}},savepoint:function(m){S(this).exec("SAVEPOINT oo1");try{let b=m(this);return this.exec("RELEASE oo1"),b}catch(b){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),b}},checkRc:function(m){return U(this,m)}},N.wrapHandle=function(m,b=!1){if(!m||!a.isPtr(m))throw new i.SQLite3Error(r.SQLITE_MISUSE,"Argument must be a WASM sqlite3 pointer");return new N({"sqlite3*":m,"sqlite3*:takeOwnership":!!b})};let me=function(m){if(!m.pointer)t("Stmt has been closed.");return m},K=function(m){let b=z[m===null||m===void 0?"null":typeof m];switch(b){case z.boolean:case z.null:case z.number:case z.string:return b;case z.bigint:return a.bigIntEnabled?b:void 0;default:return _.isBindableTypedArray(m)?z.blob:void 0}},oe=function(m){return K(m)||t("Unsupported bind() argument type:",typeof m)},u=function(m,b){let C=typeof b==="number"?b:r.sqlite3_bind_parameter_index(m.pointer,b);if(C===0||!_.isInt32(C))t("Invalid bind() parameter name: "+b);else if(C<1||C>m.parameterCount)t("Bind index",b,"is out of range.");return C},y=new Set,O=new Set,V=function(m,b){if(y.has(m))t("Operation is illegal when statement is locked:",b);return m},Y=function m(b,C,c,d){if(V(me(b),"bind()"),!m._)m._tooBigInt=(G)=>t("BigInt value is too big to store without precision loss:",G),m._={string:function(G,B,ae,ce){let[ge,qe]=a.allocCString(ae,!0);return(ce?r.sqlite3_bind_blob:r.sqlite3_bind_text)(G.pointer,B,ge,qe,r.SQLITE_WASM_DEALLOC)}};oe(d),C=u(b,C);let L=0;switch(d===null||d===void 0?z.null:c){case z.null:L=r.sqlite3_bind_null(b.pointer,C);break;case z.string:L=m._.string(b,C,d,!1);break;case z.number:{let G;if(_.isInt32(d))G=r.sqlite3_bind_int;else if(typeof d==="bigint")if(!_.bigIntFits64(d))m._tooBigInt(d);else if(a.bigIntEnabled)G=r.sqlite3_bind_int64;else if(_.bigIntFitsDouble(d))d=Number(d),G=r.sqlite3_bind_double;else m._tooBigInt(d);else if(d=Number(d),a.bigIntEnabled&&Number.isInteger(d))G=r.sqlite3_bind_int64;else G=r.sqlite3_bind_double;L=G(b.pointer,C,d);break}case z.boolean:L=r.sqlite3_bind_int(b.pointer,C,d?1:0);break;case z.blob:{if(typeof d==="string"){L=m._.string(b,C,d,!0);break}else if(d instanceof ArrayBuffer)d=new Uint8Array(d);else if(!_.isBindableTypedArray(d))t("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");let G=a.alloc(d.byteLength||1);a.heap8().set(d.byteLength?d:[0],Number(G)),L=r.sqlite3_bind_blob(b.pointer,C,G,d.byteLength,r.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",d),t("Unsupported bind() argument type: "+typeof d)}if(L)N.checkRc(b.db.pointer,L);return b};f.prototype={finalize:function(){let m=this.pointer;if(m){V(this,"finalize()");let b=p.delete(this)?0:r.sqlite3_finalize(m);return delete te.get(this.db)[m],M.delete(this),y.delete(this),O.delete(this),delete this.parameterCount,delete this.db,b}},clearBindings:function(){return V(me(this),"clearBindings()"),r.sqlite3_clear_bindings(this.pointer),O.delete(this),this},reset:function(m){if(V(this,"reset()"),m)this.clearBindings();let b=r.sqlite3_reset(me(this).pointer);return O.delete(this),U(this.db,b),this},resetNoThrow:function(m){if(V(this,"reset()"),m)this.clearBindings();let b=r.sqlite3_reset(me(this).pointer);return O.delete(this),b},bind:function(){me(this);let m,b;switch(arguments.length){case 1:m=1,b=arguments[0];break;case 2:m=arguments[0],b=arguments[1];break;default:t("Invalid bind() arguments.")}if(b===void 0)return this;else if(!this.parameterCount)t("This statement has no bindable parameters.");if(O.delete(this),b===null)return Y(this,m,z.null,b);else if(Array.isArray(b)){if(arguments.length!==1)t("When binding an array, an index argument is not permitted.");return b.forEach((C,c)=>Y(this,c+1,oe(C),C)),this}else if(b instanceof ArrayBuffer)b=new Uint8Array(b);if(typeof b==="object"&&!_.isBindableTypedArray(b)){if(arguments.length!==1)t("When binding an object, an index argument is not permitted.");return Object.keys(b).forEach((C)=>Y(this,C,oe(b[C]),b[C])),this}else return Y(this,m,oe(b),b);t("Should not reach this point.")},bindAsBlob:function(m,b){if(me(this),arguments.length===1)b=m,m=1;let C=oe(b);if(z.string!==C&&z.blob!==C&&z.null!==C)t("Invalid value type for bindAsBlob()");return Y(this,m,z.blob,b)},step:function(){V(this,"step()");let m=r.sqlite3_step(me(this).pointer);switch(m){case r.SQLITE_DONE:return O.delete(this),!1;case r.SQLITE_ROW:return O.add(this),!0;default:O.delete(this),i.config.warn("sqlite3_step() rc=",m,r.sqlite3_js_rc_str(m),"SQL =",r.sqlite3_sql(this.pointer)),N.checkRc(this.db.pointer,m)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{let m=this.step();return this.reset(),m}finally{try{this.finalize()}catch(m){}}},get:function(m,b){if(!O.has(me(this)))t("Stmt.step() has not (recently) returned true.");if(Array.isArray(m)){let C=0,c=this.columnCount;while(C<c)m[C]=Se(this,C,b),++C;return m}else if(m&&typeof m==="object"){let C=0,c=this.columnCount;while(C<c)m[r.sqlite3_column_name(this.pointer,C)]=Se(this,C,b),++C;return m}return D(this,m),Se(this,m,b)},getInt:function(m){return this.get(m,r.SQLITE_INTEGER)},getFloat:function(m){return this.get(m,r.SQLITE_FLOAT)},getString:function(m){return this.get(m,r.SQLITE_TEXT)},getBlob:function(m){return this.get(m,r.SQLITE_BLOB)},getJSON:function(m){let b=this.get(m,r.SQLITE_STRING);return b===null?b:JSON.parse(b)},getColumnName:function(m){return r.sqlite3_column_name(D(me(this),m).pointer,m)},getColumnNames:function(m=[]){D(me(this),0);let b=this.columnCount;for(let C=0;C<b;++C)m.push(r.sqlite3_column_name(this.pointer,C));return m},getParamIndex:function(m){return me(this).parameterCount?r.sqlite3_bind_parameter_index(this.pointer,m):void 0},getParamName:function(m){return me(this).parameterCount?r.sqlite3_bind_parameter_name(this.pointer,m):void 0},isBusy:function(){return r.sqlite3_stmt_busy(me(this))!==0},isReadOnly:function(){return r.sqlite3_stmt_readonly(me(this))!==0}};{let m={enumerable:!0,get:function(){return M.get(this)},set:()=>t("The pointer property is read-only.")};Object.defineProperty(f.prototype,"pointer",m),Object.defineProperty(N.prototype,"pointer",m)}Object.defineProperty(f.prototype,"columnCount",{enumerable:!1,get:function(){return r.sqlite3_column_count(this.pointer)},set:()=>t("The columnCount property is read-only.")}),Object.defineProperty(f.prototype,"parameterCount",{enumerable:!1,get:function(){return r.sqlite3_bind_parameter_count(this.pointer)},set:()=>t("The parameterCount property is read-only.")}),f.wrapHandle=function(m,b,C=!1){let c=f;if(!(m instanceof N)||!m.pointer)throw new i.SQLite3Error(i.SQLITE_MISUSE,"First argument must be an opened sqlite3.oo1.DB instance");if(!b||!a.isPtr(b))throw new i.SQLite3Error(i.SQLITE_MISUSE,"Second argument must be a WASM sqlite3_stmt pointer");return new f(m,b,z,!!C)},i.oo1={DB:N,Stmt:f}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=i.util;i.initWorker1API=function(){let r=(...j)=>{throw Error(j.join(" "))};if(!(globalThis.WorkerGlobalScope instanceof Function))r("initWorker1API() must be run from a Worker thread.");let a=this.sqlite3||r("Missing this.sqlite3 object."),_=a.oo1.DB,h=function(j){let U=I.idMap.get(j);if(U)return U;return U="db#"+ ++I.idSeq+":"+Math.floor(Math.random()*1e8)+":"+Math.floor(Math.random()*1e8),I.idMap.set(j,U),U},I={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function(j){let U=new _(j);if(this.dbs[h(U)]=U,this.dbList.indexOf(U)<0)this.dbList.push(U);return U},close:function(j,U){if(j){delete this.dbs[h(j)];let E=j.filename,g=t.sqlite3__wasm_db_vfs(j.pointer,0);j.close();let F=this.dbList.indexOf(j);if(F>=0)this.dbList.splice(F,1);if(U&&E&&g)t.sqlite3__wasm_vfs_unlink(g,E)}},post:function(j,U){if(U&&U.length)globalThis.postMessage(j,Array.from(U)),U.length=0;else globalThis.postMessage(j)},dbs:Object.create(null),getDb:function(j,U=!0){return this.dbs[j]||(U?r("Unknown (or closed) DB ID:",j):void 0)}},q=function(j=I.dbList[0]){return j&&j.pointer?j:r("DB is not opened.")},R=function(j,U=!0){let E=I.getDb(j.dbId,!1)||I.dbList[0];return U?q(E):E},M=function(){return I.dbList[0]&&h(I.dbList[0])},p=(j)=>j===""||j[0]===":",te={open:function(j){let U=Object.create(null),E=j.args||Object.create(null);if(E.simulateError)r("Throwing because of simulateError flag.");let g=Object.create(null);U.vfs=E.vfs,U.filename=E.filename||"";let F=I.open(U);return g.filename=F.filename,g.persistent=!!a.capi.sqlite3_js_db_uses_vfs(F.pointer,"opfs"),g.dbId=h(F),g.vfs=F.dbVfsName(),g},close:function(j){let U=R(j,!1),E={filename:U&&U.filename};if(U){let g=j.args&&typeof j.args==="object"?!!j.args.unlink:!1;I.close(U,g)}return E},exec:function(j){let U=typeof j.args==="string"?{sql:j.args}:j.args||Object.create(null);if(U.rowMode==="stmt")r("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API.");else if(!U.sql)r("'exec' requires input SQL.");let E=R(j);if(U.callback||Array.isArray(U.resultRows))E._blobXfer=I.xfer;let g=U.callback,F=0,x=!!U.columnNames;if(typeof g==="string"){if(!x)U.columnNames=[];U.callback=function(A,N){I.post({type:g,columnNames:U.columnNames,rowNumber:++F,row:A},I.xfer)}}try{let A=U.countChanges?E.changes(!0,U.countChanges===64):void 0;if(E.exec(U),A!==void 0)U.changeCount=E.changes(!0,U.countChanges===64)-A;let N=U.lastInsertRowId?a.capi.sqlite3_last_insert_rowid(E):void 0;if(N!==void 0)U.lastInsertRowId=N;if(U.callback instanceof Function)U.callback=g,I.post({type:g,columnNames:U.columnNames,rowNumber:null,row:void 0})}finally{if(delete E._blobXfer,U.callback)U.callback=g}return U},"config-get":function(){let j=Object.create(null),U=a.config;return["bigIntEnabled"].forEach(function(E){if(Object.getOwnPropertyDescriptor(U,E))j[E]=U[E]}),j.version=a.version,j.vfsList=a.capi.sqlite3_js_vfs_list(),j},export:function(j){let U=R(j),E={byteArray:a.capi.sqlite3_js_db_export(U.pointer),filename:U.filename,mimetype:"application/x-sqlite3"};return I.xfer.push(E.byteArray.buffer),E},toss:function(j){r("Testing worker exception")}};globalThis.onmessage=async function(j){j=j.data;let U,E=j.dbId,g=j.type,F=performance.now();try{if(te.hasOwnProperty(g)&&te[g]instanceof Function)U=await te[g](j);else r("Unknown db worker message type:",j.type)}catch(x){if(g="error",U={operation:j.type,message:x.message,errorClass:x.name,input:j},x.stack)U.stack=typeof x.stack==="string"?x.stack.split(/\n\s*/):x.stack}if(!E)E=U.dbId||M();I.post({type:g,dbId:E,messageId:j.messageId,workerReceivedTime:F,workerRespondTime:performance.now(),departureTime:j.departureTime,result:U},I.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}.bind({sqlite3:i})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let{wasm:t,capi:r}=i,a=i.util.toss3,_=Object.create(null);i.vfs=_,r.sqlite3_vfs.prototype.registerVfs=function(h=!1){if(!(this instanceof i.capi.sqlite3_vfs))a("Expecting a sqlite3_vfs-type argument.");let I=r.sqlite3_vfs_register(this,h?1:0);if(I)a("sqlite3_vfs_register(",this,") failed with rc",I);if(this.pointer!==r.sqlite3_vfs_find(this.$zName))a("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this);return this},_.installVfs=function(h){let I=0,q=["io","vfs"];for(let R of q){let M=h[R];if(M){if(++I,M.struct.installMethods(M.methods,!!M.applyArgcCheck),R==="vfs"){if(!M.struct.$zName&&typeof M.name==="string")M.struct.addOnDispose(M.struct.$zName=t.allocCString(M.name));M.struct.registerVfs(!!M.asDefault)}}}if(!I)a("Misuse: installVfs() options object requires at least","one of:",q);return this}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.wasm.exports.sqlite3_declare_vtab)return;let{wasm:t,capi:r}=i,a=i.util.toss3,_=Object.create(null);i.vtab=_;let h=r.sqlite3_index_info;h.prototype.nthConstraint=function(R,M=!1){if(R<0||R>=this.$nConstraint)return!1;let p=t.ptr.add(this.$aConstraint,h.sqlite3_index_constraint.structInfo.sizeof*R);return M?p:new h.sqlite3_index_constraint(p)},h.prototype.nthConstraintUsage=function(R,M=!1){if(R<0||R>=this.$nConstraint)return!1;let p=t.ptr.add(this.$aConstraintUsage,h.sqlite3_index_constraint_usage.structInfo.sizeof*R);return M?p:new h.sqlite3_index_constraint_usage(p)},h.prototype.nthOrderBy=function(R,M=!1){if(R<0||R>=this.$nOrderBy)return!1;let p=t.ptr.add(this.$aOrderBy,h.sqlite3_index_orderby.structInfo.sizeof*R);return M?p:new h.sqlite3_index_orderby(p)};let I=function(R,M){return function(p,te=!1){if(arguments.length===0)p=new M;if(p instanceof M)return this.set(p.pointer,p),p;else if(!t.isPtr(p))i.SQLite3Error.toss("Invalid argument to",R+"()");let j=this.get(p);if(te)this.delete(p);return j}.bind(new Map)},q=function(R,M){let p=I(R,M);return Object.assign(Object.create(null),{StructType:M,create:(te)=>{let j=p();return t.pokePtr(te,j.pointer),j},get:(te)=>p(te),unget:(te)=>p(te,!0),dispose:(te)=>p(te,!0)?.dispose?.()})};_.xVtab=q("xVtab",r.sqlite3_vtab),_.xCursor=q("xCursor",r.sqlite3_vtab_cursor),_.xIndexInfo=(R)=>new r.sqlite3_index_info(R),_.xError=function R(M,p,te){if(R.errorReporter instanceof Function)try{R.errorReporter("sqlite3_module::"+M+"(): "+p.message)}catch(U){}let j;if(p instanceof i.WasmAllocError)j=r.SQLITE_NOMEM;else if(arguments.length>2)j=te;else if(p instanceof i.SQLite3Error)j=p.resultCode;return j||r.SQLITE_ERROR},_.xError.errorReporter=i.config.error.bind(i.config),_.xRowid=(R,M)=>t.poke(R,M,"i64"),_.setupModule=function(R){let M=!1,p=this instanceof r.sqlite3_module?this:R.struct||(M=new r.sqlite3_module);try{let te=R.methods||a("Missing 'methods' object.");for(let j of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){let U=j[0],E=j[1];if(te[U]===!0)te[U]=te[E];else if(te[E]===!0)te[E]=te[U]}if(R.catchExceptions){let j=function(g,F){if(["xConnect","xCreate"].indexOf(g)>=0)return function(x,A,N,z,f,S){try{return F(...arguments)||0}catch(D){if(!(D instanceof i.WasmAllocError))t.dealloc(t.peekPtr(S)),t.pokePtr(S,t.allocCString(D.message));return _.xError(g,D)}};else return function(...x){try{return F(...x)||0}catch(A){return _.xError(g,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"],E=Object.create(null);for(let g of U){let F=te[g];if(!(F instanceof Function))continue;else if(g==="xConnect"&&te.xCreate===F)E[g]=te.xCreate;else if(g==="xCreate"&&te.xConnect===F)E[g]=te.xConnect;else E[g]=j(g,F)}p.installMethods(E,!1)}else p.installMethods(te,!!R.applyArgcCheck);if(p.$iVersion===0){let j;if(typeof R.iVersion==="number")j=R.iVersion;else if(p.$xIntegrity)j=4;else if(p.$xShadowName)j=3;else if(p.$xSavePoint||p.$xRelease||p.$xRollbackTo)j=2;else j=1;p.$iVersion=j}}catch(te){if(M)M.dispose();throw te}return p},r.sqlite3_module.prototype.setupModule=function(R){return _.setupModule.call(this,R)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.kvvfs)return;let t=i.capi,{sqlite3_kvvfs_methods:r,KVVfsFile:a}=t,_=i.capi.sqlite3_vfs_find("kvvfs");if(delete t.sqlite3_kvvfs_methods,delete t.KVVfsFile,!_)return;let{util:h,wasm:I}=i,q=h.toss3,R=(T,W)=>Object.prototype.hasOwnProperty.call(T,W),M=new r(I.exports.sqlite3__wasm_kvvfs_methods());h.assert(32<=M.$nKeySize,"unexpected kvvfsMethods.$nKeySize: "+M.$nKeySize);let p=Object.assign(Object.create(null),{rxJournalSuffix:/-journal$/,zKeyJrnl:I.allocCString("jrnl"),zKeySz:I.allocCString("sz"),keySize:M.$nKeySize,buffer:Object.assign(Object.create(null),{n:M.$nBufferSize,pool:Object.create(null)})});p.memBuffer=(T=0)=>p.buffer.pool[T]??=I.alloc(p.buffer.n),p.memBufferFree=(T)=>{let W=p.buffer.pool[T];if(W)I.dealloc(W),delete p.buffer.pool[T]};let te=()=>{},j=i.__isUnderTest?(...T)=>i.config.debug?.("kvvfs:",...T):te,U=(...T)=>i.config.warn?.("kvvfs:",...T),E=(...T)=>i.config.error?.("kvvfs:",...T);class g{#e=Object.create(null);#i=null;#s=0;constructor(){this.clear()}#t(){return this.#i??=Object.keys(this.#e)}key(T){if(T<0||T>=this.#s)return null;return this.#t()[T]}getItem(T){return this.#e[T]??null}setItem(T,W){if(!(T in this.#e))++this.#s,this.#i=null;this.#e[T]=""+W}removeItem(T){if(T in this.#e)delete this.#e[T],--this.#s,this.#i=null}clear(){this.#e=Object.create(null),this.#i=null,this.#s=0}get length(){return this.#s}}let F=(T)=>T==="local"||T==="session",x=(T)=>F(T)?"kvvfs-"+T+"-":"",A=function(T,W=!1){if(F(T))return;let Q=new Blob([T]).size;if(!Q)q(t.SQLITE_MISUSE,"Empty name is not permitted.");let H=p.keySize-1;if(p.rxJournalSuffix.test(T)){if(!W)q(t.SQLITE_MISUSE,"Storage names may not have a '-journal' suffix.")}else if(["-wal","-shm"].filter((_e)=>T.endsWith(_e)).length)q(t.SQLITE_MISUSE,"Storage names may not have a -wal or -shm suffix.");else H-=8;if(Q>H)q(t.SQLITE_RANGE,"Storage name is too long. Limit =",H);let se;for(se=0;se<Q;++se){let _e=T.codePointAt(se);if(_e<32)q(t.SQLITE_RANGE,"Illegal character ("+_e+"d) in storage name:",T)}},N=(T,W=void 0)=>Object.assign(Object.create(null),{jzClass:T,refc:1,deleteAtRefc0:!1,storage:W||new g,keyPrefix:x(T),files:[],listeners:void 0}),z=i.kvvfs=Object.create(null);if(i.__isUnderTest)z.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});let f=function(T){let W=p.rxJournalSuffix.test(T.jzClass)?T.jzClass.replace(p.rxJournalSuffix,""):T.jzClass+"-journal";if(z?.log?.xClose&&j("cleaning up storage handles [",T.jzClass,W,"]",T),delete p.storagePool[T.jzClass],delete p.storagePool[W],!i.__isUnderTest)delete T.storage,delete T.refc},S=(T)=>p.storagePool[T.jzClass]=p.storagePool[T.jzClass+"-journal"]=T,D=".";if(p.storagePool=Object.assign(Object.create(null),{[D]:N(D)}),globalThis.Storage){if(globalThis.localStorage instanceof globalThis.Storage)p.storagePool.local=N("local",globalThis.localStorage);if(globalThis.sessionStorage instanceof globalThis.Storage)p.storagePool.session=N("session",globalThis.sessionStorage)}p.builtinStorageNames=Object.keys(p.storagePool);let J=(T)=>p.builtinStorageNames.indexOf(T)>-1;for(let T of Object.keys(p.storagePool)){let W=p.storagePool[T];p.storagePool[T+"-journal"]=W}p.setError=(T=void 0,W=t.SQLITE_ERROR)=>{if(T)return p.lastError=T,T.resultCode|0||W;return delete p.lastError,0},p.popError=()=>{let T=p.lastError;return delete p.lastError,T};let ie=(T)=>{U("kvvfs.listener handler threw:",T)},le=I.exports.sqlite3__wasm_kvvfs_decode,Se=I.exports.sqlite3__wasm_kvvfs_encode,me=async function(T,W,...Q){try{if(W.keyPrefix&&Q[0])Q[0]=Q[0].replace(W.keyPrefix,"");let H,se,_e,de;for(let ue of W.listeners){let pe=Object.create(null);pe.storageName=W.jzClass,pe.type=T;let Le=ue.decodePages,Ce=ue.events[T];if(Ce){if(!ue.includeJournal&&Q[0]==="jrnl")continue;if(T==="write"&&ue.decodePages&&+Q[0]>0){if(pe.data=[Q[0]],de?.[Q[0]]){pe.data[1]=de[Q[0]];continue}H??=new TextEncoder("utf-8"),se??=p.memBuffer(10),_e??=p.memBuffer(11);let Ae=H.encode(Q[1]),Ne=I.heap8u();Ne.set(Ae,Number(se)),Ne[I.ptr.addn(se,Ae.length)]=0;let Re=le(se,_e,p.buffer.n);if(Re>0)de??=Object.create(null),de[Q[0]]=pe.data[1]=Ne.slice(Number(_e),I.ptr.addn(_e,Re));else continue}else pe.data=Q.length?Q.length===1?Q[0]:Q:void 0;try{Ce(pe)?.catch?.(ie)}catch(Ae){U("notifyListeners [",W.jzClass,"]",T,Ae)}}}}catch(H){ie(H)}},K=(T)=>typeof T==="string"?p.storagePool[T]:p.storagePool[I.cstrToJs(T)],oe=I.exports.sqlite3__wasm_kvvfsMakeKey,u=(T,W,Q)=>W&&T.keyPrefix?oe(W,Q):Q,y=(T,W,Q)=>I.cstrToJs(u(T,W,Q)),O=(T)=>+T.storage.getItem(T.keyPrefix+"sz"),V=new Map,Y=new Map,m=function(T,W){if(T.lockType<=W)return;let Q=Y.get(T.jzClass);if(T.lockType>t.SQLITE_LOCK_SHARED)Q.lockType=t.SQLITE_LOCK_SHARED;if(W===t.SQLITE_LOCK_NONE&&--Q.nShared===0)Y.delete(T.jzClass);T.lockType=W},b={vfs:Object.create(null),ioDb:Object.create(null),ioJrnl:Object.create(null)},C=(T)=>b[T.$isJournal?"ioJrnl":"ioDb"],c=new t.sqlite3_vfs(M.$pVfs),d=new t.sqlite3_io_methods(M.$pIoDb),L=new t.sqlite3_io_methods(M.$pIoJrnl),G=Object.create(null),B=Object.assign(Object.create(null),{pFileHandles:V,cache:p,storageForZClass:K,KVVfsStorage:g,disablePageSizeChange:!0});if(z.log)z.internal=B;let ae={recordHandler:{xRcrdRead:(T,W,Q,H)=>{try{let se=I.cstrToJs(T),_e=K(se);if(!_e)return-1;let de=y(_e,T,W);z?.log?.xRcrdRead&&U("xRcrdRead",se,de,H,_e);let ue=_e.storage.getItem(de);if(ue===null)return-1;let pe=ue.length;if(H<=0)return pe;else if(H===1)return I.poke(Q,0),pe;else if(H<pe)q(t.SQLITE_RANGE,"xRcrdRead()",se,de,"input buffer is too small: need",pe,"but have",H);else if(H>pe+1)H=pe+1;let Le=pe<H?pe:H-1,Ce=I.heap8();for(let Ae=0;Ae<Le;++Ae)Ce[I.ptr.add(Q,Ae)]=ue.codePointAt(Ae)&255;return Ce[I.ptr.add(Q,Le)]=0,Le}catch(se){return E("kvrecordRead()",se),p.setError(se),-2}},xRcrdWrite:(T,W,Q)=>{try{let H=K(T),se=y(H,T,W),_e=I.cstrToJs(Q);return z?.log?.xRcrdWrite&&U("xRcrdWrite",se,H),H.storage.setItem(se,_e),H.listeners&&me("write",H,se,_e),0}catch(H){return E("kvrecordWrite()",H),p.setError(H,t.SQLITE_IOERR)}},xRcrdDelete:(T,W)=>{try{let Q=K(T),H=y(Q,T,W);return z?.log?.xRcrdDelete&&U("xRcrdDelete",H,Q),Q.storage.removeItem(H),Q.listeners&&me("delete",Q,H),0}catch(Q){return E("kvrecordDelete()",Q),p.setError(Q,t.SQLITE_IOERR)}}},vfs:{xOpen:function(T,W,Q,H,se){p.popError();let _e;try{if(!W)_e=I.allocCString(""+Q+"."+(Math.random()*1e5|0)),W=_e;let de=I.cstrToJs(W);if(z?.log?.xOpen&&j("xOpen",de,"flags =",H),A(de,!0),H&(t.SQLITE_OPEN_MAIN_DB|t.SQLITE_OPEN_TEMP_DB|t.SQLITE_OPEN_TRANSIENT_DB)&&p.rxJournalSuffix.test(de))q(t.SQLITE_ERROR,"DB files may not have a '-journal' suffix.");let ue=K(de);if(!ue&&!(H&t.SQLITE_OPEN_CREATE))q(t.SQLITE_ERROR,"Storage not found:",de);let pe=b.vfs.xOpen(T,W,Q,H,se);if(pe)return pe;let Le=!!(t.SQLITE_OPEN_DELETEONCLOSE&H);if(I.isPtr(arguments[1])){if(t.sqlite3_uri_boolean(W,"delete-on-close",0))Le=!0}let Ce=new a(Q);if(h.assert(Ce.$zClass,"Missing f.$zClass"),Ce.addOnDispose(_e),_e=void 0,ue)++ue.refc,ue.files.push(Ce),I.poke32(se,H);else{I.poke32(se,H|t.SQLITE_OPEN_CREATE),h.assert(!Ce.$isJournal,"Opening a journal before its db? "+de);let Ae=de.replace(p.rxJournalSuffix,"");ue=N(Ae),S(ue),ue.files.push(Ce),ue.deleteAtRefc0=Le,z?.log?.xOpen&&j("xOpen installed storage handle [",Ae,Ae+"-journal","]",ue)}return V.set(Q,Object.assign(Object.create(null),{store:ue,file:Ce,jzClass:de,lockType:0})),ue.listeners&&me("open",ue,ue.files.length),0}catch(de){return U("xOpen:",de),p.setError(de)}finally{_e&&I.dealloc(_e)}},xDelete:function(T,W,Q){p.popError();try{let H=I.cstrToJs(W);if(p.rxJournalSuffix.test(H))G.xRcrdDelete(W,p.zKeyJrnl);return 0}catch(H){return U("xDelete",H),p.setError(H)}},xAccess:function(T,W,Q,H){p.popError();try{let se=K(W),_e=se?.jzClass||I.cstrToJs(W);if(z?.log?.xAccess)j("xAccess",_e,"flags =",Q,"*pResOut =",I.peek32(H),"store =",se);if(!se)try{A(_e)}catch(de){return I.poke32(H,0),0}if(se){let de=se.keyPrefix+(p.rxJournalSuffix.test(_e)?"jrnl":"1"),ue=se.storage.getItem(de)?0:1;I.poke32(H,ue)}else I.poke32(H,0);return 0}catch(se){return E("xAccess",se),p.setError(se)}},xRandomness:function(T,W,Q){let H=I.heap8u(),se=0,_e=Number(Q);for(;se<W;++se)H[_e+se]=Math.random()*255000&255;return W},xGetLastError:function(T,W,Q){let H=p.popError();if(j("xGetLastError",H),H){let se=I.scopedAllocPush();try{let[_e,de]=I.scopedAllocCString(H.message,!0);if(I.cstrncpy(Q,_e,W),de>W)I.poke8(I.ptr.add(Q,W,-1),0);return j("set xGetLastError",H.message),H.resultCode|0||t.SQLITE_IOERR}catch(_e){return t.SQLITE_NOMEM}finally{I.scopedAllocPop(se)}}return 0},xSleep:(T,W)=>0},ioDb:{xClose:function(T){p.popError();try{let W=V.get(T);if(z?.log?.xClose&&j("xClose",T,W),W){V.delete(T),m(W,t.SQLITE_LOCK_NONE);let Q=W.store;if(Q.files=Q.files.filter((H)=>H!==W.file),--Q.refc<=0&&Q.deleteAtRefc0)f(Q);b.ioDb.xClose(T),W.file.dispose(),Q.listeners&&me("close",Q,Q.files.length)}return 0}catch(W){return E("xClose",W),p.setError(W)}},xFileControl:function(T,W,Q){p.popError();try{let H=V.get(T);if(h.assert(H,"Missing KVVfsFile handle"),z?.log?.xFileControl&&j("xFileControl",H,"op =",W),W===t.SQLITE_FCNTL_PRAGMA&&B.disablePageSizeChange){let _e=I.peekPtr(I.ptr.add(Q,I.ptr.size));if(I.cstrToJs(_e)==="page_size"){z?.log?.xFileControl&&j("xFileControl pragma",I.cstrToJs(_e));let de=I.peekPtr(I.ptr.add(Q,2*I.ptr.size));if(de)return z?.log?.xFileControl&&U("xFileControl pragma",H,"NOT setting page size to",I.cstrToJs(de)),H.file.$szPage=-1,0;else if(H.file.$szPage>0)return z?.log?.xFileControl&&U("xFileControl",H,"getting page size",H.file.$szPage),I.pokePtr(Q,I.allocCString(""+H.file.$szPage)),0}}let se=b.ioDb.xFileControl(T,W,Q);if(se==0&&t.SQLITE_FCNTL_SYNC===W)H.store.listeners&&me("sync",H.store,!1);return se}catch(H){return E("xFileControl",H),p.setError(H)}},xSync:function(T,W){p.popError();try{let Q=V.get(T);z?.log?.xSync&&j("xSync",Q),h.assert(Q,"Missing KVVfsFile handle");let H=b.ioDb.xSync(T,W);if(H==0&&Q.store.listeners)me("sync",Q.store,!0);return H}catch(Q){return E("xSync",Q),p.setError(Q)}},xLock:function(T,W){p.popError();try{let Q=V.get(T);if(t.SQLITE_LOCK_NONE!==W)b.ioDb.xLock(T,W);if(Q.lockType>=W)return 0;let H=Y.get(Q.jzClass);if(!H)H=Object.assign(Object.create(null),{nShared:0,lockType:t.SQLITE_LOCK_NONE}),Y.set(Q.jzClass,H);if(Q.lockType!==H.lockType&&(H.lockType>=t.SQLITE_LOCK_PENDING||W>t.SQLITE_LOCK_SHARED))return t.SQLITE_BUSY;if(W===t.SQLITE_LOCK_SHARED){if(++H.nShared,H.lockType===t.SQLITE_LOCK_NONE)H.lockType=W}else if(W===t.SQLITE_LOCK_EXCLUSIVE&&H.nShared>1){if(Q.lockType===t.SQLITE_LOCK_RESERVED)Q.lockType=H.lockType=t.SQLITE_LOCK_PENDING;return t.SQLITE_BUSY}else H.lockType=W;return Q.lockType=W,0}catch(Q){return E("xLock",Q),p.setError(Q)}},xUnlock:function(T,W){p.popError();try{if(t.SQLITE_LOCK_NONE===W)b.ioDb.xUnlock(T,W);let Q=V.get(T);return m(Q,W),0}catch(Q){return E("xUnlock",Q),p.setError(Q)}},xCheckReservedLock:function(T,W){p.popError();try{let Q=V.get(T),H=Y.get(Q.jzClass);return I.poke32(W,!!H&&H.lockType>t.SQLITE_LOCK_SHARED?1:0),0}catch(Q){return E("xCheckReservedLock",Q),p.setError(Q)}}},ioJrnl:{xClose:!0,xLock:!0,xUnlock:!0,xCheckReservedLock:!0}};try{h.assert(p.buffer.n>132096,"Heap buffer is not large enough");for(let T of Object.entries(ae.recordHandler)){let W=T[0],Q=T[1];G[W]=Q,M[M.memberKey(W)]=I.installFunction(M.memberSignature(W),Q)}for(let T of Object.entries(ae.vfs)){let W=T[0],Q=T[1],H=c.memberKey(W),se=c.structInfo.members[W]||h.toss("Missing pVfs.structInfo[",W,"]");b.vfs[W]=I.functionEntry(c[H]),c[H]=I.installFunction(se.signature,Q)}for(let T of Object.entries(ae.ioDb)){let W=T[0],Q=T[1],H=d.memberKey(W);b.ioDb[W]=I.functionEntry(d[H])||h.toss("Missing native pIoDb[",H,"]"),d[H]=I.installFunction(d.memberSignature(W),Q)}for(let T of Object.entries(ae.ioJrnl)){let W=T[0],Q=T[1],H=L.memberKey(W);if(b.ioJrnl[W]=I.functionEntry(L[H])||h.toss("Missing native pIoJrnl[",H,"]"),Q===!0)L[H]=d[H]||h.toss("Missing copied pIoDb[",H,"]");else L[H]=I.installFunction(L.memberSignature(W),Q)}}finally{M.dispose(),c.dispose(),d.dispose(),L.dispose()}let ce=function T(W){if(W==="")return T("local")+T("session");let Q=K(W);if(!Q)return 0;if(Q.files.length)if(globalThis.localStorage===Q.storage||globalThis.sessionStorage===Q.storage);else q(t.SQLITE_ACCESS,"Cannot clear in-use database storage.");let H=Q.storage,se=[],_e,de=H.length;for(_e=0;_e<de;++_e){let ue=H.key(_e);if(!Q.keyPrefix||ue.startsWith(Q.keyPrefix))se.push(ue)}return se.forEach((ue)=>H.removeItem(ue)),se.length},ge=function T(W){if(W==="")return T("local")+T("session");let Q=K(W);if(!Q)return 0;let H=Q.storage,se,_e=0;for(se=0;se<H.length;++se){let de=H.key(se);if(!Q.keyPrefix||de.startsWith(Q.keyPrefix))_e+=de.length,_e+=H.getItem(de).length}return _e*2},qe=function(...W){let Q;if(W.length===1&&typeof W[0]==="object")Q=W[0];else if(W.length)Q=Object.assign(Object.create(null),{name:W[0]});let H=Q?K(Q.name):null;if(!H)q(t.SQLITE_NOTFOUND,"There is no kvvfs storage named",Q?.name);let se=H.storage,_e=Object.assign(Object.create(null),{name:H.jzClass,timestamp:Date.now(),pages:[]}),de=Object.create(null),ue,pe=H.keyPrefix,Le=pe?/^kvvfs-[^-]+-(\w+)/:void 0,Ce=0,Ae=se.length;for(;Ce<Ae;++Ce){let Ne=se.key(Ce);if(!pe||Ne.startsWith(pe)){let Re=(pe?Le.exec(Ne):void 0)?.[1]??Ne;switch(Re){case"jrnl":if(Q.includeJournal)_e.journal=se.getItem(Ne);break;case"sz":_e.size=+se.getItem(Ne);break;default:if(Re=+Re,!h.isInt32(Re)||Re<=0)q(t.SQLITE_RANGE,"Malformed kvvfs key: "+Ne);if(Q.decodePages){let tt=se.getItem(Ne),st=tt.length,Je=p.memBuffer(0),mt=p.memBuffer(1),gt=I.heap8u(),_t=0;for(;_t<st;++_t)gt[I.ptr.add(Je,_t)]=tt.codePointAt(_t)&255;gt[I.ptr.add(Je,_t)]=0;let Mt=le(Je,mt,p.buffer.n);de[Re]=gt.slice(Number(mt),I.ptr.addn(mt,Mt))}else de[Re]=se.getItem(Ne);break}}}if(Q.decodePages)p.memBufferFree(1);return Object.keys(de).map((Ne)=>+Ne).sort().forEach((Ne)=>_e.pages.push(de[Ne])),_e},Fe=function(T,W=!1){if(!T?.timestamp||!T.name||T.size===void 0||!Array.isArray(T.pages))q(t.SQLITE_MISUSE,"Malformed export object.");else if(!T.size||T.size!==(T.size|0)||T.size>=2147483647)q(t.SQLITE_RANGE,"Invalid db size: "+T.size);A(T.name);let Q=K(T.name),H=!Q;if(Q){if(!W)q(t.SQLITE_ACCESS,"Storage '"+T.name+"' already exists and","overwrite was not specified.");else if(!Q.files||!Q.jzClass)q(t.SQLITE_ERROR,"Internal storage object",T.name,"seems to be malformed.");else if(Q.files.length)q(t.SQLITE_IOERR_ACCESS,"Cannot import db storage while it is in use.");ce(T.name)}else Q=N(T.name);let se=x(T.name),_e;try{let de=Q.storage;if(de.setItem(se+"sz",T.size),T.journal)de.setItem(se+"jrnl",T.journal);if(T.pages[0]instanceof Uint8Array)T.pages.forEach((ue,pe)=>{let Le=ue.length;_e??=p.memBuffer(1);let Ce=p.memBuffer(0),Ae=I.heap8u();Ae.set(ue,Number(Ce)),Ae[I.ptr.addn(Ce,Le)]=0;let Ne=Se(Ce,Le,_e);h.assert(Ne<p.buffer.n,"Impossibly long output - possibly smashed the heap"),h.assert(I.peek8(I.ptr.add(_e,Ne))===0,"Expecting NUL-terminated encoded output");let Re=I.cstrToJs(_e);de.setItem(se+(pe+1),Re)});else if(T.pages[0])T.pages.forEach((ue,pe)=>de.setItem(se+(pe+1),ue));if(H)S(Q)}catch{if(!H)try{ce(T.name)}catch(de){}}finally{if(_e)p.memBufferFree(1)}return this},Pe=function(T){let W=K(T);if(W){++W.refc;return}A(T),S(N(T))},Ee=function(T){let W=K(T);if(!W||F(W.jzClass)||J(W.jzClass)||p.rxJournalSuffix.test(T))return!1;if(W.refc>W.files.length||W.files.length===0){if(--W.refc<=0)f(W);return!0}return!1},Ue=function(T){if(!T||typeof T!=="object")q(t.SQLITE_MISUSE,"Expecting a listener object.");let W=K(T.storage);if(!W)if(T.storage&&T.reserve)Pe(T.storage),W=K(T.storage),h.assert(W,"Unexpectedly cannot fetch reserved storage "+T.storage);else q(t.SQLITE_NOTFOUND,"No such storage:",T.storage);if(T.events)(W.listeners??=[]).push(T)},He=function(T){let W=K(T?.storage);if(W?.listeners&&T.events){let Q=W.listeners.length;W.listeners=W.listeners.filter((se)=>se!==T);let H=Q>W.listeners.length;if(!W.listeners.length)W.listeners=void 0;return H}return!1};if(i.kvvfs.reserve=Pe,i.kvvfs.import=Fe,i.kvvfs.export=qe,i.kvvfs.unlink=Ee,i.kvvfs.listen=Ue,i.kvvfs.unlisten=He,i.kvvfs.exists=(T)=>!!K(T),i.kvvfs.estimateSize=ge,i.kvvfs.clear=ce,globalThis.Storage)t.sqlite3_js_kvvfs_size=(T="")=>ge(T),t.sqlite3_js_kvvfs_clear=(T="")=>ce(T);if(i.oo1?.DB){let T=i.oo1.DB;i.oo1.JsStorageDb=function(Q=i.oo1.JsStorageDb.defaultStorageName){let H=T.dbCtorHelper.normalizeArgs(...arguments);switch(H.vfs="kvvfs",H.filename){case":sessionStorage:":H.filename="session";break;case":localStorage:":H.filename="local";break}let se=/(file:(\/\/)?)([^?]+)/.exec(H.filename);A(se?se[3]:H.filename),T.dbCtorHelper.call(this,H)},i.oo1.JsStorageDb.defaultStorageName=p.storagePool.session?"session":D;let W=i.oo1.JsStorageDb;W.prototype=Object.create(T.prototype),W.clearStorage=ce,W.prototype.clearStorage=function(){return W.clearStorage(this.affirmOpen().dbFilename(),!0)},W.storageSize=ge,W.prototype.storageSize=function(){return W.storageSize(this.affirmOpen().dbFilename(),!0)}}if(i.__isUnderTest&&i.vtab){let T=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(T).forEach((de,ue)=>T[de].colId=ue);let W=i.vtab,Q=Object.assign(Object.create(null),{row:function(){return p.storagePool[this.names[this.rowid]]}});Object.assign(Object.create(Q),{rowid:0,names:Object.keys(p.storagePool).filter((de)=>!p.rxJournalSuffix.test(de))});let H=function(de,ue){let pe=de instanceof t.sqlite3_vtab_cursor?de:W.xCursor.get(de);if(ue||!pe.vTabState)pe.vTabState=Object.assign(Object.create(Q),{rowid:0,names:Object.keys(p.storagePool).filter((Le)=>!p.rxJournalSuffix.test(Le))});return pe.vTabState},se=()=>{},_e=function de(){return de.mod??=new i.capi.sqlite3_module().setupModule({catchExceptions:!0,methods:{xConnect:function(ue,pe,Le,Ce,Ae,Ne){se("xConnect");try{let Re=[];Object.keys(T).forEach((st)=>{Re.push(st+" "+T[st].type)});let tt=t.sqlite3_declare_vtab(ue,"CREATE TABLE ignored("+Re.join(",")+")");if(tt===0){let st=W.xVtab.create(Ae);h.assert(st===W.xVtab.get(I.peekPtr(Ae)),"output pointer check failed")}return tt}catch(Re){return W.xError("xConnect",Re,t.SQLITE_ERROR)}},xCreate:I.ptr.null,xDisconnect:function(ue){return se("xDisconnect",...arguments),W.xVtab.dispose(ue),0},xOpen:function(ue,pe){return se("xOpen",...arguments),W.xCursor.create(pe),0},xClose:function(ue){se("xClose",...arguments);let pe=W.xCursor.unget(ue);return delete pe.vTabState,pe.dispose(),0},xNext:function(ue){se("xNext",...arguments);let pe=W.xCursor.get(ue);return++H(pe).rowid,0},xColumn:function(ue,pe,Le){se("xColumn",...arguments);let Ce=H(ue),Ae=Ce.row();switch(h.assert(Ae,"Unexpected xColumn call"),Le){case T.rowid.colId:t.sqlite3_result_int(pe,Ce.rowid);break;case T.name.colId:t.sqlite3_result_text(pe,Ae.jzClass,-1,t.SQLITE_TRANSIENT);break;case T.nRef.colId:t.sqlite3_result_int(pe,Ae.refc);break;case T.nOpen.colId:t.sqlite3_result_int(pe,Ae.files.length);break;case T.isTransient.colId:t.sqlite3_result_int(pe,!!Ae.deleteAtRefc0);break;case T.dbSize.colId:t.sqlite3_result_int(pe,O(Ae));break;default:return t.sqlite3_result_error(pe,"Invalid column id: "+Le),t.SQLITE_RANGE}return 0},xRowid:function(ue,pe){se("xRowid",...arguments);let Le=H(ue);return W.xRowid(pe,Le.rowid),0},xEof:function(ue){let pe=H(ue);return se("xEof?="+!pe.row(),...arguments),!pe.row()},xFilter:function(ue,pe,Le,Ce,Ae){se("xFilter",...arguments);let Ne=H(ue,!0);return 0},xBestIndex:function(ue,pe){se("xBestIndex",...arguments);let Le=new t.sqlite3_index_info(pe);return Le.$estimatedRows=p.storagePool.size,Le.$estimatedCost=1,Le.dispose(),0}}})};i.kvvfs.create_module=function(de,ue="sqlite_kvvfs"){return t.sqlite3_create_module(de,ue,_e(),I.ptr.null)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.opfs&&i.config.disable.vfs["opfs-vfs"])return;let t=i.util.toss,{capi:r,util:a,wasm:_}=i,h=i.opfs=Object.create(null);h.thisThreadHasOPFS=()=>globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory,h.getRootDir=async function q(){return q.promise??=navigator.storage.getDirectory().then((R)=>(h.rootDirectory=R,R)).catch((R)=>{throw delete q.promise,R})},h.getResolvedPath=function(q,R){let M=new URL(q,"file://irrelevant").pathname;return R?M.split("/").filter((p)=>!!p):M},h.getDirForFilename=async function(R,M=!1){let p=h.getResolvedPath(R,!0),te=p.pop(),j=await h.getRootDir();for(let U of p)if(U)j=await j.getDirectoryHandle(U,{create:!!M});return[j,te]},h.mkdir=async function(q){try{return await h.getDirForFilename(q+"/filepart",!0),!0}catch(R){return!1}},h.entryExists=async function(q){try{let[R,M]=await h.getDirForFilename(q);return await R.getFileHandle(M),!0}catch(R){return!1}},h.randomFilename=function q(R=16){if(!q._chars)q._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789",q._n=q._chars.length;let M=[],p=0;for(;p<R;++p){let te=Math.random()*(q._n*64)%q._n|0;M[p]=q._chars[te]}return M.join("")},h.treeList=async function(){let q=async function p(te,j){j.name=te.name,j.dirs=[],j.files=[];for await(let U of te.values())if(U.kind==="directory"){let E=Object.create(null);j.dirs.push(E),await p(U,E)}else j.files.push(U.name)},R=Object.create(null),M=await h.getRootDir();return await q(M,R),R},h.rmfr=async function(){let R=await h.getRootDir(),M={recurse:!0};for await(let p of R.values())R.removeEntry(p.name,M)},h.unlink=async function(q,R=!1,M=!1){try{let[p,te]=await h.getDirForFilename(q,!1);return await p.removeEntry(te,{recursive:R}),!0}catch(p){if(M)throw Error("unlink(",arguments[0],") failed: "+p.message,{cause:p});return!1}},h.traverse=async function(q){let R={recursive:!0,directory:await h.getRootDir()};if(typeof q==="function")q={callback:q};q=Object.assign(R,q||{}),async function p(te,j){for await(let U of te.values())if(q.callback(U,te,j)===!1)return!1;else if(q.recursive&&U.kind==="directory"){if(await p(U,j+1)===!1)break}}(q.directory,0)};let I=async function(q,R){let[M,p]=await h.getDirForFilename(q,!0),j=await(await M.getFileHandle(p,{create:!0})).createSyncAccessHandle(),U=0,E,g=!1,F=!1;try{j.truncate(0);while((E=await R())!==void 0){if(E instanceof ArrayBuffer)E=new Uint8Array(E);if(!g&&U===0&&E.byteLength>=15)a.affirmDbHeader(E),g=!0;j.write(E,{at:U}),U+=E.byteLength}if(U<512||U%512!==0)t("Input size",U,"is not correct for an SQLite database.");if(!g){let x=new Uint8Array(20);j.read(x,{at:0}),a.affirmDbHeader(x)}return j.write(new Uint8Array([1,1]),{at:18}),U}catch(x){throw await j.close(),j=void 0,await M.removeEntry(p).catch(()=>{}),x}finally{if(j)await j.close()}};h.importDb=async function(q,R){if(R instanceof Function)return I(q,R);if(R instanceof ArrayBuffer)R=new Uint8Array(R);a.affirmIsDb(R);let M=R.byteLength,[p,te]=await h.getDirForFilename(q,!0),j,U,E=0;try{if(j=await(await p.getFileHandle(te,{create:!0})).createSyncAccessHandle(),j.truncate(0),E=j.write(R,{at:0}),E!=M)t("Expected to write "+M+" bytes but wrote "+E+".");return j.write(new Uint8Array([1,1]),{at:18}),E}catch(g){if(j)await j.close(),j=void 0;throw await p.removeEntry(te).catch(()=>{}),g}finally{if(j)await j.close()}},h.vfsInstallationFeatureCheck=function(q){if(!globalThis.SharedArrayBuffer||!globalThis.Atomics)t("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");else if(typeof WorkerGlobalScope>"u")t("The OPFS sqlite3_vfs cannot run in the main thread","because it requires Atomics.wait().");else if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle?.prototype?.createSyncAccessHandle||!navigator?.storage?.getDirectory)t("Missing required OPFS APIs.");else if(q==="opfs-wl"&&!globalThis.Atomics.waitAsync)t("The",q,"VFS requires Atomics.waitAsync(), which is not available.")},h.initOptions=function(R,M){let p=new URL(globalThis.location.href).searchParams;if(p.has(R+"-disable"))return;try{h.vfsInstallationFeatureCheck(R)}catch(te){return}if(M=a.nu(M),M.vfsName=R,M.verbose??=p.has("opfs-verbose")?+p.get("opfs-verbose"):1,M.sanityChecks??=p.has("opfs-sanity-check"),!h.proxyUri){if(h.proxyUri="sqlite3-opfs-async-proxy.js",i.scriptInfo?.sqlite3Dir)h.proxyUri=i.scriptInfo.sqlite3Dir+h.proxyUri}if(M.proxyUri??=h.proxyUri,typeof M.proxyUri==="function")M.proxyUri=M.proxyUri();return h.options=M},h.createVfsState=function(){let q=a.nu(),R=h.options;q.verbose=R.verbose;let M=[i.config.error,i.config.warn,i.config.log],p=R.vfsName||t("Maintenance required: missing VFS name"),te=(K,...oe)=>{if(q.verbose>K)M[K](p+":",...oe)},j=(...K)=>te(2,...K),U=(...K)=>te(1,...K),E=(...K)=>te(0,...K),{capi:g,wasm:F}=i,x=q.vfs=new g.sqlite3_vfs,A=x.ioMethods=new g.sqlite3_io_methods;A.$iVersion=1,x.$iVersion=2,x.$szOsFile=g.sqlite3_file.structInfo.sizeof,x.$mxPathname=1024,x.$zName=F.allocCString(p),x.addOnDispose("$zName",x.$zName,A),x.metrics=a.nu({counters:a.nu(),dump:function(){let K,oe=0,u=0,y=0;for(K in q.opIds){let O=N[K];oe+=O.count,u+=O.time,y+=O.wait,O.avgTime=O.count&&O.time?O.time/O.count:0,O.avgWait=O.count&&O.wait?O.wait/O.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",N,`
|
|
3
|
+
Total of`,oe,"op(s) for",u,"ms (incl. "+y+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",x.metrics.counters.s11n),x.worker?.postMessage?.({type:"opfs-async-metrics"})},reset:function(){let K,oe=(O)=>O.count=O.time=O.wait=0,u=x.metrics.counters;for(K in q.opIds)oe(u[K]=Object.create(null));let y=u.s11n=Object.create(null);y=y.serialize=Object.create(null),y.count=y.time=0,y=u.s11n.deserialize=Object.create(null),y.count=y.time=0}}),q.asyncIdleWaitTime=150,q.asyncS11nExceptions=1,q.fileBufferSize=65536,q.sabS11nOffset=q.fileBufferSize,q.sabS11nSize=x.$mxPathname*2,q.sabIO=new SharedArrayBuffer(q.fileBufferSize+q.sabS11nSize),q.opIds=Object.create(null);{let K=0;q.opIds.whichOp=K++,q.opIds.rc=K++,q.opIds.xAccess=K++,q.opIds.xClose=K++,q.opIds.xDelete=K++,q.opIds.xDeleteNoWait=K++,q.opIds.xFileSize=K++,q.opIds.xLock=K++,q.opIds.xOpen=K++,q.opIds.xRead=K++,q.opIds.xSleep=K++,q.opIds.xSync=K++,q.opIds.xTruncate=K++,q.opIds.xUnlock=K++,q.opIds.xWrite=K++,q.opIds.mkdir=K++,q.opIds["opfs-async-metrics"]=K++,q.opIds["opfs-async-shutdown"]=K++,q.opIds.retry=K++,q.sabOP=new SharedArrayBuffer(K*4)}q.sq3Codes=Object.create(null);for(let K 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"])q.sq3Codes[K]=g[K]??t("Maintenance required: not found:",K);q.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1}),x.metrics.reset();let N=x.metrics.counters,z=x.opRun=(K,...oe)=>{let u=q.opIds[K]||t(x.vfsName+": Invalid op ID:",K);q.s11n.serialize(...oe),Atomics.store(q.sabOPView,q.opIds.rc,-1),Atomics.store(q.sabOPView,q.opIds.whichOp,u),Atomics.notify(q.sabOPView,q.opIds.whichOp);let y=performance.now();while(Atomics.wait(q.sabOPView,q.opIds.rc,-1)!=="not-equal");let O=Atomics.load(q.sabOPView,q.opIds.rc);if(N[K].wait+=performance.now()-y,O&&q.asyncS11nExceptions){let V=q.s11n.deserialize();if(V)E(K+"() async error:",...V)}return O},f=Object.create(null);f.op=void 0,f.start=void 0;let S=x.mTimeStart=(K)=>{f.start=performance.now(),f.op=K,++N[K].count},D=x.mTimeEnd=()=>N[f.op].time+=performance.now()-f.start,J=x.__openFiles=Object.create(null),ie=x.ioSyncWrappers=a.nu({xCheckReservedLock:function(K,oe){return F.poke(oe,0,"i32"),0},xClose:function(K){S("xClose");let oe=0,u=J[K];if(u){if(delete J[K],oe=z("xClose",K),u.sq3File)u.sq3File.dispose()}return D(),oe},xDeviceCharacteristics:function(K){return g.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(K,oe,u){return g.SQLITE_NOTFOUND},xFileSize:function(K,oe){S("xFileSize");let u=z("xFileSize",K);if(u==0)try{let y=q.s11n.deserialize()[0];F.poke(oe,y,"i64")}catch(y){E("Unexpected error reading xFileSize() result:",y),u=q.sq3Codes.SQLITE_IOERR}return D(),u},xRead:function(K,oe,u,y){S("xRead");let O=J[K],V;try{if(V=z("xRead",K,u,Number(y)),V===0||g.SQLITE_IOERR_SHORT_READ===V)F.heap8u().set(O.sabView.subarray(0,u),Number(oe))}catch(Y){E("xRead(",arguments,") failed:",Y,O),V=g.SQLITE_IOERR_READ}return D(),V},xSync:function(K,oe){S("xSync");let u=z("xSync",K,oe);return D(),u},xTruncate:function(K,oe){S("xTruncate");let u=z("xTruncate",K,Number(oe));return D(),u},xWrite:function(K,oe,u,y){S("xWrite");let O=J[K],V;try{O.sabView.set(F.heap8u().subarray(Number(oe),Number(oe)+u)),V=z("xWrite",K,u,Number(y))}catch(Y){E("xWrite(",arguments,") failed:",Y,O),V=g.SQLITE_IOERR_WRITE}return D(),V}}),le=x.vfsSyncWrappers={xAccess:function(K,oe,u,y){S("xAccess");let O=z("xAccess",F.cstrToJs(oe));return F.poke(y,O?0:1,"i32"),D(),0},xCurrentTime:function(K,oe){return F.poke(oe,2440587.5+new Date().getTime()/86400000,"double"),0},xCurrentTimeInt64:function(K,oe){return F.poke(oe,210866760000000+new Date().getTime(),"i64"),0},xDelete:function(K,oe,u){S("xDelete");let y=z("xDelete",F.cstrToJs(oe),u,!1);return D(),y},xFullPathname:function(K,oe,u,y){return F.cstrncpy(y,oe,u)<u?0:g.SQLITE_CANTOPEN},xGetLastError:function(K,oe,u){return i.config.warn("OPFS xGetLastError() has nothing sensible to return."),0},xOpen:function(oe,u,y,O,V){S("xOpen");let Y=0,m,b;if(!u)m=h.randomFilename(),u=b=F.allocCString(m);else if(F.isPtr(u)){if(g.sqlite3_uri_boolean(u,"opfs-unlock-asap",0))Y|=q.opfsFlags.OPFS_UNLOCK_ASAP;if(g.sqlite3_uri_boolean(u,"delete-before-open",0))Y|=q.opfsFlags.OPFS_UNLINK_BEFORE_OPEN;m=F.cstrToJs(u)}else return i.config.error("Impossible zName value in xOpen?",u),g.SQLITE_CANTOPEN;let C=a.nu({fid:y,filename:m,sab:new SharedArrayBuffer(q.fileBufferSize),flags:O,readOnly:!(g.SQLITE_OPEN_CREATE&O)&&!!(O&g.SQLITE_OPEN_READONLY)}),c=z("xOpen",y,m,O,Y);if(c){if(b)F.dealloc(b)}else{if(C.readOnly)F.poke(V,g.SQLITE_OPEN_READONLY,"i32");if(J[y]=C,C.sabView=q.sabFileBufView,C.sq3File=new g.sqlite3_file(y),b)C.sq3File.addOnDispose(b);C.sq3File.$pMethods=A.pointer,C.lockType=g.SQLITE_LOCK_NONE}return D(),c}},Se=g.sqlite3_vfs_find(null);if(Se){let K=new g.sqlite3_vfs(Se);x.$xRandomness=K.$xRandomness,x.$xSleep=K.$xSleep,K.dispose()}if(!x.$xRandomness)x.vfsSyncWrappers.xRandomness=function(K,oe,u){let y=F.heap8u(),O=0,V=Number(u);for(;O<oe;++O)y[V+O]=Math.random()*255000&255;return O};if(!x.$xSleep)x.vfsSyncWrappers.xSleep=function(K,oe){return S("xSleep"),Atomics.wait(q.sabOPView,q.opIds.xSleep,0,oe),D(),0};let me=function(){if(q.s11n)return q.s11n;let K=new TextDecoder,oe=new TextEncoder("utf-8"),u=new Uint8Array(q.sabIO,q.sabS11nOffset,q.sabS11nSize),y=new DataView(q.sabIO,q.sabS11nOffset,q.sabS11nSize);q.s11n=Object.create(null);let O=Object.create(null);O.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},O.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},O.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},O.string={id:4};let V=(m)=>O[typeof m]||t("Maintenance required: this value type cannot be serialized.",m),Y=(m)=>{switch(m){case O.number.id:return O.number;case O.bigint.id:return O.bigint;case O.boolean.id:return O.boolean;case O.string.id:return O.string;default:t("Invalid type ID:",m)}};return q.s11n.deserialize=function(m=!1){let b=performance.now(),C=u[0],c=C?[]:null;if(C){let d=[],L=1,G,B,ae;for(G=0;G<C;++G,++L)d.push(Y(u[L]));for(G=0;G<C;++G){let ce=d[G];if(ce.getter)ae=y[ce.getter](L,q.littleEndian),L+=ce.size;else B=y.getInt32(L,q.littleEndian),L+=4,ae=K.decode(u.slice(L,L+B)),L+=B;c.push(ae)}}if(m)u[0]=0;return c},q.s11n.serialize=function(...m){let b=performance.now();if(m.length){let C=[],c=0,d=1;u[0]=m.length&255;for(;c<m.length;++c,++d)C.push(V(m[c])),u[d]=C[c].id;for(c=0;c<m.length;++c){let L=C[c];if(L.setter)y[L.setter](d,m[c],q.littleEndian),d+=L.size;else{let G=oe.encode(m[c]);y.setInt32(d,G.byteLength,q.littleEndian),d+=4,u.set(G,d),d+=G.byteLength}}}else u[0]=0},q.s11n};return x.initS11n=me,x.bindVfs=function(K,oe){return Object.assign(x.ioSyncWrappers,K),new Promise(function(y,O){let V=void 0,Y=(B)=>(V=!0,x.dispose(),O(B)),m=()=>{try{oe(i,x)}catch(B){return Y(B)}return V=!1,y(i)},b=h.options,C=b.proxyUri+(b.proxyUri.indexOf("?")<0?"?":"&")+"vfs="+p,c=x.worker=new Worker(new URL(C,import.meta.url)),d=setTimeout(()=>{if(V===void 0)Y(Error("Timeout while waiting for OPFS async proxy worker."))},4000);c._originalOnError=c.onerror,c.onerror=function(B){E("Error initializing OPFS asyncer:",B),Y(Error("Loading OPFS async Worker failed for unknown reasons."))};let L=x.opRun,G=function(){let B=F.scopedAllocPush(),ae=new g.sqlite3_file;try{let ce=ae.pointer,ge=g.SQLITE_OPEN_CREATE|g.SQLITE_OPEN_READWRITE|g.SQLITE_OPEN_MAIN_DB,qe=F.scopedAlloc(8),Fe="/sanity/check/file"+h.randomFilename(8),Pe=F.scopedAllocCString(Fe),Ee;if(q.s11n.serialize("This is ä string."),Ee=q.s11n.deserialize(),j("deserialize() says:",Ee),Ee[0]!=="This is ä string.")t("String d13n error.");if(x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),j("xAccess(",Fe,") exists ?=",Ee),Ee=x.vfsSyncWrappers.xOpen(x.pointer,Pe,ce,ge,qe),j("open rc =",Ee,"state.sabOPView[xOpen] =",q.sabOPView[q.opIds.xOpen]),Ee!==0){E("open failed with code",Ee);return}if(x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),!Ee)t("xAccess() failed to detect file.");if(Ee=x.ioSyncWrappers.xSync(ae.pointer,0),Ee)t("sync failed w/ rc",Ee);if(Ee=x.ioSyncWrappers.xTruncate(ae.pointer,1024),Ee)t("truncate failed w/ rc",Ee);if(F.poke(qe,0,"i64"),Ee=x.ioSyncWrappers.xFileSize(ae.pointer,qe),Ee)t("xFileSize failed w/ rc",Ee);if(j("xFileSize says:",F.peek(qe,"i64")),Ee=x.ioSyncWrappers.xWrite(ae.pointer,Pe,10,1),Ee)t("xWrite() failed!");let Ue=F.scopedAlloc(16);Ee=x.ioSyncWrappers.xRead(ae.pointer,Ue,6,2),F.poke(Ue+6,0);let He=F.cstrToJs(Ue);if(j("xRead() got:",He),He!=="sanity")t("Unexpected xRead() value.");if(x.vfsSyncWrappers.xSleep)j("xSleep()ing before close()ing..."),x.vfsSyncWrappers.xSleep(x.pointer,2000),j("waking up from xSleep()");if(Ee=x.ioSyncWrappers.xClose(ce),j("xClose rc =",Ee,"sabOPView =",q.sabOPView),j("Deleting file:",Fe),x.vfsSyncWrappers.xDelete(x.pointer,Pe,4660),x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),Ee)t("Expecting 0 from xAccess(",Fe,") after xDelete().");U("End of OPFS sanity checks.")}finally{ae.dispose(),F.scopedAllocPop(B)}};c.onmessage=function({data:B}){switch(B.type){case"opfs-unavailable":Y(Error(B.payload.join(" ")));break;case"opfs-async-loaded":delete q.vfs,c.postMessage({type:"opfs-async-init",args:a.nu(q)});break;case"opfs-async-inited":{if(V===!0)break;clearTimeout(d),d=null;try{if(i.vfs.installVfs({io:{struct:x.ioMethods,methods:x.ioSyncWrappers},vfs:{struct:x,methods:x.vfsSyncWrappers}}),q.sabOPView=new Int32Array(q.sabOP),q.sabFileBufView=new Uint8Array(q.sabIO,0,q.fileBufferSize),q.sabS11nView=new Uint8Array(q.sabIO,q.sabS11nOffset,q.sabS11nSize),x.initS11n(),x.initS11n=null,b.sanityChecks)U("Running sanity checks because of opfs-sanity-check URL arg..."),G();if(h.thisThreadHasOPFS())h.getRootDir().then((ae)=>{c.onerror=c._originalOnError,delete c._originalOnError,j("End of OPFS sqlite3_vfs setup.",x),m()}).catch(Y);else m()}catch(ae){E(ae),Y(ae)}break}case"debug":U("debug message from worker:",B);break;default:{let ae="Unexpected message from the OPFS async worker: "+JSON.stringify(B);E(ae),Y(Error(ae));break}}}})},q}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.opfs)return;let t=i.util,r=i.opfs||i.util.toss("Missing sqlite3.opfs"),a=async function(_){if(_=r.initOptions("opfs",_),!_)return i;let h=i.capi,I=r.createVfsState(),q=I.vfs,R=q.metrics.counters,{mTimeStart:M,mTimeEnd:p,opRun:te}=q,j=(...g)=>i.config.debug("opfs:",...g),U=(...g)=>i.config.warn("opfs:",...g),E=q.__openFiles;return q.bindVfs(t.nu({xLock:function(g,F){M("xLock"),++R.xLock.count;let x=E[g],A=0;if(x.lockType)x.lockType=F;else if(A=te("xLock",g,F),A===0)x.lockType=F;return p(),A},xUnlock:function(g,F){M("xUnlock"),++R.xUnlock.count;let x=E[g],A=0;if(h.SQLITE_LOCK_NONE===F&&x.lockType)A=te("xUnlock",g,F);if(A===0)x.lockType=F;return p(),A}}),function(g,F){if(g.oo1){let x=function(...A){let N=g.oo1.DB.dbCtorHelper.normalizeArgs(...A);N.vfs=F.$zName,g.oo1.DB.dbCtorHelper.call(this,N)};x.prototype=Object.create(g.oo1.DB.prototype),g.oo1.OpfsDb=x,x.importDb=r.importDb,g.oo1.DB.dbCtorHelper.setVfsPostOpenCallback(q.pointer,function(A,N){N.capi.sqlite3_busy_timeout(A,1e4)})}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async(_)=>a().catch((h)=>{_.config.warn("Ignoring inability to install 'opfs' sqlite3_vfs:",h)}))}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.["opfs-sahpool"])return;let t=i.util.toss,r=i.util.toss3,a=Object.create(null),{capi:_,util:h,wasm:I}=i,q=4096,R=512,M=4,p=8,te=R+M,j=R,U=te,E=q,g=_.SQLITE_OPEN_MAIN_DB|_.SQLITE_OPEN_MAIN_JOURNAL|_.SQLITE_OPEN_SUPER_JOURNAL|_.SQLITE_OPEN_WAL,F=_.SQLITE_OPEN_MEMORY,x=".opaque",A=()=>Math.random().toString(36).slice(2),N=new TextDecoder,z=new TextEncoder,f=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2,forceReinitIfPreviouslyFailed:!1,preserveOnInitFailure:!1}),S=[i.config.error,i.config.warn,i.config.log],D=i.config.log,J=i.config.warn,ie=i.config.error,le=new Map,Se=(c)=>le.get(c),me=(c,d)=>{if(d)le.set(c,d);else le.delete(c)},K=new Map,oe=(c)=>K.get(c),u=(c,d)=>{if(d)K.set(c,d);else K.delete(c)},y={xCheckReservedLock:function(c,d){let L=oe(c);L.log("xCheckReservedLock"),L.storeErr();let G=L.getOFileForS3File(c);return I.poke32(d,L.hasReservedLock(G.path)?1:0),0},xClose:function(c){let d=oe(c);d.storeErr();let L=d.getOFileForS3File(c);if(L)try{if(d.log(`xClose ${L.path}`),d.unlockFile(L,_.SQLITE_LOCK_NONE),d.mapS3FileToOFile(c,!1),L.sah.flush(),L.flags&_.SQLITE_OPEN_DELETEONCLOSE)d.deletePath(L.path)}catch(G){return d.storeErr(G,_.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(c){return _.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(c,d,L){return _.SQLITE_NOTFOUND},xFileSize:function(c,d){let L=oe(c);L.log("xFileSize");let B=L.getOFileForS3File(c).sah.getSize()-E;return I.poke64(d,BigInt(B)),0},xLock:function(c,d){let L=oe(c);L.log(`xLock ${d}`),L.storeErr();let G=L.getOFileForS3File(c);return L.lockFile(G,d)},xRead:function(c,d,L,G){let B=oe(c);B.storeErr();let ae=B.getOFileForS3File(c);B.log(`xRead ${ae.path} ${L} @ ${G}`);try{let ce=ae.sah.read(I.heap8u().subarray(Number(d),Number(d)+L),{at:E+Number(G)});if(ce<L)return I.heap8u().fill(0,Number(d)+ce,Number(d)+L),_.SQLITE_IOERR_SHORT_READ;return 0}catch(ce){return B.storeErr(ce,_.SQLITE_IOERR)}},xSectorSize:function(c){return q},xSync:function(c,d){let L=oe(c);L.log(`xSync ${d}`),L.storeErr();let G=L.getOFileForS3File(c);try{return G.sah.flush(),0}catch(B){return L.storeErr(B,_.SQLITE_IOERR)}},xTruncate:function(c,d){let L=oe(c);L.log(`xTruncate ${d}`),L.storeErr();let G=L.getOFileForS3File(c);try{return G.sah.truncate(E+Number(d)),0}catch(B){return L.storeErr(B,_.SQLITE_IOERR)}},xUnlock:function(c,d){let L=oe(c);L.log("xUnlock");let G=L.getOFileForS3File(c);return L.unlockFile(G,d),0},xWrite:function(c,d,L,G){let B=oe(c);B.storeErr();let ae=B.getOFileForS3File(c);B.log(`xWrite ${ae.path} ${L} ${G}`);try{let ce=ae.sah.write(I.heap8u().subarray(Number(d),Number(d)+L),{at:E+Number(G)});return L===ce?0:t("Unknown write() failure.")}catch(ce){return B.storeErr(ce,_.SQLITE_IOERR)}}},O=new _.sqlite3_io_methods;O.$iVersion=1,i.vfs.installVfs({io:{struct:O,methods:y}});let V={xAccess:function(c,d,L,G){let B=Se(c);B.storeErr();try{let ae=B.getPath(d);I.poke32(G,B.hasFilename(ae)?1:0)}catch(ae){I.poke32(G,0)}return 0},xCurrentTime:function(c,d){return I.poke(d,2440587.5+new Date().getTime()/86400000,"double"),0},xCurrentTimeInt64:function(c,d){return I.poke(d,210866760000000+new Date().getTime(),"i64"),0},xDelete:function(c,d,L){let G=Se(c);G.log(`xDelete ${I.cstrToJs(d)}`),G.storeErr();try{return G.deletePath(G.getPath(d)),0}catch(B){return G.storeErr(B),_.SQLITE_IOERR_DELETE}},xFullPathname:function(c,d,L,G){return I.cstrncpy(G,d,L)<L?0:_.SQLITE_CANTOPEN},xGetLastError:function(c,d,L){let G=Se(c),B=G.popErr();if(G.log(`xGetLastError ${d} e =`,B),B){let ae=I.scopedAllocPush();try{let[ce,ge]=I.scopedAllocCString(B.message,!0);if(I.cstrncpy(L,ce,d),ge>d)I.poke8(I.ptr.add(L,d,-1),0)}catch(ce){return _.SQLITE_NOMEM}finally{I.scopedAllocPop(ae)}}return B?B.sqlite3Rc||_.SQLITE_IOERR:0},xOpen:function(d,L,G,B,ae){let ce=Se(d);try{B&=~F,ce.log(`xOpen ${I.cstrToJs(L)} ${B}`);let ge=L&&I.peek8(L)?ce.getPath(L):A(),qe=ce.getSAHForPath(ge);if(qe&&B&_.SQLITE_OPEN_CREATE&&B&_.SQLITE_OPEN_EXCLUSIVE)t("file already exists:",ge);if(!qe&&B&_.SQLITE_OPEN_CREATE)if(ce.getFileCount()<ce.getCapacity())qe=ce.nextAvailableSAH(),ce.setAssociatedPath(qe,ge,B);else t("SAH pool is full. Cannot create file",ge);if(!qe)t("file not found:",ge);let Fe={path:ge,flags:B,sah:qe};ce.mapS3FileToOFile(G,Fe),Fe.lockType=_.SQLITE_LOCK_NONE;let Pe=new _.sqlite3_file(G);return Pe.$pMethods=O.pointer,Pe.dispose(),I.poke32(ae,B),0}catch(ge){return ce.storeErr(ge),_.SQLITE_CANTOPEN}}},Y=function(c){if(i.capi.sqlite3_vfs_find(c))r("VFS name is already registered:",c);let d=new _.sqlite3_vfs,L=_.sqlite3_vfs_find(null),G=L?new _.sqlite3_vfs(L):null;if(d.$iVersion=2,d.$szOsFile=_.sqlite3_file.structInfo.sizeof,d.$mxPathname=R,d.addOnDispose(d.$zName=I.allocCString(c),()=>me(d.pointer,0)),G)d.$xRandomness=G.$xRandomness,G.dispose();if(!d.$xRandomness&&!V.xRandomness)V.xRandomness=function(B,ae,ce){let ge=I.heap8u(),qe=0,Fe=Number(ce);for(;qe<ae;++qe)ge[Fe+qe]=Math.random()*255000&255;return qe};return V.xSleep=(B,ae)=>0,i.vfs.installVfs({vfs:{struct:d,methods:V}}),d};class m{vfsDir;#e;#i;#s;#t=new Map;#n=new Map;#o=new Set;#c=new Map;#l=new Map;#r=new Uint8Array(te);#_;#a;#f;constructor(c=Object.create(null)){this.#f=c.verbosity??f.verbosity,this.vfsName=c.name||f.name,this.#a=Y(this.vfsName),me(this.#a.pointer,this),this.vfsDir=c.directory||"."+this.vfsName,this.#_=new DataView(this.#r.buffer,this.#r.byteOffset),this.isReady=this.reset(!!(c.clearOnInit??f.clearOnInit)).then(()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(c.initialCapacity||f.initialCapacity)})}#u(c,...d){if(this.#f>c)S[c](this.vfsName+":",...d)}log(...c){this.#u(2,...c)}warn(...c){this.#u(1,...c)}error(...c){this.#u(0,...c)}getVfs(){return this.#a}getCapacity(){return this.#t.size}getFileCount(){return this.#n.size}getFileNames(){let c=[];for(let d of this.#n.keys())c.push(d);return c}async addCapacity(c){for(let d=0;d<c;++d){let L=A(),B=await(await this.#i.getFileHandle(L,{create:!0})).createSyncAccessHandle();this.#t.set(B,L),this.setAssociatedPath(B,"",0)}return this.getCapacity()}async reduceCapacity(c){if(!Number.isSafeInteger(c)||c<0)t("Invalid capacity reduction:",c);let d=0;for(let L of Array.from(this.#o)){if(d===c||this.getFileCount()===this.getCapacity())break;let G=this.#t.get(L);L.close(),this.#t.delete(L),this.#o.delete(L),await this.#i.removeEntry(G),++d}return d}releaseAccessHandles(){for(let c of this.#t.keys())c.close();this.#t.clear(),this.#n.clear(),this.#o.clear(),this.#c.clear(),this.#l.clear()}async acquireAccessHandles(c=!1){let d=[];for await(let[B,ae]of this.#i)if(ae.kind==="file")d.push([B,ae]);let G=(await Promise.allSettled(d.map(async([B,ae])=>{let ce=await ae.createSyncAccessHandle();if(this.#t.set(ce,B),c)ce.truncate(E),this.setAssociatedPath(ce,"",0);else{let ge=this.getAssociatedPath(ce);if(ge)this.#n.set(ge,ce);else this.#o.add(ce)}}))).find((B)=>B.status==="rejected");if(G)throw this.storeErr(G.reason),this.releaseAccessHandles(),G.reason}getAssociatedPath(c){c.read(this.#r,{at:0});let d=this.#_.getUint32(j);if(this.#r[0]&&(d&_.SQLITE_OPEN_DELETEONCLOSE||(d&g)===0))return J(`Removing file with unexpected flags ${d.toString(16)}`,this.#r),this.setAssociatedPath(c,"",0),"";let L=new Uint32Array(p/4);c.read(L,{at:U});let G=this.computeDigest(this.#r,d);if(L.every((B,ae)=>B===G[ae])){let B=this.#r.findIndex((ae)=>ae===0);if(B===0)c.truncate(E);return B?N.decode(this.#r.subarray(0,B)):""}else return J("Disassociating file with bad digest."),this.setAssociatedPath(c,"",0),""}setAssociatedPath(c,d,L){let G=z.encodeInto(d,this.#r);if(R<=G.written+1)t("Path too long:",d);if(d&&L)L|=F;this.#r.fill(0,G.written,R),this.#_.setUint32(j,L);let B=this.computeDigest(this.#r,L);if(c.write(this.#r,{at:0}),c.write(B,{at:U}),c.flush(),d)this.#n.set(d,c),this.#o.delete(c);else c.truncate(E),this.#o.add(c)}computeDigest(c,d){if(d&F){let L=3735928559,G=1103547991;for(let B of c)L=Math.imul(L^B,2654435761),G=Math.imul(G^B,104729);return new Uint32Array([L>>>0,G>>>0])}else return new Uint32Array([0,0])}async reset(c){await this.isReady;let d=await navigator.storage.getDirectory(),L,G;for(let B of this.vfsDir.split("/"))if(B)L=d,d=await d.getDirectoryHandle(B,{create:!0});return this.#e=d,this.#s=L,this.#i=await this.#e.getDirectoryHandle(x,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(c)}getPath(c){if(I.isPtr(c))c=I.cstrToJs(c);return(c instanceof URL?c:new URL(c,"file://localhost/")).pathname}deletePath(c){let d=this.#n.get(c);if(d)this.#n.delete(c),this.setAssociatedPath(d,"",0);return!!d}storeErr(c,d){if(c)c.sqlite3Rc=d||_.SQLITE_IOERR,this.error(c);return this.$error=c,d}popErr(){let c=this.$error;return this.$error=void 0,c}nextAvailableSAH(){let[c]=this.#o.keys();return c}getOFileForS3File(c){return this.#c.get(c)}mapS3FileToOFile(c,d){if(d)this.#c.set(c,d),u(c,this);else this.#c.delete(c),u(c,!1)}hasFilename(c){return this.#n.has(c)}getSAHForPath(c){return this.#n.get(c)}async removeVfs(){if(!this.#a.pointer||!this.#i)return!1;_.sqlite3_vfs_unregister(this.#a.pointer),this.#a.dispose(),delete a[this.vfsName];try{this.releaseAccessHandles(),await this.#e.removeEntry(x,{recursive:!0}),this.#i=void 0,await this.#s.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#s=void 0}catch(c){i.config.error(this.vfsName,"removeVfs() failed with no recovery strategy:",c)}return!0}pauseVfs(){if(this.#c.size>0)i.SQLite3Error.toss(_.SQLITE_MISUSE,"Cannot pause VFS",this.vfsName,"because it has opened files.");if(this.#t.size>0)_.sqlite3_vfs_unregister(this.vfsName),this.releaseAccessHandles();return this}isPaused(){return this.#t.size===0}async unpauseVfs(){if(this.#t.size===0)return this.acquireAccessHandles(!1).then(()=>_.sqlite3_vfs_register(this.#a,0),this);return this}exportFile(c){let d=this.#n.get(c)||t("File not found:",c),L=d.getSize()-E,G=new Uint8Array(L>0?L:0);if(L>0){let B=d.read(G,{at:E});if(B!=L)t("Expected to read "+L+" bytes but read "+B+".")}return G}async importDbChunked(c,d){let L=this.#n.get(c)||this.nextAvailableSAH()||t("No available handles to import to.");L.truncate(0);let G=0,B,ae=!1,ce=!1;try{while((B=await d())!==void 0){if(B instanceof ArrayBuffer)B=new Uint8Array(B);if(!ae&&G===0&&B.byteLength>=15)h.affirmDbHeader(B),ae=!0;let ge=L.write(B,{at:E+G});if(ge!==B.byteLength)t("Expected to write "+B.byteLength+"bytes but wrote"+ge+".");G+=B.byteLength}if(G<512||G%512!==0)t("Input size",G,"is not correct for an SQLite database.");if(!ae){let ge=new Uint8Array(20);L.read(ge,{at:E}),h.affirmDbHeader(ge)}L.write(new Uint8Array([1,1]),{at:E+18})}catch(ge){throw this.setAssociatedPath(L,"",0),ge}return this.setAssociatedPath(L,c,_.SQLITE_OPEN_MAIN_DB),G}importDb(c,d){if(d instanceof ArrayBuffer)d=new Uint8Array(d);else if(d instanceof Function)return this.importDbChunked(c,d);h.affirmIsDb(d);let L=this.#n.get(c)||this.nextAvailableSAH()||t("No available handles to import to."),G=d.byteLength,B=L.write(d,{at:E});if(B!=G)this.setAssociatedPath(L,"",0),t("Expected to write "+G+" bytes but wrote "+B+".");else L.truncate(E+G),L.write(new Uint8Array([1,1]),{at:E+18}),this.setAssociatedPath(L,c,_.SQLITE_OPEN_MAIN_DB);return B}hasReservedLock(c){let d=this.#l.get(c);return!!d&&d.lockType>_.SQLITE_LOCK_SHARED}lockFile(c,d){if(c.lockType>=d)return 0;let L=this.#l.get(c.path);if(!L)L=Object.assign(Object.create(null),{nShared:0,lockType:_.SQLITE_LOCK_NONE}),this.#l.set(c.path,L);if(c.lockType!==L.lockType&&(L.lockType>=_.SQLITE_LOCK_PENDING||d>_.SQLITE_LOCK_SHARED))return _.SQLITE_BUSY;if(d===_.SQLITE_LOCK_SHARED){if(++L.nShared,L.lockType===_.SQLITE_LOCK_NONE)L.lockType=d}else if(d===_.SQLITE_LOCK_EXCLUSIVE&&L.nShared>1){if(c.lockType===_.SQLITE_LOCK_RESERVED)c.lockType=L.lockType=_.SQLITE_LOCK_PENDING;return _.SQLITE_BUSY}else L.lockType=d;return c.lockType=d,0}unlockFile(c,d){if(c.lockType<=d)return;let L=this.#l.get(c.path);if(c.lockType>_.SQLITE_LOCK_SHARED)L.lockType=_.SQLITE_LOCK_SHARED;if(d===_.SQLITE_LOCK_NONE&&--L.nShared===0)this.#l.delete(c.path);c.lockType=d}}class b{#e;constructor(c){this.#e=c,this.vfsName=c.vfsName}async addCapacity(c){return this.#e.addCapacity(c)}async reduceCapacity(c){return this.#e.reduceCapacity(c)}getCapacity(){return this.#e.getCapacity(this.#e)}getFileCount(){return this.#e.getFileCount()}getFileNames(){return this.#e.getFileNames()}async reserveMinimumCapacity(c){let d=this.#e.getCapacity();return d<c?this.#e.addCapacity(c-d):d}exportFile(c){return this.#e.exportFile(c)}importDb(c,d){return this.#e.importDb(c,d)}async wipeFiles(){return this.#e.reset(!0)}unlink(c){return this.#e.deletePath(c)}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()}}let C=async()=>{let c=await navigator.storage.getDirectory(),d=".opfs-sahpool-sync-check-"+A(),B=(await(await c.getFileHandle(d,{create:!0})).createSyncAccessHandle()).close();if(await B,await c.removeEntry(d),B?.then)t("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method.");return!0};i.installOpfsSAHPoolVfs=async function(c=Object.create(null)){c=Object.assign(Object.create(null),f,c||{});let d=c.name;if(c.$testThrowPhase1)throw c.$testThrowPhase1;if(a[d])try{return await a[d]}catch(G){if(c.forceReinitIfPreviouslyFailed)delete a[d];else throw G}if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!navigator?.storage?.getDirectory)return a[d]=Promise.reject(Error("Missing required OPFS APIs."));let L=(G)=>{let B=G.getVfs();if(B?.pointer)_.sqlite3_vfs_unregister(B.pointer),B.dispose(),G.releaseAccessHandles()};return a[d]=C().then(async function(){if(c.$testThrowPhase2)throw c.$testThrowPhase2;let G=new m(c);return G.isReady.then(async()=>{let B=new b(G);if(i.oo1){let ae=i.oo1,ce=G.getVfs(),ge=function(...qe){let Fe=ae.DB.dbCtorHelper.normalizeArgs(...qe);Fe.vfs=ce.$zName,ae.DB.dbCtorHelper.call(this,Fe)};ge.prototype=Object.create(ae.DB.prototype),B.OpfsSAHPoolDb=ge}return G.log("VFS initialized."),B}).catch(async(B)=>{if(c.preserveOnInitFailure)L(G);else await G.removeVfs().catch(()=>{});throw B})}).catch((G)=>a[d]=Promise.reject(G))}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.["opfs-wl"])return;let t=i.util,r=i.util.toss,a=i.opfs,_="opfs-wl",h=async function(I){if(I=a.initOptions(_,I),!I)return i;let q=i.capi,R=a.createVfsState(),M=R.vfs,p=M.metrics.counters,{mTimeStart:te,mTimeEnd:j,opRun:U}=M,E=(...x)=>i.config.debug(_+":",...x),g=(...x)=>i.config.warn(_+":",...x),F=M.__openFiles;return M.bindVfs(t.nu({xLock:function(x,A){te("xLock");let N=F[x],z=U("xLock",x,A);if(!z)N.lockType=A;return j(),z},xUnlock:function(x,A){te("xUnlock");let N=F[x],z=U("xUnlock",x,A);if(!z)N.lockType=A;return j(),z}}),function(x,A){if(x.oo1){let N=function(...z){let f=x.oo1.DB.dbCtorHelper.normalizeArgs(...z);f.vfs=A.$zName,x.oo1.DB.dbCtorHelper.call(this,f)};N.prototype=Object.create(x.oo1.DB.prototype),x.oo1.OpfsWlDb=N,N.importDb=a.importDb}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async(I)=>h().catch((q)=>{I.config.warn("Ignoring inability to install the",_,"sqlite3_vfs:",q)}))});try{let i=Object.assign(Object.create(null),{memory:typeof et<"u"?et:n.wasmMemory,exports:typeof ht<"u"?ht:Object.prototype.hasOwnProperty.call(n,"wasmExports")?n.wasmExports:n.asm},globalThis.sqlite3ApiBootstrap.defaultConfig,globalThis.sqlite3ApiConfig||{});e.debugModule("Bootstrapping lib config",i);let t=globalThis.sqlite3ApiBootstrap(i);return delete globalThis.sqlite3ApiBootstrap,t}catch(i){throw console.error("sqlite3ApiBootstrap() error:",i),i}},s}var Uc,xn;var Tn=Rc(()=>{Uc=function(){let w=zt;if(!w)throw Error("Expecting sqlite3InitModule to be defined by the Emscripten build.");let s=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(s.debugModule=s.urlParams.has("sqlite3.debugModule")?(...ne)=>console.warn("sqlite3.debugModule:",...ne):()=>{},s.urlParams.has("sqlite3.dir"))s.sqlite3Dir=s.urlParams.get("sqlite3.dir")+"/";else if(s.moduleScript){let ne=s.moduleScript.src.split("/");ne.pop(),s.sqlite3Dir=ne.join("/")+"/"}let Z=globalThis.sqlite3InitModule=function ne(...be){return s.emscriptenLocateFile=be[0]?.locateFile,s.emscriptenInstantiateWasm=be[0]?.instantiateWasm,w(...be).then((we)=>{s.debugModule("sqlite3InitModule() sIMS =",s),s.debugModule("sqlite3InitModule() EmscriptenModule =",we);let We=we.runSQLite3PostLoadInit(s,we,!!ne.__isUnderTest);return s.debugModule("sqlite3InitModule() sqlite3 =",We),We}).catch((we)=>{throw console.error("Exception loading sqlite3 module:",we),we})};if(Z.ready=w.ready,s.moduleScript){let ne=s.moduleScript.src.split("/");ne.pop(),s.scriptDir=ne.join("/")+"/"}return s.debugModule("extern-post-js.c-pp.js sqlite3InitModuleState =",s),Z}();zt=Uc;xn=zt});var wn=Promise.resolve();function Mc(){return typeof Bun>"u"?null:Bun.fetch}function jc(w){if(typeof w==="string")return w;return w instanceof URL?w.href:w.url}function Wc(w,s){return Object.assign((Z,ne)=>jc(Z).startsWith("file:")?w(Z,ne):s(Z,ne),{preconnect:s.preconnect})}function jt(w){let s=Mc();if(!s)return w();let Z=wn.then(async()=>{let ne=globalThis.fetch;globalThis.fetch=Wc(s,ne);try{return await w()}finally{globalThis.fetch=ne}});return wn=Z.then(()=>{return},()=>{return}),Z}function zc(w,s){let Z=Reflect.get(w.capi,"sqlite3mc_vfs_create");if(typeof Z!=="function")return null;let ne=Reflect.apply(Z,w.capi,[s,0]);return typeof ne==="number"?ne:null}function En(w,s){let Z=new Set(w.capi.sqlite3_js_vfs_list()),ne=zc(w,s);if(ne===null)throw Error("Persistent storage requested but the SQLite build does not provide sqlite3mc_vfs_create.");if(ne!==0)throw Error(`Failed to create the multiple-ciphers VFS over ${s} (rc=${ne}).`);let be=w.capi.sqlite3_js_vfs_list().filter((We)=>!Z.has(We)),we=be.find((We)=>We.includes(s))??be[0];if(!we)throw Error("The multiple-ciphers VFS was created but could not be located in the VFS list.");return we}function kn(w,s){let Z=Reflect.get(w.capi,"sqlite3mc_vfs_destroy");if(typeof Z!=="function")throw Error("The SQLite build does not provide sqlite3mc_vfs_destroy.");Reflect.apply(Z,w.capi,[s])}var qt=8000;class It extends Error{constructor(w){super(w);this.name="SahPoolStepTimeoutError"}}function vt(w,s){w.catch(()=>{});let Z;return Promise.race([w,new Promise((ne,be)=>{Z=setTimeout(()=>{be(new It(`SAHPool handle acquisition did not settle within ${s}ms (likely a hung createSyncAccessHandle under OPFS handle-cap contention).`))},s)})]).finally(()=>{clearTimeout(Z)})}var An="tearleads-opfs-sahpool",In="/tearleads-sqlite";function Bc(w){let s=w.trim().replace(/^\/+/u,"").replace(/[^a-zA-Z0-9_.-]+/gu,"_").replace(/^_+/u,""),Z=s.length;while(Z>0&&s[Z-1]==="_")Z-=1;let ne=s.slice(0,Z);return!ne||ne==="."||ne===".."?"default":ne}function Wt(w){let s=Bc(w);return{directory:`/tearleads-sqlite/${s}`,vfsName:`tearleads-opfs-sahpool-${s}`}}var Qc=["Missing SharedArrayBuffer and/or Atomics","The OPFS sqlite3_vfs cannot run in the main thread"],On=Symbol.for("tearleads.sqliteWorker.autoOpfsVfsWarnFilterInstalled");function Pn(w){if(typeof w==="string")return w;if(w instanceof Error)return w.message;if(typeof w==="object"&&w!==null){let s=Reflect.get(w,"message");if(typeof s==="string")return s}try{return String(w)}catch{return"[Object]"}}function Vc(w){return Qc.some((s)=>w.includes(s))}function Fn(w){if(w.length===0)return!1;let s=Pn(w[0]),Z=w.map(Pn).join(" ");return(s==="Ignoring inability to install OPFS sqlite3_vfs:"||s.includes("Ignoring inability to install OPFS sqlite3_vfs:"))&&Vc(Z)}function Ln(){if(Reflect.get(console,On)===!0||typeof console.warn!=="function")return;let w=console.warn;Reflect.set(console,"warn",(...Z)=>{if(Fn(Z))return;Reflect.apply(w,console,Z)}),Reflect.set(console,On,!0)}function Hc(w){let s=typeof w==="object"&&w!==null?w:void 0,Z=s?Reflect.get(s,"warn"):void 0,ne=(...be)=>{if(Fn(be))return;if(typeof Z==="function"){Reflect.apply(Z,s??globalThis,be);return}console.warn(...be)};return Object.assign(Object.create(null),s,{warn:ne})}function Gc(w){if(w===void 0){Reflect.deleteProperty(globalThis,"sqlite3ApiConfig");return}Reflect.set(globalThis,"sqlite3ApiConfig",w)}async function Cn(){let w=Reflect.get(globalThis,"sqlite3ApiConfig"),s=Hc(w);Reflect.set(globalThis,"sqlite3ApiConfig",s);try{await Promise.resolve().then(() => Tn());return await xn()}finally{if(Reflect.get(globalThis,"sqlite3ApiConfig")===s)Gc(w)}}function Bt(w,s){if(s.rowMode==="array"){let ne=[];return w.exec(s.sql,{...s.bind!==void 0?{bind:s.bind}:{},rowMode:"array",resultRows:ne}),ne}let Z=[];return w.exec(s.sql,{...s.bind!==void 0?{bind:s.bind}:{},rowMode:"object",resultRows:Z}),Z}var Kc=12,$c=3000,Jc=150,Xc=600;function Yc(w){return new Promise((s)=>{setTimeout(s,w)})}function Zc(w){if(typeof w!=="object"||w===null)return!1;if(Reflect.get(w,"name")==="NoModificationAllowedError")return!0;let Z=Reflect.get(w,"message");return typeof Z==="string"&&Z.includes("Access Handles cannot be created")}var Ut,Qt,ot=new Map,Vt=new WeakMap;function Nn(w){return`${w.vfsName}
|
|
4
|
+
${w.directory}`}function e_(w,s){let Z={installation:s.catch((ne)=>{if(ot.get(w)===Z)ot.delete(w);throw ne instanceof Error?ne:Error("Failed to install the persistent SQLite VFS.",{cause:ne})}),resume:null};return ot.set(w,Z),Z}async function t_(w){if(w.resume)return w.resume;let s=w.installation.then(async(Z)=>{if(Z.poolUtil.isPaused())await vt(Z.poolUtil.unpauseVfs(),qt);return Z});w.resume=s;try{return await s}finally{if(w.resume===s)w.resume=null}}async function n_(){if(Ut)return Ut;if(!Qt)Qt=jt(async()=>{let w=await Cn();return Ut=w,w});return Qt}async function r_(w,s){let Z=s?.directory??In,ne=s?.vfsName??An,be=s?.totalBudgetMs??$c,we=s?.maxDelayMs??Xc,We=s?.stepHangTimeoutMs??qt,Ve=s?.now??(()=>Date.now()),nt=Ve(),Ye=s?.initialDelayMs??Jc;for(;;)try{return await vt(w.installOpfsSAHPoolVfs({name:ne,directory:Z,clearOnInit:!1}),We)}catch(Xe){if(Xe instanceof It)throw Xe;if(!Zc(Xe))throw Xe;if(Ve()-nt+Ye>be)throw Xe;await Yc(Ye),Ye=Math.min(Ye*2,we)}}async function i_(w,s){let Z=Wt(s),ne=Nn(Z);if(typeof w.installOpfsSAHPoolVfs!=="function")throw Error("Persistent storage requested but the SQLite build does not provide installOpfsSAHPoolVfs.");let be=ot.get(ne);if(be)return t_(be);let we=(async()=>{let We=await r_(w,{directory:Z.directory,vfsName:Z.vfsName});await vt(We.reserveMinimumCapacity(Kc),qt);let Ve=En(w,We.vfsName);return{poolUtil:We,cipherVfsName:Ve,destroyCipherWrapper:()=>kn(w,Ve)}})();return e_(ne,we).installation}async function s_(w,s,Z){if(Z==="memory")return new w.oo1.DB(s);let{cipherVfsName:ne}=await i_(w,s),be=new w.oo1.DB(s,"c",ne),we=Wt(s);return Vt.set(be,Nn(we)),be}async function Dn(w){let s=await n_(),Z=w.persistence??"memory";return jt(async()=>{let ne=await s_(s,w.dbName,Z);return ne.exec(`PRAGMA cipher='${w.cipher}'`),ne.exec(`PRAGMA key='${w.key}'`),ne})}async function Rn(w,s,Z){let ne=w?Vt.get(w):void 0;try{w?.close()}catch{}if(w)Vt.delete(w);let be=ne?[ot.get(ne)]:w?[]:[...ot.values()];if(Z){if(ne)ot.delete(ne);else if(!w)ot.clear()}for(let we of be){if(!we)continue;try{await s(await(we.resume??we.installation))}catch{}}}function Mn(w){return Rn(w,(s)=>{s.poolUtil.pauseVfs()},!1)}function jn(w){return Rn(w,async(s)=>{if(s.poolUtil.isPaused())await vt(s.poolUtil.unpauseVfs(),qt);await s.poolUtil.wipeFiles(),s.destroyCipherWrapper(),await s.poolUtil.removeVfs()},!0)}function o_(w){return[w.dbName,w.persistence??"memory",w.cipher,w.key].join("\x00")}function Ht(w,s){let Z=w.queue.then(s,s);return w.queue=Z.then(()=>{return},()=>{return}),Z}class Wn{databasesByName=new Map;connectionsByName=new Map;lifecycleByName=new Map;createConnection(){let w={dbName:null,generation:0,initializing:!1};return{onInit:(s)=>this.initConnection(w,s),onExec:(s)=>this.execForConnection(w,s),onClose:()=>this.closeConnection(w),onDelete:()=>this.deleteConnection(w)}}async initConnection(w,s){if(w.dbName||w.initializing)throw Error("Database has already been initialized.");let Z=w.generation;w.initializing=!0;try{let ne=await this.acquireDatabase(s);if(w.generation!==Z||w.dbName)throw await this.releaseDatabase(ne.dbName),Error("Database connection closed before initialization completed.");w.dbName=ne.dbName,this.addConnection(ne.dbName,w)}finally{w.initializing=!1}}async execForConnection(w,s){let Z=w.dbName;if(!Z)throw Error("Database has not been initialized.");let ne=this.databasesByName.get(Z);if(!ne)throw this.detachConnection(w),Error("Database has not been initialized.");return Ht(ne,()=>Bt(ne.db,s))}async acquireDatabase(w){let{dbName:s}=w,Z=o_(w);await this.waitForLifecycle(s);let ne=this.databasesByName.get(s);if(ne)return this.attachDatabase(ne,Z);let be=await this.runLifecycle(s,async()=>{let we=this.databasesByName.get(s);if(we)return we;let Ve={db:await Dn(w),dbName:s,optionsKey:Z,refCount:0,queue:Promise.resolve()};return this.databasesByName.set(s,Ve),Ve});return this.attachDatabase(be,Z)}attachDatabase(w,s){if(w.optionsKey!==s)throw Error("Database is already initialized with different options.");return w.refCount+=1,w}async closeConnection(w){w.generation+=1;let s=this.detachConnection(w);if(s)await this.releaseDatabase(s)}async deleteConnection(w){w.generation+=1;let s=w.dbName;if(!s)return;await this.deleteDatabase(s)}async releaseDatabase(w){let s=this.databasesByName.get(w);if(!s)return;if(s.refCount=Math.max(0,s.refCount-1),s.refCount>0)return;this.databasesByName.delete(w),await this.runLifecycle(w,()=>Ht(s,()=>Mn(s.db)))}async deleteDatabase(w){let s=this.connectionsByName.get(w);if(s){for(let ne of s)ne.dbName=null,ne.generation+=1;this.connectionsByName.delete(w)}let Z=this.databasesByName.get(w);if(!Z)return;Z.refCount=0,this.databasesByName.delete(w),await this.runLifecycle(w,()=>Ht(Z,()=>jn(Z.db)))}addConnection(w,s){let Z=this.connectionsByName.get(w)??new Set;Z.add(s),this.connectionsByName.set(w,Z)}detachConnection(w){let s=w.dbName;if(w.dbName=null,!s)return null;let Z=this.connectionsByName.get(s);if(Z?.delete(w),Z?.size===0)this.connectionsByName.delete(s);return s}async waitForLifecycle(w){await this.lifecycleByName.get(w)}async runLifecycle(w,s){let ne=(this.lifecycleByName.get(w)??Promise.resolve()).then(s,s),be=ne.then(()=>{return},()=>{return});this.lifecycleByName.set(w,be);try{return await ne}finally{if(this.lifecycleByName.get(w)===be)this.lifecycleByName.delete(w)}}}function zn(){let w=new Wn;return()=>w.createConnection()}var Bn="tearleads:sqlite-connect-port",Un="tearleads:sqlite-disconnect-port",Qn="tearleads:sqlite-port-disconnected";function a_(w){if(typeof w!=="object"||w===null)return!1;let s=Reflect.get(w,"id"),Z=Reflect.get(w,"method");return typeof s==="number"&&(Z==="ping"||Z==="init"||Z==="exec"||Z==="close"||Z==="delete")}function Gt(w,s={}){let Z=async(ne)=>{let be=ne.data;if(!a_(be))return;try{let we=await l_(be,s);w.postMessage(we)}catch(we){w.postMessage({id:be.id,result:{ok:!1,message:we instanceof Error?we.message:String(we)}})}};return w.addEventListener("message",Z),()=>w.removeEventListener?.("message",Z)}async function l_(w,s){switch(w.method){case"ping":return{id:w.id,result:{ok:!0,message:"pong"}};case"init":return await s.onInit?.(w.params),{id:w.id,result:{ok:!0}};case"exec":return{id:w.id,result:{ok:!0,rows:await s.onExec?.(w.params)??[]}};case"close":return await s.onClose?.(),{id:w.id,result:{ok:!0}};case"delete":return await s.onDelete?.(),{id:w.id,result:{ok:!0}}}}function Hn(w){return typeof w==="object"&&w!==null&&typeof Reflect.get(w,"addEventListener")==="function"}function Gn(w){return Hn(w)&&typeof Reflect.get(w,"postMessage")==="function"}function Kn(w){return Gn(w)&&typeof Reflect.get(w,"removeEventListener")==="function"}function c_(w){return typeof w==="function"?w:()=>w}function __(w){return{addEventListener(s,Z){w.addEventListener(s,(ne)=>{if(ne instanceof MessageEvent)Z(ne)})},postMessage(s){w.postMessage(s)}}}function u_(w){let s=new Map;return{addEventListener(Z,ne){let be=(we)=>{ne(we)};s.set(ne,be),w.addEventListener(Z,be)},postMessage(Z){w.postMessage(Z)},removeEventListener(Z,ne){let be=s.get(ne);if(!be)return;s.delete(ne),w.removeEventListener(Z,be)}}}function f_(w){return typeof w==="object"&&w!==null&&Reflect.get(w,"type")===Un}function Vn(w,s){let Z=!1,ne=!1,be=async(nt)=>{await s.onInit?.(nt),ne=!1},we=()=>{if(ne)return;return ne=!0,s.onClose?.()},We=Gt(u_(w),{...s,onInit:be,onClose:we}),Ve=(nt)=>{if(Z||!f_(nt.data))return;Z=!0,We(),w.removeEventListener("message",Ve);let Ye=()=>{try{w.postMessage({type:Qn})}catch{}try{w.close()}catch{}};Promise.resolve().then(we).then(Ye,Ye)};w.addEventListener("message",Ve),w.start?.()}function d_(w){let s=w.data;if(typeof s!=="object"||s===null||Reflect.get(s,"type")!==Bn)return null;let Z=Reflect.get(w,"ports"),ne=Array.isArray(Z)?Z[0]:null;return Kn(ne)?ne:null}function $n(w={}){let s=c_(w),Z=self;if(Gn(Z))Z.addEventListener("message",(ne)=>{if(!(ne instanceof MessageEvent))return;let be=d_(ne);if(!be)return;Vn(be,s())}),Gt(__(Z),s());if(!Hn(Z))return;Z.addEventListener("connect",(ne)=>{let be=Reflect.get(ne,"ports"),we=Array.isArray(be)?be[0]:null;if(!Kn(we))return;Vn(we,s())})}Ln();$n(zn());
|